package me.vudu.Conflict;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import me.vudu.Conflict.Blocks.ArtifactBlock;
import me.vudu.Conflict.Blocks.BaseBlock;
import me.vudu.Conflict.Blocks.DamageTowerBlock;
import me.vudu.Conflict.Blocks.DefenseTowerBlock;
import me.vudu.Conflict.Blocks.RadarBlock;
import me.vudu.Conflict.Blocks.VirusBlock;
import me.vudu.Conflict.Blocks.VuduBrick;
import me.vudu.Conflict.Handlers.CommandHandler;
import me.vudu.Conflict.Handlers.ConfigHandler;
import me.vudu.Conflict.Handlers.RecipeManager;
import me.vudu.Conflict.Listeners.BlockListener;
import me.vudu.Conflict.Listeners.DoorListener;
import me.vudu.Conflict.Listeners.HungerListener;
import me.vudu.Conflict.Listeners.PlayerLoginListener;
import me.vudu.Conflict.Listeners.TeamChoiceScreenListener;
import me.vudu.Conflict.Listeners.VuduBrickListener;
import me.vudu.Conflict.Listeners.Skills.SkillKeyListener;
import me.vudu.Conflict.Listeners.Skills.PlayerKillEntityListener;
import me.vudu.Conflict.Listeners.Skills.PlayerSkillCraftListener;
import me.vudu.Conflict.Listeners.Skills.PlayerSkillFightListener;
import me.vudu.Conflict.Listeners.Skills.PlayerSkillFoodListener;
import me.vudu.Conflict.Listeners.Skills.PlayerSkillMineListener;
import me.vudu.Conflict.Listeners.Skills.SkillScreenListener;
import me.vudu.Conflict.Listeners.Xp.XpListener;
import me.vudu.Conflict.Runnables.BaseLocationUpdateRunnable;
import me.vudu.Conflict.Runnables.BlockUpdateRunnable;
import me.vudu.Conflict.Runnables.HungerUpdateRunnable;
import me.vudu.Conflict.Runnables.LoggerRunnable;
import me.vudu.Conflict.Runnables.PlayerHealerRunnable;
import me.vudu.Conflict.Runnables.PlayerLocationUpdateRunnable;
import me.vudu.Conflict.Runnables.TeamnameBackupRunnable;
import me.vudu.Conflict.Runnables.VirusRunnable;
import me.vudu.Conflict.Runnables.Skills.PlayerRegenerationRunnable;
import me.vudu.Conflict.util.BlockLocation;
import me.vudu.Conflict.util.ConflictLogger;
import me.vudu.Conflict.util.PluginSerializer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.gui.GenericLabel;
import org.getspout.spoutapi.gui.GenericTexture;
import org.getspout.spoutapi.gui.WidgetAnchor;
import org.getspout.spoutapi.inventory.SpoutItemStack;
import org.getspout.spoutapi.material.CustomBlock;
import org.getspout.spoutapi.player.SpoutPlayer;
public class ConflictPlugin extends JavaPlugin {
public static final int ARTIFACTBLOCKID = 110;
public static final int BASEBLOCKID = 112;
public static final int DAMAGETOWERBLOCKID = 113;
public static final int DEFENSETOWERBLOCKID = 114;
public static final int RADARBLOCKID = 121;
public static final int VUDUBRICKID = 48;
public static final int VIRUSBLOCKID = 110;
public static HashMap<BlockLocation, Long> timestampOverflows;
public static boolean blocked = false;
public static boolean isCoop = false;
public static int spawnX=0;
public static int spawnZ=0;
// Variable f�r den Hunger
public static int hungerPerTime = 0;
public static float hungerDecreaseMultiplicator = 1;
public static int hungerIncreaseMultiplicator = 1;
public static long hungerIntervallTicks = 1200;
public static long hungerDelayTicks = 6000;
public static int isInBaseBuild = 50;
public static int isInBaseDamage = 100;
public static int isInBaseHighDamage = 15;
public static int virusDistance = 25;
public static boolean virusPlaced = false;
public static int artRed = 0;
public static int artBlue = 0;
public static int damageTowerRed = 0;
public static int damageTowerBlue = 0;
public static int defenseTowerRed = 0;
public static int defenseTowerBlue = 0;
public static int radarTowerRed = 0;
public static int radarTowerBlue = 0;
public static int campingBaseDamage = 1;
public static int campingDamageIntervall = 50; // in ticks
public static int defenseHealIntervall = 100; // in ticks
public static int skillRegenerationIntervall = 30; // in s
public static double skillRun1 = 1.2;
public static double skillRun2 = 1.4;
public static double skillSwim1 = 1.2;
public static double skillSwim2 = 1.4;
public static double skillJump = 1.5;
public static int artSpeedupMax = 6;
// variablen f�r Bl�cke
public static boolean allowDestroyBaseBlock = false;
public static int blockGrowTime = 60;
public static long blockUpdateTicks = 200;
public static int minBBHeight = 50;
public static int maxBBHeight = 70;
public static float artBlockHardness = 0.2f;
public static float vuduBrickHardness = 50.0f;
public static float deffBlockHardness = 20.0f;
public static boolean allowBBB = true;
public static boolean allowBBR = true;
public static int damageTreshold = 1000;
// explosion bei Spielende
public static int explosionRange = 60;
// Zeitstempel f�r server down und server up
public static long serverCloseTimestamp = 0;
public static long serverOpenTimestamp = 0;
// Liste aller Spieler
public static ArrayList<SpoutPlayer> players;
public static ArrayList<SpoutPlayer> playersRed;
public static ArrayList<SpoutPlayer> playersBlue;
// Labels
// public static HashMap<SpoutPlayer, GenericLabel> playerPosLabels;
public static HashMap<SpoutPlayer, GenericLabel> redBaseLabels;
public static HashMap<SpoutPlayer, GenericLabel> blueBaseLabels;
public static HashMap<SpoutPlayer, GenericLabel> damageLabels;
public static HashMap<SpoutPlayer, GenericLabel> artNumberLabelsRed;
public static HashMap<SpoutPlayer, GenericLabel> artNumberLabelsBlue;
// Texturen f�r Pfeile zugeordnet zu Players
public static HashMap<SpoutPlayer, GenericTexture> arrowTopRed;
public static HashMap<SpoutPlayer, GenericTexture> arrowBotRed;
public static HashMap<SpoutPlayer, GenericTexture> arrowLeftRed;
public static HashMap<SpoutPlayer, GenericTexture> arrowRightRed;
public static HashMap<SpoutPlayer, GenericTexture> arrowTopBlue;
public static HashMap<SpoutPlayer, GenericTexture> arrowBotBlue;
public static HashMap<SpoutPlayer, GenericTexture> arrowLeftBlue;
public static HashMap<SpoutPlayer, GenericTexture> arrowRightBlue;
public static HashMap<SpoutPlayer, GenericTexture> alarmLamps;
public static HashMap<SpoutPlayer, GenericTexture> enemyBaseLamps;
public static HashMap<SpoutPlayer, GenericTexture> ownBaseLamps;
public static HashMap<SpoutPlayer, Boolean> showArrowRed;
public static HashMap<SpoutPlayer, Boolean> showArrowBlue;
public static HashMap<SpoutPlayer, Integer> playerDamage;
public static HashMap<String, Integer> damageTresholdForPlayer;
public static HashMap<String, Integer> totalXP;
public static HashMap<String, Integer> totalCoal;
public static HashMap<String, Integer> totalIron;
public static HashMap<String, Integer> totalGold;
public static HashMap<String, Integer> totalDiamond;
public static HashMap<String, Integer> totalLapis;
public static HashMap<String, Integer> totalRedstone;
public static HashMap<String, Integer> totalWheat;
public static HashMap<String, Integer> totalMushroom;
public static HashMap<String, Integer> totalGiantMushroom;
public static HashMap<String, Integer> totalAnimal;
public static HashMap<String, Integer> totalFish;
public static HashMap<String, Integer> totalMobs;
public static HashMap<String, Integer> totalCrafted;
public static HashMap<String, Integer> totalArt1;
public static HashMap<String, Integer> totalArt2;
public static HashMap<String, String> totalSkills;
public static HashMap<String, Integer> skillFightSpeedLand;
public static HashMap<String, Integer> skillFightSpeedWater;
public static HashMap<String, Integer> skillFightJump;
public static HashMap<String, Integer> skillFightMonsters;
public static HashMap<String, Integer> skillFightCamp;
public static HashMap<String, Integer> skillFightRegeneration;
public static HashMap<String, Integer> skillFightDamage;
public static HashMap<String, Integer> skillFightArmor;
public static HashMap<String, Integer> skillFightDrop;
public static HashMap<String, Integer> skillCraftQual;
public static HashMap<String, Integer> skillCraftArmor;
public static HashMap<String, Integer> skillCraftBow;
public static HashMap<String, Integer> skillCraftSword;
public static HashMap<String, Integer> skillCraftTool;
public static HashMap<String, Integer> skillMineDurab;
public static HashMap<String, Integer> skillMineClay;
public static HashMap<String, Integer> skillMineGold;
public static HashMap<String, Integer> skillMineLapis;
public static HashMap<String, Integer> skillMineDiamond;
public static HashMap<String, Integer> skillMineIron;
public static HashMap<String, Integer> skillMineRedstone;
public static HashMap<String, Integer> skillFoodSeed;
public static HashMap<String, Integer> skillFoodHarvest;
public static HashMap<String, Integer> skillFoodBone;
public static HashMap<String, Integer> skillFoodCow;
public static HashMap<String, Integer> skillFoodChicken;
public static HashMap<String, Integer> skillFoodFish;
public static HashMap<String, Integer> skillFoodPork;
public static HashMap<String, Integer> armorPlate;
public static HashMap<String, Integer> armorLeggins;
public static HashMap<BlockLocation, Boolean> is5Locations;
// Container f�r Listener
//public static ArrayList<Listener> listeners;
// Container f�r Artefakt-WachstumsStufenBl�cke
public static HashMap<Integer, ArtifactBlock> artifact1Grow;
public static HashMap<Integer, ArtifactBlock> artifact2Grow;
public static HashMap<Integer, ArtifactBlock> artifact3Grow;
// Container zum Speichern der Locations roter bzw blauer BaseBl�cke
public static ArrayList<BlockLocation> baseBlocksRed;
public static ArrayList<BlockLocation> baseBlocksBlue;
// Container f�r alle Artefakt-Blockarten
public static ArrayList<ArtifactBlock> allArtifacts;
// Base-Blockarten
public static CustomBlock vuduBrick;
public static CustomBlock baseBlockRed;
public static CustomBlock baseBlockBlue;
public static CustomBlock damageTower;
public static CustomBlock defenseTower;
public static CustomBlock radarTower;
public static CustomBlock virusBlock;
// Artefakt-Blockarten
public static CustomBlock art_1_1;
public static CustomBlock art_1_2;
public static CustomBlock art_1_3;
public static CustomBlock art_1_4;
public static CustomBlock art_1_5;
public static CustomBlock art_2_1;
public static CustomBlock art_2_2;
public static CustomBlock art_2_3;
public static CustomBlock art_2_4;
public static CustomBlock art_2_5;
public static CustomBlock art_3_1;
public static CustomBlock art_3_2;
public static CustomBlock art_3_3;
public static CustomBlock art_3_4;
public static CustomBlock art_3_5;
// Loations der Basen
public static BlockLocation redBase;
public static BlockLocation blueBase;
public static ArrayList<BlockLocation> doorsRed;
public static ArrayList<BlockLocation> doorsBlue;
public static ArrayList<BlockLocation> contaminated;
public static SpoutItemStack[] drops;
public ConfigHandler configHandler;
/**
* wird aufgerufen wenn der Server runtergefahren wird
*/
public void onDisable() {
configHandler.save();
ConflictLogger.getLogger().logXP();
ConflictLogger.getLogger().logSkills();
ConflictLogger.getLogger().logGeneric("Animals", ConflictPlugin.totalAnimal);
ConflictLogger.getLogger().logGeneric("Fish", ConflictPlugin.totalFish);
ConflictLogger.getLogger().logGeneric("Mobs", ConflictPlugin.totalMobs);
ConflictLogger.getLogger().logGeneric("Crafted", ConflictPlugin.totalCrafted);
ConflictLogger.getLogger().logGeneric("Coal", ConflictPlugin.totalCoal);
ConflictLogger.getLogger().logGeneric("Diamond", ConflictPlugin.totalDiamond);
ConflictLogger.getLogger().logGeneric("Gold", ConflictPlugin.totalGold);
ConflictLogger.getLogger().logGeneric("Iron", ConflictPlugin.totalIron);
ConflictLogger.getLogger().logGeneric("Lapis", ConflictPlugin.totalLapis);
ConflictLogger.getLogger().logGeneric("Redstone", ConflictPlugin.totalRedstone);
ConflictLogger.getLogger().logGeneric("Mushroom", ConflictPlugin.totalMushroom);
ConflictLogger.getLogger().logGeneric("Huge Mushroom", ConflictPlugin.totalGiantMushroom);
ConflictLogger.getLogger().logGeneric("Wheat", ConflictPlugin.totalWheat);
ConflictLogger.getLogger().logGeneric("Art1", ConflictPlugin.totalArt1);
ConflictLogger.getLogger().logGeneric("Art2", ConflictPlugin.totalArt2);
//fertig
Bukkit.getLogger().log(Level.INFO, "[Conflict Plugin] Disabled!");
}
/**
* wird aufgerufen wenn der Server gestartet wird
*/
public void onEnable() {
ConflictPlugin.serverOpenTimestamp = System.currentTimeMillis();
// Variablen initialisieren
initVariables();
// Config laden
configHandler.loadConfig();
// Bl�cke initialisieren
initBlocks();
// Listener erzeugen
initListeners();
// Rezepte bekannt machen
RecipeManager.addRecipes();
// l�dt BaseBlocks
loadBaseBlocks();
// l�dt Eisent�ren
loadDoors();
loadIs5Locations();
loadSkills();
// l�dt timestamps
loadTimestamps();
// Scheduler anwerfen
initSchedulers();
// getServer().getPluginManager().registerEvent(Event.Type.CUSTOM_EVENT, new SpoutMeasureScreenListener(this), Priority.Normal, this);
loadLoggingStats();
//loadTotalSkills();
for(String s : ConflictPlugin.totalWheat.keySet()){
Bukkit.getLogger().log(Level.INFO, s+": "+ConflictPlugin.totalWheat.get(s));
}
setWorldSpawn();
// Plugin geladen!
Bukkit.getLogger().log(Level.INFO, "[Conflict Plugin] Enabled!");
}
public static void setWorldSpawn() {
World w = Bukkit.getServer().getWorlds().get(0);
int x = ConflictPlugin.spawnX;
int z = ConflictPlugin.spawnZ;
w.setSpawnLocation(x, w.getHighestBlockYAt(x,z)+1, z);
}
/**
* initialisiert alle Scheduler (die wiederkehrende AUfgaben anstossen)
*/
private void initSchedulers() {
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new BlockUpdateRunnable(),
ConflictPlugin.blockUpdateTicks, ConflictPlugin.blockUpdateTicks);
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new HungerUpdateRunnable(),
ConflictPlugin.hungerDelayTicks, ConflictPlugin.hungerIntervallTicks);
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new BaseLocationUpdateRunnable(), 2L, 2L);
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new PlayerLocationUpdateRunnable(),
ConflictPlugin.campingDamageIntervall, ConflictPlugin.campingDamageIntervall);
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new TeamnameBackupRunnable(), 200L, 200L); // ((alle 10s))
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new PlayerHealerRunnable(), 40L, 40L); // ((alle 2s))
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new VirusRunnable(this), 4L, 4L); // ((alle 0.2s))
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new PlayerRegenerationRunnable(),
20 * ConflictPlugin.skillRegenerationIntervall, 20 * ConflictPlugin.skillRegenerationIntervall);
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new LoggerRunnable(), 1200L, 1200L); //1x pro Minute
}
/**
* veranlasst Timestamp update nach Server-Neustart
*
* @param serverClose
* TS des Server down
* @param serverOpen
* TS des Server wieder up
*/
private void updateTimestamps(long serverClose, long serverOpen) {
for (ArtifactBlock ab : ConflictPlugin.allArtifacts) {
ab.updateTimestamps(serverClose, serverOpen);
}
}
/**
* Commands definieren -> ausgelagert in den CommandHandler
*/
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return CommandHandler.onCommand(sender, command, label, args);
}
/**
* pr�ft Siegbedingung
*
* @param block
* Block, der Stufe 3, der lange genug auf der h�chsten Wachstumsstufe war
*/
public static void checkWin(org.bukkit.block.Block block) {
boolean redwin = false;
boolean bluewin = false;
Location l = new Location(block.getWorld(), block.getX(), block.getY() - 1, block.getZ());
for (BlockLocation loc : ConflictPlugin.baseBlocksRed) {
if (ConflictPlugin.compareLocaction(loc, l)) {
redwin = true;
break;
}
}
for (BlockLocation loc : ConflictPlugin.baseBlocksBlue) {
if (ConflictPlugin.compareLocaction(loc, l)) {
bluewin = true;
break;
}
}
if (redwin) {
Bukkit.getServer().broadcastMessage("Team RED Wins!!!");
for (SpoutPlayer p : ConflictPlugin.players) {
p.sendNotification("SIEG!", "Team ROT gewinnt!", Material.CAKE, (short) 0, 10000);
}
BlockLocation exp = null;
for (BlockLocation loc : ConflictPlugin.baseBlocksBlue) {
block.getWorld().getBlockAt(loc.getX(), loc.getY(), loc.getZ()).setTypeId(3);
exp = loc;
}
try {
block.getWorld().createExplosion(
block.getWorld().getBlockAt(exp.getX(), exp.getY(), exp.getZ()).getLocation(),
ConflictPlugin.explosionRange);
} catch (NullPointerException e) { //keine Basis da
}
}
if (bluewin) {
Bukkit.getServer().broadcastMessage("Team BLUE Wins!!!");
for (SpoutPlayer p : ConflictPlugin.players) {
p.sendNotification("SIEG!", "Team BLAU gewinnt!", Material.CAKE, (short) 0, 10000);
}
BlockLocation exp = null;
for (BlockLocation loc : ConflictPlugin.baseBlocksRed) {
block.getWorld().getBlockAt(loc.getX(), loc.getY(), loc.getZ()).setTypeId(3);
exp = loc;
}
try {
block.getWorld().createExplosion(
block.getWorld().getBlockAt(exp.getX(), exp.getY(), exp.getZ()).getLocation(),
ConflictPlugin.explosionRange);
} catch (NullPointerException e) {
}
}
}
/**
* vergelicht zwei Locations
*
* @param l1
* erste Location
* @param l2
* zweite Location
* @return true, falls x,y,z �bereinstimmen, false sonst
*/
public static boolean compareLocaction(Location l1, Location l2) {
if (l1.getBlockX() == l2.getBlockX() && l1.getBlockY() == l2.getBlockY() && l1.getBlockZ() == l2.getBlockZ()
&& l1.getWorld() == l2.getWorld()) {
return true;
}
return false;
}
/**
* vergelicht zwei Locations
*
* @param l1
* erste Location
* @param l2
* zweite Location
* @return true, falls x,y,z �bereinstimmen, false sonst
*/
public static boolean compareLocaction(BlockLocation l1, Location l2) {
if (l1.getX() == l2.getBlockX() && l1.getY() == l2.getBlockY() && l1.getZ() == l2.getBlockZ()
&& l1.getWorld().equals(l2.getWorld().getName())) {
return true;
}
return false;
}
/**
* initialisiert alle Variablen
*/
private void initVariables() {
drops = new SpoutItemStack[9];
players = new ArrayList<SpoutPlayer>();
playersRed = new ArrayList<SpoutPlayer>();
playersBlue = new ArrayList<SpoutPlayer>();
doorsRed = new ArrayList<BlockLocation>();
doorsBlue = new ArrayList<BlockLocation>();
timestampOverflows = new HashMap<BlockLocation, Long>();
// playerPosLabels = new HashMap<SpoutPlayer, GenericLabel>();
redBaseLabels = new HashMap<SpoutPlayer, GenericLabel>();
blueBaseLabels = new HashMap<SpoutPlayer, GenericLabel>();
damageLabels = new HashMap<SpoutPlayer, GenericLabel>();
artNumberLabelsRed = new HashMap<SpoutPlayer, GenericLabel>();
artNumberLabelsBlue = new HashMap<SpoutPlayer, GenericLabel>();
arrowTopRed = new HashMap<SpoutPlayer, GenericTexture>();
arrowBotRed = new HashMap<SpoutPlayer, GenericTexture>();
arrowLeftRed = new HashMap<SpoutPlayer, GenericTexture>();
arrowRightRed = new HashMap<SpoutPlayer, GenericTexture>();
arrowTopBlue = new HashMap<SpoutPlayer, GenericTexture>();
arrowBotBlue = new HashMap<SpoutPlayer, GenericTexture>();
arrowLeftBlue = new HashMap<SpoutPlayer, GenericTexture>();
arrowRightBlue = new HashMap<SpoutPlayer, GenericTexture>();
alarmLamps = new HashMap<SpoutPlayer, GenericTexture>();
enemyBaseLamps = new HashMap<SpoutPlayer, GenericTexture>();
ownBaseLamps = new HashMap<SpoutPlayer, GenericTexture>();
showArrowRed = new HashMap<SpoutPlayer, Boolean>();
showArrowBlue = new HashMap<SpoutPlayer, Boolean>();
playerDamage = new HashMap<SpoutPlayer, Integer>();
is5Locations = new HashMap<BlockLocation, Boolean>(20);
// Container f�r Artefakt-Wachstums_Stufen
artifact1Grow = new HashMap<Integer, ArtifactBlock>(5);
artifact2Grow = new HashMap<Integer, ArtifactBlock>(5);
artifact3Grow = new HashMap<Integer, ArtifactBlock>(5);
// Container f�r alle Artefakt-Blockarten
allArtifacts = new ArrayList<ArtifactBlock>(15);
// Container f�r die Koordinaten der roten bzw blauen BaseBlocks
baseBlocksRed = new ArrayList<BlockLocation>();
baseBlocksBlue = new ArrayList<BlockLocation>();
contaminated = new ArrayList<BlockLocation>(10000);
totalXP = new HashMap<String, Integer>();
totalSkills = new HashMap<String, String>();
totalAnimal = new HashMap<String, Integer>();
totalCoal = new HashMap<String, Integer>();
totalCrafted = new HashMap<String, Integer>();
totalDiamond = new HashMap<String, Integer>();
totalFish = new HashMap<String, Integer>();
totalGiantMushroom = new HashMap<String, Integer>();
totalGold = new HashMap<String, Integer>();
totalIron = new HashMap<String, Integer>();
totalLapis = new HashMap<String, Integer>();
totalMobs = new HashMap<String, Integer>();
totalMushroom = new HashMap<String, Integer>();
totalRedstone = new HashMap<String, Integer>();
totalWheat = new HashMap<String, Integer>();
totalArt1 = new HashMap<String, Integer>();
totalArt2 = new HashMap<String, Integer>();
// leerer Drop
drops[0] = new SpoutItemStack(363, 3, (short) 0);
drops[1] = new SpoutItemStack(365, 3, (short) 0);
drops[2] = new SpoutItemStack(319, 3, (short) 0);
drops[3] = new SpoutItemStack(360, 5, (short) 0);
drops[4] = new SpoutItemStack(297, 3, (short) 0);
drops[5] = new SpoutItemStack(351, 5, (short) 4);
drops[6] = new SpoutItemStack(266, 1, (short) 0);
drops[7] = new SpoutItemStack(357, 3, (short) 0);
drops[8] = new SpoutItemStack(264, 1, (short) 0);
damageTresholdForPlayer = new HashMap<String, Integer>();
// skillCraftQual = new HashMap<String, Integer>();
// skillCraftArmor = new HashMap<String, Integer>();
// skillCraftBow = new HashMap<String, Integer>();
// skillCraftSword = new HashMap<String, Integer>();
// skillCraftTool = new HashMap<String, Integer>();
//
//
//
// skillFightArmor = new HashMap<String, Integer>();
// skillFightDrop = new HashMap<String, Integer>();
// skillFightDamage = new HashMap<String, Integer>();
// skillFightJump = new HashMap<String, Integer>();
// skillFightMonsters = new HashMap<String, Integer>();
// skillFightCamp = new HashMap<String, Integer>();
// skillFightRegeneration = new HashMap<String, Integer>();
// skillFightSpeedLand = new HashMap<String, Integer>();
// skillFightSpeedWater = new HashMap<String, Integer>();
//
//
//
// skillMineClay = new HashMap<String, Integer>();
// skillMineDiamond = new HashMap<String, Integer>();
// skillMineDurab = new HashMap<String, Integer>();
// skillMineGold = new HashMap<String, Integer>();
// skillMineIron = new HashMap<String, Integer>();
// skillMineRedstone = new HashMap<String, Integer>();
// skillMineLapis = new HashMap<String, Integer>();
//
//
// skillFoodBone = new HashMap<String, Integer>();
// skillFoodChicken = new HashMap<String, Integer>();
// skillFoodCow = new HashMap<String, Integer>();
// skillFoodFish = new HashMap<String, Integer>();
// skillFoodHarvest = new HashMap<String, Integer>();
// skillFoodPork = new HashMap<String, Integer>();
// skillFoodSeed = new HashMap<String, Integer>();
configHandler = new ConfigHandler(this);
}
/**
* initialisiert alle Bl�cke
*/
private void initBlocks() {
// custom bl�cke initialisieren
vuduBrick = new VuduBrick(this);
baseBlockRed = new BaseBlock(this, "red");
baseBlockBlue = new BaseBlock(this, "blue");
damageTower = new DamageTowerBlock(this);
defenseTower = new DefenseTowerBlock(this);
radarTower = new RadarBlock(this);
virusBlock = new VirusBlock(this);
// T�ren 'h�rter' machen
Field field;
try {
field = net.minecraft.server.Block.class.getDeclaredField("strength");
field.setAccessible(true);
field.setFloat(net.minecraft.server.Block.WOODEN_DOOR, 100.0F);
field.setFloat(net.minecraft.server.Block.IRON_DOOR_BLOCK, 250.0F);
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
// Artefakt-Blockarten instanziieren
art_1_1 = new ArtifactBlock(this, 1, 1);
art_1_2 = new ArtifactBlock(this, 1, 2);
art_1_3 = new ArtifactBlock(this, 1, 3);
art_1_4 = new ArtifactBlock(this, 1, 4);
art_1_5 = new ArtifactBlock(this, 1, 5);
art_2_1 = new ArtifactBlock(this, 2, 1);
art_2_2 = new ArtifactBlock(this, 2, 2);
art_2_3 = new ArtifactBlock(this, 2, 3);
art_2_4 = new ArtifactBlock(this, 2, 4);
art_2_5 = new ArtifactBlock(this, 2, 5);
art_3_1 = new ArtifactBlock(this, 3, 1);
art_3_2 = new ArtifactBlock(this, 3, 2);
art_3_3 = new ArtifactBlock(this, 3, 3);
art_3_4 = new ArtifactBlock(this, 3, 4);
art_3_5 = new ArtifactBlock(this, 3, 5);
// einsortieren
artifact1Grow.put(1, (ArtifactBlock) art_1_1);
artifact1Grow.put(2, (ArtifactBlock) art_1_2);
artifact1Grow.put(3, (ArtifactBlock) art_1_3);
artifact1Grow.put(4, (ArtifactBlock) art_1_4);
artifact1Grow.put(5, (ArtifactBlock) art_1_5);
artifact2Grow.put(1, (ArtifactBlock) art_2_1);
artifact2Grow.put(2, (ArtifactBlock) art_2_2);
artifact2Grow.put(3, (ArtifactBlock) art_2_3);
artifact2Grow.put(4, (ArtifactBlock) art_2_4);
artifact2Grow.put(5, (ArtifactBlock) art_2_5);
artifact3Grow.put(1, (ArtifactBlock) art_3_1);
artifact3Grow.put(2, (ArtifactBlock) art_3_2);
artifact3Grow.put(3, (ArtifactBlock) art_3_3);
artifact3Grow.put(4, (ArtifactBlock) art_3_4);
artifact3Grow.put(5, (ArtifactBlock) art_3_5);
}
/**
* initialisiert alle Listener
*/
private void initListeners() {
new BlockListener(this);
new HungerListener(this);
new PlayerLoginListener(this);
new TeamChoiceScreenListener(this);
new DoorListener(this);
new VuduBrickListener(this);
new PlayerSkillFightListener(this);
new PlayerSkillCraftListener(this);
new PlayerSkillMineListener(this);
new PlayerSkillFoodListener(this);
new SkillKeyListener(this);
new SkillScreenListener(this);
new PlayerKillEntityListener(this);
new XpListener(this);
}
@SuppressWarnings("unchecked")
private void loadLoggingStats(){
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalXP.bin")){
ConflictPlugin.totalXP = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalXP.bin");
}
if(null!= (HashMap<String, String>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalSkills.bin")){
ConflictPlugin.totalSkills = (HashMap<String, String>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalSkills.bin");
}
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalAnimal.bin")){
ConflictPlugin.totalAnimal = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalAnimal.bin");
}
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalCoal.bin")){
ConflictPlugin.totalCoal = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalCoal.bin");
}
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalCrafted.bin")){
ConflictPlugin.totalCrafted = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalCrafted.bin");
}
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalDiamond.bin")){
ConflictPlugin.totalDiamond = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalDiamond.bin");
}
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalGiantMushroom.bin")){
ConflictPlugin.totalGiantMushroom = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalGiantMushroom.bin");
}
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalGold.bin")){
ConflictPlugin.totalGold = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalGold.bin");
}
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalIron.bin")){
ConflictPlugin.totalIron = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalIron.bin");
}
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalLapis.bin")){
ConflictPlugin.totalLapis = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalLapis.bin");
}
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalMobs.bin")){
ConflictPlugin.totalMobs = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalMobs.bin");
}
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalMushroom.bin")){
ConflictPlugin.totalMushroom = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalMushroom.bin");
}
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalRedstone.bin")){
ConflictPlugin.totalRedstone = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalRedstone.bin");
}
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalWheat.bin")){
ConflictPlugin.totalWheat = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalWheat.bin");
}
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalFish.bin")){
ConflictPlugin.totalFish = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalFish.bin");
}
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalArt1.bin")){
ConflictPlugin.totalArt1 = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalArt1.bin");
}
if(null!= (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalArt2.bin")){
ConflictPlugin.totalArt2 = (HashMap<String, Integer>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()+"/totalArt2.bin");
}
}
/**
* l�dt BaseBlock(Location)s, sofern diese abgespeichet wurden
*/
@SuppressWarnings("unchecked")
private void loadBaseBlocks() {
if (null != (ArrayList<Location>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()
+ "/baseblockRed.bin")) {
ConflictPlugin.baseBlocksRed = (ArrayList<BlockLocation>) PluginSerializer.load(getServer().getWorlds()
.get(0).getWorldFolder()
+ "/baseblockRed.bin");
}
Bukkit.getLogger().log(Level.INFO, Integer.toString(baseBlocksBlue.size()) + " red baseBlock locations loaded");
if (null != (ArrayList<Location>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()
+ "/baseblockBlue.bin")) {
ConflictPlugin.baseBlocksBlue = (ArrayList<BlockLocation>) PluginSerializer.load(getServer().getWorlds()
.get(0).getWorldFolder()
+ "/baseblockBlue.bin");
}
Bukkit.getLogger()
.log(Level.INFO, Integer.toString(baseBlocksBlue.size()) + " blue baseBlock locations loaded");
}
@SuppressWarnings("unchecked")
private void loadDoors() {
if (null != (ArrayList<Location>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()
+ "/doorsRed.bin")) {
ConflictPlugin.doorsRed = (ArrayList<BlockLocation>) PluginSerializer.load(getServer().getWorlds().get(0)
.getWorldFolder()
+ "/doorsRed.bin");
}
Bukkit.getLogger().log(Level.INFO, Integer.toString(doorsRed.size()) + " red door locations loaded");
if (null != (ArrayList<Location>) PluginSerializer.load(getServer().getWorlds().get(0).getWorldFolder()
+ "/doorsBlue.bin")) {
ConflictPlugin.doorsBlue = (ArrayList<BlockLocation>) PluginSerializer.load(getServer().getWorlds().get(0)
.getWorldFolder()
+ "/doorsBlue.bin");
}
Bukkit.getLogger().log(Level.INFO, Integer.toString(doorsBlue.size()) + " blue door locations loaded");
}
/**
* l�dt is5Locations
*/
@SuppressWarnings("unchecked")
private void loadIs5Locations() {
if (null != (HashMap<BlockLocation, Boolean>) PluginSerializer.load(getServer().getWorlds().get(0)
.getWorldFolder()
+ "/is5Locations.bin")) {
ConflictPlugin.is5Locations = (HashMap<BlockLocation, Boolean>) PluginSerializer.load(getServer()
.getWorlds().get(0).getWorldFolder()
+ "/is5Locations.bin");
}
Bukkit.getLogger().log(Level.INFO, Integer.toString(is5Locations.size()) + " is5 locations loaded");
}
/**
* l�dt Skills
*/
private void loadSkills() {
ConflictPlugin.skillCraftQual = loadSkill("skillCraftQual");
ConflictPlugin.skillCraftArmor = loadSkill("skillCraftArmor");
ConflictPlugin.skillCraftBow = loadSkill("skillCraftBow");
ConflictPlugin.skillCraftSword = loadSkill("skillCraftSword");
ConflictPlugin.skillCraftTool = loadSkill("skillCraftTool");
ConflictPlugin.skillMineClay = loadSkill("skillMineClay");
ConflictPlugin.skillMineDiamond = loadSkill("skillMineDiamond");
ConflictPlugin.skillMineDurab = loadSkill("skillMineDurab");
ConflictPlugin.skillMineGold = loadSkill("skillMineGold");
ConflictPlugin.skillMineIron = loadSkill("skillMineIron");
ConflictPlugin.skillMineRedstone = loadSkill("skillMineRedstone");
ConflictPlugin.skillMineLapis = loadSkill("skillMineLapis");
ConflictPlugin.skillFightMonsters = loadSkill("skillFightMonsters");
ConflictPlugin.skillFightCamp = loadSkill("skillFightCamp");
ConflictPlugin.skillFightArmor = loadSkill("skillFightArmor");
ConflictPlugin.skillFightDrop = loadSkill("skillFightDrop");
ConflictPlugin.skillFightDamage = loadSkill("skillFightDamage");
ConflictPlugin.skillFightJump = loadSkill("skillFightJump");
ConflictPlugin.skillFightRegeneration = loadSkill("skillFightRegeneration");
ConflictPlugin.skillFightSpeedLand = loadSkill("skillFightSpeedLand");
ConflictPlugin.skillFightSpeedWater = loadSkill("skillFightSpeedWater");
ConflictPlugin.damageTresholdForPlayer = loadSkill("damageTresholdForPlayer");
ConflictPlugin.skillFoodBone = loadSkill("skillFoodBone");
ConflictPlugin.skillFoodChicken = loadSkill("skillFoodChicken");
ConflictPlugin.skillFoodCow = loadSkill("skillFoodCow");
ConflictPlugin.skillFoodFish = loadSkill("skillFoodFish");
ConflictPlugin.skillFoodHarvest = loadSkill("skillFoodHarvest");
ConflictPlugin.skillFoodPork = loadSkill("skillFoodPork");
ConflictPlugin.skillFoodSeed = loadSkill("skillFoodSeed");
ConflictPlugin.armorPlate = loadSkill("armorPlate");
ConflictPlugin.armorLeggins = loadSkill("armorLeggins");
}
@SuppressWarnings("unchecked")
private HashMap<String, Integer> loadSkill(String fileName){
String path = getServer().getWorlds().get(0).getWorldFolder()+ "/"+fileName+".bin";
if (null != (HashMap<String, Integer>) PluginSerializer.load(path)) {
return (HashMap<String, Integer>) PluginSerializer.load(path);
}
return new HashMap<String, Integer>();
}
/**
* l�dt Timestamps, sofrn welche abgespeichert wurden
*/
@SuppressWarnings("unchecked")
private void loadTimestamps() {
for (ArtifactBlock b : ConflictPlugin.allArtifacts) {
if (null != (ConcurrentHashMap<BlockLocation, Long>) PluginSerializer.load(getServer().getWorlds().get(0)
.getWorldFolder()
+ "/timestamps" + b.getName() + ".bin")) {
b.timestamps = (ConcurrentHashMap<BlockLocation, Long>) PluginSerializer.load(getServer().getWorlds()
.get(0).getWorldFolder()
+ "/timestamps" + b.getName() + ".bin");
// Bukkit.getLogger().log(Level.INFO, Integer.toString(b.timestamps.size())+" artifact timestamps of type "+b.getName()+" loaded");
}
}
// update falls Server restart -> gleicht TS an
updateTimestamps(ConflictPlugin.serverCloseTimestamp, ConflictPlugin.serverOpenTimestamp);
}
/**
* initialisiert das PositionLabel f�r den angegebenen Player
*
* @param player
* Player f�r den das Label initialisiert wird
*/
public void initBaseLabels(SpoutPlayer player) {
// redBase Label
GenericLabel redBaselabel = new GenericLabel("no base set");
redBaselabel.setScale((float) 0.5);
redBaselabel.setAnchor(WidgetAnchor.TOP_RIGHT);
redBaselabel.setTextColor(new org.getspout.spoutapi.gui.Color(255, 0, 0));
redBaselabel.shiftXPos(-70).shiftYPos(120);
redBaselabel.setWidth(200).setHeight(10);
ConflictPlugin.redBaseLabels.put(player, redBaselabel);
if (null != ConflictPlugin.redBase) {
redBaselabel.setText("Red Base: " + ConflictPlugin.redBase.koordsString());
}
player.getMainScreen().attachWidget(this, redBaselabel);
// blueBase Label
GenericLabel blueBaselabel = new GenericLabel("no base set");
blueBaselabel.setScale((float) 0.5);
blueBaselabel.setAnchor(WidgetAnchor.TOP_RIGHT);
blueBaselabel.setTextColor(new org.getspout.spoutapi.gui.Color(0, 0, 255));
blueBaselabel.shiftXPos(-70).shiftYPos(130);
blueBaselabel.setWidth(200).setHeight(10);
ConflictPlugin.blueBaseLabels.put(player, blueBaselabel);
if (null != ConflictPlugin.blueBase) {
blueBaselabel.setText("Blue Base: " + ConflictPlugin.blueBase.koordsString());
}
player.getMainScreen().attachWidget(this, blueBaselabel);
}
/**
* initialisiert das PositionLabel f�r den angegebenen Player
*
* @param player
* Player f�r den das Label initialisiert wird
*/
public void initAlarmLabels(SpoutPlayer player) {
GenericTexture alarmTexture = new GenericTexture("http://tossat.de/~mcbukkit/images/alarm128.png");
alarmTexture.setAnchor(WidgetAnchor.TOP_LEFT);
alarmTexture.shiftXPos(10).shiftYPos(10);
alarmTexture.setWidth(16).setHeight(16);
alarmTexture.setVisible(false);
ConflictPlugin.alarmLamps.put(player, alarmTexture);
player.getMainScreen().attachWidget(this, alarmTexture);
}
/**
* initialisisert das Label, das anzeigt, dass man sich in der gegenrischen basis befindet
* @param player Player f�r den das Label initialisiert wird
*/
public void initEnemyBaseLabels(SpoutPlayer player) {
GenericTexture alarmTexture = new GenericTexture("http://tossat.de/~mcbukkit/images/camping_penalty.png");
alarmTexture.setAnchor(WidgetAnchor.TOP_LEFT);
alarmTexture.shiftXPos(10).shiftYPos(30);
alarmTexture.setWidth(16).setHeight(16);
alarmTexture.setVisible(false);
ConflictPlugin.enemyBaseLamps.put(player, alarmTexture);
player.getMainScreen().attachWidget(this, alarmTexture);
}
/**
* initialisisert das Label, das anzeigt, dass man sich in der eigenen basis befindet
* @param player Player f�r den das Label initialisiert wird
*/
public void initOwnBaseLabels(SpoutPlayer player) {
GenericTexture alarmTexture = new GenericTexture("http://tossat.de/~mcbukkit/images/base_bonus.png");
alarmTexture.setAnchor(WidgetAnchor.TOP_LEFT);
alarmTexture.shiftXPos(10).shiftYPos(30);
alarmTexture.setWidth(16).setHeight(16);
alarmTexture.setVisible(false);
ConflictPlugin.ownBaseLamps.put(player, alarmTexture);
player.getMainScreen().attachWidget(this, alarmTexture);
}
/**
* initialisiert das Schadens-Label f�r den angegebenen Spieler
*
* @param player
* Spieler
*/
public void initDamageLabel(SpoutPlayer player) {
GenericLabel damageLabel = new GenericLabel("Camping Damage: 0" + "/" + ConflictPlugin.damageTresholdForPlayer);
damageLabel.setScale((float) 0.5);
damageLabel.setAnchor(WidgetAnchor.TOP_RIGHT);
// damageLabel.setTextColor(new org.getspout.spoutapi.gui.Color(0, 0, 255));
damageLabel.shiftXPos(-70).shiftYPos(140);
damageLabel.setWidth(200).setHeight(10);
ConflictPlugin.damageLabels.put(player, damageLabel);
player.getMainScreen().attachWidget(this, damageLabel);
}
/**
* initialisiert das Label f�r die Anzahl Artefakte am oberen Bildschirmrand f�r den angegebenen Spieler
*
* @param player
* Spieler
*/
public void initArtNumberLabel(SpoutPlayer player) {
GenericLabel artNumberLabel1 = new GenericLabel(Integer.toString(ConflictPlugin.artRed));
artNumberLabel1.setScale((float) 1.0);
artNumberLabel1.setAnchor(WidgetAnchor.TOP_CENTER);
artNumberLabel1.setTextColor(new org.getspout.spoutapi.gui.Color(255, 0, 0));
artNumberLabel1.shiftXPos(-10).shiftYPos(10);
artNumberLabel1.setWidth(200).setHeight(10);
ConflictPlugin.artNumberLabelsRed.put(player, artNumberLabel1);
player.getMainScreen().attachWidget(this, artNumberLabel1);
GenericLabel artNumberLabel2 = new GenericLabel(Integer.toString(ConflictPlugin.artBlue));
artNumberLabel2.setScale((float) 1.0);
artNumberLabel2.setAnchor(WidgetAnchor.TOP_CENTER);
artNumberLabel2.setTextColor(new org.getspout.spoutapi.gui.Color(0, 0, 255));
artNumberLabel2.shiftXPos(10).shiftYPos(10);
artNumberLabel2.setWidth(200).setHeight(10);
ConflictPlugin.artNumberLabelsBlue.put(player, artNumberLabel2);
player.getMainScreen().attachWidget(this, artNumberLabel2);
}
/**
* initialsisiert die roten Arrow Texturen f�r den angegebenen Player
*
* @param player
* Player f�r den die Texturen initialisiert werden
*/
public void initRedArrows(SpoutPlayer player) {
GenericTexture arrowTop = new GenericTexture("http://tossat.de/~mcbukkit/images/arrowredtop2.png");
arrowTop.setWidth(8).setHeight(8);
arrowTop.setAnchor(WidgetAnchor.TOP_CENTER);
arrowTop.shiftXPos(-4).shiftYPos(3);
ConflictPlugin.arrowTopRed.put(player, arrowTop);
GenericTexture arrowBot = new GenericTexture("http://tossat.de/~mcbukkit/images/arrowredbot2.png");
arrowBot.setWidth(8).setHeight(8);
arrowBot.setAnchor(WidgetAnchor.BOTTOM_CENTER);
arrowBot.shiftXPos(-180).shiftYPos(-11);
ConflictPlugin.arrowBotRed.put(player, arrowBot);
GenericTexture arrowLeft = new GenericTexture("http://tossat.de/~mcbukkit/images/arrowredleft2.png");
arrowLeft.setWidth(8).setHeight(8);
arrowLeft.setAnchor(WidgetAnchor.CENTER_LEFT);
arrowLeft.shiftXPos(3).shiftYPos(-4);
ConflictPlugin.arrowLeftRed.put(player, arrowLeft);
GenericTexture arrowRight = new GenericTexture("http://tossat.de/~mcbukkit/images/arrowredright2.png");
arrowRight.setWidth(8).setHeight(8);
arrowRight.setAnchor(WidgetAnchor.CENTER_RIGHT);
arrowRight.shiftXPos(-11).shiftYPos(-4);
ConflictPlugin.arrowRightRed.put(player, arrowRight);
player.getMainScreen().attachWidget(this, arrowTop);
player.getMainScreen().attachWidget(this, arrowBot);
player.getMainScreen().attachWidget(this, arrowLeft);
player.getMainScreen().attachWidget(this, arrowRight);
ConflictPlugin.showArrowRed.put(player, true);
}
/**
* initialsisiert die blauen Arrow Texturen f�r den angegebenen Player
*
* @param player
* Player f�r den die Texturen initialisiert werden
*/
public void initBlueArrows(SpoutPlayer player) {
GenericTexture arrowTop = new GenericTexture("http://tossat.de/~mcbukkit/images/arrowbluetop2.png");
arrowTop.setWidth(8).setHeight(8);
arrowTop.setAnchor(WidgetAnchor.TOP_CENTER);
arrowTop.shiftXPos(-4).shiftYPos(3);
ConflictPlugin.arrowTopBlue.put(player, arrowTop);
GenericTexture arrowBot = new GenericTexture("http://tossat.de/~mcbukkit/images/arrowbluebot2.png");
arrowBot.setWidth(8).setHeight(8);
arrowBot.setAnchor(WidgetAnchor.BOTTOM_CENTER);
arrowBot.shiftXPos(+180).shiftYPos(-11);
ConflictPlugin.arrowBotBlue.put(player, arrowBot);
GenericTexture arrowLeft = new GenericTexture("http://tossat.de/~mcbukkit/images/arrowblueleft2.png");
arrowLeft.setWidth(8).setHeight(8);
arrowLeft.setAnchor(WidgetAnchor.CENTER_LEFT);
arrowLeft.shiftXPos(3).shiftYPos(-4);
ConflictPlugin.arrowLeftBlue.put(player, arrowLeft);
GenericTexture arrowRight = new GenericTexture("http://tossat.de/~mcbukkit/images/arrowblueright2.png");
arrowRight.setWidth(8).setHeight(8);
arrowRight.setAnchor(WidgetAnchor.CENTER_RIGHT);
arrowRight.shiftXPos(-11).shiftYPos(-4);
ConflictPlugin.arrowRightBlue.put(player, arrowRight);
player.getMainScreen().attachWidget(this, arrowTop);
player.getMainScreen().attachWidget(this, arrowBot);
player.getMainScreen().attachWidget(this, arrowLeft);
player.getMainScreen().attachWidget(this, arrowRight);
ConflictPlugin.showArrowBlue.put(player, true);
}
/**
* initialisiert das Label mit der Location der roten Basis
*/
public void setBaseLocationLabelRed() {
for (SpoutPlayer p : ConflictPlugin.players) {
ConflictPlugin.redBaseLabels.get(p).setText("Red Base: " + ConflictPlugin.redBase.koordsString());
}
}
/**
* resettet das Label mit der Location der roten Basis
*/
public void resetBaseLocationLabelRed() {
for (SpoutPlayer p : ConflictPlugin.players) {
ConflictPlugin.redBaseLabels.get(p).setText("no base set");
}
}
/**
* initialisiert das Label mit der Location der blauen Basis
*/
public void setBaseLocationLabelBlue() {
for (SpoutPlayer p : ConflictPlugin.players) {
ConflictPlugin.blueBaseLabels.get(p).setText("Red Base: " + ConflictPlugin.blueBase.koordsString());
}
}
/**
* resettet das Label mit der Location der blauen Basis
*/
public void resetBaseLocationLabelBlue() {
for (SpoutPlayer p : ConflictPlugin.players) {
ConflictPlugin.blueBaseLabels.get(p).setText("no base set");
}
}
/**
* setzt den Damage-Wert f�r den anegebenen Spieler im entsprechenden Label in der GUI
*
* @param p
* Spieler
* @param damage
* Wert
*/
public static void setDamageLabel(SpoutPlayer p, int damage) {
if (damage >= ConflictPlugin.damageTresholdForPlayer.get(p.getName())) {
ConflictPlugin.damageLabels.get(p).setTextColor(new org.getspout.spoutapi.gui.Color(255, 0, 0));
}
ConflictPlugin.damageLabels.get(p).setText(
"Camping Damage: " + Integer.toString(damage) + "/" + ConflictPlugin.damageTresholdForPlayer.get(p.getName()));
}
/**
* setzt die Punkte-Labels am oberen Bildschirmrand
*
* @param red
* roter Wert
* @param blue
* blauer Wert
*/
public static void setArtLabel(int red, int blue) {
for (SpoutPlayer p : ConflictPlugin.players) {
ConflictPlugin.artNumberLabelsRed.get(p).setText(Integer.toString(red));
ConflictPlugin.artNumberLabelsBlue.get(p).setText(Integer.toString(blue));
}
}
/**
* updatet den roten Arrow f�r den angegebenen Player
*
* @param player
* Player, dessen Arrow aktualisiert wird
* @param diff
* Wert, aus dem die neue Position errechnet wird
*/
public static void paintRedArrow(int diff, SpoutPlayer player) {
GenericTexture arrowTop = ConflictPlugin.arrowTopRed.get(player);
GenericTexture arrowBot = ConflictPlugin.arrowBotRed.get(player);
GenericTexture arrowLeft = ConflictPlugin.arrowLeftRed.get(player);
GenericTexture arrowRight = ConflictPlugin.arrowRightRed.get(player);
if (showArrowRed.get(player) == false) {
arrowTop.setVisible(false);
arrowLeft.setVisible(false);
arrowRight.setVisible(false);
arrowBot.setVisible(false);
return;
}
if (diff == 1000) {
arrowTop.setVisible(false);
arrowLeft.setVisible(false);
arrowRight.setVisible(false);
arrowBot.setVisible(false);
return;
}
// top
if (0 <= diff && diff <= 45) {
arrowTop.setVisible(true);
arrowTop.setX(diff * player.getMainScreen().getWidth() / 90);
arrowLeft.setVisible(false);
arrowRight.setVisible(false);
arrowBot.setVisible(false);
} else if (315 <= diff) {
arrowTop.setVisible(true);
arrowTop.setX(-(360 - diff) * player.getMainScreen().getWidth() / 90);
arrowLeft.setVisible(false);
arrowRight.setVisible(false);
arrowBot.setVisible(false);
} else
// rechts
if (diff > 45 && diff <= 135) {
arrowTop.setVisible(false);
arrowLeft.setVisible(false);
arrowRight.setVisible(true);
arrowRight.setY((diff - 90) * player.getMainScreen().getHeight() / 90);
arrowBot.setVisible(false);
} else
// links
if (diff < 315 && diff >= 225) {
arrowTop.setVisible(false);
arrowLeft.setVisible(true);
arrowLeft.setY((270 - diff) * player.getMainScreen().getHeight() / 90);
arrowRight.setVisible(false);
arrowBot.setVisible(false);
// bot
} else {
arrowTop.setVisible(false);
arrowLeft.setVisible(false);
arrowRight.setVisible(false);
arrowBot.setVisible(true);
}
}
/**
* updatet den blauen Arrow f�r den angegebenen Player
*
* @param player
* Player, dessen Arrow aktualisiert wird
* @param diff
* Wert, aus dem die neue Position errechnet wird
*/
public static void paintBlueArrow(int diff, SpoutPlayer player) {
GenericTexture arrowTop = ConflictPlugin.arrowTopBlue.get(player);
GenericTexture arrowBot = ConflictPlugin.arrowBotBlue.get(player);
GenericTexture arrowLeft = ConflictPlugin.arrowLeftBlue.get(player);
GenericTexture arrowRight = ConflictPlugin.arrowRightBlue.get(player);
if (showArrowBlue.get(player) == false) {
arrowTop.setVisible(false);
arrowLeft.setVisible(false);
arrowRight.setVisible(false);
arrowBot.setVisible(false);
return;
}
if (diff == 1000) {
arrowTop.setVisible(false);
arrowLeft.setVisible(false);
arrowRight.setVisible(false);
arrowBot.setVisible(false);
return;
}
// top
if (0 <= diff && diff <= 45) {
arrowTop.setVisible(true);
arrowTop.setX(diff * player.getMainScreen().getWidth() / 90);
arrowLeft.setVisible(false);
arrowRight.setVisible(false);
arrowBot.setVisible(false);
} else if (315 <= diff) {
arrowTop.setVisible(true);
arrowTop.setX(-(360 - diff) * player.getMainScreen().getWidth() / 90);
arrowLeft.setVisible(false);
arrowRight.setVisible(false);
arrowBot.setVisible(false);
} else
// rechts
if (diff > 45 && diff <= 135) {
arrowTop.setVisible(false);
arrowLeft.setVisible(false);
arrowRight.setVisible(true);
arrowRight.setY((diff - 90) * player.getMainScreen().getHeight() / 90);
arrowBot.setVisible(false);
} else
// links
if (diff < 315 && diff >= 225) {
arrowTop.setVisible(false);
arrowLeft.setVisible(true);
arrowLeft.setY((270 - diff) * player.getMainScreen().getHeight() / 90);
arrowRight.setVisible(false);
arrowBot.setVisible(false);
// bot
} else {
arrowTop.setVisible(false);
arrowLeft.setVisible(false);
arrowRight.setVisible(false);
arrowBot.setVisible(true);
}
}
/**
* (de)aktiviert die Alarmlampe in der GUI
*
* @param isOn
* Lampe an/aus
* @param player
* Spieler f�r den die GUI aktualisiert wird
*/
public static void paintAlarmLamp(boolean isOn, SpoutPlayer player) {
GenericTexture alarmLamp = ConflictPlugin.alarmLamps.get(player);
if (isOn) {
alarmLamp.setVisible(true);
} else {
alarmLamp.setVisible(false);
}
}
/**
* (de)aktiviert die EnemyBaselampe in der GUI
*
* @param isOn
* Lampe an/aus
* @param player
* Spieler f�r den die GUI aktualisiert wird
*/
public static void paintInEnemyBaseLamp(boolean isOn, SpoutPlayer player) {
GenericTexture alarmLamp = ConflictPlugin.enemyBaseLamps.get(player);
if (isOn) {
alarmLamp.setVisible(true);
} else {
alarmLamp.setVisible(false);
}
}
/**
* (de)aktiviert die OwnBaselampe in der GUI
*
* @param isOn
* Lampe an/aus
* @param player
* Spieler f�r den die GUI aktualisiert wird
*/
public static void paintInOwnBaseLamp(boolean isOn, SpoutPlayer player) {
GenericTexture alarmLamp = ConflictPlugin.ownBaseLamps.get(player);
if (isOn) {
alarmLamp.setVisible(true);
} else {
alarmLamp.setVisible(false);
}
}
/**
* setzt die Namen der Spieler in Abh�ngigkeit des Teams nur Spieler des selben Teams k�nnen Namen sehen
*/
public static void updateTeamNames() {
for (SpoutPlayer p : ConflictPlugin.playersRed) {
for (SpoutPlayer p2 : ConflictPlugin.players) {
if (ConflictPlugin.playersRed.contains(p2)) {
p.resetTitleFor(p2);
p.setTitleFor(p2, ChatColor.RED + p.getName());
} else {
p.setTitleFor(p2, "");
p.hideTitleFrom(p2);
}
}
}
for (SpoutPlayer p : ConflictPlugin.playersBlue) {
for (SpoutPlayer p2 : ConflictPlugin.players) {
if (ConflictPlugin.playersBlue.contains(p2)) {
p.resetTitleFor(p2);
p.setTitleFor(p2, ChatColor.BLUE + p.getName());
} else {
p.setTitleFor(p2, "");
p.hideTitleFrom(p2);
}
}
}
}
/**
* liefert das Team in dem der angegebene Spieler ist
*
* @param p
* Spieler
* @return "red"/"blue" oder ""
*/
public static String playerIsInTeam(SpoutPlayer p) {
if (playersRed.contains(p)) {
return "red";
}
if (playersBlue.contains(p)) {
return "blue";
}
return "";
}
/**
* liefert die Distanz von einem Punkt zur angegebenen Basis
*
* @param world
* Welt
* @param bl
* Location von der aus gepr�ft wird
* @param base
* Basis ("red"/"blue")
* @return
*/
public static double getDistanceToBase(World world, Location bl, String base) {
if (base.equals("red")) {
if (null != ConflictPlugin.redBase) {
Location baseLoc = world.getBlockAt(ConflictPlugin.redBase.getX(), ConflictPlugin.redBase.getY(),
ConflictPlugin.redBase.getZ()).getLocation();
return bl.distance(baseLoc);
} else {
return Integer.MAX_VALUE;
}
}
if (base.equals("blue")) {
if (null != ConflictPlugin.blueBase) {
Location baseLoc = world.getBlockAt(ConflictPlugin.blueBase.getX(), ConflictPlugin.blueBase.getY(),
ConflictPlugin.blueBase.getZ()).getLocation();
return bl.distance(baseLoc);
} else {
return Integer.MAX_VALUE;
}
}
return Integer.MAX_VALUE;
}
/**
* pr�ft, ob der Spieler sich innerhalb der gegnersischen Grenzen befindet
*
* @param p
* Spieler
* @param radius
* Radius um die generische Basis in Bl�cken
* @return true, falls innerhalb, false sonst
*/
public static boolean isInEnemyBase(SpoutPlayer p, int radius) {
if (ConflictPlugin.playersRed.contains(p)) {// roter Spieler
if (null == ConflictPlugin.blueBase) { // gegenerische Basis noch nicht errichtet
return false;
}
if (getDistanceToBase(p.getWorld(), p.getLocation(), "blue") <= radius) {
return true;
} else {
return false;
}
}
if (ConflictPlugin.playersBlue.contains(p)) {// roter Spieler
if (null == ConflictPlugin.redBase) { // gegenerische Basis noch nicht errichtet
return false;
}
if (getDistanceToBase(p.getWorld(), p.getLocation(), "red") <= radius) {
return true;
} else {
return false;
}
}
return false;
}
/**
* pr�ft ob der Spieler sich in der eigenen absis befidnet
* @param p Spieler
* @param radius Radius um die eigene Basis
* @return true, falls in der Basis, false sonst
*/
public static boolean isInOwnBase(SpoutPlayer p, int radius) {
if (ConflictPlugin.playersRed.contains(p)) {// roter Spieler
if (null == ConflictPlugin.redBase) { // gegenerische Basis noch nicht errichtet
return false;
}
if (getDistanceToBase(p.getWorld(), p.getLocation(), "red") <= radius) {
return true;
} else {
return false;
}
}
if (ConflictPlugin.playersBlue.contains(p)) {// roter Spieler
if (null == ConflictPlugin.blueBase) { // gegenerische Basis noch nicht errichtet
return false;
}
if (getDistanceToBase(p.getWorld(), p.getLocation(), "blue") <= radius) {
return true;
} else {
return false;
}
}
return false;
}
/**
* platziert den Virus im Koop-Modus
* NOT USED
* @param world
*/
public static void placeVirus(World world) {
if (null != ConflictPlugin.blueBase) {
int x = ConflictPlugin.blueBase.getX();
int z = ConflictPlugin.blueBase.getZ();
int y = Bukkit.getServer().getWorlds().get(0)
.getHighestBlockYAt(x - ConflictPlugin.virusDistance, z - ConflictPlugin.virusDistance);
Block b = Bukkit.getServer().getWorlds().get(0)
.getBlockAt(x - ConflictPlugin.virusDistance, y - 1, z - ConflictPlugin.virusDistance);
SpoutManager.getMaterialManager().overrideBlock(b, virusBlock);
addContaminated(new BlockLocation(world.getName(), x - ConflictPlugin.virusDistance, y - 1, z
- ConflictPlugin.virusDistance), world);
y = Bukkit.getServer().getWorlds().get(0)
.getHighestBlockYAt(x + ConflictPlugin.virusDistance, z + ConflictPlugin.virusDistance);
b = Bukkit.getServer().getWorlds().get(0)
.getBlockAt(x + ConflictPlugin.virusDistance, y - 1, z + ConflictPlugin.virusDistance);
SpoutManager.getMaterialManager().overrideBlock(b, virusBlock);
addContaminated(new BlockLocation(world.getName(), x + ConflictPlugin.virusDistance, y - 1, z
+ ConflictPlugin.virusDistance), world);
y = Bukkit.getServer().getWorlds().get(0)
.getHighestBlockYAt(x + ConflictPlugin.virusDistance, z - ConflictPlugin.virusDistance);
b = Bukkit.getServer().getWorlds().get(0)
.getBlockAt(x + ConflictPlugin.virusDistance, y - 1, z - ConflictPlugin.virusDistance);
SpoutManager.getMaterialManager().overrideBlock(b, virusBlock);
addContaminated(new BlockLocation(world.getName(), x + ConflictPlugin.virusDistance, y - 1, z
- ConflictPlugin.virusDistance), world);
y = Bukkit.getServer().getWorlds().get(0)
.getHighestBlockYAt(x - ConflictPlugin.virusDistance, z + ConflictPlugin.virusDistance);
b = Bukkit.getServer().getWorlds().get(0)
.getBlockAt(x - ConflictPlugin.virusDistance, y - 1, z + ConflictPlugin.virusDistance);
SpoutManager.getMaterialManager().overrideBlock(b, virusBlock);
addContaminated(new BlockLocation(world.getName(), x - ConflictPlugin.virusDistance, y - 1, z
+ ConflictPlugin.virusDistance), world);
}
virusPlaced = true;
}
/**
* NOT USED
* @param bl
* @param world
*/
private static void addContaminated(BlockLocation bl, World world) {
ConflictPlugin.contaminated.add(new BlockLocation(world.getName(), bl.getX() + 1, bl.getY(), bl.getZ()));
ConflictPlugin.contaminated.add(new BlockLocation(world.getName(), bl.getX() - 1, bl.getY(), bl.getZ()));
ConflictPlugin.contaminated.add(new BlockLocation(world.getName(), bl.getX(), bl.getY(), bl.getZ() - 1));
ConflictPlugin.contaminated.add(new BlockLocation(world.getName(), bl.getX(), bl.getY(), bl.getZ() + 1));
ConflictPlugin.contaminated.add(new BlockLocation(world.getName(), bl.getX(), bl.getY() - 1, bl.getZ()));
}
/**
* Hilfsfunktion um anzupr�fen, ob sich eine BlockLocation mit den Koordinaten eines BasisBlocks deckt
* @param bl BlockLocation
* @return true, wenn ja, false sonst
*/
public static String isOnBase(BlockLocation bl) {
if (null != ConflictPlugin.redBase) {
BlockLocation redbase = ConflictPlugin.redBase;
BlockLocation bl0 = new BlockLocation(redbase);
bl0.setY(bl0.getY() + 1);
Bukkit.getLogger().log(Level.INFO, bl0.toString());
BlockLocation bl1 = new BlockLocation(bl0);
bl1.setX(bl1.getX() - 1);
BlockLocation bl2 = new BlockLocation(bl0);
bl2.setX(bl2.getX() + 1);
BlockLocation bl3 = new BlockLocation(bl0);
bl3.setZ(bl3.getZ() - 1);
BlockLocation bl4 = new BlockLocation(bl0);
bl4.setZ(bl4.getZ() + 1);
if (bl.equals(bl0) || bl.equals(bl1) || bl.equals(bl2) || bl.equals(bl3) || bl.equals(bl4)) {
Bukkit.getLogger().log(Level.INFO, "red");
return "red";
}
}
if (null != ConflictPlugin.blueBase) {
BlockLocation bluebase = ConflictPlugin.blueBase;
BlockLocation bl0 = new BlockLocation(bluebase);
bl0.setY(bl0.getY() + 1);
Bukkit.getLogger().log(Level.INFO, bl0.toString());
BlockLocation bl1 = new BlockLocation(bl0);
bl1.setX(bl1.getX() - 1);
BlockLocation bl2 = new BlockLocation(bl0);
bl2.setX(bl2.getX() + 1);
BlockLocation bl3 = new BlockLocation(bl0);
bl3.setZ(bl3.getZ() - 1);
BlockLocation bl4 = new BlockLocation(bl0);
bl4.setZ(bl4.getZ() + 1);
if (bl.equals(bl0) || bl.equals(bl1) || bl.equals(bl2) || bl.equals(bl3) || bl.equals(bl4)) {
Bukkit.getLogger().log(Level.INFO, "blue");
return "blue";
}
}
Bukkit.getLogger().log(Level.INFO, "null");
return "";
}
public static boolean playerHasHeavyArmorPlate(SpoutPlayer sp){
if(sp.getInventory().getArmorContents()[2].getTypeId() == 303 || sp.getInventory().getArmorContents()[2].getTypeId() == 307
|| sp.getInventory().getArmorContents()[2].getTypeId() == 311 || sp.getInventory().getArmorContents()[2].getTypeId() == 315){
return true;
}
return false;
}
public static boolean playerHasHeavyArmorLeggins(SpoutPlayer sp){
if(sp.getInventory().getArmorContents()[1].getTypeId() == 304 || sp.getInventory().getArmorContents()[1].getTypeId() == 308
|| sp.getInventory().getArmorContents()[1].getTypeId() == 312|| sp.getInventory().getArmorContents()[1].getTypeId() == 316){
return true;
}
return false;
}
public static void setPlayerWalkingSpeed(SpoutPlayer sp){
double speed = 1.0;
if(ConflictPlugin.armorPlate.get(sp.getName())==1){
speed -=0.2;
}
if(ConflictPlugin.armorLeggins.get(sp.getName())==1){
speed -=0.2;
}
if(ConflictPlugin.skillFightSpeedLand.get(sp.getName())==1){
speed += ConflictPlugin.skillRun1 - 1.0;
}
if(ConflictPlugin.skillFightSpeedLand.get(sp.getName())==2){
speed += ConflictPlugin.skillRun2 - 1.0;
}
sp.setWalkingMultiplier(speed);
}
}