diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index eb6bfe7..78c6aa7 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/plugin.yml b/src/plugin.yml index 54ce092..9446caa 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper -version: 3.3.5 +version: 3.4 commands: money: description: Tells the player the amount of money they are holding. @@ -24,7 +24,7 @@ commands: permission-message: No permissions! artifact: description: Gives the player an artifact. - usage: /artifact + usage: /artifact [amt] permission: TwosideKeeper.artifact permission-message: No permissions! recyclingcenter: diff --git a/src/sig/plugin/TwosideKeeper/Artifact.java b/src/sig/plugin/TwosideKeeper/Artifact.java index 6aa82a7..0daae45 100644 --- a/src/sig/plugin/TwosideKeeper/Artifact.java +++ b/src/sig/plugin/TwosideKeeper/Artifact.java @@ -11,6 +11,8 @@ 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.Common.GenericFunctions; public class Artifact { public static ItemStack createArtifactItem(ArtifactItem type) { @@ -58,6 +60,9 @@ public class Artifact { case MYSTERIOUS_ESSENCE: i=new ItemStack(Material.PUMPKIN_SEEDS); break; + case ARTIFACT_RECIPE: + i=new ItemStack(Material.STAINED_GLASS_PANE); + break; default: i=new ItemStack(Material.AIR); break; @@ -153,10 +158,26 @@ public class Artifact { //Converts an item to an artifact. return convert(item, ArtifactItem.ARTIFACT_ESSENCE, true); } + + public static ItemStack convert_equip(ItemStack item, int tier, ArtifactItemType ait) { + //Converts an item to an artifact. + ItemMeta m = item.getItemMeta(); + List l = new ArrayList(); + if (item.getItemMeta().hasLore()) { + l = item.getItemMeta().getLore(); + } + l.add(ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+ChatColor.RESET+ChatColor.GOLD+" "+GenericFunctions.CapitalizeFirstLetters(ait.getItemName())+" Artifact"); + l.add(ChatColor.GOLD+""+ChatColor.ITALIC+"Artifact Item"); + m.setLore(l); + item.setItemMeta(m); + item.addUnsafeEnchantment(Enchantment.LUCK, tier); + return item; + } public static boolean isArtifact(ItemStack item) { if (item.hasItemMeta() && item.getItemMeta().hasLore() && - item.getItemMeta().getLore().contains(ChatColor.GOLD+""+ChatColor.ITALIC+"Artifact Crafting Item")) { + (item.getItemMeta().getLore().contains(ChatColor.GOLD+""+ChatColor.ITALIC+"Artifact Crafting Item") || + item.getItemMeta().getLore().contains(ChatColor.GOLD+""+ChatColor.ITALIC+"Artifact Item"))) { //This is an artifact. return true; } else { @@ -182,4 +203,68 @@ public class Artifact { return false; } } + /** + * This method adds in related information based on what type of recipe the item is. + * @param tier + * @param item + */ + public static ItemStack createRecipe(int tier, ArtifactItemType item) { + if (tier==0) { + ItemStack newitem = convert(new ItemStack(Material.STAINED_GLASS_PANE,1,(short)item.getDataValue())); + ItemMeta m = newitem.getItemMeta(); + List lore = m.getLore(); + lore.add(0,ChatColor.YELLOW+"Base Crafting Recipe"); + //lore.add(1,ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+ChatColor.RESET+ChatColor.GOLD+" "+GenericFunctions.CapitalizeFirstLetters(item.getItemName())+" Recipe"); + m.setLore(lore); + m.setDisplayName(ChatColor.BOLD+"Base Artifact "+GenericFunctions.CapitalizeFirstLetters(item.getItemName())+" Recipe"); + newitem.setItemMeta(m); + return newitem; + } else + { + ItemStack newitem = convert(new ItemStack(Material.STAINED_GLASS_PANE,1,(short)item.getDataValue())); + ItemMeta m = newitem.getItemMeta(); + List lore = m.getLore(); + lore.add(0,ChatColor.YELLOW+GenericFunctions.CapitalizeFirstLetters(item.getItemName())+" Crafting Recipe"); + lore.add(1,ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+ChatColor.RESET+ChatColor.GOLD+" "+GenericFunctions.CapitalizeFirstLetters(item.getItemName())+" Recipe"); + m.setLore(lore); + m.setDisplayName(ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+ChatColor.RESET+ChatColor.GOLD+" Artifact "+GenericFunctions.CapitalizeFirstLetters(item.getItemName())+" Recipe"); + newitem.setItemMeta(m); + return newitem; + } + } + + public static String returnRawTool(Material type) { + if (type.toString().contains("PICKAXE")) { + return "PICKAXE"; + } else + if (type.toString().contains("AXE")) { + return "AXE"; + } else + if (type.toString().contains("SPADE")) { + return "SHOVEL"; + } else + if (type.toString().contains("SWORD")) { + return "SWORD"; + } else + if (type.toString().contains("BOW")) { + return "BOW"; + } else + if (type.toString().contains("HOE")) { + return "HOE"; + } else + if (type.toString().contains("CHESTPLATE")) { + return "CHESTPLATE"; + } else + if (type.toString().contains("HELMET")) { + return "HELMET"; + } else + if (type.toString().contains("LEGGINGS")) { + return "LEGGINGS"; + } else + if (type.toString().contains("BOOTS")) { + return "BOOTS"; + } else { + return ""; + } + } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactItem.java b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactItem.java index 5a79b7f..3daf339 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactItem.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactItem.java @@ -14,5 +14,6 @@ public enum ArtifactItem { DIVINE_ESSENCE, DIVINE_CORE, DIVINE_BASE, - MALLEABLE_BASE + MALLEABLE_BASE, + ARTIFACT_RECIPE } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactItemType.java b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactItemType.java new file mode 100644 index 0000000..29ab009 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactItemType.java @@ -0,0 +1,618 @@ +package sig.plugin.TwosideKeeper.HelperStructures; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ShapedRecipe; +import org.bukkit.inventory.ShapelessRecipe; + +import sig.plugin.TwosideKeeper.Artifact; +import sig.plugin.TwosideKeeper.TwosideKeeper; + +public enum ArtifactItemType { + AXE(0,"AXE",TierType.ALL,UpgradePath.TOOL,new String[]{"EEx","EEx","xEx"}, + new ItemStack[]{ + new ItemStack(Material.GOLD_AXE), //T1 + new ItemStack(Material.WOOD_AXE), //T2 + new ItemStack(Material.WOOD_AXE), //T3 + new ItemStack(Material.STONE_AXE), //T4 + new ItemStack(Material.STONE_AXE), //T5 + new ItemStack(Material.IRON_AXE), //T6 + new ItemStack(Material.IRON_AXE), //T7 + new ItemStack(Material.IRON_AXE), //T8 + new ItemStack(Material.DIAMOND_AXE), //T9 + new ItemStack(Material.DIAMOND_AXE), //T10 + }, + new double[]{ + 1.0d, //T1 + 1.5d, //T2 + 2.0d, //T3 + 2.5d, //T4 + 3.0d, //T5 + 3.5d, //T6 + 4.0d, //T7 + 4.5d, //T8 + 5.0d, //T9 + 6.0d //T10 + }), + SWORD(1,"SWORD",TierType.ALL,UpgradePath.WEAPON,new String[]{"EEE","EEE","EEE"}, + new ItemStack[]{ + new ItemStack(Material.GOLD_SWORD), //T1 + new ItemStack(Material.WOOD_SWORD), //T2 + new ItemStack(Material.WOOD_SWORD), //T3 + new ItemStack(Material.STONE_SWORD), //T4 + new ItemStack(Material.STONE_SWORD), //T5 + new ItemStack(Material.IRON_SWORD), //T6 + new ItemStack(Material.IRON_SWORD), //T7 + new ItemStack(Material.IRON_SWORD), //T8 + new ItemStack(Material.DIAMOND_SWORD), //T9 + new ItemStack(Material.DIAMOND_SWORD), //T10 + }, + new double[]{ + 2.0d, //T1 + 3.0d, //T2 + 4.0d, //T3 + 5.0d, //T4 + 6.0d, //T5 + 7.0d, //T6 + 8.0d, //T7 + 9.0d, //T8 + 10.0d, //T9 + 12.0d //T10 + }), + PICKAXE(2,"PICKAXE",TierType.ALL,UpgradePath.TOOL,new String[]{"EEE","xEx","xEx"}, + new ItemStack[]{ + new ItemStack(Material.GOLD_PICKAXE), //T1 + new ItemStack(Material.WOOD_PICKAXE), //T2 + new ItemStack(Material.WOOD_PICKAXE), //T3 + new ItemStack(Material.STONE_PICKAXE), //T4 + new ItemStack(Material.STONE_PICKAXE), //T5 + new ItemStack(Material.IRON_PICKAXE), //T6 + new ItemStack(Material.IRON_PICKAXE), //T7 + new ItemStack(Material.IRON_PICKAXE), //T8 + new ItemStack(Material.DIAMOND_PICKAXE), //T9 + new ItemStack(Material.DIAMOND_PICKAXE), //T10 + }), + HOE(3,"HOE",TierType.ALL,UpgradePath.TOOL,new String[]{"EEx","xEx","xEx"}, + new ItemStack[]{ + new ItemStack(Material.GOLD_HOE), //T1 + new ItemStack(Material.WOOD_HOE), //T2 + new ItemStack(Material.WOOD_HOE), //T3 + new ItemStack(Material.STONE_HOE), //T4 + new ItemStack(Material.STONE_HOE), //T5 + new ItemStack(Material.IRON_HOE), //T6 + new ItemStack(Material.IRON_HOE), //T7 + new ItemStack(Material.IRON_HOE), //T8 + new ItemStack(Material.DIAMOND_HOE), //T9 + new ItemStack(Material.DIAMOND_HOE), //T10 + }), + BOW(4,"BOW",TierType.ONE,UpgradePath.BOW,new String[]{"EEx","ExE","EEx"}, + new ItemStack[]{ + new ItemStack(Material.BOW), //T1 + new ItemStack(Material.BOW), //T2 + new ItemStack(Material.BOW), //T3 + new ItemStack(Material.BOW), //T4 + new ItemStack(Material.BOW), //T5 + new ItemStack(Material.BOW), //T6 + new ItemStack(Material.BOW), //T7 + new ItemStack(Material.BOW), //T8 + new ItemStack(Material.BOW), //T9 + new ItemStack(Material.BOW), //T10 + }), + SHOVEL(5,"SPADE",TierType.ALL,UpgradePath.TOOL,new String[]{"E","E","E"}, + new ItemStack[]{ + new ItemStack(Material.GOLD_SPADE), //T1 + new ItemStack(Material.WOOD_SPADE), //T2 + new ItemStack(Material.WOOD_SPADE), //T3 + new ItemStack(Material.STONE_SPADE), //T4 + new ItemStack(Material.STONE_SPADE), //T5 + new ItemStack(Material.IRON_SPADE), //T6 + new ItemStack(Material.IRON_SPADE), //T7 + new ItemStack(Material.IRON_SPADE), //T8 + new ItemStack(Material.DIAMOND_SPADE), //T9 + new ItemStack(Material.DIAMOND_SPADE), //T10 + }), + HELMET(6,"HELMET",TierType.ARMOR,UpgradePath.ARMOR,new String[]{"EEE","ExE"}, + new ItemStack[]{ + new ItemStack(Material.LEATHER_HELMET), //T1 + new ItemStack(Material.LEATHER_HELMET), //T2 + new ItemStack(Material.GOLD_HELMET), //T3 + new ItemStack(Material.IRON_HELMET), //T4 + new ItemStack(Material.IRON_HELMET), //T5 + new ItemStack(Material.IRON_HELMET), //T6 + new ItemStack(Material.DIAMOND_HELMET), //T7 + new ItemStack(Material.DIAMOND_HELMET), //T8 + new ItemStack(Material.DIAMOND_HELMET), //T9 + new ItemStack(Material.LEATHER_HELMET), //T10 + }, + new double[]{ + 3.75d, //T1 + 5.0d, //T2 + 6.25d, //T3 + 7.50d, //T4 + 8.75d, //T5 + 11.25d, //T6 + 13.75d, //T7 + 16.25d, //T8 + 18.75d, //T9 + 22.50d //T10 + }, + new int[]{ + 2, //T1 + 3, //T2 + 4, //T3 + 5, //T4 + 6, //T5 + 7, //T6 + 9, //T7 + 10, //T8 + 12, //T9 + 14 //T10 + }), + CHESTPLATE(7,"CHESTPLATE",TierType.ARMOR,UpgradePath.ARMOR,new String[]{"ExE","EEE","EEE"}, + new ItemStack[]{ + new ItemStack(Material.LEATHER_CHESTPLATE), //T1 + new ItemStack(Material.LEATHER_CHESTPLATE), //T2 + new ItemStack(Material.GOLD_CHESTPLATE), //T3 + new ItemStack(Material.IRON_CHESTPLATE), //T4 + new ItemStack(Material.IRON_CHESTPLATE), //T5 + new ItemStack(Material.IRON_CHESTPLATE), //T6 + new ItemStack(Material.DIAMOND_CHESTPLATE), //T7 + new ItemStack(Material.DIAMOND_CHESTPLATE), //T8 + new ItemStack(Material.DIAMOND_CHESTPLATE), //T9 + new ItemStack(Material.LEATHER_CHESTPLATE), //T10 + }, + new double[]{ + 3.75d, //T1 + 5.0d, //T2 + 6.25d, //T3 + 7.50d, //T4 + 8.75d, //T5 + 11.25d, //T6 + 13.75d, //T7 + 16.25d, //T8 + 18.75d, //T9 + 22.50d //T10 + }, + new int[]{ + 2, //T1 + 3, //T2 + 4, //T3 + 5, //T4 + 6, //T5 + 7, //T6 + 9, //T7 + 10, //T8 + 12, //T9 + 14 //T10 + }), + LEGGINGS(8,"LEGGINGS",TierType.ARMOR,UpgradePath.ARMOR,new String[]{"EEE","ExE","ExE"}, + new ItemStack[]{ + new ItemStack(Material.LEATHER_LEGGINGS), //T1 + new ItemStack(Material.LEATHER_LEGGINGS), //T2 + new ItemStack(Material.GOLD_LEGGINGS), //T3 + new ItemStack(Material.IRON_LEGGINGS), //T4 + new ItemStack(Material.IRON_LEGGINGS), //T5 + new ItemStack(Material.IRON_LEGGINGS), //T6 + new ItemStack(Material.DIAMOND_LEGGINGS), //T7 + new ItemStack(Material.DIAMOND_LEGGINGS), //T8 + new ItemStack(Material.DIAMOND_LEGGINGS), //T9 + new ItemStack(Material.LEATHER_LEGGINGS), //T10 + }, + new double[]{ + 3.75d, //T1 + 5.0d, //T2 + 6.25d, //T3 + 7.50d, //T4 + 8.75d, //T5 + 11.25d, //T6 + 13.75d, //T7 + 16.25d, //T8 + 18.75d, //T9 + 22.50d //T10 + }, + new int[]{ + 2, //T1 + 3, //T2 + 4, //T3 + 5, //T4 + 6, //T5 + 7, //T6 + 9, //T7 + 10, //T8 + 12, //T9 + 14 //T10 + }), + BOOTS(9,"BOOTS",TierType.ARMOR,UpgradePath.ARMOR,new String[]{"ExE","ExE"}, + new ItemStack[]{ + new ItemStack(Material.LEATHER_BOOTS), //T1 + new ItemStack(Material.LEATHER_BOOTS), //T2 + new ItemStack(Material.GOLD_BOOTS), //T3 + new ItemStack(Material.IRON_BOOTS), //T4 + new ItemStack(Material.IRON_BOOTS), //T5 + new ItemStack(Material.IRON_BOOTS), //T6 + new ItemStack(Material.DIAMOND_BOOTS), //T7 + new ItemStack(Material.DIAMOND_BOOTS), //T8 + new ItemStack(Material.DIAMOND_BOOTS), //T9 + new ItemStack(Material.LEATHER_BOOTS), //T10 + }, + new double[]{ + 3.75d, //T1 + 5.0d, //T2 + 6.25d, //T3 + 7.50d, //T4 + 8.75d, //T5 + 11.25d, //T6 + 13.75d, //T7 + 16.25d, //T8 + 18.75d, //T9 + 22.50d //T10 + }, + new int[]{ + 2, //T1 + 3, //T2 + 4, //T3 + 5, //T4 + 6, //T5 + 7, //T6 + 9, //T7 + 10, //T8 + 12, //T9 + 14 //T10 + }); + + int data; + String itemname; + TierType tier; + UpgradePath upgrade; + String[] recipe; + ItemStack[] itemtiers; + double[] damageamt; + int[] healthamt; + + ArtifactItemType(int dataval, String itemname, TierType tier, UpgradePath upgrade, String[] recipe, ItemStack[] itemtiers, double[] damageamt, int[] healthamt) { + ArtifactItemType(dataval,itemname,tier,upgrade,recipe,itemtiers,damageamt,healthamt); + } + + ArtifactItemType(int dataval, String itemname, TierType tier, UpgradePath upgrade, String[] recipe, ItemStack[] itemtiers, double[] damageamt) { + ArtifactItemType(dataval,itemname,tier,upgrade,recipe,itemtiers,damageamt,new int[]{}); + } + + ArtifactItemType(int dataval, String itemname, TierType tier, UpgradePath upgrade, String[] recipe, ItemStack[] itemtiers) { + ArtifactItemType(dataval,itemname,tier,upgrade,recipe,itemtiers,new double[]{},new int[]{}); + } + + private void ArtifactItemType(int dataval, String itemname, TierType tier, UpgradePath upgrade, String[] recipe, ItemStack[] itemtiers, double[] damageamt, int[] healthamt) { + this.data=dataval; + this.itemname=itemname; + this.tier=tier; + this.upgrade=upgrade; + this.recipe=recipe; + this.itemtiers=itemtiers; + this.damageamt = damageamt; + this.healthamt = healthamt; + }; + + public int getDataValue() { + return this.data; + } + public String getItemName() { + return this.itemname; + } + public TierType getTier() { + return this.tier; + } + public UpgradePath getUpgradePath() { + return this.upgrade; + } + public double getDamageAmt(int tier) { + if (this.damageamt.length>=tier) { + TwosideKeeper.log("Returning value "+this.damageamt[tier-1], 5); + return this.damageamt[tier-1]; + } else { + return -1; + } + } + public int getHealthAmt(int tier) { + if (this.healthamt.length>=tier) { + return this.healthamt[tier-1]; + } else { + return -1; + } + } + + public ShapedRecipe defineBaseRecipe() { + ShapedRecipe axe_layout_recipe = new ShapedRecipe(Artifact.createRecipe(0, this)); + axe_layout_recipe.shape(recipe); + axe_layout_recipe.setIngredient('E', Material.PUMPKIN_SEEDS); + return axe_layout_recipe; + } + public void defineAllDecompRecipes() { + for (int i=0;i<10;i++) { + ShapelessRecipe decomp_recipe = new ShapelessRecipe(Artifact.createRecipe(i+1, this)); + decomp_recipe.addIngredient(itemtiers[i].getType()); + Bukkit.addRecipe(decomp_recipe); + } + } + + public ItemStack getTieredItem(int tier) { + ItemStack ouritem = itemtiers[tier-1]; + switch (tier) { + case 1:{ + switch (upgrade) { + case WEAPON:{ + ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 1); + }break; + case BOW:{ + ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 1); + }break; + case ARMOR:{ + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 1); + }break; + case TOOL:{ + ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 1); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 1); + }break; + } + }break; + case 2:{ + switch (upgrade) { + case WEAPON:{ + ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 2); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 2); + }break; + case BOW:{ + ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 2); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 2); + }break; + case ARMOR:{ + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 2); + }break; + case TOOL:{ + ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 2); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 2); + }break; + } + }break; + case 3:{ + switch (upgrade) { + case WEAPON:{ + ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 3); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 3); + ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 1); + }break; + case BOW:{ + ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 4); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 3); + }break; + case ARMOR:{ + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 1); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 1); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 1); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 1); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 3); + }break; + case TOOL:{ + ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 3); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 3); + }break; + } + }break; + case 4:{ + switch (upgrade) { + case WEAPON:{ + ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 4); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 4); + ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 1); + }break; + case BOW:{ + ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 5); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 4); + }break; + case ARMOR:{ + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 2); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 1); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 1); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 2); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 5); + }break; + case TOOL:{ + ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 4); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 4); + }break; + } + }break; + case 5:{ + switch (upgrade) { + case WEAPON:{ + ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 6); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 6); + ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 2); + }break; + case BOW:{ + ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 7); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 6); + }break; + case ARMOR:{ + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 6); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 2); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 2); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 4); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 7); + }break; + case TOOL:{ + ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 6); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 6); + }break; + } + }break; + case 6:{ + switch (upgrade) { + case WEAPON:{ + ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 8); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 8); + ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 3); + }break; + case BOW:{ + ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 10); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 8); + }break; + case ARMOR:{ + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 8); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 6); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 4); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 4); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 6); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + }break; + case TOOL:{ + ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 8); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 8); + ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 1); + }break; + } + }break; + case 7:{ + switch (upgrade) { + case WEAPON:{ + ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 5); + ouritem.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); + }break; + case BOW:{ + ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 12); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ouritem.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); + }break; + case ARMOR:{ + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 14); + }break; + case TOOL:{ + ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 2); + ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 2); + }break; + } + }break; + case 8:{ + switch (upgrade) { + case WEAPON:{ + ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 14); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 7); + ouritem.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); + }break; + case BOW:{ + ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 14); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ouritem.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); + }break; + case ARMOR:{ + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 12); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 12); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 12); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 12); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 12); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 14); + }break; + case TOOL:{ + ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 14); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 4); + ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 6); + }break; + } + }break; + case 9:{ + switch (upgrade) { + case WEAPON:{ + ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 18); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 9); + ouritem.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); + }break; + case BOW:{ + ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 18); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ouritem.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1); + ouritem.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1); + }break; + case ARMOR:{ + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 16); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 16); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 16); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 16); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 16); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 18); + }break; + case TOOL:{ + ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 18); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 7); + ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 12); + }break; + } + }break; + case 10:{ + switch (upgrade) { + case WEAPON:{ + ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 40); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 20); + ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10); + ouritem.addUnsafeEnchantment(Enchantment.KNOCKBACK, 2); + }break; + case BOW:{ + ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 40); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 20); + ouritem.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 2); + ouritem.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1); + }break; + case ARMOR:{ + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 20); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 20); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 20); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 20); + ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 20); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 75); + }break; + case TOOL:{ + ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 40); + ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 20); + ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 10); + ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 20); + }break; + }break; + } + } + return ouritem; + } + +} + +enum TierType { + ALL, //Contains Wooden, Stone, Iron, Gold, Diamond Variants of this item. + ONE, //Only the specified item exists for this type of Artifact. + ARMOR //The armor type contains Leather, Iron, Gold, and Diamond Variants. +} + +enum UpgradePath { + WEAPON, //Weapon Upgrade Path - Boosts mostly offensive based statistics. + BOW, //Bow Upgrade Path - Boosts mostly offensive based statistics, but for a bow. + ARMOR, //Armor Upgrade Path - Boosts mostly defensive based statistics. + TOOL //Tool Upgrade Path - Boosts mostly utility based statistics. +} \ No newline at end of file diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index e05f088..e43fef5 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -14,6 +14,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.PotionMeta; +import sig.plugin.TwosideKeeper.Artifact; import sig.plugin.TwosideKeeper.TwosideKeeper; import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; @@ -27,7 +28,12 @@ public class GenericFunctions { int loreline=-1; for (int i=0;i0) { ItemMeta m = item.getItemMeta(); List lore = item.getItemMeta().getLore(); for (int i=0;i-1) { + ItemMeta m = item.getItemMeta(); + List lore = item.getItemMeta().getLore(); + for (int i=0;i=1728000) //1.7M ticks per day. + { + int charges_stored = (int)((TwosideKeeper.getServerTickTime()-time)/1728000); + TwosideKeeper.log(charges_stored+" charges stored. Adding them.", 2); + break_count+=charges_stored; + lore.set(i, ChatColor.BLUE+""+ChatColor.MAGIC+TwosideKeeper.getServerTickTime()); + TwosideKeeper.log("Setting time to "+TwosideKeeper.getServerTickTime(),3); + } + } + } + if (break_count>5) {break_count=5;} + lore.set(break_line, ChatColor.GRAY+"Breaks Remaining: "+ChatColor.MAGIC+(break_count)); + TwosideKeeper.log("Setting breaks remaining to "+(break_count),3); + m.setLore(lore); + item.setItemMeta(m); + item.setAmount(1); + item.setDurability((short)0); + TwosideKeeper.log("New item is "+item.toString(),2); return item; //By setting the amount to 1, you refresh the item in the player's inventory. } else { @@ -1054,6 +1138,21 @@ public class GenericFunctions { } } + public static boolean isEquip(ItemStack item) { + if (item.getType().toString().contains("SPADE") || + item.getType().toString().contains("AXE") || + item.getType().toString().contains("SWORD") || + item.getType().toString().contains("HOE") || + item.getType().toString().contains("BOOTS") || + item.getType().toString().contains("CHESTPLATE") || + item.getType().toString().contains("LEGGINGS") || + item.getType().toString().contains("HELMET")) { + return true; + } else { + return false; + } + } + public static boolean isTool(ItemStack item) { if (item.getType().toString().contains("SPADE") || item.getType().toString().contains("AXE") || @@ -1065,6 +1164,16 @@ public class GenericFunctions { } } + public static boolean isWeapon(ItemStack item) { + if (item.getType().toString().contains("BOW") || + item.getType().toString().contains("AXE") || + item.getType().toString().contains("SWORD")) { + return true; + } else { + return false; + } + } + public static boolean isArmor(ItemStack item) { if (item.getType().toString().contains("BOOTS") || item.getType().toString().contains("CHESTPLATE") || @@ -1086,8 +1195,7 @@ public class GenericFunctions { public static boolean isRareItem(ItemStack it) { if (((it.getItemMeta().hasDisplayName() && (it.getItemMeta().getDisplayName().contains("Mega") || - it.getItemMeta().getDisplayName().contains("Hardened") || - ChatColor.getByChar(it.getItemMeta().getDisplayName().charAt(0))!=null)) || + it.getItemMeta().getDisplayName().contains("Hardened"))) || isHardenedItem(it) )) { TwosideKeeper.log("Returning it!", 5); diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/MalleableBaseQuest.java b/src/sig/plugin/TwosideKeeper/HelperStructures/MalleableBaseQuest.java index 94805d2..2017543 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/MalleableBaseQuest.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/MalleableBaseQuest.java @@ -82,17 +82,27 @@ public class MalleableBaseQuest { long starttime = getTimeStarted(base); long currenttime = TwosideKeeper.getServerTickTime(); - if (currenttime-starttime<=36000) { //30 min passed. Divine tier. - return Artifact.createArtifactItem(ArtifactItem.DIVINE_BASE); + int amt = base.getAmount(); + + if (currenttime-starttime<=54000) { //45 min passed. Divine tier. + ItemStack newbase = Artifact.createArtifactItem(ArtifactItem.DIVINE_BASE); + newbase.setAmount(amt); + return newbase; } else - if (currenttime-starttime<=72000) { //1 hour passed. Lost tier. - return Artifact.createArtifactItem(ArtifactItem.LOST_BASE); + if (currenttime-starttime<=144000) { //2 hours passed. Lost tier. + ItemStack newbase = Artifact.createArtifactItem(ArtifactItem.LOST_BASE); + newbase.setAmount(amt); + return newbase; } else - if (currenttime-starttime<=144000) { //2 hours passed. Ancient tier. - return Artifact.createArtifactItem(ArtifactItem.ANCIENT_BASE); + if (currenttime-starttime<=288000) { //4 hours passed. Ancient tier. + ItemStack newbase = Artifact.createArtifactItem(ArtifactItem.ANCIENT_BASE); + newbase.setAmount(amt); + return newbase; } else { //>2 hours passed. Artifact tier. - return Artifact.createArtifactItem(ArtifactItem.ARTIFACT_BASE); + ItemStack newbase = Artifact.createArtifactItem(ArtifactItem.ARTIFACT_BASE); + newbase.setAmount(amt); + return newbase; }/* else //Too harsh. We are not going to make the player start all over. { //This failed. Turn it back into a Malleable base. diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterType.java b/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterType.java index ad74e9c..ba0b7bc 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterType.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterType.java @@ -1,5 +1,7 @@ package sig.plugin.TwosideKeeper.HelperStructures; +import org.bukkit.entity.EntityType; + public enum MonsterType { BLAZE, CAVESPIDER, diff --git a/src/sig/plugin/TwosideKeeper/MonsterController.java b/src/sig/plugin/TwosideKeeper/MonsterController.java index c99e1de..9d2a0eb 100644 --- a/src/sig/plugin/TwosideKeeper/MonsterController.java +++ b/src/sig/plugin/TwosideKeeper/MonsterController.java @@ -534,8 +534,8 @@ public class MonsterController { ( (md==MonsterDifficulty.NORMAL && ent.getMaxHealth()>20) || (md==MonsterDifficulty.DANGEROUS && ent.getMaxHealth()>20*2) || - (md==MonsterDifficulty.NORMAL && ent.getMaxHealth()>20*2) || - (md==MonsterDifficulty.NORMAL && ent.getMaxHealth()>20*4) + (md==MonsterDifficulty.DEADLY && ent.getMaxHealth()>20*2) || + (md==MonsterDifficulty.HELLFIRE && ent.getMaxHealth()>20*4) ) { return true; diff --git a/src/sig/plugin/TwosideKeeper/Party.java b/src/sig/plugin/TwosideKeeper/Party.java index 9926e24..84ddbd6 100644 --- a/src/sig/plugin/TwosideKeeper/Party.java +++ b/src/sig/plugin/TwosideKeeper/Party.java @@ -25,7 +25,7 @@ public class Party { TwosideKeeper.log("Party Region Position: "+region.toString(),5); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives remove Party"+color); //Make sure the party is cleared out if it was used for something before... //Bukkit.getScoreboardManager().getMainScoreboard().registerNewObjective("Party"+color, "dummy"); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives add Party"+color+" dummy Your Party"); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives add Party"+color+" dummy Party"); //Bukkit.getScoreboardManager().getMainScoreboard().getObjective("Party"+color).setDisplaySlot(DisplaySlot.SIDEBAR); String color_txt = ""; Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives setdisplay sidebar.team."+ConvertColor(color)+" Party"+color); diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index a5c546b..b536fe3 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -51,6 +51,11 @@ public class PlayerStructure { public int pickeditems=-1; public boolean sounds_enabled=true; + public double prev_weapondmg=0.0; + public double prev_buffdmg=0.0; + public double prev_partydmg=0.0; + public double prev_armordef=0.0; + //Needs the instance of the player object to get all other info. Only to be called at the beginning. public PlayerStructure(Player p, long serverTickTime) { if (p!=null) { diff --git a/src/sig/plugin/TwosideKeeper/Recipes.java b/src/sig/plugin/TwosideKeeper/Recipes.java index 3718763..5262a9d 100644 --- a/src/sig/plugin/TwosideKeeper/Recipes.java +++ b/src/sig/plugin/TwosideKeeper/Recipes.java @@ -14,6 +14,9 @@ import org.bukkit.inventory.ShapelessRecipe; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.material.Dye; +import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem; +import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItemType; + public class Recipes { public static void Initialize_ItemCube_Recipes() { ItemStack item_ItemCube = new ItemStack(Material.CHEST); @@ -99,7 +102,7 @@ public class Recipes { blockarmorpc.setItemMeta(blockarmorpc_meta); ShapedRecipe BlockArmor = new ShapedRecipe(blockarmorpc); - BlockArmor.shape("aaa","axa","xxx"); + BlockArmor.shape("aaa","axa"); BlockArmor.setIngredient('a', Material.IRON_BLOCK); Bukkit.addRecipe(BlockArmor); @@ -167,7 +170,7 @@ public class Recipes { blockarmorpc.setItemMeta(blockarmorpc_meta); BlockArmor = new ShapedRecipe(blockarmorpc); - BlockArmor.shape("aaa","axa","xxx"); + BlockArmor.shape("aaa","axa"); BlockArmor.setIngredient('a', Material.GOLD_BLOCK); Bukkit.addRecipe(BlockArmor); @@ -235,7 +238,7 @@ public class Recipes { blockarmorpc.setItemMeta(blockarmorpc_meta); BlockArmor = new ShapedRecipe(blockarmorpc); - BlockArmor.shape("aaa","axa","xxx"); + BlockArmor.shape("aaa","axa"); BlockArmor.setIngredient('a', Material.DIAMOND_BLOCK); Bukkit.addRecipe(BlockArmor); @@ -462,6 +465,9 @@ public class Recipes { stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.PURPUR_BLOCK,1)); stone_construction_recipe.addIngredient(2, Material.PURPUR_SLAB); Bukkit.addRecipe(stone_construction_recipe); + stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.QUARTZ,4)); + stone_construction_recipe.addIngredient(1, Material.QUARTZ_BLOCK); + Bukkit.addRecipe(stone_construction_recipe); ItemStack modded_plank = new ItemStack(Material.STEP,1); modded_plank.setDurability((short)2); ItemMeta m = modded_plank.getItemMeta(); @@ -472,4 +478,70 @@ public class Recipes { stone_construction_recipe.addIngredient(1, Material.SLIME_BALL); Bukkit.addRecipe(stone_construction_recipe); } + public static void Initialize_Artifact_Recipes() { + //Essence Recipes. + //T0 + for (int i=0;i playerdata; public static SpleefManager TwosideSpleefGames; @@ -215,6 +217,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { sig.plugin.TwosideKeeper.Recipes.Initialize_ItemDeconstruction_Recipes(); sig.plugin.TwosideKeeper.Recipes.Initialize_WoolRecolor_Recipes(); sig.plugin.TwosideKeeper.Recipes.Initialize_SlabReconstruction_Recipes(); + sig.plugin.TwosideKeeper.Recipes.Initialize_Artifact_Recipes(); filesave=getDataFolder(); //Store the location of where our data folder is. log("Data folder at "+filesave+".",3); @@ -261,6 +264,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener { for (int i=0;i. Length is "+colorcodes.length(),4); + //ev.getWhoClicked().sendMessage(ChatColor.getByChar(colorcodes)+"This is the color."); + ItemMeta m = ev.getCurrentItem().getItemMeta(); + m.setDisplayName(ChatColor.getByChar(colorcodes)+m.getDisplayName().replaceFirst(colorcodes, "")); + ev.getCurrentItem().setItemMeta(m); } } @@ -2400,7 +2428,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //Recycle allowed. Now figure out which node to go to. if (TwosideRecyclingCenter.getNumberOfNodes()>0) { Location rand_node=TwosideRecyclingCenter.getRandomNode(); - Block b = Bukkit.getWorld("world").getBlockAt(rand_node); + rand_node.getWorld().loadChunk(rand_node.getChunk()); //Load that chunk to make sure we can throw items into it. + Block b = rand_node.getWorld().getBlockAt(rand_node); if (b!=null && b.getType()==Material.CHEST || b.getType()==Material.TRAPPED_CHEST) { if (b.getState()!=null) { @@ -2567,7 +2596,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public void expEvent(PlayerExpChangeEvent ev) { double val = Math.random(); log("ExpChange event: "+val,5); - if (val<=0.00125) { + int amt = ev.getAmount(); + if (val<=((double)amt/(double)50)*(0.00125)*ARTIFACT_RARITY) { ev.getPlayer().getWorld().dropItemNaturally(ev.getPlayer().getLocation(), Artifact.createArtifactItem(ArtifactItem.MALLEABLE_BASE)); ev.getPlayer().sendMessage(ChatColor.LIGHT_PURPLE+"A strange item has appeared nearby."); } @@ -2733,7 +2763,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { */ Location arrowLoc = ((Arrow)(ev.getDamager())).getLocation(); - Location monsterHead = m.getEyeLocation().add(0,0.075,0); + Location monsterHead = m.getEyeLocation().add(0,0.105,0); boolean headshot=false; if (ev.getDamager().getTicksLived()>=4) { @@ -2777,7 +2807,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } } - if (Math.random()<0.00390625*dropmult) { + if (Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) { ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ARTIFACT_ESSENCE)); } if (m.getType()==EntityType.ZOMBIE && @@ -2795,27 +2825,27 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } else { allowed=true; - if (allowed && Math.random()<0.00390625*dropmult) { - switch ((int)(Math.random()*4)) { - case 0:{ - ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.LOST_CORE)); - }break; - case 1:{ - ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ANCIENT_CORE)); - }break; - case 2:{ - ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ARTIFACT_CORE)); - }break; - case 3:{ - ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.DIVINE_CORE)); - }break; - } + } + if (allowed && Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) { + switch ((int)(Math.random()*4)) { + case 0:{ + ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.LOST_CORE)); + }break; + case 1:{ + ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ANCIENT_CORE)); + }break; + case 2:{ + ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ARTIFACT_CORE)); + }break; + case 3:{ + ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.DIVINE_CORE)); + }break; } } } if (m.getType()==EntityType.ENDER_DRAGON || m.getType()==EntityType.WITHER) { - if (Math.random()<0.125*dropmult) { + if (Math.random()<0.125*dropmult*ARTIFACT_RARITY) { switch ((int)(Math.random()*4)) { case 0:{ ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.LOST_CORE)); @@ -2833,7 +2863,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } if (m.getType()==EntityType.ENDERMAN) { - if (Math.random()<0.00390625*dropmult) { + if (Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) { switch ((int)(Math.random()*12)) { case 0:{ ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ARTIFACT_ESSENCE)); @@ -2904,7 +2934,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } ev.getDrops().add(raresword); } - if (Math.random()<0.00390625*dropmult) { + if (Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) { ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ANCIENT_ESSENCE)); } } @@ -3172,7 +3202,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.getDrops().add(raresword); } - if (Math.random()<0.00390625*dropmult) { + if (Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) { ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.LOST_ESSENCE)); } final List drops = new ArrayList(); @@ -3525,7 +3555,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); ev.getDrops().add(raresword); } - if (Math.random()<0.00390625*dropmult) { + if (Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) { ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.DIVINE_ESSENCE)); } } @@ -3593,7 +3623,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //See if this item has lore. if (GenericFunctions.getHardenedItemBreaks(item)>0) { //item.setAmount(1); - GenericFunctions.breakHardenedItem(item); + GenericFunctions.breakHardenedItem(item,p); } else { p.sendMessage(ChatColor.DARK_RED+"Your "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(item)+ChatColor.DARK_RED+" has broken!"); @@ -3834,13 +3864,280 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } - @EventHandler(priority=EventPriority.LOW) public void onItemCraftEvent(PrepareItemCraftEvent ev) { ItemStack result = ev.getInventory().getResult(); if (result.getType()==Material.TNT) { result.setAmount(result.getAmount()*5); //TNT recipes are 5 times as effective. } + + + //Look for the base material. + if (Artifact.isArtifact(ev.getInventory().getResult()) && result.getType()!=Material.STAINED_GLASS_PANE && GenericFunctions.isEquip(result)) { + log("This is an artifact we are crafting...Begin search",4); + boolean good = false; + ItemStack stainedglass1 = null; //Gets set if stained glass is an artifact. + ItemStack stainedglass2 = null; //Gets set if stained glass is an artifact. + ItemStack baseitem = null; //Gets set if a base item is an artifact. + ItemStack baseitem2 = null; //Gets set if a base item is an artifact. + ItemStack baseitem3 = null; //Gets set if a base item is an artifact. + int baseitemcount=0; + int totaltierval=0; + for (int i=0;i=10 && baseitemcount!=3) || + (totaltierval!=33 && baseitemcount==3)/*This tier is not allowed through this recipe.*/) { + //Not allowed, sorry. + ev.getInventory().setResult(new ItemStack(Material.AIR)); + } else { + //This is allowed. Modify the name of the item. + List oldlore = result.getItemMeta().getLore(); + ItemStack artifactitem = ArtifactItemType.valueOf(Artifact.returnRawTool(ev.getInventory().getResult().getType())).getTieredItem(recipe_tier); + ItemMeta m = artifactitem.getItemMeta(); + m.setDisplayName(ChatColor.GOLD+""+ChatColor.BOLD+""+"T"+tierval+ChatColor.RESET+ChatColor.GOLD+" Artifact "+GenericFunctions.CapitalizeFirstLetters(Artifact.returnRawTool(artifactitem.getType()))); + oldlore.set(0, ChatColor.GOLD+""+ChatColor.BOLD+"T"+tierval+ChatColor.RESET+ChatColor.GOLD+" "+GenericFunctions.CapitalizeFirstLetters(Artifact.returnRawTool(artifactitem.getType()))+" Recipe"); + oldlore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.MAGIC+5); + oldlore.add(ChatColor.BLUE+""+ChatColor.MAGIC+getServerTickTime());double dmgval = ArtifactItemType.valueOf(Artifact.returnRawTool(artifactitem.getType())).getDamageAmt(tierval); + int healthval = ArtifactItemType.valueOf(Artifact.returnRawTool(artifactitem.getType())).getHealthAmt(tierval); + if (dmgval!=-1) { + if (GenericFunctions.isArmor(artifactitem)) { + oldlore.add(ChatColor.YELLOW+"+"+dmgval+"%"+ChatColor.BLUE+" Damage Reduction"); + } else { + oldlore.add(ChatColor.YELLOW+"+"+dmgval+ChatColor.BLUE+" Damage"); + } + } + if (healthval!=-1) { + oldlore.add(ChatColor.YELLOW+"+"+healthval+ChatColor.BLUE+" Health"); + } + m.setLore(oldlore); + artifactitem.setItemMeta(m); + artifactitem.addUnsafeEnchantment(Enchantment.LUCK, tierval); + ev.getInventory().setResult(artifactitem); + } + } + } + else + //We are looking for an artifact recipe. + if (result.getType()==Material.STAINED_GLASS_PANE && Artifact.isArtifact(result)) { + for (int i=0;i items_found = new ArrayList(); + for (int i=1;i lore = m.getLore(); + lore.add(0,ChatColor.GOLD+""+ChatColor.BOLD+"T"+(tier+1)+" Crafting Recipe"); + //lore.add(1,ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+ChatColor.RESET+ChatColor.GOLD+" "+GenericFunctions.CapitalizeFirstLetters(item.getItemName())+" Recipe"); + + m.setLore(lore); + m.setDisplayName(ChatColor.GOLD+""+ChatColor.BOLD+"T"+(tier+1)+" Artifact "+GenericFunctions.CapitalizeFirstLetters(Artifact.returnRawTool(ev.getInventory().getItem(slot_found).getType()))+" Recipe"); + newitem.setItemMeta(m); + newitem.addUnsafeEnchantment(Enchantment.LUCK, tier+1); + ev.getInventory().setResult(newitem); + } + } + } + } @EventHandler(priority=EventPriority.LOW) @@ -3927,6 +4224,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { getConfig().set("XP_CONVERSION_RATE", XP_CONVERSION_RATE); getConfig().set("WORLD_SHOP_ID", WORLD_SHOP_ID); getConfig().set("LOGGING_LEVEL", LOGGING_LEVEL); + getConfig().set("ARTIFACT_RARITY", ARTIFACT_RARITY); //getConfig().set("MOTD", MOTD); //It makes no sense to save the MOTD as it will never be modified in-game. saveConfig(); @@ -3973,6 +4271,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { getConfig().addDefault("XP_CONVERSION_RATE", XP_CONVERSION_RATE); getConfig().addDefault("WORLD_SHOP_ID", WORLD_SHOP_ID); getConfig().addDefault("LOGGING_LEVEL", LOGGING_LEVEL); + getConfig().addDefault("ARTIFACT_RARITY", ARTIFACT_RARITY); getConfig().options().copyDefaults(true); saveConfig(); SERVERTICK = getConfig().getLong("SERVERTICK"); @@ -4000,6 +4299,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { XP_CONVERSION_RATE = getConfig().getDouble("XP_CONVERSION_RATE"); WORLD_SHOP_ID = getConfig().getInt("WORLD_SHOP_ID"); LOGGING_LEVEL = getConfig().getInt("LOGGING_LEVEL"); + ARTIFACT_RARITY = getConfig().getDouble("ARTIFACT_RARITY"); getMOTD(); //Informational reports to the console. @@ -4014,7 +4314,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { getLogger().info("[CONFIG] Food healing amount is "+FOOD_HEAL_AMT+" health per food item."); getLogger().info("[CONFIG] Enemy Damage Multiplier x"+ENEMY_DMG_MULT+". Explosion Damage Multiplier x"+EXPLOSION_DMG_MULT); getLogger().info("[CONFIG] Headshots have to be "+(HEADSHOT_ACC*100)+"% accurate."); - getLogger().info("[CONFIG] Rare Drop Rate is currently "+(RARE_DROP_RATE*100)+"%"); + getLogger().info("[CONFIG] Rare Drop Rate is currently "+(RARE_DROP_RATE*100)+"%. Artifact Drop Rarity is x"+ARTIFACT_RARITY); getLogger().info("[CONFIG] Party Chunk Size Detection is set to "+(PARTY_CHUNK_SIZE)+" chunks."); getLogger().info("[CONFIG] XP Conversion rate is $"+XP_CONVERSION_RATE+" per XP Point."); getLogger().info("[CONFIG] Console Logging Level set to "+LOGGING_LEVEL+"."); @@ -4440,28 +4740,38 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (equipment[i]!=null) { boolean is_block_form=false; //Determine if the piece is block form. - if (equipment[i].hasItemMeta() && - equipment[i].getItemMeta().hasLore()) { - for (int j=0;j0) { + partylevel = playerdata.get(j).partybonus; + log("Party level is "+partylevel,5); + if (partylevel>9) {partylevel=9;} + pd.prev_partydmg = partylevel; + } + } + } + + int sharpnesslevel=0; + //Apply player enchantments next. + //Each sharpness level increases damage by 0.5. + //Both Smite and Bane of Arthropods increases damage by 1.0 per level. + if (p.getEquipment().getItemInMainHand()!=null) { + if (weapon.getType()==Material.BOW) { + if (p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.ARROW_DAMAGE)>0) { + sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.ARROW_DAMAGE); + log("Player "+p.getName()+" has Power "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.ARROW_DAMAGE)+".",5); + } + } + else { + if (p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL)>0) { + sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL); + log("Player "+p.getName()+" has Sharpness "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL)+".",5); + } else + if (target!=null) { + if ((target.getType()==EntityType.ZOMBIE || target.getType()==EntityType.PIG_ZOMBIE || + target.getType()==EntityType.WITHER || target.getType()==EntityType.SKELETON) && + p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)>0) { + sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)*2; + log("Player "+p.getName()+" has Smite "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)+".",5); + } else + if ((target.getType()==EntityType.SPIDER || target.getType()==EntityType.CAVE_SPIDER || + target.getType()==EntityType.SILVERFISH || target.getType()==EntityType.ENDERMITE) && + p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS)>0) { + sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS)*2; + log("Player "+p.getName()+" has Bane of Arthropods "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS)+".",5); + } + } + } + } + + if (pd!=null) { + pd.prev_weapondmg = basedmg; + } int weaknesslevel = 0; int strengthlevel = 0; @@ -4685,46 +5066,18 @@ public class TwosideKeeper extends JavaPlugin implements Listener { weaknesslevel = Iterables.get(player_effects, i).getAmplifier()+1; log("Found weakness on this player. Weakness level: "+(weaknesslevel),5); } - } - - int partylevel = 0; - for (int j=0;j0) { - partylevel = playerdata.get(j).partybonus; - log("Party level is "+partylevel,5); - if (partylevel>9) {partylevel=9;} - } - } - - int sharpnesslevel=0; - //Apply player enchantments next. - //Each sharpness level increases damage by 0.5. - //Both Smite and Bane of Arthropods increases damage by 1.0 per level. - if (p.getEquipment().getItemInMainHand()!=null) { - if (p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL)>0) { - sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL); - log("Player "+p.getName()+" has Sharpness "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL)+".",5); - } else - if (target!=null) { - if ((target.getType()==EntityType.ZOMBIE || target.getType()==EntityType.PIG_ZOMBIE || - target.getType()==EntityType.WITHER || target.getType()==EntityType.SKELETON) && - p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)>0) { - sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)*2; - log("Player "+p.getName()+" has Smite "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)+".",5); - } else - if ((target.getType()==EntityType.SPIDER || target.getType()==EntityType.CAVE_SPIDER || - target.getType()==EntityType.SILVERFISH || target.getType()==EntityType.ENDERMITE) && - p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS)>0) { - sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS)*2; - log("Player "+p.getName()+" has Bane of Arthropods "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS)+".",5); - } + if (pd!=null) { + pd.prev_buffdmg = strengthlevel; } } - return (basedmg+(sharpnesslevel*0.5)) + double finalamt = (basedmg+(sharpnesslevel*0.5)) /((10-partylevel)*0.1) /((10-strengthlevel)*0.1) *((10-weaknesslevel)*0.1); + + + return finalamt; } public void DealCalculatedDamage(ItemStack weapon, LivingEntity p, LivingEntity target) { @@ -4750,63 +5103,74 @@ public class TwosideKeeper extends JavaPlugin implements Listener { protectionlevel+=monsterEquipment[i].getEnchantmentLevel(Enchantment.PROTECTION_ENVIRONMENTAL); //Protection is 1% damage reduction per level of protection. } - - switch (monsterEquipment[i].getType()) { - case LEATHER_HELMET:{ - dmgreduction+=3.0*((isMonster)?2:1); //We multiply it all by 2 since we are giving them the "block" version of the armor. - }break; - case LEATHER_CHESTPLATE:{ - dmgreduction+=3.0*((isMonster)?2:1); - }break; - case LEATHER_LEGGINGS:{ - dmgreduction+=3.0*((isMonster)?2:1); - }break; - case LEATHER_BOOTS:{ - dmgreduction+=3.0*((isMonster)?2:1); - }break; - case IRON_HELMET:{ - dmgreduction+=5.0*((isMonster)?2:1); - }break; - case IRON_CHESTPLATE:{ - dmgreduction+=5.0*((isMonster)?2:1); - }break; - case IRON_LEGGINGS:{ - dmgreduction+=5.0*((isMonster)?2:1); - }break; - case IRON_BOOTS:{ - dmgreduction+=5.0*((isMonster)?2:1); - }break; - case GOLD_HELMET:{ - dmgreduction+=10.0*((isMonster)?2:1); - }break; - case GOLD_CHESTPLATE:{ - dmgreduction+=10.0*((isMonster)?2:1); - }break; - case GOLD_LEGGINGS:{ - dmgreduction+=10.0*((isMonster)?2:1); - }break; - case GOLD_BOOTS:{ - dmgreduction+=10.0*((isMonster)?2:1); - }break; - case DIAMOND_HELMET:{ - dmgreduction+=8.0*((isMonster)?2:1); - }break; - case DIAMOND_CHESTPLATE:{ - dmgreduction+=8.0*((isMonster)?2:1); - }break; - case DIAMOND_LEGGINGS:{ - dmgreduction+=8.0*((isMonster)?2:1); - }break; - case DIAMOND_BOOTS:{ - dmgreduction+=8.0*((isMonster)?2:1); - }break; - default: { - dmgreduction+=0.0*((isMonster)?2:1); + + //If this is an artifact armor, we totally override the base damage reduction. + if (GenericFunctions.isArmor(monsterEquipment[i]) && Artifact.isArtifact(monsterEquipment[i])) { + //Let's change up the damage. + double dmgval = ArtifactItemType.valueOf(Artifact.returnRawTool(monsterEquipment[i].getType())).getDamageAmt(monsterEquipment[i].getEnchantmentLevel(Enchantment.LUCK)); + if (dmgval!=-1) { + dmgreduction += dmgval; + } + } else { + switch (monsterEquipment[i].getType()) { + case LEATHER_HELMET:{ + dmgreduction+=3.0*((isMonster)?2:1); //We multiply it all by 2 since we are giving them the "block" version of the armor. + }break; + case LEATHER_CHESTPLATE:{ + dmgreduction+=3.0*((isMonster)?2:1); + }break; + case LEATHER_LEGGINGS:{ + dmgreduction+=3.0*((isMonster)?2:1); + }break; + case LEATHER_BOOTS:{ + dmgreduction+=3.0*((isMonster)?2:1); + }break; + case IRON_HELMET:{ + dmgreduction+=5.0*((isMonster)?2:1); + }break; + case IRON_CHESTPLATE:{ + dmgreduction+=5.0*((isMonster)?2:1); + }break; + case IRON_LEGGINGS:{ + dmgreduction+=5.0*((isMonster)?2:1); + }break; + case IRON_BOOTS:{ + dmgreduction+=5.0*((isMonster)?2:1); + }break; + case GOLD_HELMET:{ + dmgreduction+=10.0*((isMonster)?2:1); + }break; + case GOLD_CHESTPLATE:{ + dmgreduction+=10.0*((isMonster)?2:1); + }break; + case GOLD_LEGGINGS:{ + dmgreduction+=10.0*((isMonster)?2:1); + }break; + case GOLD_BOOTS:{ + dmgreduction+=10.0*((isMonster)?2:1); + }break; + case DIAMOND_HELMET:{ + dmgreduction+=8.0*((isMonster)?2:1); + }break; + case DIAMOND_CHESTPLATE:{ + dmgreduction+=8.0*((isMonster)?2:1); + }break; + case DIAMOND_LEGGINGS:{ + dmgreduction+=8.0*((isMonster)?2:1); + }break; + case DIAMOND_BOOTS:{ + dmgreduction+=8.0*((isMonster)?2:1); + }break; + default: { + dmgreduction+=0.0*((isMonster)?2:1); + } } } } } + + //Now apply resistances if any. //Resistance effect reduces damage by 10% per level of resistance. int resistlevel = 0; @@ -4846,7 +5210,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } - public double CalculateDamageReduction(double basedmg,LivingEntity target,Entity damager) { + static public double CalculateDamageReduction(double basedmg,LivingEntity target,Entity damager) { ItemStack[] armor = target.getEquipment().getArmorContents(); double dmgreduction = 0.0; @@ -4869,31 +5233,41 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } boolean isBlockArmor = GenericFunctions.isHardenedItem(armor[i]); - switch (armor[i].getType()) { - case LEATHER_BOOTS: - case LEATHER_LEGGINGS: - case LEATHER_CHESTPLATE: - case LEATHER_HELMET: { - dmgreduction+=3*((isBlockArmor)?2:1); - }break; - case IRON_BOOTS: - case IRON_LEGGINGS: - case IRON_CHESTPLATE: - case IRON_HELMET: { - dmgreduction+=5*((isBlockArmor)?2:1); - }break; - case GOLD_BOOTS: - case GOLD_LEGGINGS: - case GOLD_CHESTPLATE: - case GOLD_HELMET: { - dmgreduction+=10*((isBlockArmor)?2:1); - }break; - case DIAMOND_BOOTS: - case DIAMOND_LEGGINGS: - case DIAMOND_CHESTPLATE: - case DIAMOND_HELMET: { - dmgreduction+=8*((isBlockArmor)?2:1); - }break; + + //If this is an artifact armor, we totally override the base damage reduction. + if (GenericFunctions.isArmor(armor[i]) && Artifact.isArtifact(armor[i])) { + //Let's change up the damage. + double dmgval = ArtifactItemType.valueOf(Artifact.returnRawTool(armor[i].getType())).getDamageAmt(armor[i].getEnchantmentLevel(Enchantment.LUCK)); + if (dmgval!=-1) { + dmgreduction += dmgval; + } + } else { + switch (armor[i].getType()) { + case LEATHER_BOOTS: + case LEATHER_LEGGINGS: + case LEATHER_CHESTPLATE: + case LEATHER_HELMET: { + dmgreduction+=3*((isBlockArmor)?2:1); + }break; + case IRON_BOOTS: + case IRON_LEGGINGS: + case IRON_CHESTPLATE: + case IRON_HELMET: { + dmgreduction+=5*((isBlockArmor)?2:1); + }break; + case GOLD_BOOTS: + case GOLD_LEGGINGS: + case GOLD_CHESTPLATE: + case GOLD_HELMET: { + dmgreduction+=10*((isBlockArmor)?2:1); + }break; + case DIAMOND_BOOTS: + case DIAMOND_LEGGINGS: + case DIAMOND_CHESTPLATE: + case DIAMOND_HELMET: { + dmgreduction+=8*((isBlockArmor)?2:1); + }break; + } } } } @@ -4907,12 +5281,17 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } + PlayerStructure pd = null; + if (target instanceof Player) { Player p = (Player)target; for (int j=0;j0) { - partylevel = playerdata.get(j).partybonus; - if (partylevel>9) {partylevel=9;} + if (playerdata.get(j).name.equalsIgnoreCase(p.getName())) { + pd = playerdata.get(j); + if (playerdata.get(j).partybonus>0) { + partylevel = playerdata.get(j).partybonus; + if (partylevel>9) {partylevel=9;} + } } } } @@ -4929,6 +5308,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener { *((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 (pd!=null) { + pd.prev_armordef = finaldmg; + } return finaldmg; } diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java index 8f12aaf..d335466 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java @@ -2,6 +2,7 @@ package sig.plugin.TwosideKeeper; import org.bukkit.Location; import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Monster; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -64,9 +65,17 @@ public final class TwosideKeeperAPI { return GenericFunctions.getHardenedItemBreaks(i); } public static ItemStack breakHardenedItem(ItemStack i) { - return GenericFunctions.breakHardenedItem(i); + return GenericFunctions.breakHardenedItem(i,null); + } + public static ItemStack breakHardenedItem(ItemStack i, Player p) { + return GenericFunctions.breakHardenedItem(i,p); } + //Combat COMMANDS. + public static double getModifiedDamage(double dmg_amt, LivingEntity p) { + return TwosideKeeper.CalculateDamageReduction(dmg_amt, p, p); + } + //Spleef COMMANDS. public static boolean isPlayingSpleef(Player p) { return SpleefManager.playerIsPlayingSpleef(p);