From eef59e0d35d43846100ca5aa60181580ae22acb4 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Tue, 10 Dec 2013 23:28:54 -0700 Subject: [PATCH] Rename name tag functionality. Fix Ender Cubes. --- BankEconomyMod/src/me/kaZep/Base/Main.java | 49 ++-- .../src/me/kaZep/Base/PlayerData.java | 1 + .../src/me/kaZep/Base/PlayerListener.java | 227 ++++++++++++++---- .../me/kaZep/Commands/commandBankEconomy.java | 8 + 4 files changed, 217 insertions(+), 68 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index c98a858..53e48e8 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -73,6 +73,7 @@ import org.bukkit.entity.Skeleton; import org.bukkit.entity.Wither; import org.bukkit.entity.Wolf; import org.bukkit.entity.Zombie; +import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; @@ -268,6 +269,7 @@ public class Main extends JavaPlugin getCommand("ticktime").setExecutor(new commandBankEconomy(this)); getCommand("line").setExecutor(new commandBankEconomy(this)); getCommand("rectangle").setExecutor(new commandBankEconomy(this)); + getCommand("rename").setExecutor(new commandBankEconomy(this)); setupEconomy(); @@ -771,7 +773,14 @@ public class Main extends JavaPlugin Bukkit.addRecipe(DeConv_gold_spade); Bukkit.addRecipe(DeConv_stone_spade); - + for (int i=0;i<16;i++) { + ShapelessRecipe nametag_color = new ShapelessRecipe(new ItemStack(Material.NAME_TAG)); + nametag_color.addIngredient(Material.NAME_TAG); + MaterialData md = new MaterialData(Material.INK_SACK, (byte)i); + nametag_color.addIngredient(md); + Bukkit.addRecipe(nametag_color); + } + ItemSetList = new ItemSetList(); ItemSetList.Init(); //Create a list of item sets. @@ -5508,31 +5517,27 @@ public void payDay(int time) if (LoreData.get(i).contains(ChatColor.GRAY+getBonusRomanNumeralEnchantments().get(j).name+" ")) { newLoreData.add(LoreData.get(i)); LoreData.remove(i); + i--; } } } //Now find all bonus enchantments. for (int i=0;i getBonusNotRomanNumeralEnchantments() { + List finallist = new ArrayList(); + for (int i=0;i0) { + chance_increase=((Player)e.getEntity().getKiller()).getItemInHand().getEnchantmentLevel(Enchantment.LOOT_BONUS_MOBS)/2; + } + for (int i=0;i0.085*chance_increase) { + e.getDrops().remove(i); + } + } + } + if (Math.random()<=0.00390625*chance_increase) { + ItemStack rename_token = new ItemStack(Material.NAME_TAG); + e.getDrops().add(rename_token); + } + } + if (e.getEntity() instanceof LivingEntity) { LivingEntity f = e.getEntity(); if (f instanceof Monster) { if (this.plugin.getConfig().getBoolean("thanksgiving-enabled") && Math.random()<=0.01) { @@ -8228,15 +8301,20 @@ implements Listener if (f.getCustomName().contains("Mythical Wither")) { e.setDroppedExp(e.getDroppedExp()*4000); boolean dropMythical=false; + boolean dropMythical2=false; for (int j=0;j<10;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.05 && !dropMythical) { + if (Math.random()<=0.1 && !dropMythical) { dropMythical=true; - item = getGoodie(2); + item = getGoodie(1); + } else + if (Math.random()<=0.03 && !dropMythical2) { + dropMythical2=true; + item = getGoodie(1); } if (Math.random()<=0.2) { item = getGoodie(); @@ -9994,10 +10072,10 @@ implements Listener //Choose a random set to mark off. blocked_attack=true; //Reduce all armor by one as if it was a normal hit. - if (p.getInventory().getHelmet()!=null) {p.getInventory().getHelmet().setDurability((short)(p.getInventory().getHelmet().getDurability()+1));} - if (p.getInventory().getChestplate()!=null) {p.getInventory().getChestplate().setDurability((short)(p.getInventory().getChestplate().getDurability()+1));} - if (p.getInventory().getLeggings()!=null) {p.getInventory().getLeggings().setDurability((short)(p.getInventory().getLeggings().getDurability()+1));} - if (p.getInventory().getBoots()!=null) {p.getInventory().getBoots().setDurability((short)(p.getInventory().getBoots().getDurability()+1));} + if (p.getInventory().getHelmet()!=null && this.plugin.hasBonusEnchantment(p.getInventory().getHelmet(), Main.ENCHANT_BLOCK_CHANCE)) {p.getInventory().getHelmet().setDurability((short)(p.getInventory().getHelmet().getDurability()+1));} + if (p.getInventory().getChestplate()!=null && this.plugin.hasBonusEnchantment(p.getInventory().getChestplate(), Main.ENCHANT_BLOCK_CHANCE)) {p.getInventory().getChestplate().setDurability((short)(p.getInventory().getChestplate().getDurability()+1));} + if (p.getInventory().getLeggings()!=null && this.plugin.hasBonusEnchantment(p.getInventory().getLeggings(), Main.ENCHANT_BLOCK_CHANCE)) {p.getInventory().getLeggings().setDurability((short)(p.getInventory().getLeggings().getDurability()+1));} + if (p.getInventory().getBoots()!=null && this.plugin.hasBonusEnchantment(p.getInventory().getBoots(), Main.ENCHANT_BLOCK_CHANCE)) {p.getInventory().getBoots().setDurability((short)(p.getInventory().getBoots().getDurability()+1));} /* if (blocks.size()>0) { int armor = blocks.get((int)(Math.random()*blocks.size())); @@ -11911,8 +11989,6 @@ implements Listener p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(ChatColor.DARK_PURPLE+""); } - //Bukkit.getLogger().info("Slot is "+event.getSlot()); - //*****************************// Job buffs here if (event.getInventory().getType()==InventoryType.BREWING && event.getSlot()==3) { //Check if the brewing stand can start up. @@ -12816,6 +12892,9 @@ implements Listener } } //****************************//End job buffs. + + if (event.getInventory().getType()==InventoryType.FURNACE) { + } if (event.getCursor()!=null || event.getCurrentItem()!=null) { if (event.getCursor().getType()==Material.SULPHUR) { @@ -12995,43 +13074,16 @@ implements Listener } }, 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;iMain.SERVER_TICK_TIME) { //Parse the amount. double val=0; @@ -16006,9 +16078,7 @@ implements Listener if (Bukkit.getOnlinePlayers()[i].getOpenInventory().getTopInventory().getTitle().contains("Ender Item Cube") && Bukkit.getOnlinePlayers()[i].getOpenInventory().getTopInventory().getTitle().length()>0) { if (Integer.valueOf(Bukkit.getOnlinePlayers()[i].getOpenInventory().getTopInventory().getTitle().substring(Bukkit.getOnlinePlayers()[i].getOpenInventory().getTopInventory().getTitle().indexOf("#")).replace("#", ""))==cube_id) { //It is! We need to close it out and re-open with the updated properties of the cube. - Inventory new_inven = player.getOpenInventory().getTopInventory(); - Bukkit.getOnlinePlayers()[i].closeInventory(); - Bukkit.getOnlinePlayers()[i].openInventory(new_inven); + ItemCube_load(Bukkit.getOnlinePlayers()[i], cube_id, Cube.ENDER); } } } @@ -16026,7 +16096,7 @@ implements Listener if (Bukkit.getOnlinePlayers()[i].getOpenInventory().getTopInventory().getTitle().contains("Ender Item Cube") && Bukkit.getOnlinePlayers()[i].getOpenInventory().getTopInventory().getTitle().length()>0) { if (Integer.valueOf(Bukkit.getOnlinePlayers()[i].getOpenInventory().getTopInventory().getTitle().substring(Bukkit.getOnlinePlayers()[i].getOpenInventory().getTopInventory().getTitle().indexOf("#")).replace("#", ""))==cube_id) { //It is! "Add" it to that inventory list too. - player.getOpenInventory().getTopInventory().addItem(add_item); + Bukkit.getOnlinePlayers()[i].getOpenInventory().getTopInventory().addItem(add_item); } } } @@ -16034,6 +16104,57 @@ implements Listener } } + private void ItemCube_save(Player p, int identifier, Cube size) { + FileConfiguration f = this.plugin.reloadItemCubeConfig(identifier); + int slots = -1; + String heading = ""; + switch (size) { + case SMALL: { + slots = 9; + heading = ""; + }break; + case LARGE: { + slots = 54; + heading = "Large"; + }break; + case ENDER: { + slots = 27; + heading = "Ender"; + }break; + } + for (int i=0;i