diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index 5ec75f0..e5b5a5d 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -196,197 +196,197 @@ import me.kaZep.Base.SupportEntity; import me.kaZep.Base.SupportPlayer; public class PlayerListener - implements Listener +implements Listener { - public Main plugin; + public Main plugin; - public PlayerListener(Main plugin) - { - this.plugin = plugin; - } - - enum Cube { SMALL, LARGE, ENDER } - - public void updateTopSPLEEFSigns() { - String name[] = {"","",""}; - int rating[] = {-9999,-9999,-9999}, wins[] = {0,0,0}, losses[] = {0,0,0}; - //Get list of all players on the server. - OfflinePlayer playerlist[] = Bukkit.getOfflinePlayers(); - for (int i=0;i=20) { - if (this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating")>rating[0]) { - //This beats the top record, move everything down. - name[2]=name[1];rating[2]=rating[1];wins[2]=wins[1];losses[2]=losses[1]; - name[1]=name[0];rating[1]=rating[0];wins[1]=wins[0];losses[1]=losses[0]; - name[0]=playerlist[i].getName(); - rating[0]=(int)this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating"); - wins[0]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleefwins"); - losses[0]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleeflosses"); - } else - if (this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating")>rating[1]) { - //This beats the 2nd record, move everything down. - name[2]=name[1];rating[2]=rating[1];wins[2]=wins[1];losses[2]=losses[1]; - name[1]=playerlist[i].getName(); - rating[1]=(int)this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating"); - wins[1]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleefwins"); - losses[1]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleeflosses"); - } else - if (this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating")>rating[2]) { - //This beats the 3rd record, move everything down. - name[2]=playerlist[i].getName(); - rating[2]=(int)this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating"); - wins[2]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleefwins"); - losses[2]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleeflosses"); - } - } - } - } - Sign sign = (Sign)Bukkit.getWorld("world").getBlockAt(1611,85,42).getState(); - sign.setLine(0, "");sign.setLine(2, "");sign.setLine(3, ""); - sign.setLine(1, ChatColor.BOLD+name[0]); - sign.update(); - sign = (Sign)Bukkit.getWorld("world").getBlockAt(1611,84,43).getState(); - sign.setLine(0, "");sign.setLine(2, "");sign.setLine(3, ""); - sign.setLine(1, ChatColor.BOLD+"Wins: "+ChatColor.DARK_GREEN+wins[0]); - sign.update(); - sign = (Sign)Bukkit.getWorld("world").getBlockAt(1611,84,41).getState(); - sign.setLine(0, "");sign.setLine(2, "");sign.setLine(3, ""); - sign.setLine(1, ChatColor.BOLD+"Losses: "+ChatColor.DARK_GREEN+losses[0]); - sign.update(); - sign = (Sign)Bukkit.getWorld("world").getBlockAt(1612,84,42).getState(); - sign.setLine(0, "");sign.setLine(2, "");sign.setLine(3, ""); - sign.setLine(1, ChatColor.BOLD+"RATING: "+ChatColor.DARK_GREEN+rating[0]/10); - sign.update(); - - sign = (Sign)Bukkit.getWorld("world").getBlockAt(1611,85,39).getState(); - sign.setLine(0, ChatColor.BOLD+name[1]); - sign.setLine(1, "Rating: "+rating[1]/10); - sign.setLine(2, ChatColor.ITALIC+"Wins: "+wins[1]); - sign.setLine(3, ChatColor.ITALIC+"Losses: "+losses[1]); - sign.update(); - - sign = (Sign)Bukkit.getWorld("world").getBlockAt(1611,84,37).getState(); - sign.setLine(0, ChatColor.BOLD+name[2]); - sign.setLine(1, "Rating: "+rating[2]/10); - sign.setLine(2, ChatColor.ITALIC+"Wins: "+wins[2]); - sign.setLine(3, ChatColor.ITALIC+"Losses: "+losses[2]); - sign.update(); - } - - @EventHandler - public void onServerListPing(ServerListPingEvent e) { - e.setMaxPlayers(16); - if (this.plugin.getConfig().getBoolean("maintenance-mode")) { - e.setMotd(ChatColor.RED+"Currently in Maintenance Mode."); - } else { - e.setMotd("Sig's Minecraft - "+ChatColor.BLUE+"Currently Online."); - } - return; - } - - @EventHandler - public void onPlayerGainEXP(PlayerExpChangeEvent e) { - Player p = e.getPlayer(); - if (this.plugin.PlayerinJob(p, "Enchanter") && this.plugin.getJobLv("Enchanter", p)>=5) { - e.setAmount(e.getAmount()*2); - } - if (this.plugin.getAccountsConfig().getBoolean("halloween-enabled")) { - e.setAmount(e.getAmount()*2); - } - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify3")) { - p.sendMessage(ChatColor.DARK_GREEN+""+ChatColor.ITALIC+"Gained "+e.getAmount()+" exp."); - } - } + public PlayerListener(Main plugin) + { + this.plugin = plugin; + } - @EventHandler - public void onBrewingStandBrew(BrewEvent e) { - //Look for an owner to this brewingstand. - String owner=""; - int mult=0; - boolean allowed=true; - for (int i=0;i=10) { - ItemStack[] items = e.getContents().getContents(); - for (int i=0;i=20) { + if (this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating")>rating[0]) { + //This beats the top record, move everything down. + name[2]=name[1];rating[2]=rating[1];wins[2]=wins[1];losses[2]=losses[1]; + name[1]=name[0];rating[1]=rating[0];wins[1]=wins[0];losses[1]=losses[0]; + name[0]=playerlist[i].getName(); + rating[0]=(int)this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating"); + wins[0]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleefwins"); + losses[0]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleeflosses"); + } else + if (this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating")>rating[1]) { + //This beats the 2nd record, move everything down. + name[2]=name[1];rating[2]=rating[1];wins[2]=wins[1];losses[2]=losses[1]; + name[1]=playerlist[i].getName(); + rating[1]=(int)this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating"); + wins[1]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleefwins"); + losses[1]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleeflosses"); + } else + if (this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating")>rating[2]) { + //This beats the 3rd record, move everything down. + name[2]=playerlist[i].getName(); + rating[2]=(int)this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating"); + wins[2]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleefwins"); + losses[2]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleeflosses"); + } + } + } + } + Sign sign = (Sign)Bukkit.getWorld("world").getBlockAt(1611,85,42).getState(); + sign.setLine(0, "");sign.setLine(2, "");sign.setLine(3, ""); + sign.setLine(1, ChatColor.BOLD+name[0]); + sign.update(); + sign = (Sign)Bukkit.getWorld("world").getBlockAt(1611,84,43).getState(); + sign.setLine(0, "");sign.setLine(2, "");sign.setLine(3, ""); + sign.setLine(1, ChatColor.BOLD+"Wins: "+ChatColor.DARK_GREEN+wins[0]); + sign.update(); + sign = (Sign)Bukkit.getWorld("world").getBlockAt(1611,84,41).getState(); + sign.setLine(0, "");sign.setLine(2, "");sign.setLine(3, ""); + sign.setLine(1, ChatColor.BOLD+"Losses: "+ChatColor.DARK_GREEN+losses[0]); + sign.update(); + sign = (Sign)Bukkit.getWorld("world").getBlockAt(1612,84,42).getState(); + sign.setLine(0, "");sign.setLine(2, "");sign.setLine(3, ""); + sign.setLine(1, ChatColor.BOLD+"RATING: "+ChatColor.DARK_GREEN+rating[0]/10); + sign.update(); + sign = (Sign)Bukkit.getWorld("world").getBlockAt(1611,85,39).getState(); + sign.setLine(0, ChatColor.BOLD+name[1]); + sign.setLine(1, "Rating: "+rating[1]/10); + sign.setLine(2, ChatColor.ITALIC+"Wins: "+wins[1]); + sign.setLine(3, ChatColor.ITALIC+"Losses: "+losses[1]); + sign.update(); - @EventHandler - public void onEnchantItem(EnchantItemEvent e) { - Map map = e.getEnchantsToAdd(); - Player p = e.getEnchanter(); - /*e.getEnchanter().sendMessage("Enchantments are:"); + sign = (Sign)Bukkit.getWorld("world").getBlockAt(1611,84,37).getState(); + sign.setLine(0, ChatColor.BOLD+name[2]); + sign.setLine(1, "Rating: "+rating[2]/10); + sign.setLine(2, ChatColor.ITALIC+"Wins: "+wins[2]); + sign.setLine(3, ChatColor.ITALIC+"Losses: "+losses[2]); + sign.update(); + } + + @EventHandler + public void onServerListPing(ServerListPingEvent e) { + e.setMaxPlayers(16); + if (this.plugin.getConfig().getBoolean("maintenance-mode")) { + e.setMotd(ChatColor.RED+"Currently in Maintenance Mode."); + } else { + e.setMotd("Sig's Minecraft - "+ChatColor.BLUE+"Currently Online."); + } + return; + } + + @EventHandler + public void onPlayerGainEXP(PlayerExpChangeEvent e) { + Player p = e.getPlayer(); + if (this.plugin.PlayerinJob(p, "Enchanter") && this.plugin.getJobLv("Enchanter", p)>=5) { + e.setAmount(e.getAmount()*2); + } + if (this.plugin.getAccountsConfig().getBoolean("halloween-enabled")) { + e.setAmount(e.getAmount()*2); + } + if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify3")) { + p.sendMessage(ChatColor.DARK_GREEN+""+ChatColor.ITALIC+"Gained "+e.getAmount()+" exp."); + } + } + + @EventHandler + public void onBrewingStandBrew(BrewEvent e) { + //Look for an owner to this brewingstand. + String owner=""; + int mult=0; + boolean allowed=true; + for (int i=0;i=10) { + ItemStack[] items = e.getContents().getContents(); + for (int i=0;i map = e.getEnchantsToAdd(); + Player p = e.getEnchanter(); + /*e.getEnchanter().sendMessage("Enchantments are:"); for (Map.Entry entry : map.entrySet()) { e.getEnchanter().sendMessage(entry.getKey().getName()+" "+entry.getValue()); }*/ - /* + /* if (Math.random()<=0.05) { //5% chance of getting a book when enchanting. ItemStack book = new ItemStack(Material.WRITTEN_BOOK); @@ -445,985 +445,985 @@ public class PlayerListener p.updateInventory(); p.sendMessage(ChatColor.LIGHT_PURPLE+"You feel a magical presence get inserted into your inventory."); }*/ - - - if (this.plugin.PlayerinJob(p, "Enchanter")) { - if (this.plugin.getJobLv("Enchanter", p)>=10) { - e.setExpLevelCost((int)(e.getExpLevelCost()*0.75)); - if (e.getItem().getType()==Material.BOW) { - int enchants[] = {48,49,50,51}; - for (int j=0;j ourLore = new ArrayList(); - if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. - List thelore = e.getItem().getItemMeta().getLore(); - for (int i=0;i ourLore = new ArrayList(); - if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. - List thelore = e.getItem().getItemMeta().getLore(); - for (int i=0;i ourLore = new ArrayList(); - if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. - List thelore = e.getItem().getItemMeta().getLore(); - for (int i=0;i ourLore = new ArrayList(); - if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. - List thelore = e.getItem().getItemMeta().getLore(); - for (int i=0;i entry : map.entrySet()) { - if (this.plugin.getJobLv("Enchanter", p)>=20) { - if (entry.getKey().getMaxLevel() ourLore = new ArrayList(); - if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. - List thelore = e.getItem().getItemMeta().getLore(); - for (int i=0;i ourLore = new ArrayList(); - if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. - List thelore = e.getItem().getItemMeta().getLore(); - for (int i=0;i ourLore = new ArrayList(); - if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. - List thelore = e.getItem().getItemMeta().getLore(); - for (int i=0;i ourLore = new ArrayList(); - if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. - List thelore = e.getItem().getItemMeta().getLore(); - for (int i=0;i=5) { - //Bukkit.getPlayer("sigonasr2").sendMessage("Old time: "+e.getBurnTime()); - e.setBurnTime(e.getBurnTime()*2); - //Bukkit.getPlayer("sigonasr2").sendMessage("Doubled the furnace's burn time. New time: "+e.getBurnTime()); - } - } - - @EventHandler - public void onFurnaceSmelt(FurnaceSmeltEvent e) { - //Bukkit.getPlayer("sigonasr2").sendMessage("Current time: "+((Furnace)e.getBlock().getState()).getBurnTime()); - //Look for an owner to this furnace. - String owner=""; - for (int i=0;i=20 && crafteditem) { - ItemStack result = e.getResult(); - result.setAmount(result.getAmount()+1); - e.setResult(result); - } - } - } - - @EventHandler - public void onCreatureInteract(PlayerInteractEntityEvent e) { - Player p = e.getPlayer(); - //When right-clicked on, check if it already exists in the entity list. - boolean contains=false; - int slot=0; - for (int i=0;i=20) { - Cow a = (Cow)e.getRightClicked(); - if (a.canBreed()) { - if (Math.random()<=0.50) { - p.getItemInHand().setAmount(p.getItemInHand().getAmount()); - } - } - } - //See if it exists already. - boolean contains_uuid=false; - String finalstring = ""; - if (this.plugin.getConfig().getString("fed.mobs").length()>4) { - String[] mobslist = this.plugin.getConfig().getString("fed.mobs").split(","); - //p.sendMessage("Mobs list length: "+mobslist.length); - for (int i=0;i=20) { - Sheep a = (Sheep)e.getRightClicked(); - if (a.canBreed()) { - if (Math.random()<=0.50) { - p.getItemInHand().setAmount(p.getItemInHand().getAmount()); - } - } - } - //See if it exists already. - boolean contains_uuid=false; - String finalstring = ""; - if (this.plugin.getConfig().getString("fed.mobs").length()>4) { - String[] mobslist = this.plugin.getConfig().getString("fed.mobs").split(","); - //p.sendMessage("Mobs list length: "+mobslist.length); - for (int i=0;i=20) { - Pig a = (Pig)e.getRightClicked(); - if (a.canBreed()) { - if (Math.random()<=0.50) { - p.getItemInHand().setAmount(p.getItemInHand().getAmount()); - } - } - } - //See if it exists already. - boolean contains_uuid=false; - String finalstring = ""; - if (this.plugin.getConfig().getString("fed.mobs").length()>4) { - String[] mobslist = this.plugin.getConfig().getString("fed.mobs").split(","); - //p.sendMessage("Mobs list length: "+mobslist.length); - for (int i=0;i=20) { - Chicken a = (Chicken)e.getRightClicked(); - if (a.canBreed()) { - if (Math.random()<=0.50) { - p.getItemInHand().setAmount(p.getItemInHand().getAmount()); - } - } - } - //See if it exists already. - boolean contains_uuid=false; - String finalstring = ""; - if (this.plugin.getConfig().getString("fed.mobs").length()>4) { - String[] mobslist = this.plugin.getConfig().getString("fed.mobs").split(","); - //p.sendMessage("Mobs list length: "+mobslist.length); - for (int i=0;i=20) { - Wolf a = (Wolf)e.getRightClicked(); - if (a.canBreed()) { - if (Math.random()<=0.50) { - p.getItemInHand().setAmount(p.getItemInHand().getAmount()); - } - } - } - //See if it exists already. - boolean contains_uuid=false; - String finalstring = ""; - if (this.plugin.getConfig().getString("fed.mobs").length()>4) { - String[] mobslist = this.plugin.getConfig().getString("fed.mobs").split(","); - //p.sendMessage("Mobs list length: "+mobslist.length); - for (int i=0;i=20) { - Ocelot a = (Ocelot)e.getRightClicked(); - if (a.canBreed()) { - if (Math.random()<=0.50) { - p.getItemInHand().setAmount(p.getItemInHand().getAmount()); - } - } - } - //See if it exists already. - boolean contains_uuid=false; - String finalstring = ""; - if (this.plugin.getConfig().getString("fed.mobs").length()>4) { - String[] mobslist = this.plugin.getConfig().getString("fed.mobs").split(","); - ////p.sendMessage("Mobs list length: "+mobslist.length); - for (int i=0;i=20) { - Horse a = (Horse)e.getRightClicked(); - if (a.canBreed()) { - if (Math.random()<=0.50) { - p.getItemInHand().setAmount(p.getItemInHand().getAmount()); - } - } - } - //This is a special entity and won't be added to the list of animals to despawn for now. - } - } - } - @EventHandler - public void onShearEntity(PlayerShearEntityEvent e) { - Player p = e.getPlayer(); - if (this.plugin.PlayerinJob(p, "Breeder")) { - if (e.getEntity().getType()==EntityType.SHEEP) { - this.plugin.gainMoneyExp(p,"Breeder",0.002,0.2); - } - if (e.getEntity().getType()==EntityType.MUSHROOM_COW) { - this.plugin.gainMoneyExp(p,"Breeder",0.005,1); - } - } - if (e.getEntity().getType()==EntityType.MUSHROOM_COW) { - Bukkit.getWorld("world").spawnEntity(e.getEntity().getLocation(), EntityType.COW); - } - Bukkit.getWorld("world").spawnEntity((Location) e.getEntity(), EntityType.COW); - } - - @EventHandler - public void onSheepDye(SheepDyeWoolEvent e) { - int slot=-1; - Player p=null; - for (int i=0;i=10) { + e.setExpLevelCost((int)(e.getExpLevelCost()*0.75)); + if (e.getItem().getType()==Material.BOW) { + int enchants[] = {48,49,50,51}; + for (int j=0;j ourLore = new ArrayList(); + if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. + List thelore = e.getItem().getItemMeta().getLore(); + for (int i=0;i ourLore = new ArrayList(); + if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. + List thelore = e.getItem().getItemMeta().getLore(); + for (int i=0;i ourLore = new ArrayList(); + if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. + List thelore = e.getItem().getItemMeta().getLore(); + for (int i=0;i ourLore = new ArrayList(); + if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. + List thelore = e.getItem().getItemMeta().getLore(); + for (int i=0;i entry : map.entrySet()) { + if (this.plugin.getJobLv("Enchanter", p)>=20) { + if (entry.getKey().getMaxLevel() ourLore = new ArrayList(); + if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. + List thelore = e.getItem().getItemMeta().getLore(); + for (int i=0;i ourLore = new ArrayList(); + if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. + List thelore = e.getItem().getItemMeta().getLore(); + for (int i=0;i ourLore = new ArrayList(); + if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. + List thelore = e.getItem().getItemMeta().getLore(); + for (int i=0;i ourLore = new ArrayList(); + if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. + List thelore = e.getItem().getItemMeta().getLore(); + for (int i=0;i=10) { - e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 0, true)); - } - } else { - if (this.plugin.PlayerinJob(e.getPlayer(),"Hunter") && this.plugin.getJobLv("Hunter", e.getPlayer())>=10) { - if (e.getPlayer().hasPotionEffect(PotionEffectType.INVISIBILITY)) { - try { - Collection effects = e.getPlayer().getActivePotionEffects(); - for (PotionEffect nextpotioneffect : effects) { - if (nextpotioneffect.getType().getName().compareTo("INVISIBILITY")==0 && nextpotioneffect.getDuration()>24000) { - //This is definitely not a potion given to you. - e.getPlayer().removePotionEffect(PotionEffectType.INVISIBILITY); - break; - } - } - } catch (ConcurrentModificationException ex_e) { - Bukkit.getLogger().warning("Potion Effect Collection not accessible for a hunter while toggling sneak mode."); - } - } - } - } - } - - public String healthbar(double curHP,double maxHP) { - //笆�笆� - int bits=(int)(Math.ceil(curHP/maxHP*10)); - String bar=" "; - if (bits>6) { - bar+=ChatColor.GREEN+""; - } else - if (bits>3) { - bar+=ChatColor.YELLOW+""; - } else - { - bar+=ChatColor.RED+""; - } - for (int i=0;i6) { - bar+=ChatColor.GREEN+""; - } else - if (bits>3) { - bar+=ChatColor.YELLOW+""; - } else - { - bar+=ChatColor.RED+""; - } - } else { - if (bits>6) { - bar+=ChatColor.DARK_GREEN+""; - } else - if (bits>3) { - bar+=ChatColor.GOLD+""; - } else - { - bar+=ChatColor.DARK_RED+""; - } - } - for (int i=0;i=5) { + //Bukkit.getPlayer("sigonasr2").sendMessage("Old time: "+e.getBurnTime()); + e.setBurnTime(e.getBurnTime()*2); + //Bukkit.getPlayer("sigonasr2").sendMessage("Doubled the furnace's burn time. New time: "+e.getBurnTime()); + } } - if (p.hasPermission("group.administrators")) { - tempteam.setPrefix(ChatColor.LIGHT_PURPLE+""); + + @EventHandler + public void onFurnaceSmelt(FurnaceSmeltEvent e) { + //Bukkit.getPlayer("sigonasr2").sendMessage("Current time: "+((Furnace)e.getBlock().getState()).getBurnTime()); + //Look for an owner to this furnace. + String owner=""; + for (int i=0;i=20 && crafteditem) { + ItemStack result = e.getResult(); + result.setAmount(result.getAmount()+1); + e.setResult(result); + } + } } - tempteam.setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); - tempteam.addPlayer(p.getPlayer()); - if (this.plugin.getConfig().getBoolean("maintenance-mode") && !p.hasPermission("maintenance-mode")) { - p.kickPlayer("Sorry, the server is currently under "+ChatColor.GREEN+" Maintenance Mode."); - return; - } - //Look through inventory. - for (int i=0;i newlore = p.getInventory().getArmorContents()[i].getItemMeta().getLore(); - for (int j=0;j=20) { + Cow a = (Cow)e.getRightClicked(); + if (a.canBreed()) { + if (Math.random()<=0.50) { + p.getItemInHand().setAmount(p.getItemInHand().getAmount()); + } + } + } + //See if it exists already. + boolean contains_uuid=false; + String finalstring = ""; + if (this.plugin.getConfig().getString("fed.mobs").length()>4) { + String[] mobslist = this.plugin.getConfig().getString("fed.mobs").split(","); + //p.sendMessage("Mobs list length: "+mobslist.length); + for (int i=0;i=20) { + Sheep a = (Sheep)e.getRightClicked(); + if (a.canBreed()) { + if (Math.random()<=0.50) { + p.getItemInHand().setAmount(p.getItemInHand().getAmount()); + } + } + } + //See if it exists already. + boolean contains_uuid=false; + String finalstring = ""; + if (this.plugin.getConfig().getString("fed.mobs").length()>4) { + String[] mobslist = this.plugin.getConfig().getString("fed.mobs").split(","); + //p.sendMessage("Mobs list length: "+mobslist.length); + for (int i=0;i=20) { + Pig a = (Pig)e.getRightClicked(); + if (a.canBreed()) { + if (Math.random()<=0.50) { + p.getItemInHand().setAmount(p.getItemInHand().getAmount()); + } + } + } + //See if it exists already. + boolean contains_uuid=false; + String finalstring = ""; + if (this.plugin.getConfig().getString("fed.mobs").length()>4) { + String[] mobslist = this.plugin.getConfig().getString("fed.mobs").split(","); + //p.sendMessage("Mobs list length: "+mobslist.length); + for (int i=0;i=20) { + Chicken a = (Chicken)e.getRightClicked(); + if (a.canBreed()) { + if (Math.random()<=0.50) { + p.getItemInHand().setAmount(p.getItemInHand().getAmount()); + } + } + } + //See if it exists already. + boolean contains_uuid=false; + String finalstring = ""; + if (this.plugin.getConfig().getString("fed.mobs").length()>4) { + String[] mobslist = this.plugin.getConfig().getString("fed.mobs").split(","); + //p.sendMessage("Mobs list length: "+mobslist.length); + for (int i=0;i=20) { + Wolf a = (Wolf)e.getRightClicked(); + if (a.canBreed()) { + if (Math.random()<=0.50) { + p.getItemInHand().setAmount(p.getItemInHand().getAmount()); + } + } + } + //See if it exists already. + boolean contains_uuid=false; + String finalstring = ""; + if (this.plugin.getConfig().getString("fed.mobs").length()>4) { + String[] mobslist = this.plugin.getConfig().getString("fed.mobs").split(","); + //p.sendMessage("Mobs list length: "+mobslist.length); + for (int i=0;i=20) { + Ocelot a = (Ocelot)e.getRightClicked(); + if (a.canBreed()) { + if (Math.random()<=0.50) { + p.getItemInHand().setAmount(p.getItemInHand().getAmount()); + } + } + } + //See if it exists already. + boolean contains_uuid=false; + String finalstring = ""; + if (this.plugin.getConfig().getString("fed.mobs").length()>4) { + String[] mobslist = this.plugin.getConfig().getString("fed.mobs").split(","); + ////p.sendMessage("Mobs list length: "+mobslist.length); + for (int i=0;i=20) { + Horse a = (Horse)e.getRightClicked(); + if (a.canBreed()) { + if (Math.random()<=0.50) { + p.getItemInHand().setAmount(p.getItemInHand().getAmount()); + } + } + } + //This is a special entity and won't be added to the list of animals to despawn for now. + } + } + } + + @EventHandler + public void onShearEntity(PlayerShearEntityEvent e) { + Player p = e.getPlayer(); + if (this.plugin.PlayerinJob(p, "Breeder")) { + if (e.getEntity().getType()==EntityType.SHEEP) { + this.plugin.gainMoneyExp(p,"Breeder",0.002,0.2); + } + if (e.getEntity().getType()==EntityType.MUSHROOM_COW) { + this.plugin.gainMoneyExp(p,"Breeder",0.005,1); + } + } + if (e.getEntity().getType()==EntityType.MUSHROOM_COW) { + Bukkit.getWorld("world").spawnEntity(e.getEntity().getLocation(), EntityType.COW); + } + Bukkit.getWorld("world").spawnEntity((Location) e.getEntity(), EntityType.COW); + } + + @EventHandler + public void onSheepDye(SheepDyeWoolEvent e) { + int slot=-1; + Player p=null; + for (int i=0;i=10) { + e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 0, true)); + } + } else { + if (this.plugin.PlayerinJob(e.getPlayer(),"Hunter") && this.plugin.getJobLv("Hunter", e.getPlayer())>=10) { + if (e.getPlayer().hasPotionEffect(PotionEffectType.INVISIBILITY)) { + try { + Collection effects = e.getPlayer().getActivePotionEffects(); + for (PotionEffect nextpotioneffect : effects) { + if (nextpotioneffect.getType().getName().compareTo("INVISIBILITY")==0 && nextpotioneffect.getDuration()>24000) { + //This is definitely not a potion given to you. + e.getPlayer().removePotionEffect(PotionEffectType.INVISIBILITY); + break; + } + } + } catch (ConcurrentModificationException ex_e) { + Bukkit.getLogger().warning("Potion Effect Collection not accessible for a hunter while toggling sneak mode."); + } + } + } + } + } + + public String healthbar(double curHP,double maxHP) { + //笆�笆� + int bits=(int)(Math.ceil(curHP/maxHP*10)); + String bar=" "; + if (bits>6) { + bar+=ChatColor.GREEN+""; + } else + if (bits>3) { + bar+=ChatColor.YELLOW+""; + } else + { + bar+=ChatColor.RED+""; + } + for (int i=0;i6) { + bar+=ChatColor.GREEN+""; + } else + if (bits>3) { + bar+=ChatColor.YELLOW+""; + } else + { + bar+=ChatColor.RED+""; + } + } else { + if (bits>6) { + bar+=ChatColor.DARK_GREEN+""; + } else + if (bits>3) { + bar+=ChatColor.GOLD+""; + } else + { + bar+=ChatColor.DARK_RED+""; + } + } + for (int i=0;i newlore = p.getInventory().getArmorContents()[i].getItemMeta().getLore(); + for (int j=0;j=5) { - //p.sendMessage("Explorer speed buff set."); - newplayer.setBaseSpd(1); - } - if (this.plugin.PlayerinJob(p, "Hunter") && this.plugin.getJobLv("Hunter", p)>=20) { - //p.sendMessage("Explorer speed buff set."); - newplayer.setBaseSpd(newplayer.base_spdlv+1); - } - //Bukkit.getPlayer("sigonasr2").sendMessage("Got to here."); - newplayer.updatePlayerSpd(); - this.plugin.SPEED_CONTROL.add(newplayer); - //Bukkit.getPlayer("sigonasr2").sendMessage("Got to here."); - Iterator players = Bukkit.getWhitelistedPlayers().iterator(); - boolean playerwhitelisted=false; - String playerslist = ""; - while (players.hasNext()) { - if (playerslist!="") { - playerslist += ","; - } - String name = players.next().getName(); - playerslist += name; - if (name.compareToIgnoreCase(p.getName())==0) { - playerwhitelisted=true; - } - } - /* + + p.updateInventory(); + if (this.plugin.PlayerinJob(p, "Explorer") && this.plugin.getJobLv("Explorer", p)>=5) { + //p.sendMessage("Explorer speed buff set."); + newplayer.setBaseSpd(1); + } + if (this.plugin.PlayerinJob(p, "Hunter") && this.plugin.getJobLv("Hunter", p)>=20) { + //p.sendMessage("Explorer speed buff set."); + newplayer.setBaseSpd(newplayer.base_spdlv+1); + } + //Bukkit.getPlayer("sigonasr2").sendMessage("Got to here."); + newplayer.updatePlayerSpd(); + this.plugin.SPEED_CONTROL.add(newplayer); + //Bukkit.getPlayer("sigonasr2").sendMessage("Got to here."); + Iterator players = Bukkit.getWhitelistedPlayers().iterator(); + boolean playerwhitelisted=false; + String playerslist = ""; + while (players.hasNext()) { + if (playerslist!="") { + playerslist += ","; + } + String name = players.next().getName(); + playerslist += name; + if (name.compareToIgnoreCase(p.getName())==0) { + playerwhitelisted=true; + } + } + /* //Boss platform is created +,+ coordinates from the location specified. File file = new File("plugins/WorldEdit/schematics/boss.schematic"); if (file.exists()) { @@ -1483,216 +1483,216 @@ public class PlayerListener } else { Bukkit.getLogger().warning(("File does not exist.")); } - */ - //System.out.println("Whitelisted Players: "+playerslist); - //System.out.println("Maximum Air: "+p.getMaximumAir()); - if (!this.plugin.getAccountsConfig().contains(p.getName())) { - //This is a brand new player. - Main.economy.withdrawPlayer(p.getName(), Main.economy.getBalance(p.getName())); - Main.economy.depositPlayer(p.getName(), 70); - this.plugin.getAccountsConfig().set(p.getName() + ".status", Boolean.valueOf(true)); - this.plugin.getAccountsConfig().set(p.getName() + ".money", Double.valueOf(this.plugin.getConfig().getDouble("start-balance"))); - this.plugin.getAccountsConfig().set(p.getName() + ".revived", Boolean.valueOf(true)); - this.plugin.getAccountsConfig().set(p.getName() + ".spleefrating", Double.valueOf(1000.0d)); - this.plugin.getAccountsConfig().set(p.getName() + ".spleefwins", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".spleeflosses", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job1", String.valueOf("None")); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job1lv", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job1exp", Double.valueOf(0.0d)); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job2", String.valueOf("None")); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job2lv", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job2exp", Double.valueOf(0.0d)); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job3", String.valueOf("None")); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job3lv", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job3exp", Double.valueOf(0.0d)); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.ultimate", String.valueOf("None")); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.ultimatesealed", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat1", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat2", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat3", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat4", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat5", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat6", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat7", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat8", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat9", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat10", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify1", Boolean.valueOf(true)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify2", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify3", Boolean.valueOf(true)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify4", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify5", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify6", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest1", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest2", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest3", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest4", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest5", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest6", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest7", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest8", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest9", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest10", Boolean.valueOf(false)); - this.plugin.saveAccountsConfig(); - System.out.println("[BankEconomy] Bank account created for " + p.getName() + "."); - if (playerwhitelisted) { - Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE+"New player "+ChatColor.ITALIC+ChatColor.GOLD+p.getName()+ChatColor.RESET+ChatColor.LIGHT_PURPLE+" has joined the game."); - //Give a tutorial book and starting items to this user. - p.getInventory().addItem(new ItemStack(Material.STONE_SWORD)); - p.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE)); - p.getInventory().addItem(new ItemStack(Material.COOKED_CHICKEN,16)); - p.getInventory().addItem(new ItemStack(Material.TORCH,32)); - p.getInventory().addItem(new ItemStack(Material.LEATHER_HELMET)); - p.getInventory().addItem(new ItemStack(Material.LEATHER_CHESTPLATE)); - p.getInventory().addItem(new ItemStack(Material.LEATHER_LEGGINGS)); - p.getInventory().addItem(new ItemStack(Material.LEATHER_BOOTS)); - p.getInventory().addItem(new ItemStack(Material.MINECART)); - } - } else { - DecimalFormat df = new DecimalFormat("#0.00"); - p.sendMessage(ChatColor.DARK_AQUA+"For a list of all changes made to this server, visit: http://z-gamers.net/changelog.html"); - p.sendMessage("----------------------------"); - p.sendMessage(ChatColor.YELLOW+"Current Money Balance: $ "+df.format(Main.economy.bankBalance(p.getName()).balance)+", Bank Balance: $"+df.format(this.plugin.getAccountsConfig().getDouble(p.getName()+".money"))); - //Update account information for the stat point update. - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".stats.stat1")) { - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat1", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat2", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat3", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat4", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat5", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat6", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat7", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat8", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat9", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat10", Integer.valueOf(0)); - this.plugin.saveAccountsConfig(); - System.out.println("Updated " + p.getName() + "'s data with stat point update."); - } - //Update account information for notification settings. - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".settings.notify1")) { - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify1", Boolean.valueOf(true)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify2", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify3", Boolean.valueOf(true)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify4", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify5", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify6", Boolean.valueOf(false)); - this.plugin.saveAccountsConfig(); - System.out.println("Updated " + p.getName() + "'s data with nofitications update."); - } - if (this.plugin.getConfig().getBoolean("halloween-enabled")) { - //Update account information for Halloween book update. - PlayerInventory pi = p.getInventory(); - boolean full=true; - for (int i=0;i0) { - p.setMaximumAir(300+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName() + ".stats.stat10"))*20); - } - if (p.getLocation().getY()>78.0d && p.getLocation().getZ()>53.0d && p.getLocation().getZ()<64.0d && p.getLocation().getX()<1627.0d && p.getLocation().getX()>1616.0d) { - //In a spleef zone. Kick this player out. - Location newloc = p.getLocation(); - newloc.setX(1622.5d); - newloc.setY(87.0d); - newloc.setZ(51.65d); - p.teleport(newloc); - this.plugin.getConfig().set("spleefinsession", Boolean.valueOf(false)); - } - } - boolean found=false; - for (int i=0;i effects = p.getActivePotionEffects().iterator(); + */ + //System.out.println("Whitelisted Players: "+playerslist); + //System.out.println("Maximum Air: "+p.getMaximumAir()); + if (!this.plugin.getAccountsConfig().contains(p.getName())) { + //This is a brand new player. + Main.economy.withdrawPlayer(p.getName(), Main.economy.getBalance(p.getName())); + Main.economy.depositPlayer(p.getName(), 70); + this.plugin.getAccountsConfig().set(p.getName() + ".status", Boolean.valueOf(true)); + this.plugin.getAccountsConfig().set(p.getName() + ".money", Double.valueOf(this.plugin.getConfig().getDouble("start-balance"))); + this.plugin.getAccountsConfig().set(p.getName() + ".revived", Boolean.valueOf(true)); + this.plugin.getAccountsConfig().set(p.getName() + ".spleefrating", Double.valueOf(1000.0d)); + this.plugin.getAccountsConfig().set(p.getName() + ".spleefwins", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".spleeflosses", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job1", String.valueOf("None")); + this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job1lv", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job1exp", Double.valueOf(0.0d)); + this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job2", String.valueOf("None")); + this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job2lv", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job2exp", Double.valueOf(0.0d)); + this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job3", String.valueOf("None")); + this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job3lv", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job3exp", Double.valueOf(0.0d)); + this.plugin.getAccountsConfig().set(p.getName() + ".jobs.ultimate", String.valueOf("None")); + this.plugin.getAccountsConfig().set(p.getName() + ".jobs.ultimatesealed", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat1", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat2", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat3", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat4", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat5", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat6", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat7", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat8", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat9", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat10", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify1", Boolean.valueOf(true)); + this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify2", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify3", Boolean.valueOf(true)); + this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify4", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify5", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify6", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest1", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest2", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest3", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest4", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest5", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest6", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest7", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest8", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest9", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest10", Boolean.valueOf(false)); + this.plugin.saveAccountsConfig(); + System.out.println("[BankEconomy] Bank account created for " + p.getName() + "."); + if (playerwhitelisted) { + Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE+"New player "+ChatColor.ITALIC+ChatColor.GOLD+p.getName()+ChatColor.RESET+ChatColor.LIGHT_PURPLE+" has joined the game."); + //Give a tutorial book and starting items to this user. + p.getInventory().addItem(new ItemStack(Material.STONE_SWORD)); + p.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE)); + p.getInventory().addItem(new ItemStack(Material.COOKED_CHICKEN,16)); + p.getInventory().addItem(new ItemStack(Material.TORCH,32)); + p.getInventory().addItem(new ItemStack(Material.LEATHER_HELMET)); + p.getInventory().addItem(new ItemStack(Material.LEATHER_CHESTPLATE)); + p.getInventory().addItem(new ItemStack(Material.LEATHER_LEGGINGS)); + p.getInventory().addItem(new ItemStack(Material.LEATHER_BOOTS)); + p.getInventory().addItem(new ItemStack(Material.MINECART)); + } + } else { + DecimalFormat df = new DecimalFormat("#0.00"); + p.sendMessage(ChatColor.DARK_AQUA+"For a list of all changes made to this server, visit: http://z-gamers.net/changelog.html"); + p.sendMessage("----------------------------"); + p.sendMessage(ChatColor.YELLOW+"Current Money Balance: $ "+df.format(Main.economy.bankBalance(p.getName()).balance)+", Bank Balance: $"+df.format(this.plugin.getAccountsConfig().getDouble(p.getName()+".money"))); + //Update account information for the stat point update. + if (!this.plugin.getAccountsConfig().contains(p.getName() + ".stats.stat1")) { + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat1", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat2", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat3", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat4", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat5", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat6", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat7", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat8", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat9", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat10", Integer.valueOf(0)); + this.plugin.saveAccountsConfig(); + System.out.println("Updated " + p.getName() + "'s data with stat point update."); + } + //Update account information for notification settings. + if (!this.plugin.getAccountsConfig().contains(p.getName() + ".settings.notify1")) { + this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify1", Boolean.valueOf(true)); + this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify2", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify3", Boolean.valueOf(true)); + this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify4", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify5", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify6", Boolean.valueOf(false)); + this.plugin.saveAccountsConfig(); + System.out.println("Updated " + p.getName() + "'s data with nofitications update."); + } + if (this.plugin.getConfig().getBoolean("halloween-enabled")) { + //Update account information for Halloween book update. + PlayerInventory pi = p.getInventory(); + boolean full=true; + for (int i=0;i0) { + p.setMaximumAir(300+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName() + ".stats.stat10"))*20); + } + if (p.getLocation().getY()>78.0d && p.getLocation().getZ()>53.0d && p.getLocation().getZ()<64.0d && p.getLocation().getX()<1627.0d && p.getLocation().getX()>1616.0d) { + //In a spleef zone. Kick this player out. + Location newloc = p.getLocation(); + newloc.setX(1622.5d); + newloc.setY(87.0d); + newloc.setZ(51.65d); + p.teleport(newloc); + this.plugin.getConfig().set("spleefinsession", Boolean.valueOf(false)); + } + } + boolean found=false; + for (int i=0;i effects = p.getActivePotionEffects().iterator(); //Figure out potion effects when player joins. while (effects.hasNext()) { PotionEffect nexteffect = effects.next(); @@ -1702,1607 +1702,1607 @@ public class PlayerListener p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 360000, nexteffect.getAmplifier()+2, true)); }*/ effects.remove(); - } - - } catch (ConcurrentModificationException ex_e) { - Bukkit.getLogger().warning("Potion Effect Collection not accessible while trying to slow down player."); - } - updateTopSPLEEFSigns(); - } - - /* - @EventHandler - public void onPortalEnter(PlayerTeleportEvent e) { - final Player p = e.getPlayer(); - if (e.getFrom().getWorld()==Bukkit.getWorld("world")) { - if (e.getFrom().distanceSquared(new Location(Bukkit.getWorld("world"),1606d,66d,-365d))<900) { - //This is a player trying to enter a portal. Verify if they have selected their ultimate. - if (this.plugin.getAccountsConfig().contains(e.getPlayer().getName()+".jobs.ultimate")) { - //Check if this job's ultimate level is high enough. - if (this.plugin.getJobLv(this.plugin.getAccountsConfig().getString(e.getPlayer().getName()+".jobs.ultimate"), e.getPlayer())>=40) { - //Allow this teleport. - //e.setTo(new Location(Bukkit.getWorld("world"),-8990,68,-4)); - Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { - @Override - public void run() { - p.getPlayer().teleport(new Location(Bukkit.getWorld("world"),-8990,68,-4)); - } - },5); - } else { - Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { - @Override - public void run() { - p.getPlayer().teleport(new Location(Bukkit.getWorld("world"),1606d,66d,-365d)); - } - },5); - } - } - } - } - }*/ - - @EventHandler - public void onPlayerInteract(PlayerInteractEntityEvent ev) { - Entity theAnimal = ev.getRightClicked(); - if (ev.getPlayer().getItemInHand().getType()==Material.getMaterial(127)) { - if (this.plugin.getAccountsConfig().getLong(ev.getPlayer().getName()+".halloween.wand")65) { - //Bukkit.broadcastMessage("PlayerListener: HP too high for ID "+id+". HP was "+hp); - } - return hp; - } - - @EventHandler - public void onBlockGrow(BlockGrowEvent e) { - int x1,y1,z1,x2=0,y2=0,z2=0; - x1=e.getBlock().getX(); - y1=e.getBlock().getY(); - z1=e.getBlock().getZ(); - Player[] plist= Bukkit.getOnlinePlayers(); - for (int i=0;i=20) { - if (Math.random()<=0.30) { - if (e.getBlock().getType()==Material.POTATO || e.getBlock().getType()==Material.CARROT || e.getBlock().getType()==Material.CROPS || e.getBlock().getType()==Material.MELON_STEM || e.getBlock().getType()==Material.PUMPKIN_STEM) { - if (e.getBlock().getData()<7) { - e.getBlock().setData((byte) (e.getBlock().getData()+1)); - } - } - if (e.getBlock().getType()==Material.COCOA) { - if (e.getBlock().getData()<8) { - e.getBlock().setData((byte) (e.getBlock().getData()+4)); - } - } - if (e.getBlock().getType()==Material.NETHER_WARTS) { - if (e.getBlock().getData()<3) { - e.getBlock().setData((byte) (e.getBlock().getData()+1)); - } - } - } - } - } - } - } - } - - private boolean isPermanentSpawn(CreatureSpawnEvent e, LivingEntity l) { - //Will return true if it's something that is not allowed to despawn. False if we are allowed to get rid of it. - //Basically this is the control that will determine if the mob stays or goes, before further processing is done. - //If the mob is identified as a special mob... - - EntityType type = l.getType(); - - //heightmodifier determines if it's a super tall chunk or a normal sized one. - int heightmodifier=0; - if (Bukkit.getWorld("world").getHighestBlockYAt(l.getLocation())>=96) { - heightmodifier=126; - } else { - heightmodifier=63; - } - - //Handle every special entity's spawning properties in here. - switch (type) { - case CREEPER:{ - if (l.getLocation().getY()<=40 && Math.random()<=0.08+((heightmodifier-l.getLocation().getY())*0.01d)) { - if (Math.random()<=0.35) { - l.setCustomName(ChatColor.YELLOW+"Explosive Creeper"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(l.getMaxHealth()*1.25d); - l.setHealth(l.getMaxHealth()); - } else - if (Math.random()<=0.15) { - l.setCustomName(ChatColor.GOLD+"Explosive Creeper II"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(l.getMaxHealth()*1.75d); - l.setHealth(l.getMaxHealth()); - } else - if (Math.random()<=0.35) { - l.setCustomName(ChatColor.YELLOW+"Destructive Creeper"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(l.getMaxHealth()*1.25d); - l.setHealth(l.getMaxHealth()); - } else { - l.setCustomName(ChatColor.GOLD+"Destructive Creeper II"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(l.getMaxHealth()*1.75d); - l.setHealth(l.getMaxHealth()); - } - } - }break; - case ARROW: { - }break; - case BAT: { - }break; - case BLAZE: { - }break; - case BOAT: { - }break; - case CAVE_SPIDER: { - }break; - case CHICKEN: { - }break; - case COMPLEX_PART: { - }break; - case COW: { - }break; - case DROPPED_ITEM: { - }break; - case EGG: { - }break; - case ENDERMAN: { - }break; - case ENDER_CRYSTAL: { - }break; - case ENDER_DRAGON: { - }break; - case ENDER_PEARL: { - }break; - case ENDER_SIGNAL: { - }break; - case EXPERIENCE_ORB: { - }break; - case FALLING_BLOCK: { - }break; - case FIREBALL: { - }break; - case FIREWORK: { - }break; - case FISHING_HOOK: { - }break; - case GHAST: { - }break; - case GIANT: { - }break; - case HORSE: { - }break; - case IRON_GOLEM: { - }break; - case ITEM_FRAME: { - }break; - case LEASH_HITCH: { - }break; - case LIGHTNING: { - }break; - case MAGMA_CUBE: { - }break; - case MINECART: { - }break; - case MINECART_CHEST: { - }break; - case MINECART_FURNACE: { - }break; - case MINECART_HOPPER: { - }break; - case MINECART_MOB_SPAWNER: { - }break; - case MINECART_TNT: { - }break; - case MUSHROOM_COW: { - }break; - case OCELOT: { - }break; - case PAINTING: { - }break; - case PIG: { - }break; - case PIG_ZOMBIE: { - }break; - case PLAYER: { - }break; - case PRIMED_TNT: { - }break; - case SHEEP: { - }break; - case SILVERFISH: { - }break; - case SKELETON: { - if (Math.random()<=0.10+((heightmodifier-l.getLocation().getY())*0.01d)) { - if (Math.random()<=0.85) { - l.setCustomName(ChatColor.YELLOW+"Sniper"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(l.getMaxHealth()/2); - l.setHealth(l.getMaxHealth()); - } else { - l.setCustomName(ChatColor.GOLD+"Sniper II"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(l.getMaxHealth()/4); - l.setHealth(l.getMaxHealth()); - } - } - }break; - case SLIME: { - }break; - case SMALL_FIREBALL: { - }break; - case SNOWBALL: { - }break; - case SNOWMAN: { - }break; - case SPIDER: { - if (Math.random()<=0.08+((heightmodifier-l.getLocation().getY())*0.01d)) { - if (Math.random()<=0.35) { - l.setCustomName(ChatColor.YELLOW+"Venomous Spider"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(l.getMaxHealth()); - l.setHealth(l.getMaxHealth()); - } else - if (Math.random()<=0.15) { - l.setCustomName(ChatColor.GOLD+"Venomous Spider II"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(l.getMaxHealth()*1.5); - l.setHealth(l.getMaxHealth()); - } else - if (Math.random()<=0.35) { - l.setCustomName(ChatColor.YELLOW+"Snaring Spider"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(l.getMaxHealth()*1.5); - l.setHealth(l.getMaxHealth()); - } else { - l.setCustomName(ChatColor.GOLD+"Snaring Spider II"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(l.getMaxHealth()*2); - l.setHealth(l.getMaxHealth()); - } - } - }break; - case SPLASH_POTION: { - }break; - case SQUID: { - }break; - case THROWN_EXP_BOTTLE: { - }break; - case UNKNOWN: { - }break; - case VILLAGER: { - }break; - case WEATHER: { - }break; - case WITCH: { - }break; - case WITHER: { - }break; - case WITHER_SKULL: { - }break; - case WOLF: { - }break; - case ZOMBIE: { - if (l.getHealth()<65) { - if (l.getLocation().getY()<=35 && Math.random()<=0.15) { - if (Math.random()<=0.85) { - l.setCustomName(ChatColor.YELLOW+"Charge Zombie"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(l.getMaxHealth()+5); - l.setHealth(l.getMaxHealth()); - } else { - l.setCustomName(ChatColor.GOLD+"Charge Zombie II"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(l.getMaxHealth()+20); - l.setHealth(l.getMaxHealth()); - } - } else { - if (Math.random()<=0.10+((heightmodifier-l.getLocation().getY())*0.01d)) { - if (Math.random()<=0.25) { - l.setCustomName(ChatColor.GRAY+"Zombie Ninja"); - l.setCustomNameVisible(false); - l.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 0, true)); - l.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 2, true)); - //l.setCustomNameVisible(true); - //A Zombie Ninja will not wear armor to stay hidden. But may carry a sword. - l.getEquipment().setChestplate(new ItemStack(Material.AIR)); - l.getEquipment().setBoots(new ItemStack(Material.AIR)); - l.getEquipment().setLeggings(new ItemStack(Material.AIR)); - l.getEquipment().setHelmet(new ItemStack(Material.AIR)); - Zombie g = (Zombie)l; - g.setBaby(true); - l.setMaxHealth(l.getMaxHealth()*0.65d); - l.setHealth(l.getMaxHealth()); - } - } - } - } else { - return false; - } - //If it's a super zombie, we're going to despawn it now. - }break; - default: { - } - } - - //This allows bosses to spawn. - if (e.getEntity().getType()==EntityType.ENDER_DRAGON || e.getEntity().getType()==EntityType.WITHER || - e.getEntity() instanceof Golem || e.getEntity() instanceof Animals) { - return true; - } - - //Custom bosses - if (l.getCustomName()!=null && (l.getCustomName().contains(ChatColor.DARK_PURPLE+"") || l.getCustomName().contains(ChatColor.DARK_AQUA+"Polymorphed Creature"))) { - return true; - } - - //Special reasons that should always happen. - if (e.getSpawnReason()==SpawnReason.SPAWNER || e.getSpawnReason()==SpawnReason.BUILD_IRONGOLEM || e.getSpawnReason()==SpawnReason.BREEDING || - e.getSpawnReason()==SpawnReason.BUILD_SNOWMAN || e.getSpawnReason()==SpawnReason.BUILD_WITHER || e.getSpawnReason()==SpawnReason.LIGHTNING || - e.getSpawnReason()==SpawnReason.SPAWNER_EGG || e.getSpawnReason()==SpawnReason.VILLAGE_DEFENSE || e.getSpawnReason()==SpawnReason.VILLAGE_INVASION) { - return true; - } - - return false; //If we got down to here, allow this particular mob to spawn. - - } - - - @EventHandler - public void onCreatureSpawn(CreatureSpawnEvent e) { - if (isPermanentSpawn(e, e.getEntity())) { - e.getEntity().setRemoveWhenFarAway(false); - - //If this is a boss that spawns from a command block, make sure the command blocks are removed. - if (e.getEntity().getCustomName()!=null && (e.getEntity().getCustomName().contains(ChatColor.DARK_PURPLE+"") || e.getEntity().getCustomName().contains(ChatColor.DARK_AQUA+"Polymorphed Creature"))) { - for (int i=-2;i<3;i++) { - for (int j=-2;j<3;j++) { - for (int k=-2;k<3;k++) { - if (Bukkit.getWorld("world").getBlockAt(e.getEntity().getLocation().add(i,j,k)).getType()==Material.COMMAND) { - Bukkit.getWorld("world").getBlockAt(e.getEntity().getLocation().add(i,j,k)).setType(Material.COBBLESTONE); - } - } - } - } - } - - //Give the wither bonuses. - if (e.getEntity() instanceof Wither) { - Wither w = (Wither)e.getEntity(); - w.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,999999,3)); - w.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,999999,3)); - w.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING,999999,3)); - w.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST,999999,40)); - w.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,2)); - w.setCustomName(ChatColor.GOLD+""+ChatColor.BOLD+"Mega Wither"); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule mobGriefing true"); - } - - } else { - float groupmult=1.0f; //Change this to modify the global grouping multiplier. - int maxgroup=(int)(10*groupmult); - double chancer=0.10d; - double despawnchancer=0.25d; - - if (e.getEntity().getHealth()>65 && e.getEntity().getCustomName()==null /*Meaning it's not a special mob.*/) { - e.getEntity().remove(); //Too much HP. Nothing should have this much. - return; - } - - boolean allow=false; //If this is set to true, it will not be marked for removal. - - //We will now determine if it is allowed to spawn due to being next to a boss or mob spawner. - List entities = e.getEntity().getWorld().getEntities(); - for (int i=0;i=96) { - //This is a tall world. - if (e.getEntity().getLocation().getBlockY()<=104) { - for (int i=104-e.getEntity().getLocation().getBlockY();i>0;i--) { - despawnchancer/=1.0175d; - } - } - } else { - //This is a short world. - if (e.getEntity().getLocation().getBlockY()<=52) { - for (int i=52-e.getEntity().getLocation().getBlockY();i>0;i--) { - despawnchancer/=1.025d; - } - } - } - - if (spawners==0 && (Math.random()<=despawnchancer || (torches+glowstone>=3))) { - allow=false; - } else { - allow=true; - } - - - int totallvs=0; - List nearbylist = e.getEntity().getNearbyEntities(30, 30, 30); - //Filter out all unrelated e.getEntity() types. - for (int k=0;kmaxgroup) { - allow=false; //Too many mobs, can't have more. - } - - if (!allow) { - //This is our chance to despawn it if we must. - e.getEntity().remove(); - } else { - //They will be allowed to spawn. Increase their base HP. - e.getEntity().setMaxHealth(e.getEntity().getMaxHealth()*1.15d); - e.getEntity().setHealth(e.getEntity().getMaxHealth()); - - - if (e.getEntity().getCustomName()!=null && e.getEntity().getCustomName().equals(ChatColor.GOLD+"Charge Zombie II")) { - //Destroy an area around itself. - for (int k=-4;k<5;k++) { - for (int j=-4;j<5;j++) { - for (int m=-1;m<5;m++) { - if (Math.random()<=1.00-((j+4)*0.05d)) { - Location checkloc = e.getEntity().getLocation().add(k,m,j); - Block bl = Bukkit.getWorld("world").getBlockAt(checkloc); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER || bl.getType()!=Material.COMMAND || bl.getType()!=Material.MOSSY_COBBLESTONE) { - bl.breakNaturally(); - } - } - } - } - } - } - - - if (e.getEntity().getType()==EntityType.ZOMBIE || e.getEntity().getType()==EntityType.PIG_ZOMBIE || e.getEntity().getType()==EntityType.SKELETON) { - //Modify the difficulty of the mobs based on who is around. - EntityEquipment inven = e.getEntity().getEquipment(); - if (inven!=null) { - inven.setBootsDropChance(0.02f); - inven.setChestplateDropChance(0.02f); - inven.setLeggingsDropChance(0.02f); - inven.setHelmetDropChance(0.02f); - inven.setItemInHandDropChance(0.02f); - if (e.getEntity().getType()==EntityType.SKELETON) { - inven.setItemInHand(new ItemStack(Material.BOW)); - } - } - - double levelsmult=1.0; - if (totallvs>20*levelsmult) { - if (totallvs<40*levelsmult) { - //Sometimes wear leather armor. Only for Skeletons and Zombies. - if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { - LivingEntity l = (LivingEntity) e.getEntity(); - if (Math.random()>=0.15) { - l.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); - if (Math.random()>=0.25) { - l.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); - if (Math.random()>=0.5) { - l.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); - if (Math.random()>=0.8) { - l.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); - } - } - } - } - } - } else - if (totallvs<60*levelsmult) { - //Wear leather armor a bit more often. Sometimes a chain piece here or there. Include a Wooden sword usually. - if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { - LivingEntity l = (LivingEntity) e.getEntity(); - if (e.getEntity().getType()==EntityType.ZOMBIE) { - if (Math.random()<=0.65) { - l.getEquipment().setItemInHand(new ItemStack(Material.WOOD_SWORD)); - } - } - if (e.getEntity().getType()==EntityType.SKELETON) { - if (Math.random()<=0.65) { - ItemStack new_bow = new ItemStack(Material.BOW); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1); - l.getEquipment().setItemInHand(new_bow); - } - } - if (Math.random()>=0.25) { - if (Math.random()<=0.75) { - l.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); - } else { - l.getEquipment().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); - } - if (Math.random()>=0.45) { - if (Math.random()<=0.75) { - l.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); - } else { - l.getEquipment().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); - } - if (Math.random()>=0.65) { - if (Math.random()<=0.75) { - l.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); - } else { - l.getEquipment().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET)); - } - if (Math.random()>=0.95) { - if (Math.random()<=0.75) { - l.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); - } else { - l.getEquipment().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); - } - } - } - } - } - } - } else - if (totallvs<80*levelsmult) { - //Wear chainmail armor a bit more often. Sometimes an iron piece here or there. Include an Iron sword sometimes, a wooden one usually. - if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { - LivingEntity l = (LivingEntity) e.getEntity(); - if (e.getEntity().getType()==EntityType.ZOMBIE) { - if (Math.random()<=0.65) { - if (Math.random()<=0.75) { - l.getEquipment().setItemInHand(new ItemStack(Material.WOOD_SWORD)); - } else { - l.getEquipment().setItemInHand(new ItemStack(Material.IRON_SWORD)); - } - } - } else - if (e.getEntity().getType()==EntityType.SKELETON) { - if (Math.random()<=0.65) { - if (Math.random()<=0.75) { - ItemStack new_bow = new ItemStack(Material.BOW); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1); - l.getEquipment().setItemInHand(new_bow); - } else { - ItemStack new_bow = new ItemStack(Material.BOW); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); - l.getEquipment().setItemInHand(new_bow); - } - } - } else { - ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,0)); - } - if (Math.random()>=0.25) { - if (Math.random()<=0.75) { - l.getEquipment().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); - } else { - l.getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); - } - if (Math.random()>=0.45) { - if (Math.random()<=0.75) { - l.getEquipment().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); - } else { - l.getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); - } - if (Math.random()>=0.65) { - if (Math.random()<=0.75) { - l.getEquipment().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET)); - } else { - l.getEquipment().setHelmet(new ItemStack(Material.IRON_HELMET)); - } - if (Math.random()>=0.95) { - if (Math.random()<=0.75) { - l.getEquipment().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); - } else { - l.getEquipment().setBoots(new ItemStack(Material.IRON_BOOTS)); - } - } - } - } - } - } - } else - if (totallvs<100*levelsmult) { - //Wear iron armor a bit more often. Sometimes a diamond piece here or there. Include a Diamond sword sometimes, an iron one usually. - if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { - LivingEntity l = (LivingEntity) e.getEntity(); - if (e.getEntity().getType()==EntityType.ZOMBIE) { - if (Math.random()<=0.65) { - if (Math.random()<=0.75) { - l.getEquipment().setItemInHand(new ItemStack(Material.IRON_SWORD)); - } else { - l.getEquipment().setItemInHand(new ItemStack(Material.DIAMOND_SWORD)); - } - } - } else - if (e.getEntity().getType()==EntityType.SKELETON) { - if (Math.random()<=0.65) { - if (Math.random()<=0.75) { - ItemStack new_bow = new ItemStack(Material.BOW); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 2); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); - l.getEquipment().setItemInHand(new_bow); - } else { - ItemStack new_bow = new ItemStack(Material.BOW); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 3); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); - l.getEquipment().setItemInHand(new_bow); - } - } - } else { - if (Math.random()<=0.65) { - if (Math.random()<=0.75) { - ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,1)); - } else { - ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,1)); - //l.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,999999,0)); - } - } - } - if (Math.random()>=0.25) { - if (Math.random()<=0.75) { - l.getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); - } else { - l.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); - } - if (Math.random()>=0.45) { - if (Math.random()<=0.75) { - l.getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); - } else { - l.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); - } - if (Math.random()>=0.65) { - if (Math.random()<=0.75) { - l.getEquipment().setHelmet(new ItemStack(Material.IRON_HELMET)); - } else { - l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); - } - if (Math.random()>=0.95) { - if (Math.random()<=0.75) { - l.getEquipment().setBoots(new ItemStack(Material.IRON_BOOTS)); - } else { - l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); - } - } - } - } - } - } - } else - if (totallvs<120*levelsmult) { - //Wear diamond armor a bit more often. Sometimes an enchanted diamond piece here or there. Include a Golden sword sometimes, a diamond one usually. - if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { - LivingEntity l = (LivingEntity) e.getEntity(); - if (e.getEntity().getType()==EntityType.ZOMBIE) { - if (Math.random()<=0.65) { - if (Math.random()<=0.75) { - l.getEquipment().setItemInHand(new ItemStack(Material.DIAMOND_SWORD)); - } else { - l.getEquipment().setItemInHand(new ItemStack(Material.GOLD_SWORD)); - } - } - } else - if (e.getEntity().getType()==EntityType.SKELETON) { - if (Math.random()<=0.65) { - if (Math.random()<=0.75) { - ItemStack new_bow = new ItemStack(Material.BOW); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 3); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); - l.getEquipment().setItemInHand(new_bow); - } else { - ItemStack new_bow = new ItemStack(Material.BOW); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 4); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 1); - l.getEquipment().setItemInHand(new_bow); - } - } - } else { - if (Math.random()<=0.65) { - if (Math.random()<=0.75) { - ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,2)); - } else { - ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,2)); - //l.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,999999,0)); - } - } - } - if (Math.random()>=0.25) { - if (Math.random()<=0.75) { - l.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_CHESTPLATE); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*1.0d)+1); - l.getEquipment().setChestplate(enchanted); - } - if (Math.random()>=0.45) { - if (Math.random()<=0.75) { - l.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_LEGGINGS); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*1.0d)+1); - l.getEquipment().setLeggings(enchanted); - } - if (Math.random()>=0.65) { - if (Math.random()<=0.75) { - l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_HELMET); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*1.0d)+1); - l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); - } - if (Math.random()>=0.95) { - if (Math.random()<=0.75) { - l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_BOOTS); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*1.0d)+1); - l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); - } - } - } - } - } - } - } else - if (totallvs<140*levelsmult) { - //Well dang, your party's huge and OP. - //Wear diamond armor almost always. Enchanted diamond pieces here and there. - if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { - LivingEntity l = (LivingEntity) e.getEntity(); - if (e.getEntity().getType()==EntityType.ZOMBIE) { - if (Math.random()<=0.80) { - if (Math.random()<=0.75) { - ItemStack enchanted = new ItemStack(Material.DIAMOND_SWORD); - //enchanted.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, (int)(Math.random()*2.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.KNOCKBACK, (int)(Math.random()*2.0d)+1); - } else { - enchanted.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, (int)(Math.random()*2.0d)+1); - } - l.getEquipment().setItemInHand(enchanted); - } else { - ItemStack enchanted = new ItemStack(Material.GOLD_SWORD); - //enchanted.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, (int)(Math.random()*2.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.KNOCKBACK, (int)(Math.random()*2.0d)+1); - } else { - enchanted.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, (int)(Math.random()*4.0d)+1); - } - l.getEquipment().setItemInHand(enchanted); - } - } - } else - if (e.getEntity().getType()==EntityType.SKELETON) { - if (Math.random()<=0.65) { - if (Math.random()<=0.75) { - ItemStack new_bow = new ItemStack(Material.BOW); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 5); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 1); - l.getEquipment().setItemInHand(new_bow); - } else { - ItemStack new_bow = new ItemStack(Material.BOW); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 4); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 2); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 2); - l.getEquipment().setItemInHand(new_bow); - } - } - } else { - if (Math.random()<=0.65) { - if (Math.random()<=0.75) { - ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,2)); - l.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,999999,0)); - } else { - ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,2)); - //l.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,999999,1)); - l.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,999999,0)); - } - } - } - if (Math.random()>=0.25) { - if (Math.random()<=0.75) { - l.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_CHESTPLATE); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*2.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*1.0d)+1); - } - l.getEquipment().setChestplate(enchanted); - } - if (Math.random()>=0.45) { - if (Math.random()<=0.75) { - l.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_LEGGINGS); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*2.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*2.0d)+1); - } - l.getEquipment().setLeggings(enchanted); - } - if (Math.random()>=0.65) { - if (Math.random()<=0.75) { - l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_HELMET); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*2.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*2.0d)+1); - } - l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); - } - if (Math.random()>=0.95) { - if (Math.random()<=0.75) { - l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_BOOTS); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*2.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*2.0d)+1); - } - l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); - } - } - } - } - } - } - } else - if (totallvs<200*levelsmult) { - //Well dang, your party's huge and OP. - //Wear diamond armor almost always. Enchanted diamond pieces here and there. - if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { - LivingEntity l = (LivingEntity) e.getEntity(); - if (e.getEntity().getType()==EntityType.ZOMBIE) { - if (Math.random()<=0.80) { - if (Math.random()<=0.75) { - ItemStack enchanted = new ItemStack(Material.DIAMOND_SWORD); - //enchanted.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, (int)(Math.random()*4.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.KNOCKBACK, (int)(Math.random()*3.0d)+1); - } else { - enchanted.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, (int)(Math.random()*2.0d)+1); - } - l.getEquipment().setItemInHand(enchanted); - } else { - ItemStack enchanted = new ItemStack(Material.GOLD_SWORD); - //enchanted.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, (int)(Math.random()*4.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.KNOCKBACK, (int)(Math.random()*3.0d)+1); - } else { - enchanted.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, (int)(Math.random()*2.0d)+1); - } - l.getEquipment().setItemInHand(enchanted); - } - } - } else - if (e.getEntity().getType()==EntityType.SKELETON) { - if (Math.random()<=0.65) { - if (Math.random()<=0.75) { - ItemStack new_bow = new ItemStack(Material.BOW); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 5); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 2); - l.getEquipment().setItemInHand(new_bow); - } else { - ItemStack new_bow = new ItemStack(Material.BOW); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 6); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 2); - new_bow.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 3); - l.getEquipment().setItemInHand(new_bow); - } - } - } else { - if (Math.random()<=0.65) { - if (Math.random()<=0.75) { - ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,3)); - //l.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,999999,2)); - l.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,999999,1)); - } else { - ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,4)); - //l.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,999999,2)); - l.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,999999,1)); - } - } - } - if (Math.random()>=0.25) { - if (Math.random()<=0.75) { - l.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_CHESTPLATE); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*3.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*3.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*3.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*2.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*2.0d)+1); - } - l.getEquipment().setChestplate(enchanted); - } - if (Math.random()>=0.45) { - if (Math.random()<=0.75) { - l.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_LEGGINGS); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*2.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*2.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*2.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*2.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*2.0d)+1); - } - l.getEquipment().setLeggings(enchanted); - } - if (Math.random()>=0.65) { - if (Math.random()<=0.75) { - l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_HELMET); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*4.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*2.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*2.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*2.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*2.0d)+1); - } - l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); - } - if (Math.random()>=0.95) { - if (Math.random()<=0.75) { - l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_BOOTS); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*4.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*4.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*2.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*2.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*4.0d)+1); - } - l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); - } - } - } - } - } - } - } - else { - //Time to give it our all. - //Well dang, your party's huge and OP. - //Wear diamond armor almost always. Enchanted diamond pieces here and there. - if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { - LivingEntity l = (LivingEntity) e.getEntity(); - //l.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST,999999,1)); - l.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,999999,1)); - l.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,999999,0)); - l.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,999999,0)); - //l.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,999999,0)); - //l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,1)); - if (e.getEntity().getType()==EntityType.ZOMBIE) { - if (Math.random()<=0.80) { - if (Math.random()<=0.75) { - ItemStack enchanted = new ItemStack(Material.DIAMOND_SWORD); - //enchanted.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, (int)(Math.random()*4.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.KNOCKBACK, (int)(Math.random()*2.0d)+1); - } else { - enchanted.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, (int)(Math.random()*3.0d)+1); - } - l.getEquipment().setItemInHand(enchanted); - } else { - ItemStack enchanted = new ItemStack(Material.GOLD_SWORD); - //enchanted.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, (int)(Math.random()*4.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.KNOCKBACK, (int)(Math.random()*2.0d)+1); - } else { - enchanted.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, (int)(Math.random()*3.0d)+1); - } - l.getEquipment().setItemInHand(enchanted); - } - } - } - if (Math.random()>=0.25) { - if (Math.random()<=0.75) { - l.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_CHESTPLATE); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*4.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*4.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*4.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*3.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*4.0d)+1); - } - l.getEquipment().setChestplate(enchanted); - } - if (Math.random()>=0.45) { - if (Math.random()<=0.75) { - l.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_LEGGINGS); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*4.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*4.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*3.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*2.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*4.0d)+1); - } - l.getEquipment().setLeggings(enchanted); - } - if (Math.random()>=0.65) { - if (Math.random()<=0.75) { - l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_HELMET); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*4.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*4.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*2.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*2.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*4.0d)+1); - } - l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); - } - if (Math.random()>=0.95) { - if (Math.random()<=0.75) { - l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); - } else { - ItemStack enchanted = new ItemStack(Material.DIAMOND_BOOTS); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*4.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*4.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*4.0d)+1); - enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*4.0d)+1); - if (Math.random()<=0.5) { - enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*2.0d)+1); - } - l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); - } - } - } - } - } - } - } - } - } - } - } - if (e.getEntity().getType()==EntityType.EXPERIENCE_ORB) { - Bukkit.getWorld("world").spawnEntity(e.getEntity().getLocation(),e.getEntity().getType()); - } - if (e.getSpawnReason()==SpawnReason.BREEDING) { - //Spawn reason for later spawning. - //Check for this entity in list of animals that have been interacted with. - int slot=-1; - Player p=null; - String owner1="",owner2=""; - List checklist = e.getEntity().getNearbyEntities(3, 3, 3); - for (int i=0;inearby=e.getEntity().getNearbyEntities(25, 25, 25); - int countamount=0; - for (int i=0;i=40) { + //Allow this teleport. + //e.setTo(new Location(Bukkit.getWorld("world"),-8990,68,-4)); + Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { + @Override + public void run() { + p.getPlayer().teleport(new Location(Bukkit.getWorld("world"),-8990,68,-4)); + } + },5); } else { - mult=1; - } - if (mult==10) { - p.sendMessage("You started a new "+ChatColor.GREEN+e.getEntity().getType()+ChatColor.WHITE+" family out here!"); - } - if (e.getEntity().getType()==EntityType.CHICKEN) { - this.plugin.gainMoneyExp(p,"Breeder",0.01*mult,2*mult); - if (this.plugin.getJobLv("Breeder", p)>=10) { - if (Math.random()<=0.25 && countamount<50) { - Chicken newent = (Chicken)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.CHICKEN); - newent.setBaby(); - } else - if (Math.random()<=0.25 && countamount<50) { - Chicken newent = (Chicken)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.CHICKEN); - newent.setBaby(); - newent = (Chicken)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.CHICKEN); - newent.setBaby(); - } - } - } - if (e.getEntity().getType()==EntityType.PIG) { - this.plugin.gainMoneyExp(p,"Breeder",0.02*mult,4*mult); - if (this.plugin.getJobLv("Breeder", p)>=10) { - if (Math.random()<=0.25 && countamount<50) { - Pig newent = (Pig)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.PIG); - newent.setBaby(); - } else - if (Math.random()<=0.25 && countamount<50) { - Pig newent = (Pig)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.PIG); - newent.setBaby(); - newent = (Pig)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.PIG); - newent.setBaby(); - } - } - } - if (e.getEntity().getType()==EntityType.SHEEP) { - this.plugin.gainMoneyExp(p,"Breeder",0.02*mult,4*mult); - if (this.plugin.getJobLv("Breeder", p)>=10) { - if (Math.random()<=0.25 && countamount<50) { - Sheep newent = (Sheep)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.SHEEP); - newent.setBaby(); - newent.setColor(((Sheep)e.getEntity()).getColor()); - } else - if (Math.random()<=0.25 && countamount<50) { - Sheep newent = (Sheep)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.SHEEP); - newent.setBaby(); - newent.setColor(((Sheep)e.getEntity()).getColor()); - newent = (Sheep)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.SHEEP); - newent.setBaby(); - newent.setColor(((Sheep)e.getEntity()).getColor()); - } - } - } - if (e.getEntity().getType()==EntityType.COW) { - this.plugin.gainMoneyExp(p,"Breeder",0.03*mult,4*mult); - if (this.plugin.getJobLv("Breeder", p)>=10) { - if (Math.random()<=0.25 && countamount<50) { - Cow newent = (Cow)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.COW); - newent.setBaby(); - } else - if (Math.random()<=0.25 && countamount<50) { - Cow newent = (Cow)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.COW); - newent.setBaby(); - newent = (Cow)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.COW); - newent.setBaby(); - } - } - } - if (e.getEntity().getType()==EntityType.OCELOT) { - this.plugin.gainMoneyExp(p,"Breeder",0.04*mult,8*mult); - if (this.plugin.getJobLv("Breeder", p)>=10) { - if (Math.random()<=0.25 && countamount<50) { - Ocelot newent = (Ocelot)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.OCELOT); - newent.setBaby(); - newent.setOwner(((Ocelot)e.getEntity()).getOwner()); - newent.setCatType(((Ocelot)e.getEntity()).getCatType()); - } else - if (Math.random()<=0.25 && countamount<50) { - Ocelot newent = (Ocelot)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.OCELOT); - newent.setBaby(); - newent.setOwner(((Ocelot)e.getEntity()).getOwner()); - newent.setCatType(((Ocelot)e.getEntity()).getCatType()); - newent = (Ocelot)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.OCELOT); - newent.setBaby(); - newent.setOwner(((Ocelot)e.getEntity()).getOwner()); - newent.setCatType(((Ocelot)e.getEntity()).getCatType()); - } - } - } - if (e.getEntity().getType()==EntityType.WOLF) { - this.plugin.gainMoneyExp(p,"Breeder",0.06*mult,10*mult); - if (this.plugin.getJobLv("Breeder", p)>=10) { - if (Math.random()<=0.25 && countamount<50) { - Wolf newent = (Wolf)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.WOLF); - newent.setBaby(); - newent.setOwner(((Wolf)e).getOwner()); - newent.setCollarColor(((Wolf)e.getEntity()).getCollarColor()); - } else - if (Math.random()<=0.25 && countamount<50) { - Wolf newent = (Wolf)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.WOLF); - newent.setBaby(); - newent.setOwner(((Wolf)e).getOwner()); - newent.setCollarColor(((Wolf)e.getEntity()).getCollarColor()); - newent = (Wolf)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.WOLF); - newent.setBaby(); - newent.setOwner(((Wolf)e).getOwner()); - newent.setCollarColor(((Wolf)e.getEntity()).getCollarColor()); - } - } - } - if (e.getEntity().getType()==EntityType.MUSHROOM_COW) { - this.plugin.gainMoneyExp(p,"Breeder",0.20*mult,16*mult); - if (this.plugin.getJobLv("Breeder", p)>=10) { - if (Math.random()<=0.25 && countamount<50) { - MushroomCow newent = (MushroomCow)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.MUSHROOM_COW); - newent.setBaby(); - } else - if (Math.random()<=0.25 && countamount<50) { - MushroomCow newent = (MushroomCow)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.MUSHROOM_COW); - newent.setBaby(); - newent = (MushroomCow)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.MUSHROOM_COW); - newent.setBaby(); - } - } - } - if (e.getEntity().getType()==EntityType.HORSE) { - this.plugin.gainMoneyExp(p,"Breeder",0.30*mult,30*mult); - if (this.plugin.getJobLv("Breeder", p)>=10) { - if (Math.random()<=0.25 && countamount<50) { - Horse newent = (Horse)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.HORSE); - newent.setBaby(); - } else - if (Math.random()<=0.25 && countamount<50) { - Horse newent = (Horse)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.HORSE); - newent.setBaby(); - newent = (Horse)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.HORSE); - newent.setBaby(); - } - } + Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { + @Override + public void run() { + p.getPlayer().teleport(new Location(Bukkit.getWorld("world"),1606d,66d,-365d)); + } + },5); } } } } - } + }*/ + + @EventHandler + public void onPlayerInteract(PlayerInteractEntityEvent ev) { + Entity theAnimal = ev.getRightClicked(); + if (ev.getPlayer().getItemInHand().getType()==Material.getMaterial(127)) { + if (this.plugin.getAccountsConfig().getLong(ev.getPlayer().getName()+".halloween.wand")65) { + //Bukkit.broadcastMessage("PlayerListener: HP too high for ID "+id+". HP was "+hp); + } + return hp; + } + + @EventHandler + public void onBlockGrow(BlockGrowEvent e) { + int x1,y1,z1,x2=0,y2=0,z2=0; + x1=e.getBlock().getX(); + y1=e.getBlock().getY(); + z1=e.getBlock().getZ(); + Player[] plist= Bukkit.getOnlinePlayers(); + for (int i=0;i=20) { + if (Math.random()<=0.30) { + if (e.getBlock().getType()==Material.POTATO || e.getBlock().getType()==Material.CARROT || e.getBlock().getType()==Material.CROPS || e.getBlock().getType()==Material.MELON_STEM || e.getBlock().getType()==Material.PUMPKIN_STEM) { + if (e.getBlock().getData()<7) { + e.getBlock().setData((byte) (e.getBlock().getData()+1)); + } + } + if (e.getBlock().getType()==Material.COCOA) { + if (e.getBlock().getData()<8) { + e.getBlock().setData((byte) (e.getBlock().getData()+4)); + } + } + if (e.getBlock().getType()==Material.NETHER_WARTS) { + if (e.getBlock().getData()<3) { + e.getBlock().setData((byte) (e.getBlock().getData()+1)); + } + } + } + } + } + } + } + } + + private boolean isPermanentSpawn(CreatureSpawnEvent e, LivingEntity l) { + //Will return true if it's something that is not allowed to despawn. False if we are allowed to get rid of it. + //Basically this is the control that will determine if the mob stays or goes, before further processing is done. + //If the mob is identified as a special mob... + + EntityType type = l.getType(); + + //heightmodifier determines if it's a super tall chunk or a normal sized one. + int heightmodifier=0; + if (Bukkit.getWorld("world").getHighestBlockYAt(l.getLocation())>=96) { + heightmodifier=126; + } else { + heightmodifier=63; + } + + //Handle every special entity's spawning properties in here. + switch (type) { + case CREEPER:{ + if (l.getLocation().getY()<=40 && Math.random()<=0.08+((heightmodifier-l.getLocation().getY())*0.01d)) { + if (Math.random()<=0.35) { + l.setCustomName(ChatColor.YELLOW+"Explosive Creeper"); + l.setCustomNameVisible(false); + //l.setCustomNameVisible(true); + l.setMaxHealth(l.getMaxHealth()*1.25d); + l.setHealth(l.getMaxHealth()); + } else + if (Math.random()<=0.15) { + l.setCustomName(ChatColor.GOLD+"Explosive Creeper II"); + l.setCustomNameVisible(false); + //l.setCustomNameVisible(true); + l.setMaxHealth(l.getMaxHealth()*1.75d); + l.setHealth(l.getMaxHealth()); + } else + if (Math.random()<=0.35) { + l.setCustomName(ChatColor.YELLOW+"Destructive Creeper"); + l.setCustomNameVisible(false); + //l.setCustomNameVisible(true); + l.setMaxHealth(l.getMaxHealth()*1.25d); + l.setHealth(l.getMaxHealth()); + } else { + l.setCustomName(ChatColor.GOLD+"Destructive Creeper II"); + l.setCustomNameVisible(false); + //l.setCustomNameVisible(true); + l.setMaxHealth(l.getMaxHealth()*1.75d); + l.setHealth(l.getMaxHealth()); + } + } + }break; + case ARROW: { + }break; + case BAT: { + }break; + case BLAZE: { + }break; + case BOAT: { + }break; + case CAVE_SPIDER: { + }break; + case CHICKEN: { + }break; + case COMPLEX_PART: { + }break; + case COW: { + }break; + case DROPPED_ITEM: { + }break; + case EGG: { + }break; + case ENDERMAN: { + }break; + case ENDER_CRYSTAL: { + }break; + case ENDER_DRAGON: { + }break; + case ENDER_PEARL: { + }break; + case ENDER_SIGNAL: { + }break; + case EXPERIENCE_ORB: { + }break; + case FALLING_BLOCK: { + }break; + case FIREBALL: { + }break; + case FIREWORK: { + }break; + case FISHING_HOOK: { + }break; + case GHAST: { + }break; + case GIANT: { + }break; + case HORSE: { + }break; + case IRON_GOLEM: { + }break; + case ITEM_FRAME: { + }break; + case LEASH_HITCH: { + }break; + case LIGHTNING: { + }break; + case MAGMA_CUBE: { + }break; + case MINECART: { + }break; + case MINECART_CHEST: { + }break; + case MINECART_FURNACE: { + }break; + case MINECART_HOPPER: { + }break; + case MINECART_MOB_SPAWNER: { + }break; + case MINECART_TNT: { + }break; + case MUSHROOM_COW: { + }break; + case OCELOT: { + }break; + case PAINTING: { + }break; + case PIG: { + }break; + case PIG_ZOMBIE: { + }break; + case PLAYER: { + }break; + case PRIMED_TNT: { + }break; + case SHEEP: { + }break; + case SILVERFISH: { + }break; + case SKELETON: { + if (Math.random()<=0.10+((heightmodifier-l.getLocation().getY())*0.01d)) { + if (Math.random()<=0.85) { + l.setCustomName(ChatColor.YELLOW+"Sniper"); + l.setCustomNameVisible(false); + //l.setCustomNameVisible(true); + l.setMaxHealth(l.getMaxHealth()/2); + l.setHealth(l.getMaxHealth()); + } else { + l.setCustomName(ChatColor.GOLD+"Sniper II"); + l.setCustomNameVisible(false); + //l.setCustomNameVisible(true); + l.setMaxHealth(l.getMaxHealth()/4); + l.setHealth(l.getMaxHealth()); + } + } + }break; + case SLIME: { + }break; + case SMALL_FIREBALL: { + }break; + case SNOWBALL: { + }break; + case SNOWMAN: { + }break; + case SPIDER: { + if (Math.random()<=0.08+((heightmodifier-l.getLocation().getY())*0.01d)) { + if (Math.random()<=0.35) { + l.setCustomName(ChatColor.YELLOW+"Venomous Spider"); + l.setCustomNameVisible(false); + //l.setCustomNameVisible(true); + l.setMaxHealth(l.getMaxHealth()); + l.setHealth(l.getMaxHealth()); + } else + if (Math.random()<=0.15) { + l.setCustomName(ChatColor.GOLD+"Venomous Spider II"); + l.setCustomNameVisible(false); + //l.setCustomNameVisible(true); + l.setMaxHealth(l.getMaxHealth()*1.5); + l.setHealth(l.getMaxHealth()); + } else + if (Math.random()<=0.35) { + l.setCustomName(ChatColor.YELLOW+"Snaring Spider"); + l.setCustomNameVisible(false); + //l.setCustomNameVisible(true); + l.setMaxHealth(l.getMaxHealth()*1.5); + l.setHealth(l.getMaxHealth()); + } else { + l.setCustomName(ChatColor.GOLD+"Snaring Spider II"); + l.setCustomNameVisible(false); + //l.setCustomNameVisible(true); + l.setMaxHealth(l.getMaxHealth()*2); + l.setHealth(l.getMaxHealth()); + } + } + }break; + case SPLASH_POTION: { + }break; + case SQUID: { + }break; + case THROWN_EXP_BOTTLE: { + }break; + case UNKNOWN: { + }break; + case VILLAGER: { + }break; + case WEATHER: { + }break; + case WITCH: { + }break; + case WITHER: { + }break; + case WITHER_SKULL: { + }break; + case WOLF: { + }break; + case ZOMBIE: { + if (l.getHealth()<65) { + if (l.getLocation().getY()<=35 && Math.random()<=0.15) { + if (Math.random()<=0.85) { + l.setCustomName(ChatColor.YELLOW+"Charge Zombie"); + l.setCustomNameVisible(false); + //l.setCustomNameVisible(true); + l.setMaxHealth(l.getMaxHealth()+5); + l.setHealth(l.getMaxHealth()); + } else { + l.setCustomName(ChatColor.GOLD+"Charge Zombie II"); + l.setCustomNameVisible(false); + //l.setCustomNameVisible(true); + l.setMaxHealth(l.getMaxHealth()+20); + l.setHealth(l.getMaxHealth()); + } + } else { + if (Math.random()<=0.10+((heightmodifier-l.getLocation().getY())*0.01d)) { + if (Math.random()<=0.25) { + l.setCustomName(ChatColor.GRAY+"Zombie Ninja"); + l.setCustomNameVisible(false); + l.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 0, true)); + l.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 2, true)); + //l.setCustomNameVisible(true); + //A Zombie Ninja will not wear armor to stay hidden. But may carry a sword. + l.getEquipment().setChestplate(new ItemStack(Material.AIR)); + l.getEquipment().setBoots(new ItemStack(Material.AIR)); + l.getEquipment().setLeggings(new ItemStack(Material.AIR)); + l.getEquipment().setHelmet(new ItemStack(Material.AIR)); + Zombie g = (Zombie)l; + g.setBaby(true); + l.setMaxHealth(l.getMaxHealth()*0.65d); + l.setHealth(l.getMaxHealth()); + } + } + } + } else { + return false; + } + //If it's a super zombie, we're going to despawn it now. + }break; + default: { + } + } + + //This allows bosses to spawn. + if (e.getEntity().getType()==EntityType.ENDER_DRAGON || e.getEntity().getType()==EntityType.WITHER || + e.getEntity() instanceof Golem || e.getEntity() instanceof Animals) { + return true; + } + + //Custom bosses + if (l.getCustomName()!=null && (l.getCustomName().contains(ChatColor.DARK_PURPLE+"") || l.getCustomName().contains(ChatColor.DARK_AQUA+"Polymorphed Creature"))) { + return true; + } + + //Special reasons that should always happen. + if (e.getSpawnReason()==SpawnReason.SPAWNER || e.getSpawnReason()==SpawnReason.BUILD_IRONGOLEM || e.getSpawnReason()==SpawnReason.BREEDING || + e.getSpawnReason()==SpawnReason.BUILD_SNOWMAN || e.getSpawnReason()==SpawnReason.BUILD_WITHER || e.getSpawnReason()==SpawnReason.LIGHTNING || + e.getSpawnReason()==SpawnReason.SPAWNER_EGG || e.getSpawnReason()==SpawnReason.VILLAGE_DEFENSE || e.getSpawnReason()==SpawnReason.VILLAGE_INVASION) { + return true; + } + + return false; //If we got down to here, allow this particular mob to spawn. + + } + + + @EventHandler + public void onCreatureSpawn(CreatureSpawnEvent e) { + if (isPermanentSpawn(e, e.getEntity())) { + e.getEntity().setRemoveWhenFarAway(false); + + //If this is a boss that spawns from a command block, make sure the command blocks are removed. + if (e.getEntity().getCustomName()!=null && (e.getEntity().getCustomName().contains(ChatColor.DARK_PURPLE+"") || e.getEntity().getCustomName().contains(ChatColor.DARK_AQUA+"Polymorphed Creature"))) { + for (int i=-2;i<3;i++) { + for (int j=-2;j<3;j++) { + for (int k=-2;k<3;k++) { + if (Bukkit.getWorld("world").getBlockAt(e.getEntity().getLocation().add(i,j,k)).getType()==Material.COMMAND) { + Bukkit.getWorld("world").getBlockAt(e.getEntity().getLocation().add(i,j,k)).setType(Material.COBBLESTONE); + } + } + } + } + } + + //Give the wither bonuses. + if (e.getEntity() instanceof Wither) { + Wither w = (Wither)e.getEntity(); + w.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,999999,3)); + w.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,999999,3)); + w.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING,999999,3)); + w.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST,999999,40)); + w.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,2)); + w.setCustomName(ChatColor.GOLD+""+ChatColor.BOLD+"Mega Wither"); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule mobGriefing true"); + } + + } else { + float groupmult=1.0f; //Change this to modify the global grouping multiplier. + int maxgroup=(int)(10*groupmult); + double chancer=0.10d; + double despawnchancer=0.25d; + + if (e.getEntity().getHealth()>65 && e.getEntity().getCustomName()==null /*Meaning it's not a special mob.*/) { + e.getEntity().remove(); //Too much HP. Nothing should have this much. + return; + } + + boolean allow=false; //If this is set to true, it will not be marked for removal. + + //We will now determine if it is allowed to spawn due to being next to a boss or mob spawner. + List entities = e.getEntity().getWorld().getEntities(); + for (int i=0;i=96) { + //This is a tall world. + if (e.getEntity().getLocation().getBlockY()<=104) { + for (int i=104-e.getEntity().getLocation().getBlockY();i>0;i--) { + despawnchancer/=1.0175d; + } + } + } else { + //This is a short world. + if (e.getEntity().getLocation().getBlockY()<=52) { + for (int i=52-e.getEntity().getLocation().getBlockY();i>0;i--) { + despawnchancer/=1.025d; + } + } + } + + if (spawners==0 && (Math.random()<=despawnchancer || (torches+glowstone>=3))) { + allow=false; + } else { + allow=true; + } + + + int totallvs=0; + List nearbylist = e.getEntity().getNearbyEntities(30, 30, 30); + //Filter out all unrelated e.getEntity() types. + for (int k=0;kmaxgroup) { + allow=false; //Too many mobs, can't have more. + } + + if (!allow) { + //This is our chance to despawn it if we must. + e.getEntity().remove(); + } else { + //They will be allowed to spawn. Increase their base HP. + e.getEntity().setMaxHealth(e.getEntity().getMaxHealth()*1.15d); + e.getEntity().setHealth(e.getEntity().getMaxHealth()); + + + if (e.getEntity().getCustomName()!=null && e.getEntity().getCustomName().equals(ChatColor.GOLD+"Charge Zombie II")) { + //Destroy an area around itself. + for (int k=-4;k<5;k++) { + for (int j=-4;j<5;j++) { + for (int m=-1;m<5;m++) { + if (Math.random()<=1.00-((j+4)*0.05d)) { + Location checkloc = e.getEntity().getLocation().add(k,m,j); + Block bl = Bukkit.getWorld("world").getBlockAt(checkloc); + if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER || bl.getType()!=Material.COMMAND || bl.getType()!=Material.MOSSY_COBBLESTONE) { + bl.breakNaturally(); + } + } + } + } + } + } + + + if (e.getEntity().getType()==EntityType.ZOMBIE || e.getEntity().getType()==EntityType.PIG_ZOMBIE || e.getEntity().getType()==EntityType.SKELETON) { + //Modify the difficulty of the mobs based on who is around. + EntityEquipment inven = e.getEntity().getEquipment(); + if (inven!=null) { + inven.setBootsDropChance(0.02f); + inven.setChestplateDropChance(0.02f); + inven.setLeggingsDropChance(0.02f); + inven.setHelmetDropChance(0.02f); + inven.setItemInHandDropChance(0.02f); + if (e.getEntity().getType()==EntityType.SKELETON) { + inven.setItemInHand(new ItemStack(Material.BOW)); + } + } + + double levelsmult=1.0; + if (totallvs>20*levelsmult) { + if (totallvs<40*levelsmult) { + //Sometimes wear leather armor. Only for Skeletons and Zombies. + if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { + LivingEntity l = (LivingEntity) e.getEntity(); + if (Math.random()>=0.15) { + l.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); + if (Math.random()>=0.25) { + l.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); + if (Math.random()>=0.5) { + l.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); + if (Math.random()>=0.8) { + l.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); + } + } + } + } + } + } else + if (totallvs<60*levelsmult) { + //Wear leather armor a bit more often. Sometimes a chain piece here or there. Include a Wooden sword usually. + if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { + LivingEntity l = (LivingEntity) e.getEntity(); + if (e.getEntity().getType()==EntityType.ZOMBIE) { + if (Math.random()<=0.65) { + l.getEquipment().setItemInHand(new ItemStack(Material.WOOD_SWORD)); + } + } + if (e.getEntity().getType()==EntityType.SKELETON) { + if (Math.random()<=0.65) { + ItemStack new_bow = new ItemStack(Material.BOW); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1); + l.getEquipment().setItemInHand(new_bow); + } + } + if (Math.random()>=0.25) { + if (Math.random()<=0.75) { + l.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); + } else { + l.getEquipment().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); + } + if (Math.random()>=0.45) { + if (Math.random()<=0.75) { + l.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); + } else { + l.getEquipment().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); + } + if (Math.random()>=0.65) { + if (Math.random()<=0.75) { + l.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); + } else { + l.getEquipment().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET)); + } + if (Math.random()>=0.95) { + if (Math.random()<=0.75) { + l.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); + } else { + l.getEquipment().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); + } + } + } + } + } + } + } else + if (totallvs<80*levelsmult) { + //Wear chainmail armor a bit more often. Sometimes an iron piece here or there. Include an Iron sword sometimes, a wooden one usually. + if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { + LivingEntity l = (LivingEntity) e.getEntity(); + if (e.getEntity().getType()==EntityType.ZOMBIE) { + if (Math.random()<=0.65) { + if (Math.random()<=0.75) { + l.getEquipment().setItemInHand(new ItemStack(Material.WOOD_SWORD)); + } else { + l.getEquipment().setItemInHand(new ItemStack(Material.IRON_SWORD)); + } + } + } else + if (e.getEntity().getType()==EntityType.SKELETON) { + if (Math.random()<=0.65) { + if (Math.random()<=0.75) { + ItemStack new_bow = new ItemStack(Material.BOW); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1); + l.getEquipment().setItemInHand(new_bow); + } else { + ItemStack new_bow = new ItemStack(Material.BOW); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); + l.getEquipment().setItemInHand(new_bow); + } + } + } else { + ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,0)); + } + if (Math.random()>=0.25) { + if (Math.random()<=0.75) { + l.getEquipment().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); + } else { + l.getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); + } + if (Math.random()>=0.45) { + if (Math.random()<=0.75) { + l.getEquipment().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); + } else { + l.getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); + } + if (Math.random()>=0.65) { + if (Math.random()<=0.75) { + l.getEquipment().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET)); + } else { + l.getEquipment().setHelmet(new ItemStack(Material.IRON_HELMET)); + } + if (Math.random()>=0.95) { + if (Math.random()<=0.75) { + l.getEquipment().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); + } else { + l.getEquipment().setBoots(new ItemStack(Material.IRON_BOOTS)); + } + } + } + } + } + } + } else + if (totallvs<100*levelsmult) { + //Wear iron armor a bit more often. Sometimes a diamond piece here or there. Include a Diamond sword sometimes, an iron one usually. + if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { + LivingEntity l = (LivingEntity) e.getEntity(); + if (e.getEntity().getType()==EntityType.ZOMBIE) { + if (Math.random()<=0.65) { + if (Math.random()<=0.75) { + l.getEquipment().setItemInHand(new ItemStack(Material.IRON_SWORD)); + } else { + l.getEquipment().setItemInHand(new ItemStack(Material.DIAMOND_SWORD)); + } + } + } else + if (e.getEntity().getType()==EntityType.SKELETON) { + if (Math.random()<=0.65) { + if (Math.random()<=0.75) { + ItemStack new_bow = new ItemStack(Material.BOW); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 2); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); + l.getEquipment().setItemInHand(new_bow); + } else { + ItemStack new_bow = new ItemStack(Material.BOW); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 3); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); + l.getEquipment().setItemInHand(new_bow); + } + } + } else { + if (Math.random()<=0.65) { + if (Math.random()<=0.75) { + ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,1)); + } else { + ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,1)); + //l.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,999999,0)); + } + } + } + if (Math.random()>=0.25) { + if (Math.random()<=0.75) { + l.getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); + } else { + l.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); + } + if (Math.random()>=0.45) { + if (Math.random()<=0.75) { + l.getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); + } else { + l.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); + } + if (Math.random()>=0.65) { + if (Math.random()<=0.75) { + l.getEquipment().setHelmet(new ItemStack(Material.IRON_HELMET)); + } else { + l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); + } + if (Math.random()>=0.95) { + if (Math.random()<=0.75) { + l.getEquipment().setBoots(new ItemStack(Material.IRON_BOOTS)); + } else { + l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); + } + } + } + } + } + } + } else + if (totallvs<120*levelsmult) { + //Wear diamond armor a bit more often. Sometimes an enchanted diamond piece here or there. Include a Golden sword sometimes, a diamond one usually. + if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { + LivingEntity l = (LivingEntity) e.getEntity(); + if (e.getEntity().getType()==EntityType.ZOMBIE) { + if (Math.random()<=0.65) { + if (Math.random()<=0.75) { + l.getEquipment().setItemInHand(new ItemStack(Material.DIAMOND_SWORD)); + } else { + l.getEquipment().setItemInHand(new ItemStack(Material.GOLD_SWORD)); + } + } + } else + if (e.getEntity().getType()==EntityType.SKELETON) { + if (Math.random()<=0.65) { + if (Math.random()<=0.75) { + ItemStack new_bow = new ItemStack(Material.BOW); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 3); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); + l.getEquipment().setItemInHand(new_bow); + } else { + ItemStack new_bow = new ItemStack(Material.BOW); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 4); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 1); + l.getEquipment().setItemInHand(new_bow); + } + } + } else { + if (Math.random()<=0.65) { + if (Math.random()<=0.75) { + ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,2)); + } else { + ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,2)); + //l.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,999999,0)); + } + } + } + if (Math.random()>=0.25) { + if (Math.random()<=0.75) { + l.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_CHESTPLATE); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*1.0d)+1); + l.getEquipment().setChestplate(enchanted); + } + if (Math.random()>=0.45) { + if (Math.random()<=0.75) { + l.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_LEGGINGS); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*1.0d)+1); + l.getEquipment().setLeggings(enchanted); + } + if (Math.random()>=0.65) { + if (Math.random()<=0.75) { + l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_HELMET); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*1.0d)+1); + l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); + } + if (Math.random()>=0.95) { + if (Math.random()<=0.75) { + l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_BOOTS); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*1.0d)+1); + l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); + } + } + } + } + } + } + } else + if (totallvs<140*levelsmult) { + //Well dang, your party's huge and OP. + //Wear diamond armor almost always. Enchanted diamond pieces here and there. + if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { + LivingEntity l = (LivingEntity) e.getEntity(); + if (e.getEntity().getType()==EntityType.ZOMBIE) { + if (Math.random()<=0.80) { + if (Math.random()<=0.75) { + ItemStack enchanted = new ItemStack(Material.DIAMOND_SWORD); + //enchanted.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, (int)(Math.random()*2.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.KNOCKBACK, (int)(Math.random()*2.0d)+1); + } else { + enchanted.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, (int)(Math.random()*2.0d)+1); + } + l.getEquipment().setItemInHand(enchanted); + } else { + ItemStack enchanted = new ItemStack(Material.GOLD_SWORD); + //enchanted.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, (int)(Math.random()*2.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.KNOCKBACK, (int)(Math.random()*2.0d)+1); + } else { + enchanted.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, (int)(Math.random()*4.0d)+1); + } + l.getEquipment().setItemInHand(enchanted); + } + } + } else + if (e.getEntity().getType()==EntityType.SKELETON) { + if (Math.random()<=0.65) { + if (Math.random()<=0.75) { + ItemStack new_bow = new ItemStack(Material.BOW); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 5); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 1); + l.getEquipment().setItemInHand(new_bow); + } else { + ItemStack new_bow = new ItemStack(Material.BOW); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 4); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 2); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 2); + l.getEquipment().setItemInHand(new_bow); + } + } + } else { + if (Math.random()<=0.65) { + if (Math.random()<=0.75) { + ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,2)); + l.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,999999,0)); + } else { + ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,2)); + //l.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,999999,1)); + l.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,999999,0)); + } + } + } + if (Math.random()>=0.25) { + if (Math.random()<=0.75) { + l.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_CHESTPLATE); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*2.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*1.0d)+1); + } + l.getEquipment().setChestplate(enchanted); + } + if (Math.random()>=0.45) { + if (Math.random()<=0.75) { + l.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_LEGGINGS); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*2.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*2.0d)+1); + } + l.getEquipment().setLeggings(enchanted); + } + if (Math.random()>=0.65) { + if (Math.random()<=0.75) { + l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_HELMET); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*2.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*2.0d)+1); + } + l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); + } + if (Math.random()>=0.95) { + if (Math.random()<=0.75) { + l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_BOOTS); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*2.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*2.0d)+1); + } + l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); + } + } + } + } + } + } + } else + if (totallvs<200*levelsmult) { + //Well dang, your party's huge and OP. + //Wear diamond armor almost always. Enchanted diamond pieces here and there. + if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { + LivingEntity l = (LivingEntity) e.getEntity(); + if (e.getEntity().getType()==EntityType.ZOMBIE) { + if (Math.random()<=0.80) { + if (Math.random()<=0.75) { + ItemStack enchanted = new ItemStack(Material.DIAMOND_SWORD); + //enchanted.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, (int)(Math.random()*4.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.KNOCKBACK, (int)(Math.random()*3.0d)+1); + } else { + enchanted.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, (int)(Math.random()*2.0d)+1); + } + l.getEquipment().setItemInHand(enchanted); + } else { + ItemStack enchanted = new ItemStack(Material.GOLD_SWORD); + //enchanted.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, (int)(Math.random()*4.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.KNOCKBACK, (int)(Math.random()*3.0d)+1); + } else { + enchanted.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, (int)(Math.random()*2.0d)+1); + } + l.getEquipment().setItemInHand(enchanted); + } + } + } else + if (e.getEntity().getType()==EntityType.SKELETON) { + if (Math.random()<=0.65) { + if (Math.random()<=0.75) { + ItemStack new_bow = new ItemStack(Material.BOW); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 5); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 2); + l.getEquipment().setItemInHand(new_bow); + } else { + ItemStack new_bow = new ItemStack(Material.BOW); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 6); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 2); + new_bow.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 3); + l.getEquipment().setItemInHand(new_bow); + } + } + } else { + if (Math.random()<=0.65) { + if (Math.random()<=0.75) { + ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,3)); + //l.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,999999,2)); + l.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,999999,1)); + } else { + ////l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,4)); + //l.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,999999,2)); + l.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,999999,1)); + } + } + } + if (Math.random()>=0.25) { + if (Math.random()<=0.75) { + l.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_CHESTPLATE); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*3.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*3.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*3.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*2.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*2.0d)+1); + } + l.getEquipment().setChestplate(enchanted); + } + if (Math.random()>=0.45) { + if (Math.random()<=0.75) { + l.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_LEGGINGS); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*2.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*2.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*2.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*2.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*2.0d)+1); + } + l.getEquipment().setLeggings(enchanted); + } + if (Math.random()>=0.65) { + if (Math.random()<=0.75) { + l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_HELMET); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*4.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*2.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*2.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*2.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*2.0d)+1); + } + l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); + } + if (Math.random()>=0.95) { + if (Math.random()<=0.75) { + l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_BOOTS); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*4.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*4.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*2.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*2.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*4.0d)+1); + } + l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); + } + } + } + } + } + } + } + else { + //Time to give it our all. + //Well dang, your party's huge and OP. + //Wear diamond armor almost always. Enchanted diamond pieces here and there. + if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { + LivingEntity l = (LivingEntity) e.getEntity(); + //l.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST,999999,1)); + l.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,999999,1)); + l.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,999999,0)); + l.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,999999,0)); + //l.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,999999,0)); + //l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,1)); + if (e.getEntity().getType()==EntityType.ZOMBIE) { + if (Math.random()<=0.80) { + if (Math.random()<=0.75) { + ItemStack enchanted = new ItemStack(Material.DIAMOND_SWORD); + //enchanted.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, (int)(Math.random()*4.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.KNOCKBACK, (int)(Math.random()*2.0d)+1); + } else { + enchanted.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, (int)(Math.random()*3.0d)+1); + } + l.getEquipment().setItemInHand(enchanted); + } else { + ItemStack enchanted = new ItemStack(Material.GOLD_SWORD); + //enchanted.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, (int)(Math.random()*4.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.KNOCKBACK, (int)(Math.random()*2.0d)+1); + } else { + enchanted.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, (int)(Math.random()*3.0d)+1); + } + l.getEquipment().setItemInHand(enchanted); + } + } + } + if (Math.random()>=0.25) { + if (Math.random()<=0.75) { + l.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_CHESTPLATE); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*4.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*4.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*4.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*3.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*4.0d)+1); + } + l.getEquipment().setChestplate(enchanted); + } + if (Math.random()>=0.45) { + if (Math.random()<=0.75) { + l.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_LEGGINGS); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*4.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*4.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*3.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*2.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*4.0d)+1); + } + l.getEquipment().setLeggings(enchanted); + } + if (Math.random()>=0.65) { + if (Math.random()<=0.75) { + l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_HELMET); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*4.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*4.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*2.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*2.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*4.0d)+1); + } + l.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); + } + if (Math.random()>=0.95) { + if (Math.random()<=0.75) { + l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); + } else { + ItemStack enchanted = new ItemStack(Material.DIAMOND_BOOTS); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*4.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*4.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*4.0d)+1); + enchanted.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*4.0d)+1); + if (Math.random()<=0.5) { + enchanted.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*2.0d)+1); + } + l.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); + } + } + } + } + } + } + } + } + } + } + } + if (e.getEntity().getType()==EntityType.EXPERIENCE_ORB) { + Bukkit.getWorld("world").spawnEntity(e.getEntity().getLocation(),e.getEntity().getType()); + } + if (e.getSpawnReason()==SpawnReason.BREEDING) { + //Spawn reason for later spawning. + //Check for this entity in list of animals that have been interacted with. + int slot=-1; + Player p=null; + String owner1="",owner2=""; + List checklist = e.getEntity().getNearbyEntities(3, 3, 3); + for (int i=0;inearby=e.getEntity().getNearbyEntities(25, 25, 25); + int countamount=0; + for (int i=0;i=10) { + if (Math.random()<=0.25 && countamount<50) { + Chicken newent = (Chicken)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.CHICKEN); + newent.setBaby(); + } else + if (Math.random()<=0.25 && countamount<50) { + Chicken newent = (Chicken)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.CHICKEN); + newent.setBaby(); + newent = (Chicken)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.CHICKEN); + newent.setBaby(); + } + } + } + if (e.getEntity().getType()==EntityType.PIG) { + this.plugin.gainMoneyExp(p,"Breeder",0.02*mult,4*mult); + if (this.plugin.getJobLv("Breeder", p)>=10) { + if (Math.random()<=0.25 && countamount<50) { + Pig newent = (Pig)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.PIG); + newent.setBaby(); + } else + if (Math.random()<=0.25 && countamount<50) { + Pig newent = (Pig)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.PIG); + newent.setBaby(); + newent = (Pig)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.PIG); + newent.setBaby(); + } + } + } + if (e.getEntity().getType()==EntityType.SHEEP) { + this.plugin.gainMoneyExp(p,"Breeder",0.02*mult,4*mult); + if (this.plugin.getJobLv("Breeder", p)>=10) { + if (Math.random()<=0.25 && countamount<50) { + Sheep newent = (Sheep)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.SHEEP); + newent.setBaby(); + newent.setColor(((Sheep)e.getEntity()).getColor()); + } else + if (Math.random()<=0.25 && countamount<50) { + Sheep newent = (Sheep)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.SHEEP); + newent.setBaby(); + newent.setColor(((Sheep)e.getEntity()).getColor()); + newent = (Sheep)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.SHEEP); + newent.setBaby(); + newent.setColor(((Sheep)e.getEntity()).getColor()); + } + } + } + if (e.getEntity().getType()==EntityType.COW) { + this.plugin.gainMoneyExp(p,"Breeder",0.03*mult,4*mult); + if (this.plugin.getJobLv("Breeder", p)>=10) { + if (Math.random()<=0.25 && countamount<50) { + Cow newent = (Cow)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.COW); + newent.setBaby(); + } else + if (Math.random()<=0.25 && countamount<50) { + Cow newent = (Cow)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.COW); + newent.setBaby(); + newent = (Cow)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.COW); + newent.setBaby(); + } + } + } + if (e.getEntity().getType()==EntityType.OCELOT) { + this.plugin.gainMoneyExp(p,"Breeder",0.04*mult,8*mult); + if (this.plugin.getJobLv("Breeder", p)>=10) { + if (Math.random()<=0.25 && countamount<50) { + Ocelot newent = (Ocelot)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.OCELOT); + newent.setBaby(); + newent.setOwner(((Ocelot)e.getEntity()).getOwner()); + newent.setCatType(((Ocelot)e.getEntity()).getCatType()); + } else + if (Math.random()<=0.25 && countamount<50) { + Ocelot newent = (Ocelot)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.OCELOT); + newent.setBaby(); + newent.setOwner(((Ocelot)e.getEntity()).getOwner()); + newent.setCatType(((Ocelot)e.getEntity()).getCatType()); + newent = (Ocelot)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.OCELOT); + newent.setBaby(); + newent.setOwner(((Ocelot)e.getEntity()).getOwner()); + newent.setCatType(((Ocelot)e.getEntity()).getCatType()); + } + } + } + if (e.getEntity().getType()==EntityType.WOLF) { + this.plugin.gainMoneyExp(p,"Breeder",0.06*mult,10*mult); + if (this.plugin.getJobLv("Breeder", p)>=10) { + if (Math.random()<=0.25 && countamount<50) { + Wolf newent = (Wolf)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.WOLF); + newent.setBaby(); + newent.setOwner(((Wolf)e).getOwner()); + newent.setCollarColor(((Wolf)e.getEntity()).getCollarColor()); + } else + if (Math.random()<=0.25 && countamount<50) { + Wolf newent = (Wolf)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.WOLF); + newent.setBaby(); + newent.setOwner(((Wolf)e).getOwner()); + newent.setCollarColor(((Wolf)e.getEntity()).getCollarColor()); + newent = (Wolf)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.WOLF); + newent.setBaby(); + newent.setOwner(((Wolf)e).getOwner()); + newent.setCollarColor(((Wolf)e.getEntity()).getCollarColor()); + } + } + } + if (e.getEntity().getType()==EntityType.MUSHROOM_COW) { + this.plugin.gainMoneyExp(p,"Breeder",0.20*mult,16*mult); + if (this.plugin.getJobLv("Breeder", p)>=10) { + if (Math.random()<=0.25 && countamount<50) { + MushroomCow newent = (MushroomCow)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.MUSHROOM_COW); + newent.setBaby(); + } else + if (Math.random()<=0.25 && countamount<50) { + MushroomCow newent = (MushroomCow)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.MUSHROOM_COW); + newent.setBaby(); + newent = (MushroomCow)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.MUSHROOM_COW); + newent.setBaby(); + } + } + } + if (e.getEntity().getType()==EntityType.HORSE) { + this.plugin.gainMoneyExp(p,"Breeder",0.30*mult,30*mult); + if (this.plugin.getJobLv("Breeder", p)>=10) { + if (Math.random()<=0.25 && countamount<50) { + Horse newent = (Horse)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.HORSE); + newent.setBaby(); + } else + if (Math.random()<=0.25 && countamount<50) { + Horse newent = (Horse)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.HORSE); + newent.setBaby(); + newent = (Horse)Bukkit.getWorld("world").spawnEntity(e.getLocation(), EntityType.HORSE); + newent.setBaby(); + } + } + } + } + } + } + } - @EventHandler - public void onBlockBreak(BlockBreakEvent e) { - Player p = e.getPlayer(); - //p.sendMessage("Block broke."); - //p.sendMessage("Has name: "+p.getItemInHand().getItemMeta().hasDisplayName()); - //p.sendMessage("Name is: "+p.getItemInHand().getItemMeta().getDisplayName()); - int myData=this.plugin.getPlayerDataSlot(p); - boolean has_silktouch=false; - if (!p.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { - has_silktouch=false; - } else { - has_silktouch=true; - } - if (p!=null) { - if (e.getBlock().getType()==Material.COMMAND) { - e.setCancelled(true); - return; - } - if (e.getBlock().getType()==Material.STONE && p.getLocation().getY()<=50) { - //We are mining underground. - //Check if we need to spawn Charge Zombie II's. - //Find our player data. - int pdata_slot=0; - for (int i=0;i-6;j--) { - for (int k=2;k>-1;k--) { - for (int l=5;l>-6;l--) { - Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(20+j,k,spread+l)); - if (b.getType()==Material.TORCH || b.getType()==Material.GLOWSTONE || b.getType()==Material.COMMAND || b.getType()==Material.MOSSY_COBBLESTONE) { - torch1=true; - } - } - } + for (int k=2;k>-1;k--) { + for (int l=5;l>-6;l--) { + Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(20+j,k,spread+l)); + if (b.getType()==Material.TORCH || b.getType()==Material.GLOWSTONE || b.getType()==Material.COMMAND || b.getType()==Material.MOSSY_COBBLESTONE) { + torch1=true; + } + } + } } if (!torch1) { int lb1=(int)(Math.random()*5)+1,lb2=(int)(Math.random()*5)+1,ub1=-(int)(Math.random()*6)+1,ub2=-(int)(Math.random()*6)+1; - for (int j=lb1;j>ub1;j--) { - for (int k=2;k>-1;k--) { - for (int l=lb2;l>-ub2;l--) { - Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(10+j,k,spread+l)); - if (b.getType()!=Material.BEDROCK && b.getType()!=Material.MOB_SPAWNER && b.getType()!=Material.ENDER_PORTAL && b.getType()!=Material.ENDER_PORTAL_FRAME) { - b.setType(Material.AIR); - } - } - } - } - e1 = Bukkit.getWorld("world").spawnEntity(p.getLocation().add(10,0,spread), EntityType.ZOMBIE); + for (int j=lb1;j>ub1;j--) { + for (int k=2;k>-1;k--) { + for (int l=lb2;l>-ub2;l--) { + Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(10+j,k,spread+l)); + if (b.getType()!=Material.BEDROCK && b.getType()!=Material.MOB_SPAWNER && b.getType()!=Material.ENDER_PORTAL && b.getType()!=Material.ENDER_PORTAL_FRAME) { + b.setType(Material.AIR); + } + } + } + } + e1 = Bukkit.getWorld("world").spawnEntity(p.getLocation().add(10,0,spread), EntityType.ZOMBIE); } torch2=false; spread = (int)(Math.random()*10); for (int j=5;j>-6;j--) { - for (int k=2;k>-1;k--) { - for (int l=5;l>-6;l--) { - Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(-10+j,k,spread+l)); - if (b.getType()==Material.TORCH || b.getType()==Material.GLOWSTONE || b.getType()==Material.COMMAND || b.getType()==Material.MOSSY_COBBLESTONE) { - torch2=true; - } - } - } + for (int k=2;k>-1;k--) { + for (int l=5;l>-6;l--) { + Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(-10+j,k,spread+l)); + if (b.getType()==Material.TORCH || b.getType()==Material.GLOWSTONE || b.getType()==Material.COMMAND || b.getType()==Material.MOSSY_COBBLESTONE) { + torch2=true; + } + } + } } if (!torch2) { int lb1=(int)(Math.random()*5)+1,lb2=(int)(Math.random()*5)+1,ub1=-(int)(Math.random()*6)+1,ub2=-(int)(Math.random()*6)+1; - for (int j=lb1;j>ub1;j--) { - for (int k=2;k>-1;k--) { - for (int l=lb2;l>-ub2;l--) { - Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(-10+j,k,spread+l)); - if (b.getType()!=Material.BEDROCK && b.getType()!=Material.MOB_SPAWNER && b.getType()!=Material.ENDER_PORTAL && b.getType()!=Material.ENDER_PORTAL_FRAME) { - b.setType(Material.AIR); - } - } - } - } - e2 = Bukkit.getWorld("world").spawnEntity(p.getLocation().add(-10,0,spread), EntityType.ZOMBIE); + for (int j=lb1;j>ub1;j--) { + for (int k=2;k>-1;k--) { + for (int l=lb2;l>-ub2;l--) { + Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(-10+j,k,spread+l)); + if (b.getType()!=Material.BEDROCK && b.getType()!=Material.MOB_SPAWNER && b.getType()!=Material.ENDER_PORTAL && b.getType()!=Material.ENDER_PORTAL_FRAME) { + b.setType(Material.AIR); + } + } + } + } + e2 = Bukkit.getWorld("world").spawnEntity(p.getLocation().add(-10,0,spread), EntityType.ZOMBIE); } spread = (int)(Math.random()*10); for (int j=5;j>-6;j--) { - for (int k=2;k>-1;k--) { - for (int l=5;l>-6;l--) { - Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(spread+j,k,10+l)); - if (b.getType()==Material.TORCH || b.getType()==Material.GLOWSTONE || b.getType()==Material.COMMAND || b.getType()==Material.MOSSY_COBBLESTONE) { - torch3=true; - } - } - } + for (int k=2;k>-1;k--) { + for (int l=5;l>-6;l--) { + Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(spread+j,k,10+l)); + if (b.getType()==Material.TORCH || b.getType()==Material.GLOWSTONE || b.getType()==Material.COMMAND || b.getType()==Material.MOSSY_COBBLESTONE) { + torch3=true; + } + } + } } if (!torch3) { int lb1=(int)(Math.random()*5)+1,lb2=(int)(Math.random()*5)+1,ub1=-(int)(Math.random()*6)+1,ub2=-(int)(Math.random()*6)+1; - for (int j=lb1;j>ub1;j--) { - for (int k=2;k>-1;k--) { - for (int l=lb2;l>-ub2;l--) { - Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(spread+j,k,10+l)); - if (b.getType()!=Material.BEDROCK && b.getType()!=Material.MOB_SPAWNER && b.getType()!=Material.ENDER_PORTAL && b.getType()!=Material.ENDER_PORTAL_FRAME) { - b.setType(Material.AIR); - } - } - } + for (int j=lb1;j>ub1;j--) { + for (int k=2;k>-1;k--) { + for (int l=lb2;l>-ub2;l--) { + Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(spread+j,k,10+l)); + if (b.getType()!=Material.BEDROCK && b.getType()!=Material.MOB_SPAWNER && b.getType()!=Material.ENDER_PORTAL && b.getType()!=Material.ENDER_PORTAL_FRAME) { + b.setType(Material.AIR); + } + } + } } e3 = Bukkit.getWorld("world").spawnEntity(p.getLocation().add(spread,0,10), EntityType.ZOMBIE); } spread = (int)(Math.random()*10); for (int j=5;j>-6;j--) { - for (int k=2;k>-1;k--) { - for (int l=5;l>-6;l--) { - Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(spread+j,k,-10+l)); - if (b.getType()==Material.TORCH || b.getType()==Material.GLOWSTONE || b.getType()==Material.COMMAND || b.getType()==Material.MOSSY_COBBLESTONE) { - torch4=true; - } - } - } + for (int k=2;k>-1;k--) { + for (int l=5;l>-6;l--) { + Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(spread+j,k,-10+l)); + if (b.getType()==Material.TORCH || b.getType()==Material.GLOWSTONE || b.getType()==Material.COMMAND || b.getType()==Material.MOSSY_COBBLESTONE) { + torch4=true; + } + } + } } if (!torch4) { int lb1=(int)(Math.random()*5)+1,lb2=(int)(Math.random()*5)+1,ub1=-(int)(Math.random()*6)+1,ub2=-(int)(Math.random()*6)+1; - for (int j=lb1;j>ub1;j--) { - for (int k=2;k>-1;k--) { - for (int l=lb2;l>-ub2;l--) { - Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(spread+j,k,-10+l)); - if (b.getType()!=Material.BEDROCK && b.getType()!=Material.MOB_SPAWNER && b.getType()!=Material.ENDER_PORTAL && b.getType()!=Material.ENDER_PORTAL_FRAME) { - b.setType(Material.AIR); - } - } - } - } - e4 = Bukkit.getWorld("world").spawnEntity(p.getLocation().add(spread,0,-20), EntityType.ZOMBIE); + for (int j=lb1;j>ub1;j--) { + for (int k=2;k>-1;k--) { + for (int l=lb2;l>-ub2;l--) { + Block b =Bukkit.getWorld("world").getBlockAt(p.getLocation().add(spread+j,k,-10+l)); + if (b.getType()!=Material.BEDROCK && b.getType()!=Material.MOB_SPAWNER && b.getType()!=Material.ENDER_PORTAL && b.getType()!=Material.ENDER_PORTAL_FRAME) { + b.setType(Material.AIR); + } + } + } + } + e4 = Bukkit.getWorld("world").spawnEntity(p.getLocation().add(spread,0,-20), EntityType.ZOMBIE); } if (!torch1) { - Zombie z1 = (Zombie)e1; - z1.setCustomName(ChatColor.GOLD+"Charge Zombie II"); - z1.setCustomNameVisible(false); - z1.setTarget(p); + Zombie z1 = (Zombie)e1; + z1.setCustomName(ChatColor.GOLD+"Charge Zombie II"); + z1.setCustomNameVisible(false); + z1.setTarget(p); } if (!torch2) { - Zombie z2 = (Zombie)e2; - z2.setCustomName(ChatColor.GOLD+"Charge Zombie II"); - z2.setCustomNameVisible(false); - z2.setTarget(p); + Zombie z2 = (Zombie)e2; + z2.setCustomName(ChatColor.GOLD+"Charge Zombie II"); + z2.setCustomNameVisible(false); + z2.setTarget(p); } if (!torch3) { - Zombie z3 = (Zombie)e3; - z3.setCustomName(ChatColor.GOLD+"Charge Zombie II"); - z3.setCustomNameVisible(false); - z3.setTarget(p); + Zombie z3 = (Zombie)e3; + z3.setCustomName(ChatColor.GOLD+"Charge Zombie II"); + z3.setCustomNameVisible(false); + z3.setTarget(p); } if (!torch4) { - Zombie z4 = (Zombie)e4; - z4.setCustomName(ChatColor.GOLD+"Charge Zombie II"); - z4.setCustomNameVisible(false); - z4.setTarget(p); + Zombie z4 = (Zombie)e4; + z4.setCustomName(ChatColor.GOLD+"Charge Zombie II"); + z4.setCustomNameVisible(false); + z4.setTarget(p); } - } - } - if (e.getBlock().getType()==Material.EMERALD_ORE || - e.getBlock().getType()==Material.DIAMOND_ORE || - e.getBlock().getType()==Material.GOLD_ORE || - e.getBlock().getType()==Material.IRON_ORE) { - /* + } + } + if (e.getBlock().getType()==Material.EMERALD_ORE || + e.getBlock().getType()==Material.DIAMOND_ORE || + e.getBlock().getType()==Material.GOLD_ORE || + e.getBlock().getType()==Material.IRON_ORE) { + /* if (Math.random()<=0.01) { //1% chance of getting a book. ItemStack book = new ItemStack(Material.WRITTEN_BOOK); @@ -3361,187 +3361,187 @@ public class PlayerListener p.updateInventory(); p.sendMessage(ChatColor.LIGHT_PURPLE+"You feel a magical presence get inserted into your inventory."); }*/ - } - if (this.plugin.PlayerinJob(p, "Builder")) { - this.plugin.playerdata_list.get(myData).BadInteract(e.getBlock().getType()); - } - if (this.plugin.PlayerinJob(p, "Woodcutter")) { - if (e.getBlock().getType()==Material.LOG) { - if (p.getItemInHand().getType()==Material.WOOD_AXE || p.getItemInHand().getType()==Material.STONE_AXE || p.getItemInHand().getType()==Material.IRON_AXE || p.getItemInHand().getType()==Material.GOLD_AXE || p.getItemInHand().getType()==Material.DIAMOND_AXE) { - //p.sendMessage("Cut down wood w/axe."); - this.plugin.gainMoneyExp(p,"Woodcutter",0.025,2); - } else { - //p.sendMessage("Cut down wood."); - this.plugin.gainMoneyExp(p,"Woodcutter",0.01,1); - } - } - } - if (this.plugin.PlayerinJob(p, "Miner")) { - if (this.plugin.getJobLv("Miner", p)>=10) { - //Half chance to set the durability back by one. - if (p.getItemInHand().getType()==Material.WOOD_PICKAXE || - p.getItemInHand().getType()==Material.STONE_PICKAXE || - p.getItemInHand().getType()==Material.GOLD_PICKAXE || - p.getItemInHand().getType()==Material.IRON_PICKAXE || - p.getItemInHand().getType()==Material.DIAMOND_PICKAXE) { - if (p.getItemInHand().getDurability()>0) { - if (Math.random()>=0.5) { - p.getItemInHand().setDurability((short)(p.getItemInHand().getDurability()-1)); - p.updateInventory(); - } - } - } - } - if (this.plugin.playerdata_list.get(myData).GoodInteract()) { - if (e.getBlock().getType()==Material.STONE) { - this.plugin.gainMoneyExp(p,"Miner",0.0025,1); - } else - if (e.getBlock().getType()==Material.NETHERRACK) { - this.plugin.gainMoneyExp(p,"Miner",0.005,1); - } else - if (e.getBlock().getType()==Material.COAL_ORE && !has_silktouch) { - this.plugin.gainMoneyExp(p,"Miner",0.0125,3); - } else - if (e.getBlock().getType()==Material.GLOWSTONE && !has_silktouch) { - this.plugin.gainMoneyExp(p,"Miner",0.015,3); - } else - if (e.getBlock().getType()==Material.SANDSTONE) { - this.plugin.gainMoneyExp(p,"Miner",0.015,4); - } else - if (e.getBlock().getType()==Material.NETHER_BRICK) { - this.plugin.gainMoneyExp(p,"Miner",0.02,3); - } else - if (e.getBlock().getType()==Material.QUARTZ_ORE && !has_silktouch) { - this.plugin.gainMoneyExp(p,"Miner",0.025,4); - } else - if (e.getBlock().getType()==Material.LAPIS_ORE && !has_silktouch) { - this.plugin.gainMoneyExp(p,"Miner",0.03,5); - } else - if (e.getBlock().getType()==Material.MOSSY_COBBLESTONE) { - this.plugin.gainMoneyExp(p,"Miner",0.0375,8); - } else - if (e.getBlock().getType()==Material.IRON_ORE && !has_silktouch) { - this.plugin.gainMoneyExp(p,"Miner",0.0375,6); - } else - if ((e.getBlock().getType()==Material.REDSTONE_ORE || e.getBlock().getType()==Material.GLOWING_REDSTONE_ORE) && !has_silktouch) { - this.plugin.gainMoneyExp(p,"Miner",0.05,9); - } else - if (e.getBlock().getType()==Material.OBSIDIAN) { - this.plugin.gainMoneyExp(p,"Miner",0.0625,10); - } else - if (e.getBlock().getType()==Material.GOLD_ORE && !has_silktouch) { - this.plugin.gainMoneyExp(p,"Miner",0.0975,12); - } else - if (e.getBlock().getType()==Material.DIAMOND_ORE && !has_silktouch) { - this.plugin.gainMoneyExp(p,"Miner",0.3125,60); - } else - if (e.getBlock().getType()==Material.EMERALD_ORE && !has_silktouch) { - this.plugin.gainMoneyExp(p,"Miner",0.7625,160); - } - } - } - if (this.plugin.PlayerinJob(p, "Digger")) { - if (this.plugin.getJobLv("Digger", p)>=20) { - //Half chance to set the durability back by one. - if (p.getItemInHand().getType()==Material.WOOD_SPADE || - p.getItemInHand().getType()==Material.STONE_SPADE || - p.getItemInHand().getType()==Material.GOLD_SPADE || - p.getItemInHand().getType()==Material.IRON_SPADE || - p.getItemInHand().getType()==Material.DIAMOND_SPADE) { - if (p.getItemInHand().getDurability()>0) { - if (Math.random()>=0.66) { - p.getItemInHand().setDurability((short)(p.getItemInHand().getDurability()-1)); - p.updateInventory(); - } - } - } - } else - if (this.plugin.getJobLv("Digger", p)>=10) { - //Half chance to set the durability back by one. - if (p.getItemInHand().getType()==Material.WOOD_SPADE || - p.getItemInHand().getType()==Material.STONE_SPADE || - p.getItemInHand().getType()==Material.GOLD_SPADE || - p.getItemInHand().getType()==Material.IRON_SPADE || - p.getItemInHand().getType()==Material.DIAMOND_SPADE) { - if (p.getItemInHand().getDurability()>0) { - if (Math.random()>=0.5) { - p.getItemInHand().setDurability((short)(p.getItemInHand().getDurability()-1)); - p.updateInventory(); - } - } - } - } - if (this.plugin.playerdata_list.get(myData).GoodInteract()) { - if (e.getBlock().getType()==Material.DIRT) { - this.plugin.gainMoneyExp(p,"Digger",0.005,1); - } - if (e.getBlock().getType()==Material.GRASS) { - this.plugin.gainMoneyExp(p,"Digger",0.005,2); - } - if (e.getBlock().getType()==Material.SAND) { - this.plugin.gainMoneyExp(p,"Digger",0.01,2); - } - if (e.getBlock().getType()==Material.GRAVEL) { - this.plugin.gainMoneyExp(p,"Digger",0.02,5); - } - if (e.getBlock().getType()==Material.SOUL_SAND) { - this.plugin.gainMoneyExp(p,"Digger",0.04,8); - } - if (e.getBlock().getType()==Material.CLAY) { - this.plugin.gainMoneyExp(p,"Digger",0.05,10); - } - } - } - //p.sendMessage("You broke the "+e.getBlock().getType()+", Data: "+e.getBlock().getData()); - if (this.plugin.PlayerinJob(p, "Farmer")) { - if (e.getBlock().getType()==Material.SUGAR_CANE_BLOCK) { - this.plugin.gainMoneyExp(p,"Farmer",0.00,1); - } - if (e.getBlock().getType()==Material.CROPS && e.getBlock().getData()==7) { - this.plugin.gainMoneyExp(p,"Farmer",0.01,2); - } - if (e.getBlock().getType()==Material.CARROT && e.getBlock().getData()==7) { - this.plugin.gainMoneyExp(p,"Farmer",0.01,2); - } - if (e.getBlock().getType()==Material.CACTUS) { - this.plugin.gainMoneyExp(p,"Farmer",0.00,3); - } - if (e.getBlock().getType()==Material.POTATO && e.getBlock().getData()==7) { - this.plugin.gainMoneyExp(p,"Farmer",0.03,3); - } - if (e.getBlock().getType()==Material.BROWN_MUSHROOM) { - this.plugin.gainMoneyExp(p,"Farmer",0.00,3); - } - if (e.getBlock().getType()==Material.RED_MUSHROOM) { - this.plugin.gainMoneyExp(p,"Farmer",0.00,3); - } - if (e.getBlock().getType()==Material.NETHER_WARTS && e.getBlock().getData()==3) { - this.plugin.gainMoneyExp(p,"Farmer",0.03,3); - } - /*if (e.getBlock().getType()==Material.PUMPKIN) { + } + if (this.plugin.PlayerinJob(p, "Builder")) { + this.plugin.playerdata_list.get(myData).BadInteract(e.getBlock().getType()); + } + if (this.plugin.PlayerinJob(p, "Woodcutter")) { + if (e.getBlock().getType()==Material.LOG) { + if (p.getItemInHand().getType()==Material.WOOD_AXE || p.getItemInHand().getType()==Material.STONE_AXE || p.getItemInHand().getType()==Material.IRON_AXE || p.getItemInHand().getType()==Material.GOLD_AXE || p.getItemInHand().getType()==Material.DIAMOND_AXE) { + //p.sendMessage("Cut down wood w/axe."); + this.plugin.gainMoneyExp(p,"Woodcutter",0.025,2); + } else { + //p.sendMessage("Cut down wood."); + this.plugin.gainMoneyExp(p,"Woodcutter",0.01,1); + } + } + } + if (this.plugin.PlayerinJob(p, "Miner")) { + if (this.plugin.getJobLv("Miner", p)>=10) { + //Half chance to set the durability back by one. + if (p.getItemInHand().getType()==Material.WOOD_PICKAXE || + p.getItemInHand().getType()==Material.STONE_PICKAXE || + p.getItemInHand().getType()==Material.GOLD_PICKAXE || + p.getItemInHand().getType()==Material.IRON_PICKAXE || + p.getItemInHand().getType()==Material.DIAMOND_PICKAXE) { + if (p.getItemInHand().getDurability()>0) { + if (Math.random()>=0.5) { + p.getItemInHand().setDurability((short)(p.getItemInHand().getDurability()-1)); + p.updateInventory(); + } + } + } + } + if (this.plugin.playerdata_list.get(myData).GoodInteract()) { + if (e.getBlock().getType()==Material.STONE) { + this.plugin.gainMoneyExp(p,"Miner",0.0025,1); + } else + if (e.getBlock().getType()==Material.NETHERRACK) { + this.plugin.gainMoneyExp(p,"Miner",0.005,1); + } else + if (e.getBlock().getType()==Material.COAL_ORE && !has_silktouch) { + this.plugin.gainMoneyExp(p,"Miner",0.0125,3); + } else + if (e.getBlock().getType()==Material.GLOWSTONE && !has_silktouch) { + this.plugin.gainMoneyExp(p,"Miner",0.015,3); + } else + if (e.getBlock().getType()==Material.SANDSTONE) { + this.plugin.gainMoneyExp(p,"Miner",0.015,4); + } else + if (e.getBlock().getType()==Material.NETHER_BRICK) { + this.plugin.gainMoneyExp(p,"Miner",0.02,3); + } else + if (e.getBlock().getType()==Material.QUARTZ_ORE && !has_silktouch) { + this.plugin.gainMoneyExp(p,"Miner",0.025,4); + } else + if (e.getBlock().getType()==Material.LAPIS_ORE && !has_silktouch) { + this.plugin.gainMoneyExp(p,"Miner",0.03,5); + } else + if (e.getBlock().getType()==Material.MOSSY_COBBLESTONE) { + this.plugin.gainMoneyExp(p,"Miner",0.0375,8); + } else + if (e.getBlock().getType()==Material.IRON_ORE && !has_silktouch) { + this.plugin.gainMoneyExp(p,"Miner",0.0375,6); + } else + if ((e.getBlock().getType()==Material.REDSTONE_ORE || e.getBlock().getType()==Material.GLOWING_REDSTONE_ORE) && !has_silktouch) { + this.plugin.gainMoneyExp(p,"Miner",0.05,9); + } else + if (e.getBlock().getType()==Material.OBSIDIAN) { + this.plugin.gainMoneyExp(p,"Miner",0.0625,10); + } else + if (e.getBlock().getType()==Material.GOLD_ORE && !has_silktouch) { + this.plugin.gainMoneyExp(p,"Miner",0.0975,12); + } else + if (e.getBlock().getType()==Material.DIAMOND_ORE && !has_silktouch) { + this.plugin.gainMoneyExp(p,"Miner",0.3125,60); + } else + if (e.getBlock().getType()==Material.EMERALD_ORE && !has_silktouch) { + this.plugin.gainMoneyExp(p,"Miner",0.7625,160); + } + } + } + if (this.plugin.PlayerinJob(p, "Digger")) { + if (this.plugin.getJobLv("Digger", p)>=20) { + //Half chance to set the durability back by one. + if (p.getItemInHand().getType()==Material.WOOD_SPADE || + p.getItemInHand().getType()==Material.STONE_SPADE || + p.getItemInHand().getType()==Material.GOLD_SPADE || + p.getItemInHand().getType()==Material.IRON_SPADE || + p.getItemInHand().getType()==Material.DIAMOND_SPADE) { + if (p.getItemInHand().getDurability()>0) { + if (Math.random()>=0.66) { + p.getItemInHand().setDurability((short)(p.getItemInHand().getDurability()-1)); + p.updateInventory(); + } + } + } + } else + if (this.plugin.getJobLv("Digger", p)>=10) { + //Half chance to set the durability back by one. + if (p.getItemInHand().getType()==Material.WOOD_SPADE || + p.getItemInHand().getType()==Material.STONE_SPADE || + p.getItemInHand().getType()==Material.GOLD_SPADE || + p.getItemInHand().getType()==Material.IRON_SPADE || + p.getItemInHand().getType()==Material.DIAMOND_SPADE) { + if (p.getItemInHand().getDurability()>0) { + if (Math.random()>=0.5) { + p.getItemInHand().setDurability((short)(p.getItemInHand().getDurability()-1)); + p.updateInventory(); + } + } + } + } + if (this.plugin.playerdata_list.get(myData).GoodInteract()) { + if (e.getBlock().getType()==Material.DIRT) { + this.plugin.gainMoneyExp(p,"Digger",0.005,1); + } + if (e.getBlock().getType()==Material.GRASS) { + this.plugin.gainMoneyExp(p,"Digger",0.005,2); + } + if (e.getBlock().getType()==Material.SAND) { + this.plugin.gainMoneyExp(p,"Digger",0.01,2); + } + if (e.getBlock().getType()==Material.GRAVEL) { + this.plugin.gainMoneyExp(p,"Digger",0.02,5); + } + if (e.getBlock().getType()==Material.SOUL_SAND) { + this.plugin.gainMoneyExp(p,"Digger",0.04,8); + } + if (e.getBlock().getType()==Material.CLAY) { + this.plugin.gainMoneyExp(p,"Digger",0.05,10); + } + } + } + //p.sendMessage("You broke the "+e.getBlock().getType()+", Data: "+e.getBlock().getData()); + if (this.plugin.PlayerinJob(p, "Farmer")) { + if (e.getBlock().getType()==Material.SUGAR_CANE_BLOCK) { + this.plugin.gainMoneyExp(p,"Farmer",0.00,1); + } + if (e.getBlock().getType()==Material.CROPS && e.getBlock().getData()==7) { + this.plugin.gainMoneyExp(p,"Farmer",0.01,2); + } + if (e.getBlock().getType()==Material.CARROT && e.getBlock().getData()==7) { + this.plugin.gainMoneyExp(p,"Farmer",0.01,2); + } + if (e.getBlock().getType()==Material.CACTUS) { + this.plugin.gainMoneyExp(p,"Farmer",0.00,3); + } + if (e.getBlock().getType()==Material.POTATO && e.getBlock().getData()==7) { + this.plugin.gainMoneyExp(p,"Farmer",0.03,3); + } + if (e.getBlock().getType()==Material.BROWN_MUSHROOM) { + this.plugin.gainMoneyExp(p,"Farmer",0.00,3); + } + if (e.getBlock().getType()==Material.RED_MUSHROOM) { + this.plugin.gainMoneyExp(p,"Farmer",0.00,3); + } + if (e.getBlock().getType()==Material.NETHER_WARTS && e.getBlock().getData()==3) { + this.plugin.gainMoneyExp(p,"Farmer",0.03,3); + } + /*if (e.getBlock().getType()==Material.PUMPKIN) { this.plugin.gainMoneyExp(p,"Farmer",0.00,1); } if (e.getBlock().getType()==Material.MELON_BLOCK) { this.plugin.gainMoneyExp(p,"Farmer",0.10,10); }*/ - } - boolean hasfortune; - hasfortune = (p.getItemInHand().getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS)>0)?true:false; - //Check blocks around it. If it's a spawner, it's protected until the spawner is destroyed. - for (int x=-4;x<4;x++) { - for (int y=0;y<2;y++) { - for (int z=-4;z<4;z++) { - if ((x!=0 || y!=0 || z!=0) && p.getWorld().getBlockAt(e.getBlock().getLocation().add(x,y,z)).getType()==Material.MOB_SPAWNER && e.getBlock().getType()!=Material.MOB_SPAWNER) { - e.setCancelled(true); - p.sendMessage("A Mob Spawner force field protects this block from being destroyed."); - } - } - } - } - if (e.getBlock().getType()==Material.MOB_SPAWNER) { - p.setLevel(p.getLevel()+30); - try { - Iterator effects = p.getActivePotionEffects().iterator(); + } + boolean hasfortune; + hasfortune = (p.getItemInHand().getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS)>0)?true:false; + //Check blocks around it. If it's a spawner, it's protected until the spawner is destroyed. + for (int x=-4;x<4;x++) { + for (int y=0;y<2;y++) { + for (int z=-4;z<4;z++) { + if ((x!=0 || y!=0 || z!=0) && p.getWorld().getBlockAt(e.getBlock().getLocation().add(x,y,z)).getType()==Material.MOB_SPAWNER && e.getBlock().getType()!=Material.MOB_SPAWNER) { + e.setCancelled(true); + p.sendMessage("A Mob Spawner force field protects this block from being destroyed."); + } + } + } + } + if (e.getBlock().getType()==Material.MOB_SPAWNER) { + p.setLevel(p.getLevel()+30); + try { + Iterator effects = p.getActivePotionEffects().iterator(); //Figure out potion effects when player joins. while (effects.hasNext()) { PotionEffect nexteffect = effects.next(); @@ -3553,326 +3553,326 @@ public class PlayerListener p.removePotionEffect(PotionEffectType.HEALTH_BOOST); p.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 360000, nexteffect.getAmplifier()+1, true)); } - /*if (nexteffect.getType().getName().compareTo(PotionEffectType.JUMP.getName())==0) { - p.removePotionEffect(PotionEffectType.JUMP); - p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 360000, nexteffect.getAmplifier()+2, true)); - }*/ - effects.remove(); + /*if (nexteffect.getType().getName().compareTo(PotionEffectType.JUMP.getName())==0) { + p.removePotionEffect(PotionEffectType.JUMP); + p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 360000, nexteffect.getAmplifier()+2, true)); + }*/ + effects.remove(); + } + + } catch (ConcurrentModificationException ex_e) { + Bukkit.getLogger().warning("Potion Effect Collection not accessible while initializing player speed."); + } + p.removePotionEffect(PotionEffectType.WATER_BREATHING); + p.removePotionEffect(PotionEffectType.FAST_DIGGING); + p.removePotionEffect(PotionEffectType.INCREASE_DAMAGE); + //p.removePotionEffect(PotionEffectType.NIGHT_VISION); + p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 360000, 1, true)); + p.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 360000, 0, true)); + p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 360000, 0, true)); + p.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 360000, 0, true)); + //p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 360000, 0, true)); + //p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 360000, 1, true)); + p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 360000, 1, true)); + } + if ((e.getBlock().getX()==1616 && e.getBlock().getZ()>=53 && e.getBlock().getZ()<=64) || (e.getBlock().getX()==1627 && e.getBlock().getZ()>=53 && e.getBlock().getZ()<=64) || (e.getBlock().getZ()==53 && e.getBlock().getX()>=1616 && e.getBlock().getX()<=1627) || (e.getBlock().getZ()==64 && e.getBlock().getX()>=1616 && e.getBlock().getX()<=1627)) { + e.setCancelled(true); + } + if ((e.getBlock().getX()==1585 && e.getBlock().getZ()>=24 && e.getBlock().getZ()<=39) || (e.getBlock().getX()==1600 && e.getBlock().getZ()>=24 && e.getBlock().getZ()<=39) || (e.getBlock().getZ()==24 && e.getBlock().getX()>=1585 && e.getBlock().getX()<=1600) || (e.getBlock().getZ()==39 && e.getBlock().getX()>=1585 && e.getBlock().getX()<=1600)) { + e.setCancelled(true); + } + if (this.plugin.getConfig().getBoolean("spleefinsession")==true && (this.plugin.getConfig().getString("spleefrequestaplayer").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestbplayer").compareTo(p.getName())==0)) { + this.plugin.spleef_last_broken_block=p.getPlayerTime(); + } + if (this.plugin.getConfig().getBoolean("spleef4insession")==true && (this.plugin.getConfig().getString("spleefrequesta4player").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestb4player").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestc4player").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestd4player").compareTo(p.getName())==0)) { + this.plugin.spleef4_last_broken_block=p.getPlayerTime(); + } + if (p.getItemInHand()!=null && p.getItemInHand().getItemMeta()!=null && p.getItemInHand().getItemMeta().hasDisplayName()==true && p.getItemInHand().getItemMeta().getDisplayName().compareTo("Spleef Wooden Shovel")==0) { + p.getItemInHand().setDurability((short)0); + //p.sendMessage("Got in."); + p.updateInventory(); + } + if (p.getItemInHand()!=null && p.getItemInHand().getItemMeta()!=null && p.getItemInHand().getItemMeta().hasDisplayName()==true && p.getItemInHand().getItemMeta().getDisplayName().compareTo("Spleef Stone Shovel")==0) { + p.getItemInHand().setDurability((short)0); + //p.sendMessage("Got in."); + p.updateInventory(); + } + } + Material[] fortune_materials = {Material.EMERALD_ORE,Material.COAL_ORE,Material.DIAMOND_ORE,Material.REDSTONE_ORE,Material.LAPIS_ORE,Material.QUARTZ_ORE}; //An array of all blocks that multiply via fortune. + Material[] result_materials = {Material.EMERALD,Material.COAL,Material.DIAMOND,Material.REDSTONE,Material.INK_SACK,Material.QUARTZ}; //The resulting materials corresponding to the fortune blocks being broken. + boolean fortune_material=false; + int fortune_material_slot=0; + for (int i=0;i0) { //Check if the player has fortune. + if (fortune_material) { //If this is a fortune material, we have to account for the new fortune enchantment algorithm. + e.setCancelled(true); + e.getPlayer().getWorld().getBlockAt(e.getBlock().getLocation()).setType(Material.AIR); + int fortune_level = p.getItemInHand().getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS); + int drop_chance=50; + for (int i=1;i=53 && e.getBlock().getZ()<=64) || (e.getBlock().getX()==1627 && e.getBlock().getZ()>=53 && e.getBlock().getZ()<=64) || (e.getBlock().getZ()==53 && e.getBlock().getX()>=1616 && e.getBlock().getX()<=1627) || (e.getBlock().getZ()==64 && e.getBlock().getX()>=1616 && e.getBlock().getX()<=1627)) { - e.setCancelled(true); - } - if ((e.getBlock().getX()==1585 && e.getBlock().getZ()>=24 && e.getBlock().getZ()<=39) || (e.getBlock().getX()==1600 && e.getBlock().getZ()>=24 && e.getBlock().getZ()<=39) || (e.getBlock().getZ()==24 && e.getBlock().getX()>=1585 && e.getBlock().getX()<=1600) || (e.getBlock().getZ()==39 && e.getBlock().getX()>=1585 && e.getBlock().getX()<=1600)) { - e.setCancelled(true); - } - if (this.plugin.getConfig().getBoolean("spleefinsession")==true && (this.plugin.getConfig().getString("spleefrequestaplayer").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestbplayer").compareTo(p.getName())==0)) { - this.plugin.spleef_last_broken_block=p.getPlayerTime(); - } - if (this.plugin.getConfig().getBoolean("spleef4insession")==true && (this.plugin.getConfig().getString("spleefrequesta4player").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestb4player").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestc4player").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestd4player").compareTo(p.getName())==0)) { - this.plugin.spleef4_last_broken_block=p.getPlayerTime(); - } - if (p.getItemInHand()!=null && p.getItemInHand().getItemMeta()!=null && p.getItemInHand().getItemMeta().hasDisplayName()==true && p.getItemInHand().getItemMeta().getDisplayName().compareTo("Spleef Wooden Shovel")==0) { - p.getItemInHand().setDurability((short)0); - //p.sendMessage("Got in."); - p.updateInventory(); - } - if (p.getItemInHand()!=null && p.getItemInHand().getItemMeta()!=null && p.getItemInHand().getItemMeta().hasDisplayName()==true && p.getItemInHand().getItemMeta().getDisplayName().compareTo("Spleef Stone Shovel")==0) { - p.getItemInHand().setDurability((short)0); - //p.sendMessage("Got in."); - p.updateInventory(); - } - } - Material[] fortune_materials = {Material.EMERALD_ORE,Material.COAL_ORE,Material.DIAMOND_ORE,Material.REDSTONE_ORE,Material.LAPIS_ORE,Material.QUARTZ_ORE}; //An array of all blocks that multiply via fortune. - Material[] result_materials = {Material.EMERALD,Material.COAL,Material.DIAMOND,Material.REDSTONE,Material.INK_SACK,Material.QUARTZ}; //The resulting materials corresponding to the fortune blocks being broken. - boolean fortune_material=false; - int fortune_material_slot=0; - for (int i=0;i0) { //Check if the player has fortune. - if (fortune_material) { //If this is a fortune material, we have to account for the new fortune enchantment algorithm. - e.setCancelled(true); - e.getPlayer().getWorld().getBlockAt(e.getBlock().getLocation()).setType(Material.AIR); - int fortune_level = p.getItemInHand().getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS); - int drop_chance=50; - for (int i=1;ip.getMaxHealth()) { + p.setHealth(p.getMaxHealth()); + } else { + p.setHealth(p.getHealth()+24); + } + } + } + } + } - if (pot.getType()==PotionType.INSTANT_HEAL) { - if (!p.isDead()) { - if (p.getHealth()+24>p.getMaxHealth()) { - p.setHealth(p.getMaxHealth()); - } else { - p.setHealth(p.getHealth()+24); - } - } - } - } - } - - @EventHandler - public void onPotionSplash(PotionSplashEvent e) { - try { - Iterator entities = e.getAffectedEntities().iterator(); - Player shooter; - if (e.getPotion().getShooter().getType() == EntityType.PLAYER) { - shooter=(Player)e.getPotion().getShooter(); - if (this.plugin.PlayerinJob(shooter,"Support")) { - //Bukkit.getPlayer("sigonasr2").sendMessage("Shooter is "+shooter.getName()); - while (entities.hasNext()) { - LivingEntity next = entities.next(); - if (next.getType() == EntityType.PLAYER) { - final Player p = (Player)next; - Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { - @Override - public void run() { - p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); - } - },5); - if (p!=shooter) { - //Award the support. - //Bukkit.getPlayer("sigonasr2").sendMessage(p.getName()+" got hit by your potion!"); - //Iterator effects = e.getPotion().getEffects().iterator(); - try { - Collection effects = e.getPotion().getEffects(); - for (PotionEffect nextpotioneffect : effects) { - //shooter.sendMessage(nextpotioneffect.getType().getName()+" is the potion effect."); - if (nextpotioneffect.getType().getName().compareTo("NIGHT_VISION")==0) { - //this.plugin.gainMoneyExp(shooter,"Support",0.10,5); - } - if (nextpotioneffect.getType().getName().compareTo("SPEED")==0) { - this.plugin.gainMoneyExp(shooter,"Support",0.15,6); - for (int i=0;i0) { - this.plugin.gainMoneyExp(shooter,"Support",4.80,240); - } - //this.plugin.gainMoneyExp(shooter,"Support",0.25,12); - } - if (nextpotioneffect.getType().getName().compareTo("HEAL")==0) { - if (!p.isDead()) { - if (p.getHealth()/p.getMaxHealth()<=0.30) { - this.plugin.gainMoneyExp(shooter,"Support",2.40,120); - //shooter.sendMessage("This is a big heal."); - p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); - } - //this.plugin.gainMoneyExp(shooter,"Support",0.30,14); - if (p.getHealth()+12>p.getMaxHealth()) { - p.setHealth(p.getMaxHealth()); - } else { - p.setHealth(p.getHealth()+12); - } - //shooter.sendMessage("This is a heal."); - } - } - if (nextpotioneffect.getType().getName().compareTo("REGENERATION")==0) { - if (p.getHealth()/p.getMaxHealth()<=0.30) { - //this.plugin.gainMoneyExp(shooter,"Support",0.60,30); - } - //this.plugin.gainMoneyExp(shooter,"Support",0.30,14); - //shooter.sendMessage("This is a heal."); - } - } - } catch (ConcurrentModificationException ex_e) { - Bukkit.getLogger().warning("Potion Effect Collection not accessible for a support while attempting a splash potion."); - } - /*while (effects.hasNext()) { + @EventHandler + public void onPotionSplash(PotionSplashEvent e) { + try { + Iterator entities = e.getAffectedEntities().iterator(); + Player shooter; + if (e.getPotion().getShooter().getType() == EntityType.PLAYER) { + shooter=(Player)e.getPotion().getShooter(); + if (this.plugin.PlayerinJob(shooter,"Support")) { + //Bukkit.getPlayer("sigonasr2").sendMessage("Shooter is "+shooter.getName()); + while (entities.hasNext()) { + LivingEntity next = entities.next(); + if (next.getType() == EntityType.PLAYER) { + final Player p = (Player)next; + Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { + @Override + public void run() { + p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); + } + },5); + if (p!=shooter) { + //Award the support. + //Bukkit.getPlayer("sigonasr2").sendMessage(p.getName()+" got hit by your potion!"); + //Iterator effects = e.getPotion().getEffects().iterator(); + try { + Collection effects = e.getPotion().getEffects(); + for (PotionEffect nextpotioneffect : effects) { + //shooter.sendMessage(nextpotioneffect.getType().getName()+" is the potion effect."); + if (nextpotioneffect.getType().getName().compareTo("NIGHT_VISION")==0) { + //this.plugin.gainMoneyExp(shooter,"Support",0.10,5); + } + if (nextpotioneffect.getType().getName().compareTo("SPEED")==0) { + this.plugin.gainMoneyExp(shooter,"Support",0.15,6); + for (int i=0;i0) { + this.plugin.gainMoneyExp(shooter,"Support",4.80,240); + } + //this.plugin.gainMoneyExp(shooter,"Support",0.25,12); + } + if (nextpotioneffect.getType().getName().compareTo("HEAL")==0) { + if (!p.isDead()) { + if (p.getHealth()/p.getMaxHealth()<=0.30) { + this.plugin.gainMoneyExp(shooter,"Support",2.40,120); + //shooter.sendMessage("This is a big heal."); + p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); + } + //this.plugin.gainMoneyExp(shooter,"Support",0.30,14); + if (p.getHealth()+12>p.getMaxHealth()) { + p.setHealth(p.getMaxHealth()); + } else { + p.setHealth(p.getHealth()+12); + } + //shooter.sendMessage("This is a heal."); + } + } + if (nextpotioneffect.getType().getName().compareTo("REGENERATION")==0) { + if (p.getHealth()/p.getMaxHealth()<=0.30) { + //this.plugin.gainMoneyExp(shooter,"Support",0.60,30); + } + //this.plugin.gainMoneyExp(shooter,"Support",0.30,14); + //shooter.sendMessage("This is a heal."); + } + } + } catch (ConcurrentModificationException ex_e) { + Bukkit.getLogger().warning("Potion Effect Collection not accessible for a support while attempting a splash potion."); + } + /*while (effects.hasNext()) { PotionEffect nextpotioneffect = effects.next(); shooter.sendMessage(nextpotioneffect.getType().getName()+" is the potion effect."); if (nextpotioneffect.getType().getName().compareTo("NIGHT_VISION")==0) { @@ -3914,289 +3914,289 @@ public class PlayerListener } effects.remove(); } - */ - } else { - try { - Collection effects = e.getPotion().getEffects(); - for (PotionEffect nextpotioneffect : effects) { - //shooter.sendMessage(nextpotioneffect.getType().getName()+" is the potion effect."); - if (nextpotioneffect.getType().getName().compareTo("SPEED")==0) { - //this.plugin.gainMoneyExp(shooter,"Support",0.15,6); - //Apply this potion effect to our player buff data. - for (int i=0;ip.getMaxHealth()) { - p.setHealth(p.getMaxHealth()); - } else { - p.setHealth(p.getHealth()+12); - } - //shooter.sendMessage("This is a heal."); - p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); - } - } - } - } catch (ConcurrentModificationException ex_e) { - Bukkit.getLogger().warning("Potion Effect Collection not accessible for a player while modifying speed amount."); - } - } - } - entities.remove(); - } - } else { - while (entities.hasNext()) { - LivingEntity next = entities.next(); - if (next.getType() == EntityType.PLAYER) { - final Player p = (Player)next; - Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { - @Override - public void run() { - p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); - } - },5); - try { - Iterator effects = e.getPotion().getEffects().iterator(); - while (effects.hasNext()) { - PotionEffect nextpotioneffect = effects.next(); - //shooter.sendMessage(nextpotioneffect.getType().getName()+" is the potion effect."); - if (this.plugin.PlayerinJob(shooter, "Brewer") && this.plugin.getJobLv("Brewer", shooter)>=20) { - next.removePotionEffect(nextpotioneffect.getType()); - next.addPotionEffect(new PotionEffect(nextpotioneffect.getType(),nextpotioneffect.getDuration()*2,nextpotioneffect.getAmplifier(),false)); - nextpotioneffect.getDuration(); - } - if (nextpotioneffect.getType().getName().compareTo("SPEED")==0) { - //this.plugin.gainMoneyExp(shooter,"Support",0.15,6); - //Apply this potion effect to our player buff data. - for (int i=0;ip.getMaxHealth()) { - p.setHealth(p.getMaxHealth()); - } else { - p.setHealth(p.getHealth()+12); - } - //shooter.sendMessage("This is a heal."); - } - } - effects.remove(); - } - } catch (ConcurrentModificationException ex_e) { - Bukkit.getLogger().warning("Potion Effect Collection not accessible for a player during a splash potion speed update."); - } - } - entities.remove(); - } - } - } - } catch (ConcurrentModificationException ex_e) { - Bukkit.getLogger().warning("Entity Collection not accessible during splash potion effect."); - } - } - - @EventHandler - public void onItemPrepareCraft(PrepareItemCraftEvent e) { - CraftingInventory result = e.getInventory(); - - // Disable melon crafting recipe - if (result.getResult().getType()==Material.MELON_BLOCK) { - result.setResult(new ItemStack(Material.AIR)); - } - - // Increase stairs recipe efficiency - if (result.getResult().getType()==Material.WOOD_STAIRS) { - result.setResult(new ItemStack(Material.WOOD_STAIRS, 8)); - } - if (result.getResult().getType()==Material.BIRCH_WOOD_STAIRS) { - result.setResult(new ItemStack(Material.BIRCH_WOOD_STAIRS, 8)); - } - if (result.getResult().getType()==Material.SPRUCE_WOOD_STAIRS) { - result.setResult(new ItemStack(Material.SPRUCE_WOOD_STAIRS, 8)); - } - if (result.getResult().getType()==Material.JUNGLE_WOOD_STAIRS) { - result.setResult(new ItemStack(Material.JUNGLE_WOOD_STAIRS, 8)); - } - if (result.getResult().getType()==Material.BRICK_STAIRS) { - result.setResult(new ItemStack(Material.BRICK_STAIRS, 8)); - } - if (result.getResult().getType()==Material.NETHER_BRICK_STAIRS) { - result.setResult(new ItemStack(Material.NETHER_BRICK_STAIRS, 8)); - } - if (result.getResult().getType()==Material.QUARTZ_STAIRS) { - result.setResult(new ItemStack(Material.QUARTZ_STAIRS, 8)); - } - if (result.getResult().getType()==Material.SANDSTONE_STAIRS) { - result.setResult(new ItemStack(Material.SANDSTONE_STAIRS, 8)); - } - if (result.getResult().getType()==Material.SMOOTH_STAIRS) { - result.setResult(new ItemStack(Material.SMOOTH_STAIRS, 8)); - } - - if (result.getResult().getType()==Material.IRON_HELMET || - result.getResult().getType()==Material.IRON_CHESTPLATE || - result.getResult().getType()==Material.IRON_LEGGINGS || - result.getResult().getType()==Material.IRON_BOOTS) { - ItemStack[] craftwith = result.getMatrix(); - boolean ingots=true; - for (int i=0;i='a'&&mod[i]<='z') { - mod[i]-=32; - first=true; - } else - if (i==0) { - if (mod[i]>='A'&&mod[i]<='Z') { - first=true; - } - } else { - if (mod[i]>='A'&&mod[i]<='Z'&&(mod[i-1]<'A'||mod[i-1]>'Z')) { - first=true; - } - } - } else { - if (mod[i-1]!=' ') { - if (mod[i]>='A'&&mod[i]<='Z') { - mod[i]+=32; - } - } - } - } - newarmor_meta.setDisplayName(String.copyValueOf(mod)); - List NewLore = new ArrayList(); - NewLore.add(ChatColor.RED+"-400% Durability"); - newarmor_meta.setLore(NewLore); - newarmor.setItemMeta(newarmor_meta); - result.setResult(newarmor); - } - } else - if (result.getResult().getType()==Material.GOLD_HELMET || - result.getResult().getType()==Material.GOLD_CHESTPLATE || - result.getResult().getType()==Material.GOLD_LEGGINGS || - result.getResult().getType()==Material.GOLD_BOOTS) { - ItemStack[] craftwith = result.getMatrix(); - boolean ingots=true; - for (int i=0;i='a'&&mod[i]<='z') { - mod[i]-=32; - first=true; - } else - if (i==0) { - if (mod[i]>='A'&&mod[i]<='Z') { - first=true; - } - } else { - if (mod[i]>='A'&&mod[i]<='Z'&&(mod[i-1]<'A'||mod[i-1]>'Z')) { - first=true; - } - } - } else { - if (mod[i-1]!=' ') { - if (mod[i]>='A'&&mod[i]<='Z') { - mod[i]+=32; - } - } - } - } - newarmor_meta.setDisplayName(String.copyValueOf(mod)); - List NewLore = new ArrayList(); - NewLore.add(ChatColor.RED+"-400% Durability"); - newarmor_meta.setLore(NewLore); - newarmor.setItemMeta(newarmor_meta); - result.setResult(newarmor); - } - } else - if (result.getResult().getType()==Material.DIAMOND_HELMET || - result.getResult().getType()==Material.DIAMOND_CHESTPLATE || - result.getResult().getType()==Material.DIAMOND_LEGGINGS || - result.getResult().getType()==Material.DIAMOND_BOOTS) { - ItemStack[] craftwith = result.getMatrix(); - boolean ingots=true; - for (int i=0;i='a'&&mod[i]<='z') { - mod[i]-=32; - first=true; - } else - if (i==0) { - if (mod[i]>='A'&&mod[i]<='Z') { - first=true; - } - } else { - if (mod[i]>='A'&&mod[i]<='Z'&&(mod[i-1]<'A'||mod[i-1]>'Z')) { - first=true; - } - } - } else { - if (mod[i-1]!=' ') { - if (mod[i]>='A'&&mod[i]<='Z') { - mod[i]+=32; - } - } - } - } - newarmor_meta.setDisplayName(String.copyValueOf(mod)); - List NewLore = new ArrayList(); - NewLore.add(ChatColor.RED+"-400% Durability"); - newarmor_meta.setLore(NewLore); - newarmor.setItemMeta(newarmor_meta); - result.setResult(newarmor); - } + */ + } else { + try { + Collection effects = e.getPotion().getEffects(); + for (PotionEffect nextpotioneffect : effects) { + //shooter.sendMessage(nextpotioneffect.getType().getName()+" is the potion effect."); + if (nextpotioneffect.getType().getName().compareTo("SPEED")==0) { + //this.plugin.gainMoneyExp(shooter,"Support",0.15,6); + //Apply this potion effect to our player buff data. + for (int i=0;ip.getMaxHealth()) { + p.setHealth(p.getMaxHealth()); + } else { + p.setHealth(p.getHealth()+12); + } + //shooter.sendMessage("This is a heal."); + p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); + } + } + } + } catch (ConcurrentModificationException ex_e) { + Bukkit.getLogger().warning("Potion Effect Collection not accessible for a player while modifying speed amount."); + } + } + } + entities.remove(); + } + } else { + while (entities.hasNext()) { + LivingEntity next = entities.next(); + if (next.getType() == EntityType.PLAYER) { + final Player p = (Player)next; + Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { + @Override + public void run() { + p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); + } + },5); + try { + Iterator effects = e.getPotion().getEffects().iterator(); + while (effects.hasNext()) { + PotionEffect nextpotioneffect = effects.next(); + //shooter.sendMessage(nextpotioneffect.getType().getName()+" is the potion effect."); + if (this.plugin.PlayerinJob(shooter, "Brewer") && this.plugin.getJobLv("Brewer", shooter)>=20) { + next.removePotionEffect(nextpotioneffect.getType()); + next.addPotionEffect(new PotionEffect(nextpotioneffect.getType(),nextpotioneffect.getDuration()*2,nextpotioneffect.getAmplifier(),false)); + nextpotioneffect.getDuration(); + } + if (nextpotioneffect.getType().getName().compareTo("SPEED")==0) { + //this.plugin.gainMoneyExp(shooter,"Support",0.15,6); + //Apply this potion effect to our player buff data. + for (int i=0;ip.getMaxHealth()) { + p.setHealth(p.getMaxHealth()); + } else { + p.setHealth(p.getHealth()+12); + } + //shooter.sendMessage("This is a heal."); + } + } + effects.remove(); + } + } catch (ConcurrentModificationException ex_e) { + Bukkit.getLogger().warning("Potion Effect Collection not accessible for a player during a splash potion speed update."); + } + } + entities.remove(); + } + } + } + } catch (ConcurrentModificationException ex_e) { + Bukkit.getLogger().warning("Entity Collection not accessible during splash potion effect."); + } } + + @EventHandler + public void onItemPrepareCraft(PrepareItemCraftEvent e) { + CraftingInventory result = e.getInventory(); + + // Disable melon crafting recipe + if (result.getResult().getType()==Material.MELON_BLOCK) { + result.setResult(new ItemStack(Material.AIR)); + } + + // Increase stairs recipe efficiency + if (result.getResult().getType()==Material.WOOD_STAIRS) { + result.setResult(new ItemStack(Material.WOOD_STAIRS, 8)); + } + if (result.getResult().getType()==Material.BIRCH_WOOD_STAIRS) { + result.setResult(new ItemStack(Material.BIRCH_WOOD_STAIRS, 8)); + } + if (result.getResult().getType()==Material.SPRUCE_WOOD_STAIRS) { + result.setResult(new ItemStack(Material.SPRUCE_WOOD_STAIRS, 8)); + } + if (result.getResult().getType()==Material.JUNGLE_WOOD_STAIRS) { + result.setResult(new ItemStack(Material.JUNGLE_WOOD_STAIRS, 8)); + } + if (result.getResult().getType()==Material.BRICK_STAIRS) { + result.setResult(new ItemStack(Material.BRICK_STAIRS, 8)); + } + if (result.getResult().getType()==Material.NETHER_BRICK_STAIRS) { + result.setResult(new ItemStack(Material.NETHER_BRICK_STAIRS, 8)); + } + if (result.getResult().getType()==Material.QUARTZ_STAIRS) { + result.setResult(new ItemStack(Material.QUARTZ_STAIRS, 8)); + } + if (result.getResult().getType()==Material.SANDSTONE_STAIRS) { + result.setResult(new ItemStack(Material.SANDSTONE_STAIRS, 8)); + } + if (result.getResult().getType()==Material.SMOOTH_STAIRS) { + result.setResult(new ItemStack(Material.SMOOTH_STAIRS, 8)); + } + + if (result.getResult().getType()==Material.IRON_HELMET || + result.getResult().getType()==Material.IRON_CHESTPLATE || + result.getResult().getType()==Material.IRON_LEGGINGS || + result.getResult().getType()==Material.IRON_BOOTS) { + ItemStack[] craftwith = result.getMatrix(); + boolean ingots=true; + for (int i=0;i='a'&&mod[i]<='z') { + mod[i]-=32; + first=true; + } else + if (i==0) { + if (mod[i]>='A'&&mod[i]<='Z') { + first=true; + } + } else { + if (mod[i]>='A'&&mod[i]<='Z'&&(mod[i-1]<'A'||mod[i-1]>'Z')) { + first=true; + } + } + } else { + if (mod[i-1]!=' ') { + if (mod[i]>='A'&&mod[i]<='Z') { + mod[i]+=32; + } + } + } + } + newarmor_meta.setDisplayName(String.copyValueOf(mod)); + List NewLore = new ArrayList(); + NewLore.add(ChatColor.RED+"-400% Durability"); + newarmor_meta.setLore(NewLore); + newarmor.setItemMeta(newarmor_meta); + result.setResult(newarmor); + } + } else + if (result.getResult().getType()==Material.GOLD_HELMET || + result.getResult().getType()==Material.GOLD_CHESTPLATE || + result.getResult().getType()==Material.GOLD_LEGGINGS || + result.getResult().getType()==Material.GOLD_BOOTS) { + ItemStack[] craftwith = result.getMatrix(); + boolean ingots=true; + for (int i=0;i='a'&&mod[i]<='z') { + mod[i]-=32; + first=true; + } else + if (i==0) { + if (mod[i]>='A'&&mod[i]<='Z') { + first=true; + } + } else { + if (mod[i]>='A'&&mod[i]<='Z'&&(mod[i-1]<'A'||mod[i-1]>'Z')) { + first=true; + } + } + } else { + if (mod[i-1]!=' ') { + if (mod[i]>='A'&&mod[i]<='Z') { + mod[i]+=32; + } + } + } + } + newarmor_meta.setDisplayName(String.copyValueOf(mod)); + List NewLore = new ArrayList(); + NewLore.add(ChatColor.RED+"-400% Durability"); + newarmor_meta.setLore(NewLore); + newarmor.setItemMeta(newarmor_meta); + result.setResult(newarmor); + } + } else + if (result.getResult().getType()==Material.DIAMOND_HELMET || + result.getResult().getType()==Material.DIAMOND_CHESTPLATE || + result.getResult().getType()==Material.DIAMOND_LEGGINGS || + result.getResult().getType()==Material.DIAMOND_BOOTS) { + ItemStack[] craftwith = result.getMatrix(); + boolean ingots=true; + for (int i=0;i='a'&&mod[i]<='z') { + mod[i]-=32; + first=true; + } else + if (i==0) { + if (mod[i]>='A'&&mod[i]<='Z') { + first=true; + } + } else { + if (mod[i]>='A'&&mod[i]<='Z'&&(mod[i-1]<'A'||mod[i-1]>'Z')) { + first=true; + } + } + } else { + if (mod[i-1]!=' ') { + if (mod[i]>='A'&&mod[i]<='Z') { + mod[i]+=32; + } + } + } + } + newarmor_meta.setDisplayName(String.copyValueOf(mod)); + List NewLore = new ArrayList(); + NewLore.add(ChatColor.RED+"-400% Durability"); + newarmor_meta.setLore(NewLore); + newarmor.setItemMeta(newarmor_meta); + result.setResult(newarmor); + } + } //It could be with iron, gold, or diamond blocks. Try them out. - /* + /* boolean iron=false,gold=false,diamond=false; boolean helmet=false,chestplate=false,leggings=false,boots=false; ItemStack[] craftwith = result.getMatrix(); @@ -4331,401 +4331,401 @@ public class PlayerListener if (craftwith[0].getType()==Material.DIAMOND_BLOCK && craftwith[1].getType()==Material.DIAMOND_BLOCK && craftwith[2].getType()==Material.DIAMOND_BLOCK && - craftwith[3].getType()==Material.DIAMOND_BLOCK && - craftwith[4].getType()==Material.AIR && - craftwith[5].getType()==Material.DIAMOND_BLOCK && - craftwith[6].getType()==Material.DIAMOND_BLOCK && - craftwith[7].getType()==Material.AIR && - craftwith[8].getType()==Material.DIAMOND_BLOCK) { - ItemStack newarmor = new ItemStack(Material.DIAMOND_LEGGINGS); - result.setResult(newarmor); - } else - if (craftwith[0].getType()==Material.DIAMOND_BLOCK && - craftwith[1].getType()==Material.AIR && - craftwith[2].getType()==Material.DIAMOND_BLOCK && - craftwith[3].getType()==Material.DIAMOND_BLOCK && - craftwith[4].getType()==Material.DIAMOND_BLOCK && - craftwith[5].getType()==Material.DIAMOND_BLOCK && - craftwith[6].getType()==Material.DIAMOND_BLOCK && - craftwith[7].getType()==Material.DIAMOND_BLOCK && - craftwith[8].getType()==Material.DIAMOND_BLOCK) { - ItemStack newarmor = new ItemStack(Material.DIAMOND_CHESTPLATE); - result.setResult(newarmor); - } else - if ((craftwith[0].getType()==Material.DIAMOND_BLOCK && - craftwith[1].getType()==Material.DIAMOND_BLOCK && - craftwith[2].getType()==Material.DIAMOND_BLOCK && - craftwith[3].getType()==Material.DIAMOND_BLOCK && - craftwith[4].getType()==Material.AIR && - craftwith[5].getType()==Material.DIAMOND_BLOCK && - craftwith[6].getType()==Material.AIR && - craftwith[7].getType()==Material.AIR && - craftwith[8].getType()==Material.AIR) || (craftwith[3].getType()==Material.DIAMOND_BLOCK && - craftwith[4].getType()==Material.DIAMOND_BLOCK && - craftwith[5].getType()==Material.DIAMOND_BLOCK && - craftwith[6].getType()==Material.DIAMOND_BLOCK && - craftwith[7].getType()==Material.AIR && - craftwith[8].getType()==Material.DIAMOND_BLOCK && - craftwith[0].getType()==Material.AIR && - craftwith[1].getType()==Material.AIR && - craftwith[2].getType()==Material.AIR)) { - ItemStack newarmor = new ItemStack(Material.DIAMOND_HELMET); - result.setResult(newarmor); - } else - if ((craftwith[0].getType()==Material.DIAMOND_BLOCK && - craftwith[1].getType()==Material.AIR && - craftwith[2].getType()==Material.DIAMOND_BLOCK && - craftwith[3].getType()==Material.DIAMOND_BLOCK && - craftwith[4].getType()==Material.AIR && - craftwith[5].getType()==Material.DIAMOND_BLOCK && - craftwith[6].getType()==Material.AIR && - craftwith[7].getType()==Material.AIR && - craftwith[8].getType()==Material.AIR) || (craftwith[3].getType()==Material.DIAMOND_BLOCK && - craftwith[4].getType()==Material.AIR && - craftwith[5].getType()==Material.DIAMOND_BLOCK && - craftwith[6].getType()==Material.DIAMOND_BLOCK && - craftwith[7].getType()==Material.AIR && - craftwith[8].getType()==Material.DIAMOND_BLOCK && - craftwith[0].getType()==Material.AIR && - craftwith[1].getType()==Material.AIR && - craftwith[2].getType()==Material.AIR)) { - ItemStack newarmor = new ItemStack(Material.DIAMOND_BOOTS); - result.setResult(newarmor); - } - */ - } - - @EventHandler - public void onItemCraft(CraftItemEvent e) { - //This is something we just crafted. - //Bukkit.getPlayer("sigonasr2").sendMessage("Resulting item is "+result.getResult().getAmount()+" "+result.getResult().getType()); - CraftingInventory result = e.getInventory(); - //Bukkit.getPlayer("sigonasr2").sendMessage("Resulting item is "+result.getResult().getAmount()+" "+result.getResult().getType()); - Player p = Bukkit.getPlayer(e.getWhoClicked().getName()); - if (this.plugin.PlayerinJob(p,"Weaponsmith")) { - boolean crafteditem=false; - if (result.getResult().getType()==Material.ARROW) { - crafteditem=true; - } - if (result.getResult().getType()==Material.WOOD_SWORD) { - crafteditem=true; - } - if (result.getResult().getType()==Material.FLINT_AND_STEEL) { - crafteditem=true; - } - if (result.getResult().getType()==Material.BOW) { - crafteditem=true; - } - if (result.getResult().getType()==Material.IRON_SWORD) { - crafteditem=true; - } - if (result.getResult().getType()==Material.GOLD_SWORD) { - crafteditem=true; - } - if (result.getResult().getType()==Material.DIAMOND_SWORD) { - crafteditem=true; - } - if (this.plugin.getJobLv("Weaponsmith", p)>=20 && crafteditem) { - ItemStack[] crafteditems = result.getMatrix(); - if (e.getClick()==ClickType.SHIFT_RIGHT || e.getClick()==ClickType.SHIFT_LEFT) { - int lowestamt=9999; - for (int i=0;i=5 && crafteditem) { - ItemStack[] crafteditems = result.getMatrix(); - if (e.getClick()==ClickType.SHIFT_RIGHT || e.getClick()==ClickType.SHIFT_LEFT) { - int lowestamt=9999; - for (int i=0;i=10 && crafteditem) { - //Bukkit.getPlayer("sigonasr2").sendMessage("Valid item. Going to attempt to enchant."); - if (e.getClick()!=ClickType.SHIFT_RIGHT && e.getClick()!=ClickType.SHIFT_LEFT) { - ItemStack resulting = EnchantItem(result.getResult(),5,p); - result.setResult(resulting); - } - } - } - if (this.plugin.PlayerinJob(p,"Blacksmith")) { - boolean crafteditem=false; - /* - if (result.getResult().getType()==Material.STONE_HOE) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.04,7); - crafteditem=true; - } - if (result.getResult().getType()==Material.STONE_SPADE) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.05,8); - crafteditem=true; - } - if (result.getResult().getType()==Material.STONE_PICKAXE) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.075,15); - crafteditem=true; - }*/ - if (result.getResult().getType()==Material.LEATHER_BOOTS) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.125,8); - crafteditem=true; - } - if (result.getResult().getType()==Material.LEATHER_HELMET) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.15,14); - crafteditem=true; - } - if (result.getResult().getType()==Material.LEATHER_LEGGINGS) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.175,15); - crafteditem=true; - } - if (result.getResult().getType()==Material.LEATHER_CHESTPLATE) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.20,18); - crafteditem=true; - } - if (result.getResult().getType()==Material.IRON_SPADE) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.25,18); - crafteditem=true; - } - if (result.getResult().getType()==Material.IRON_AXE) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.25,18); - crafteditem=true; - } - if (result.getResult().getType()==Material.IRON_HOE) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.325,24); - crafteditem=true; - } - if (result.getResult().getType()==Material.IRON_BOOTS) { - int mult=1; - if ((result.getResult().getItemMeta().getDisplayName()!=null && !result.getResult().getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getResult().getItemMeta().getDisplayName()==null) { - mult=8; - } - //this.plugin.gainMoneyExp(p,"Blacksmith",0.375*mult,27*mult); - crafteditem=true; - } - if (result.getResult().getType()==Material.IRON_PICKAXE) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.40,30); - crafteditem=true; - } - if (result.getResult().getType()==Material.IRON_HELMET) { - int mult=1; - if ((result.getResult().getItemMeta().getDisplayName()!=null && !result.getResult().getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getResult().getItemMeta().getDisplayName()==null) { - mult=8; - } - //this.plugin.gainMoneyExp(p,"Blacksmith",0.50*mult,45*mult); - crafteditem=true; - } - if (result.getResult().getType()==Material.GOLD_SPADE) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.625,55); - crafteditem=true; - } - if (result.getResult().getType()==Material.GOLD_AXE) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.625,55); - crafteditem=true; - } - if (result.getResult().getType()==Material.GOLD_HOE) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.65,60); - crafteditem=true; - } - if (result.getResult().getType()==Material.IRON_LEGGINGS) { - int mult=1; - if ((result.getResult().getItemMeta().getDisplayName()!=null && !result.getResult().getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getResult().getItemMeta().getDisplayName()==null) { - mult=8; - } - //this.plugin.gainMoneyExp(p,"Blacksmith",0.725*mult,60*mult); - crafteditem=true; - } - if (result.getResult().getType()==Material.DIAMOND_SPADE) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.75,65); - crafteditem=true; - } - if (result.getResult().getType()==Material.DIAMOND_AXE) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.75,65); - crafteditem=true; - } - if (result.getResult().getType()==Material.DIAMOND_HOE) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.80,70); - crafteditem=true; - } - if (result.getResult().getType()==Material.GOLD_BOOTS) { - int mult=1; - if ((result.getResult().getItemMeta().getDisplayName()!=null && !result.getResult().getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getResult().getItemMeta().getDisplayName()==null) { - mult=8; - } - //this.plugin.gainMoneyExp(p,"Blacksmith",0.825*mult,50*mult); - crafteditem=true; - } - if (result.getResult().getType()==Material.IRON_CHESTPLATE) { - int mult=1; - if ((result.getResult().getItemMeta().getDisplayName()!=null && !result.getResult().getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getResult().getItemMeta().getDisplayName()==null) { - mult=8; - } - //this.plugin.gainMoneyExp(p,"Blacksmith",0.875*mult,70*mult); - crafteditem=true; - } - if (result.getResult().getType()==Material.GOLD_HELMET) { - int mult=1; - if ((result.getResult().getItemMeta().getDisplayName()!=null && !result.getResult().getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getResult().getItemMeta().getDisplayName()==null) { - mult=8; - } - //this.plugin.gainMoneyExp(p,"Blacksmith",0.925*mult,80*mult); - crafteditem=true; - } - if (result.getResult().getType()==Material.DIAMOND_PICKAXE) { - //this.plugin.gainMoneyExp(p,"Blacksmith",0.925,80); - crafteditem=true; - } - if (result.getResult().getType()==Material.DIAMOND_BOOTS) { - int mult=1; - if ((result.getResult().getItemMeta().getDisplayName()!=null && !result.getResult().getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getResult().getItemMeta().getDisplayName()==null) { - mult=8; - } - //this.plugin.gainMoneyExp(p,"Blacksmith",1.00*mult,85*mult); - crafteditem=true; - } - if (result.getResult().getType()==Material.GOLD_LEGGINGS) { - int mult=1; - if ((result.getResult().getItemMeta().getDisplayName()!=null && !result.getResult().getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getResult().getItemMeta().getDisplayName()==null) { - mult=8; - } - //this.plugin.gainMoneyExp(p,"Blacksmith",1.025*mult,100*mult); - crafteditem=true; - } - if (result.getResult().getType()==Material.GOLD_CHESTPLATE) { - int mult=1; - if ((result.getResult().getItemMeta().getDisplayName()!=null && !result.getResult().getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getResult().getItemMeta().getDisplayName()==null) { - mult=8; - } - //this.plugin.gainMoneyExp(p,"Blacksmith",1.15*mult,130*mult); - crafteditem=true; - } - if (result.getResult().getType()==Material.DIAMOND_HELMET) { - int mult=1; - if ((result.getResult().getItemMeta().getDisplayName()!=null && !result.getResult().getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getResult().getItemMeta().getDisplayName()==null) { - mult=8; - } - //this.plugin.gainMoneyExp(p,"Blacksmith",1.15*mult,125*mult); + craftwith[3].getType()==Material.DIAMOND_BLOCK && + craftwith[4].getType()==Material.AIR && + craftwith[5].getType()==Material.DIAMOND_BLOCK && + craftwith[6].getType()==Material.DIAMOND_BLOCK && + craftwith[7].getType()==Material.AIR && + craftwith[8].getType()==Material.DIAMOND_BLOCK) { + ItemStack newarmor = new ItemStack(Material.DIAMOND_LEGGINGS); + result.setResult(newarmor); + } else + if (craftwith[0].getType()==Material.DIAMOND_BLOCK && + craftwith[1].getType()==Material.AIR && + craftwith[2].getType()==Material.DIAMOND_BLOCK && + craftwith[3].getType()==Material.DIAMOND_BLOCK && + craftwith[4].getType()==Material.DIAMOND_BLOCK && + craftwith[5].getType()==Material.DIAMOND_BLOCK && + craftwith[6].getType()==Material.DIAMOND_BLOCK && + craftwith[7].getType()==Material.DIAMOND_BLOCK && + craftwith[8].getType()==Material.DIAMOND_BLOCK) { + ItemStack newarmor = new ItemStack(Material.DIAMOND_CHESTPLATE); + result.setResult(newarmor); + } else + if ((craftwith[0].getType()==Material.DIAMOND_BLOCK && + craftwith[1].getType()==Material.DIAMOND_BLOCK && + craftwith[2].getType()==Material.DIAMOND_BLOCK && + craftwith[3].getType()==Material.DIAMOND_BLOCK && + craftwith[4].getType()==Material.AIR && + craftwith[5].getType()==Material.DIAMOND_BLOCK && + craftwith[6].getType()==Material.AIR && + craftwith[7].getType()==Material.AIR && + craftwith[8].getType()==Material.AIR) || (craftwith[3].getType()==Material.DIAMOND_BLOCK && + craftwith[4].getType()==Material.DIAMOND_BLOCK && + craftwith[5].getType()==Material.DIAMOND_BLOCK && + craftwith[6].getType()==Material.DIAMOND_BLOCK && + craftwith[7].getType()==Material.AIR && + craftwith[8].getType()==Material.DIAMOND_BLOCK && + craftwith[0].getType()==Material.AIR && + craftwith[1].getType()==Material.AIR && + craftwith[2].getType()==Material.AIR)) { + ItemStack newarmor = new ItemStack(Material.DIAMOND_HELMET); + result.setResult(newarmor); + } else + if ((craftwith[0].getType()==Material.DIAMOND_BLOCK && + craftwith[1].getType()==Material.AIR && + craftwith[2].getType()==Material.DIAMOND_BLOCK && + craftwith[3].getType()==Material.DIAMOND_BLOCK && + craftwith[4].getType()==Material.AIR && + craftwith[5].getType()==Material.DIAMOND_BLOCK && + craftwith[6].getType()==Material.AIR && + craftwith[7].getType()==Material.AIR && + craftwith[8].getType()==Material.AIR) || (craftwith[3].getType()==Material.DIAMOND_BLOCK && + craftwith[4].getType()==Material.AIR && + craftwith[5].getType()==Material.DIAMOND_BLOCK && + craftwith[6].getType()==Material.DIAMOND_BLOCK && + craftwith[7].getType()==Material.AIR && + craftwith[8].getType()==Material.DIAMOND_BLOCK && + craftwith[0].getType()==Material.AIR && + craftwith[1].getType()==Material.AIR && + craftwith[2].getType()==Material.AIR)) { + ItemStack newarmor = new ItemStack(Material.DIAMOND_BOOTS); + result.setResult(newarmor); + } + */ + } + + @EventHandler + public void onItemCraft(CraftItemEvent e) { + //This is something we just crafted. + //Bukkit.getPlayer("sigonasr2").sendMessage("Resulting item is "+result.getResult().getAmount()+" "+result.getResult().getType()); + CraftingInventory result = e.getInventory(); + //Bukkit.getPlayer("sigonasr2").sendMessage("Resulting item is "+result.getResult().getAmount()+" "+result.getResult().getType()); + Player p = Bukkit.getPlayer(e.getWhoClicked().getName()); + if (this.plugin.PlayerinJob(p,"Weaponsmith")) { + boolean crafteditem=false; + if (result.getResult().getType()==Material.ARROW) { + crafteditem=true; + } + if (result.getResult().getType()==Material.WOOD_SWORD) { + crafteditem=true; + } + if (result.getResult().getType()==Material.FLINT_AND_STEEL) { + crafteditem=true; + } + if (result.getResult().getType()==Material.BOW) { + crafteditem=true; + } + if (result.getResult().getType()==Material.IRON_SWORD) { + crafteditem=true; + } + if (result.getResult().getType()==Material.GOLD_SWORD) { + crafteditem=true; + } + if (result.getResult().getType()==Material.DIAMOND_SWORD) { + crafteditem=true; + } + if (this.plugin.getJobLv("Weaponsmith", p)>=20 && crafteditem) { + ItemStack[] crafteditems = result.getMatrix(); + if (e.getClick()==ClickType.SHIFT_RIGHT || e.getClick()==ClickType.SHIFT_LEFT) { + int lowestamt=9999; + for (int i=0;i=5 && crafteditem) { + ItemStack[] crafteditems = result.getMatrix(); + if (e.getClick()==ClickType.SHIFT_RIGHT || e.getClick()==ClickType.SHIFT_LEFT) { + int lowestamt=9999; + for (int i=0;i=10 && crafteditem) { + //Bukkit.getPlayer("sigonasr2").sendMessage("Valid item. Going to attempt to enchant."); + if (e.getClick()!=ClickType.SHIFT_RIGHT && e.getClick()!=ClickType.SHIFT_LEFT) { + ItemStack resulting = EnchantItem(result.getResult(),5,p); + result.setResult(resulting); + } + } + } + if (this.plugin.PlayerinJob(p,"Blacksmith")) { + boolean crafteditem=false; + /* + if (result.getResult().getType()==Material.STONE_HOE) { + //this.plugin.gainMoneyExp(p,"Blacksmith",0.04,7); crafteditem=true; } - if (result.getResult().getType()==Material.DIAMOND_LEGGINGS) { - int mult=1; - if ((result.getResult().getItemMeta().getDisplayName()!=null && !result.getResult().getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getResult().getItemMeta().getDisplayName()==null) { - mult=8; - } - //this.plugin.gainMoneyExp(p,"Blacksmith",1.325*mult,145*mult); + if (result.getResult().getType()==Material.STONE_SPADE) { + //this.plugin.gainMoneyExp(p,"Blacksmith",0.05,8); crafteditem=true; } - if (result.getResult().getType()==Material.DIAMOND_CHESTPLATE) { - int mult=1; - if ((result.getResult().getItemMeta().getDisplayName()!=null && !result.getResult().getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getResult().getItemMeta().getDisplayName()==null) { - mult=8; - } - //this.plugin.gainMoneyExp(p,"Blacksmith",1.50*mult,175*mult); + if (result.getResult().getType()==Material.STONE_PICKAXE) { + //this.plugin.gainMoneyExp(p,"Blacksmith",0.075,15); crafteditem=true; - } - if (this.plugin.getJobLv("Blacksmith", p)>=5 && crafteditem) { - //Bukkit.getPlayer("sigonasr2").sendMessage("Valid item. Going to attempt to enchant."); - if (e.getClick()!=ClickType.SHIFT_RIGHT && e.getClick()!=ClickType.SHIFT_LEFT) { - ItemStack resulting = EnchantItem(result.getResult(),5,p); - result.setResult(resulting); - } - } - if (this.plugin.getJobLv("Blacksmith", p)>=10 && crafteditem) { - //Bukkit.getPlayer("sigonasr2").sendMessage("Valid item. Going to attempt to enchant."); - if (e.getClick()!=ClickType.SHIFT_RIGHT && e.getClick()!=ClickType.SHIFT_LEFT) { - ItemStack resulting = EnchantItem(result.getResult(),10,p); - result.setResult(resulting); - } - } - if (this.plugin.getJobLv("Blacksmith", p)>=20 && crafteditem) { - ItemStack[] crafteditems = result.getMatrix(); - if (e.getClick()==ClickType.SHIFT_RIGHT || e.getClick()==ClickType.SHIFT_LEFT) { - int lowestamt=9999; - for (int i=0;i=5 && crafteditem) { + //Bukkit.getPlayer("sigonasr2").sendMessage("Valid item. Going to attempt to enchant."); + if (e.getClick()!=ClickType.SHIFT_RIGHT && e.getClick()!=ClickType.SHIFT_LEFT) { + ItemStack resulting = EnchantItem(result.getResult(),5,p); + result.setResult(resulting); + } + } + if (this.plugin.getJobLv("Blacksmith", p)>=10 && crafteditem) { + //Bukkit.getPlayer("sigonasr2").sendMessage("Valid item. Going to attempt to enchant."); + if (e.getClick()!=ClickType.SHIFT_RIGHT && e.getClick()!=ClickType.SHIFT_LEFT) { + ItemStack resulting = EnchantItem(result.getResult(),10,p); + result.setResult(resulting); + } + } + if (this.plugin.getJobLv("Blacksmith", p)>=20 && crafteditem) { + ItemStack[] crafteditems = result.getMatrix(); + if (e.getClick()==ClickType.SHIFT_RIGHT || e.getClick()==ClickType.SHIFT_LEFT) { + int lowestamt=9999; + for (int i=0;i=20) { - //Increase sapling drops by 64%. - if (e.getBlock().getData()!=3) { - //This is not a jungle leaf block. - if (Math.random()*100<=25) { - //Produce a sapling. - Bukkit.getWorld("world").dropItem(e.getBlock().getLocation(), new ItemStack(Material.SAPLING,1,e.getBlock().getData())); - //list[i].sendMessage("You got an extra spawned sapling."); - } - } else { - if (Math.random()*100<=12.5) { - //Produce a sapling. - Bukkit.getWorld("world").dropItem(e.getBlock().getLocation(), new ItemStack(Material.SAPLING,1,e.getBlock().getData())); - } - } - } else - if (this.plugin.PlayerinJob(list[i], "Woodcutter") && this.plugin.getJobLv("Woodcutter", list[i])>=5) { - //Increase sapling drops by 40%. - if (e.getBlock().getData()!=3) { - //This is not a jungle leaf block. - if (Math.random()*100<=12) { - //Produce a sapling. - Bukkit.getWorld("world").dropItem(e.getBlock().getLocation(), new ItemStack(Material.SAPLING,1,e.getBlock().getData())); - //list[i].sendMessage("You got an extra spawned sapling."); - } - } else { - if (Math.random()*100<=6) { - //Produce a sapling. - Bukkit.getWorld("world").dropItem(e.getBlock().getLocation(), new ItemStack(Material.SAPLING,1,e.getBlock().getData())); - } - } - } - } - } - } - - @EventHandler - public void onItemChange(PlayerItemHeldEvent e) { - Player p = e.getPlayer(); - if (this.plugin.PlayerinJob(p, "Miner") && this.plugin.getJobLv("Miner", p)>=20) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_PICKAXE)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { - currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 2); - } else { - //if (currentitem.getEnchantmentLevel()) - } - } - } else - if (this.plugin.PlayerinJob(p, "Miner") && this.plugin.getJobLv("Miner", p)>=5) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_PICKAXE)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { - currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 1); - } + if (result.getResult().getType()==Material.MUSHROOM_SOUP) { + this.plugin.gainMoneyExp(p,"Support",0.015,2); } - } - if (this.plugin.PlayerinJob(p, "Digger") && this.plugin.getJobLv("Digger", p)>=5) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_SPADE)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { - currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 1); - } + if (result.getResult().getType()==Material.COOKIE) { + this.plugin.gainMoneyExp(p,"Support",0.015,2); } - } else - if (this.plugin.PlayerinJob(p, "Digger") && this.plugin.getJobLv("Digger", p)>=20) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_SPADE)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { - currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 2); - } + if (result.getResult().getType()==Material.GOLDEN_CARROT) { + this.plugin.gainMoneyExp(p,"Support",0.015,2); } - } - if (this.plugin.PlayerinJob(p, "Hunter") && this.plugin.getJobLv("Hunter", p)>=20) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_SWORD || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_SWORD || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_SWORD || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_SWORD || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_SWORD)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("FIRE_ASPECT"))) { - currentitem.addEnchantment(Enchantment.getByName("FIRE_ASPECT"), 2); - } + if (result.getResult().getType()==Material.GOLDEN_APPLE) { + this.plugin.gainMoneyExp(p,"Support",0.015,2); } - } - if (this.plugin.PlayerinJob(p, "Woodcutter") && this.plugin.getJobLv("Woodcutter", p)>=10) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_AXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_AXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_AXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_AXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_AXE)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { - currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 1); - } + if (result.getResult().getType()==Material.PUMPKIN_PIE) { + this.plugin.gainMoneyExp(p,"Support",0.015,2); } - } - } - -public ItemStack getGoodie() { - ItemStack item = null; - if (Math.random()<0.33) { - //Add a weapon/armor piece. - int rand = (int)(Math.random()*5); - String type = ""; - String type2 = ""; - int rarity=0; //0 = Normal, 1 = Rare, 2 = Legendary, 3 = Mythical - switch ((int)(Math.random()*20)) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 10: - case 11: - case 7: - case 8: - case 9: - case 12: - case 13: - case 18:{ - rarity=0; - }break; - case 5: - case 14: - case 15:{ - rarity=1; - }break; - case 6: - case 16: - case 17:{ - rarity=2; - }break; - case 19:{ - rarity=3; - }break; + if (result.getResult().getType()==Material.CAKE) { + this.plugin.gainMoneyExp(p,"Support",0.015,2); } - switch (rand) { - case 0: { - type = "LEATHER"; - }break; - case 1: { - type = "IRON"; - }break; - case 2: { - type = "GOLD"; - }break; - case 3: { - type = "CHAINMAIL"; - }break; - case 4: { - type = "DIAMOND"; - }break; + if (result.getResult().getType()==Material.IRON_SWORD) { + this.plugin.gainMoneyExp(p,"Support",0.015,3); } - if (rand!=0 && rand!=3) { - rand = (int)(Math.random()*9); - type2 = ""; - switch (rand) { - case 0: { - type2 = "HELMET"; - }break; - case 1: { - type2 = "CHESTPLATE"; - }break; - case 2: { - type2 = "LEGGINGS"; - }break; - case 3: { - type2 = "BOOTS"; - }break; - case 4: { - type2 = "SWORD"; - }break; - case 5: { - type2 = "PICKAXE"; - }break; - case 6: { - type2 = "SPADE"; - }break; - case 7: { - type2 = "HOE"; - }break; - case 8: { - type2 = "AXE"; - }break; - } - } else { - rand = (int)(Math.random()*5); - type2 = ""; - switch (rand) { - case 0: { - type2 = "HELMET"; - }break; - case 1: { - type2 = "CHESTPLATE"; - }break; - case 2: { - type2 = "LEGGINGS"; - }break; - case 3: { - type2 = "BOOTS"; - }break; - case 4: { - type2 = "BOW"; - }break; - } + if (result.getResult().getType()==Material.IRON_CHESTPLATE || result.getResult().getType()==Material.IRON_HELMET || result.getResult().getType()==Material.IRON_BOOTS || result.getResult().getType()==Material.IRON_LEGGINGS) { + this.plugin.gainMoneyExp(p,"Support",0.025,5); } - double chance_increase=0; - if (rarity>0) { - chance_increase=1.5d; + if (result.getResult().getType()==Material.DIAMOND_SWORD) { + this.plugin.gainMoneyExp(p,"Support",0.075,8); } - if (type2.equalsIgnoreCase("BOW")) { - item = new ItemStack(Material.BOW); - int enchants[] = {48,49,50,51}; - for (int j=0;j ourLore = new ArrayList(); - if (rarity==3) { - int choice1=0; - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+20+1)+"% "+ChatColor.BLUE+"Critical Chance"); - } else - if (Math.random()<=0.2) { - choice1=1; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+4+1)+" "+ChatColor.BLUE+"Armor Penetration"); - } else - if (Math.random()<=0.2) { - choice1=2; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+20+1)+"% "+ChatColor.BLUE+"Life Steal"); - } else - if (Math.random()<=0.2) { - choice1=3; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*180)+60+1)+"% "+ChatColor.BLUE+"Attack Speed"); - } else { - choice1=4; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+10+1)+" "+ChatColor.BLUE+"Damage"); - } - } else - if (rarity==2) { - int choice1=0; - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Critical Chance"); - } else - if (Math.random()<=0.2) { - choice1=1; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*12)+1)+" "+ChatColor.BLUE+"Armor Penetration"); - } else - if (Math.random()<=0.2) { - choice1=2; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Life Steal"); - } else - if (Math.random()<=0.2) { - choice1=3; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*120)+1)+"% "+ChatColor.BLUE+"Attack Speed"); - } else { - choice1=4; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+" "+ChatColor.BLUE+"Damage"); - } - } else - if (rarity==1) { - int choice1=0; - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Critical Chance"); - } else - if (Math.random()<=0.2) { - choice1=1; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*6)+1)+" "+ChatColor.BLUE+"Armor Penetration"); - } else - if (Math.random()<=0.2) { - choice1=2; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Life Steal"); - } else - if (Math.random()<=0.2) { - choice1=3; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+1)+"% "+ChatColor.BLUE+"Attack Speed"); - } else { - choice1=4; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+" "+ChatColor.BLUE+"Damage"); - } - if (Math.random()<=0.2 && choice1!=0) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Critical Chance"); - } else - if (Math.random()<=0.2 && choice1!=1) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*6)+1)+" "+ChatColor.BLUE+"Armor Penetration"); - } else - if (Math.random()<=0.2 && choice1!=2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Life Steal"); - } else - if (Math.random()<=0.2 && choice1!=3) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+1)+"% "+ChatColor.BLUE+"Attack Speed"); - } else { - if (choice1!=4) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+" "+ChatColor.BLUE+"Damage"); - } - } - } - else { - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Critical Chance"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*3)+1)+" "+ChatColor.BLUE+"Armor Penetration"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Life Steal"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+1)+"% "+ChatColor.BLUE+"Attack Speed"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*5)+1)+" "+ChatColor.BLUE+"Damage"); - } - } - ItemMeta meta = item.getItemMeta(); - meta.setLore(ourLore); - if (rarity==1) { - meta.setDisplayName(ChatColor.BLUE+"Rare "+convertToItemName(item.getType().name().replace("_", " "))); - } - if (rarity==2) { - meta.setDisplayName(ChatColor.YELLOW+""+ChatColor.BOLD+"Legendary "+convertToItemName(item.getType().name().replace("_", " "))); - } - if (rarity==3) { - meta.setDisplayName(ChatColor.LIGHT_PURPLE+""+"Mythical "+convertToItemName(item.getType().name().replace("_", " "))); - } - item.setItemMeta(meta); - } else { - item = new ItemStack(Material.getMaterial(type+"_"+type2)); - if (type2.equalsIgnoreCase("SWORD")) { - int enchants[] = {16,17,18,19,20,21,34}; - for (int j=0;j ourLore = new ArrayList(); - if (rarity==3) { - int choice1=0; - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+20+1)+"% "+ChatColor.BLUE+"Critical Chance"); - } else - if (Math.random()<=0.2) { - choice1=1; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+4+1)+" "+ChatColor.BLUE+"Armor Penetration"); - } else - if (Math.random()<=0.2) { - choice1=2; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+20+1)+"% "+ChatColor.BLUE+"Life Steal"); - } else - if (Math.random()<=0.2) { - choice1=3; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*180)+60+1)+"% "+ChatColor.BLUE+"Attack Speed"); - } else { - choice1=4; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+10+1)+" "+ChatColor.BLUE+"Damage"); - } - } else - if (rarity==2) { - int choice1=0; - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Critical Chance"); - } else - if (Math.random()<=0.2) { - choice1=1; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*12)+1)+" "+ChatColor.BLUE+"Armor Penetration"); - } else - if (Math.random()<=0.2) { - choice1=2; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Life Steal"); - } else - if (Math.random()<=0.2) { - choice1=3; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*120)+1)+"% "+ChatColor.BLUE+"Attack Speed"); - } else { - choice1=4; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+" "+ChatColor.BLUE+"Damage"); - } - } else - if (rarity==1) { - int choice1=0; - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Critical Chance"); - } else - if (Math.random()<=0.2) { - choice1=1; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*6)+1)+" "+ChatColor.BLUE+"Armor Penetration"); - } else - if (Math.random()<=0.2) { - choice1=2; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Life Steal"); - } else - if (Math.random()<=0.2) { - choice1=3; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+1)+"% "+ChatColor.BLUE+"Attack Speed"); - } else { - choice1=4; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+" "+ChatColor.BLUE+"Damage"); - } - if (Math.random()<=0.2 && choice1!=0) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Critical Chance"); - } else - if (Math.random()<=0.2 && choice1!=1) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*6)+1)+" "+ChatColor.BLUE+"Armor Penetration"); - } else - if (Math.random()<=0.2 && choice1!=2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Life Steal"); - } else - if (Math.random()<=0.2 && choice1!=3) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+1)+"% "+ChatColor.BLUE+"Attack Speed"); - } else { - if (choice1!=4) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+" "+ChatColor.BLUE+"Damage"); - } - } - } - else { - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Critical Chance"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*3)+1)+" "+ChatColor.BLUE+"Armor Penetration"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Life Steal"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+1)+"% "+ChatColor.BLUE+"Attack Speed"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*5)+1)+" "+ChatColor.BLUE+"Damage"); - } - } - ItemMeta meta = item.getItemMeta(); - meta.setLore(ourLore); - if (rarity==1) { - meta.setDisplayName(ChatColor.BLUE+"Rare "+convertToItemName(item.getType().name().replace("_", " "))); - } - if (rarity==2) { - meta.setDisplayName(ChatColor.YELLOW+""+ChatColor.BOLD+"Legendary "+convertToItemName(item.getType().name().replace("_", " "))); - } - if (rarity==3) { - meta.setDisplayName(ChatColor.LIGHT_PURPLE+""+"Mythical "+convertToItemName(item.getType().name().replace("_", " "))); - } - item.setItemMeta(meta); - } else if (type2.equalsIgnoreCase("SPADE") || type2.equalsIgnoreCase("PICKAXE") || type2.equalsIgnoreCase("HOE") || type2.equalsIgnoreCase("AXE")) { - int enchants[] = {32,33,34,35}; - for (int j=0;j ourLore = new ArrayList(); - if (rarity==3) { - int choice1=0; - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+20+1)+"% "+ChatColor.BLUE+"Critical Chance"); - } else - if (Math.random()<=0.2) { - choice1=1; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+4+1)+" "+ChatColor.BLUE+"Armor Penetration"); - } else - if (Math.random()<=0.2) { - choice1=2; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+20+1)+"% "+ChatColor.BLUE+"Life Steal"); - } else - if (Math.random()<=0.2) { - choice1=3; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*180)+60+1)+"% "+ChatColor.BLUE+"Attack Speed"); - } else { - choice1=4; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+10+1)+" "+ChatColor.BLUE+"Damage"); - } - } else - if (rarity==2) { - int choice1=0; - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Critical Chance"); - } else - if (Math.random()<=0.2) { - choice1=1; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*12)+1)+" "+ChatColor.BLUE+"Armor Penetration"); - } else - if (Math.random()<=0.2) { - choice1=2; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Life Steal"); - } else - if (Math.random()<=0.2) { - choice1=3; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*120)+1)+"% "+ChatColor.BLUE+"Attack Speed"); - } else { - choice1=4; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+" "+ChatColor.BLUE+"Damage"); - } - } else - if (rarity==1) { - int choice1=0; - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Critical Chance"); - } else - if (Math.random()<=0.2) { - choice1=1; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*6)+1)+" "+ChatColor.BLUE+"Armor Penetration"); - } else - if (Math.random()<=0.2) { - choice1=2; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Life Steal"); - } else - if (Math.random()<=0.2) { - choice1=3; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+1)+"% "+ChatColor.BLUE+"Attack Speed"); - } else { - choice1=4; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+" "+ChatColor.BLUE+"Damage"); - } - if (Math.random()<=0.2 && choice1!=0) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Critical Chance"); - } else - if (Math.random()<=0.2 && choice1!=1) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*6)+1)+" "+ChatColor.BLUE+"Armor Penetration"); - } else - if (Math.random()<=0.2 && choice1!=2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Life Steal"); - } else - if (Math.random()<=0.2 && choice1!=3) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+1)+"% "+ChatColor.BLUE+"Attack Speed"); - } else { - if (choice1!=4) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+" "+ChatColor.BLUE+"Damage"); - } - } - } - else { - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Critical Chance"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*3)+1)+" "+ChatColor.BLUE+"Armor Penetration"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Life Steal"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+1)+"% "+ChatColor.BLUE+"Attack Speed"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*5)+1)+" "+ChatColor.BLUE+"Damage"); - } - } - ItemMeta meta = item.getItemMeta(); - meta.setLore(ourLore); - if (rarity==1) { - meta.setDisplayName(ChatColor.BLUE+"Rare "+convertToItemName(item.getType().name().replace("_", " "))); - } - if (rarity==2) { - meta.setDisplayName(ChatColor.YELLOW+""+ChatColor.BOLD+"Legendary "+convertToItemName(item.getType().name().replace("_", " "))); - } - if (rarity==3) { - meta.setDisplayName(ChatColor.LIGHT_PURPLE+""+"Mythical "+convertToItemName(item.getType().name().replace("_", " "))); - } - item.setItemMeta(meta); - } else { - int enchants[] = {0,1,2,3,4,5,6,7,34}; - for (int j=0;j ourLore = new ArrayList(); - if (rarity==3) { - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*48)+16+1)+" "+ChatColor.BLUE+"Health"); - } else - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+20+1)+"% "+ChatColor.BLUE+"Damage Reduction"); - } else - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*400)+100+1)*10)+"% "+ChatColor.BLUE+"Durability"); - } else - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+10+1)+"% "+ChatColor.BLUE+"Block Chance"); - } else - { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*70)+20+1)+"% "+ChatColor.BLUE+"Speed Boost Chance"); - } - } else - if (rarity==2) { - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*16)+1)+" "+ChatColor.BLUE+"Health"); - } else - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Damage Reduction"); - } else - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*200)+1)*10)+"% "+ChatColor.BLUE+"Durability"); - } else - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Block Chance"); - } else - { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Speed Boost Chance"); - } - } else - if (rarity==1) { - int choice1=0; - if (Math.random()<=0.2) { - choice1=0; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*8)+1)+" "+ChatColor.BLUE+"Health"); - } else - if (Math.random()<=0.2) { - choice1=1; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Damage Reduction"); - } else - if (Math.random()<=0.2) { - choice1=2; - ourLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*100)+1)*10)+"% "+ChatColor.BLUE+"Durability"); - } else - if (Math.random()<=0.2) { - choice1=3; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Block Chance"); - } else - { - choice1=4; - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Speed Boost Chance"); - } - if (Math.random()<=0.2 && choice1!=0) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*8)+1)+" "+ChatColor.BLUE+"Health"); - } else - if (Math.random()<=0.2 && choice1!=1) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Damage Reduction"); - } else - if (Math.random()<=0.2 && choice1!=2) { - ourLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*100)+1)*10)+"% "+ChatColor.BLUE+"Durability"); - } else - if (Math.random()<=0.2 && choice1!=3) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Block Chance"); - } else - { - if (choice1!=4) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Speed Boost Chance"); - } - } - } else { - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*4)+1)+" "+ChatColor.BLUE+"Health"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Damage Reduction"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*50)+1)*10)+"% "+ChatColor.BLUE+"Durability"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Block Chance"); - } - if (Math.random()<=0.2) { - ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Speed Boost Chance"); - } - } - ItemMeta meta = item.getItemMeta(); - meta.setLore(ourLore); - if (rarity==1) { - meta.setDisplayName(ChatColor.BLUE+"Rare "+convertToItemName(item.getType().name().replace("_", " "))); - } - if (rarity==2) { - meta.setDisplayName(ChatColor.YELLOW+""+ChatColor.BOLD+"Legendary "+convertToItemName(item.getType().name().replace("_", " "))); - } - if (rarity==3) { - meta.setDisplayName(ChatColor.LIGHT_PURPLE+""+"Mythical "+convertToItemName(item.getType().name().replace("_", " "))); - } - item.setItemMeta(meta); - } + if (result.getResult().getType()==Material.DIAMOND_CHESTPLATE || result.getResult().getType()==Material.DIAMOND_HELMET || result.getResult().getType()==Material.DIAMOND_BOOTS || result.getResult().getType()==Material.DIAMOND_LEGGINGS) { + this.plugin.gainMoneyExp(p,"Support",0.20,20); } - } else { - //Add minerals. - int rand = (int)(Math.random()*18); - switch (rand) { - case 0 : - case 9: - case 10: - case 11:{ - item = new ItemStack(Material.IRON_INGOT,(int)(Math.random()*20)+10); - }break; - case 1 :{ - item = new ItemStack(Material.IRON_BLOCK,(int)(Math.random()*2)+1); - }break; - case 2 : - case 12: - case 13: - case 14:{ - item = new ItemStack(Material.GOLD_INGOT,(int)(Math.random()*10)+5); - }break; - case 3 :{ - item = new ItemStack(Material.GOLD_BLOCK,(int)(Math.random()*1)+1); - }break; - case 4 : - case 15: - case 16: - case 17: { - item = new ItemStack(Material.LAPIS_BLOCK,(int)(Math.random()*20)+10); - }break; - case 5 :{ - item = new ItemStack(Material.REDSTONE_BLOCK,(int)(Math.random()*12)+2); - }break; - case 6 :{ - item = new ItemStack(Material.DIAMOND,(int)(Math.random()*2)+1); - }break; - case 7 :{ - item = new ItemStack(Material.DIAMOND_BLOCK,(int)(Math.random()*1)+1); - }break; - case 8 :{ - item = new ItemStack(Material.EMERALD,(int)(Math.random()*2)+1); - }break; + if (result.getResult().getType()==Material.CAKE) { + this.plugin.gainMoneyExp(p,"Support",0.03,2); } } - return item; -} + */ + } + + /*@EventHandler + public void onFurnaceGet(FurnaceExtractEvent e) { + Player p = e.getPlayer(); + Bukkit.getPlayer("sigonasr2").sendMessage("Extacting "+e.getItemAmount()+" "+e.getItemType()); + }*/ + @EventHandler + public void onLeafDecay(LeavesDecayEvent e) { + Player[] list = Bukkit.getOnlinePlayers(); + for (int i=0;i=20) { + //Increase sapling drops by 64%. + if (e.getBlock().getData()!=3) { + //This is not a jungle leaf block. + if (Math.random()*100<=25) { + //Produce a sapling. + Bukkit.getWorld("world").dropItem(e.getBlock().getLocation(), new ItemStack(Material.SAPLING,1,e.getBlock().getData())); + //list[i].sendMessage("You got an extra spawned sapling."); + } + } else { + if (Math.random()*100<=12.5) { + //Produce a sapling. + Bukkit.getWorld("world").dropItem(e.getBlock().getLocation(), new ItemStack(Material.SAPLING,1,e.getBlock().getData())); + } + } + } else + if (this.plugin.PlayerinJob(list[i], "Woodcutter") && this.plugin.getJobLv("Woodcutter", list[i])>=5) { + //Increase sapling drops by 40%. + if (e.getBlock().getData()!=3) { + //This is not a jungle leaf block. + if (Math.random()*100<=12) { + //Produce a sapling. + Bukkit.getWorld("world").dropItem(e.getBlock().getLocation(), new ItemStack(Material.SAPLING,1,e.getBlock().getData())); + //list[i].sendMessage("You got an extra spawned sapling."); + } + } else { + if (Math.random()*100<=6) { + //Produce a sapling. + Bukkit.getWorld("world").dropItem(e.getBlock().getLocation(), new ItemStack(Material.SAPLING,1,e.getBlock().getData())); + } + } + } + } + } + } + + @EventHandler + public void onItemChange(PlayerItemHeldEvent e) { + Player p = e.getPlayer(); + if (this.plugin.PlayerinJob(p, "Miner") && this.plugin.getJobLv("Miner", p)>=20) { + if (p.getInventory().getContents()[e.getNewSlot()]!=null && + (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_PICKAXE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_PICKAXE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_PICKAXE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_PICKAXE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_PICKAXE)) { + ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; + if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { + currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 2); + } else { + //if (currentitem.getEnchantmentLevel()) + } + } + } else + if (this.plugin.PlayerinJob(p, "Miner") && this.plugin.getJobLv("Miner", p)>=5) { + if (p.getInventory().getContents()[e.getNewSlot()]!=null && + (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_PICKAXE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_PICKAXE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_PICKAXE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_PICKAXE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_PICKAXE)) { + ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; + if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { + currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 1); + } + } + } + if (this.plugin.PlayerinJob(p, "Digger") && this.plugin.getJobLv("Digger", p)>=5) { + if (p.getInventory().getContents()[e.getNewSlot()]!=null && + (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_SPADE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_SPADE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_SPADE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_SPADE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_SPADE)) { + ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; + if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { + currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 1); + } + } + } else + if (this.plugin.PlayerinJob(p, "Digger") && this.plugin.getJobLv("Digger", p)>=20) { + if (p.getInventory().getContents()[e.getNewSlot()]!=null && + (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_SPADE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_SPADE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_SPADE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_SPADE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_SPADE)) { + ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; + if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { + currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 2); + } + } + } + if (this.plugin.PlayerinJob(p, "Hunter") && this.plugin.getJobLv("Hunter", p)>=20) { + if (p.getInventory().getContents()[e.getNewSlot()]!=null && + (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_SWORD || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_SWORD || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_SWORD || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_SWORD || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_SWORD)) { + ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; + if (!currentitem.containsEnchantment(Enchantment.getByName("FIRE_ASPECT"))) { + currentitem.addEnchantment(Enchantment.getByName("FIRE_ASPECT"), 2); + } + } + } + if (this.plugin.PlayerinJob(p, "Woodcutter") && this.plugin.getJobLv("Woodcutter", p)>=10) { + if (p.getInventory().getContents()[e.getNewSlot()]!=null && + (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_AXE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_AXE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_AXE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_AXE || + p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_AXE)) { + ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; + if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { + currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 1); + } + } + } + } + + public ItemStack getGoodie() { + ItemStack item = null; + if (Math.random()<0.33) { + //Add a weapon/armor piece. + int rand = (int)(Math.random()*5); + String type = ""; + String type2 = ""; + int rarity=0; //0 = Normal, 1 = Rare, 2 = Legendary, 3 = Mythical + switch ((int)(Math.random()*20)) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 10: + case 11: + case 7: + case 8: + case 9: + case 12: + case 13: + case 18:{ + rarity=0; + }break; + case 5: + case 14: + case 15:{ + rarity=1; + }break; + case 6: + case 16: + case 17:{ + rarity=2; + }break; + case 19:{ + rarity=3; + }break; + } + switch (rand) { + case 0: { + type = "LEATHER"; + }break; + case 1: { + type = "IRON"; + }break; + case 2: { + type = "GOLD"; + }break; + case 3: { + type = "CHAINMAIL"; + }break; + case 4: { + type = "DIAMOND"; + }break; + } + if (rand!=0 && rand!=3) { + rand = (int)(Math.random()*9); + type2 = ""; + switch (rand) { + case 0: { + type2 = "HELMET"; + }break; + case 1: { + type2 = "CHESTPLATE"; + }break; + case 2: { + type2 = "LEGGINGS"; + }break; + case 3: { + type2 = "BOOTS"; + }break; + case 4: { + type2 = "SWORD"; + }break; + case 5: { + type2 = "PICKAXE"; + }break; + case 6: { + type2 = "SPADE"; + }break; + case 7: { + type2 = "HOE"; + }break; + case 8: { + type2 = "AXE"; + }break; + } + } else { + rand = (int)(Math.random()*5); + type2 = ""; + switch (rand) { + case 0: { + type2 = "HELMET"; + }break; + case 1: { + type2 = "CHESTPLATE"; + }break; + case 2: { + type2 = "LEGGINGS"; + }break; + case 3: { + type2 = "BOOTS"; + }break; + case 4: { + type2 = "BOW"; + }break; + } + } + double chance_increase=0; + if (rarity>0) { + chance_increase=1.5d; + } + if (type2.equalsIgnoreCase("BOW")) { + item = new ItemStack(Material.BOW); + int enchants[] = {48,49,50,51}; + for (int j=0;j ourLore = new ArrayList(); + if (rarity==3) { + int choice1=0; + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+20+1)+"% "+ChatColor.BLUE+"Critical Chance"); + } else + if (Math.random()<=0.2) { + choice1=1; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+4+1)+" "+ChatColor.BLUE+"Armor Penetration"); + } else + if (Math.random()<=0.2) { + choice1=2; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+20+1)+"% "+ChatColor.BLUE+"Life Steal"); + } else + if (Math.random()<=0.2) { + choice1=3; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*180)+60+1)+"% "+ChatColor.BLUE+"Attack Speed"); + } else { + choice1=4; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+10+1)+" "+ChatColor.BLUE+"Damage"); + } + } else + if (rarity==2) { + int choice1=0; + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Critical Chance"); + } else + if (Math.random()<=0.2) { + choice1=1; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*12)+1)+" "+ChatColor.BLUE+"Armor Penetration"); + } else + if (Math.random()<=0.2) { + choice1=2; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Life Steal"); + } else + if (Math.random()<=0.2) { + choice1=3; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*120)+1)+"% "+ChatColor.BLUE+"Attack Speed"); + } else { + choice1=4; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+" "+ChatColor.BLUE+"Damage"); + } + } else + if (rarity==1) { + int choice1=0; + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Critical Chance"); + } else + if (Math.random()<=0.2) { + choice1=1; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*6)+1)+" "+ChatColor.BLUE+"Armor Penetration"); + } else + if (Math.random()<=0.2) { + choice1=2; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Life Steal"); + } else + if (Math.random()<=0.2) { + choice1=3; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+1)+"% "+ChatColor.BLUE+"Attack Speed"); + } else { + choice1=4; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+" "+ChatColor.BLUE+"Damage"); + } + if (Math.random()<=0.2 && choice1!=0) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Critical Chance"); + } else + if (Math.random()<=0.2 && choice1!=1) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*6)+1)+" "+ChatColor.BLUE+"Armor Penetration"); + } else + if (Math.random()<=0.2 && choice1!=2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Life Steal"); + } else + if (Math.random()<=0.2 && choice1!=3) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+1)+"% "+ChatColor.BLUE+"Attack Speed"); + } else { + if (choice1!=4) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+" "+ChatColor.BLUE+"Damage"); + } + } + } + else { + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Critical Chance"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*3)+1)+" "+ChatColor.BLUE+"Armor Penetration"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Life Steal"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+1)+"% "+ChatColor.BLUE+"Attack Speed"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*5)+1)+" "+ChatColor.BLUE+"Damage"); + } + } + ItemMeta meta = item.getItemMeta(); + meta.setLore(ourLore); + if (rarity==1) { + meta.setDisplayName(ChatColor.BLUE+"Rare "+convertToItemName(item.getType().name().replace("_", " "))); + } + if (rarity==2) { + meta.setDisplayName(ChatColor.YELLOW+""+ChatColor.BOLD+"Legendary "+convertToItemName(item.getType().name().replace("_", " "))); + } + if (rarity==3) { + meta.setDisplayName(ChatColor.LIGHT_PURPLE+""+"Mythical "+convertToItemName(item.getType().name().replace("_", " "))); + } + item.setItemMeta(meta); + } else { + item = new ItemStack(Material.getMaterial(type+"_"+type2)); + if (type2.equalsIgnoreCase("SWORD")) { + int enchants[] = {16,17,18,19,20,21,34}; + for (int j=0;j ourLore = new ArrayList(); + if (rarity==3) { + int choice1=0; + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+20+1)+"% "+ChatColor.BLUE+"Critical Chance"); + } else + if (Math.random()<=0.2) { + choice1=1; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+4+1)+" "+ChatColor.BLUE+"Armor Penetration"); + } else + if (Math.random()<=0.2) { + choice1=2; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+20+1)+"% "+ChatColor.BLUE+"Life Steal"); + } else + if (Math.random()<=0.2) { + choice1=3; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*180)+60+1)+"% "+ChatColor.BLUE+"Attack Speed"); + } else { + choice1=4; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+10+1)+" "+ChatColor.BLUE+"Damage"); + } + } else + if (rarity==2) { + int choice1=0; + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Critical Chance"); + } else + if (Math.random()<=0.2) { + choice1=1; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*12)+1)+" "+ChatColor.BLUE+"Armor Penetration"); + } else + if (Math.random()<=0.2) { + choice1=2; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Life Steal"); + } else + if (Math.random()<=0.2) { + choice1=3; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*120)+1)+"% "+ChatColor.BLUE+"Attack Speed"); + } else { + choice1=4; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+" "+ChatColor.BLUE+"Damage"); + } + } else + if (rarity==1) { + int choice1=0; + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Critical Chance"); + } else + if (Math.random()<=0.2) { + choice1=1; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*6)+1)+" "+ChatColor.BLUE+"Armor Penetration"); + } else + if (Math.random()<=0.2) { + choice1=2; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Life Steal"); + } else + if (Math.random()<=0.2) { + choice1=3; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+1)+"% "+ChatColor.BLUE+"Attack Speed"); + } else { + choice1=4; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+" "+ChatColor.BLUE+"Damage"); + } + if (Math.random()<=0.2 && choice1!=0) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Critical Chance"); + } else + if (Math.random()<=0.2 && choice1!=1) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*6)+1)+" "+ChatColor.BLUE+"Armor Penetration"); + } else + if (Math.random()<=0.2 && choice1!=2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Life Steal"); + } else + if (Math.random()<=0.2 && choice1!=3) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+1)+"% "+ChatColor.BLUE+"Attack Speed"); + } else { + if (choice1!=4) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+" "+ChatColor.BLUE+"Damage"); + } + } + } + else { + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Critical Chance"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*3)+1)+" "+ChatColor.BLUE+"Armor Penetration"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Life Steal"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+1)+"% "+ChatColor.BLUE+"Attack Speed"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*5)+1)+" "+ChatColor.BLUE+"Damage"); + } + } + ItemMeta meta = item.getItemMeta(); + meta.setLore(ourLore); + if (rarity==1) { + meta.setDisplayName(ChatColor.BLUE+"Rare "+convertToItemName(item.getType().name().replace("_", " "))); + } + if (rarity==2) { + meta.setDisplayName(ChatColor.YELLOW+""+ChatColor.BOLD+"Legendary "+convertToItemName(item.getType().name().replace("_", " "))); + } + if (rarity==3) { + meta.setDisplayName(ChatColor.LIGHT_PURPLE+""+"Mythical "+convertToItemName(item.getType().name().replace("_", " "))); + } + item.setItemMeta(meta); + } else if (type2.equalsIgnoreCase("SPADE") || type2.equalsIgnoreCase("PICKAXE") || type2.equalsIgnoreCase("HOE") || type2.equalsIgnoreCase("AXE")) { + int enchants[] = {32,33,34,35}; + for (int j=0;j ourLore = new ArrayList(); + if (rarity==3) { + int choice1=0; + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+20+1)+"% "+ChatColor.BLUE+"Critical Chance"); + } else + if (Math.random()<=0.2) { + choice1=1; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+4+1)+" "+ChatColor.BLUE+"Armor Penetration"); + } else + if (Math.random()<=0.2) { + choice1=2; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+20+1)+"% "+ChatColor.BLUE+"Life Steal"); + } else + if (Math.random()<=0.2) { + choice1=3; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*180)+60+1)+"% "+ChatColor.BLUE+"Attack Speed"); + } else { + choice1=4; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+10+1)+" "+ChatColor.BLUE+"Damage"); + } + } else + if (rarity==2) { + int choice1=0; + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Critical Chance"); + } else + if (Math.random()<=0.2) { + choice1=1; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*12)+1)+" "+ChatColor.BLUE+"Armor Penetration"); + } else + if (Math.random()<=0.2) { + choice1=2; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Life Steal"); + } else + if (Math.random()<=0.2) { + choice1=3; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*120)+1)+"% "+ChatColor.BLUE+"Attack Speed"); + } else { + choice1=4; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+" "+ChatColor.BLUE+"Damage"); + } + } else + if (rarity==1) { + int choice1=0; + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Critical Chance"); + } else + if (Math.random()<=0.2) { + choice1=1; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*6)+1)+" "+ChatColor.BLUE+"Armor Penetration"); + } else + if (Math.random()<=0.2) { + choice1=2; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Life Steal"); + } else + if (Math.random()<=0.2) { + choice1=3; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+1)+"% "+ChatColor.BLUE+"Attack Speed"); + } else { + choice1=4; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+" "+ChatColor.BLUE+"Damage"); + } + if (Math.random()<=0.2 && choice1!=0) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Critical Chance"); + } else + if (Math.random()<=0.2 && choice1!=1) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*6)+1)+" "+ChatColor.BLUE+"Armor Penetration"); + } else + if (Math.random()<=0.2 && choice1!=2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Life Steal"); + } else + if (Math.random()<=0.2 && choice1!=3) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+1)+"% "+ChatColor.BLUE+"Attack Speed"); + } else { + if (choice1!=4) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+" "+ChatColor.BLUE+"Damage"); + } + } + } + else { + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Critical Chance"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*3)+1)+" "+ChatColor.BLUE+"Armor Penetration"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Life Steal"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+1)+"% "+ChatColor.BLUE+"Attack Speed"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*5)+1)+" "+ChatColor.BLUE+"Damage"); + } + } + ItemMeta meta = item.getItemMeta(); + meta.setLore(ourLore); + if (rarity==1) { + meta.setDisplayName(ChatColor.BLUE+"Rare "+convertToItemName(item.getType().name().replace("_", " "))); + } + if (rarity==2) { + meta.setDisplayName(ChatColor.YELLOW+""+ChatColor.BOLD+"Legendary "+convertToItemName(item.getType().name().replace("_", " "))); + } + if (rarity==3) { + meta.setDisplayName(ChatColor.LIGHT_PURPLE+""+"Mythical "+convertToItemName(item.getType().name().replace("_", " "))); + } + item.setItemMeta(meta); + } else { + int enchants[] = {0,1,2,3,4,5,6,7,34}; + for (int j=0;j ourLore = new ArrayList(); + if (rarity==3) { + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*48)+16+1)+" "+ChatColor.BLUE+"Health"); + } else + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+20+1)+"% "+ChatColor.BLUE+"Damage Reduction"); + } else + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*400)+100+1)*10)+"% "+ChatColor.BLUE+"Durability"); + } else + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*60)+10+1)+"% "+ChatColor.BLUE+"Block Chance"); + } else + { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*70)+20+1)+"% "+ChatColor.BLUE+"Speed Boost Chance"); + } + } else + if (rarity==2) { + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*16)+1)+" "+ChatColor.BLUE+"Health"); + } else + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Damage Reduction"); + } else + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*200)+1)*10)+"% "+ChatColor.BLUE+"Durability"); + } else + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Block Chance"); + } else + { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*40)+1)+"% "+ChatColor.BLUE+"Speed Boost Chance"); + } + } else + if (rarity==1) { + int choice1=0; + if (Math.random()<=0.2) { + choice1=0; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*8)+1)+" "+ChatColor.BLUE+"Health"); + } else + if (Math.random()<=0.2) { + choice1=1; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Damage Reduction"); + } else + if (Math.random()<=0.2) { + choice1=2; + ourLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*100)+1)*10)+"% "+ChatColor.BLUE+"Durability"); + } else + if (Math.random()<=0.2) { + choice1=3; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Block Chance"); + } else + { + choice1=4; + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Speed Boost Chance"); + } + if (Math.random()<=0.2 && choice1!=0) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*8)+1)+" "+ChatColor.BLUE+"Health"); + } else + if (Math.random()<=0.2 && choice1!=1) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Damage Reduction"); + } else + if (Math.random()<=0.2 && choice1!=2) { + ourLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*100)+1)*10)+"% "+ChatColor.BLUE+"Durability"); + } else + if (Math.random()<=0.2 && choice1!=3) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Block Chance"); + } else + { + if (choice1!=4) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Speed Boost Chance"); + } + } + } else { + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*4)+1)+" "+ChatColor.BLUE+"Health"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Damage Reduction"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*50)+1)*10)+"% "+ChatColor.BLUE+"Durability"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Block Chance"); + } + if (Math.random()<=0.2) { + ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Speed Boost Chance"); + } + } + ItemMeta meta = item.getItemMeta(); + meta.setLore(ourLore); + if (rarity==1) { + meta.setDisplayName(ChatColor.BLUE+"Rare "+convertToItemName(item.getType().name().replace("_", " "))); + } + if (rarity==2) { + meta.setDisplayName(ChatColor.YELLOW+""+ChatColor.BOLD+"Legendary "+convertToItemName(item.getType().name().replace("_", " "))); + } + if (rarity==3) { + meta.setDisplayName(ChatColor.LIGHT_PURPLE+""+"Mythical "+convertToItemName(item.getType().name().replace("_", " "))); + } + item.setItemMeta(meta); + } + } + } else { + //Add minerals. + int rand = (int)(Math.random()*18); + switch (rand) { + case 0 : + case 9: + case 10: + case 11:{ + item = new ItemStack(Material.IRON_INGOT,(int)(Math.random()*20)+10); + }break; + case 1 :{ + item = new ItemStack(Material.IRON_BLOCK,(int)(Math.random()*2)+1); + }break; + case 2 : + case 12: + case 13: + case 14:{ + item = new ItemStack(Material.GOLD_INGOT,(int)(Math.random()*10)+5); + }break; + case 3 :{ + item = new ItemStack(Material.GOLD_BLOCK,(int)(Math.random()*1)+1); + }break; + case 4 : + case 15: + case 16: + case 17: { + item = new ItemStack(Material.LAPIS_BLOCK,(int)(Math.random()*20)+10); + }break; + case 5 :{ + item = new ItemStack(Material.REDSTONE_BLOCK,(int)(Math.random()*12)+2); + }break; + case 6 :{ + item = new ItemStack(Material.DIAMOND,(int)(Math.random()*2)+1); + }break; + case 7 :{ + item = new ItemStack(Material.DIAMOND_BLOCK,(int)(Math.random()*1)+1); + }break; + case 8 :{ + item = new ItemStack(Material.EMERALD,(int)(Math.random()*2)+1); + }break; + } + } + return item; + } - @EventHandler - public void onEnemyKill(EntityDeathEvent e) { - if (e.getEntity().getType()==EntityType.SQUID || e.getEntity().getType()==EntityType.SLIME || e.getEntity().getType()==EntityType.ZOMBIE || e.getEntity().getType()==EntityType.SPIDER || e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.CREEPER - || e.getEntity().getType()==EntityType.PIG_ZOMBIE || e.getEntity().getType()==EntityType.GHAST || e.getEntity().getType()==EntityType.ENDERMAN || e.getEntity().getType()==EntityType.BLAZE - || e.getEntity().getType()==EntityType.ENDER_DRAGON || e.getEntity().getType()==EntityType.WITHER || e.getEntity().getType()==EntityType.CHICKEN || e.getEntity().getType()==EntityType.SHEEP - || e.getEntity().getType()==EntityType.PIG || e.getEntity().getType()==EntityType.COW || e.getEntity().getType()==EntityType.OCELOT || e.getEntity().getType()==EntityType.WOLF - || e.getEntity().getType()==EntityType.MUSHROOM_COW) { - LivingEntity f = e.getEntity(); - if (f.getType()==EntityType.ZOMBIE || - f.getType()==EntityType.SKELETON || - f.getType()==EntityType.PIG_ZOMBIE || - f.getType()==EntityType.SPIDER || - f.getType()==EntityType.CREEPER || - f.getType()==EntityType.ENDERMAN) { - //if (Math.random()<=0.005) { - /* + @EventHandler + public void onEnemyKill(EntityDeathEvent e) { + if (e.getEntity().getType()==EntityType.SQUID || e.getEntity().getType()==EntityType.SLIME || e.getEntity().getType()==EntityType.ZOMBIE || e.getEntity().getType()==EntityType.SPIDER || e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.CREEPER + || e.getEntity().getType()==EntityType.PIG_ZOMBIE || e.getEntity().getType()==EntityType.GHAST || e.getEntity().getType()==EntityType.ENDERMAN || e.getEntity().getType()==EntityType.BLAZE + || e.getEntity().getType()==EntityType.ENDER_DRAGON || e.getEntity().getType()==EntityType.WITHER || e.getEntity().getType()==EntityType.CHICKEN || e.getEntity().getType()==EntityType.SHEEP + || e.getEntity().getType()==EntityType.PIG || e.getEntity().getType()==EntityType.COW || e.getEntity().getType()==EntityType.OCELOT || e.getEntity().getType()==EntityType.WOLF + || e.getEntity().getType()==EntityType.MUSHROOM_COW) { + LivingEntity f = e.getEntity(); + if (f.getType()==EntityType.ZOMBIE || + f.getType()==EntityType.SKELETON || + f.getType()==EntityType.PIG_ZOMBIE || + f.getType()==EntityType.SPIDER || + f.getType()==EntityType.CREEPER || + f.getType()==EntityType.ENDERMAN) { + //if (Math.random()<=0.005) { + /* if (Math.random()<=0.005) { //0.5% chance of a mystical book dropping. if (f.getKiller()!=null) { @@ -5941,364 +5941,364 @@ public ItemStack getGoodie() { f.getKiller().sendMessage(ChatColor.LIGHT_PURPLE+"You feel a magical presence get inserted into your inventory."); } }*/ - } - if (f.getCustomName()!=null) { - if (f.getCustomName().contains("Strong")) { - e.setDroppedExp(e.getDroppedExp()*2); - } - if (f.getCustomName().contains("II")) { - e.setDroppedExp(e.getDroppedExp()*2); - } - if (f.getCustomName().contains("Venomous")) { - e.setDroppedExp(e.getDroppedExp()*2); - } - if (f.getCustomName().contains("Snaring")) { - e.setDroppedExp(e.getDroppedExp()*2); - } - if (f.getCustomName().contains("Charge")) { - e.setDroppedExp(e.getDroppedExp()*2); - } - if (f.getCustomName().contains("Explosive")) { - e.setDroppedExp(e.getDroppedExp()*2); - } - if (f.getCustomName().contains("Destructive")) { - e.setDroppedExp(e.getDroppedExp()*2); - } - if (f.getCustomName().contains("Sniper")) { - e.setDroppedExp(e.getDroppedExp()*2); - } - if (f.getCustomName().contains("Mega Wither")) { - e.setDroppedExp(e.getDroppedExp()*500); - for (int j=0;j<4;j++) { - Location dd = f.getLocation().add(Math.random()*4,Math.random()*4,Math.random()*4); - Bukkit.getWorld("world").getBlockAt(dd).setType(Material.CHEST); - Chest c=(Chest)Bukkit.getWorld("world").getBlockAt(dd).getState(); - for (int i=0;i<27;i++) { - ItemStack item = null; - if (Math.random()<=0.3) { - item = getGoodie(); - c.getBlockInventory().setItem(i, item); - } - } - } - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule mobGriefing false"); - } - if (f.getCustomName().contains(ChatColor.DARK_PURPLE+"")) { - e.setDroppedExp(e.getDroppedExp()*20); - f.setHealth(0); - this.plugin.BOSS_DEFEAT=100; - this.plugin.BOSS_DEFEAT_LOC=f.getLocation(); - //Create a chest at the death spot. - Bukkit.getWorld("world").getBlockAt(f.getLocation()).setType(Material.CHEST); - Chest c=(Chest)Bukkit.getWorld("world").getBlockAt(f.getLocation()).getState(); - for (int i=0;i<27;i++) { - ItemStack item = null; - if (Math.random()<=0.3) { - item = getGoodie(); - c.getBlockInventory().setItem(i, item); - } - } - } - } - if (this.plugin.getAccountsConfig().getBoolean("halloween-enabled")) { - e.setDroppedExp(e.getDroppedExp()*2); - } - if (f.getKiller()!=null && f.getKiller().getType()==EntityType.PLAYER) { - Player p = f.getKiller(); - for (int x=-10;x<10;x++) { - for (int y=-3;y<3;y++) { - for (int z=-10;z<10;z++) { - if (f.getWorld().getBlockAt(f.getLocation().add(x,y,z)).getType()==Material.MOB_SPAWNER) { - //This is near a spawner. Do not drop exp orbs or items. - List drops = e.getDrops(); - for (int i=0;i=5) { - e.setDroppedExp(e.getDroppedExp()*2); - } - p.giveExp(e.getDroppedExp()); - if (e.getDroppedExp()!=0) { - p.playSound(p.getLocation(), Sound.ORB_PICKUP, 0.9f, 1); - } - //p.sendMessage(f.getType()+" is mad at you."); - if (!this.plugin.PlayerinJob(p, "Support")) { - //Make sure a support did not kill it. - for (int i=0;i=10) { - List drops = e.getDrops(); - for (int i=0;i0) { - ItemStack reward = getGoodie(); - Bukkit.getWorld("world").dropItemNaturally(s.getLocation(), reward); - times--; - } - } - } - } - e.setDroppedExp(0); - /* - if (f.getType()==EntityType.PLAYER) { - Player p = (Player)f; - Bukkit.getPlayer("sigonasr2").sendMessage("EXP Lost: "+p.get); - if (this.plugin.PlayerinJob(p, "Explorer")) { - if (this.plugin.getJobLv("Explorer", p)>=10) { - //Don't lose levels. - - } - } - }*/ - } - } - - @EventHandler - public void onFoodLevelChange(FoodLevelChangeEvent e) { - //Check for nearby support. - if (e.getEntity().getType()==EntityType.PLAYER) { - final Player p = (Player)e.getEntity(); - Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { - @Override - public void run() { - p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); - } - },5); - if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9")>0) { - if (Math.random()<=this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9"))/100.0d) { - e.setFoodLevel(e.getFoodLevel()+1); - } - } - List nearby = p.getNearbyEntities(10, 10, 10); - for (int i=0;i=20) { - if (Math.random()<=0.50) { - e.setFoodLevel(e.getFoodLevel()+1); - } - } - } - } - } - - @EventHandler - public void onBucketEmpty(PlayerBucketEmptyEvent e) { - Player p = e.getPlayer(); - if (e.getBucket()==Material.WATER_BUCKET) { - if (this.plugin.PlayerinJob(p, "Support")) { - //Check if someone's with us. If not, we don't get awarded for supporting. - List nearby = p.getNearbyEntities(10, 20, 10); - boolean playernearby=false; - boolean onfire=false; - for (int i=0;i0 && ((Player)nearby.get(i)).getHealth()<=8) { - //They are on fire, you intend to douse them. - this.plugin.gainMoneyExp(p,"Support",4.80,240); - } - } - } - if (playernearby) { - //Check for lava below. If we find some, award some money and experience. - boolean foundlava=false; - for (int x=-10;x<10;x++) { - for (int y=-20;y<0;y++) { - for (int z=-10;z<10;z++) { - if (Bukkit.getWorld("world").getBlockAt(p.getLocation().getBlockX()+x,p.getLocation().getBlockY()+y,p.getLocation().getBlockZ()+z).getType()==Material.LAVA) { - foundlava=true; - break; - } - } - if (foundlava) { - break; - } - } - if (foundlava) { - break; - } - } - if (foundlava) { - this.plugin.gainMoneyExp(p,"Support",0.15,60); - } - } - } - } - } - - - @EventHandler - public void onLightningStrike(LightningStrikeEvent e) { - if (this.plugin.last_lightning_random_time=5) { - //Half chance to set the durability back by one. - if (p.getItemInHand().getType()==Material.FISHING_ROD) { - if (p.getItemInHand().getDurability()>0) { - if (Math.random()>=0.5) { - p.getItemInHand().setDurability((short)(p.getItemInHand().getDurability()-1)); - } - } - } - } - if (this.plugin.getJobLv("Fisherman", p)>=20) { - e.setExpToDrop(e.getExpToDrop()*2); - int i=4; - while (i>0) { - if (Math.random()<=0.25) { - this.plugin.gainMoneyExp(p,"Fisherman",0.175,3); - if (Math.random()<=0.50) { - p.getWorld().dropItemNaturally(p.getLocation(), new ItemStack(Material.COOKED_FISH)); - //p.getInventory().addItem(new ItemStack(Material.COOKED_FISH)); - this.plugin.gainMoneyExp(p,"Fisherman",0.125,2); - } else { - p.getWorld().dropItemNaturally(p.getLocation(), new ItemStack(Material.RAW_FISH)); - //p.getInventory().addItem(new ItemStack(Material.RAW_FISH)); - } - } - i--; - } - } else - if (this.plugin.getJobLv("Fisherman", p)>=10) { - e.setExpToDrop(e.getExpToDrop()*2); - if (Math.random()<=0.25) { - p.getWorld().dropItemNaturally(p.getLocation(), new ItemStack(Material.RAW_FISH)); - //p.getInventory().addItem(new ItemStack(Material.RAW_FISH)); - this.plugin.gainMoneyExp(p,"Fisherman",0.175,3); + } + if (f.getCustomName()!=null) { + if (f.getCustomName().contains("Strong")) { + e.setDroppedExp(e.getDroppedExp()*2); + } + if (f.getCustomName().contains("II")) { + e.setDroppedExp(e.getDroppedExp()*2); + } + if (f.getCustomName().contains("Venomous")) { + e.setDroppedExp(e.getDroppedExp()*2); + } + if (f.getCustomName().contains("Snaring")) { + e.setDroppedExp(e.getDroppedExp()*2); + } + if (f.getCustomName().contains("Charge")) { + e.setDroppedExp(e.getDroppedExp()*2); + } + if (f.getCustomName().contains("Explosive")) { + e.setDroppedExp(e.getDroppedExp()*2); + } + if (f.getCustomName().contains("Destructive")) { + e.setDroppedExp(e.getDroppedExp()*2); + } + if (f.getCustomName().contains("Sniper")) { + e.setDroppedExp(e.getDroppedExp()*2); + } + if (f.getCustomName().contains("Mega Wither")) { + e.setDroppedExp(e.getDroppedExp()*500); + for (int j=0;j<4;j++) { + Location dd = f.getLocation().add(Math.random()*4,Math.random()*4,Math.random()*4); + Bukkit.getWorld("world").getBlockAt(dd).setType(Material.CHEST); + Chest c=(Chest)Bukkit.getWorld("world").getBlockAt(dd).getState(); + for (int i=0;i<27;i++) { + ItemStack item = null; + if (Math.random()<=0.3) { + item = getGoodie(); + c.getBlockInventory().setItem(i, item); + } + } + } + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule mobGriefing false"); + } + if (f.getCustomName().contains(ChatColor.DARK_PURPLE+"")) { + e.setDroppedExp(e.getDroppedExp()*20); + f.setHealth(0); + this.plugin.BOSS_DEFEAT=100; + this.plugin.BOSS_DEFEAT_LOC=f.getLocation(); + //Create a chest at the death spot. + Bukkit.getWorld("world").getBlockAt(f.getLocation()).setType(Material.CHEST); + Chest c=(Chest)Bukkit.getWorld("world").getBlockAt(f.getLocation()).getState(); + for (int i=0;i<27;i++) { + ItemStack item = null; + if (Math.random()<=0.3) { + item = getGoodie(); + c.getBlockInventory().setItem(i, item); + } + } + } + } + if (this.plugin.getAccountsConfig().getBoolean("halloween-enabled")) { + e.setDroppedExp(e.getDroppedExp()*2); + } + if (f.getKiller()!=null && f.getKiller().getType()==EntityType.PLAYER) { + Player p = f.getKiller(); + for (int x=-10;x<10;x++) { + for (int y=-3;y<3;y++) { + for (int z=-10;z<10;z++) { + if (f.getWorld().getBlockAt(f.getLocation().add(x,y,z)).getType()==Material.MOB_SPAWNER) { + //This is near a spawner. Do not drop exp orbs or items. + List drops = e.getDrops(); + for (int i=0;i=5) { + e.setDroppedExp(e.getDroppedExp()*2); + } + p.giveExp(e.getDroppedExp()); + if (e.getDroppedExp()!=0) { + p.playSound(p.getLocation(), Sound.ORB_PICKUP, 0.9f, 1); + } + //p.sendMessage(f.getType()+" is mad at you."); + if (!this.plugin.PlayerinJob(p, "Support")) { + //Make sure a support did not kill it. + for (int i=0;i=10) { + List drops = e.getDrops(); + for (int i=0;i0) { + ItemStack reward = getGoodie(); + Bukkit.getWorld("world").dropItemNaturally(s.getLocation(), reward); + times--; + } + } + } + } + e.setDroppedExp(0); + /* + if (f.getType()==EntityType.PLAYER) { + Player p = (Player)f; + Bukkit.getPlayer("sigonasr2").sendMessage("EXP Lost: "+p.get); + if (this.plugin.PlayerinJob(p, "Explorer")) { + if (this.plugin.getJobLv("Explorer", p)>=10) { + //Don't lose levels. + } } - - } - } - } - - @EventHandler - public void onWorldLoad(WorldLoadEvent e) { - /*for (int i=0;i0) { + if (Math.random()<=this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9"))/100.0d) { + e.setFoodLevel(e.getFoodLevel()+1); + } + } + List nearby = p.getNearbyEntities(10, 10, 10); + for (int i=0;i=20) { + if (Math.random()<=0.50) { + e.setFoodLevel(e.getFoodLevel()+1); + } + } + } + } + } + + @EventHandler + public void onBucketEmpty(PlayerBucketEmptyEvent e) { + Player p = e.getPlayer(); + if (e.getBucket()==Material.WATER_BUCKET) { + if (this.plugin.PlayerinJob(p, "Support")) { + //Check if someone's with us. If not, we don't get awarded for supporting. + List nearby = p.getNearbyEntities(10, 20, 10); + boolean playernearby=false; + boolean onfire=false; + for (int i=0;i0 && ((Player)nearby.get(i)).getHealth()<=8) { + //They are on fire, you intend to douse them. + this.plugin.gainMoneyExp(p,"Support",4.80,240); + } + } + } + if (playernearby) { + //Check for lava below. If we find some, award some money and experience. + boolean foundlava=false; + for (int x=-10;x<10;x++) { + for (int y=-20;y<0;y++) { + for (int z=-10;z<10;z++) { + if (Bukkit.getWorld("world").getBlockAt(p.getLocation().getBlockX()+x,p.getLocation().getBlockY()+y,p.getLocation().getBlockZ()+z).getType()==Material.LAVA) { + foundlava=true; + break; + } + } + if (foundlava) { + break; + } + } + if (foundlava) { + break; + } + } + if (foundlava) { + this.plugin.gainMoneyExp(p,"Support",0.15,60); + } + } + } + } + } + + + @EventHandler + public void onLightningStrike(LightningStrikeEvent e) { + if (this.plugin.last_lightning_random_time=5) { + //Half chance to set the durability back by one. + if (p.getItemInHand().getType()==Material.FISHING_ROD) { + if (p.getItemInHand().getDurability()>0) { + if (Math.random()>=0.5) { + p.getItemInHand().setDurability((short)(p.getItemInHand().getDurability()-1)); + } + } + } + } + if (this.plugin.getJobLv("Fisherman", p)>=20) { + e.setExpToDrop(e.getExpToDrop()*2); + int i=4; + while (i>0) { + if (Math.random()<=0.25) { + this.plugin.gainMoneyExp(p,"Fisherman",0.175,3); + if (Math.random()<=0.50) { + p.getWorld().dropItemNaturally(p.getLocation(), new ItemStack(Material.COOKED_FISH)); + //p.getInventory().addItem(new ItemStack(Material.COOKED_FISH)); + this.plugin.gainMoneyExp(p,"Fisherman",0.125,2); + } else { + p.getWorld().dropItemNaturally(p.getLocation(), new ItemStack(Material.RAW_FISH)); + //p.getInventory().addItem(new ItemStack(Material.RAW_FISH)); + } + } + i--; + } + } else + if (this.plugin.getJobLv("Fisherman", p)>=10) { + e.setExpToDrop(e.getExpToDrop()*2); + if (Math.random()<=0.25) { + p.getWorld().dropItemNaturally(p.getLocation(), new ItemStack(Material.RAW_FISH)); + //p.getInventory().addItem(new ItemStack(Material.RAW_FISH)); + this.plugin.gainMoneyExp(p,"Fisherman",0.175,3); + } + } + + } + } + } + + @EventHandler + public void onWorldLoad(WorldLoadEvent e) { + /*for (int i=0;i <"+f.getLocation().getY()+"> <"+f.getLocation().getZ()+">"); - f.remove(); - arrows++; - } - } - this.plugin.cleaned=true; + int arrows=0; + for (int i=0;i <"+f.getLocation().getY()+"> <"+f.getLocation().getZ()+">"); + f.remove(); + arrows++; + } + } + this.plugin.cleaned=true; } if (this.plugin.chunk_queue_list!=null && e.getChunk()!=null && e.getChunk().isLoaded()) { - this.plugin.chunk_queue_list.add(e.getChunk()); - if (this.plugin.chunk_queue_list.size()>640) { - this.plugin.chunk_queue_list.remove(0); - } + this.plugin.chunk_queue_list.add(e.getChunk()); + if (this.plugin.chunk_queue_list.size()>640) { + this.plugin.chunk_queue_list.remove(0); + } } - } - - @EventHandler - public void onChunkLoad(ChunkPopulateEvent e) { - Chunk c = e.getChunk(); - if (e.getWorld().getName().equalsIgnoreCase("world")) { - int removeddiamonds=0,keptdiamonds=0,removediron=0,keptiron=0; - for (int x=0;x<16;x++) { - for (int y=5;y<100;y++) { - for (int z=0;z<16;z++) { - Block b = c.getBlock(x, y, z); - if (b.getType()==Material.DIAMOND_ORE) { - if (Math.random()<=0.4) { - removeddiamonds++; - ////Bukkit.getLogger().info("A diamond has been removed from this chunk."); - b.setType(Material.STONE); - } else { - keptdiamonds++; - } - } else - if (b.getType()==Material.IRON_ORE) { - if (Math.random()<=0.6) { - removediron++; - ////Bukkit.getLogger().info("A diamond has been removed from this chunk."); - b.setType(Material.STONE); - } else { - keptiron++; - } - } - } - } - } - //Bukkit.getLogger().info(keptdiamonds+"/"+(removeddiamonds+keptdiamonds)+" diamonds, "+keptiron+"/"+(removediron+keptiron)+" iron kept for this new chunk."); - } - - Player[] playerlist = Bukkit.getOnlinePlayers(); - //Whichever player is closest gets the credit. - Player closestplayer=null; - double closestdistance=99999999; - for (int i=0;i newlore = new ArrayList(); - newlore.add("Requires "+((int)(Math.random()*1000)+100)+" Pumpkin Pie in inventory"); - newlore.add("to convert to a legendary equipment item."); - meta.setLore(newlore); - meta.setDisplayName(ChatColor.GREEN+"Magical Pumpkin Pie"); - pump.setItemMeta(meta); - a.addItem(pump); - p.openInventory(a); - } - } - } - } - if (this.plugin.getConfig().getBoolean("halloween-enabled")) { - for (int m=0;m data = p.getInventory().getContents()[m].getItemMeta().getLore(); - //newlore.add("Requires "+((int)(Math.random()*1000)+100)+" Pumpkin Pie in inventory"); - ItemStack magic_pie = null; - for (int i=0;i=pies) { - p.getInventory().remove(magic_pie); - //Check to see if there are any pies we need to keep for later. - List items = new ArrayList(); - for (int i=0;i0) { - if (amountleft>=64) { - p.getInventory().addItem(new ItemStack(Material.PUMPKIN_PIE,64)); - amountleft-=64; - } else { - p.getInventory().addItem(new ItemStack(Material.PUMPKIN_PIE,1)); - amountleft--; - } - } - for (int i=0;i nearby = p.getNearbyEntities(10, 10, 10); - for (int i=0;i=20) { - //A support with the Lv20 buff is detected. If health is less than 8, take half damage. - if (p.getHealth()<=8) { - e.setDamage(e.getDamage()/2.0d); - } - } - } - if (this.plugin.PlayerinJob(p, "Explorer")) { - if (this.plugin.getJobLv("Explorer", p)>=10) { - //Check to see if our "fatal s urvivor" effect is available. - boolean survivor=false; - for (int i=0;i=0.5) { - p.sendMessage(ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+"Took "+df.format(player_starthp-p.getHealth())+" damage from "+ChatColor.WHITE+f.getCause().toString()+ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+" (-"+df2.format(((player_starthp-p.getHealth())/p.getMaxHealth())*100)+"%)"); - } - if (plugin.PlayerinJob(p, "Explorer")) { - if (plugin.getJobLv("Explorer", p)>=10) { - //Check to see if our "fatal s urvivor" effect is available. - boolean survivor=false; - for (int i=0;i='a'&&mod[i]<='z') { - mod[i]-=32; - first=true; - } else - if (i==0) { - if (mod[i]>='A'&&mod[i]<='Z') { - first=true; - } - } else { - if (mod[i]>='A'&&mod[i]<='Z'&&(mod[i-1]<'A'||mod[i-1]>'Z')) { - first=true; - } - } - } else { - if (mod[i-1]!=' ') { - if (mod[i]>='A'&&mod[i]<='Z') { - mod[i]+=32; - } - } - } - } - boolean same=false; - for (int i=0;i0) { - p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, (this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat6"))/3)*20, 0)); - } - } - } - - @EventHandler - public void onRegainHealth(EntityRegainHealthEvent e) { - if (e.getEntity().getType()==EntityType.PLAYER) { - final Player p = (Player)e.getEntity(); - p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); - boolean regen_high=false; - int duration=0; - if (e.getRegainReason()==RegainReason.MAGIC_REGEN) { - try { - Iterator effects = p.getActivePotionEffects().iterator(); + Player[] playerlist = Bukkit.getOnlinePlayers(); + //Whichever player is closest gets the credit. + Player closestplayer=null; + double closestdistance=99999999; + for (int i=0;i temp_meta_lore = new ArrayList(); + temp_meta_lore.add(ChatColor.ITALIC + + "Place the item to be repaired or enchanted here."); + temp_meta.setLore(temp_meta_lore); + temp.setItemMeta(temp_meta); + temp.setType(Material.IRON_AXE); + i.setItem(count += 2, temp); + + temp_meta.setDisplayName(ChatColor.YELLOW + "Item Tributes"); + temp_meta_lore = new ArrayList(); + temp_meta_lore.add(ChatColor.ITALIC + + "Place applicable item tributes here."); + temp_meta_lore.add(ChatColor.ITALIC + ""); + temp_meta_lore.add(ChatColor.ITALIC + "" + ChatColor.GRAY + + "Chainmail repairs with iron ingots."); + temp_meta.setLore(temp_meta_lore); + temp.setItemMeta(temp_meta); + temp.setType(Material.IRON_INGOT); + i.setItem(count += 2, temp); + + temp_meta.setDisplayName(ChatColor.YELLOW + "Magical Artifacts"); + temp_meta_lore = new ArrayList(); + temp_meta_lore.add(ChatColor.ITALIC + + "Place applicable magic artifacts here."); + temp_meta_lore.add(ChatColor.ITALIC + ""); + temp_meta_lore.add(ChatColor.ITALIC + "" + ChatColor.GRAY + + "Includes enchanted boots and repair shards."); + temp_meta.setLore(temp_meta_lore); + temp.setItemMeta(temp_meta); + temp.setType(Material.WRITTEN_BOOK); + i.setItem(count += 2, temp); + + temp_meta.setDisplayName(ChatColor.YELLOW + "Output"); + temp_meta_lore = new ArrayList(); + temp_meta_lore.add(ChatColor.ITALIC + + "Grab your finished item here!"); + temp_meta.setLore(temp_meta_lore); + temp.setItemMeta(temp_meta); + temp.setType(Material.CHEST); + i.setItem(count += 2, temp); + + temp_meta.setDisplayName(ChatColor.YELLOW + "Experience Cost"); + temp_meta_lore = new ArrayList(); + temp_meta_lore.add(ChatColor.ITALIC + + "Experience Cost of Enchanting."); + temp_meta.setLore(temp_meta_lore); + temp.setItemMeta(temp_meta); + temp.setType(Material.SLIME_BALL); + i.setItem(count += 15, temp); + + temp_meta.setDisplayName(ChatColor.RESET + "Anvil Interface"); + temp_meta_lore = new ArrayList(); + temp_meta_lore.add(ChatColor.GRAY + "Nothing to see here. Shoo!"); + temp_meta.setLore(temp_meta_lore); + temp.setItemMeta(temp_meta); + temp.setType(Material.COBBLESTONE); + for (int c = 0; c < 27; c++) { + if (i.getItem(c) == null) { + i.setItem(c, temp); + } + } + i.setItem(10, new ItemStack(Material.AIR)); + i.setItem(12, new ItemStack(Material.AIR)); + i.setItem(14, new ItemStack(Material.AIR)); + i.setItem(16, new ItemStack(Material.AIR)); + + e.setCancelled(true); + + e.getPlayer().closeInventory(); + e.getPlayer().openInventory(i); + + } + // 笆�笆�(Player)e.getPlayer()).sendMessage(((Player)e.getPlayer()).getScoreboard().getPlayerTeam((OfflinePlayer)e.getPlayer()).getName()); + Player p = (Player)e.getPlayer(); + p.getScoreboard().getTeam(p.getName()).setPrefix(ChatColor.DARK_GRAY+""); + if (p.hasPermission("group.moderator")) { + p.getScoreboard().getTeam(p.getName()).setPrefix(ChatColor.DARK_GREEN+""); + } + if (p.hasPermission("group.administrators")) { + p.getScoreboard().getTeam(p.getName()).setPrefix(ChatColor.DARK_PURPLE+""); + } + if (this.plugin.getConfig().getBoolean("halloween-enabled")) { + for (int m=0;m newlore = new ArrayList(); + newlore.add("Requires "+((int)(Math.random()*1000)+100)+" Pumpkin Pie in inventory"); + newlore.add("to convert to a legendary equipment item."); + meta.setLore(newlore); + meta.setDisplayName(ChatColor.GREEN+"Magical Pumpkin Pie"); + pump.setItemMeta(meta); + a.addItem(pump); + p.openInventory(a); + } + } + } + } + if (this.plugin.getConfig().getBoolean("halloween-enabled")) { + for (int m=0;m data = p.getInventory().getContents()[m].getItemMeta().getLore(); + //newlore.add("Requires "+((int)(Math.random()*1000)+100)+" Pumpkin Pie in inventory"); + ItemStack magic_pie = null; + for (int i=0;i=pies) { + p.getInventory().remove(magic_pie); + //Check to see if there are any pies we need to keep for later. + List items = new ArrayList(); + for (int i=0;i0) { + if (amountleft>=64) { + p.getInventory().addItem(new ItemStack(Material.PUMPKIN_PIE,64)); + amountleft-=64; + } else { + p.getInventory().addItem(new ItemStack(Material.PUMPKIN_PIE,1)); + amountleft--; + } + } + for (int i=0;i nearby = p.getNearbyEntities(10, 10, 10); + for (int i=0;i=20) { + //A support with the Lv20 buff is detected. If health is less than 8, take half damage. + if (p.getHealth()<=8) { + e.setDamage(e.getDamage()/2.0d); + } + } + } + if (this.plugin.PlayerinJob(p, "Explorer")) { + if (this.plugin.getJobLv("Explorer", p)>=10) { + //Check to see if our "fatal s urvivor" effect is available. + boolean survivor=false; + for (int i=0;i=0.5) { + p.sendMessage(ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+"Took "+df.format(player_starthp-p.getHealth())+" damage from "+ChatColor.WHITE+f.getCause().toString()+ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+" (-"+df2.format(((player_starthp-p.getHealth())/p.getMaxHealth())*100)+"%)"); + } + if (plugin.PlayerinJob(p, "Explorer")) { + if (plugin.getJobLv("Explorer", p)>=10) { + //Check to see if our "fatal s urvivor" effect is available. + boolean survivor=false; + for (int i=0;i='a'&&mod[i]<='z') { + mod[i]-=32; + first=true; + } else + if (i==0) { + if (mod[i]>='A'&&mod[i]<='Z') { + first=true; + } + } else { + if (mod[i]>='A'&&mod[i]<='Z'&&(mod[i-1]<'A'||mod[i-1]>'Z')) { + first=true; + } + } + } else { + if (mod[i-1]!=' ') { + if (mod[i]>='A'&&mod[i]<='Z') { + mod[i]+=32; + } + } + } + } + boolean same=false; + for (int i=0;i0) { + p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, (this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat6"))/3)*20, 0)); + } + } + } + + @EventHandler + public void onRegainHealth(EntityRegainHealthEvent e) { + if (e.getEntity().getType()==EntityType.PLAYER) { + final Player p = (Player)e.getEntity(); + p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); + boolean regen_high=false; + int duration=0; + if (e.getRegainReason()==RegainReason.MAGIC_REGEN) { + try { + Iterator effects = p.getActivePotionEffects().iterator(); //Figure out potion effects when player joins. while (effects.hasNext()) { PotionEffect nexteffect = effects.next(); @@ -6716,95 +6803,95 @@ public ItemStack getGoodie() { p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 360000, nexteffect.getAmplifier()+2, true)); }*/ } - } catch (ConcurrentModificationException ex_e) { - Bukkit.getLogger().warning("Potion Effect Collection not accessible while trying to regenerate player."); - } - final int mod_duration=duration; - if (regen_high) { - Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { - @Override - public void run() { - p.removePotionEffect(PotionEffectType.REGENERATION); - p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,mod_duration,2)); - } - }, 1L); - } - } - if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat1")>0) { - e.setAmount(e.getAmount()+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat1")/6)); + } catch (ConcurrentModificationException ex_e) { + Bukkit.getLogger().warning("Potion Effect Collection not accessible while trying to regenerate player."); + } + final int mod_duration=duration; + if (regen_high) { + Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { + @Override + public void run() { + p.removePotionEffect(PotionEffectType.REGENERATION); + p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,mod_duration,2)); + } + }, 1L); + } + } + if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat1")>0) { + e.setAmount(e.getAmount()+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat1")/6)); + } } - } - } - - @EventHandler - public void onEnemyHit(EntityDamageByEntityEvent e) { - if (e.getEntity() instanceof LivingEntity) { - final LivingEntity l = (LivingEntity)e.getEntity(); - if (l instanceof Player) { - e.setDamage(e.getDamage()*1.45d); - if (e.getDamager() instanceof Wither) { - e.setDamage(e.getDamage()*2d); - if (Math.random()<=0.75) { - l.getWorld().spawnEntity(l.getLocation(), EntityType.CREEPER); - l.getWorld().spawnEntity(l.getLocation(), EntityType.ZOMBIE); - } - } - } - if (e.getEntity() instanceof Wither) { - e.setDamage(e.getDamage()*0.075d); - } - if (e.getEntity().getType()==EntityType.ZOMBIE) { - Zombie z = (Zombie)e.getEntity(); - if (z.getCustomName()==null && z.getMaxHealth()>65) { - //If it's a normal zombie with too much HP, something wrong. Lower it. - z.setMaxHealth(65); - z.setHealth(z.getMaxHealth()); - } - } - if (e.getDamager() instanceof Projectile) { - Projectile pp = (Projectile)(e.getDamager()); - if (pp.getShooter() instanceof Player && l instanceof Wither) { - Player p = (Player)(pp.getShooter()); - if (Math.random()<=0.75) { - l.getWorld().spawnEntity(pp.getLocation(), EntityType.CREEPER); - l.getWorld().spawnEntity(l.getLocation(), EntityType.ZOMBIE); - } - } - } - if (l.getCustomName()!=null && l.getCustomName().contains(ChatColor.DARK_PURPLE+"")) { - //Bukkit.getPlayer("sigonasr2").sendMessage("Entered Boss Entity hit loop."); - Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { - @Override - public void run() { - //Multiplying by a number lower than 1 will reduce knockback - //Multiplying by a number greater than 1 will increase knockback - Vector knockback = l.getVelocity().multiply(0.1f); - l.setVelocity(knockback); - } - }, 1L); - if (l.getHealth()>=1) { - LivingEntity enderdragon = (LivingEntity)Bukkit.getWorld("world").spawnEntity(new Location(l.getWorld(),l.getLocation().getBlockX(),-250,l.getLocation().getBlockZ()),EntityType.ENDER_DRAGON); - enderdragon.setCustomName(ChatColor.DARK_PURPLE+"Charge Zombie III"); - enderdragon.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,127,999999)); - enderdragon.setMaxHealth(200); - enderdragon.setHealth(Warning(l.getHealth()/l.getMaxHealth()*200,7)); - enderdragon.setNoDamageTicks(999999); - enderdragon.setRemoveWhenFarAway(false); - } - Iterator e_list = Bukkit.getWorld("world").getEntitiesByClass(EnderDragon.class).iterator(); - boolean first=false; - while (e_list.hasNext()) { - //p.sendMessage("Moving Enderdragon to "+new Location(p.getWorld(),p.getLocation().getBlockX()+i,-50,p.getLocation().getBlockZ()+j)); - EnderDragon next = e_list.next(); - if (!first) { - first=true; - } else { - next.remove(); - } - } - boolean clear_torches=false; - try { - Iterator effects = l.getActivePotionEffects().iterator(); + } + + @EventHandler + public void onEnemyHit(EntityDamageByEntityEvent e) { + if (e.getEntity() instanceof LivingEntity) { + final LivingEntity l = (LivingEntity)e.getEntity(); + if (l instanceof Player) { + e.setDamage(e.getDamage()*1.45d); + if (e.getDamager() instanceof Wither) { + e.setDamage(e.getDamage()*2d); + if (Math.random()<=0.75) { + l.getWorld().spawnEntity(l.getLocation(), EntityType.CREEPER); + l.getWorld().spawnEntity(l.getLocation(), EntityType.ZOMBIE); + } + } + } + if (e.getEntity() instanceof Wither) { + e.setDamage(e.getDamage()*0.075d); + } + if (e.getEntity().getType()==EntityType.ZOMBIE) { + Zombie z = (Zombie)e.getEntity(); + if (z.getCustomName()==null && z.getMaxHealth()>65) { + //If it's a normal zombie with too much HP, something wrong. Lower it. + z.setMaxHealth(65); + z.setHealth(z.getMaxHealth()); + } + } + if (e.getDamager() instanceof Projectile) { + Projectile pp = (Projectile)(e.getDamager()); + if (pp.getShooter() instanceof Player && l instanceof Wither) { + Player p = (Player)(pp.getShooter()); + if (Math.random()<=0.75) { + l.getWorld().spawnEntity(pp.getLocation(), EntityType.CREEPER); + l.getWorld().spawnEntity(l.getLocation(), EntityType.ZOMBIE); + } + } + } + if (l.getCustomName()!=null && l.getCustomName().contains(ChatColor.DARK_PURPLE+"")) { + //Bukkit.getPlayer("sigonasr2").sendMessage("Entered Boss Entity hit loop."); + Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { + @Override + public void run() { + //Multiplying by a number lower than 1 will reduce knockback + //Multiplying by a number greater than 1 will increase knockback + Vector knockback = l.getVelocity().multiply(0.1f); + l.setVelocity(knockback); + } + }, 1L); + if (l.getHealth()>=1) { + LivingEntity enderdragon = (LivingEntity)Bukkit.getWorld("world").spawnEntity(new Location(l.getWorld(),l.getLocation().getBlockX(),-250,l.getLocation().getBlockZ()),EntityType.ENDER_DRAGON); + enderdragon.setCustomName(ChatColor.DARK_PURPLE+"Charge Zombie III"); + enderdragon.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,127,999999)); + enderdragon.setMaxHealth(200); + enderdragon.setHealth(Warning(l.getHealth()/l.getMaxHealth()*200,7)); + enderdragon.setNoDamageTicks(999999); + enderdragon.setRemoveWhenFarAway(false); + } + Iterator e_list = Bukkit.getWorld("world").getEntitiesByClass(EnderDragon.class).iterator(); + boolean first=false; + while (e_list.hasNext()) { + //p.sendMessage("Moving Enderdragon to "+new Location(p.getWorld(),p.getLocation().getBlockX()+i,-50,p.getLocation().getBlockZ()+j)); + EnderDragon next = e_list.next(); + if (!first) { + first=true; + } else { + next.remove(); + } + } + boolean clear_torches=false; + try { + Iterator effects = l.getActivePotionEffects().iterator(); //Figure out potion effects when player joins. while (effects.hasNext()) { PotionEffect nexteffect = effects.next(); @@ -6817,18 +6904,18 @@ public ItemStack getGoodie() { } int extramobs=0; List nearbylist = e.getEntity().getNearbyEntities(30, 30, 30); - //Filter out all unrelated entity types. - for (int k=0;k nearbylist = e.getEntity().getNearbyEntities(30, 30, 30); - //Filter out all unrelated entity types. - for (int k=0;k nearby = p.getNearbyEntities(10, 10, 10); + for (int i=0;i=20) { + //A support with the Lv20 buff is detected. If health is less than 8, take half damage. + if (p.getHealth()<=8) { + e.setDamage(e.getDamage()/2.0d); + } + } + } + if (e.getDamager() instanceof LivingEntity) { + final double player_starthp = p.getHealth(); + final LivingEntity l = (LivingEntity)e.getDamager(); + if (p.getNoDamageTicks()=10) { + //Check to see if our "fatal s urvivor" effect is available. + boolean survivor=false; + for (int i=0;iblocks = new ArrayList(); //Corresponds to helmet, chestplate, leggings, and boots. + //Found the slot. Check armor values. + double block_chance=0,speed_boost_chance=0; + if (p.getEquipment().getBoots()!=null) { + ItemStack item = p.getEquipment().getBoots(); + if (this.plugin.isBroken(item)) { + //Add it either to our inventory, or drop on the ground. + if (this.plugin.inventoryFull(p)) { + //Drop it on the ground. + p.sendMessage(ChatColor.LIGHT_PURPLE+"Dropped "+item.getItemMeta().getDisplayName()+ChatColor.LIGHT_PURPLE+" on the ground since there is no room in your inventory."); + p.getWorld().dropItemNaturally(p.getLocation(), item); + } else { + p.getInventory().addItem(item); + } + + //Remove it from the slot. + p.getEquipment().setBoots(new ItemStack(Material.AIR)); + } else + if (item.getItemMeta()!=null && item.getItemMeta().getLore()!=null && item.getItemMeta().getLore().size()!=0) { + for (int i=0;i100) { + extradurability=this.plugin.getEnchantmentNumb(item.getItemMeta().getLore().get(i)); + } + } } - if (Bukkit.getWorld("world").getBlockAt(l.getLocation().add(i,j,k)).getType()==Material.SAND && Math.random()<=0.1) { - Bukkit.getWorld("world").getBlockAt(l.getLocation().add(i,j,k)).breakNaturally(); + + //Bukkit.getLogger().info("Made it through 2.1.6."); + } + int heal = item.getDurability()-this.plugin.SPEED_CONTROL.get(slot).boots_durability; + //p.sendMessage("Heal is "+heal+" ("+item.getDurability()+"-"+this.plugin.SPEED_CONTROL.get(slot).boots_durability+")"); + if (Math.random()<=0.75 && heal>0) { + heal--; + item.setDurability((short)(item.getDurability()-1)); + //p.sendMessage("Healed! "+item.getDurability()); + } + if (heal!=0) { + while (extradurability>0) { + extradurability-=200; + if (Math.random()<=0.5 && heal>0) { + heal--; + item.setDurability((short)(item.getDurability()-1)); + //p.sendMessage("Healed! "+item.getDurability()); + } } } + //Bukkit.getLogger().info("Armor durability now "+item.getDurability()); + //Bukkit.getLogger().info("Made it through 2.1.7."); + this.plugin.SPEED_CONTROL.get(slot).boots_durability=item.getDurability(); + //p.sendMessage("New Durability: "+item.getDurability()); + //Bukkit.getLogger().info("Made it through 2.1.8."); } } - } - } - } - ////Bukkit.getLogger().info("Made it through 1."); - /*if (e.getDamager().getType()==EntityType.CREEPER) { - e.setDamage(e.getDamage()/2.0d); - }*/ - if (e.getEntity().getType()==EntityType.PLAYER) { - final Player p = (Player)e.getEntity(); - List nearby = p.getNearbyEntities(10, 10, 10); - for (int i=0;i=20) { - //A support with the Lv20 buff is detected. If health is less than 8, take half damage. - if (p.getHealth()<=8) { - e.setDamage(e.getDamage()/2.0d); - } - } - } - if (e.getDamager() instanceof LivingEntity) { - final double player_starthp = p.getHealth(); - final LivingEntity l = (LivingEntity)e.getDamager(); - if (p.getNoDamageTicks()=10) { - //Check to see if our "fatal s urvivor" effect is available. - boolean survivor=false; - for (int i=0;iblocks = new ArrayList(); //Corresponds to helmet, chestplate, leggings, and boots. - //Found the slot. Check armor values. - double block_chance=0,speed_boost_chance=0; - if (p.getEquipment().getBoots()!=null) { - ItemStack item = p.getEquipment().getBoots(); - if (this.plugin.isBroken(item)) { - //Add it either to our inventory, or drop on the ground. - if (this.plugin.inventoryFull(p)) { - //Drop it on the ground. - p.sendMessage(ChatColor.LIGHT_PURPLE+"Dropped "+item.getItemMeta().getDisplayName()+ChatColor.LIGHT_PURPLE+" on the ground since there is no room in your inventory."); - p.getWorld().dropItemNaturally(p.getLocation(), item); - } else { - p.getInventory().addItem(item); - } - - //Remove it from the slot. - p.getEquipment().setBoots(new ItemStack(Material.AIR)); - } else - if (item.getItemMeta()!=null && item.getItemMeta().getLore()!=null && item.getItemMeta().getLore().size()!=0) { - for (int i=0;i100) { - extradurability=this.plugin.getEnchantmentNumb(item.getItemMeta().getLore().get(i)); - } - } - } - - //Bukkit.getLogger().info("Made it through 2.1.6."); - } - int heal = item.getDurability()-this.plugin.SPEED_CONTROL.get(slot).boots_durability; - //p.sendMessage("Heal is "+heal+" ("+item.getDurability()+"-"+this.plugin.SPEED_CONTROL.get(slot).boots_durability+")"); - if (Math.random()<=0.75 && heal>0) { - heal--; - item.setDurability((short)(item.getDurability()-1)); - //p.sendMessage("Healed! "+item.getDurability()); - } - if (heal!=0) { - while (extradurability>0) { - extradurability-=200; - if (Math.random()<=0.5 && heal>0) { - heal--; - item.setDurability((short)(item.getDurability()-1)); - //p.sendMessage("Healed! "+item.getDurability()); - } - } - } - //Bukkit.getLogger().info("Armor durability now "+item.getDurability()); - //Bukkit.getLogger().info("Made it through 2.1.7."); - this.plugin.SPEED_CONTROL.get(slot).boots_durability=item.getDurability(); - //p.sendMessage("New Durability: "+item.getDurability()); - //Bukkit.getLogger().info("Made it through 2.1.8."); - } - } - } else { - this.plugin.SPEED_CONTROL.get(slot).boots_durability=-1; - //Bukkit.getLogger().info("Made it through 2.1.9."); - } - //Bukkit.getLogger().info("Made it through 2.1."); - if (p.getEquipment().getChestplate()!=null) { - ItemStack item = p.getEquipment().getChestplate(); - if (this.plugin.isBroken(item)) { - //Add it either to our inventory, or drop on the ground. - if (this.plugin.inventoryFull(p)) { - //Drop it on the ground. - p.sendMessage(ChatColor.LIGHT_PURPLE+"Dropped "+item.getItemMeta().getDisplayName()+ChatColor.LIGHT_PURPLE+" on the ground since there is no room in your inventory."); - p.getWorld().dropItemNaturally(p.getLocation(), item); - } else { - p.getInventory().addItem(item); - } - - //Remove it from the slot. - p.getEquipment().setChestplate(new ItemStack(Material.AIR)); - } else - if (item.getItemMeta()!=null && item.getItemMeta().getLore()!=null && item.getItemMeta().getLore().size()!=0) { - for (int i=0;i100) { - extradurability=this.plugin.getEnchantmentNumb(item.getItemMeta().getLore().get(i)); - } - } - } - } - boolean allow=false; - int heal = item.getDurability()-this.plugin.SPEED_CONTROL.get(slot).chestplate_durability; - if (Math.random()<=0.75 && heal>0) { - heal--; - item.setDurability((short)(item.getDurability()-1)); - } - if (heal!=0) { - while (extradurability>0) { - extradurability-=200; - if (Math.random()<=0.5 && heal>0) { - heal--; - item.setDurability((short)(item.getDurability()-1)); - } - } - } - this.plugin.SPEED_CONTROL.get(slot).chestplate_durability=item.getDurability(); - } - } - } else { - this.plugin.SPEED_CONTROL.get(slot).chestplate_durability=-1; - } - //Bukkit.getLogger().info("Made it through 2.2."); - if (p.getEquipment().getLeggings()!=null) { - ItemStack item = p.getEquipment().getLeggings(); - if (this.plugin.isBroken(item)) { - //Add it either to our inventory, or drop on the ground. - if (this.plugin.inventoryFull(p)) { - //Drop it on the ground. - p.sendMessage(ChatColor.LIGHT_PURPLE+"Dropped "+item.getItemMeta().getDisplayName()+ChatColor.LIGHT_PURPLE+" on the ground since there is no room in your inventory."); - p.getWorld().dropItemNaturally(p.getLocation(), item); - } else { - p.getInventory().addItem(item); - } - - //Remove it from the slot. - p.getEquipment().setLeggings(new ItemStack(Material.AIR)); - } else - if (item.getItemMeta()!=null && item.getItemMeta().getLore()!=null && item.getItemMeta().getLore().size()!=0) { - for (int i=0;i100) { - extradurability=this.plugin.getEnchantmentNumb(item.getItemMeta().getLore().get(i)); - } - } - } - } - int heal = item.getDurability()-this.plugin.SPEED_CONTROL.get(slot).leggings_durability; - if (Math.random()<=0.75 && heal>0) { - heal--; - item.setDurability((short)(item.getDurability()-1)); - } - if (heal!=0) { - while (extradurability>0) { - extradurability-=200; - if (Math.random()<=0.5 && heal>0) { - heal--; - item.setDurability((short)(item.getDurability()-1)); - } - } - } - this.plugin.SPEED_CONTROL.get(slot).leggings_durability=item.getDurability(); - } - } - } else { - this.plugin.SPEED_CONTROL.get(slot).leggings_durability=-1; - } - //Bukkit.getLogger().info("Made it through 2.3"); - if (p.getEquipment().getHelmet()!=null) { - ItemStack item = p.getEquipment().getHelmet(); - if (this.plugin.isBroken(item)) { - //Add it either to our inventory, or drop on the ground. - if (this.plugin.inventoryFull(p)) { - //Drop it on the ground. - p.sendMessage(ChatColor.LIGHT_PURPLE+"Dropped "+item.getItemMeta().getDisplayName()+ChatColor.LIGHT_PURPLE+" on the ground since there is no room in your inventory."); - p.getWorld().dropItemNaturally(p.getLocation(), item); - } else { - p.getInventory().addItem(item); - } - - //Remove it from the slot. - p.getEquipment().setHelmet(new ItemStack(Material.AIR)); - } else - if (item.getItemMeta()!=null && item.getItemMeta().getLore()!=null && item.getItemMeta().getLore().size()!=0) { - for (int i=0;i100) { - extradurability=this.plugin.getEnchantmentNumb(item.getItemMeta().getLore().get(i)); - } - } - } - } - int heal = item.getDurability()-this.plugin.SPEED_CONTROL.get(slot).helmet_durability; - if (Math.random()<=0.75 && heal>0) { - heal--; - item.setDurability((short)(item.getDurability()-1)); - } - if (heal!=0) { - while (extradurability>0) { - extradurability-=200; - if (Math.random()<=0.5 && heal>0) { - heal--; - item.setDurability((short)(item.getDurability()-1)); - } - } - } - this.plugin.SPEED_CONTROL.get(slot).helmet_durability=item.getDurability(); - } - } - } else { - this.plugin.SPEED_CONTROL.get(slot).helmet_durability=-1; - } - //Bukkit.getLogger().info("Made it through 3."); - //This is the player getting hit. + } else { + this.plugin.SPEED_CONTROL.get(slot).boots_durability=-1; + //Bukkit.getLogger().info("Made it through 2.1.9."); + } + //Bukkit.getLogger().info("Made it through 2.1."); + if (p.getEquipment().getChestplate()!=null) { + ItemStack item = p.getEquipment().getChestplate(); + if (this.plugin.isBroken(item)) { + //Add it either to our inventory, or drop on the ground. + if (this.plugin.inventoryFull(p)) { + //Drop it on the ground. + p.sendMessage(ChatColor.LIGHT_PURPLE+"Dropped "+item.getItemMeta().getDisplayName()+ChatColor.LIGHT_PURPLE+" on the ground since there is no room in your inventory."); + p.getWorld().dropItemNaturally(p.getLocation(), item); + } else { + p.getInventory().addItem(item); + } + + //Remove it from the slot. + p.getEquipment().setChestplate(new ItemStack(Material.AIR)); + } else + if (item.getItemMeta()!=null && item.getItemMeta().getLore()!=null && item.getItemMeta().getLore().size()!=0) { + for (int i=0;i100) { + extradurability=this.plugin.getEnchantmentNumb(item.getItemMeta().getLore().get(i)); + } + } + } + } + boolean allow=false; + int heal = item.getDurability()-this.plugin.SPEED_CONTROL.get(slot).chestplate_durability; + if (Math.random()<=0.75 && heal>0) { + heal--; + item.setDurability((short)(item.getDurability()-1)); + } + if (heal!=0) { + while (extradurability>0) { + extradurability-=200; + if (Math.random()<=0.5 && heal>0) { + heal--; + item.setDurability((short)(item.getDurability()-1)); + } + } + } + this.plugin.SPEED_CONTROL.get(slot).chestplate_durability=item.getDurability(); + } + } + } else { + this.plugin.SPEED_CONTROL.get(slot).chestplate_durability=-1; + } + //Bukkit.getLogger().info("Made it through 2.2."); + if (p.getEquipment().getLeggings()!=null) { + ItemStack item = p.getEquipment().getLeggings(); + if (this.plugin.isBroken(item)) { + //Add it either to our inventory, or drop on the ground. + if (this.plugin.inventoryFull(p)) { + //Drop it on the ground. + p.sendMessage(ChatColor.LIGHT_PURPLE+"Dropped "+item.getItemMeta().getDisplayName()+ChatColor.LIGHT_PURPLE+" on the ground since there is no room in your inventory."); + p.getWorld().dropItemNaturally(p.getLocation(), item); + } else { + p.getInventory().addItem(item); + } + + //Remove it from the slot. + p.getEquipment().setLeggings(new ItemStack(Material.AIR)); + } else + if (item.getItemMeta()!=null && item.getItemMeta().getLore()!=null && item.getItemMeta().getLore().size()!=0) { + for (int i=0;i100) { + extradurability=this.plugin.getEnchantmentNumb(item.getItemMeta().getLore().get(i)); + } + } + } + } + int heal = item.getDurability()-this.plugin.SPEED_CONTROL.get(slot).leggings_durability; + if (Math.random()<=0.75 && heal>0) { + heal--; + item.setDurability((short)(item.getDurability()-1)); + } + if (heal!=0) { + while (extradurability>0) { + extradurability-=200; + if (Math.random()<=0.5 && heal>0) { + heal--; + item.setDurability((short)(item.getDurability()-1)); + } + } + } + this.plugin.SPEED_CONTROL.get(slot).leggings_durability=item.getDurability(); + } + } + } else { + this.plugin.SPEED_CONTROL.get(slot).leggings_durability=-1; + } + //Bukkit.getLogger().info("Made it through 2.3"); + if (p.getEquipment().getHelmet()!=null) { + ItemStack item = p.getEquipment().getHelmet(); + if (this.plugin.isBroken(item)) { + //Add it either to our inventory, or drop on the ground. + if (this.plugin.inventoryFull(p)) { + //Drop it on the ground. + p.sendMessage(ChatColor.LIGHT_PURPLE+"Dropped "+item.getItemMeta().getDisplayName()+ChatColor.LIGHT_PURPLE+" on the ground since there is no room in your inventory."); + p.getWorld().dropItemNaturally(p.getLocation(), item); + } else { + p.getInventory().addItem(item); + } + + //Remove it from the slot. + p.getEquipment().setHelmet(new ItemStack(Material.AIR)); + } else + if (item.getItemMeta()!=null && item.getItemMeta().getLore()!=null && item.getItemMeta().getLore().size()!=0) { + for (int i=0;i100) { + extradurability=this.plugin.getEnchantmentNumb(item.getItemMeta().getLore().get(i)); + } + } + } + } + int heal = item.getDurability()-this.plugin.SPEED_CONTROL.get(slot).helmet_durability; + if (Math.random()<=0.75 && heal>0) { + heal--; + item.setDurability((short)(item.getDurability()-1)); + } + if (heal!=0) { + while (extradurability>0) { + extradurability-=200; + if (Math.random()<=0.5 && heal>0) { + heal--; + item.setDurability((short)(item.getDurability()-1)); + } + } + } + this.plugin.SPEED_CONTROL.get(slot).helmet_durability=item.getDurability(); + } + } + } else { + this.plugin.SPEED_CONTROL.get(slot).helmet_durability=-1; + } + //Bukkit.getLogger().info("Made it through 3."); + //This is the player getting hit. for (int i=0;i0) { + double olddmg=e.getDamage(); + e.setDamage(e.getDamage()*(((100-this.plugin.getStatBonus(2, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat3")/4))/100.0d))); + //p.sendMessage("Damage set from "+olddmg+" to "+e.getDamage()); + } + } + //Bukkit.getLogger().info("Made it through 5."); + if (e.getEntity().getType()==EntityType.PLAYER && e.getDamager().getType()==EntityType.SPIDER) { + LivingEntity enemy = (LivingEntity)e.getDamager(); + if (enemy.getCustomName()!=null && (enemy.getCustomName().compareTo(ChatColor.YELLOW+"Venomous Spider")==0)) { + LivingEntity p = (LivingEntity)e.getEntity(); + p.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 100, 1, false)); + } else + if (enemy.getCustomName()!=null && (enemy.getCustomName().compareTo(ChatColor.GOLD+"Venomous Spider II")==0)) { + LivingEntity p = (LivingEntity)e.getEntity(); + p.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 100, 2, false)); + } else + if (enemy.getCustomName()!=null && (enemy.getCustomName().compareTo(ChatColor.YELLOW+"Snaring Spider")==0)) { + LivingEntity p = (LivingEntity)e.getEntity(); + p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, 2, false)); + //Create web at the position of the player. + /* + for (int x=-1;x<2;x++) { + for (int y=-1;y<2;y++) { + for (int z=-1;z<2;z++) { + Block b = Bukkit.getWorld("world").getBlockAt(p.getLocation().add(x,y,z)); + if (b.getType()==Material.AIR) { + b.setType(Material.WEB); + this.plugin.TEMP_WEBS.add(new TempWeb(p.getLocation().add(x,y,z), 90)); + } + } + } + }*/ + } else + if (enemy.getCustomName()!=null && (enemy.getCustomName().compareTo(ChatColor.GOLD+"Snaring Spider II")==0)) { + LivingEntity p = (LivingEntity)e.getEntity(); + try { + Iterator effects = p.getActivePotionEffects().iterator(); + //Figure out potion effects when player joins. + while (effects.hasNext()) { + PotionEffect nexteffect = effects.next(); + if (nexteffect.getType().getName().compareTo(PotionEffectType.SLOW.getName())==0) { + p.removePotionEffect(PotionEffectType.SLOW); + p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 150, nexteffect.getAmplifier()+1, true)); + } + /*if (nexteffect.getType().getName().compareTo(PotionEffectType.JUMP.getName())==0) { + p.removePotionEffect(PotionEffectType.JUMP); + p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 360000, nexteffect.getAmplifier()+2, true)); + }*/ + effects.remove(); + } + + } catch (ConcurrentModificationException ex_e) { + Bukkit.getLogger().warning("Potion Effect Collection not accessible while trying to slow down player."); + } + p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 150, 1, true)); + //Create web at the position of the player. + /*for (int x=-2;x<3;x++) { + for (int y=-2;y<3;y++) { + for (int z=-2;z<3;z++) { + Block b = Bukkit.getWorld("world").getBlockAt(p.getLocation().add(x,y,z)); + if (b.getType()==Material.AIR) { + b.setType(Material.WEB); + this.plugin.TEMP_WEBS.add(new TempWeb(p.getLocation().add(x,y,z), 150)); + } + } + } + }*/ + } + } + //Bukkit.getLogger().info("Made it through 6."); + if (e.getEntity().getType()==EntityType.PLAYER && e.getDamager().getType()==EntityType.ZOMBIE) { + LivingEntity enemy = (LivingEntity)e.getDamager(); + Player p = (Player)e.getEntity(); + p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); + double throughdmg=0; + double maxdmg=0; + if (enemy.getCustomName()!=null && (enemy.getCustomName().compareTo(ChatColor.YELLOW+"Charge Zombie")==0 || enemy.getCustomName().compareTo(ChatColor.DARK_PURPLE+"Charge Zombie III")==0)) { + throughdmg=(this.plugin.DMGCALC.getDamage(new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), e.getDamage(), DamageCause.ENTITY_ATTACK, false))/2; + if (throughdmg>e.getDamage()/2) { + if (p.getHealth()-throughdmg>0) { + p.setHealth(p.getHealth()-throughdmg); + if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify5") && e.getDamage()!=0) { + //p.sendMessage(ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+"You were hurt for "+Math.round(throughdmg*10)/10+" damage from "+convertToItemName(e.getCause().name())+"."); + } + } else { + e.setDamage(0); + final Player p2 = p; + if (plugin.PlayerinJob(p, "Explorer")) { + if (plugin.getJobLv("Explorer", p)>=10) { + //Check to see if our "fatal s urvivor" effect is available. + boolean survivor=false; + for (int i=0;i0) { + p.setHealth(p.getHealth()-e.getDamage()/2); + if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify5") && e.getDamage()!=0) { + //p.sendMessage(ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+"You were hurt for "+Math.round(e.getDamage()/2*10)/10+" damage from "+convertToItemName(e.getCause().name())+"."); + } + } else { + e.setDamage(0); + final Player p2 = p; + if (plugin.PlayerinJob(p, "Explorer")) { + if (plugin.getJobLv("Explorer", p)>=10) { + //Check to see if our "fatal s urvivor" effect is available. + boolean survivor=false; + for (int i=0;ie.getDamage()) { + if (p.getHealth()-throughdmg>0) { + p.setHealth(p.getHealth()-throughdmg); + if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify5") && e.getDamage()!=0) { + //p.sendMessage(ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+"You were hurt for "+Math.round(throughdmg*10)/10+" damage from "+convertToItemName(e.getCause().name())+"."); + } + } else { + e.setDamage(0); + final Player p2 = p; + if (plugin.PlayerinJob(p, "Explorer")) { + if (plugin.getJobLv("Explorer", p)>=10) { + //Check to see if our "fatal s urvivor" effect is available. + boolean survivor=false; + for (int i=0;i0) { + p.setHealth(p.getHealth()-e.getDamage()); + if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify5") && e.getDamage()!=0) { + //p.sendMessage(ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+"You were hurt for "+Math.round(e.getDamage()*10)/10+" damage from "+convertToItemName(e.getCause().name())+"."); + } + } else { + e.setDamage(0); + final Player p2 = p; + if (plugin.PlayerinJob(p, "Explorer")) { + if (plugin.getJobLv("Explorer", p)>=10) { + //Check to see if our "fatal s urvivor" effect is available. + boolean survivor=false; + for (int i=0;i0) { + if (Math.random()<=critical_chance/100.0d) { + e.setDamage(e.getDamage()*2); + } + } + if (f.getNoDamageTicks()0) { + if (p.getHealth()+e.getDamage()*(life_steal/100.0d)0) { + f.setNoDamageTicks(f.getNoDamageTicks()-(int)(f.getNoDamageTicks()*(attack_speed/100.0d/4))); + } + if (dmg>0) { + e.setDamage(e.getDamage()+dmg); + } + if (this.plugin.PlayerinJob((Player)e.getDamager(), "Support")) { + for (int i=0;i=5) { + //Deal 2 extra damage. + e.setDamage(e.getDamage()+2); + } + if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7")>0) { + e.setDamage(e.getDamage()+(this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7"))/2)); + } + if (f.getNoDamageTicks()0) { + double normaldmg=(this.plugin.DMGCALC.getDamage(f.getEquipment().getHelmet(), f.getEquipment().getChestplate(), f.getEquipment().getLeggings(), f.getEquipment().getBoots(), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); + double throughdmg=(this.plugin.DMGCALC.getDamage(new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); + if (throughdmg>normaldmg+armor_pen) { + //This means some piercing can be done. + //e.setDamage(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)); + if (f.getHealth()-(normaldmg+armor_pen)>0) { + f.setHealth(f.getHealth()-(normaldmg+armor_pen)); + armor_pen_dmg=(normaldmg+armor_pen); + if (f!=null) { + if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { + if (f.getCustomName()!=null) { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(normaldmg+armor_pen)*10)/10+" damage to "+convertToItemName(f.getCustomName())+"."); + } else { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(normaldmg+armor_pen)*10)/10+" damage to "+convertToItemName(f.getType().getName())+"."); + } + } + } + } else { + f.setHealth(0); + } + } else { + //This means piercing would do extra damage. Just subtract throughdmg. + if (f.getHealth()-throughdmg>0) { + f.setHealth(Warning(f,14)); + if (f!=null) { + if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { + if (f.getCustomName()!=null) { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getCustomName())+"."); + } else { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getType().getName())+"."); + } + } + } + } else { + f.setHealth(0); + } + } + e.setDamage(0); + } + + if (f.getNoDamageTicks()0) { + //e.setDamage(e.getDamage()+(this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5"))/4)); + double normaldmg=(this.plugin.DMGCALC.getDamage(f.getEquipment().getHelmet(), f.getEquipment().getChestplate(), f.getEquipment().getLeggings(), f.getEquipment().getBoots(), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); + double throughdmg=(this.plugin.DMGCALC.getDamage(new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); + if (throughdmg>normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)) { + //This means some piercing can be done. + //e.setDamage(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)); + if (f.getHealth()-(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4))>0) { + f.setHealth(Warning(f.getHealth()-(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)),15)); + if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { + if (f.getCustomName()!=null) { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4))+" damage to "+convertToItemName(f.getCustomName())+"."); + } else { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4))+" damage to "+convertToItemName(f.getType().getName())+"."); + } + } + } else { + f.setHealth(0); + } + } else { + //This means piercing would do extra damage. Just subtract throughdmg. + if (f.getHealth()-throughdmg>0) { + f.setHealth(Warning(f.getHealth()-throughdmg,16)); + if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { + if (f.getCustomName()!=null) { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getCustomName())+"."); + } else { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getType().getName())+"."); + } + } + } else { + f.setHealth(0); + } + } + e.setDamage(0); } - - } catch (ConcurrentModificationException ex_e) { - Bukkit.getLogger().warning("Potion Effect Collection not accessible while finalizing player speed."); - } - p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,200,2)); - } - if (Math.random()<=block_chance/100.0d) { - e.setDamage(0); - //Choose a random set to mark off. - int armor = blocks.get((int)(Math.random()*blocks.size())); - switch (armor) { - case 0:{ - p.getInventory().getHelmet().setDurability((short)(p.getInventory().getHelmet().getDurability()+1)); - }break; - case 1:{ - p.getInventory().getChestplate().setDurability((short)(p.getInventory().getChestplate().getDurability()+1)); - }break; - case 2:{ - p.getInventory().getLeggings().setDurability((short)(p.getInventory().getLeggings().getDurability()+1)); - }break; - case 3:{ - p.getInventory().getBoots().setDurability((short)(p.getInventory().getBoots().getDurability()+1)); - }break; - } - e.setCancelled(true); - } - //Bukkit.getLogger().info("Made it through 4."); - p.updateInventory(); - if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat3")>0) { - double olddmg=e.getDamage(); - e.setDamage(e.getDamage()*(((100-this.plugin.getStatBonus(2, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat3")/4))/100.0d))); - //p.sendMessage("Damage set from "+olddmg+" to "+e.getDamage()); - } - } - //Bukkit.getLogger().info("Made it through 5."); - if (e.getEntity().getType()==EntityType.PLAYER && e.getDamager().getType()==EntityType.SPIDER) { - LivingEntity enemy = (LivingEntity)e.getDamager(); - if (enemy.getCustomName()!=null && (enemy.getCustomName().compareTo(ChatColor.YELLOW+"Venomous Spider")==0)) { - LivingEntity p = (LivingEntity)e.getEntity(); - p.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 100, 1, false)); - } else - if (enemy.getCustomName()!=null && (enemy.getCustomName().compareTo(ChatColor.GOLD+"Venomous Spider II")==0)) { - LivingEntity p = (LivingEntity)e.getEntity(); - p.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 100, 2, false)); - } else - if (enemy.getCustomName()!=null && (enemy.getCustomName().compareTo(ChatColor.YELLOW+"Snaring Spider")==0)) { - LivingEntity p = (LivingEntity)e.getEntity(); - p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, 2, false)); - //Create web at the position of the player. - /* - for (int x=-1;x<2;x++) { - for (int y=-1;y<2;y++) { - for (int z=-1;z<2;z++) { - Block b = Bukkit.getWorld("world").getBlockAt(p.getLocation().add(x,y,z)); - if (b.getType()==Material.AIR) { - b.setType(Material.WEB); - this.plugin.TEMP_WEBS.add(new TempWeb(p.getLocation().add(x,y,z), 90)); - } - } - } - }*/ - } else - if (enemy.getCustomName()!=null && (enemy.getCustomName().compareTo(ChatColor.GOLD+"Snaring Spider II")==0)) { - LivingEntity p = (LivingEntity)e.getEntity(); - try { - Iterator effects = p.getActivePotionEffects().iterator(); - //Figure out potion effects when player joins. - while (effects.hasNext()) { - PotionEffect nexteffect = effects.next(); - if (nexteffect.getType().getName().compareTo(PotionEffectType.SLOW.getName())==0) { - p.removePotionEffect(PotionEffectType.SLOW); - p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 150, nexteffect.getAmplifier()+1, true)); - } - /*if (nexteffect.getType().getName().compareTo(PotionEffectType.JUMP.getName())==0) { - p.removePotionEffect(PotionEffectType.JUMP); - p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 360000, nexteffect.getAmplifier()+2, true)); - }*/ - effects.remove(); + if (f.getNoDamageTicks()0) { + if (Math.random()<=critical_chance/100.0d) { + e.setDamage(e.getDamage()*2); + } + } + if (f.getNoDamageTicks()0) { + if (p.getHealth()+e.getDamage()*(life_steal/100.0d)0) { + f.setNoDamageTicks(f.getNoDamageTicks()-(int)(f.getNoDamageTicks()*(attack_speed/100.0d/4))); + } + if (dmg>0) { + e.setDamage(e.getDamage()+dmg); + } + if (e.getEntity() instanceof LivingEntity) { + LivingEntity enemy = (LivingEntity)e.getEntity(); + if (enemy.getCustomName()!=null && (enemy.getCustomName().compareTo(ChatColor.GRAY+"Zombie Ninja")==0)) { + boolean found=false; + for (int i=0;i=5) { + //Deal 2 extra damage. + e.setDamage(e.getDamage()+2); + } + if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7")>0) { + e.setDamage(e.getDamage()+(this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7"))/2)); + } + if (f.getNoDamageTicks()0) { + double normaldmg=(this.plugin.DMGCALC.getDamage(f.getEquipment().getHelmet(), f.getEquipment().getChestplate(), f.getEquipment().getLeggings(), f.getEquipment().getBoots(), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); + double throughdmg=(this.plugin.DMGCALC.getDamage(new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); - } catch (ConcurrentModificationException ex_e) { - Bukkit.getLogger().warning("Potion Effect Collection not accessible while trying to slow down player."); - } - p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 150, 1, true)); - //Create web at the position of the player. - /*for (int x=-2;x<3;x++) { - for (int y=-2;y<3;y++) { - for (int z=-2;z<3;z++) { - Block b = Bukkit.getWorld("world").getBlockAt(p.getLocation().add(x,y,z)); - if (b.getType()==Material.AIR) { - b.setType(Material.WEB); - this.plugin.TEMP_WEBS.add(new TempWeb(p.getLocation().add(x,y,z), 150)); - } - } - } - }*/ - } - } - //Bukkit.getLogger().info("Made it through 6."); - if (e.getEntity().getType()==EntityType.PLAYER && e.getDamager().getType()==EntityType.ZOMBIE) { - LivingEntity enemy = (LivingEntity)e.getDamager(); - Player p = (Player)e.getEntity(); - p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); - double throughdmg=0; - double maxdmg=0; - if (enemy.getCustomName()!=null && (enemy.getCustomName().compareTo(ChatColor.YELLOW+"Charge Zombie")==0 || enemy.getCustomName().compareTo(ChatColor.DARK_PURPLE+"Charge Zombie III")==0)) { - throughdmg=(this.plugin.DMGCALC.getDamage(new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), e.getDamage(), DamageCause.ENTITY_ATTACK, false))/2; - if (throughdmg>e.getDamage()/2) { - if (p.getHealth()-throughdmg>0) { - p.setHealth(p.getHealth()-throughdmg); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify5") && e.getDamage()!=0) { - //p.sendMessage(ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+"You were hurt for "+Math.round(throughdmg*10)/10+" damage from "+convertToItemName(e.getCause().name())+"."); - } - } else { - e.setDamage(0); - final Player p2 = p; - if (plugin.PlayerinJob(p, "Explorer")) { - if (plugin.getJobLv("Explorer", p)>=10) { - //Check to see if our "fatal s urvivor" effect is available. - boolean survivor=false; - for (int i=0;i0) { - p.setHealth(p.getHealth()-e.getDamage()/2); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify5") && e.getDamage()!=0) { - //p.sendMessage(ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+"You were hurt for "+Math.round(e.getDamage()/2*10)/10+" damage from "+convertToItemName(e.getCause().name())+"."); - } - } else { - e.setDamage(0); - final Player p2 = p; - if (plugin.PlayerinJob(p, "Explorer")) { - if (plugin.getJobLv("Explorer", p)>=10) { - //Check to see if our "fatal s urvivor" effect is available. - boolean survivor=false; - for (int i=0;ie.getDamage()) { - if (p.getHealth()-throughdmg>0) { - p.setHealth(p.getHealth()-throughdmg); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify5") && e.getDamage()!=0) { - //p.sendMessage(ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+"You were hurt for "+Math.round(throughdmg*10)/10+" damage from "+convertToItemName(e.getCause().name())+"."); - } - } else { - e.setDamage(0); - final Player p2 = p; - if (plugin.PlayerinJob(p, "Explorer")) { - if (plugin.getJobLv("Explorer", p)>=10) { - //Check to see if our "fatal s urvivor" effect is available. - boolean survivor=false; - for (int i=0;i0) { - p.setHealth(p.getHealth()-e.getDamage()); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify5") && e.getDamage()!=0) { - //p.sendMessage(ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+"You were hurt for "+Math.round(e.getDamage()*10)/10+" damage from "+convertToItemName(e.getCause().name())+"."); - } - } else { - e.setDamage(0); - final Player p2 = p; - if (plugin.PlayerinJob(p, "Explorer")) { - if (plugin.getJobLv("Explorer", p)>=10) { - //Check to see if our "fatal s urvivor" effect is available. - boolean survivor=false; - for (int i=0;i0) { - if (Math.random()<=critical_chance/100.0d) { - e.setDamage(e.getDamage()*2); - } - } - if (f.getNoDamageTicks()0) { - if (p.getHealth()+e.getDamage()*(life_steal/100.0d)0) { - f.setNoDamageTicks(f.getNoDamageTicks()-(int)(f.getNoDamageTicks()*(attack_speed/100.0d/4))); - } - if (dmg>0) { - e.setDamage(e.getDamage()+dmg); - } - if (this.plugin.PlayerinJob((Player)e.getDamager(), "Support")) { - for (int i=0;i=5) { - //Deal 2 extra damage. - e.setDamage(e.getDamage()+2); - } - if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7")>0) { - e.setDamage(e.getDamage()+(this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7"))/2)); - } - if (f.getNoDamageTicks()0) { - double normaldmg=(this.plugin.DMGCALC.getDamage(f.getEquipment().getHelmet(), f.getEquipment().getChestplate(), f.getEquipment().getLeggings(), f.getEquipment().getBoots(), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); - double throughdmg=(this.plugin.DMGCALC.getDamage(new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); - if (throughdmg>normaldmg+armor_pen) { - //This means some piercing can be done. - //e.setDamage(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)); - if (f.getHealth()-(normaldmg+armor_pen)>0) { - f.setHealth(f.getHealth()-(normaldmg+armor_pen)); - armor_pen_dmg=(normaldmg+armor_pen); - if (f!=null) { + + if (throughdmg>normaldmg+armor_pen) { + //This means some piercing can be done. + //e.setDamage(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)); + if (f.getHealth()-(normaldmg+armor_pen)>0) { + f.setHealth(f.getHealth()-(normaldmg+armor_pen)); + armor_pen_dmg=(normaldmg+armor_pen); + if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { + if (f.getCustomName()!=null) { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(normaldmg+armor_pen)*10)/10+" damage to "+convertToItemName(f.getCustomName())+"."); + } else { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(normaldmg+armor_pen)*10)/10+" damage to "+convertToItemName(f.getType().getName())+"."); + } + } + } else { + f.setHealth(0); + } + } else { + //This means piercing would do extra damage. Just subtract throughdmg. + if (f.getHealth()-throughdmg>0) { + f.setHealth(Warning(f.getHealth()-throughdmg,18)); + if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { + if (f.getCustomName()!=null) { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getCustomName())+"."); + } else { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getType().getName())+"."); + } + } + } else { + f.setHealth(0); + } + } + e.setDamage(0); + } + if (f.getNoDamageTicks()0) { + //e.setDamage(e.getDamage()+(this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5"))/4)); + double normaldmg=(this.plugin.DMGCALC.getDamage(f.getEquipment().getHelmet(), f.getEquipment().getChestplate(), f.getEquipment().getLeggings(), f.getEquipment().getBoots(), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); + double throughdmg=(this.plugin.DMGCALC.getDamage(new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); + if (throughdmg>normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)) { + //This means some piercing can be done. + //e.setDamage(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)); + if (f.getHealth()-(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4))>0) { + f.setHealth(Warning(f.getHealth()-(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)),19)); + if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { + if (f.getCustomName()!=null) { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4))+" damage to "+convertToItemName(f.getCustomName())+"."); + } else { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4))+" damage to "+convertToItemName(f.getType().getName())+"."); + } + } + } else { + f.setHealth(0); + } + } else { + //This means piercing would do extra damage. Just subtract throughdmg. + if (f.getHealth()-throughdmg>0) { + f.setHealth(Warning(f.getHealth()-throughdmg,20)); + if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { + if (f.getCustomName()!=null) { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getCustomName())+"."); + } else { + //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getType().getName())+"."); + } + } + } else { + f.setHealth(0); + } + } + e.setDamage(0); + } + if (f.getNoDamageTicks()0) { - f.setHealth(Warning(f,14)); - if (f!=null) { - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { - if (f.getCustomName()!=null) { - //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getCustomName())+"."); - } else { - //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getType().getName())+"."); + if (is_giant) { + if (p.getWorld().getBlockAt(e.getBlockPlaced().getLocation().add(0,-1,0)).getType()==Material.WOOL) { + e.getBlockPlaced().setType(Material.AIR); + p.getWorld().getBlockAt(e.getBlockPlaced().getLocation().add(0,-1,0)).setType(Material.GRASS); + //CREATE THE GIANT PUMPKIN + File file = new File("plugins/WorldEdit/schematics/Pumpkin.schematic"); + if (file.exists()) { + try { + //Pumpkin is 18x18. + com.sk89q.worldedit.Vector v = new com.sk89q.worldedit.Vector(e.getBlockPlaced().getLocation().getX(), e.getBlockPlaced().getLocation().getY(), e.getBlockPlaced().getLocation().getZ()); + World worldf = Bukkit.getWorld("world"); + BukkitWorld BWf = new BukkitWorld(worldf); + EditSession es = new EditSession(BWf, 2000000); + CuboidClipboard c1 = SchematicFormat.MCEDIT.load(file); + c1.place(es, v, true); + } catch (DataException ex) { + Bukkit.getLogger().warning("DataException while trying to create structure."); + } catch (IOException ex) { + Bukkit.getLogger().warning("IOException while trying to create structure."); + } catch (MaxChangedBlocksException ex) { + Bukkit.getLogger().warning("MaxChangedBlocksException while trying to create structure."); } + } else { + Bukkit.getLogger().warning(("File does not exist.")); } - } - } else { - f.setHealth(0); - } - } - e.setDamage(0); - } - - if (f.getNoDamageTicks()0) { - //e.setDamage(e.getDamage()+(this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5"))/4)); - double normaldmg=(this.plugin.DMGCALC.getDamage(f.getEquipment().getHelmet(), f.getEquipment().getChestplate(), f.getEquipment().getLeggings(), f.getEquipment().getBoots(), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); - double throughdmg=(this.plugin.DMGCALC.getDamage(new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); - if (throughdmg>normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)) { - //This means some piercing can be done. - //e.setDamage(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)); - if (f.getHealth()-(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4))>0) { - f.setHealth(Warning(f.getHealth()-(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)),15)); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { - if (f.getCustomName()!=null) { - //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4))+" damage to "+convertToItemName(f.getCustomName())+"."); - } else { - //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4))+" damage to "+convertToItemName(f.getType().getName())+"."); + for (int x=0;x<18;x++) { + for (int y=0;y<50;y++) { + for (int z=0;z<18;z++) { + Block b = p.getWorld().getBlockAt(e.getBlockPlaced().getLocation().add(x,y,z)); + if (b.getType()==Material.WOOL && b.getData()!=4) { + if (Math.random()<=0.01) { + b.setType(Material.DIAMOND_ORE); + } + if (Math.random()<=0.001) { + b.setType(Material.DIAMOND_BLOCK); + } + //REWARD! + if (Math.random()<=0.0005) { + Bukkit.getWorld("world").getBlockAt(b.getLocation()).setType(Material.CHEST); + Chest c=(Chest)Bukkit.getWorld("world").getBlockAt(b.getLocation()).getState(); + for (int i=0;i<27;i++) { + ItemStack item = null; + if (Math.random()<=0.3) { + item = getGoodie(); + c.getBlockInventory().setItem(i, item); + } + } + } + } + } } } + return; } else { - f.setHealth(0); + e.setCancelled(true); + return; } - } else { - //This means piercing would do extra damage. Just subtract throughdmg. - if (f.getHealth()-throughdmg>0) { - f.setHealth(Warning(f.getHealth()-throughdmg,16)); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { - if (f.getCustomName()!=null) { - //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getCustomName())+"."); - } else { - //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getType().getName())+"."); - } - } - } else { - f.setHealth(0); + } + } + } + } + int myData=this.plugin.getPlayerDataSlot(p); + if (e.getItemInHand().hasItemMeta() && e.getItemInHand().getItemMeta().getLore()!=null) { + //Check the Lore. + for (int i=0;i=20) { + if (Math.random()<=0.05) { + ItemStack replenishitem = e.getItemInHand().clone(); + replenishitem.setAmount(1); + p.getInventory().addItem(replenishitem); + p.updateInventory(); + } + } else + if (this.plugin.getJobLv("Builder", p)>=10) { + if (Math.random()<=0.01) { + ItemStack replenishitem = e.getItemInHand().clone(); + replenishitem.setAmount(1); + p.getInventory().addItem(replenishitem); + p.updateInventory(); } } - e.setDamage(0); + if (e.getBlockPlaced().getType()==Material.COBBLESTONE) { + this.plugin.gainMoneyExp(p,"Builder",0.005,1); + if (this.plugin.getJobLv("Builder", p)>=5 && (int)this.plugin.getcurrentJobExp("Builder", p)%5==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } } - if (f.getNoDamageTicks()=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); } } } - if (f.getNoDamageTicks()0) { - if (Math.random()<=critical_chance/100.0d) { - e.setDamage(e.getDamage()*2); - } - } - if (f.getNoDamageTicks()0) { - if (p.getHealth()+e.getDamage()*(life_steal/100.0d)0) { - f.setNoDamageTicks(f.getNoDamageTicks()-(int)(f.getNoDamageTicks()*(attack_speed/100.0d/4))); - } - if (dmg>0) { - e.setDamage(e.getDamage()+dmg); - } - if (e.getEntity() instanceof LivingEntity) { - LivingEntity enemy = (LivingEntity)e.getEntity(); - if (enemy.getCustomName()!=null && (enemy.getCustomName().compareTo(ChatColor.GRAY+"Zombie Ninja")==0)) { - boolean found=false; - for (int i=0;i=5) { - //Deal 2 extra damage. - e.setDamage(e.getDamage()+2); - } - if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7")>0) { - e.setDamage(e.getDamage()+(this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7"))/2)); + if (e.getBlockPlaced().getType()==Material.LOG) { + this.plugin.gainMoneyExp(p,"Builder",0.01,3); + for (int i=0;i<3;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } } - if (f.getNoDamageTicks()0) { - double normaldmg=(this.plugin.DMGCALC.getDamage(f.getEquipment().getHelmet(), f.getEquipment().getChestplate(), f.getEquipment().getLeggings(), f.getEquipment().getBoots(), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); - double throughdmg=(this.plugin.DMGCALC.getDamage(new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); - - - if (throughdmg>normaldmg+armor_pen) { - //This means some piercing can be done. - //e.setDamage(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)); - if (f.getHealth()-(normaldmg+armor_pen)>0) { - f.setHealth(f.getHealth()-(normaldmg+armor_pen)); - armor_pen_dmg=(normaldmg+armor_pen); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { - if (f.getCustomName()!=null) { - //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(normaldmg+armor_pen)*10)/10+" damage to "+convertToItemName(f.getCustomName())+"."); - } else { - //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(normaldmg+armor_pen)*10)/10+" damage to "+convertToItemName(f.getType().getName())+"."); - } + if (e.getBlockPlaced().getType()==Material.WOOD_STEP) { + this.plugin.gainMoneyExp(p,"Builder",0.015,3); + for (int i=0;i<2;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.COBBLESTONE_STAIRS) { + this.plugin.gainMoneyExp(p,"Builder",0.015,3); + for (int i=0;i<2;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.STONE) { + this.plugin.gainMoneyExp(p,"Builder",0.015,4); + for (int i=0;i<4;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.FENCE) { + this.plugin.gainMoneyExp(p,"Builder",0.015,3); + for (int i=0;i<3;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.STEP) { + switch (e.getBlockPlaced().getData()) { + case 0:{ + this.plugin.gainMoneyExp(p,"Builder",0.02,4); + for (int i=0;i<4;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); } - } else { - f.setHealth(0); } - } else { - //This means piercing would do extra damage. Just subtract throughdmg. - if (f.getHealth()-throughdmg>0) { - f.setHealth(Warning(f.getHealth()-throughdmg,18)); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { - if (f.getCustomName()!=null) { - //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getCustomName())+"."); - } else { - //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getType().getName())+"."); - } + }break; + case 1:{ + this.plugin.gainMoneyExp(p,"Builder",0.025,4); + for (int i=0;i<4;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); } - } else { - f.setHealth(0); } - } - e.setDamage(0); - } - if (f.getNoDamageTicks()0) { - //e.setDamage(e.getDamage()+(this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5"))/4)); - double normaldmg=(this.plugin.DMGCALC.getDamage(f.getEquipment().getHelmet(), f.getEquipment().getChestplate(), f.getEquipment().getLeggings(), f.getEquipment().getBoots(), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); - double throughdmg=(this.plugin.DMGCALC.getDamage(new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); - if (throughdmg>normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)) { - //This means some piercing can be done. - //e.setDamage(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)); - if (f.getHealth()-(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4))>0) { - f.setHealth(Warning(f.getHealth()-(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)),19)); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { - if (f.getCustomName()!=null) { - //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4))+" damage to "+convertToItemName(f.getCustomName())+"."); - } else { - //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4))+" damage to "+convertToItemName(f.getType().getName())+"."); - } - } - } else { - f.setHealth(0); + }break; + case 3:{ + this.plugin.gainMoneyExp(p,"Builder",0.015,3); + for (int i=0;i<3;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); } - } else { - //This means piercing would do extra damage. Just subtract throughdmg. - if (f.getHealth()-throughdmg>0) { - f.setHealth(Warning(f.getHealth()-throughdmg,20)); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { - if (f.getCustomName()!=null) { - //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getCustomName())+"."); - } else { - //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getType().getName())+"."); - } - } - } else { - f.setHealth(0); + } + }break; + case 4:{ + this.plugin.gainMoneyExp(p,"Builder",0.05,9); + for (int i=0;i<9;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + }break; + case 5:{ + this.plugin.gainMoneyExp(p,"Builder",0.03,5); + for (int i=0;i<5;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + }break; + case 6:{ + this.plugin.gainMoneyExp(p,"Builder",0.03,5); + for (int i=0;i<5;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + }break; + case 7:{ + this.plugin.gainMoneyExp(p,"Builder",0.06,12); + for (int i=0;i<12;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + }break; + case 8:{ + this.plugin.gainMoneyExp(p,"Builder",0.02,4); + for (int i=0;i<4;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + }break; + case 9:{ + this.plugin.gainMoneyExp(p,"Builder",0.025,4); + for (int i=0;i<4;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + }break; + case 10:{ + this.plugin.gainMoneyExp(p,"Builder",0.015,3); + for (int i=0;i<3;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + }break; + case 11:{ + this.plugin.gainMoneyExp(p,"Builder",0.015,3); + for (int i=0;i<3;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + }break; + case 12:{ + this.plugin.gainMoneyExp(p,"Builder",0.05,9); + for (int i=0;i<9;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + }break; + case 13:{ + this.plugin.gainMoneyExp(p,"Builder",0.03,5); + for (int i=0;i<5;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + }break; + case 14:{ + this.plugin.gainMoneyExp(p,"Builder",0.03,5); + for (int i=0;i<5;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + }break; + case 15:{ + this.plugin.gainMoneyExp(p,"Builder",0.06,12); + for (int i=0;i<12;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + }break; + } + } + if (e.getBlockPlaced().getType()==Material.WOOD_STAIRS) { + this.plugin.gainMoneyExp(p,"Builder",0.02,4); + for (int i=0;i<4;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.LAPIS_BLOCK) { + this.plugin.gainMoneyExp(p,"Builder",0.02,3); + for (int i=0;i<3;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.COBBLE_WALL) { + this.plugin.gainMoneyExp(p,"Builder",0.025,5); + for (int i=0;i<5;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.NETHER_BRICK_STAIRS) { + this.plugin.gainMoneyExp(p,"Builder",0.025,5); + for (int i=0;i<5;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.NETHER_BRICK) { + this.plugin.gainMoneyExp(p,"Builder",0.03,5); + for (int i=0;i<5;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.NETHER_FENCE) { + this.plugin.gainMoneyExp(p,"Builder",0.03,6); + for (int i=0;i<6;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.WOOL) { + this.plugin.gainMoneyExp(p,"Builder",0.035,7); + for (int i=0;i<7;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.getMaterial(109)) { + this.plugin.gainMoneyExp(p,"Builder",0.04,8); + for (int i=0;i<8;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.getMaterial(98)) { + this.plugin.gainMoneyExp(p,"Builder",0.04,8); + for (int i=0;i<8;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.GLASS) { + this.plugin.gainMoneyExp(p,"Builder",0.04,8); + for (int i=0;i<8;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.GLOWSTONE) { + this.plugin.gainMoneyExp(p,"Builder",0.05,10); + for (int i=0;i<10;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.HARD_CLAY) { + this.plugin.gainMoneyExp(p,"Builder",0.05,10); + for (int i=0;i<10;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.STAINED_CLAY) { + this.plugin.gainMoneyExp(p,"Builder",0.05,10); + for (int i=0;i<10;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.SANDSTONE_STAIRS) { + this.plugin.gainMoneyExp(p,"Builder",0.05,10); + for (int i=0;i<10;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.SANDSTONE) { + this.plugin.gainMoneyExp(p,"Builder",0.06,10); + for (int i=0;i<10;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.QUARTZ_STAIRS) { + this.plugin.gainMoneyExp(p,"Builder",0.06,12); + for (int i=0;i<12;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.IRON_FENCE) { + this.plugin.gainMoneyExp(p,"Builder",0.06,12); + for (int i=0;i<12;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.BRICK_STAIRS) { + this.plugin.gainMoneyExp(p,"Builder",0.065,9); + for (int i=0;i<9;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.QUARTZ_BLOCK) { + this.plugin.gainMoneyExp(p,"Builder",0.07,14); + for (int i=0;i<14;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + if (e.getBlockPlaced().getType()==Material.BRICK) { + this.plugin.gainMoneyExp(p,"Builder",0.075,11); + for (int i=0;i<11;i++) { + if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { + //Give a torch to the player. + p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); + } + } + } + } + } + if (this.plugin.PlayerinJob(p, "Miner")) { + this.plugin.playerdata_list.get(myData).BadInteract(e.getBlockPlaced().getType()); + } + if (this.plugin.PlayerinJob(p, "Digger")) { + this.plugin.playerdata_list.get(myData).BadInteract(e.getBlockPlaced().getType()); + } + if (this.plugin.PlayerinJob(p, "Farmer")) { + if (e.getBlockPlaced().getType()==Material.CROPS) { + this.plugin.gainMoneyExp(p,"Farmer",0.005,1); + } + //p.sendMessage("Placing down "+e.getBlockPlaced().getType()+" ("+e.getBlockPlaced().getTypeId()+"), "+e.getBlockPlaced().getData()); + if (e.getBlockPlaced().getType()==Material.PUMPKIN_STEM) { + this.plugin.gainMoneyExp(p,"Farmer",0.01,2); + } + if (e.getBlockPlaced().getType()==Material.MELON_STEM) { + this.plugin.gainMoneyExp(p,"Farmer",0.01,2); + } + } + if (this.plugin.PlayerinJob(p, "Support")) { + if (e.getBlockPlaced().getType()==Material.TORCH) { + //Make sure there are no other torches or Glowstone nearby. + boolean found=false; + for (int x=-5;x<5;x++) { + for (int y=-3;y<3;y++) { + for (int z=-5;z<5;z++) { + if (Bukkit.getWorld(p.getWorld().getName()).getBlockAt(p.getLocation().add(x,0,z)).getType()==Material.TORCH || Bukkit.getWorld(p.getWorld().getName()).getBlockAt(p.getLocation().add(x,0,z)).getType()==Material.GLOWSTONE) { + found=true; + break; + } + if (found) { + break; } } - e.setDamage(0); + if (found) { + break; + } } - if (f.getNoDamageTicks()=20) { - if (Math.random()<=0.05) { - ItemStack replenishitem = e.getItemInHand().clone(); - replenishitem.setAmount(1); - p.getInventory().addItem(replenishitem); - p.updateInventory(); - } - } else - if (this.plugin.getJobLv("Builder", p)>=10) { - if (Math.random()<=0.01) { - ItemStack replenishitem = e.getItemInHand().clone(); - replenishitem.setAmount(1); - p.getInventory().addItem(replenishitem); - p.updateInventory(); - } - } - if (e.getBlockPlaced().getType()==Material.COBBLESTONE) { - this.plugin.gainMoneyExp(p,"Builder",0.005,1); - if (this.plugin.getJobLv("Builder", p)>=5 && (int)this.plugin.getcurrentJobExp("Builder", p)%5==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - if (e.getBlockPlaced().getType()==Material.WOOD) { - this.plugin.gainMoneyExp(p,"Builder",0.005,2); - for (int i=0;i<2;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.LOG) { - this.plugin.gainMoneyExp(p,"Builder",0.01,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.WOOD_STEP) { - this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<2;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.COBBLESTONE_STAIRS) { - this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<2;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.STONE) { - this.plugin.gainMoneyExp(p,"Builder",0.015,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.FENCE) { - this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.STEP) { - switch (e.getBlockPlaced().getData()) { - case 0:{ - this.plugin.gainMoneyExp(p,"Builder",0.02,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 1:{ - this.plugin.gainMoneyExp(p,"Builder",0.025,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 3:{ - this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 4:{ - this.plugin.gainMoneyExp(p,"Builder",0.05,9); - for (int i=0;i<9;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 5:{ - this.plugin.gainMoneyExp(p,"Builder",0.03,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 6:{ - this.plugin.gainMoneyExp(p,"Builder",0.03,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 7:{ - this.plugin.gainMoneyExp(p,"Builder",0.06,12); - for (int i=0;i<12;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 8:{ - this.plugin.gainMoneyExp(p,"Builder",0.02,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 9:{ - this.plugin.gainMoneyExp(p,"Builder",0.025,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 10:{ - this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 11:{ - this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 12:{ - this.plugin.gainMoneyExp(p,"Builder",0.05,9); - for (int i=0;i<9;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 13:{ - this.plugin.gainMoneyExp(p,"Builder",0.03,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 14:{ - this.plugin.gainMoneyExp(p,"Builder",0.03,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 15:{ - this.plugin.gainMoneyExp(p,"Builder",0.06,12); - for (int i=0;i<12;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - } - } - if (e.getBlockPlaced().getType()==Material.WOOD_STAIRS) { - this.plugin.gainMoneyExp(p,"Builder",0.02,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.LAPIS_BLOCK) { - this.plugin.gainMoneyExp(p,"Builder",0.02,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.COBBLE_WALL) { - this.plugin.gainMoneyExp(p,"Builder",0.025,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.NETHER_BRICK_STAIRS) { - this.plugin.gainMoneyExp(p,"Builder",0.025,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.NETHER_BRICK) { - this.plugin.gainMoneyExp(p,"Builder",0.03,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.NETHER_FENCE) { - this.plugin.gainMoneyExp(p,"Builder",0.03,6); - for (int i=0;i<6;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.WOOL) { - this.plugin.gainMoneyExp(p,"Builder",0.035,7); - for (int i=0;i<7;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.getMaterial(109)) { - this.plugin.gainMoneyExp(p,"Builder",0.04,8); - for (int i=0;i<8;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.getMaterial(98)) { - this.plugin.gainMoneyExp(p,"Builder",0.04,8); - for (int i=0;i<8;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.GLASS) { - this.plugin.gainMoneyExp(p,"Builder",0.04,8); - for (int i=0;i<8;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.GLOWSTONE) { - this.plugin.gainMoneyExp(p,"Builder",0.05,10); - for (int i=0;i<10;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.HARD_CLAY) { - this.plugin.gainMoneyExp(p,"Builder",0.05,10); - for (int i=0;i<10;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.STAINED_CLAY) { - this.plugin.gainMoneyExp(p,"Builder",0.05,10); - for (int i=0;i<10;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.SANDSTONE_STAIRS) { - this.plugin.gainMoneyExp(p,"Builder",0.05,10); - for (int i=0;i<10;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.SANDSTONE) { - this.plugin.gainMoneyExp(p,"Builder",0.06,10); - for (int i=0;i<10;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.QUARTZ_STAIRS) { - this.plugin.gainMoneyExp(p,"Builder",0.06,12); - for (int i=0;i<12;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.IRON_FENCE) { - this.plugin.gainMoneyExp(p,"Builder",0.06,12); - for (int i=0;i<12;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.BRICK_STAIRS) { - this.plugin.gainMoneyExp(p,"Builder",0.065,9); - for (int i=0;i<9;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.QUARTZ_BLOCK) { - this.plugin.gainMoneyExp(p,"Builder",0.07,14); - for (int i=0;i<14;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.BRICK) { - this.plugin.gainMoneyExp(p,"Builder",0.075,11); - for (int i=0;i<11;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - } - } - if (this.plugin.PlayerinJob(p, "Miner")) { - this.plugin.playerdata_list.get(myData).BadInteract(e.getBlockPlaced().getType()); - } - if (this.plugin.PlayerinJob(p, "Digger")) { - this.plugin.playerdata_list.get(myData).BadInteract(e.getBlockPlaced().getType()); - } - if (this.plugin.PlayerinJob(p, "Farmer")) { - if (e.getBlockPlaced().getType()==Material.CROPS) { - this.plugin.gainMoneyExp(p,"Farmer",0.005,1); - } - //p.sendMessage("Placing down "+e.getBlockPlaced().getType()+" ("+e.getBlockPlaced().getTypeId()+"), "+e.getBlockPlaced().getData()); - if (e.getBlockPlaced().getType()==Material.PUMPKIN_STEM) { - this.plugin.gainMoneyExp(p,"Farmer",0.01,2); - } - if (e.getBlockPlaced().getType()==Material.MELON_STEM) { - this.plugin.gainMoneyExp(p,"Farmer",0.01,2); - } - } - if (this.plugin.PlayerinJob(p, "Support")) { - if (e.getBlockPlaced().getType()==Material.TORCH) { - //Make sure there are no other torches or Glowstone nearby. - boolean found=false; - for (int x=-5;x<5;x++) { - for (int y=-3;y<3;y++) { - for (int z=-5;z<5;z++) { - if (Bukkit.getWorld(p.getWorld().getName()).getBlockAt(p.getLocation().add(x,0,z)).getType()==Material.TORCH || Bukkit.getWorld(p.getWorld().getName()).getBlockAt(p.getLocation().add(x,0,z)).getType()==Material.GLOWSTONE) { - found=true; - break; - } - if (found) { - break; - } - } - if (found) { - break; - } - } - } - if (!found) { - this.plugin.gainMoneyExp(p,"Support",0.01,2); - } - } else - if (e.getBlockPlaced().getType()==Material.GLOWSTONE) { - //Make sure there are no other torches or Glowstone nearby. - boolean found=false; - for (int x=-5;x<5;x++) { - for (int y=-3;y<3;y++) { - for (int z=-5;z<5;z++) { - if (Bukkit.getWorld(p.getWorld().getName()).getBlockAt(p.getLocation().add(x,0,z)).getType()==Material.TORCH || Bukkit.getWorld(p.getWorld().getName()).getBlockAt(p.getLocation().add(x,0,z)).getType()==Material.GLOWSTONE) { - found=true; - break; - } - if (found) { - break; - } - } - if (found) { - break; - } - } - } - if (!found) { - this.plugin.gainMoneyExp(p,"Support",0.00,1); - } - } - } - if (this.plugin.getConfig().getBoolean("spleefinsession")==true && (this.plugin.getConfig().getString("spleefrequestaplayer").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestbplayer").compareTo(p.getName())==0)) { - e.setCancelled(true); - } - if (this.plugin.getConfig().getBoolean("spleef4insession")==true && (this.plugin.getConfig().getString("spleefrequesta4player").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestb4player").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestc4player").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestd4player").compareTo(p.getName())==0)) { - e.setCancelled(true); - } - if (e.getItemInHand().getType()==Material.getMaterial(127)) { - e.setCancelled(true); - } - if (this.plugin.is_ItemCube(e.getItemInHand())) { - e.setCancelled(true); - } - return; - } + @EventHandler + public void onItemBreak(PlayerItemBreakEvent e) { + final Player p = e.getPlayer(); + final ItemStack i = e.getBrokenItem(); + if (i.getItemMeta()!=null && i.getItemMeta().hasDisplayName() && i.getItemMeta().getDisplayName().compareTo("Spleef Wooden Shovel")==0) { + i.setDurability((short)0); + p.getInventory().addItem(i); + } + if (i.hasItemMeta() && i.getItemMeta().hasLore()) { + boolean is_halloween=false; + List finallore = new ArrayList(); + for (int j=0;j finallore = new ArrayList(); - for (int j=0;j enchants1 = new ArrayList(); - List enchants2 = new ArrayList(); - ItemStack finalitem = null; - if (type==0) { - finalitem=new ItemStack(Material.DIAMOND_HELMET); - enchants1.add("Protective"); - enchants1.add("Fire-Proof"); - enchants1.add("Blast Resistant"); - enchants1.add("Untouchable"); - enchants1.add("Breathing"); - enchants1.add("Working"); - enchants1.add("Unbreaking"); - enchants1.add("Thorny"); - enchants2.add("Life"); - enchants2.add("Resistance"); - enchants2.add("Durability"); - enchants2.add("Protection"); - } - if (type==1) { - finalitem=new ItemStack(Material.DIAMOND_CHESTPLATE); - enchants1.add("Protective"); - enchants1.add("Fire-Proof"); - enchants1.add("Blast Resistant"); - enchants1.add("Untouchable"); - enchants1.add("Unbreaking"); - enchants1.add("Thorny"); - enchants2.add("Life"); - enchants2.add("Resistance"); - enchants2.add("Durability"); - enchants2.add("Protection"); - } - if (type==2) { - finalitem=new ItemStack(Material.DIAMOND_LEGGINGS); - enchants1.add("Protective"); - enchants1.add("Fire-Proof"); - enchants1.add("Blast Resistant"); - enchants1.add("Untouchable"); - enchants1.add("Unbreaking"); - enchants1.add("Thorny"); - enchants2.add("Life"); - enchants2.add("Resistance"); - enchants2.add("Durability"); - enchants2.add("Protection"); - } - if (type==3) { - finalitem=new ItemStack(Material.DIAMOND_BOOTS); - enchants1.add("Protective"); - enchants1.add("Fire-Proof"); - enchants1.add("Blast Resistant"); - enchants1.add("Untouchable"); - enchants1.add("Lightweight"); - enchants1.add("Unbreaking"); - enchants1.add("Thorny"); - enchants2.add("Life"); - enchants2.add("Resistance"); - enchants2.add("Durability"); - enchants2.add("Protection"); - } - if (type==4) { - finalitem=new ItemStack(Material.BOW); - enchants1.add("Power"); - enchants1.add("Punch"); - enchants1.add("Flaming"); - enchants1.add("Infinite"); - enchants1.add("Unbreaking"); - enchants2.add("Smiting"); - enchants2.add("Penetration"); - enchants2.add("Draining"); - enchants2.add("Fury"); - enchants2.add("Power"); - } - if (type==5) { - finalitem=new ItemStack(Material.DIAMOND_SWORD); - enchants1.add("Damaging"); - enchants1.add("Knockback"); - enchants1.add("Undead"); - enchants1.add("Baning"); - enchants1.add("Fiery"); - enchants1.add("Greedy"); - enchants1.add("Unbreaking"); - enchants2.add("Smiting"); - enchants2.add("Penetration"); - enchants2.add("Draining"); - enchants2.add("Fury"); - enchants2.add("Power"); - } - prefix = enchants1.get((int)(Math.random()*enchants1.size())); - suffix = enchants2.get((int)(Math.random()*enchants2.size())); - if (prefix.equalsIgnoreCase("Protective")) { - finalitem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); - } - if (prefix.equalsIgnoreCase("Fire-Proof")) { - finalitem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); - } - if (prefix.equalsIgnoreCase("Blast Resistant")) { - finalitem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); - } - if (prefix.equalsIgnoreCase("Untouchable")) { - finalitem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); - } - if (prefix.equalsIgnoreCase("Breathing")) { - finalitem.addUnsafeEnchantment(Enchantment.OXYGEN, 10); - } - if (prefix.equalsIgnoreCase("Working")) { - finalitem.addUnsafeEnchantment(Enchantment.WATER_WORKER, 10); - } - if (prefix.equalsIgnoreCase("Unbreaking")) { - finalitem.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - } - if (prefix.equalsIgnoreCase("Thorny")) { - finalitem.addUnsafeEnchantment(Enchantment.THORNS, 10); - } - if (prefix.equalsIgnoreCase("Untouchable")) { - finalitem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); - } - if (prefix.equalsIgnoreCase("Lightweight")) { - finalitem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); - } - if (prefix.equalsIgnoreCase("Power")) { - finalitem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 10); - } - if (prefix.equalsIgnoreCase("Damaging")) { - finalitem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); - } - if (prefix.equalsIgnoreCase("Knockback")) { - finalitem.addUnsafeEnchantment(Enchantment.KNOCKBACK, 10); - } - if (prefix.equalsIgnoreCase("Punch")) { - finalitem.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 10); - } - if (prefix.equalsIgnoreCase("Flaming")) { - finalitem.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10); - } - if (prefix.equalsIgnoreCase("Infinite")) { - finalitem.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 10); - } - if (prefix.equalsIgnoreCase("Undead")) { - finalitem.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 10); - } - if (prefix.equalsIgnoreCase("Baning")) { - finalitem.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 10); - } - if (prefix.equalsIgnoreCase("Fiery")) { - finalitem.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 10); - } - if (prefix.equalsIgnoreCase("Greedy")) { - finalitem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10); - } - ItemMeta meta = finalitem.getItemMeta(); - meta.setDisplayName(ChatColor.GOLD+""+ChatColor.BOLD+prefix+" "+convertToItemName(finalitem.getType().name())+" of "+suffix); - List setLore = new ArrayList(); - if (suffix.equalsIgnoreCase("Life")) { - setLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+10)+" "+ChatColor.BLUE+"Health"); - } - if (suffix.equalsIgnoreCase("Resistance")) { - setLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*70)+20)+"% "+ChatColor.BLUE+"Damage Reduction"); - } - if (suffix.equalsIgnoreCase("Durability")) { - setLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*200)+50)*10)+"% "+ChatColor.BLUE+"Durability"); - } - if (suffix.equalsIgnoreCase("Protection")) { - setLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*50)+10))+"% "+ChatColor.BLUE+"Block Chance"); - } - if (suffix.equalsIgnoreCase("Smiting")) { - setLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*50)+10))+"% "+ChatColor.BLUE+"Critical Chance"); - } - if (suffix.equalsIgnoreCase("Penetration")) { - setLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*20)+5))+" "+ChatColor.BLUE+"Armor Penetration"); - } - if (suffix.equalsIgnoreCase("Draining")) { - setLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*30)+20))+"% "+ChatColor.BLUE+"Life Steal"); - } - if (suffix.equalsIgnoreCase("Fury")) { - setLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*50)+10))+"% "+ChatColor.BLUE+"Attack Speed"); - } - if (suffix.equalsIgnoreCase("Power")) { - setLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*10)+5))+" "+ChatColor.BLUE+"Damage"); - } - setLore.add(""); - setLore.add(ChatColor.YELLOW+"[Halloween]"); - setLore.add("This item was created during the Halloween"); - setLore.add("event. When this item breaks, it simply turns"); - setLore.add("into a \"broken\" state and has a recharge time"); - setLore.add("of 1 week. The item will be fully restored after"); - setLore.add("a week of cooldown."); - meta.setLore(setLore); - finalitem.setItemMeta(meta); - //finalitem.setDurability((short)1560); //TESTING. - boolean full=true; - for (int i=0;i storelore = store.getItemMeta().getLore(); - for (int i=0;i0) { - if (storename.contains("Diamond Chestplate")) { - store.setType(Material.DIAMOND_CHESTPLATE); - ItemMeta meta = store.getItemMeta(); - meta.setDisplayName(meta.getDisplayName().replace(ChatColor.DARK_GRAY+"[BROKEN] ","")); - List lore = store.getItemMeta().getLore(); - lore.remove(repairline); - lore.remove(repairline-1); - meta.setLore(lore); - store.setItemMeta(meta); - p.sendMessage("Your "+meta.getDisplayName()+ChatColor.RESET+" has been repaired!"); - } - if (storename.contains("Diamond Leggings")) { - store.setType(Material.DIAMOND_LEGGINGS); - ItemMeta meta = store.getItemMeta(); - meta.setDisplayName(meta.getDisplayName().replace(ChatColor.DARK_GRAY+"[BROKEN] ","")); - List lore = store.getItemMeta().getLore(); - lore.remove(repairline); - lore.remove(repairline-1); - meta.setLore(lore); - store.setItemMeta(meta); - p.sendMessage("Your "+meta.getDisplayName()+ChatColor.RESET+" has been repaired!"); - } - if (storename.contains("Diamond Helmet")) { - store.setType(Material.DIAMOND_HELMET); - ItemMeta meta = store.getItemMeta(); - meta.setDisplayName(meta.getDisplayName().replace(ChatColor.DARK_GRAY+"[BROKEN] ","")); - List lore = store.getItemMeta().getLore(); - lore.remove(repairline); - lore.remove(repairline-1); - meta.setLore(lore); - store.setItemMeta(meta); - p.sendMessage("Your "+meta.getDisplayName()+ChatColor.RESET+" has been repaired!"); - } - if (storename.contains("Diamond Boots")) { - store.setType(Material.DIAMOND_CHESTPLATE); - ItemMeta meta = store.getItemMeta(); - meta.setDisplayName(meta.getDisplayName().replace(ChatColor.DARK_GRAY+"[BROKEN] ","")); - List lore = store.getItemMeta().getLore(); - lore.remove(repairline); - lore.remove(repairline-1); - meta.setLore(lore); - store.setItemMeta(meta); - p.sendMessage("Your "+meta.getDisplayName()+ChatColor.RESET+" has been repaired!"); - } - if (storename.contains("Diamond Sword")) { - store.setType(Material.DIAMOND_SWORD); - ItemMeta meta = store.getItemMeta(); - meta.setDisplayName(meta.getDisplayName().replace(ChatColor.DARK_GRAY+"[BROKEN] ","")); - List lore = store.getItemMeta().getLore(); - lore.remove(repairline); - lore.remove(repairline-1); - meta.setLore(lore); - store.setItemMeta(meta); - p.sendMessage("Your "+meta.getDisplayName()+ChatColor.RESET+" has been repaired!"); - } - if (storename.contains("Bow")) { - store.setType(Material.BOW); - ItemMeta meta = store.getItemMeta(); - meta.setDisplayName(meta.getDisplayName().replace(ChatColor.DARK_GRAY+"[BROKEN] ","")); - List lore = store.getItemMeta().getLore(); - lore.remove(repairline); - lore.remove(repairline-1); - meta.setLore(lore); - store.setItemMeta(meta); - p.sendMessage("Your "+meta.getDisplayName()+ChatColor.RESET+" has been repaired!"); - } - } - } - } - if ((event.getClick()==ClickType.LEFT || event.getClick()==ClickType.RIGHT)) { - if (event.getCursor()!=null && event.getCurrentItem()!=null && event.getCursor().getType().equals(event.getCurrentItem().getType()) && event.getCursor().getType()==Material.POTION) { - //Literally swap them and cancel. - ItemStack temp = event.getCursor(); - event.setCursor(event.getCurrentItem()); - event.setCurrentItem(temp); - event.setCancelled(true); - } - } - if ((event.getClick()==ClickType.SHIFT_RIGHT || event.getClick()==ClickType.SHIFT_LEFT) && (event.getInventory().getType()==InventoryType.WORKBENCH || event.getInventory().getType()==InventoryType.CRAFTING || event.getInventory().getType()==InventoryType.PLAYER) && event.getSlotType()==SlotType.RESULT) { - //Always refresh your inventory after a delay, just in case. This is a temporary fix for bugs with crafting multiple amounts of a crafting recipe. - final Player p2 = p; - p.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - @Override - public void run() { - p2.updateInventory(); - } - }, 1); - } - if (event.getSlot() != -999) { - ItemStack item = event.getCurrentItem(); - if (event.getInventory().getType() == InventoryType.ANVIL) - { - if (item != null && item.hasItemMeta() && item.getItemMeta().hasLore()) { - List lore = item.getItemMeta().getLore(); - for (int i=0;i enchants1 = new ArrayList(); + List enchants2 = new ArrayList(); + ItemStack finalitem = null; + if (type==0) { + finalitem=new ItemStack(Material.DIAMOND_HELMET); + enchants1.add("Protective"); + enchants1.add("Fire-Proof"); + enchants1.add("Blast Resistant"); + enchants1.add("Untouchable"); + enchants1.add("Breathing"); + enchants1.add("Working"); + enchants1.add("Unbreaking"); + enchants1.add("Thorny"); + enchants2.add("Life"); + enchants2.add("Resistance"); + enchants2.add("Durability"); + enchants2.add("Protection"); + } + if (type==1) { + finalitem=new ItemStack(Material.DIAMOND_CHESTPLATE); + enchants1.add("Protective"); + enchants1.add("Fire-Proof"); + enchants1.add("Blast Resistant"); + enchants1.add("Untouchable"); + enchants1.add("Unbreaking"); + enchants1.add("Thorny"); + enchants2.add("Life"); + enchants2.add("Resistance"); + enchants2.add("Durability"); + enchants2.add("Protection"); + } + if (type==2) { + finalitem=new ItemStack(Material.DIAMOND_LEGGINGS); + enchants1.add("Protective"); + enchants1.add("Fire-Proof"); + enchants1.add("Blast Resistant"); + enchants1.add("Untouchable"); + enchants1.add("Unbreaking"); + enchants1.add("Thorny"); + enchants2.add("Life"); + enchants2.add("Resistance"); + enchants2.add("Durability"); + enchants2.add("Protection"); + } + if (type==3) { + finalitem=new ItemStack(Material.DIAMOND_BOOTS); + enchants1.add("Protective"); + enchants1.add("Fire-Proof"); + enchants1.add("Blast Resistant"); + enchants1.add("Untouchable"); + enchants1.add("Lightweight"); + enchants1.add("Unbreaking"); + enchants1.add("Thorny"); + enchants2.add("Life"); + enchants2.add("Resistance"); + enchants2.add("Durability"); + enchants2.add("Protection"); + } + if (type==4) { + finalitem=new ItemStack(Material.BOW); + enchants1.add("Power"); + enchants1.add("Punch"); + enchants1.add("Flaming"); + enchants1.add("Infinite"); + enchants1.add("Unbreaking"); + enchants2.add("Smiting"); + enchants2.add("Penetration"); + enchants2.add("Draining"); + enchants2.add("Fury"); + enchants2.add("Power"); + } + if (type==5) { + finalitem=new ItemStack(Material.DIAMOND_SWORD); + enchants1.add("Damaging"); + enchants1.add("Knockback"); + enchants1.add("Undead"); + enchants1.add("Baning"); + enchants1.add("Fiery"); + enchants1.add("Greedy"); + enchants1.add("Unbreaking"); + enchants2.add("Smiting"); + enchants2.add("Penetration"); + enchants2.add("Draining"); + enchants2.add("Fury"); + enchants2.add("Power"); + } + prefix = enchants1.get((int)(Math.random()*enchants1.size())); + suffix = enchants2.get((int)(Math.random()*enchants2.size())); + if (prefix.equalsIgnoreCase("Protective")) { + finalitem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); + } + if (prefix.equalsIgnoreCase("Fire-Proof")) { + finalitem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); + } + if (prefix.equalsIgnoreCase("Blast Resistant")) { + finalitem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); + } + if (prefix.equalsIgnoreCase("Untouchable")) { + finalitem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); + } + if (prefix.equalsIgnoreCase("Breathing")) { + finalitem.addUnsafeEnchantment(Enchantment.OXYGEN, 10); + } + if (prefix.equalsIgnoreCase("Working")) { + finalitem.addUnsafeEnchantment(Enchantment.WATER_WORKER, 10); + } + if (prefix.equalsIgnoreCase("Unbreaking")) { + finalitem.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + } + if (prefix.equalsIgnoreCase("Thorny")) { + finalitem.addUnsafeEnchantment(Enchantment.THORNS, 10); + } + if (prefix.equalsIgnoreCase("Untouchable")) { + finalitem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); + } + if (prefix.equalsIgnoreCase("Lightweight")) { + finalitem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); + } + if (prefix.equalsIgnoreCase("Power")) { + finalitem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 10); + } + if (prefix.equalsIgnoreCase("Damaging")) { + finalitem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); + } + if (prefix.equalsIgnoreCase("Knockback")) { + finalitem.addUnsafeEnchantment(Enchantment.KNOCKBACK, 10); + } + if (prefix.equalsIgnoreCase("Punch")) { + finalitem.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 10); + } + if (prefix.equalsIgnoreCase("Flaming")) { + finalitem.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10); + } + if (prefix.equalsIgnoreCase("Infinite")) { + finalitem.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 10); + } + if (prefix.equalsIgnoreCase("Undead")) { + finalitem.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 10); + } + if (prefix.equalsIgnoreCase("Baning")) { + finalitem.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 10); + } + if (prefix.equalsIgnoreCase("Fiery")) { + finalitem.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 10); + } + if (prefix.equalsIgnoreCase("Greedy")) { + finalitem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10); + } + ItemMeta meta = finalitem.getItemMeta(); + meta.setDisplayName(ChatColor.GOLD+""+ChatColor.BOLD+prefix+" "+convertToItemName(finalitem.getType().name())+" of "+suffix); + List setLore = new ArrayList(); + if (suffix.equalsIgnoreCase("Life")) { + setLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+10)+" "+ChatColor.BLUE+"Health"); + } + if (suffix.equalsIgnoreCase("Resistance")) { + setLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*70)+20)+"% "+ChatColor.BLUE+"Damage Reduction"); + } + if (suffix.equalsIgnoreCase("Durability")) { + setLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*200)+50)*10)+"% "+ChatColor.BLUE+"Durability"); + } + if (suffix.equalsIgnoreCase("Protection")) { + setLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*50)+10))+"% "+ChatColor.BLUE+"Block Chance"); + } + if (suffix.equalsIgnoreCase("Smiting")) { + setLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*50)+10))+"% "+ChatColor.BLUE+"Critical Chance"); + } + if (suffix.equalsIgnoreCase("Penetration")) { + setLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*20)+5))+" "+ChatColor.BLUE+"Armor Penetration"); + } + if (suffix.equalsIgnoreCase("Draining")) { + setLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*30)+20))+"% "+ChatColor.BLUE+"Life Steal"); + } + if (suffix.equalsIgnoreCase("Fury")) { + setLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*50)+10))+"% "+ChatColor.BLUE+"Attack Speed"); + } + if (suffix.equalsIgnoreCase("Power")) { + setLore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*10)+5))+" "+ChatColor.BLUE+"Damage"); + } + setLore.add(""); + setLore.add(ChatColor.YELLOW+"[Halloween]"); + setLore.add("This item was created during the Halloween"); + setLore.add("event. When this item breaks, it simply turns"); + setLore.add("into a \"broken\" state and has a recharge time"); + setLore.add("of 1 week. The item will be fully restored after"); + setLore.add("a week of cooldown."); + meta.setLore(setLore); + finalitem.setItemMeta(meta); + //finalitem.setDurability((short)1560); //TESTING. + boolean full=true; + for (int i=0;i storelore = store.getItemMeta().getLore(); + for (int i=0;i0) { + if (storename.contains("Diamond Chestplate")) { + store.setType(Material.DIAMOND_CHESTPLATE); + ItemMeta meta = store.getItemMeta(); + meta.setDisplayName(meta.getDisplayName().replace(ChatColor.DARK_GRAY+"[BROKEN] ","")); + List lore = store.getItemMeta().getLore(); + lore.remove(repairline); + lore.remove(repairline-1); + meta.setLore(lore); + store.setItemMeta(meta); + p.sendMessage("Your "+meta.getDisplayName()+ChatColor.RESET+" has been repaired!"); + } + if (storename.contains("Diamond Leggings")) { + store.setType(Material.DIAMOND_LEGGINGS); + ItemMeta meta = store.getItemMeta(); + meta.setDisplayName(meta.getDisplayName().replace(ChatColor.DARK_GRAY+"[BROKEN] ","")); + List lore = store.getItemMeta().getLore(); + lore.remove(repairline); + lore.remove(repairline-1); + meta.setLore(lore); + store.setItemMeta(meta); + p.sendMessage("Your "+meta.getDisplayName()+ChatColor.RESET+" has been repaired!"); + } + if (storename.contains("Diamond Helmet")) { + store.setType(Material.DIAMOND_HELMET); + ItemMeta meta = store.getItemMeta(); + meta.setDisplayName(meta.getDisplayName().replace(ChatColor.DARK_GRAY+"[BROKEN] ","")); + List lore = store.getItemMeta().getLore(); + lore.remove(repairline); + lore.remove(repairline-1); + meta.setLore(lore); + store.setItemMeta(meta); + p.sendMessage("Your "+meta.getDisplayName()+ChatColor.RESET+" has been repaired!"); + } + if (storename.contains("Diamond Boots")) { + store.setType(Material.DIAMOND_CHESTPLATE); + ItemMeta meta = store.getItemMeta(); + meta.setDisplayName(meta.getDisplayName().replace(ChatColor.DARK_GRAY+"[BROKEN] ","")); + List lore = store.getItemMeta().getLore(); + lore.remove(repairline); + lore.remove(repairline-1); + meta.setLore(lore); + store.setItemMeta(meta); + p.sendMessage("Your "+meta.getDisplayName()+ChatColor.RESET+" has been repaired!"); + } + if (storename.contains("Diamond Sword")) { + store.setType(Material.DIAMOND_SWORD); + ItemMeta meta = store.getItemMeta(); + meta.setDisplayName(meta.getDisplayName().replace(ChatColor.DARK_GRAY+"[BROKEN] ","")); + List lore = store.getItemMeta().getLore(); + lore.remove(repairline); + lore.remove(repairline-1); + meta.setLore(lore); + store.setItemMeta(meta); + p.sendMessage("Your "+meta.getDisplayName()+ChatColor.RESET+" has been repaired!"); + } + if (storename.contains("Bow")) { + store.setType(Material.BOW); + ItemMeta meta = store.getItemMeta(); + meta.setDisplayName(meta.getDisplayName().replace(ChatColor.DARK_GRAY+"[BROKEN] ","")); + List lore = store.getItemMeta().getLore(); + lore.remove(repairline); + lore.remove(repairline-1); + meta.setLore(lore); + store.setItemMeta(meta); + p.sendMessage("Your "+meta.getDisplayName()+ChatColor.RESET+" has been repaired!"); + } + } + } + } + if ((event.getClick()==ClickType.LEFT || event.getClick()==ClickType.RIGHT)) { + if (event.getCursor()!=null && event.getCurrentItem()!=null && event.getCursor().getType().equals(event.getCurrentItem().getType()) && event.getCursor().getType()==Material.POTION) { + //Literally swap them and cancel. + ItemStack temp = event.getCursor(); + event.setCursor(event.getCurrentItem()); + event.setCurrentItem(temp); event.setCancelled(true); - return; - } - } - }else - if (event.getInventory().getType()==InventoryType.CHEST && !event.getInventory().getName().equalsIgnoreCase("Notification Options")) { - //If we click a chest, make sure it's not the same ID chest. - if (event.getCurrentItem()!=null) { - if ((event.getCurrentItem().getType()==Material.CHEST || event.getCurrentItem().getType()==Material.TRAPPED_CHEST || event.getCurrentItem().getType()==Material.ENDER_CHEST)) { - int identifier=-1; - if (event.getCurrentItem().getItemMeta().getLore()!=null) { - //Check to see if the Lore contains anything. - for (int i=0;i lore = item.getItemMeta().getLore(); + for (int i=0;i=10) { - if (event.getCurrentItem()!=null && event.getCurrentItem().getType()==Material.POTION) { - if (event.getCurrentItem().getItemMeta()!=null && event.getCurrentItem().getItemMeta().getLore()!=null) { - List loredata = event.getCurrentItem().getItemMeta().getLore(); - boolean found=false; - for (int i=0;i loredata = new ArrayList(); - loredata.add(ChatColor.RED+"Duplicated"); - ItemMeta meta = event.getCurrentItem().getItemMeta(); - meta.setLore(loredata); - event.getCurrentItem().setItemMeta(meta); - } - } - } - } - } else - if (event.getInventory().getName().equalsIgnoreCase("Notification Options")) { - if (event.getSlotType()==SlotType.CONTAINER && (event.getSlot()==2 || event.getSlot()==6 || - event.getSlot()==11 || event.getSlot()==15 || - event.getSlot()==20 || event.getSlot()==24)) { - if (event.getInventory().getContents()[event.getSlot()].getType()==Material.REDSTONE_TORCH_OFF) { - event.getInventory().getContents()[event.getSlot()].setType(Material.REDSTONE_TORCH_ON); - } else { - event.getInventory().getContents()[event.getSlot()].setType(Material.REDSTONE_TORCH_OFF); - } - } - if (event.getSlotType()==SlotType.CONTAINER && (event.getSlot()==1 || event.getSlot()==5 || - event.getSlot()==10 || event.getSlot()==14 || - event.getSlot()==19 || event.getSlot()==23)) { - if (event.getInventory().getContents()[event.getSlot()+1].getType()==Material.REDSTONE_TORCH_OFF) { - event.getInventory().getContents()[event.getSlot()+1].setType(Material.REDSTONE_TORCH_ON); - } else { - event.getInventory().getContents()[event.getSlot()+1].setType(Material.REDSTONE_TORCH_OFF); - } - } - event.setCancelled(true); - } - if (event.getInventory() != null && - event.getSlotType() == SlotType.RESULT) { - - switch (event.getInventory().getType()) { - case CRAFTING: - handleCrafting(event); - break; - case WORKBENCH: - handleCrafting(event); - break; - } + } + if (item != null && item.hasItemMeta()) { + String tempname = ""; + + if (item.getItemMeta() + .hasDisplayName()) { + tempname = item.getItemMeta() + .getDisplayName(); + } + + if (!tempname.equals(event + .getInventory().getItem(0) + .getItemMeta() + .getDisplayName()) && event + .getInventory().getItem(0) + .getItemMeta() + .getDisplayName().contains(Character.toString((char)0x00A7))) { + item.setItemMeta(event.getInventory().getItem(0).getItemMeta()); + } + } + } + } + if (isViewingEnderCube(p)) { + //If we are viewing an ender cube, every single click should prompt an update for all viewers of it. In case it does something. + ItemCube_updateSameEnderCube(getViewingEnderCubeID(p),p); + } + if (event.getCursor()!=null) { + //Regardless of the inventory, if we try to put it inside a chest, got to try to insert it in there. + if (event.getCurrentItem()!=null) { + if (event.getCursor()!=null && event.getSlotType()!=SlotType.RESULT && event.getCursor().getType()!=Material.AIR && (event.getCurrentItem().getType()==Material.CHEST || event.getCurrentItem().getType()==Material.TRAPPED_CHEST || event.getCurrentItem().getType()==Material.ENDER_CHEST) && event.getClick()==ClickType.LEFT) { + event.setCursor(insertIntoItemCube(p, event.getCurrentItem(), event.getCursor())); + p.updateInventory(); + event.setCancelled(true); + return; + } + } + } + if (event.getInventory().getType()==InventoryType.CRAFTING /*|| event.getInventory().getType()==InventoryType.CHEST*//*Buggy for some reason. We can't open chests in chests.*/) { + if (event.getCurrentItem()!=null) { + if ((event.getCurrentItem().getType()==Material.CHEST || event.getCurrentItem().getType()==Material.TRAPPED_CHEST || event.getCurrentItem().getType()==Material.ENDER_CHEST) && event.getClick()==ClickType.RIGHT) { + viewItemCube(p, event.getCurrentItem()); + event.setCancelled(true); + return; + } + } + }else + if (event.getInventory().getType()==InventoryType.CHEST && event.getInventory().getName().contains("Item Cube")) { + //If we click a chest, make sure it's not the same ID chest. + if (event.getCurrentItem()!=null) { + if ((event.getCurrentItem().getType()==Material.CHEST || event.getCurrentItem().getType()==Material.TRAPPED_CHEST || event.getCurrentItem().getType()==Material.ENDER_CHEST)) { + int identifier=-1; + if (event.getCurrentItem().getItemMeta().getLore()!=null) { + //Check to see if the Lore contains anything. + for (int i=0;i=10) { + if (event.getCurrentItem()!=null && event.getCurrentItem().getType()==Material.POTION) { + if (event.getCurrentItem().getItemMeta()!=null && event.getCurrentItem().getItemMeta().getLore()!=null) { + List loredata = event.getCurrentItem().getItemMeta().getLore(); + boolean found=false; + for (int i=0;i loredata = new ArrayList(); + loredata.add(ChatColor.RED+"Duplicated"); + ItemMeta meta = event.getCurrentItem().getItemMeta(); + meta.setLore(loredata); + event.getCurrentItem().setItemMeta(meta); + } + } + } + } + } else if (event.getInventory().getTitle().equalsIgnoreCase("Repair and Enchant")) { + final int INPUT = 10; + final int MATERIALS = 12; + final int MAGIC = 14; + final int OUTPUT = 16; + final int LEVELS = 22; + boolean anvilClicked = false; + + Bukkit.getLogger().info("Anvil interface CLICK at slot #" + event.getRawSlot()); + + if (event.getRawSlot() < 27) { + anvilClicked = true; + Bukkit.getLogger().info("Anvil clicked."); + } else { + Bukkit.getLogger().info("Inventory clicked."); + } + if (!anvilClicked) { + // Clicked the inventory. Leave the operation alone UNLESS it's a shift-click operation. + if (event.isShiftClick()) { + // Call the scheduled task to validate and update the inventory + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new updateInventoryTask(event.getWhoClicked().getName())); + } + } else { + // Clicked the anvil. If GUI items are clicked or an invalid operation happens, cancel the operation. + if (event.getSlot() == INPUT || event.getSlot() == MATERIALS + || event.getSlot() == MAGIC || event.getSlot() == OUTPUT) + { + /* + * OUTPUT Block + */ + + if (event.getSlot() == OUTPUT && event.getCursor() != null && event.getCursor().getType() != Material.AIR && !matches(event.getCursor(), event.getCurrentItem())){ + Bukkit.getLogger().info("Anvil OUTPUT click."); + event.setCancelled(true); // Cancel the event if trying to put items into the output slot + } + + // If click on output and it's not null, take the item and clear anvil inventory + if (event.getInventory().getContents()[OUTPUT] != null + && event.getSlot() == OUTPUT) { + + Bukkit.getLogger().info("Anvil OUTPUT click with output populated."); + + if (event.getInventory().getContents()[LEVELS].getAmount() > Bukkit.getPlayer(event.getWhoClicked().getName()).getLevel()) { + // Player doesn't have enough XP, abort + Bukkit.getLogger().info("Player has insufficient XP."); + p.sendMessage(ChatColor.RED+"You don't have enough experience to do that!"); + event.setCancelled(true); + } else { + Bukkit.getLogger().info("Player has sufficient XP."); + if (event.getCursor() != null && event.getCursor().getType() != Material.AIR) { + + Bukkit.getLogger().info("Anvil OUTPUT click with non-null mouse. Mouse has: " + event.getCursor()); + + event.setCancelled(true); // Cancel event if cursor is not empty + + if (event.isShiftClick()) { + // Attempts to store the item in the player's inventory. + // If it succeeds, remove the item from the anvil + // interface. + Bukkit.getLogger().info("Shift-click"); + if (event + .getWhoClicked() + .getInventory() + .addItem( + event.getInventory().getContents()[OUTPUT]) + .isEmpty()) { + + Bukkit.getLogger().info("Can place into inventory."); + + event.getInventory().setItem(INPUT, new ItemStack(Material.AIR)); + event.getInventory().setItem(MATERIALS, new ItemStack(Material.AIR)); + event.getInventory().setItem(MAGIC, new ItemStack(Material.AIR)); + + // Set XP + Bukkit.getPlayer(event.getWhoClicked().getName()).setLevel(Bukkit.getPlayer(event.getWhoClicked().getName()).getLevel() - event.getInventory().getContents()[LEVELS].getAmount()); + + Bukkit.getLogger().info("Item is: " + event.getInventory().getItem(OUTPUT)); + + // Play anvil sound + if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("IRON") || + event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("GOLD") || + event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("DIAMOND") || + event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("CHAINMAIL")) { + Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.BLAZE_HIT, 10, 1); + } else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("WOOD")) { + Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.DIG_WOOD, 20, 1); + } else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("STONE")) { + Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.DIG_STONE, 20, 1); + } else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("LEATHER")) { + Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.DIG_WOOL, 20, 1); + } else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("BOW") || + event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("FISHING")) { + Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.ARROW_HIT, 10, 1); + } + + event.getInventory().setItem(OUTPUT, new ItemStack(Material.AIR)); + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new updateInventoryTask(event.getWhoClicked().getName())); + + } + } + } else { + + Bukkit.getLogger().info("Anvil OUTPUT click with null mouse."); + + + if (event.isShiftClick()) { + event.setCancelled(true); // Cancel event if Shift-Click, run checks + + // Attempts to store the item in the player's inventory. + // If it succeeds, remove the item from the anvil + // interface. + Bukkit.getLogger().info("Shift-click"); + if (event + .getWhoClicked() + .getInventory() + .addItem( + event.getInventory().getContents()[OUTPUT]) + .isEmpty()) { + + Bukkit.getLogger().info("Can place into inventory."); + + event.getInventory().setItem(INPUT, new ItemStack(Material.AIR)); + event.getInventory().setItem(MATERIALS, new ItemStack(Material.AIR)); + event.getInventory().setItem(MAGIC, new ItemStack(Material.AIR)); + + // Set XP + Bukkit.getPlayer(event.getWhoClicked().getName()).setLevel(Bukkit.getPlayer(event.getWhoClicked().getName()).getLevel() - event.getInventory().getContents()[LEVELS].getAmount()); + + // Play anvil sound + if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("IRON") || + event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("GOLD") || + event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("DIAMOND") || + event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("CHAINMAIL")) { + Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.BLAZE_HIT, 10, 1); + } else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("WOOD")) { + Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.DIG_WOOD, 20, 1); + } else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("STONE")) { + Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.DIG_STONE, 20, 1); + } else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("LEATHER")) { + Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.DIG_WOOL, 20, 1); + } else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("BOW") || + event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("FISHING")) { + Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.ARROW_HIT, 10, 1); + } + + event.getInventory().setItem(OUTPUT, new ItemStack(Material.AIR)); + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new updateInventoryTask(event.getWhoClicked().getName())); + } + } else { + Bukkit.getLogger().info("Normal click"); + + // Cursor is empty, item picked up. Subtract XP levels and remove ingredients. + event.getInventory().setItem(INPUT, new ItemStack(Material.AIR)); + event.getInventory().setItem(MATERIALS, new ItemStack(Material.AIR)); + event.getInventory().setItem(MAGIC, new ItemStack(Material.AIR)); + // event.getInventory().setItem(OUTPUT, new ItemStack(Material.AIR)); + + // Set XP + Bukkit.getPlayer(event.getWhoClicked().getName()).setLevel(Bukkit.getPlayer(event.getWhoClicked().getName()).getLevel() - event.getInventory().getContents()[LEVELS].getAmount()); + + // Play anvil sound + if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("IRON") || + event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("GOLD") || + event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("DIAMOND") || + event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("CHAINMAIL")) { + Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.BLAZE_HIT, 10, 1); + } else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("WOOD")) { + Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.DIG_WOOD, 20, 1); + } else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("STONE")) { + Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.DIG_STONE, 20, 1); + } else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("LEATHER")) { + Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.DIG_WOOL, 20, 1); + } else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("BOW") || + event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("FISHING")) { + Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.ARROW_HIT, 10, 1); + } + + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new updateInventoryTask(event.getWhoClicked().getName())); + + } + } + + } + } + + boolean valid = false; + + if (event.isShiftClick() && event.getRawSlot() != OUTPUT) { + valid = true; // always valid if shift clicking an anvil slot that isn't the output. + } + + if (event.getCursor() == null || event.getCursor().getType() == Material.AIR) { + valid = true; // always valid if cursor carries nothing + } else if (event.getSlotType() == SlotType.CONTAINER && event.getSlot() == INPUT) { + + /* + * INPUT Block + * All tools and armor types, as well as fishing rods and bows. + */ + + Bukkit.getLogger().info("Anvil INPUT click with this item on mouse: " + event.getCursor().getType().toString()); + + if (event.getCursor().getType().toString().toUpperCase().contains("HELMET") || event.getCursor().getType().toString().toUpperCase().contains("CHESTPLATE") || + event.getCursor().getType().toString().toUpperCase().contains("LEGGINGS") || event.getCursor().getType().toString().toUpperCase().contains("BOOTS") || + event.getCursor().getType().toString().toUpperCase().contains("PICKAXE") || event.getCursor().getType().toString().toUpperCase().contains("SPADE") || + event.getCursor().getType().toString().toUpperCase().contains("HOE") || event.getCursor().getType().toString().toUpperCase().contains("AXE") || + event.getCursor().getType().toString().toUpperCase().contains("SWORD") || event.getCursor().getType().toString().toUpperCase().contains("FISHING") || + event.getCursor().getType().toString().toUpperCase().contentEquals("BOW")) { + valid = true; + } + + if (event.getCursor().getDurability() == 0) + { + // Can't put fully repaired item into input slot. + valid = false; + } + } else if (event.getSlotType() == SlotType.CONTAINER && event.getSlot() == MATERIALS) { + + /* + * MATERIALS Block + * Leather, string, wood, cobble, iron, gold, and diamond allowed. + */ + + Bukkit.getLogger().info("Anvil MATERIALS click with this item on mouse: " + event.getCursor().getType().toString()); + + if (event.getCursor().getType() == Material.LEATHER || event.getCursor().getType() == Material.IRON_INGOT || + event.getCursor().getType() == Material.GOLD_INGOT || event.getCursor().getType() == Material.IRON_BLOCK || + event.getCursor().getType() == Material.DIAMOND_BLOCK || event.getCursor().getType() == Material.DIAMOND || + event.getCursor().getType() == Material.WOOD || event.getCursor().getType() == Material.COBBLESTONE || + event.getCursor().getType() == Material.STRING) { + valid = true; + } + } else if (event.getSlotType() == SlotType.CONTAINER && event.getSlot() == MAGIC) { + + /* + * MAGIC Block + * Shards and Enchanted Books allowed. + * Not implemented yet, so nothing is allowed at the moment. + */ + + Bukkit.getLogger().info("Anvil MAGIC click with this item on mouse: " + event.getCursor().getType().toString()); + + /* + if (event.getCursor().getType() == Material.FLINT || event.getCursor().getType() == Material.QUARTZ || + event.getCursor().getType() == Material.NETHER_STAR || event.getCursor().getType() == Material.ENCHANTED_BOOK) { + valid = true; + } + */ + } + + if (!valid) { + event.setCancelled(true); + } else { + // Update the inventory if it is valid + // Set up anvil inventory update scheduler + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new updateInventoryTask(event.getWhoClicked().getName())); + } + } else { + event.setCancelled(true); + } + } + + } else if (event.getInventory().getName().equalsIgnoreCase("Notification Options")) { + boolean optionsClicked; + if (event.getRawSlot() < 27) { + optionsClicked = true; + // Bukkit.getLogger().info("Options clicked."); + } else { + optionsClicked = false; + // Bukkit.getLogger().info("Inventory clicked."); + } + + if (optionsClicked && (event.getSlot() % 9 == 2 || event.getSlot() % 9 == 6)) { + if (event.getInventory().getContents()[event.getSlot()].getType()==Material.REDSTONE_TORCH_OFF) { + event.getInventory().getContents()[event.getSlot()].setType(Material.REDSTONE_TORCH_ON); + } else { + event.getInventory().getContents()[event.getSlot()].setType(Material.REDSTONE_TORCH_OFF); + } + } + if (optionsClicked && (event.getSlot() % 9 == 1 || event.getSlot() % 9 == 5)) { + if (event.getInventory().getContents()[event.getSlot()+1].getType()==Material.REDSTONE_TORCH_OFF) { + event.getInventory().getContents()[event.getSlot()+1].setType(Material.REDSTONE_TORCH_ON); + } else { + event.getInventory().getContents()[event.getSlot()+1].setType(Material.REDSTONE_TORCH_OFF); + } + } + event.setCancelled(true); + } + if (event.getInventory() != null && + event.getSlotType() == SlotType.RESULT) { + switch (event.getInventory().getType()) { + case CRAFTING: + handleCrafting(event); + break; + case WORKBENCH: + handleCrafting(event); + break; + } + + } } - } - - private void rewardCraft(ItemStack item, int amount, HumanEntity pl) { - Player p = (Player)pl; - if (this.plugin.PlayerinJob(p,"Digger")) { - if (item.getType()==Material.SANDSTONE) { - this.plugin.gainMoneyExp(p,"Digger",0.02*amount,6*amount); - } - if (item.getType()==Material.BRICK) { - this.plugin.gainMoneyExp(p,"Digger",0.04*amount,8*amount); - } - } - if (this.plugin.PlayerinJob(p,"Weaponsmith")) { - boolean crafteditem=false; - if (item.getType()==Material.ARROW) { - this.plugin.gainMoneyExp(p,"Weaponsmith",0.025*amount,4*amount); - crafteditem=true; - } - /* + + private void rewardCraft(ItemStack item, int amount, HumanEntity pl) { + Player p = (Player)pl; + if (this.plugin.PlayerinJob(p,"Digger")) { + if (item.getType()==Material.SANDSTONE) { + this.plugin.gainMoneyExp(p,"Digger",0.02*amount,6*amount); + } + if (item.getType()==Material.BRICK) { + this.plugin.gainMoneyExp(p,"Digger",0.04*amount,8*amount); + } + } + if (this.plugin.PlayerinJob(p,"Weaponsmith")) { + boolean crafteditem=false; + if (item.getType()==Material.ARROW) { + this.plugin.gainMoneyExp(p,"Weaponsmith",0.025*amount,4*amount); + crafteditem=true; + } + /* if (item.getType()==Material.WOOD_SWORD) { this.plugin.gainMoneyExp(p,"Weaponsmith",0.05*amount,10*amount); crafteditem=true; }*/ - if (item.getType()==Material.FLINT_AND_STEEL) { - this.plugin.gainMoneyExp(p,"Weaponsmith",0.06*amount,12*amount); - crafteditem=true; - } - if (item.getType()==Material.BOW) { - this.plugin.gainMoneyExp(p,"Weaponsmith",0.075*amount,12*amount); - crafteditem=true; - } - if (item.getType()==Material.IRON_SWORD) { - this.plugin.gainMoneyExp(p,"Weaponsmith",0.375*amount,75*amount); - crafteditem=true; - } - if (item.getType()==Material.GOLD_SWORD) { - this.plugin.gainMoneyExp(p,"Weaponsmith",0.50*amount,100*amount); - crafteditem=true; - } - if (item.getType()==Material.DIAMOND_SWORD) { - this.plugin.gainMoneyExp(p,"Weaponsmith",3.60*amount,280*amount); - crafteditem=true; - } - } - if (this.plugin.PlayerinJob(p,"Blacksmith")) { - boolean crafteditem=false; - /* + if (item.getType()==Material.FLINT_AND_STEEL) { + this.plugin.gainMoneyExp(p,"Weaponsmith",0.06*amount,12*amount); + crafteditem=true; + } + if (item.getType()==Material.BOW) { + this.plugin.gainMoneyExp(p,"Weaponsmith",0.075*amount,12*amount); + crafteditem=true; + } + if (item.getType()==Material.IRON_SWORD) { + this.plugin.gainMoneyExp(p,"Weaponsmith",0.375*amount,75*amount); + crafteditem=true; + } + if (item.getType()==Material.GOLD_SWORD) { + this.plugin.gainMoneyExp(p,"Weaponsmith",0.50*amount,100*amount); + crafteditem=true; + } + if (item.getType()==Material.DIAMOND_SWORD) { + this.plugin.gainMoneyExp(p,"Weaponsmith",3.60*amount,280*amount); + crafteditem=true; + } + } + if (this.plugin.PlayerinJob(p,"Blacksmith")) { + boolean crafteditem=false; + /* if (item.getType()==Material.STONE_HOE) { this.plugin.gainMoneyExp(p,"Blacksmith",0.04*amount,7*amount); crafteditem=true; @@ -9701,233 +10065,233 @@ public ItemStack getGoodie() { this.plugin.gainMoneyExp(p,"Blacksmith",0.075*amount,15*amount); crafteditem=true; }*/ - if (item.getType()==Material.LEATHER_BOOTS) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.125*amount,8*amount); - crafteditem=true; - } - if (item.getType()==Material.LEATHER_HELMET) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.15*amount,14*amount); - crafteditem=true; - } - if (item.getType()==Material.LEATHER_LEGGINGS) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.175*amount,15*amount); - crafteditem=true; - } - if (item.getType()==Material.LEATHER_CHESTPLATE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.20*amount,18*amount); - crafteditem=true; - } - if (item.getType()==Material.IRON_SPADE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.25*amount,18*amount); - crafteditem=true; - } - if (item.getType()==Material.IRON_HOE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.325*amount,38*amount); - crafteditem=true; - } - if (item.getType()==Material.IRON_AXE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.35*amount,40*amount); - crafteditem=true; - } - if (item.getType()==Material.CHAINMAIL_BOOTS) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.375*0.5*amount,80*0.5*amount); - crafteditem=true; - } - if (item.getType()==Material.CHAINMAIL_HELMET) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.50*0.5*amount,100*0.5*amount); - crafteditem=true; - } - if (item.getType()==Material.CHAINMAIL_LEGGINGS) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.725*0.5*amount,140*0.5*amount); - crafteditem=true; - } - if (item.getType()==Material.CHAINMAIL_CHESTPLATE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.875*0.5*amount,175*0.5*amount); - crafteditem=true; - } - if (item.getType()==Material.IRON_BOOTS) { - int mult=1; - if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { - mult=10; - } - this.plugin.gainMoneyExp(p,"Blacksmith",0.375*mult*amount,80*mult*amount); - crafteditem=true; - } - if (item.getType()==Material.IRON_PICKAXE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.40*amount,58*amount); - crafteditem=true; - } - if (item.getType()==Material.IRON_HELMET) { - int mult=1; - if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { - mult=10; - } - this.plugin.gainMoneyExp(p,"Blacksmith",0.50*mult*amount,100*mult*amount); - crafteditem=true; - } - if (item.getType()==Material.GOLD_SPADE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.625*amount,23*amount); - crafteditem=true; - } - if (item.getType()==Material.GOLD_HOE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.65*amount,65*amount); - crafteditem=true; - } - if (item.getType()==Material.GOLD_AXE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.70*amount,70*amount); - crafteditem=true; - } - if (item.getType()==Material.IRON_LEGGINGS) { - int mult=1; - if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { - mult=10; - } - this.plugin.gainMoneyExp(p,"Blacksmith",0.725*mult*amount,140*mult*amount); - crafteditem=true; - } - if (item.getType()==Material.DIAMOND_SPADE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.75*amount,90*amount); - crafteditem=true; - } - if (item.getType()==Material.DIAMOND_HOE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.80*amount,188*amount); - crafteditem=true; - } - if (item.getType()==Material.DIAMOND_AXE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.81*amount,196*amount); - crafteditem=true; - } - if (item.getType()==Material.GOLD_BOOTS) { - int mult=1; - if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { - mult=10; - } - this.plugin.gainMoneyExp(p,"Blacksmith",0.825*mult*amount,120*mult*amount); - crafteditem=true; - } - if (item.getType()==Material.IRON_CHESTPLATE) { - int mult=1; - if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { - mult=10; - } - this.plugin.gainMoneyExp(p,"Blacksmith",0.875*mult*amount,175*mult*amount); - crafteditem=true; - } - if (item.getType()==Material.GOLD_HELMET) { - int mult=1; - if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { - mult=10; - } - this.plugin.gainMoneyExp(p,"Blacksmith",0.925*mult*amount,150*mult*amount); - crafteditem=true; - } - if (item.getType()==Material.DIAMOND_PICKAXE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.925*amount,290*amount); - crafteditem=true; - } - if (item.getType()==Material.DIAMOND_BOOTS) { - int mult=1; - if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { - mult=10; - } - this.plugin.gainMoneyExp(p,"Blacksmith",1.00*mult*amount,390*mult*amount); - crafteditem=true; - } - if (item.getType()==Material.GOLD_LEGGINGS) { - int mult=1; - if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { - mult=10; - } - this.plugin.gainMoneyExp(p,"Blacksmith",1.025*mult*amount,170*mult*amount); - crafteditem=true; - } - if (item.getType()==Material.GOLD_CHESTPLATE) { - int mult=1; - if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { - mult=10; - } - this.plugin.gainMoneyExp(p,"Blacksmith",1.15*mult*amount,192*mult*amount); - crafteditem=true; - } - if (item.getType()==Material.DIAMOND_HELMET) { - int mult=1; - if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { - mult=10; - } - this.plugin.gainMoneyExp(p,"Blacksmith",1.15*mult*amount,480*mult*amount); - crafteditem=true; - } - if (item.getType()==Material.DIAMOND_LEGGINGS) { - int mult=1; - if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { - mult=10; - } - this.plugin.gainMoneyExp(p,"Blacksmith",1.325*mult*amount,660*mult*amount); - crafteditem=true; - } - if (item.getType()==Material.DIAMOND_CHESTPLATE) { - int mult=1; - if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { - mult=10; - } - this.plugin.gainMoneyExp(p,"Blacksmith",1.50*mult*amount,750*mult*amount); - crafteditem=true; - } - } - /*if (e.getBlock().getType()==Material.PUMPKIN) { + if (item.getType()==Material.LEATHER_BOOTS) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.125*amount,8*amount); + crafteditem=true; + } + if (item.getType()==Material.LEATHER_HELMET) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.15*amount,14*amount); + crafteditem=true; + } + if (item.getType()==Material.LEATHER_LEGGINGS) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.175*amount,15*amount); + crafteditem=true; + } + if (item.getType()==Material.LEATHER_CHESTPLATE) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.20*amount,18*amount); + crafteditem=true; + } + if (item.getType()==Material.IRON_SPADE) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.25*amount,18*amount); + crafteditem=true; + } + if (item.getType()==Material.IRON_HOE) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.325*amount,38*amount); + crafteditem=true; + } + if (item.getType()==Material.IRON_AXE) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.35*amount,40*amount); + crafteditem=true; + } + if (item.getType()==Material.CHAINMAIL_BOOTS) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.375*0.5*amount,80*0.5*amount); + crafteditem=true; + } + if (item.getType()==Material.CHAINMAIL_HELMET) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.50*0.5*amount,100*0.5*amount); + crafteditem=true; + } + if (item.getType()==Material.CHAINMAIL_LEGGINGS) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.725*0.5*amount,140*0.5*amount); + crafteditem=true; + } + if (item.getType()==Material.CHAINMAIL_CHESTPLATE) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.875*0.5*amount,175*0.5*amount); + crafteditem=true; + } + if (item.getType()==Material.IRON_BOOTS) { + int mult=1; + if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { + mult=10; + } + this.plugin.gainMoneyExp(p,"Blacksmith",0.375*mult*amount,80*mult*amount); + crafteditem=true; + } + if (item.getType()==Material.IRON_PICKAXE) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.40*amount,58*amount); + crafteditem=true; + } + if (item.getType()==Material.IRON_HELMET) { + int mult=1; + if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { + mult=10; + } + this.plugin.gainMoneyExp(p,"Blacksmith",0.50*mult*amount,100*mult*amount); + crafteditem=true; + } + if (item.getType()==Material.GOLD_SPADE) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.625*amount,23*amount); + crafteditem=true; + } + if (item.getType()==Material.GOLD_HOE) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.65*amount,65*amount); + crafteditem=true; + } + if (item.getType()==Material.GOLD_AXE) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.70*amount,70*amount); + crafteditem=true; + } + if (item.getType()==Material.IRON_LEGGINGS) { + int mult=1; + if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { + mult=10; + } + this.plugin.gainMoneyExp(p,"Blacksmith",0.725*mult*amount,140*mult*amount); + crafteditem=true; + } + if (item.getType()==Material.DIAMOND_SPADE) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.75*amount,90*amount); + crafteditem=true; + } + if (item.getType()==Material.DIAMOND_HOE) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.80*amount,188*amount); + crafteditem=true; + } + if (item.getType()==Material.DIAMOND_AXE) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.81*amount,196*amount); + crafteditem=true; + } + if (item.getType()==Material.GOLD_BOOTS) { + int mult=1; + if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { + mult=10; + } + this.plugin.gainMoneyExp(p,"Blacksmith",0.825*mult*amount,120*mult*amount); + crafteditem=true; + } + if (item.getType()==Material.IRON_CHESTPLATE) { + int mult=1; + if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { + mult=10; + } + this.plugin.gainMoneyExp(p,"Blacksmith",0.875*mult*amount,175*mult*amount); + crafteditem=true; + } + if (item.getType()==Material.GOLD_HELMET) { + int mult=1; + if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { + mult=10; + } + this.plugin.gainMoneyExp(p,"Blacksmith",0.925*mult*amount,150*mult*amount); + crafteditem=true; + } + if (item.getType()==Material.DIAMOND_PICKAXE) { + this.plugin.gainMoneyExp(p,"Blacksmith",0.925*amount,290*amount); + crafteditem=true; + } + if (item.getType()==Material.DIAMOND_BOOTS) { + int mult=1; + if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { + mult=10; + } + this.plugin.gainMoneyExp(p,"Blacksmith",1.00*mult*amount,390*mult*amount); + crafteditem=true; + } + if (item.getType()==Material.GOLD_LEGGINGS) { + int mult=1; + if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { + mult=10; + } + this.plugin.gainMoneyExp(p,"Blacksmith",1.025*mult*amount,170*mult*amount); + crafteditem=true; + } + if (item.getType()==Material.GOLD_CHESTPLATE) { + int mult=1; + if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { + mult=10; + } + this.plugin.gainMoneyExp(p,"Blacksmith",1.15*mult*amount,192*mult*amount); + crafteditem=true; + } + if (item.getType()==Material.DIAMOND_HELMET) { + int mult=1; + if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { + mult=10; + } + this.plugin.gainMoneyExp(p,"Blacksmith",1.15*mult*amount,480*mult*amount); + crafteditem=true; + } + if (item.getType()==Material.DIAMOND_LEGGINGS) { + int mult=1; + if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { + mult=10; + } + this.plugin.gainMoneyExp(p,"Blacksmith",1.325*mult*amount,660*mult*amount); + crafteditem=true; + } + if (item.getType()==Material.DIAMOND_CHESTPLATE) { + int mult=1; + if ((item.getItemMeta().getDisplayName()!=null && !item.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || item.getItemMeta().getDisplayName()==null) { + mult=10; + } + this.plugin.gainMoneyExp(p,"Blacksmith",1.50*mult*amount,750*mult*amount); + crafteditem=true; + } + } + /*if (e.getBlock().getType()==Material.PUMPKIN) { this.plugin.gainMoneyExp(p,"Farmer",0.00,1); } if (e.getBlock().getType()==Material.MELON_BLOCK) { this.plugin.gainMoneyExp(p,"Farmer",0.10,10); }*/ - if (this.plugin.PlayerinJob(p,"Farmer")) { - boolean crafteditem=false; - if (item.getType()==Material.MELON) { - this.plugin.gainMoneyExp(p,"Farmer",0.10,10); - crafteditem=true; - } - if (item.getType()==Material.PUMPKIN_SEEDS) { - this.plugin.gainMoneyExp(p,"Farmer",0.04,8); - crafteditem=true; - } - } - if (this.plugin.PlayerinJob(p,"Cook")) { - boolean crafteditem=false; - if (item.getType()==Material.BREAD) { - this.plugin.gainMoneyExp(p,"Cook",0.003125*amount,1.25*amount); - crafteditem=true; - } - if (item.getType()==Material.COOKIE) { - this.plugin.gainMoneyExp(p,"Cook",0.016875*amount,1.50*amount); - crafteditem=true; - } - if (item.getType()==Material.MUSHROOM_SOUP) { - this.plugin.gainMoneyExp(p,"Cook",0.009375*amount,3.75*amount); - crafteditem=true; - } - if (item.getType()==Material.PUMPKIN_PIE) { - this.plugin.gainMoneyExp(p,"Cook",0.0375*amount,15*amount); - crafteditem=true; - } - if (item.getType()==Material.GOLDEN_CARROT) { - this.plugin.gainMoneyExp(p,"Cook",0.0875*amount,35*amount); - crafteditem=true; - } - if (item.getType()==Material.CAKE) { - this.plugin.gainMoneyExp(p,"Cook",0.10625*amount,21.25*amount); - crafteditem=true; - } - if (item.getType()==Material.GOLDEN_APPLE) { - this.plugin.gainMoneyExp(p,"Cook",0.1125*amount,45*amount); - crafteditem=true; - } - if (this.plugin.getJobLv("Cook", p)>=10 && crafteditem==true) { - //This is an ugly fix for the problem...But it works somehow. - //Player newp = Bukkit.getPlayer(p.getName()); - p.getInventory().addItem(new ItemStack(item.getType(),amount,item.getDurability(),item.getData().getData())); - } - } - /* + if (this.plugin.PlayerinJob(p,"Farmer")) { + boolean crafteditem=false; + if (item.getType()==Material.MELON) { + this.plugin.gainMoneyExp(p,"Farmer",0.10,10); + crafteditem=true; + } + if (item.getType()==Material.PUMPKIN_SEEDS) { + this.plugin.gainMoneyExp(p,"Farmer",0.04,8); + crafteditem=true; + } + } + if (this.plugin.PlayerinJob(p,"Cook")) { + boolean crafteditem=false; + if (item.getType()==Material.BREAD) { + this.plugin.gainMoneyExp(p,"Cook",0.003125*amount,1.25*amount); + crafteditem=true; + } + if (item.getType()==Material.COOKIE) { + this.plugin.gainMoneyExp(p,"Cook",0.016875*amount,1.50*amount); + crafteditem=true; + } + if (item.getType()==Material.MUSHROOM_SOUP) { + this.plugin.gainMoneyExp(p,"Cook",0.009375*amount,3.75*amount); + crafteditem=true; + } + if (item.getType()==Material.PUMPKIN_PIE) { + this.plugin.gainMoneyExp(p,"Cook",0.0375*amount,15*amount); + crafteditem=true; + } + if (item.getType()==Material.GOLDEN_CARROT) { + this.plugin.gainMoneyExp(p,"Cook",0.0875*amount,35*amount); + crafteditem=true; + } + if (item.getType()==Material.CAKE) { + this.plugin.gainMoneyExp(p,"Cook",0.10625*amount,21.25*amount); + crafteditem=true; + } + if (item.getType()==Material.GOLDEN_APPLE) { + this.plugin.gainMoneyExp(p,"Cook",0.1125*amount,45*amount); + crafteditem=true; + } + if (this.plugin.getJobLv("Cook", p)>=10 && crafteditem==true) { + //This is an ugly fix for the problem...But it works somehow. + //Player newp = Bukkit.getPlayer(p.getName()); + p.getInventory().addItem(new ItemStack(item.getType(),amount,item.getDurability(),item.getData().getData())); + } + } + /* if (this.plugin.PlayerinJob(p,"Support")) { if (item.getType()==Material.BREAD) { this.plugin.gainMoneyExp(p,"Support",0.015*amount,2*amount); @@ -9966,212 +10330,212 @@ public ItemStack getGoodie() { this.plugin.gainMoneyExp(p,"Support",0.03*amount,2*amount); } }*/ - } - + } + private void handleCrafting(InventoryClickEvent event) { - - HumanEntity player = event.getWhoClicked(); - ItemStack toCraft = event.getCurrentItem(); - ItemStack toStore = event.getCursor(); - - // Make sure we are actually crafting anything - if (player != null && hasItems(toCraft)) { - - if (event.isShiftClick()) { - // Hack ahoy - schedulePostDetection(player, toCraft); - } else { - // The items are stored in the cursor. Make sure there's enough space. - if (isStackSumLegal(toCraft, toStore)) { - int newItemsCount = toCraft.getAmount(); - - rewardCraft(toCraft,newItemsCount,player); - } - } - } + + HumanEntity player = event.getWhoClicked(); + ItemStack toCraft = event.getCurrentItem(); + ItemStack toStore = event.getCursor(); + + // Make sure we are actually crafting anything + if (player != null && hasItems(toCraft)) { + + if (event.isShiftClick()) { + // Hack ahoy + schedulePostDetection(player, toCraft); + } else { + // The items are stored in the cursor. Make sure there's enough space. + if (isStackSumLegal(toCraft, toStore)) { + int newItemsCount = toCraft.getAmount(); + + rewardCraft(toCraft,newItemsCount,player); + } + } + } } - + public String[] getJobs(Player p) { return this.plugin.getJobs(p); } - + public String[] getJobs(String p) { return this.plugin.getJobs(p); } - + public boolean PlayerinJob(String p,String job) { return this.plugin.PlayerinJob(p, job); } - + public boolean PlayerinJob(Player p,String job) { return this.plugin.PlayerinJob(p, job); } - + public int getJobLv(String job, String p) { return this.plugin.getJobLv(job, p); } - + public boolean validItem_Weaponsmith(ItemStack i) { if (i.getType()==Material.ARROW || - //i.getType()==Material.WOODEN_SWORD || - i.getType()==Material.FLINT_AND_STEEL || - i.getType()==Material.BOW || - i.getType()==Material.IRON_SWORD || - i.getType()==Material.GOLD_SWORD || - i.getType()==Material.DIAMOND_SWORD) { + //i.getType()==Material.WOODEN_SWORD || + i.getType()==Material.FLINT_AND_STEEL || + i.getType()==Material.BOW || + i.getType()==Material.IRON_SWORD || + i.getType()==Material.GOLD_SWORD || + i.getType()==Material.DIAMOND_SWORD) { return true; } - else { + else { return false; - } + } } - + public boolean validItem_Blacksmith(ItemStack i) { if (i.getType()==Material.LEATHER_BOOTS || - //i.getType()==Material.WOODEN_SWORD || - i.getType()==Material.LEATHER_HELMET || - i.getType()==Material.LEATHER_LEGGINGS || - i.getType()==Material.LEATHER_CHESTPLATE || - i.getType()==Material.IRON_SPADE || - i.getType()==Material.IRON_HOE || - i.getType()==Material.IRON_BOOTS || - i.getType()==Material.IRON_PICKAXE || - i.getType()==Material.IRON_LEGGINGS || - i.getType()==Material.IRON_CHESTPLATE || - i.getType()==Material.IRON_HELMET || - i.getType()==Material.IRON_AXE || - i.getType()==Material.GOLD_SPADE || - i.getType()==Material.GOLD_HOE || - i.getType()==Material.GOLD_BOOTS || - i.getType()==Material.GOLD_CHESTPLATE || - i.getType()==Material.GOLD_LEGGINGS || - i.getType()==Material.GOLD_HELMET || - i.getType()==Material.GOLD_AXE || - i.getType()==Material.DIAMOND_PICKAXE || - i.getType()==Material.DIAMOND_HOE || - i.getType()==Material.DIAMOND_SPADE || - i.getType()==Material.DIAMOND_AXE || - i.getType()==Material.DIAMOND_HELMET || - i.getType()==Material.DIAMOND_CHESTPLATE || - i.getType()==Material.DIAMOND_LEGGINGS || - i.getType()==Material.DIAMOND_BOOTS) { + //i.getType()==Material.WOODEN_SWORD || + i.getType()==Material.LEATHER_HELMET || + i.getType()==Material.LEATHER_LEGGINGS || + i.getType()==Material.LEATHER_CHESTPLATE || + i.getType()==Material.IRON_SPADE || + i.getType()==Material.IRON_HOE || + i.getType()==Material.IRON_BOOTS || + i.getType()==Material.IRON_PICKAXE || + i.getType()==Material.IRON_LEGGINGS || + i.getType()==Material.IRON_CHESTPLATE || + i.getType()==Material.IRON_HELMET || + i.getType()==Material.IRON_AXE || + i.getType()==Material.GOLD_SPADE || + i.getType()==Material.GOLD_HOE || + i.getType()==Material.GOLD_BOOTS || + i.getType()==Material.GOLD_CHESTPLATE || + i.getType()==Material.GOLD_LEGGINGS || + i.getType()==Material.GOLD_HELMET || + i.getType()==Material.GOLD_AXE || + i.getType()==Material.DIAMOND_PICKAXE || + i.getType()==Material.DIAMOND_HOE || + i.getType()==Material.DIAMOND_SPADE || + i.getType()==Material.DIAMOND_AXE || + i.getType()==Material.DIAMOND_HELMET || + i.getType()==Material.DIAMOND_CHESTPLATE || + i.getType()==Material.DIAMOND_LEGGINGS || + i.getType()==Material.DIAMOND_BOOTS) { return true; } - else { + else { return false; - } + } } - - + + public ItemStack EnchantItem(ItemStack item,int lv, Player p) { return this.plugin.EnchantItem(item, lv, p, true); } - + // HACK! The API doesn't allow us to easily determine the resulting number of // crafted items, so we're forced to compare the inventory before and after. private void schedulePostDetection(final HumanEntity player, final ItemStack compareItem) { - final ItemStack[] preInv = player.getInventory().getContents(); - final int ticks = 1; - - - // Clone the array. The content may (was for me) be mutable. - for (int i = 0; i < preInv.length; i++) { - preInv[i] = preInv[i] != null ? preInv[i].clone() : null; - } - Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { - @Override - public void run() { - final ItemStack[] postInv = player.getInventory().getContents(); - int newItemsCount = 0; - - for (int i = 0; i < preInv.length; i++) { - ItemStack pre = preInv[i]; - ItemStack post = postInv[i]; - if (pre!=null && post!=null) { - //See if they are the same item. - if (pre.getTypeId()==post.getTypeId() && pre.getDurability()==post.getDurability() && - pre.getItemMeta().equals(post.getItemMeta()) && pre.getEnchantments().equals(post.getEnchantments()) && - compareItem.getTypeId()==post.getTypeId() && compareItem.getDurability()==post.getDurability() && - compareItem.getItemMeta().equals(post.getItemMeta()) && compareItem.getEnchantments().equals(post.getEnchantments())) { - //See if the quantities differ. - newItemsCount += post.getAmount()-pre.getAmount(); - //Bukkit.getPlayer("sigonasr2").sendMessage("Item amounts differ. New count: "+newItemsCount); - } - } else { - if (post!=null) { - //pre is null, so we just add the amount. - if (compareItem.getTypeId()==post.getTypeId() && compareItem.getDurability()==post.getDurability() && - compareItem.getItemMeta().equals(post.getItemMeta()) && compareItem.getEnchantments().equals(post.getEnchantments())) { - newItemsCount += post.getAmount(); - //Do any enchants we need to do here. - if (PlayerinJob((Player)player,"Weaponsmith")) { - if (getJobLv("Weaponsmith", player.getName())>=10 && validItem_Weaponsmith(post)) { - //Bukkit.getPlayer("sigonasr2").sendMessage("Valid item. Going to attempt to enchant."); - ItemStack clone = post.clone(); - ItemStack resulting = EnchantItem(clone,5,(Player)player); - player.getInventory().setItem(i, resulting); - } - } - if (PlayerinJob((Player)player,"Blacksmith")) { - if (getJobLv("Blacksmith", player.getName())>=10 && validItem_Blacksmith(post)) { - //Bukkit.getPlayer("sigonasr2").sendMessage("Valid item. Going to attempt to enchant."); - ItemStack clone = post.clone(); - ItemStack resulting = EnchantItem(clone,10,(Player)player); - player.getInventory().setItem(i, resulting); - } else - if (getJobLv("Blacksmith", player.getName())>=5 && validItem_Blacksmith(post)) { - //Bukkit.getPlayer("sigonasr2").sendMessage("Valid item. Going to attempt to enchant."); - ItemStack clone = post.clone(); - ItemStack resulting = EnchantItem(clone,5,(Player)player); - player.getInventory().setItem(i, resulting); - } - } - } - //Bukkit.getPlayer("sigonasr2").sendMessage("Item amounts differ. New count: "+newItemsCount); - } - } - } - - if (newItemsCount > 0) { - //Bukkit.getPlayer("AaMay").sendMessage(newItemsCount+" New Items have been detected."); - if (plugin.getAccountsConfig().getBoolean(player.getName()+".settings.notify2")) { - if (special_convert(compareItem.getType())) { - Bukkit.getPlayer(player.getName()).sendMessage(ChatColor.DARK_AQUA+""+ChatColor.ITALIC+"Crafted "+newItemsCount+" "+convertToItemName(compareItem.getType().name(), compareItem.getData().getData(), compareItem.getType())+"."); - } else { - Bukkit.getPlayer(player.getName()).sendMessage(ChatColor.DARK_AQUA+""+ChatColor.ITALIC+"Crafted "+newItemsCount+" "+convertToItemName(compareItem.getType().name())+"."); - } - } - rewardCraft(compareItem,newItemsCount,player); - } - } - }, ticks); + final ItemStack[] preInv = player.getInventory().getContents(); + final int ticks = 1; + + + // Clone the array. The content may (was for me) be mutable. + for (int i = 0; i < preInv.length; i++) { + preInv[i] = preInv[i] != null ? preInv[i].clone() : null; + } + Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { + @Override + public void run() { + final ItemStack[] postInv = player.getInventory().getContents(); + int newItemsCount = 0; + + for (int i = 0; i < preInv.length; i++) { + ItemStack pre = preInv[i]; + ItemStack post = postInv[i]; + if (pre!=null && post!=null) { + //See if they are the same item. + if (pre.getTypeId()==post.getTypeId() && pre.getDurability()==post.getDurability() && + pre.getItemMeta().equals(post.getItemMeta()) && pre.getEnchantments().equals(post.getEnchantments()) && + compareItem.getTypeId()==post.getTypeId() && compareItem.getDurability()==post.getDurability() && + compareItem.getItemMeta().equals(post.getItemMeta()) && compareItem.getEnchantments().equals(post.getEnchantments())) { + //See if the quantities differ. + newItemsCount += post.getAmount()-pre.getAmount(); + //Bukkit.getPlayer("sigonasr2").sendMessage("Item amounts differ. New count: "+newItemsCount); + } + } else { + if (post!=null) { + //pre is null, so we just add the amount. + if (compareItem.getTypeId()==post.getTypeId() && compareItem.getDurability()==post.getDurability() && + compareItem.getItemMeta().equals(post.getItemMeta()) && compareItem.getEnchantments().equals(post.getEnchantments())) { + newItemsCount += post.getAmount(); + //Do any enchants we need to do here. + if (PlayerinJob((Player)player,"Weaponsmith")) { + if (getJobLv("Weaponsmith", player.getName())>=10 && validItem_Weaponsmith(post)) { + //Bukkit.getPlayer("sigonasr2").sendMessage("Valid item. Going to attempt to enchant."); + ItemStack clone = post.clone(); + ItemStack resulting = EnchantItem(clone,5,(Player)player); + player.getInventory().setItem(i, resulting); + } + } + if (PlayerinJob((Player)player,"Blacksmith")) { + if (getJobLv("Blacksmith", player.getName())>=10 && validItem_Blacksmith(post)) { + //Bukkit.getPlayer("sigonasr2").sendMessage("Valid item. Going to attempt to enchant."); + ItemStack clone = post.clone(); + ItemStack resulting = EnchantItem(clone,10,(Player)player); + player.getInventory().setItem(i, resulting); + } else + if (getJobLv("Blacksmith", player.getName())>=5 && validItem_Blacksmith(post)) { + //Bukkit.getPlayer("sigonasr2").sendMessage("Valid item. Going to attempt to enchant."); + ItemStack clone = post.clone(); + ItemStack resulting = EnchantItem(clone,5,(Player)player); + player.getInventory().setItem(i, resulting); + } + } + } + //Bukkit.getPlayer("sigonasr2").sendMessage("Item amounts differ. New count: "+newItemsCount); + } + } + } + + if (newItemsCount > 0) { + //Bukkit.getPlayer("AaMay").sendMessage(newItemsCount+" New Items have been detected."); + if (plugin.getAccountsConfig().getBoolean(player.getName()+".settings.notify2")) { + if (special_convert(compareItem.getType())) { + Bukkit.getPlayer(player.getName()).sendMessage(ChatColor.DARK_AQUA+""+ChatColor.ITALIC+"Crafted "+newItemsCount+" "+convertToItemName(compareItem.getType().name(), compareItem.getData().getData(), compareItem.getType())+"."); + } else { + Bukkit.getPlayer(player.getName()).sendMessage(ChatColor.DARK_AQUA+""+ChatColor.ITALIC+"Crafted "+newItemsCount+" "+convertToItemName(compareItem.getType().name())+"."); + } + } + rewardCraft(compareItem,newItemsCount,player); + } + } + }, ticks); } - + private boolean hasSameItem(ItemStack a, ItemStack b) { - if (a == null) - return b == null; - else if (b == null) - return a == null; - return a.getTypeId() == b.getTypeId() && - a.getDurability() == b.getDurability() && - ((a.getItemMeta()!=null && b.getItemMeta()!=null)?Objects.equal(a.getItemMeta(), b.getItemMeta()):true) && - ((a.getEnchantments()!=null && b.getEnchantments()!=null)?Objects.equal(a.getEnchantments(), b.getEnchantments()):true); + if (a == null) + return b == null; + else if (b == null) + return a == null; + return a.getTypeId() == b.getTypeId() && + a.getDurability() == b.getDurability() && + ((a.getItemMeta()!=null && b.getItemMeta()!=null)?Objects.equal(a.getItemMeta(), b.getItemMeta()):true) && + ((a.getEnchantments()!=null && b.getEnchantments()!=null)?Objects.equal(a.getEnchantments(), b.getEnchantments()):true); } - + private boolean hasItems(ItemStack stack) { - return stack != null && stack.getAmount() > 0; - } - + return stack != null && stack.getAmount() > 0; + } + private boolean isStackSumLegal(ItemStack a, ItemStack b) { - // See if we can create a new item stack with the combined elements of a and b - if (a == null || b == null) - return true; // Treat null as an empty stack - else - return a.getAmount() + b.getAmount() <= a.getType().getMaxStackSize(); + // See if we can create a new item stack with the combined elements of a and b + if (a == null || b == null) + return true; // Treat null as an empty stack + else + return a.getAmount() + b.getAmount() <= a.getType().getMaxStackSize(); } - /*@EventHandler + /*@EventHandler public void onItemSpawn(ItemSpawnEvent e) { if (e.getEntity().getType()==EntityType.DROPPED_ITEM) { if (e.getEntity().getItemStack().getType()==Material.IRON_ORE) { @@ -10182,114 +10546,114 @@ public ItemStack getGoodie() { return; } } - */ - @EventHandler - public void onItemDespawn(ItemDespawnEvent e) { - Item i = e.getEntity(); - Player p = Bukkit.getPlayer("sigonasr2"); - boolean allow=true; - if (this.plugin.getConfig().getBoolean("halloween-enabled") && ( - i.getItemStack().getType()==Material.PUMPKIN_PIE || - i.getItemStack().getType()==Material.SUGAR || - i.getItemStack().getType()==Material.PUMPKIN || - i.getItemStack().getType()==Material.EGG - )) { - allow=false; - } - //p.sendMessage("Item "+i.getItemStack().getItemMeta().getDisplayName()+" despawned.");// <-- CHECK THIS FOR NULL TO DETERMINE IF IT'S A REAL ITEM. - //String metastring = "Has name: "+i.getItemStack().getItemMeta().hasDisplayName(); - //p.sendMessage(metastring); - if (allow) { - //Find the nearest recycling center to dump to...usually. - RecyclingCenterNode center = null; - double distance = 99999999d; - for (int j=0;j0) { - if (i.getWorld()==this.plugin.recycling_center_list.get(j).locations.get(0).getWorld() && i.getLocation().distanceSquared(this.plugin.recycling_center_list.get(j).locations.get(0))0) { - if (center1==null) { - //Choose one randomly, if it's not equal to center2. - int randomnumb = (int)(Math.random()*this.plugin.recycling_center_list.size()); - if (center2==null) { - center1=this.plugin.recycling_center_list.get(randomnumb); - } else { - if (!center2.equals(this.plugin.recycling_center_list.get(randomnumb))) { - center1=this.plugin.recycling_center_list.get(randomnumb); - } - } - } - if (center2==null) { - //Choose one randomly, if it's not equal to center2. - int randomnumb = (int)(Math.random()*this.plugin.recycling_center_list.size()); - if (center1==null) { - center2=this.plugin.recycling_center_list.get(randomnumb); - } else { - if (!center1.equals(this.plugin.recycling_center_list.get(randomnumb))) { - center2=this.plugin.recycling_center_list.get(randomnumb); - } - } - } - if (center1==null || center2==null) { - maxiterator--; - } else { - maxiterator=0; - } - } - if (center1!=null && center2!=null) { - //Do a swap. - center1.swapItem(center2); - } - } - } - } - return; + */ + @EventHandler + public void onItemDespawn(ItemDespawnEvent e) { + Item i = e.getEntity(); + Player p = Bukkit.getPlayer("sigonasr2"); + boolean allow=true; + if (this.plugin.getConfig().getBoolean("halloween-enabled") && ( + i.getItemStack().getType()==Material.PUMPKIN_PIE || + i.getItemStack().getType()==Material.SUGAR || + i.getItemStack().getType()==Material.PUMPKIN || + i.getItemStack().getType()==Material.EGG + )) { + allow=false; + } + //p.sendMessage("Item "+i.getItemStack().getItemMeta().getDisplayName()+" despawned.");// <-- CHECK THIS FOR NULL TO DETERMINE IF IT'S A REAL ITEM. + //String metastring = "Has name: "+i.getItemStack().getItemMeta().hasDisplayName(); + //p.sendMessage(metastring); + if (allow) { + //Find the nearest recycling center to dump to...usually. + RecyclingCenterNode center = null; + double distance = 99999999d; + for (int j=0;j0) { + if (i.getWorld()==this.plugin.recycling_center_list.get(j).locations.get(0).getWorld() && i.getLocation().distanceSquared(this.plugin.recycling_center_list.get(j).locations.get(0))0) { + if (center1==null) { + //Choose one randomly, if it's not equal to center2. + int randomnumb = (int)(Math.random()*this.plugin.recycling_center_list.size()); + if (center2==null) { + center1=this.plugin.recycling_center_list.get(randomnumb); + } else { + if (!center2.equals(this.plugin.recycling_center_list.get(randomnumb))) { + center1=this.plugin.recycling_center_list.get(randomnumb); + } + } + } + if (center2==null) { + //Choose one randomly, if it's not equal to center2. + int randomnumb = (int)(Math.random()*this.plugin.recycling_center_list.size()); + if (center1==null) { + center2=this.plugin.recycling_center_list.get(randomnumb); + } else { + if (!center1.equals(this.plugin.recycling_center_list.get(randomnumb))) { + center2=this.plugin.recycling_center_list.get(randomnumb); + } + } + } + if (center1==null || center2==null) { + maxiterator--; + } else { + maxiterator=0; + } + } + if (center1!=null && center2!=null) { + //Do a swap. + center1.swapItem(center2); + } + } + } + } + return; } - //c.getBlockInventory().getSize(); - /* + //c.getBlockInventory().getSize(); + /* if (Bukkit.getWorld("world").getBlockAt(l).getType()==Material.CHEST) { p.sendMessage("Added item "+i.getItemStack().getTypeId()+" to chest."); Chest c = (Chest)Bukkit.getWorld("world").getBlockAt(l1).getState(); c.getBlockInventory(). c.getBlockInventory().addItem(i.getItemStack()); }*/ - /*// WORKING ITEM CODE. + /*// WORKING ITEM CODE. Location l = new Location(Bukkit.getWorld("world"), 1617, 67, -351); if (Bukkit.getWorld("world").getBlockAt(l).getType()==Material.CHEST) { p.sendMessage("Added item to chest."); Chest c = (Chest)Bukkit.getWorld("world").getBlockAt(l).getState(); c.getBlockInventory().addItem(i.getItemStack()); } - */ + */ - /* + /* @EventHandler public void onDamage(EntityDamageEvent e) { if (e.getEntity().getType() == EntityType.PLAYER) { @@ -10317,27 +10681,27 @@ public ItemStack getGoodie() { //p.setDisplayName(ChatColor.RED+"TEST"); //p.setPlayerListName(ChatColor.RED+"TEST"); } - */ - @EventHandler - public void onRedstoneChange(BlockRedstoneEvent e) { - if (e.getBlock().getType()==Material.REDSTONE_LAMP_ON || e.getBlock().getType()==Material.REDSTONE_LAMP_OFF) { - if (e.getBlock().getX()>=1562 && e.getBlock().getX()<=1644 && e.getBlock().getY()>=64 && e.getBlock().getY()<=79 && e.getBlock().getZ()>=-357 && e.getBlock().getZ()<=-211) { - e.setNewCurrent(15); - } - } - } + */ + @EventHandler + public void onRedstoneChange(BlockRedstoneEvent e) { + if (e.getBlock().getType()==Material.REDSTONE_LAMP_ON || e.getBlock().getType()==Material.REDSTONE_LAMP_OFF) { + if (e.getBlock().getX()>=1562 && e.getBlock().getX()<=1644 && e.getBlock().getY()>=64 && e.getBlock().getY()<=79 && e.getBlock().getZ()>=-357 && e.getBlock().getZ()<=-211) { + e.setNewCurrent(15); + } + } + } - @EventHandler -public void onMinecartExit(VehicleExitEvent e) { - if (e.getVehicle().getType()==EntityType.MINECART && e.getVehicle().getPassenger().getType()==EntityType.PLAYER && ((Player)e.getVehicle().getPassenger()).isOnline()) { - Bukkit.getWorld("world").dropItemNaturally(e.getVehicle().getLocation(),new ItemStack(Material.MINECART)); - e.getVehicle().remove(); - } - } - - @EventHandler -public void onMinecartEnter(VehicleEnterEvent e) { - /*if (e.getEntered().getType()==EntityType.PLAYER) { + @EventHandler + public void onMinecartExit(VehicleExitEvent e) { + if (e.getVehicle().getType()==EntityType.MINECART && e.getVehicle().getPassenger().getType()==EntityType.PLAYER && ((Player)e.getVehicle().getPassenger()).isOnline()) { + Bukkit.getWorld("world").dropItemNaturally(e.getVehicle().getLocation(),new ItemStack(Material.MINECART)); + e.getVehicle().remove(); + } + } + + @EventHandler + public void onMinecartEnter(VehicleEnterEvent e) { + /*if (e.getEntered().getType()==EntityType.PLAYER) { if (e.getVehicle().getType()==EntityType.MINECART) { Minecart m = (Minecart)e.getVehicle(); if (e.getEntered().getLocation().getBlockZ()==-328 || e.getEntered().getLocation().getBlockZ()==-316) { @@ -10347,8 +10711,8 @@ public void onMinecartEnter(VehicleEnterEvent e) { } } }*/ - } - /* + } + /* @EventHandler public void onEntityEvent(EntityEvent e) { return; @@ -10356,7 +10720,7 @@ public void onMinecartEnter(VehicleEnterEvent e) { LivingEntity f = (LivingEntity)e.getEntity(); if (f.getCustomName()!=null && (f.getCustomName().compareTo("&eCharge Zombie")==0 || f.getCustomName().compareTo("&6Charge Zombie II")==0)) { //Destroy blocks around it. - + boolean doit=true; if (f.getKiller()!=null && f.getKiller().getLocation().getY()>f.getLocation().getY()) { doit=false; @@ -10379,73 +10743,73 @@ public void onMinecartEnter(VehicleEnterEvent e) { } } }*/ - -@EventHandler -public void onShootArrow(ProjectileHitEvent e) { - LivingEntity l = e.getEntity().getShooter(); - if (l!=null && l.getType()==EntityType.SKELETON && l.getCustomName()!=null) { - if ((l.getCustomName().compareTo(ChatColor.YELLOW+"Sniper")==0)) { - boolean found=false; - if (!found) { - //Create a new shooter from this skeleton only if they are not shooting already. - this.plugin.ARROW_SHOOTERS.add(new ArrowShooter(e.getEntity().getVelocity(), e.getEntity().getLocation(),50,10,l)); - } - } else - if (l.getCustomName().compareTo(ChatColor.GOLD+"Sniper II")==0) { - boolean found=false; - if (!found) { - //Create a new shooter from this skeleton only if they are not shooting already. - for (int i=-2;i<3;i+=2) { - this.plugin.ARROW_SHOOTERS.add(new ArrowShooter(e.getEntity().getVelocity(), e.getEntity().getLocation().add(0,i,0),50,5,l)); - this.plugin.ARROW_SHOOTERS.add(new ArrowShooter(e.getEntity().getVelocity(), e.getEntity().getLocation().add(0,i,0),50,5,l)); + + @EventHandler + public void onShootArrow(ProjectileHitEvent e) { + LivingEntity l = e.getEntity().getShooter(); + if (l!=null && l.getType()==EntityType.SKELETON && l.getCustomName()!=null) { + if ((l.getCustomName().compareTo(ChatColor.YELLOW+"Sniper")==0)) { + boolean found=false; + if (!found) { + //Create a new shooter from this skeleton only if they are not shooting already. + this.plugin.ARROW_SHOOTERS.add(new ArrowShooter(e.getEntity().getVelocity(), e.getEntity().getLocation(),50,10,l)); + } + } else + if (l.getCustomName().compareTo(ChatColor.GOLD+"Sniper II")==0) { + boolean found=false; + if (!found) { + //Create a new shooter from this skeleton only if they are not shooting already. + for (int i=-2;i<3;i+=2) { + this.plugin.ARROW_SHOOTERS.add(new ArrowShooter(e.getEntity().getVelocity(), e.getEntity().getLocation().add(0,i,0),50,5,l)); + this.plugin.ARROW_SHOOTERS.add(new ArrowShooter(e.getEntity().getVelocity(), e.getEntity().getLocation().add(0,i,0),50,5,l)); + } + } } - } } } -} -@EventHandler -public void onEntityExpode(ExplosionPrimeEvent e) { - //Bukkit.getPlayer("AaMay").sendMessage("Entity Type: "+e.getEntity().getType().getName()); - if (e.getEntity().getType()==EntityType.CREEPER) { - LivingEntity c = (LivingEntity)e.getEntity(); - //Bukkit.getPlayer("AaMay").sendMessage("A Creeper exploded."); - if (c.getCustomName()!=null) { - //Bukkit.getPlayer("AaMay").sendMessage("Detected a name."); - if (c.getCustomName().compareTo(ChatColor.YELLOW+"Explosive Creeper")==0) { - Bukkit.getWorld("world").createExplosion(c.getLocation().getX(),c.getLocation().getY(),c.getLocation().getZ(),3f,false,true); - //Bukkit.getPlayer("AaMay").sendMessage("Sent explosion"); - e.setCancelled(true); - //e.setRadius(3f); - //e.setFire(false); - } else - if (c.getCustomName().compareTo(ChatColor.GOLD+"Explosive Creeper II")==0) { - Bukkit.getWorld("world").createExplosion(c.getLocation().getX(),c.getLocation().getY(),c.getLocation().getZ(),5f,false,true); - //Bukkit.getPlayer("AaMay").sendMessage("Sent explosion"); - e.setCancelled(true); - //e.setRadius(5f); - //e.setFire(false); - } else - if (c.getCustomName().compareTo(ChatColor.YELLOW+"Destructive Creeper")==0) { - Bukkit.getWorld("world").createExplosion(c.getLocation().getX(),c.getLocation().getY(),c.getLocation().getZ(),2f,true,true); - //Bukkit.getPlayer("AaMay").sendMessage("Sent explosion"); - e.setCancelled(true); - //e.setRadius(2f); - //e.setFire(true); - } else - if (c.getCustomName().compareTo(ChatColor.GOLD+"Destructive Creeper II")==0) { - Bukkit.getWorld("world").createExplosion(c.getLocation().getX(),c.getLocation().getY(),c.getLocation().getZ(),4f,true,true); - //Bukkit.getPlayer("AaMay").sendMessage("Sent explosion"); - e.setCancelled(true); - //e.setRadius(4f); - //e.setFire(true); + @EventHandler + public void onEntityExpode(ExplosionPrimeEvent e) { + //Bukkit.getPlayer("AaMay").sendMessage("Entity Type: "+e.getEntity().getType().getName()); + if (e.getEntity().getType()==EntityType.CREEPER) { + LivingEntity c = (LivingEntity)e.getEntity(); + //Bukkit.getPlayer("AaMay").sendMessage("A Creeper exploded."); + if (c.getCustomName()!=null) { + //Bukkit.getPlayer("AaMay").sendMessage("Detected a name."); + if (c.getCustomName().compareTo(ChatColor.YELLOW+"Explosive Creeper")==0) { + Bukkit.getWorld("world").createExplosion(c.getLocation().getX(),c.getLocation().getY(),c.getLocation().getZ(),3f,false,true); + //Bukkit.getPlayer("AaMay").sendMessage("Sent explosion"); + e.setCancelled(true); + //e.setRadius(3f); + //e.setFire(false); + } else + if (c.getCustomName().compareTo(ChatColor.GOLD+"Explosive Creeper II")==0) { + Bukkit.getWorld("world").createExplosion(c.getLocation().getX(),c.getLocation().getY(),c.getLocation().getZ(),5f,false,true); + //Bukkit.getPlayer("AaMay").sendMessage("Sent explosion"); + e.setCancelled(true); + //e.setRadius(5f); + //e.setFire(false); + } else + if (c.getCustomName().compareTo(ChatColor.YELLOW+"Destructive Creeper")==0) { + Bukkit.getWorld("world").createExplosion(c.getLocation().getX(),c.getLocation().getY(),c.getLocation().getZ(),2f,true,true); + //Bukkit.getPlayer("AaMay").sendMessage("Sent explosion"); + e.setCancelled(true); + //e.setRadius(2f); + //e.setFire(true); + } else + if (c.getCustomName().compareTo(ChatColor.GOLD+"Destructive Creeper II")==0) { + Bukkit.getWorld("world").createExplosion(c.getLocation().getX(),c.getLocation().getY(),c.getLocation().getZ(),4f,true,true); + //Bukkit.getPlayer("AaMay").sendMessage("Sent explosion"); + e.setCancelled(true); + //e.setRadius(4f); + //e.setFire(true); + } } } + //Bukkit.broadcastMessage("Explosion occurs."); } - //Bukkit.broadcastMessage("Explosion occurs."); -} - -/* + + /* @SuppressWarnings("deprecation") @EventHandler public void onPlayerMove(PlayerMoveEvent e) { @@ -10458,8 +10822,8 @@ public void onEntityExpode(ExplosionPrimeEvent e) { //You lose. //See if we're the winner. int countdead=0; //We're looking for 3. - - + + Player winningplayer = p,losingplayer = p; if (this.plugin.getConfig().getString("spleefrequesta4player").compareTo("none")==0) { countdead++; @@ -10499,14 +10863,14 @@ public void onEntityExpode(ExplosionPrimeEvent e) { } if (countdead==2) { this.plugin.getConfig().set("spleef4insession", Boolean.valueOf(false)); - - - - + + + + //Stand someplace else when you win. - - + + //Losing player has losing player stuff happen. //This was a player that lost. //Move them out, give them back their stuff. @@ -10548,7 +10912,7 @@ public void onEntityExpode(ExplosionPrimeEvent e) { this.plugin.getConfig().set("spleefrequestd4player",String.valueOf("none")); } Bukkit.broadcastMessage(ChatColor.RED+"[SPLEEF] "+ChatColor.YELLOW+p.getName()+" fell out of the arena and is out of the match!"); - + newloc = winningplayer.getLocation(); newloc.setX(1583); @@ -10642,7 +11006,7 @@ public void onEntityExpode(ExplosionPrimeEvent e) { this.plugin.getConfig().set("spleefrequestd4player",String.valueOf("none")); } Bukkit.broadcastMessage(ChatColor.RED+"[SPLEEF] "+ChatColor.YELLOW+p.getName()+" fell out of the arena and is out of the match!"); - + } } //Check to see if we are a player in spleef. @@ -10656,7 +11020,7 @@ public void onEntityExpode(ExplosionPrimeEvent e) { } } } - + if (this.plugin.getConfig().getBoolean("spleefinsession") && (p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestaplayer"))==0 || p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestbplayer"))==0)) { //Determine if we're still playing. int blockwinner=0; @@ -10830,9 +11194,9 @@ public void onEntityExpode(ExplosionPrimeEvent e) { } } } - */ - - /* + */ + + /* @EventHandler public void onNameTag(PlayerReceiveNameTagEvent event) { //String event.getNamedPlayer().getName() @@ -10843,373 +11207,373 @@ public void onEntityExpode(ExplosionPrimeEvent e) { String secondpart=name.substring(firstpart.length(),name.length()-firstpart.length()); event.setTag(ChatColor.GREEN + firstpart + ChatColor.DARK_RED + secondpart); } -*/ - - @EventHandler - public void onPlayerLeave(PlayerQuitEvent e) { - Player p = e.getPlayer(); - for (int i=0;i=10) { - //Check to see if our "fatal s urvivor" effect is available. - for (int i=0;i drops = new ArrayList(); - for (int i=0;i=20) { - finalcost*=0.25; - } - if (mymoney>=mincost) { - p.sendMessage("You died. It will cost you $"+df.format(finalcost)+" to revive. To revive, type /revive me."); - } else { - p.sendMessage("You died. You do not have enough money in your bank to revive."); - p.sendMessage("Cost: $"+df.format(finalcost)+". If you want to revive, type "+ChatColor.AQUA+"/revive me"+ChatColor.WHITE+" when you have enough."); - } - } - } + if (shovelfound) { + Location l1 = new Location(Bukkit.getWorld("world"), 1622, 85, 58); + Chest c=(Chest)Bukkit.getWorld("world").getBlockAt(l1).getState(); + c.getBlockInventory().setItem((int)(Math.random()*27.0d), shovel); + }*/ + Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().clear(); + Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().clear(); + Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().clear(Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().getHeldItemSlot()); + Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().clear(Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().getHeldItemSlot()); + //Give inventories back. + for (int i=0;i=10) { + //Check to see if our "fatal s urvivor" effect is available. + for (int i=0;i drops = new ArrayList(); + for (int i=0;i=20) { + finalcost*=0.25; + } + if (mymoney>=mincost) { + p.sendMessage("You died. It will cost you $"+df.format(finalcost)+" to revive. To revive, type /revive me."); + } else { + p.sendMessage("You died. You do not have enough money in your bank to revive."); + p.sendMessage("Cost: $"+df.format(finalcost)+". If you want to revive, type "+ChatColor.AQUA+"/revive me"+ChatColor.WHITE+" when you have enough."); + } + } + } + + @EventHandler + public void onSignPlace(SignChangeEvent e) + { + Player p = e.getPlayer(); + String[] lines = e.getLines(); + updateTopSPLEEFSigns(); + if (p.hasPermission("bankeconomy.sign.create")) { + if ((lines[0].equalsIgnoreCase("[Bank]")) && (lines[1].equalsIgnoreCase("Deposit"))) { + e.setLine(0, ChatColor.DARK_GREEN + "[Bank]"); + e.setLine(1, ChatColor.DARK_RED + "Deposit"); + e.setLine(2, "Right-Click"); + e.setLine(3, "to use"); + } else + if ((lines[0].equalsIgnoreCase("[Bank]")) && (lines[1].equalsIgnoreCase("Withdraw"))) { + e.setLine(0, ChatColor.DARK_GREEN + "[Bank]"); + e.setLine(1, ChatColor.DARK_BLUE + "Withdraw"); + e.setLine(2, "Right-Click"); + e.setLine(3, "to use"); + } else + if ((lines[0].equalsIgnoreCase("[Bank]")) && (lines[1].equalsIgnoreCase("Check Balance"))) { + e.setLine(0, ChatColor.DARK_GREEN + "[Bank]"); + e.setLine(1, ChatColor.DARK_GRAY + "Check Balance"); + e.setLine(2, "Right-Click"); + e.setLine(3, "to use"); + } else { + if ((lines[0].equalsIgnoreCase("[Bank]"))) { + e.setCancelled(true); + p.sendMessage("�ァcYou do not have permission to create [Bank] signs."); + } + } + } + /* if (p.hasPermission("bankeconomy.sign.create")) { if ((lines[0].equalsIgnoreCase("[BankEconomy]")) && (lines[1].equalsIgnoreCase("deposit"))) { e.setLine(0, ChatColor.DARK_GREEN + "[BankEconomy]"); @@ -11265,151 +11629,151 @@ public void onEntityExpode(ExplosionPrimeEvent e) { p.sendMessage("�ァcYou do not have permission."); } }*/ - } - - public int getSongDuration(Material record) { - int padding=20; - if (record==Material.RECORD_3) { - return 345/2+5+padding; - } else - if (record==Material.RECORD_4) { - return 185/2+5+padding; - } else - if (record==Material.RECORD_5) { - return 174/2+5+padding; - } else - if (record==Material.RECORD_6) { - return 197/2+5+padding; - } else - if (record==Material.RECORD_7) { - return 96/2+5+padding; - } else - if (record==Material.RECORD_8) { - return 150/2+5+padding; - } else - if (record==Material.RECORD_9) { - return 188/2+5+padding; - } else - if (record==Material.RECORD_10) { - return 251/2+5+padding; - } else - if (record==Material.RECORD_11) { - return 71/2+5+padding; - } else - if (record==Material.RECORD_12) { - return 238/2+5+padding; - } else - if (record==Material.GOLD_RECORD) { - return 178/2+5+padding; - } else - if (record==Material.GREEN_RECORD) { - return 185/2+5+padding; - } else - return 0; - } - - @EventHandler - public void onPlayerChat(PlayerChatEvent e) { - //Check if they are withdrawing or depositing money. - DecimalFormat df = new DecimalFormat("#0.00"); - if (e.getPlayer().getName().equalsIgnoreCase(this.plugin.last_bank_deposit_user) && this.plugin.last_bank_deposit_use_time+200>Main.SERVER_TICK_TIME) { - //Parse the amount. - double val=0; - if (e.getMessage().equalsIgnoreCase("all")) { - //Deposit all the money into their account. - val = this.plugin.economy.getBalance(e.getPlayer().getName()); - this.plugin.economy.withdrawPlayer(e.getPlayer().getName(), val); - double mymoney = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"); - this.plugin.getAccountsConfig().set(e.getPlayer().getName() + ".money", Double.valueOf(mymoney+val)); - this.plugin.saveAccountsConfig(); - e.getPlayer().sendMessage(ChatColor.GREEN+"Deposited $" + df.format(val) + " into your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"))); - this.plugin.last_bank_deposit_use_time=0; - } else { - try { - val = Double.parseDouble(e.getMessage()); - //Make sure the user is holding at least that much money. - if (this.plugin.economy.getBalance(e.getPlayer().getName())>=val && val>0) { - //Deposit the money into their account. - //this.plugin.economy.bankDeposit(e.getPlayer().getName(), val); - this.plugin.economy.withdrawPlayer(e.getPlayer().getName(), val); - double mymoney = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"); - this.plugin.getAccountsConfig().set(e.getPlayer().getName() + ".money", Double.valueOf(mymoney+val)); - this.plugin.saveAccountsConfig(); - e.getPlayer().sendMessage(ChatColor.GREEN+"Deposited $" + df.format(val) + " into your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"))); - this.plugin.last_bank_deposit_use_time=0; - } else { - e.getPlayer().sendMessage(ChatColor.RED+"You are not holding that much! " + ChatColor.YELLOW +"Enter a value equal to or lower than $" + ChatColor.GREEN+ df.format(this.plugin.economy.getBalance(e.getPlayer().getName())) + "" + ChatColor.GRAY + ChatColor.ITALIC + " (Remember you can also use the word all)"); - this.plugin.last_bank_deposit_use_time=Main.SERVER_TICK_TIME; - } - } catch (NumberFormatException ex_e) { - e.getPlayer().sendMessage(ChatColor.RED+"That is not a valid amount! Please try again."); - this.plugin.last_bank_deposit_use_time=Main.SERVER_TICK_TIME; - } - } - e.setCancelled(true); - } else - if (e.getPlayer().getName().equalsIgnoreCase(this.plugin.last_bank_withdraw_user) && this.plugin.last_bank_withdraw_use_time+200>Main.SERVER_TICK_TIME) { - //Parse the amount. - double val=0; - if (e.getMessage().equalsIgnoreCase("all")) { - //Withdraw all the money in their account. - val = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"); - this.plugin.getAccountsConfig().set(e.getPlayer().getName() + ".money", Double.valueOf(0)); - this.plugin.saveAccountsConfig(); - this.plugin.economy.depositPlayer(e.getPlayer().getName(), val); - e.getPlayer().sendMessage(ChatColor.GREEN+"Withdrawed $" + df.format(val) + " from your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"))); - this.plugin.last_bank_withdraw_use_time=0; - } else { - try { - val = Double.parseDouble(e.getMessage()); - //Make sure the user is holding at least that much money. - if (this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money")>=val && val>0) { - //Deposit the money into their account. - //this.plugin.economy.bankDeposit(e.getPlayer().getName(), val); - this.plugin.economy.depositPlayer(e.getPlayer().getName(), val); - double mymoney = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"); - this.plugin.getAccountsConfig().set(e.getPlayer().getName() + ".money", Double.valueOf(mymoney-val)); - this.plugin.saveAccountsConfig(); - e.getPlayer().sendMessage(ChatColor.GREEN+"Withdrawed $" + df.format(val) + " from your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"))); - this.plugin.last_bank_withdraw_use_time=0; - } else { - e.getPlayer().sendMessage(ChatColor.RED+"You do not have that much! " + ChatColor.YELLOW +"Enter a value equal to or lower than $" + ChatColor.GREEN+ df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money")) + "" + ChatColor.GRAY + ChatColor.ITALIC + " (Remember you can also use the word all)"); - this.plugin.last_bank_withdraw_use_time=Main.SERVER_TICK_TIME; - } - } catch (NumberFormatException ex_e) { - e.getPlayer().sendMessage(ChatColor.RED+"That is not a valid amount! Please try again."); - this.plugin.last_bank_withdraw_use_time=Main.SERVER_TICK_TIME; - } - } - e.setCancelled(true); - } else - { - if (e.getMessage().replaceAll("[0-9.]","").length()>0) { - Player[] playerlist = Bukkit.getOnlinePlayers(); - for (int i=0;iMain.SERVER_TICK_TIME) { + //Parse the amount. + double val=0; + if (e.getMessage().equalsIgnoreCase("all")) { + //Deposit all the money into their account. + val = this.plugin.economy.getBalance(e.getPlayer().getName()); + this.plugin.economy.withdrawPlayer(e.getPlayer().getName(), val); + double mymoney = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"); + this.plugin.getAccountsConfig().set(e.getPlayer().getName() + ".money", Double.valueOf(mymoney+val)); + this.plugin.saveAccountsConfig(); + e.getPlayer().sendMessage(ChatColor.GREEN+"Deposited $" + df.format(val) + " into your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"))); + this.plugin.last_bank_deposit_use_time=0; + } else { + try { + val = Double.parseDouble(e.getMessage()); + //Make sure the user is holding at least that much money. + if (this.plugin.economy.getBalance(e.getPlayer().getName())>=val && val>0) { + //Deposit the money into their account. + //this.plugin.economy.bankDeposit(e.getPlayer().getName(), val); + this.plugin.economy.withdrawPlayer(e.getPlayer().getName(), val); + double mymoney = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"); + this.plugin.getAccountsConfig().set(e.getPlayer().getName() + ".money", Double.valueOf(mymoney+val)); + this.plugin.saveAccountsConfig(); + e.getPlayer().sendMessage(ChatColor.GREEN+"Deposited $" + df.format(val) + " into your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"))); + this.plugin.last_bank_deposit_use_time=0; + } else { + e.getPlayer().sendMessage(ChatColor.RED+"You are not holding that much! " + ChatColor.YELLOW +"Enter a value equal to or lower than $" + ChatColor.GREEN+ df.format(this.plugin.economy.getBalance(e.getPlayer().getName())) + "" + ChatColor.GRAY + ChatColor.ITALIC + " (Remember you can also use the word all)"); + this.plugin.last_bank_deposit_use_time=Main.SERVER_TICK_TIME; + } + } catch (NumberFormatException ex_e) { + e.getPlayer().sendMessage(ChatColor.RED+"That is not a valid amount! Please try again."); + this.plugin.last_bank_deposit_use_time=Main.SERVER_TICK_TIME; + } + } + e.setCancelled(true); + } else + if (e.getPlayer().getName().equalsIgnoreCase(this.plugin.last_bank_withdraw_user) && this.plugin.last_bank_withdraw_use_time+200>Main.SERVER_TICK_TIME) { + //Parse the amount. + double val=0; + if (e.getMessage().equalsIgnoreCase("all")) { + //Withdraw all the money in their account. + val = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"); + this.plugin.getAccountsConfig().set(e.getPlayer().getName() + ".money", Double.valueOf(0)); + this.plugin.saveAccountsConfig(); + this.plugin.economy.depositPlayer(e.getPlayer().getName(), val); + e.getPlayer().sendMessage(ChatColor.GREEN+"Withdrawed $" + df.format(val) + " from your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"))); + this.plugin.last_bank_withdraw_use_time=0; + } else { + try { + val = Double.parseDouble(e.getMessage()); + //Make sure the user is holding at least that much money. + if (this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money")>=val && val>0) { + //Deposit the money into their account. + //this.plugin.economy.bankDeposit(e.getPlayer().getName(), val); + this.plugin.economy.depositPlayer(e.getPlayer().getName(), val); + double mymoney = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"); + this.plugin.getAccountsConfig().set(e.getPlayer().getName() + ".money", Double.valueOf(mymoney-val)); + this.plugin.saveAccountsConfig(); + e.getPlayer().sendMessage(ChatColor.GREEN+"Withdrawed $" + df.format(val) + " from your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"))); + this.plugin.last_bank_withdraw_use_time=0; + } else { + e.getPlayer().sendMessage(ChatColor.RED+"You do not have that much! " + ChatColor.YELLOW +"Enter a value equal to or lower than $" + ChatColor.GREEN+ df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money")) + "" + ChatColor.GRAY + ChatColor.ITALIC + " (Remember you can also use the word all)"); + this.plugin.last_bank_withdraw_use_time=Main.SERVER_TICK_TIME; + } + } catch (NumberFormatException ex_e) { + e.getPlayer().sendMessage(ChatColor.RED+"That is not a valid amount! Please try again."); + this.plugin.last_bank_withdraw_use_time=Main.SERVER_TICK_TIME; + } + } + e.setCancelled(true); + } else + { + if (e.getMessage().replaceAll("[0-9.]","").length()>0) { + Player[] playerlist = Bukkit.getOnlinePlayers(); + for (int i=0;i items = new ArrayList(); - screen=Bukkit.createInventory(p, 9, "Item Cube #"+identifier); + case SMALL: { + FileConfiguration f = this.plugin.reloadItemCubeConfig(identifier); + if (!f.contains("created")) { for (int i=0;i<9;i++) { - //items.add(f.getItemStack("item-"+i)); - screen.setItem(i, f.getItemStack("item-"+i)); + f.set("item-"+i, new ItemStack(Material.AIR)); } - this.plugin.saveItemCubeConfig(f, identifier); - }break; - case LARGE: { - FileConfiguration f = this.plugin.reloadItemCubeConfig(identifier); - if (!f.contains("created")) { - for (int i=0;i<54;i++) { - f.set("item-"+i, new ItemStack(Material.AIR)); - } - f.set("created", Boolean.valueOf(true)); - } - //List items = new ArrayList(); - screen=Bukkit.createInventory(p, 54, "Large Item Cube #"+identifier); + f.set("created", Boolean.valueOf(true)); + } + //List items = new ArrayList(); + screen=Bukkit.createInventory(p, 9, "Item Cube #"+identifier); + for (int i=0;i<9;i++) { + //items.add(f.getItemStack("item-"+i)); + screen.setItem(i, f.getItemStack("item-"+i)); + } + this.plugin.saveItemCubeConfig(f, identifier); + }break; + case LARGE: { + FileConfiguration f = this.plugin.reloadItemCubeConfig(identifier); + if (!f.contains("created")) { for (int i=0;i<54;i++) { - //items.add(f.getItemStack("item-"+i)); - screen.setItem(i, f.getItemStack("item-"+i)); - } - this.plugin.saveItemCubeConfig(f, identifier); - }break; - case ENDER: { - FileConfiguration f = this.plugin.reloadItemCubeConfig(identifier); - if (!f.contains("created")) { - for (int i=0;i<27;i++) { - f.set("item-"+i, new ItemStack(Material.AIR)); - } - f.set("created", Boolean.valueOf(true)); + f.set("item-"+i, new ItemStack(Material.AIR)); } - //List items = new ArrayList(); - screen=Bukkit.createInventory(p, 27, "Ender Item Cube #"+identifier); + f.set("created", Boolean.valueOf(true)); + } + //List items = new ArrayList(); + screen=Bukkit.createInventory(p, 54, "Large Item Cube #"+identifier); + for (int i=0;i<54;i++) { + //items.add(f.getItemStack("item-"+i)); + screen.setItem(i, f.getItemStack("item-"+i)); + } + this.plugin.saveItemCubeConfig(f, identifier); + }break; + case ENDER: { + FileConfiguration f = this.plugin.reloadItemCubeConfig(identifier); + if (!f.contains("created")) { for (int i=0;i<27;i++) { - //items.add(f.getItemStack("item-"+i)); - screen.setItem(i, f.getItemStack("item-"+i)); + f.set("item-"+i, new ItemStack(Material.AIR)); } - this.plugin.saveItemCubeConfig(f, identifier); - }break; + f.set("created", Boolean.valueOf(true)); + } + //List items = new ArrayList(); + screen=Bukkit.createInventory(p, 27, "Ender Item Cube #"+identifier); + for (int i=0;i<27;i++) { + //items.add(f.getItemStack("item-"+i)); + screen.setItem(i, f.getItemStack("item-"+i)); + } + this.plugin.saveItemCubeConfig(f, identifier); + }break; } if (screen!=null) { p.closeInventory(); p.openInventory(screen); } - } - } - - public boolean isViewingEnderCube(Player p) { - //Returns whether or not this player is viewing an ender cube. - //This is useful for determining if you have to update the ender cube for other viewers. - if (p.getOpenInventory().getTopInventory()!=null && p.getOpenInventory().getTopInventory().getTitle().contains("Ender Item Cube")) { - return true; - } else { - return false; - } - } - - public int getViewingEnderCubeID(Player p) { - //Returns whether or not this player is viewing an ender cube. - //This is useful for determining if you have to update the ender cube for other viewers. - if (p.getOpenInventory().getTopInventory()!=null && p.getOpenInventory().getTopInventory().getTitle().contains("Ender Item Cube")) { - return Integer.valueOf(p.getOpenInventory().getTopInventory().getTitle().substring(p.getOpenInventory().getTopInventory().getTitle().indexOf("#")).replace("#", "")); - } else { - return -1; //Invalid use. - } - } + } + } + + public boolean isViewingEnderCube(Player p) { + //Returns whether or not this player is viewing an ender cube. + //This is useful for determining if you have to update the ender cube for other viewers. + if (p.getOpenInventory().getTopInventory()!=null && p.getOpenInventory().getTopInventory().getTitle().contains("Ender Item Cube")) { + return true; + } else { + return false; + } + } + + public int getViewingEnderCubeID(Player p) { + //Returns whether or not this player is viewing an ender cube. + //This is useful for determining if you have to update the ender cube for other viewers. + if (p.getOpenInventory().getTopInventory()!=null && p.getOpenInventory().getTopInventory().getTitle().contains("Ender Item Cube")) { + return Integer.valueOf(p.getOpenInventory().getTopInventory().getTitle().substring(p.getOpenInventory().getTopInventory().getTitle().indexOf("#")).replace("#", "")); + } else { + return -1; //Invalid use. + } + } - public void ItemCube_updateSameEnderCube(int cube_id, Player player) { - //If a player attempts to do something in an Ender Cube, update the Ender Cube for all other viewers that is not player. (The player argument is the player making modifications to the inventory.) + public void ItemCube_updateSameEnderCube(int cube_id, Player player) { + //If a player attempts to do something in an Ender Cube, update the Ender Cube for all other viewers that is not player. (The player argument is the player making modifications to the inventory.) for (int i=0;i=insert_item.getAmount()) { //We can simply add it in no problem. thisinven.addItem(insert_item); - for (int i=0;i0) { - //We can at least fit a few. - int fit = insert_item.getAmount()-countinven; - //Leave behind this many. - ItemStack thisitem = insert_item, thisitem2 = insert_item; - thisitem.setAmount(fit); - //Bukkit.getPlayer("sigonasr2").sendMessage("Cursor gets "+thisitem.getAmount()); - thisitem2.setAmount(countinven); - thisinven.addItem(thisitem2); - if (size == Cube.ENDER) { - //This is an Ender Item Cube. We have to check if any other players are looking at the correspnding Ender Item Cube inventory. - ItemCube_addSameEnderCube(thisitem2, identifier, p); + if (countinven>0) { + //We can at least fit a few. + int fit = insert_item.getAmount()-countinven; + //Leave behind this many. + ItemStack thisitem = insert_item, thisitem2 = insert_item; + thisitem.setAmount(fit); + //Bukkit.getPlayer("sigonasr2").sendMessage("Cursor gets "+thisitem.getAmount()); + thisitem2.setAmount(countinven); + thisinven.addItem(thisitem2); + if (size == Cube.ENDER) { + //This is an Ender Item Cube. We have to check if any other players are looking at the correspnding Ender Item Cube inventory. + ItemCube_addSameEnderCube(thisitem2, identifier, p); + } + //Bukkit.getPlayer("sigonasr2").sendMessage("Item Cube gets "+thisitem2.getAmount()); + for (int i=0;i1) { + ItemStack newitem = item_cube.clone(); + newitem.setAmount(item_cube.getAmount()-1); + item_cube.setAmount(1); + //Drop the rest on the ground. + p.getWorld().dropItemNaturally(p.getLocation(), newitem); + } + ItemMeta meta = item_cube.getItemMeta(); + List newlore = meta.getLore(); + newlore.add("ID#"+identifier); + meta.setLore(newlore); + item_cube.setItemMeta(meta); + if (cube_type == Cube.ENDER) { + item_cube.setAmount(2); } - //Bukkit.getPlayer("sigonasr2").sendMessage("Item Cube gets "+thisitem2.getAmount()); - for (int i=0;i1) { - ItemStack newitem = item_cube.clone(); - newitem.setAmount(item_cube.getAmount()-1); - item_cube.setAmount(1); - //Drop the rest on the ground. - p.getWorld().dropItemNaturally(p.getLocation(), newitem); - } - ItemMeta meta = item_cube.getItemMeta(); - List newlore = meta.getLore(); - newlore.add("ID#"+identifier); - meta.setLore(newlore); - item_cube.setItemMeta(meta); - if (cube_type == Cube.ENDER) { - item_cube.setAmount(2); - } - } - return ItemCube_add(p, identifier, cube_type, insert_item); + return new ItemStack(Material.AIR); //Something went wrong. Just return a blank item. } - return new ItemStack(Material.AIR); //Something went wrong. Just return a blank item. - } - @EventHandler - public void onPlayerInteract(PlayerInteractEvent e) - { - Player p = e.getPlayer(); - Action blockAction = e.getAction(); - String currencySG = Main.economy.currencyNameSingular(); - String currencyPL = Main.economy.currencyNamePlural(); - boolean stats = this.plugin.getAccountsConfig().getBoolean(p.getName() + ".status"); - double actMon = this.plugin.getAccountsConfig().getDouble(p.getName() + ".money"); - int actHand = (int)Main.economy.getBalance(p.getName()); - if (this.plugin.PlayerinJob(p, "Explorer")) { - for (int i=0;i=5) { - p.getItemInHand().setDurability((short)0); - p.updateInventory(); - } - if (e.getClickedBlock().getType() == Material.JUKEBOX && e.getItem()!=null && (e.getItem().getType()==Material.RECORD_3 || - e.getItem().getType()==Material.RECORD_4 || e.getItem().getType()==Material.RECORD_5 || - e.getItem().getType()==Material.RECORD_6 || e.getItem().getType()==Material.RECORD_7 || - e.getItem().getType()==Material.RECORD_8 || e.getItem().getType()==Material.RECORD_9 || - e.getItem().getType()==Material.RECORD_10 || e.getItem().getType()==Material.RECORD_11 || - e.getItem().getType()==Material.RECORD_12 || e.getItem().getType()==Material.GOLD_RECORD || - e.getItem().getType()==Material.GREEN_RECORD)) { - //if (p.getName().compareTo("sigonasr2")==0) {p.sendMessage("This is a jukebox.");} - //if (p.getName().compareTo("sigonasr2")==0) {p.sendMessage("Item in hand: "+e.getItem().getType().toString());} - boolean contains=false; - for (int i=0;i newlore = new ArrayList(); - newlore.add("Requires "+((int)(Math.random()*1000)+100)+" Pumpkin Pie in inventory"); - newlore.add("to convert to a legendary equipment item."); - meta.setLore(newlore); - meta.setDisplayName(ChatColor.GREEN+"Magical Pumpkin Pie"); - pump.setItemMeta(meta); - c.getInventory().setItem(i, pump); - break; - } - } - } - } - } - /* + if ((e.getClickedBlock().getType()==Material.GRASS || e.getClickedBlock().getType()==Material.DIRT) && ( + p.getItemInHand().getType()==Material.WOOD_HOE || + p.getItemInHand().getType()==Material.STONE_HOE || + p.getItemInHand().getType()==Material.IRON_HOE || + p.getItemInHand().getType()==Material.GOLD_HOE || + p.getItemInHand().getType()==Material.DIAMOND_HOE) && this.plugin.PlayerinJob(p, "Farmer") && this.plugin.getJobLv("Farmer", p)>=5) { + p.getItemInHand().setDurability((short)0); + p.updateInventory(); + } + if (e.getClickedBlock().getType() == Material.JUKEBOX && e.getItem()!=null && (e.getItem().getType()==Material.RECORD_3 || + e.getItem().getType()==Material.RECORD_4 || e.getItem().getType()==Material.RECORD_5 || + e.getItem().getType()==Material.RECORD_6 || e.getItem().getType()==Material.RECORD_7 || + e.getItem().getType()==Material.RECORD_8 || e.getItem().getType()==Material.RECORD_9 || + e.getItem().getType()==Material.RECORD_10 || e.getItem().getType()==Material.RECORD_11 || + e.getItem().getType()==Material.RECORD_12 || e.getItem().getType()==Material.GOLD_RECORD || + e.getItem().getType()==Material.GREEN_RECORD)) { + //if (p.getName().compareTo("sigonasr2")==0) {p.sendMessage("This is a jukebox.");} + //if (p.getName().compareTo("sigonasr2")==0) {p.sendMessage("Item in hand: "+e.getItem().getType().toString());} + boolean contains=false; + for (int i=0;i newlore = new ArrayList(); + newlore.add("Requires "+((int)(Math.random()*1000)+100)+" Pumpkin Pie in inventory"); + newlore.add("to convert to a legendary equipment item."); + meta.setLore(newlore); + meta.setDisplayName(ChatColor.GREEN+"Magical Pumpkin Pie"); + pump.setItemMeta(meta); + c.getInventory().setItem(i, pump); + break; + } + } + } + } + } + /* if (p.getName().compareTo("sigonasr2")==0) { int v=2; final Vector direction = p.getEyeLocation().getDirection().multiply(v); Bukkit.getWorld("world").spawnEntity(p.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), EntityType.SILVERFISH); }*/ - //if (p.getName().compareTo("sigonasr2")==0) {Bukkit.getPlayer("sigonasr2").sendMessage("This block is at "+e.getClickedBlock().getX()+" "+e.getClickedBlock().getY()+" "+e.getClickedBlock().getZ()+" Data value:"+e.getClickedBlock().getData());} - if ((e.getClickedBlock().getState() instanceof BrewingStand)) { - BrewingStand brewingstand = (BrewingStand)e.getClickedBlock().getState(); - //Bukkit.getPlayer("sigonasr2").sendMessage("This is a furnace "+furnace.getBurnTime()+","+furnace.getCookTime()); - boolean contains=false; - //This furnace becomes owned. Add it to list if it doesn't exist. - for (int i=0;i400) { - if (p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestatime")>400 && (p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestbplayer"))!=0 || p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestbtime")>400)) { - Bukkit.broadcastMessage(ChatColor.RED+"[SPLEEF] "+ChatColor.YELLOW+"Spleef Player "+p.getName()+" requested a game in slot A. Join within 20 seconds."); - this.plugin.getConfig().set("spleefrequestatime", Double.valueOf(p.getPlayerTime())); - this.plugin.getConfig().set("spleefrequestaplayer", String.valueOf(p.getName())); - } - } else { - if (p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestbplayer"))!=0) { - //This is a confirmed Spleef game. - int playerarating,playerbrating; - Player playera,playerb; - playera=p; - this.plugin.getConfig().set("spleefrequestatime", Double.valueOf(p.getPlayerTime())); - this.plugin.getConfig().set("spleefrequestaplayer", String.valueOf(p.getName())); - playerb=Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")); - if (this.plugin.getAccountsConfig().contains(this.plugin.getConfig().getString("spleefrequestaplayer")+".spleefrating")) { - playerarating=(int)this.plugin.getAccountsConfig().getDouble(this.plugin.getConfig().getString("spleefrequestaplayer")+".spleefrating")/10; - } else { - playerarating=1000; - } - if (this.plugin.getAccountsConfig().contains(this.plugin.getConfig().getString("spleefrequestbplayer")+".spleefrating")) { - playerbrating=(int)this.plugin.getAccountsConfig().getDouble(this.plugin.getConfig().getString("spleefrequestbplayer")+".spleefrating")/10; - } else { - playerbrating=1000; - } - Bukkit.broadcastMessage(ChatColor.RED+"[SPLEEF] "+ChatColor.GREEN+"Spleef Game Started: "+ChatColor.YELLOW+this.plugin.getConfig().getString("spleefrequestaplayer")+"["+playerarating+"] vs. "+this.plugin.getConfig().getString("spleefrequestbplayer")+"["+playerbrating+"]"); - this.plugin.getConfig().set("spleefinsession", Boolean.valueOf(true)); - this.plugin.spleef_inventory_a = Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().getContents(); - this.plugin.spleef_inventory_b = Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().getContents(); - Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().clear(); - Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().clear(Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().getHeldItemSlot()); - Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().clear(); - Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().clear(Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().getHeldItemSlot()); - //Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).updateInventory(); - //Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).updateInventory(); - for (int i=1617;i<1627;i++) { - for (int j=54;j<64;j++) { - Bukkit.getWorld("world").getBlockAt(i,86,j).setType(Material.DIRT); - } - } - Location theshovel = new Location(Bukkit.getWorld("world"), 1627, 50, 27); - Chest shovelchest = (Chest)Bukkit.getWorld("world").getBlockAt(theshovel).getState(); - for (int i=0;i<27;i++) { - if (shovelchest.getBlockInventory().getContents()[i]!=null && shovelchest.getBlockInventory().getContents()[i].getType()==Material.WOOD_SPADE) { - this.plugin.store_shovel=shovelchest.getBlockInventory().getContents()[i]; - break; - } - } - Location l1 = new Location(Bukkit.getWorld("world"), 1622, 85, 58); - Chest c=(Chest)Bukkit.getWorld("world").getBlockAt(l1).getState(); - if (!c.getBlockInventory().contains(this.plugin.store_shovel)) { - c.getBlockInventory().setItem((int)(Math.random()*27.0d), this.plugin.store_shovel); - } - for (int i=1617;i<1627;i++) { - for (int j=54;j<64;j++) { - Bukkit.getWorld("world").getBlockAt(i,86,j).setType(Material.DIRT); - } - } - Bukkit.getWorld("world").getBlockAt(1622,86,58).setType(Material.WOOD); - Location newloc=playera.getLocation(); - newloc.setX(1622.49d); - newloc.setY(87.0d); - newloc.setZ(54.53d); - playera.teleport(newloc); - newloc.setZ(63.5d); - playerb.teleport(newloc); - this.plugin.spleef_last_broken_block=p.getPlayerTime(); - } - } - this.plugin.saveConfig(); - this.plugin.saveAccountsConfig(); - } - } else - if (sign.getBlock().getX()==1620 && sign.getBlock().getY()==83 && sign.getBlock().getZ()==45) { //Side B Request. - //If not requested already. - if (!this.plugin.getConfig().getBoolean("spleefinsession")) { - if (p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestatime")>400) { - if (p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestbtime")>400 && (p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestaplayer"))!=0 || p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestatime")>400)) { - Bukkit.broadcastMessage(ChatColor.RED+"[SPLEEF] "+ChatColor.YELLOW+"Spleef Player "+p.getName()+" requested a game in slot B. Join within 20 seconds."); - this.plugin.getConfig().set("spleefrequestbtime", Double.valueOf(p.getPlayerTime())); - this.plugin.getConfig().set("spleefrequestbplayer", String.valueOf(p.getName())); - } - } else { - if (p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestaplayer"))!=0) { - //This is a confirmed Spleef game. - int playerarating,playerbrating; - Player playera,playerb; - this.plugin.getConfig().set("spleefrequestbtime", Double.valueOf(p.getPlayerTime())); - this.plugin.getConfig().set("spleefrequestbplayer", String.valueOf(p.getName())); - playera=Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")); - playerb=p; - if (this.plugin.getAccountsConfig().contains(this.plugin.getConfig().getString("spleefrequestaplayer")+".spleefrating")) { - playerarating=(int)this.plugin.getAccountsConfig().getDouble(this.plugin.getConfig().getString("spleefrequestaplayer")+".spleefrating")/10; - } else { - playerarating=100; - } - if (this.plugin.getAccountsConfig().contains(this.plugin.getConfig().getString("spleefrequestbplayer")+".spleefrating")) { - playerbrating=(int)this.plugin.getAccountsConfig().getDouble(this.plugin.getConfig().getString("spleefrequestbplayer")+".spleefrating")/10; - } else { - playerbrating=100; - } - Bukkit.broadcastMessage(ChatColor.RED+"[SPLEEF] "+ChatColor.GREEN+"Spleef Game Started: "+ChatColor.YELLOW+this.plugin.getConfig().getString("spleefrequestaplayer")+"["+playerarating+"] vs. "+this.plugin.getConfig().getString("spleefrequestbplayer")+"["+playerbrating+"]"); - this.plugin.getConfig().set("spleefinsession", Boolean.valueOf(true)); - this.plugin.spleef_inventory_a = Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().getContents(); - this.plugin.spleef_inventory_b = Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().getContents(); - Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().clear(); - Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().clear(Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().getHeldItemSlot()); - Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().clear(); - Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().clear(Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().getHeldItemSlot()); - //Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).updateInventory(); - //Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).updateInventory(); - Location theshovel = new Location(Bukkit.getWorld("world"), 1627, 50, 27); - Chest shovelchest = (Chest)Bukkit.getWorld("world").getBlockAt(theshovel).getState(); - for (int i=0;i<27;i++) { - if (shovelchest.getBlockInventory().getContents()[i]!=null && shovelchest.getBlockInventory().getContents()[i].getType()==Material.WOOD_SPADE) { - this.plugin.store_shovel=shovelchest.getBlockInventory().getContents()[i]; - break; - } - } - Location l1 = new Location(Bukkit.getWorld("world"), 1622, 85, 58); - Chest c=(Chest)Bukkit.getWorld("world").getBlockAt(l1).getState(); - if (!c.getBlockInventory().contains(this.plugin.store_shovel)) { - c.getBlockInventory().setItem((int)(Math.random()*27.0d), this.plugin.store_shovel); - } - for (int i=1617;i<1627;i++) { - for (int j=54;j<64;j++) { - Bukkit.getWorld("world").getBlockAt(i,86,j).setType(Material.DIRT); - } - } - Bukkit.getWorld("world").getBlockAt(1622,86,58).setType(Material.WOOD); - Location newloc=playera.getLocation(); - newloc.setX(1622.49d); - newloc.setY(87.0d); - newloc.setZ(54.53d); - playera.teleport(newloc); - newloc.setZ(63.5d); - playerb.teleport(newloc); - this.plugin.spleef_last_broken_block=p.getPlayerTime(); - } - } - this.plugin.saveConfig(); - this.plugin.saveAccountsConfig(); - } - } - if (stats) { - if (p.hasPermission("bankeconomy.sign.use")) { - if ((sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_GREEN + "[Bank]")) && (sign.getLine(1).equalsIgnoreCase(ChatColor.DARK_RED + "Deposit"))) { - /*double value = Double.parseDouble(arg0); + //if (p.getName().compareTo("sigonasr2")==0) {Bukkit.getPlayer("sigonasr2").sendMessage("This block is at "+e.getClickedBlock().getX()+" "+e.getClickedBlock().getY()+" "+e.getClickedBlock().getZ()+" Data value:"+e.getClickedBlock().getData());} + if ((e.getClickedBlock().getState() instanceof BrewingStand)) { + BrewingStand brewingstand = (BrewingStand)e.getClickedBlock().getState(); + //Bukkit.getPlayer("sigonasr2").sendMessage("This is a furnace "+furnace.getBurnTime()+","+furnace.getCookTime()); + boolean contains=false; + //This furnace becomes owned. Add it to list if it doesn't exist. + for (int i=0;i400) { + if (p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestatime")>400 && (p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestbplayer"))!=0 || p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestbtime")>400)) { + Bukkit.broadcastMessage(ChatColor.RED+"[SPLEEF] "+ChatColor.YELLOW+"Spleef Player "+p.getName()+" requested a game in slot A. Join within 20 seconds."); + this.plugin.getConfig().set("spleefrequestatime", Double.valueOf(p.getPlayerTime())); + this.plugin.getConfig().set("spleefrequestaplayer", String.valueOf(p.getName())); + } + } else { + if (p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestbplayer"))!=0) { + //This is a confirmed Spleef game. + int playerarating,playerbrating; + Player playera,playerb; + playera=p; + this.plugin.getConfig().set("spleefrequestatime", Double.valueOf(p.getPlayerTime())); + this.plugin.getConfig().set("spleefrequestaplayer", String.valueOf(p.getName())); + playerb=Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")); + if (this.plugin.getAccountsConfig().contains(this.plugin.getConfig().getString("spleefrequestaplayer")+".spleefrating")) { + playerarating=(int)this.plugin.getAccountsConfig().getDouble(this.plugin.getConfig().getString("spleefrequestaplayer")+".spleefrating")/10; + } else { + playerarating=1000; + } + if (this.plugin.getAccountsConfig().contains(this.plugin.getConfig().getString("spleefrequestbplayer")+".spleefrating")) { + playerbrating=(int)this.plugin.getAccountsConfig().getDouble(this.plugin.getConfig().getString("spleefrequestbplayer")+".spleefrating")/10; + } else { + playerbrating=1000; + } + Bukkit.broadcastMessage(ChatColor.RED+"[SPLEEF] "+ChatColor.GREEN+"Spleef Game Started: "+ChatColor.YELLOW+this.plugin.getConfig().getString("spleefrequestaplayer")+"["+playerarating+"] vs. "+this.plugin.getConfig().getString("spleefrequestbplayer")+"["+playerbrating+"]"); + this.plugin.getConfig().set("spleefinsession", Boolean.valueOf(true)); + this.plugin.spleef_inventory_a = Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().getContents(); + this.plugin.spleef_inventory_b = Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().getContents(); + Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().clear(); + Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().clear(Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().getHeldItemSlot()); + Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().clear(); + Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().clear(Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().getHeldItemSlot()); + //Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).updateInventory(); + //Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).updateInventory(); + for (int i=1617;i<1627;i++) { + for (int j=54;j<64;j++) { + Bukkit.getWorld("world").getBlockAt(i,86,j).setType(Material.DIRT); + } + } + Location theshovel = new Location(Bukkit.getWorld("world"), 1627, 50, 27); + Chest shovelchest = (Chest)Bukkit.getWorld("world").getBlockAt(theshovel).getState(); + for (int i=0;i<27;i++) { + if (shovelchest.getBlockInventory().getContents()[i]!=null && shovelchest.getBlockInventory().getContents()[i].getType()==Material.WOOD_SPADE) { + this.plugin.store_shovel=shovelchest.getBlockInventory().getContents()[i]; + break; + } + } + Location l1 = new Location(Bukkit.getWorld("world"), 1622, 85, 58); + Chest c=(Chest)Bukkit.getWorld("world").getBlockAt(l1).getState(); + if (!c.getBlockInventory().contains(this.plugin.store_shovel)) { + c.getBlockInventory().setItem((int)(Math.random()*27.0d), this.plugin.store_shovel); + } + for (int i=1617;i<1627;i++) { + for (int j=54;j<64;j++) { + Bukkit.getWorld("world").getBlockAt(i,86,j).setType(Material.DIRT); + } + } + Bukkit.getWorld("world").getBlockAt(1622,86,58).setType(Material.WOOD); + Location newloc=playera.getLocation(); + newloc.setX(1622.49d); + newloc.setY(87.0d); + newloc.setZ(54.53d); + playera.teleport(newloc); + newloc.setZ(63.5d); + playerb.teleport(newloc); + this.plugin.spleef_last_broken_block=p.getPlayerTime(); + } + } + this.plugin.saveConfig(); + this.plugin.saveAccountsConfig(); + } + } else + if (sign.getBlock().getX()==1620 && sign.getBlock().getY()==83 && sign.getBlock().getZ()==45) { //Side B Request. + //If not requested already. + if (!this.plugin.getConfig().getBoolean("spleefinsession")) { + if (p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestatime")>400) { + if (p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestbtime")>400 && (p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestaplayer"))!=0 || p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestatime")>400)) { + Bukkit.broadcastMessage(ChatColor.RED+"[SPLEEF] "+ChatColor.YELLOW+"Spleef Player "+p.getName()+" requested a game in slot B. Join within 20 seconds."); + this.plugin.getConfig().set("spleefrequestbtime", Double.valueOf(p.getPlayerTime())); + this.plugin.getConfig().set("spleefrequestbplayer", String.valueOf(p.getName())); + } + } else { + if (p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestaplayer"))!=0) { + //This is a confirmed Spleef game. + int playerarating,playerbrating; + Player playera,playerb; + this.plugin.getConfig().set("spleefrequestbtime", Double.valueOf(p.getPlayerTime())); + this.plugin.getConfig().set("spleefrequestbplayer", String.valueOf(p.getName())); + playera=Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")); + playerb=p; + if (this.plugin.getAccountsConfig().contains(this.plugin.getConfig().getString("spleefrequestaplayer")+".spleefrating")) { + playerarating=(int)this.plugin.getAccountsConfig().getDouble(this.plugin.getConfig().getString("spleefrequestaplayer")+".spleefrating")/10; + } else { + playerarating=100; + } + if (this.plugin.getAccountsConfig().contains(this.plugin.getConfig().getString("spleefrequestbplayer")+".spleefrating")) { + playerbrating=(int)this.plugin.getAccountsConfig().getDouble(this.plugin.getConfig().getString("spleefrequestbplayer")+".spleefrating")/10; + } else { + playerbrating=100; + } + Bukkit.broadcastMessage(ChatColor.RED+"[SPLEEF] "+ChatColor.GREEN+"Spleef Game Started: "+ChatColor.YELLOW+this.plugin.getConfig().getString("spleefrequestaplayer")+"["+playerarating+"] vs. "+this.plugin.getConfig().getString("spleefrequestbplayer")+"["+playerbrating+"]"); + this.plugin.getConfig().set("spleefinsession", Boolean.valueOf(true)); + this.plugin.spleef_inventory_a = Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().getContents(); + this.plugin.spleef_inventory_b = Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().getContents(); + Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().clear(); + Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().clear(Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).getInventory().getHeldItemSlot()); + Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().clear(); + Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().clear(Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).getInventory().getHeldItemSlot()); + //Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")).updateInventory(); + //Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")).updateInventory(); + Location theshovel = new Location(Bukkit.getWorld("world"), 1627, 50, 27); + Chest shovelchest = (Chest)Bukkit.getWorld("world").getBlockAt(theshovel).getState(); + for (int i=0;i<27;i++) { + if (shovelchest.getBlockInventory().getContents()[i]!=null && shovelchest.getBlockInventory().getContents()[i].getType()==Material.WOOD_SPADE) { + this.plugin.store_shovel=shovelchest.getBlockInventory().getContents()[i]; + break; + } + } + Location l1 = new Location(Bukkit.getWorld("world"), 1622, 85, 58); + Chest c=(Chest)Bukkit.getWorld("world").getBlockAt(l1).getState(); + if (!c.getBlockInventory().contains(this.plugin.store_shovel)) { + c.getBlockInventory().setItem((int)(Math.random()*27.0d), this.plugin.store_shovel); + } + for (int i=1617;i<1627;i++) { + for (int j=54;j<64;j++) { + Bukkit.getWorld("world").getBlockAt(i,86,j).setType(Material.DIRT); + } + } + Bukkit.getWorld("world").getBlockAt(1622,86,58).setType(Material.WOOD); + Location newloc=playera.getLocation(); + newloc.setX(1622.49d); + newloc.setY(87.0d); + newloc.setZ(54.53d); + playera.teleport(newloc); + newloc.setZ(63.5d); + playerb.teleport(newloc); + this.plugin.spleef_last_broken_block=p.getPlayerTime(); + } + } + this.plugin.saveConfig(); + this.plugin.saveAccountsConfig(); + } + } + if (stats) { + if (p.hasPermission("bankeconomy.sign.use")) { + if ((sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_GREEN + "[Bank]")) && (sign.getLine(1).equalsIgnoreCase(ChatColor.DARK_RED + "Deposit"))) { + /*double value = Double.parseDouble(arg0); double total = actMon + value; if (value <= actHand) { this.plugin.getAccountsConfig().set(p.getName() + ".money", Double.valueOf(total)); @@ -12184,19 +12548,19 @@ public void onEntityExpode(ExplosionPrimeEvent e) { } else { p.sendMessage("�ァ2[BankEconomy]" + ChatColor.AQUA + " Sorry, you can't deposit that amount of money."); }*/ - //If they were using the withdraw bank before, clear them from it. - if (this.plugin.last_bank_withdraw_user.equalsIgnoreCase(p.getName())) { - this.plugin.last_bank_withdraw_user=""; - } - if (this.plugin.last_bank_deposit_use_time+200='a'&&mod[i]<='z') { - mod[i]-=32; - first=true; - } else - if (i==0) { - if (mod[i]>='A'&&mod[i]<='Z') { - first=true; - } - } else { - if (mod[i]>='A'&&mod[i]<='Z'&&(mod[i-1]<'A'||mod[i-1]>'Z')) { - first=true; - } - } - } else { - if (mod[i-1]!=' ') { - if (mod[i]>='A'&&mod[i]<='Z') { - mod[i]+=32; - } - } - } - } - return String.valueOf(mod); -} -public String convertToItemName(String val, short data, Material material_id) { - String color = ""; - String name = ""; - switch (material_id) { - case WOOL:{ - name = "Wool"; - }break; - case INK_SACK:{ - name = "Dye"; - }break; - case CARPET:{ - name = "Carpet"; - }break; - } - if (name.equalsIgnoreCase("Dye")) { - switch (data) { - case 0:{ - color = "Black"; - }break; - case 1:{ - color = "Red"; - }break; - case 2:{ - color = "Green"; - }break; - case 3:{ - color = "Brown"; - }break; - case 4:{ - color = "Blue"; - }break; - case 5:{ - color = "Purple"; - }break; - case 6:{ - color = "Cyan"; - }break; - case 7:{ - color = "Light Gray"; - }break; - case 8:{ - color = "Gray"; - }break; - case 9:{ - color = "Pink"; - }break; - case 10:{ - color = "Lime"; - }break; - case 11:{ - color = "Yellow"; - }break; - case 12:{ - color = "Light Blue"; - }break; - case 13:{ - color = "Green"; - }break; - case 14:{ - color = "Red"; - }break; - case 15:{ - color = "Black"; - }break; - } - } else { - switch (data) { - case 0:{ - color = "White"; - }break; - case 1:{ - color = "Orange"; - }break; - case 2:{ - color = "Magenta"; - }break; - case 3:{ - color = "Light Blue"; - }break; - case 4:{ - color = "Yellow"; - }break; - case 5:{ - color = "Lime"; - }break; - case 6:{ - color = "Pink"; - }break; - case 7:{ - color = "Gray"; - }break; - case 8:{ - color = "Light Gray"; - }break; - case 9:{ - color = "Cyan"; - }break; - case 10:{ - color = "Purple"; - }break; - case 11:{ - color = "Blue"; - }break; - case 12:{ - color = "Brown"; - }break; - case 13:{ - color = "Green"; - }break; - case 14:{ - color = "Red"; - }break; - case 15:{ - color = "Black"; - }break; - } - } - return String.valueOf(color+" "+name); -} + public boolean special_convert(Material mat) { + if (mat==Material.WOOL || mat==Material.INK_SACK || mat==Material.CARPET) { + return true; + } else { + return false; + } + } -@EventHandler -public void onHangingBreak(HangingBreakEvent e) { - //Bukkit.broadcastMessage(""+e.getCause()); - if (e.getCause().name().equalsIgnoreCase(RemoveCause.DEFAULT.name()) || e.getCause().name().equalsIgnoreCase(RemoveCause.EXPLOSION.name())) { - //Prevent this from happening here. - e.setCancelled(true); + public String convertToItemName(String val) { + val=val.replace('_', ' '); + char[] mod = val.toCharArray(); + boolean first=false; + for (int i=0;i='a'&&mod[i]<='z') { + mod[i]-=32; + first=true; + } else + if (i==0) { + if (mod[i]>='A'&&mod[i]<='Z') { + first=true; + } + } else { + if (mod[i]>='A'&&mod[i]<='Z'&&(mod[i-1]<'A'||mod[i-1]>'Z')) { + first=true; + } + } + } else { + if (mod[i-1]!=' ') { + if (mod[i]>='A'&&mod[i]<='Z') { + mod[i]+=32; + } + } + } + } + return String.valueOf(mod); } -} -@EventHandler -public void onHangingBreakEntity(HangingBreakByEntityEvent e) { - //Bukkit.broadcastMessage(""+e.getRemover().getType()); - if (e.getRemover().getType()==EntityType.LIGHTNING || (e.getRemover() instanceof Monster)) { - //Prevent this from happening here. - e.setCancelled(true); + public String convertToItemName(String val, short data, Material material_id) { + String color = ""; + String name = ""; + switch (material_id) { + case WOOL:{ + name = "Wool"; + }break; + case INK_SACK:{ + name = "Dye"; + }break; + case CARPET:{ + name = "Carpet"; + }break; + } + if (name.equalsIgnoreCase("Dye")) { + switch (data) { + case 0:{ + color = "Black"; + }break; + case 1:{ + color = "Red"; + }break; + case 2:{ + color = "Green"; + }break; + case 3:{ + color = "Brown"; + }break; + case 4:{ + color = "Blue"; + }break; + case 5:{ + color = "Purple"; + }break; + case 6:{ + color = "Cyan"; + }break; + case 7:{ + color = "Light Gray"; + }break; + case 8:{ + color = "Gray"; + }break; + case 9:{ + color = "Pink"; + }break; + case 10:{ + color = "Lime"; + }break; + case 11:{ + color = "Yellow"; + }break; + case 12:{ + color = "Light Blue"; + }break; + case 13:{ + color = "Green"; + }break; + case 14:{ + color = "Red"; + }break; + case 15:{ + color = "Black"; + }break; + } + } else { + switch (data) { + case 0:{ + color = "White"; + }break; + case 1:{ + color = "Orange"; + }break; + case 2:{ + color = "Magenta"; + }break; + case 3:{ + color = "Light Blue"; + }break; + case 4:{ + color = "Yellow"; + }break; + case 5:{ + color = "Lime"; + }break; + case 6:{ + color = "Pink"; + }break; + case 7:{ + color = "Gray"; + }break; + case 8:{ + color = "Light Gray"; + }break; + case 9:{ + color = "Cyan"; + }break; + case 10:{ + color = "Purple"; + }break; + case 11:{ + color = "Blue"; + }break; + case 12:{ + color = "Brown"; + }break; + case 13:{ + color = "Green"; + }break; + case 14:{ + color = "Red"; + }break; + case 15:{ + color = "Black"; + }break; + } + } + return String.valueOf(color+" "+name); + } + + @EventHandler + public void onHangingBreak(HangingBreakEvent e) { + //Bukkit.broadcastMessage(""+e.getCause()); + if (e.getCause().name().equalsIgnoreCase(RemoveCause.DEFAULT.name()) || e.getCause().name().equalsIgnoreCase(RemoveCause.EXPLOSION.name())) { + //Prevent this from happening here. + e.setCancelled(true); + } + } + + @EventHandler + public void onHangingBreakEntity(HangingBreakByEntityEvent e) { + //Bukkit.broadcastMessage(""+e.getRemover().getType()); + if (e.getRemover().getType()==EntityType.LIGHTNING || (e.getRemover() instanceof Monster)) { + //Prevent this from happening here. + e.setCancelled(true); + } } -} -/* + /* @EventHandler public void onLightningStrike(LightningStrikeEvent e) { Bukkit.getWorld("world").strikeLightning(new Location("world", Bukkit.getOnlinePlayers()[(int)(Math.random()*Bukkit.getOnlinePlayers().length)].getLocation().getX(), 0d, 0d)); @@ -12433,3 +12797,252 @@ public void onHangingBreakEntity(HangingBreakByEntityEvent e) { } +class updateInventoryTask implements Runnable { + String playerName; + + public updateInventoryTask(String pl){ + playerName = pl; + } + + @Override + public void run() { + Bukkit.getLogger().info("Runnable task run() called; player name: " + playerName); + + Player player = Bukkit.getPlayer(playerName); + Inventory anvilInv = player.getOpenInventory().getTopInventory(); + + final int INPUT = 10; + final int MATERIALS = 12; + final int MAGIC = 14; + final int OUTPUT = 16; + final int LEVELS = 22; + + + + + if (anvilInv.getItem(INPUT) == null || anvilInv.getItem(MATERIALS) == null) { + // No valid combo, set XP orb to stack size 1 and remove output. + anvilInv.getItem(LEVELS).setAmount(1); + anvilInv.setItem(OUTPUT, new ItemStack(Material.AIR)); + } + else + { + // Redundant validation code for verification + + + if (!((anvilInv.getItem(INPUT).toString().toUpperCase().contains("HELMET") || anvilInv.getItem(INPUT).toString().toUpperCase().contains("CHESTPLATE") || + anvilInv.getItem(INPUT).toString().toUpperCase().contains("LEGGINGS") || anvilInv.getItem(INPUT).toString().toUpperCase().contains("BOOTS") || + anvilInv.getItem(INPUT).toString().toUpperCase().contains("PICKAXE") || anvilInv.getItem(INPUT).toString().toUpperCase().contains("SPADE") || + anvilInv.getItem(INPUT).toString().toUpperCase().contains("HOE") || anvilInv.getItem(INPUT).toString().toUpperCase().contains("AXE") || + anvilInv.getItem(INPUT).toString().toUpperCase().contains("SWORD") || anvilInv.getItem(INPUT).toString().toUpperCase().contains("FISHING") || + anvilInv.getItem(INPUT).toString().toUpperCase().contentEquals("BOW")) && anvilInv.getItem(INPUT).getDurability() != 0)) { + + sendToInventory(anvilInv.getItem(INPUT), anvilInv.getItem(INPUT).getAmount(), player, player.getInventory()); + Bukkit.getLogger().info("Invalid input!"); + } + + + if (!(anvilInv.getItem(MATERIALS).getType() == Material.LEATHER || anvilInv.getItem(MATERIALS).getType() == Material.IRON_INGOT || + anvilInv.getItem(MATERIALS).getType() == Material.GOLD_INGOT || anvilInv.getItem(MATERIALS).getType() == Material.IRON_BLOCK || + anvilInv.getItem(MATERIALS).getType() == Material.DIAMOND_BLOCK || anvilInv.getItem(MATERIALS).getType() == Material.DIAMOND || + anvilInv.getItem(MATERIALS).getType() == Material.WOOD || anvilInv.getItem(MATERIALS).getType() == Material.COBBLESTONE || + anvilInv.getItem(MATERIALS).getType() == Material.STRING)) { + + sendToInventory(anvilInv.getItem(MATERIALS), anvilInv.getItem(MATERIALS).getAmount(), player, player.getInventory()); + + Bukkit.getLogger().info("Invalid materials!"); + } + + // Verify the right material is combined with the source item. + boolean validCombo = false; + double multiplier = 0; + + if (anvilInv.getItem(MATERIALS).getType() == Material.WOOD && (anvilInv.getItem(INPUT).getType() == Material.WOOD_AXE || + anvilInv.getItem(INPUT).getType() == Material.WOOD_SWORD || anvilInv.getItem(INPUT).getType() == Material.WOOD_HOE || + anvilInv.getItem(INPUT).getType() == Material.WOOD_PICKAXE || anvilInv.getItem(INPUT).getType() == Material.WOOD_SPADE)) { + + validCombo = true; + multiplier = 0.1; + } + + if (anvilInv.getItem(MATERIALS).getType() == Material.STRING && (anvilInv.getItem(INPUT).getType() == Material.FISHING_ROD || + anvilInv.getItem(INPUT).getType() == Material.BOW)) { + + validCombo = true; + multiplier = 1; + } + + if (anvilInv.getItem(MATERIALS).getType() == Material.COBBLESTONE && (anvilInv.getItem(INPUT).getType() == Material.STONE_AXE || + anvilInv.getItem(INPUT).getType() == Material.STONE_SWORD || anvilInv.getItem(INPUT).getType() == Material.STONE_HOE || + anvilInv.getItem(INPUT).getType() == Material.STONE_PICKAXE || anvilInv.getItem(INPUT).getType() == Material.STONE_SPADE)) { + + validCombo = true; + multiplier = 0.2; + } + + if (anvilInv.getItem(MATERIALS).getType() == Material.LEATHER && (anvilInv.getItem(INPUT).getType() == Material.LEATHER_BOOTS || + anvilInv.getItem(INPUT).getType() == Material.LEATHER_CHESTPLATE || anvilInv.getItem(INPUT).getType() == Material.LEATHER_HELMET || + anvilInv.getItem(INPUT).getType() == Material.LEATHER_LEGGINGS)) { + + validCombo = true; + multiplier = 0.15; + } + + if (anvilInv.getItem(MATERIALS).getType() == Material.IRON_INGOT && (anvilInv.getItem(INPUT).getType() == Material.IRON_BOOTS || + anvilInv.getItem(INPUT).getType() == Material.IRON_CHESTPLATE || anvilInv.getItem(INPUT).getType() == Material.IRON_HELMET || + anvilInv.getItem(INPUT).getType() == Material.IRON_LEGGINGS || anvilInv.getItem(INPUT).getType() == Material.IRON_AXE || + anvilInv.getItem(INPUT).getType() == Material.IRON_SWORD || anvilInv.getItem(INPUT).getType() == Material.IRON_HOE || + anvilInv.getItem(INPUT).getType() == Material.IRON_PICKAXE || anvilInv.getItem(INPUT).getType() == Material.IRON_SPADE)) { + + validCombo = true; + multiplier = 0.8; + } + + if (anvilInv.getItem(MATERIALS).getType() == Material.IRON_BLOCK && (anvilInv.getItem(INPUT).getType() == Material.IRON_BOOTS || + anvilInv.getItem(INPUT).getType() == Material.IRON_CHESTPLATE || anvilInv.getItem(INPUT).getType() == Material.IRON_HELMET || + anvilInv.getItem(INPUT).getType() == Material.IRON_LEGGINGS || anvilInv.getItem(INPUT).getType() == Material.IRON_AXE || + anvilInv.getItem(INPUT).getType() == Material.IRON_SWORD || anvilInv.getItem(INPUT).getType() == Material.IRON_HOE || + anvilInv.getItem(INPUT).getType() == Material.IRON_PICKAXE || anvilInv.getItem(INPUT).getType() == Material.IRON_SPADE)) { + + validCombo = true; + multiplier = 0.08; + } + + if (anvilInv.getItem(MATERIALS).getType() == Material.IRON_INGOT && (anvilInv.getItem(INPUT).getType() == Material.CHAINMAIL_BOOTS || + anvilInv.getItem(INPUT).getType() == Material.CHAINMAIL_CHESTPLATE || anvilInv.getItem(INPUT).getType() == Material.CHAINMAIL_HELMET || + anvilInv.getItem(INPUT).getType() == Material.CHAINMAIL_LEGGINGS)) { + + validCombo = true; + multiplier = 0.65; + } + + if (anvilInv.getItem(MATERIALS).getType() == Material.GOLD_INGOT && (anvilInv.getItem(INPUT).getType() == Material.GOLD_BOOTS || + anvilInv.getItem(INPUT).getType() == Material.GOLD_CHESTPLATE || anvilInv.getItem(INPUT).getType() == Material.GOLD_HELMET || + anvilInv.getItem(INPUT).getType() == Material.GOLD_LEGGINGS || anvilInv.getItem(INPUT).getType() == Material.GOLD_AXE || + anvilInv.getItem(INPUT).getType() == Material.GOLD_SWORD || anvilInv.getItem(INPUT).getType() == Material.GOLD_HOE || + anvilInv.getItem(INPUT).getType() == Material.GOLD_PICKAXE || anvilInv.getItem(INPUT).getType() == Material.GOLD_SPADE)) { + + validCombo = true; + multiplier = 0.3; + } + + if (anvilInv.getItem(MATERIALS).getType() == Material.DIAMOND && (anvilInv.getItem(INPUT).getType() == Material.DIAMOND_BOOTS || + anvilInv.getItem(INPUT).getType() == Material.DIAMOND_CHESTPLATE || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_HELMET || + anvilInv.getItem(INPUT).getType() == Material.DIAMOND_LEGGINGS || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_AXE || + anvilInv.getItem(INPUT).getType() == Material.DIAMOND_SWORD || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_HOE || + anvilInv.getItem(INPUT).getType() == Material.DIAMOND_PICKAXE || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_SPADE)) { + + validCombo = true; + multiplier = 1.2; + } + + if (anvilInv.getItem(MATERIALS).getType() == Material.DIAMOND_BLOCK && (anvilInv.getItem(INPUT).getType() == Material.DIAMOND_BOOTS || + anvilInv.getItem(INPUT).getType() == Material.DIAMOND_CHESTPLATE || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_HELMET || + anvilInv.getItem(INPUT).getType() == Material.DIAMOND_LEGGINGS || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_AXE || + anvilInv.getItem(INPUT).getType() == Material.DIAMOND_SWORD || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_HOE || + anvilInv.getItem(INPUT).getType() == Material.DIAMOND_PICKAXE || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_SPADE)) { + + validCombo = true; + multiplier = 0.12; + } + + if (validCombo) { + // If materials stacked past number needed to full repair, reduce stack size and drop the rest + // in the player's inventory, or if that fails, drop it on the ground. + // Limit to 5 just in case math doesn't work. + int maxItemsNeeded = Math.min(5, 1 + (5 * anvilInv.getItem(INPUT).getDurability() / anvilInv.getItem(INPUT).getType().getMaxDurability())); + + if (anvilInv.getItem(MATERIALS).getAmount() > maxItemsNeeded) { + // Bukkit.getLogger().info("Materials exceed " + maxItemsNeeded + " stack. Dropping " + (anvilInv.getItem(MATERIALS).getAmount() - maxItemsNeeded) + " of " + anvilInv.getItem(MATERIALS).getType()); + + sendToInventory(anvilInv.getItem(MATERIALS), anvilInv.getItem(MATERIALS).getAmount() - maxItemsNeeded, player, player.getInventory()); + + // anvilInv.getItem(MATERIALS).setAmount(maxItemsNeeded); + } + + int cost = anvilInv.getContents()[MATERIALS].getAmount() * 2; + int bonus_cost = 0; + ItemStack item = anvilInv.getContents()[INPUT]; + + Bukkit.getLogger().warning("Repair cost calculation valid"); + Map enchantments = item.getEnchantments(); + + Bukkit.getLogger().warning(enchantments.keySet().toString()); + for (Enchantment e : enchantments.keySet()) { + Bukkit.getLogger().warning("BC: " + bonus_cost + " | INCR: " + 2 + enchantments.get(e)); + bonus_cost += (2 + enchantments.get(e)); + } + + cost += bonus_cost; + + Bukkit.getLogger().info("Raw cost: " + cost); + + cost = (short) Math.floor(cost * multiplier); + cost = Math.min(cost, 60); // Cap cost at 60 in case some egregiously enchanted item exists + cost = Math.max(cost, 1); // Make sure it's at least one level + + Bukkit.getLogger().info("Cost: " + cost); + + ItemStack orbs = new ItemStack(Material.SLIME_BALL); + + ItemMeta temp_meta = orbs.getItemMeta(); + temp_meta.setDisplayName(ChatColor.YELLOW + "Experience Cost"); + List temp_meta_lore = new ArrayList(); + temp_meta_lore.add(ChatColor.ITALIC + "This operation costs " + cost + " levels."); + temp_meta_lore.add(ChatColor.ITALIC + "You currently have " + player.getLevel() + " levels."); + + if (cost > player.getLevel()) { + orbs.setType(Material.MAGMA_CREAM); + temp_meta_lore.add(""); + temp_meta_lore.add(ChatColor.RED + "You can't afford this!"); + } else { + temp_meta_lore.add(""); + temp_meta_lore.add(ChatColor.GREEN + "Completing the operation will"); + temp_meta_lore.add(ChatColor.GREEN + "bring you to " + (player.getLevel() - cost) + " levels."); + } + + temp_meta.setLore(temp_meta_lore); + orbs.setItemMeta(temp_meta); + + orbs.setAmount(cost); + anvilInv.setItem(LEVELS, orbs); + + // anvilInv.getContents()[OUTPUT].setType(item.getType()); + // anvilInv.getContents()[OUTPUT].setData(item.getData()); + + anvilInv.setItem(OUTPUT, item.clone()); + anvilInv.getContents()[OUTPUT].setDurability((short) (item.getDurability() - item.getType().getMaxDurability() * 0.2 * anvilInv.getContents()[MATERIALS].getAmount())); + } + + + // TRY EVERYTHING + player.getInventory().setContents(player.getInventory().getContents()); + anvilInv.setContents(anvilInv.getContents()); + player.updateInventory(); + + } + } + + public void sendToInventory(ItemStack item, int number, Player player, Inventory target) { + + ItemStack temp = item.clone(); + + temp.setAmount(number); + ItemStack leftovers = target.addItem(temp).get(0); + + if (leftovers != null) { + player.getWorld().dropItemNaturally(player.getLocation(), leftovers); + } + + item.setAmount(item.getAmount() - number); + + if (item.getAmount() - number == 0) { + item.setType(Material.AIR); + + Bukkit.getLogger().info("Item stack size reduced to 0, " + item.getType().toString() + " removed."); + + } + // player.getWorld().dropItemNaturally(player.getLocation(), new ItemStack(anvilInv.getItem(MATERIALS).getType(), anvilInv.getItem(MATERIALS).getAmount() - maxItemsNeeded)); + + } +}