diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index 3f20b75..7aafbe0 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/plugin.yml b/src/plugin.yml index 05dba46..3e52a35 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper -version: 3.4.3e2 +version: 3.4.4 commands: money: description: Tells the player the amount of money they are holding. @@ -52,6 +52,16 @@ commands: usage: /servertype permission: TwosideKeeper.servertype permission-message: No permissions! + ess: + description: Generates a Mysterious Essence report. + usage: /ess + permission: TwosideKeeper.report + permission-message: No permissions! + mega: + description: Generates a Mega Piece. + usage: /mega + permission: TwosideKeeper.mega + permission-message: No permissions! fix: description: Does many things depending on what item is being held. Typically if it's broken, typing this will help. usage: /fix diff --git a/src/sig/plugin/TwosideKeeper/Artifact.java b/src/sig/plugin/TwosideKeeper/Artifact.java index ed232fe..720c383 100644 --- a/src/sig/plugin/TwosideKeeper/Artifact.java +++ b/src/sig/plugin/TwosideKeeper/Artifact.java @@ -6,12 +6,14 @@ import java.util.List; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Monster; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.material.MaterialData; import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem; import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItemType; +import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; public class Artifact { @@ -62,6 +64,7 @@ public class Artifact { break; case MYSTERIOUS_ESSENCE: i=new ItemStack(Material.PUMPKIN_SEEDS,amt); + TwosideKeeper.EssenceLogger.AddGeneralEssence(); break; case ARTIFACT_RECIPE: i=new ItemStack(Material.STAINED_GLASS_PANE,amt); diff --git a/src/sig/plugin/TwosideKeeper/ChargeZombie.java b/src/sig/plugin/TwosideKeeper/ChargeZombie.java new file mode 100644 index 0000000..74c3e5c --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/ChargeZombie.java @@ -0,0 +1,187 @@ +package sig.plugin.TwosideKeeper; + +import org.bukkit.block.Block; +import org.bukkit.entity.Monster; + +import aPlugin.BlockUtils; +import sig.plugin.TwosideKeeper.HelperStructures.BlockToughness; + +public class ChargeZombie { + Monster m; + + public ChargeZombie(Monster m) { + this.m=m; + } + + public Monster GetZombie() { + return m; + } + public boolean isAlive() { + return !m.isDead(); + } + public boolean hasTarget() { + return (m.getTarget()!=null)?true:false; + } + + public void BreakBlocksAroundArea(int radius) { + for (int x=-radius;x lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+GetHardenedBreaks(mat_type)); + sword_meta.setLore(lore); + raresword.setItemMeta(sword_meta); + raresword = addEnchantments(raresword,true); + } + return raresword; + } + + private static int GetHardenedBreaks(Material type) { + if (type.toString().contains("STONE")) { + return (int)((Math.random()*3)+2); + } else + if (type.toString().contains("IRON")) { + return (int)((Math.random()*4)+3); + } else + if (type.toString().contains("DIAMOND")) { + return (int)((Math.random()*7)+5); + } else + if (type.toString().contains("GOLD")) { + return (int)((Math.random()*12)+10); + } else + { + return 5; + } + } + + private static int GetEnchantmentLevels(Material type) { + return GetEnchantmentLevels(type, false); + } + + private static int GetEnchantmentLevels(Material type, boolean hardened) { + int enchantment_level = 0; + if (type.toString().contains("STONE")) { + enchantment_level = (int)(((Math.random()*3)+2)*((hardened)?HARDENED_ENCHANT_MULT:1)); + } else + if (type.toString().contains("IRON")) { + enchantment_level = (int)(((Math.random()*4)+3)*((hardened)?HARDENED_ENCHANT_MULT:1)); + } else + if (type.toString().contains("DIAMOND")) { + enchantment_level = (int)(((Math.random()*4)+5)*((hardened)?HARDENED_ENCHANT_MULT:1)); + } else + if (type.toString().contains("GOLD")) { + enchantment_level = (int)(((Math.random()*5)+6)*((hardened)?HARDENED_ENCHANT_MULT:1)); + } else + if (type.toString().contains("BOW")) { + enchantment_level = (int)(((Math.random()*5)+6)*((hardened)?HARDENED_ENCHANT_MULT:1)); + } else + { + enchantment_level = (int)(((Math.random()*9))*((hardened)?HARDENED_ENCHANT_MULT:1)); + } + + if (enchantment_level>MAX_ENCHANT_LEVEL) { + enchantment_level = 10; + } + + return enchantment_level; + } + + private static ItemStack addEnchantments(ItemStack item, boolean hardened) { + if (GenericFunctions.isHarvestingTool(item)) { + item.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.DIG_SPEED, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.DURABILITY, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.KNOCKBACK, 2); + if (item.getType().toString().contains("HOE")) {item.addUnsafeEnchantment(Enchantment.KNOCKBACK, 10);} + if (Math.random()<0.2*HARDENED_ENCHANT_MULT) {item.addUnsafeEnchantment(Enchantment.SILK_TOUCH, GetEnchantmentLevels(item.getType(),hardened));} + if (Math.random()<0.2*HARDENED_ENCHANT_MULT) {item.addUnsafeEnchantment(Enchantment.MENDING, GetEnchantmentLevels(item.getType(),hardened));} + } else + if (item.getType()==Material.BOW) { + item.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.ARROW_FIRE, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.DURABILITY, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 2); + if (Math.random()<0.2*HARDENED_ENCHANT_MULT) {item.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, GetEnchantmentLevels(item.getType(),hardened));} + if (Math.random()<0.2*HARDENED_ENCHANT_MULT) {item.addUnsafeEnchantment(Enchantment.MENDING, GetEnchantmentLevels(item.getType(),hardened));} + } else + if (GenericFunctions.isWeapon(item)) { + item.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.DURABILITY, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); + if (Math.random()<0.2*HARDENED_ENCHANT_MULT) {item.addUnsafeEnchantment(Enchantment.MENDING, GetEnchantmentLevels(item.getType(),hardened));} + } else + if (GenericFunctions.isArmor(item)) { + item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, GetEnchantmentLevels(item.getType(),hardened)); + if (Math.random()<0.5*HARDENED_ENCHANT_MULT) {item.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, GetEnchantmentLevels(item.getType(),hardened));} + if (Math.random()<0.5*HARDENED_ENCHANT_MULT) {item.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, GetEnchantmentLevels(item.getType(),hardened));} + if (Math.random()<0.5*HARDENED_ENCHANT_MULT) {item.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, GetEnchantmentLevels(item.getType(),hardened));} + if (Math.random()<0.5*HARDENED_ENCHANT_MULT) {item.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, GetEnchantmentLevels(item.getType(),hardened));} + if (Math.random()<0.5*HARDENED_ENCHANT_MULT) {item.addUnsafeEnchantment(Enchantment.DEPTH_STRIDER, GetEnchantmentLevels(item.getType(),hardened));} + if (Math.random()<0.5*HARDENED_ENCHANT_MULT) {item.addUnsafeEnchantment(Enchantment.WATER_WORKER, GetEnchantmentLevels(item.getType(),hardened));} + if (Math.random()<0.5*HARDENED_ENCHANT_MULT) {item.addUnsafeEnchantment(Enchantment.OXYGEN, GetEnchantmentLevels(item.getType(),hardened));} + if (Math.random()<0.2*HARDENED_ENCHANT_MULT) {item.addUnsafeEnchantment(Enchantment.FROST_WALKER, GetEnchantmentLevels(item.getType(),hardened));} + if (Math.random()<0.08*HARDENED_ENCHANT_MULT) {item.addUnsafeEnchantment(Enchantment.THORNS, GetEnchantmentLevels(item.getType(),hardened));} + item.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); + if (Math.random()<0.2*HARDENED_ENCHANT_MULT) {item.addUnsafeEnchantment(Enchantment.MENDING, GetEnchantmentLevels(item.getType(),hardened));} + } else + if (item.getType()==Material.FISHING_ROD) { + item.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.DURABILITY, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.LUCK, GetEnchantmentLevels(item.getType(),hardened)); + item.addUnsafeEnchantment(Enchantment.LURE, GetEnchantmentLevels(item.getType(),hardened)); + } else { + //Generic Random Enchantments. + for (int i=0;i lore = m.getLore(); - lore.remove(2); - lore.add(2,ChatColor.BLUE+""+TwosideKeeper.getServerTickTime()); + lore.remove(3); + lore.add(3,ChatColor.BLUE+""+TwosideKeeper.getServerTickTime()); m.setLore(lore); base.setItemMeta(m); return base; diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java b/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java index 6ea2228..07e438d 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java @@ -1,8 +1,227 @@ package sig.plugin.TwosideKeeper.HelperStructures; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import sig.plugin.TwosideKeeper.TwosideKeeper; +import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; + public enum MonsterDifficulty { - NORMAL, - DANGEROUS, - DEADLY, - HELLFIRE + + NORMAL( //Contains info about loot for everything. + new LootStructure[]{ //Regular Loot + + }, + new LootStructure[]{ //Rare Loot + new LootStructure(Material.STONE_SWORD, false), + new LootStructure(ArtifactItem.ARTIFACT_ESSENCE,1), + }, + new LootStructure[]{ //Legendary Loot + new LootStructure(ArtifactItem.ARTIFACT_CORE,1), + new LootStructure(Material.STONE_SWORD, true), + } + ), + DANGEROUS( + new LootStructure[]{ //Regular Loot + new LootStructure(Material.IRON_INGOT,false), + }, + new LootStructure[]{ //Rare Loot + new LootStructure(ArtifactItem.ANCIENT_ESSENCE,1), + new LootStructure(Material.IRON_BLOCK,false), + new LootStructure(Material.IRON_SWORD, false), + new LootStructure(Material.IRON_CHESTPLATE, false), + new LootStructure(Material.IRON_LEGGINGS, false), + new LootStructure(Material.IRON_BOOTS, false), + new LootStructure(Material.IRON_HELMET, false), + new LootStructure(Material.STONE_AXE, false), + new LootStructure(Material.STONE_PICKAXE, false), + new LootStructure(Material.STONE_HOE, false), + new LootStructure(Material.STONE_SPADE, false), + new LootStructure(Material.FISHING_ROD, false), + }, + new LootStructure[]{ //Legendary Loot + new LootStructure(ArtifactItem.ANCIENT_CORE,1), + new LootStructure(Material.IRON_SWORD, true), + new LootStructure(Material.IRON_CHESTPLATE, true), + new LootStructure(Material.IRON_LEGGINGS, true), + new LootStructure(Material.IRON_BOOTS, true), + new LootStructure(Material.IRON_HELMET, true), + new LootStructure(Material.STONE_AXE, true), + new LootStructure(Material.STONE_PICKAXE, true), + new LootStructure(Material.STONE_HOE, true), + new LootStructure(Material.STONE_SPADE, true), + new LootStructure(Material.FISHING_ROD, true), + } + ), + DEADLY( + new LootStructure[]{ //Regular Loot + new LootStructure(Material.IRON_INGOT,(int)((Math.random()*2)+1)), + new LootStructure(Material.DIAMOND), + new LootStructure(Material.GOLD_NUGGET,(int)((Math.random()*3)+1)), + }, + new LootStructure[]{ //Rare Loot + new LootStructure(ArtifactItem.LOST_ESSENCE,1), + new LootStructure(Material.IRON_BLOCK,(int)((Math.random()*2)+1)), + new LootStructure(Material.DIAMOND_BLOCK), + new LootStructure(Material.GOLD_INGOT,(int)((Math.random()*3)+1)), + new LootStructure(Material.DIAMOND_SWORD, false), + new LootStructure(Material.IRON_AXE, false), + new LootStructure(Material.IRON_PICKAXE, false), + new LootStructure(Material.IRON_HOE, false), + new LootStructure(Material.IRON_SPADE, false), + new LootStructure(Material.DIAMOND_CHESTPLATE, false), + new LootStructure(Material.DIAMOND_LEGGINGS, false), + new LootStructure(Material.DIAMOND_BOOTS, false), + new LootStructure(Material.DIAMOND_HELMET, false), + new LootStructure(Material.FISHING_ROD, false), + new LootStructure(Material.BOW, false), + }, + new LootStructure[]{ //Legendary Loot + new LootStructure(ArtifactItem.LOST_CORE,1), + new LootStructure(Material.DIAMOND_SWORD, true), + new LootStructure(Material.IRON_AXE, true), + new LootStructure(Material.IRON_PICKAXE, true), + new LootStructure(Material.IRON_HOE, true), + new LootStructure(Material.IRON_SPADE, true), + new LootStructure(Material.FISHING_ROD, true), + new LootStructure(Material.DIAMOND_CHESTPLATE, true), + new LootStructure(Material.DIAMOND_LEGGINGS, true), + new LootStructure(Material.DIAMOND_BOOTS, true), + new LootStructure(Material.DIAMOND_HELMET, true), + new LootStructure(Material.FISHING_ROD, true), + } + ), + HELLFIRE( + new LootStructure[]{ //Regular Loot + new LootStructure(Material.EMERALD,(int)((Math.random()*3)+1)), + new LootStructure(Material.DIAMOND,(int)((Math.random()*3)+1)), + new LootStructure(Material.GOLD_INGOT,(int)((Math.random()*3)+1)), + }, + new LootStructure[]{ //Rare Loot + new LootStructure(ArtifactItem.DIVINE_ESSENCE,1), + new LootStructure(Material.EMERALD_BLOCK), + new LootStructure(Material.DIAMOND_BLOCK,(int)((Math.random()*2)+1)), + new LootStructure(Material.GOLD_BLOCK), + new LootStructure(Material.DIAMOND_SWORD, false), + new LootStructure(Material.GOLD_SWORD, false), + new LootStructure(Material.DIAMOND_AXE, false), + new LootStructure(Material.DIAMOND_PICKAXE, false), + new LootStructure(Material.DIAMOND_HOE, false), + new LootStructure(Material.DIAMOND_SPADE, false), + new LootStructure(Material.DIAMOND_CHESTPLATE, false), + new LootStructure(Material.DIAMOND_LEGGINGS, false), + new LootStructure(Material.DIAMOND_BOOTS, false), + new LootStructure(Material.DIAMOND_HELMET, false), + new LootStructure(Material.GOLD_CHESTPLATE, false), + new LootStructure(Material.GOLD_LEGGINGS, false), + new LootStructure(Material.GOLD_BOOTS, false), + new LootStructure(Material.GOLD_HELMET, false), + new LootStructure(Material.BOW, false), + new LootStructure(Material.FISHING_ROD, false), + }, + new LootStructure[]{ //Legendary Loot + new LootStructure(ArtifactItem.DIVINE_CORE,1), + new LootStructure(Material.GOLD_SWORD, true), + new LootStructure(Material.DIAMOND_SWORD, true), + new LootStructure(Material.DIAMOND_AXE, true), + new LootStructure(Material.DIAMOND_PICKAXE, true), + new LootStructure(Material.DIAMOND_HOE, true), + new LootStructure(Material.DIAMOND_SPADE, true), + new LootStructure(Material.DIAMOND_CHESTPLATE, true), + new LootStructure(Material.DIAMOND_LEGGINGS, true), + new LootStructure(Material.DIAMOND_BOOTS, true), + new LootStructure(Material.DIAMOND_HELMET, true), + new LootStructure(Material.GOLD_CHESTPLATE, true), + new LootStructure(Material.GOLD_LEGGINGS, true), + new LootStructure(Material.GOLD_BOOTS, true), + new LootStructure(Material.GOLD_HELMET, true), + new LootStructure(Material.BOW, true), + new LootStructure(Material.FISHING_ROD, true), + } + ); + + LootStructure[] loot_regular; + LootStructure[] loot_rare; + LootStructure[] loot_legendary; + + private MonsterDifficulty(LootStructure[] loot_regular, LootStructure[] loot_rare, LootStructure[] loot_legendary) { + this.loot_regular=loot_regular; + this.loot_rare=loot_rare; + this.loot_legendary=loot_legendary; + } + + private ItemStack Artifact() { + sig.plugin.TwosideKeeper.Artifact.createArtifactItem(ArtifactItem.ARTIFACT_ESSENCE,3); + return null; + } + + public List RandomizeDrops(double dropmult, boolean isBoss) { + List droplist = new ArrayList(); + dropmult += 1; //Base dropmult is 1.0. + + //Basically for each additional dropmult integer value, the + //amount of rolls increases. (A dropmult of 1.0 is required for + //an additional roll.) + for (int i=0;i0) { + //This is a common roll. + ItemStack gen_loot = DistributeRandomLoot(this.loot_regular); + TwosideKeeper.log("Adding "+gen_loot.toString()+" to loot table.", 2); + droplist.add(gen_loot); + } + //Rare Loot roll. + if (Math.random()0) { + //This is a common roll. + ItemStack gen_loot = DistributeRandomLoot(this.loot_rare); + TwosideKeeper.log("Adding "+gen_loot.toString()+" to loot table.", 2); + droplist.add(gen_loot); + } + //Legendary Loot roll. + if (Math.random()0) { + //This is a common roll. + ItemStack gen_loot = DistributeRandomLoot(this.loot_legendary); + TwosideKeeper.log("Adding "+gen_loot.toString()+" to loot table.", 2); + droplist.add(gen_loot); + } + if (isBoss) { //50% of the time, we drop something great. + if (Math.random()<=0.5 && this.loot_legendary.length>0) { + ItemStack gen_loot = DistributeRandomLoot(this.loot_legendary); + TwosideKeeper.log("Adding "+gen_loot.toString()+" to loot table.", 2); + droplist.add(gen_loot); + } + else + if (this.loot_rare.length>0) { //Consolation Prize. + ItemStack gen_loot = DistributeRandomLoot(this.loot_rare); + TwosideKeeper.log("Adding "+gen_loot.toString()+" to loot table.", 2); + droplist.add(gen_loot); + } + } + } + + return droplist; + } + + private ItemStack DistributeRandomLoot(LootStructure[] lootlist) { + //Choose an item randomly from the loot list. + if (lootlist.length>0) { + //Choose an element. + LootStructure ls = lootlist[(int)((Math.random())*lootlist.length)]; + if (GenericFunctions.isEquip(new ItemStack(ls.GetMaterial()))) { + //Turn it into a Mega Piece. + return Loot.GenerateMegaPiece(ls.GetMaterial(), ls.GetHardened()); + } else { + //Turn it into a normal item. + return new ItemStack(ls.GetMaterial(),ls.GetAmount()); + } + } else { //Something bad happened if we got here... + return new ItemStack(Material.AIR); + } + } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java b/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java index f31f750..87232b3 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java @@ -105,7 +105,7 @@ public class WorldShop { String message = ""; for (int i=0;i0) { message+="\n\n"+ChatColor.GRAY+"Durability: "+(item.getType().getMaxDurability()-item.getDurability()-1)+"/"+(item.getType().getMaxDurability()-1); } - if (item.getItemMeta() instanceof Repairable) { + if (item.getItemMeta() instanceof Repairable && + GenericFunctions.isEquip(item)) { Repairable rep = (Repairable)item.getItemMeta(); + int repairs = 0; if (rep.hasRepairCost()) { - message+="\n\n"+ChatColor.GRAY+"Repair Cost: "+(item.getType().getMaxDurability()-item.getDurability()-1)+"/"+(item.getType().getMaxDurability()-1); + int cost = rep.getRepairCost(); + while (cost>0) { + cost/=2; + repairs++; + } + } else { + repairs=0; } + message+="\n"+ChatColor.GRAY+"Repairs Left: "+(6-repairs); } return message; } diff --git a/src/sig/plugin/TwosideKeeper/Logging/MysteriousEssenceLogger.java b/src/sig/plugin/TwosideKeeper/Logging/MysteriousEssenceLogger.java new file mode 100644 index 0000000..5216b30 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/Logging/MysteriousEssenceLogger.java @@ -0,0 +1,33 @@ +package sig.plugin.TwosideKeeper.Logging; + +import java.text.DecimalFormat; + +import org.bukkit.ChatColor; + +public class MysteriousEssenceLogger { + int essence_hellfire = 0; + int essence_other = 0; + int essence_despawned = 0; + public MysteriousEssenceLogger() { + + } + public void AddHellfireEssence() { + essence_hellfire++; + } + public void AddGeneralEssence() { + essence_other++; + } + public void AddEssenceDespawn() { + essence_despawned++; + } + public String GenerateReport() { + DecimalFormat df = new DecimalFormat("0.0"); + if (essence_hellfire+essence_other>0) { + return "Total Essences Spawned: "+ChatColor.YELLOW+(essence_hellfire+essence_other)+ChatColor.WHITE+"\n"+ + "Total Essences from Hellfires: "+ChatColor.YELLOW+essence_hellfire+ChatColor.RED+" ("+df.format(((double)essence_hellfire/(essence_other+essence_hellfire))*100)+"%)\n"+ChatColor.WHITE + + "Total Essences Despawned: "+ChatColor.YELLOW+essence_despawned+ChatColor.BLUE+" ("+df.format(((double)essence_despawned/(essence_other+essence_hellfire))*100)+"%)"; + } else { + return "Not enough data yet!"; + } + } +} diff --git a/src/sig/plugin/TwosideKeeper/MonsterController.java b/src/sig/plugin/TwosideKeeper/MonsterController.java index e933990..b4b76e6 100644 --- a/src/sig/plugin/TwosideKeeper/MonsterController.java +++ b/src/sig/plugin/TwosideKeeper/MonsterController.java @@ -4,8 +4,12 @@ import java.util.ArrayList; import java.util.List; import org.bukkit.ChatColor; +import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Banner; +import org.bukkit.block.banner.Pattern; +import org.bukkit.block.banner.PatternType; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; @@ -14,7 +18,10 @@ import org.bukkit.entity.Skeleton; import org.bukkit.entity.Zombie; import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; +import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.material.MaterialData; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -290,7 +297,8 @@ public class MonsterController { m.getEquipment().setItemInMainHand(weapon); } if (Math.random()<0.2) { - m.getEquipment().setItemInOffHand(new ItemStack(Material.SHIELD)); + ItemStack shield = new ItemStack(Material.SHIELD,1,(short)((Math.random()*DyeColor.values().length))); + m.getEquipment().setItemInOffHand(shield); } } else { ItemStack weapon = new ItemStack(Material.BOW); @@ -397,7 +405,8 @@ public class MonsterController { m.getEquipment().setItemInMainHand(weapon); } if (Math.random()<0.5) { - m.getEquipment().setItemInOffHand(new ItemStack(Material.SHIELD)); + ItemStack shield = new ItemStack(Material.SHIELD,1,(short)((Math.random()*DyeColor.values().length))); + m.getEquipment().setItemInOffHand(shield); } } else { ItemStack weapon = new ItemStack(Material.BOW); @@ -628,7 +637,9 @@ public class MonsterController { //m.setCustomNameVisible(true); m.setMaxHealth(m.getMaxHealth()*4.0); m.setHealth(m.getMaxHealth()); - m.setFireTicks(999999); + if (m.getType()!=EntityType.ENDERMAN) { + m.setFireTicks(999999); + } if (isAllowedToEquipItems(m)) { m.getEquipment().clear(); RandomizeEquipment(m,3); diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 1530363..ba1d014 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -140,6 +140,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.SpleefArena; import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; import sig.plugin.TwosideKeeper.HelperStructures.WorldShopSession; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; +import sig.plugin.TwosideKeeper.Logging.MysteriousEssenceLogger; public class TwosideKeeper extends JavaPlugin implements Listener { @@ -167,7 +168,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static double ENEMY_DMG_MULT=1.0f; // public static double EXPLOSION_DMG_MULT=1.2f; // public static double HEADSHOT_ACC=1.0f; //How accurate headshots have to be. Lower values means more leniency on headshots. Higher values means more strict. - public static double RARE_DROP_RATE=0.0052; + public static double COMMON_DROP_RATE=0.5; // 1/2 chance + public static double RARE_DROP_RATE=0.010417; // 1/96 chance + public static double LEGENDARY_DROP_RATE=0.0052; // 1/192 chance public static int PARTY_CHUNK_SIZE=16; //The number of chunks each party spans. public double XP_CONVERSION_RATE=0.01; //How much money per exp point? public static int WORLD_SHOP_ID=0; //The shop ID number we are on. @@ -178,10 +181,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static HashMap playerdata; public static SpleefManager TwosideSpleefGames; public WorldShopManager TwosideShops; + public static MysteriousEssenceLogger EssenceLogger; //The logger for Essences. public int TeamCounter = 0; public List PartyList = new ArrayList(); public List colors_used = new ArrayList(); + public List chargezombies = new ArrayList(); public RecyclingCenter TwosideRecyclingCenter; @@ -236,6 +241,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { STARTTIME=Bukkit.getWorld("world").getFullTime(); LASTSERVERCHECK=getServerTickTime(); + EssenceLogger = new MysteriousEssenceLogger(); + + chargezombies = new ArrayList(); + TwosideRecyclingCenter = new RecyclingCenter(); TwosideRecyclingCenter.loadConfig(); log("Recycling Centers Loaded: "+TwosideRecyclingCenter.getNumberOfNodes(),3); @@ -282,7 +291,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { @Override public void run() { - DiscordMessageSender.sendItalicizedRawMessageDiscord(SERVER_TYPE.GetServerName()+"Server has been restarted.\nRunning v."+Bukkit.getPluginManager().getPlugin("TwosideKeeper").getDescription().getVersion()+" of TwosideKeeper\nRunning v"+Bukkit.getPluginManager().getPlugin("aPlugin").getDescription().getVersion()+" of Jobs."); + boolean sent=false; + do {DiscordMessageSender.sendItalicizedRawMessageDiscord(SERVER_TYPE.GetServerName()+"Server has been restarted.\nRunning v."+Bukkit.getPluginManager().getPlugin("TwosideKeeper").getDescription().getVersion()+" of TwosideKeeper\nRunning v"+Bukkit.getPluginManager().getPlugin("aPlugin").getDescription().getVersion()+" of Jobs.");} while (!Bukkit.getPluginManager().isPluginEnabled("aPlugin")); } },100); } @@ -298,7 +308,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (getServerTickTime()-LASTSERVERCHECK>=SERVERCHECKERTICKS) { //15 MINUTES (DEFAULT) saveOurData(); - //Advertisement messages could go here. //MOTD: "Thanks for playing on Sig's Minecraft!\n*bCheck out http://z-gamers.net/mc for update info!\n*aReport any bugs you find at http://zgamers.domain.com/mc/" getMOTD(); @@ -370,6 +379,19 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } + //Control charge zombies.. + for (int i=0;i32) { + //This has to be removed... + chargezombies.remove(i); + i--; + } else { + //This is fine! Clear away blocks. + cz.BreakBlocksAroundArea(1); + } + } + //See if each player needs to regenerate their health. for (int i=0;i \"},{\"text\":\""+ev.getMessage().substring(0, pos)+"\"},{\"text\":\""+ChatColor.GREEN+"["+ChatColor.stripColor(GenericFunctions.GetItemName(ev.getPlayer().getEquipment().getItemInMainHand()))+ChatColor.GREEN+"]"+ChatColor.WHITE+"\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\""+GenericFunctions.GetItemName(ev.getPlayer().getEquipment().getItemInMainHand())+"\n"+WorldShop.GetItemInfo(ev.getPlayer().getEquipment().getItemInMainHand()).replace("\"", "\\\"")+"\"}},{\"text\":\""+ev.getMessage().substring(pos)+"\"}]"); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"tellraw @a [\"\",{\"text\":\"<"+ev.getPlayer().getName()+"> \"},{\"text\":\""+ev.getMessage().substring(0, pos)+"\"},{\"text\":\""+ChatColor.GREEN+"["+ChatColor.stripColor(GenericFunctions.GetItemName(ev.getPlayer().getEquipment().getItemInMainHand()))+ChatColor.GREEN+"]"+ChatColor.WHITE+"\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\""+GenericFunctions.GetItemName(ev.getPlayer().getEquipment().getItemInMainHand())+""+WorldShop.GetItemInfo(ev.getPlayer().getEquipment().getItemInMainHand()).replace("\"", "\\\"")+"\"}},{\"text\":\""+ev.getMessage().substring(pos)+"\"}]"); ev.setCancelled(true); } //Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"tellraw @a [\"\",{\"text\":\""+ChatColor.GREEN+"[Item]"+ChatColor.WHITE+"\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\""+(ev.getPlayer().getEquipment().getItemInMainHand().getType())+"\"}},{\"text\":\" "+ev.getMessage().substring(0, pos)+" \"}]"); @@ -1344,15 +1367,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } },8); - /* - if (p.isBlocking()) { - //Give absorption hearts. - if (isDefender(p)) { - p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,10,2)); - } else { - p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,10,1)); - } - }*/ } //Check for a Malleable Base right-click. @@ -1403,9 +1417,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (ev.getAction()==Action.RIGHT_CLICK_BLOCK && ev.getClickedBlock().getType()==Material.BED_BLOCK) { Location BedPos=ev.getClickedBlock().getLocation(); + Location oldBedPos = ev.getPlayer().getBedSpawnLocation(); log(ev.getPlayer()+" Right-clicked bed. Set bed spawn to "+BedPos.toString(),3); ev.getPlayer().setBedSpawnLocation(BedPos); - ev.getPlayer().sendMessage(ChatColor.BLUE+""+ChatColor.ITALIC+"New bed respawn location set."); + if (!oldBedPos.equals(BedPos)) { + ev.getPlayer().sendMessage(ChatColor.BLUE+""+ChatColor.ITALIC+"New bed respawn location set."); + } } if (ev.getAction()==Action.RIGHT_CLICK_BLOCK && ev.getClickedBlock().getType().toString().contains("RAIL") && @@ -2509,6 +2526,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Item i = ev.getEntity(); //If the item is a display item, respawn it. + if (Artifact.isMysteriousEssence(i.getItemStack())) { + EssenceLogger.AddEssenceDespawn(); + } + if (i!=null && i.getCustomName()!=null && i.getItemStack().hasItemMeta() && i.getItemStack().getItemMeta().hasLore() && @@ -2566,7 +2587,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { @EventHandler(priority=EventPriority.LOW) public void MonsterSpawnEvent(CreatureSpawnEvent ev) { log("Reason for spawn: "+ev.getSpawnReason().toString(),5); - if (ev.getSpawnReason().equals(SpawnReason.NATURAL) && + if ((ev.getSpawnReason().equals(SpawnReason.NATURAL) || + ev.getSpawnReason().equals(SpawnReason.SPAWNER_EGG)) && ev.getEntity() instanceof Monster) { if (!MonsterController.MobHeightControl(ev.getEntity())) { ev.setCancelled(true); @@ -2602,10 +2624,32 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public void updateHealthbarDamageEvent(EntityDamageEvent ev) { Entity e = ev.getEntity(); if (e instanceof Player) { + log("Damage reason is "+ev.getCause().toString(),4); final Player p = (Player)e; if (ev.getCause()==DamageCause.ENTITY_EXPLOSION || ev.getCause()==DamageCause.BLOCK_EXPLOSION) { - ev.setDamage(ev.getDamage()*EXPLOSION_DMG_MULT); + //Calculate new damage based on armor worn. + //Remove all other damage modifiers since we will calculate it manually. + ev.setDamage(DamageModifier.BLOCKING,0); + ev.setDamage(DamageModifier.MAGIC,0); + ev.setDamage(DamageModifier.RESISTANCE,0); + ev.setDamage(DamageModifier.ARMOR,0); + + //Damage reduction is also set based on how much blast resistance we have. + + ItemStack[] armor = p.getEquipment().getArmorContents(); + + int protectionlevel = 0; + for (int i=0;i droplist = ev.getDrops(); + + Monster m = (Monster)ev.getEntity(); + + double dropmult = 0.0d; + boolean isBoss=false; + boolean killedByPlayer = false; + final Location deathloc = m.getLocation(); + + if (m.getKiller()!=null) { + killedByPlayer = true; + } + if (m.getKiller() instanceof Player) { Player p = (Player)m.getKiller(); PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId()); - dropmult+=pd.partybonus*0.1; + dropmult+=pd.partybonus*0.33; //Party bonus increases drop rate by 33% per party member. ItemStack item = p.getEquipment().getItemInMainHand(); if (item!=null && item.getType()!=Material.AIR && GenericFunctions.isWeapon(item)) { - dropmult+=item.getEnchantmentLevel(Enchantment.LOOT_BONUS_MOBS)*0.1; + dropmult+=item.getEnchantmentLevel(Enchantment.LOOT_BONUS_MOBS)*0.1; //Looting increases drop rate by 10% per level. } } - if (Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) { - ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ARTIFACT_ESSENCE)); - } - if ((m.getType()==EntityType.ZOMBIE && - MonsterController.isZombieLeader(m)) || - (m.getType()==EntityType.GUARDIAN && - ((Guardian)m).isElder()) || - m.getType()==EntityType.ENDER_DRAGON || - m.getType()==EntityType.WITHER) { - ev.setDroppedExp(ev.getDroppedExp()*6); - dropmult+=3.5; - } - if (m.getType()==EntityType.GUARDIAN || - m.getType()==EntityType.SKELETON) { - boolean allowed=false; - if (m.getType()==EntityType.SKELETON) { - Skeleton s = (Skeleton)m; - if (s.getSkeletonType()==SkeletonType.WITHER) { - allowed=true; - } - } else { - allowed=true; - } - if (allowed && Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) { - switch ((int)(Math.random()*4)) { - case 0:{ - ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.LOST_CORE,2)); - }break; - case 1:{ - ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ANCIENT_CORE,2)); - }break; - case 2:{ - ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ARTIFACT_CORE,2)); - }break; - case 3:{ - ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.DIVINE_CORE,2)); - }break; - } - } - } - if (m.getType()==EntityType.ENDER_DRAGON || - m.getType()==EntityType.WITHER) { + + isBoss=GenericFunctions.isBossMonster(m); + + if (killedByPlayer && GenericFunctions.isCoreMonster(m) && Math.random() lore = new ArrayList(); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"2"); - sword_meta.setLore(lore); - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 10); - } - ev.getDrops().add(raresword); - } - if (Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) { - ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ANCIENT_ESSENCE)); - } - } - } - if (m.getCustomName().contains("Deadly")) { - m.getWorld().playSound(m.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f); - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - public void run() { - if (m.getLocation().getBlockY()<48) { - m.getWorld().createExplosion(m.getLocation().getBlockX(), m.getLocation().getBlockY(), m.getLocation().getBlockZ(), 3.0f, false, true); - } else { - m.getWorld().createExplosion(m.getLocation().getBlockX(), m.getLocation().getBlockY(), m.getLocation().getBlockZ(), 6.0f, false, false); - } - }} - ,20); - if (m.getKiller()!=null) { //Make sure a player actually killed this. - ev.setDroppedExp(ev.getDroppedExp()*8); - - if (Math.random()<0.5*dropmult) { - //m.getWorld().dropItemNaturally(m.getLocation(), new ItemStack(Material.DIAMOND)); - ev.getDrops().add(new ItemStack(Material.DIAMOND)); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); - sword_meta.setLore(lore); - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 10); - } - ev.getDrops().add(raresword); - if (Math.random()<0.1) { - ev.getDrops().add(raresword); - } - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); - lore.add(ChatColor.GRAY+"Twice as strong"); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); - sword_meta.setLore(lore); - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - } - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); - lore.add(ChatColor.GRAY+"Twice as strong"); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); - sword_meta.setLore(lore); - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - } - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); - lore.add(ChatColor.GRAY+"Twice as strong"); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); - sword_meta.setLore(lore); - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - } - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); - lore.add(ChatColor.GRAY+"Twice as strong"); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); - sword_meta.setLore(lore); - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - } - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); - sword_meta.setLore(lore); - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); - raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 10); - raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - } - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); - sword_meta.setLore(lore); - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); - raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10); - raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - } - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); - sword_meta.setLore(lore); - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); - raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 10); - raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - } - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); - sword_meta.setLore(lore); - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); - raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10); - raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - } - ev.getDrops().add(raresword); - } - if (Math.random() drops = new ArrayList(); - drops.addAll(ev.getDrops()); - ev.getDrops().clear(); - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + + if (killedByPlayer) { + droplist.addAll(MonsterController.getMonsterDifficulty((Monster)ev.getEntity()).RandomizeDrops(dropmult, isBoss)); + final List drop = new ArrayList(); + drop.addAll(droplist); + + droplist.clear(); //Clear the drop list. We are going to delay the drops. + + //Determine EXP amount and explosion type. + switch (MonsterController.getMonsterDifficulty(m)) { + case DANGEROUS: + ev.setDroppedExp(ev.getDroppedExp()*4); + break; + case DEADLY: + m.getWorld().playSound(m.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f); + ev.setDroppedExp(ev.getDroppedExp()*8); + final Monster mer = m; + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { - for (int i=0;i lore = new ArrayList(); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*7)+4)); - sword_meta.setLore(lore); - } - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); - lore.add(ChatColor.GRAY+"Twice as strong"); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*7)+4)); - sword_meta.setLore(lore); - } - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); - lore.add(ChatColor.GRAY+"Twice as strong"); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*7)+4)); - sword_meta.setLore(lore); - } - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); - lore.add(ChatColor.GRAY+"Twice as strong"); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*7)+4)); - sword_meta.setLore(lore); - } - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); - lore.add(ChatColor.GRAY+"Twice as strong"); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*7)+4)); - sword_meta.setLore(lore); - } - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); - lore.add(ChatColor.GRAY+"Twice as strong"); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*14)+8)); - sword_meta.setLore(lore); - } - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); - lore.add(ChatColor.GRAY+"Twice as strong"); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*14)+8)); - sword_meta.setLore(lore); - } - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); - lore.add(ChatColor.GRAY+"Twice as strong"); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*14)+8)); - sword_meta.setLore(lore); - } - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); - lore.add(ChatColor.GRAY+"Twice as strong"); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*14)+8)); - sword_meta.setLore(lore); - } - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); - raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*14)+8)); - sword_meta.setLore(lore); - } - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - ev.getDrops().add(raresword); - } - - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); - sword_meta.setLore(lore); - } - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); - raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 10); - raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); - sword_meta.setLore(lore); - } - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); - raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10); - raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); - sword_meta.setLore(lore); - } - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); - raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 10); - raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); - sword_meta.setLore(lore); - } - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); - raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); - raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10); - raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 10); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - ev.getDrops().add(raresword); - } - if (Math.random() lore = new ArrayList(); - lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*7)+4)); - sword_meta.setLore(lore); - } - raresword.setItemMeta(sword_meta); - raresword.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 10); - raresword.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 2); - raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - ev.getDrops().add(raresword); - } - if (Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) { - ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.DIVINE_ESSENCE)); - } - } - final List drops = new ArrayList(); - drops.addAll(ev.getDrops()); - ev.getDrops().clear(); - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + ,30); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { - for (int i=0;i20) { while (health>20) { color1++; @@ -5115,10 +4529,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { basedmg=1.0; } - if (GenericFunctions.isHardenedItem(weapon)) { - basedmg*=2; - } - //If this is an artifact weapon, we totally override the base damage. if (GenericFunctions.isTool(weapon) && Artifact.isArtifact(weapon)) { //Let's change up the damage. @@ -5130,6 +4540,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } + if (GenericFunctions.isHardenedItem(weapon)) { + basedmg*=2; + } + if (weapon.getType()==Material.BOW) { basedmg = 4.5; } @@ -5203,16 +4617,17 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } + weaknesslevel = (weaknesslevel>10)?10:weaknesslevel; + double finalamt = (basedmg+(sharpnesslevel*0.5)) - /((10-partylevel)*0.1) - /((10-strengthlevel)*0.1) + *(1 + 0.1*partylevel) + *(1 + 0.1*strengthlevel) *((10-weaknesslevel)*0.1); - return finalamt; } - public void DealCalculatedDamage(ItemStack weapon, LivingEntity p, LivingEntity target) { + public void CalculateDamageDealtToMob(ItemStack weapon, LivingEntity p, LivingEntity target) { //Deals custom calculated damage to a given target. //Because we do not want to use Minecraft's built-in combat system, we will //create our own. @@ -5322,6 +4737,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (target.getEquipment().getItemInOffHand().getType()==Material.SHIELD) { hasShield=true; } + + resistlevel=(resistlevel>10)?10:resistlevel; + protectionlevel=(protectionlevel>100)?100:protectionlevel; final double dmgamt = ( basedmg-(basedmg*(dmgreduction/100.0d)) @@ -5379,6 +4797,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } if ((damager instanceof Creeper) && armor[i].getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)>0) { protectionlevel+=armor[i].getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS); + //log("Protection level increased by "+protectionlevel,2); } boolean isBlockArmor = GenericFunctions.isHardenedItem(armor[i]); @@ -5440,15 +4859,20 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //Blocking: -((p.isBlocking())?ev.getDamage()*0.33:0) //33% damage will be reduced if we are blocking. //Shield: -((p.getEquipment().getItemInOffHand()!=null && p.getEquipment().getItemInOffHand().getType()==Material.SHIELD)?ev.getDamage()*0.05:0) //5% damage will be reduced if we are holding a shield. - + resistlevel=(resistlevel>10)?10:resistlevel; + protectionlevel=(protectionlevel>100)?100:protectionlevel; + partylevel=(partylevel>100)?100:partylevel; double finaldmg=(basedmg-(basedmg*(dmgreduction/100.0d))) *((10-resistlevel)*0.1) *((100-protectionlevel)*0.01) *((10-partylevel)*0.1) *((target instanceof Player && ((Player)target).isBlocking())?(GenericFunctions.isDefender((Player)target))?0.30:0.50:1) *((GenericFunctions.isDefender(target))?0.9:(target.getEquipment().getItemInOffHand()!=null && target.getEquipment().getItemInOffHand().getType()==Material.SHIELD)?0.95:1); - - log(finaldmg+" damage calculated for: "+target.getName()+".",5); + + if (basedmg!=finaldmg) { + log("Original damage was: "+basedmg,5); + log(finaldmg+" damage calculated for: "+target.getName()+".",5); + } if (target instanceof Player) { Player p = (Player)target;