diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index e0525b9..b8fbac0 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/plugin.yml b/src/plugin.yml index 5c71ba8..403d8d3 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper -version: 3.10.7a +version: 3.10.8 loadbefore: [aPlugin] commands: money: diff --git a/src/sig/plugin/TwosideKeeper/CustomDamage.java b/src/sig/plugin/TwosideKeeper/CustomDamage.java index 3536757..23bc8b4 100644 --- a/src/sig/plugin/TwosideKeeper/CustomDamage.java +++ b/src/sig/plugin/TwosideKeeper/CustomDamage.java @@ -162,9 +162,11 @@ public class CustomDamage { private static double CalculateBonusTrueDamage(Entity damager) { if (getDamagerEntity(damager) instanceof Player) { + LivingEntity shooter = getDamagerEntity(damager); double bonus_truedmg = 0; Player p = (Player)getDamagerEntity(damager); bonus_truedmg += API.getPlayerBonuses(p).getBonusTrueDamage(); + bonus_truedmg += ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getBaubles(shooter), (Player)shooter, ItemSet.ALUSTINE, 7)?((Player)shooter).getLevel():0; return bonus_truedmg; } else { return 0.0; @@ -237,12 +239,14 @@ public class CustomDamage { dmg += addMultiplierToPlayerLogger(damager,target,"Tactics Bonus Mult",dmg * API.getPlayerBonuses((Player)shooter).getBonusOverallDamageMultiplier()); } dmg += addMultiplierToPlayerLogger(damager,target,"Striker Mult",dmg * calculateStrikerMultiplier(shooter,target)); - double preemptivedmg = addMultiplierToPlayerLogger(damager,target,"Preemptive Strike Mult",dmg * calculatePreemptiveStrikeMultiplier(target,shooter)); - if (preemptivedmg!=0.0) {preemptive=true;} - dmg += preemptivedmg; - double backstabdmg = addMultiplierToPlayerLogger(damager,target,"Backstab Mult",dmg * calculateBackstabMultiplier(target,shooter)); - if (backstabdmg!=0.0) {preemptive=true;} - dmg += backstabdmg; + if ((reason==null || !reason.equalsIgnoreCase("Test Damage"))) { + double preemptivedmg = addMultiplierToPlayerLogger(damager,target,"Preemptive Strike Mult",dmg * calculatePreemptiveStrikeMultiplier(target,shooter)); + if (preemptivedmg!=0.0) {preemptive=true;} + dmg += preemptivedmg; + double backstabdmg = addMultiplierToPlayerLogger(damager,target,"Backstab Mult",dmg * calculateBackstabMultiplier(target,shooter)); + if (backstabdmg!=0.0 && (reason==null || !reason.equalsIgnoreCase("Test Damage"))) {preemptive=true;} + dmg += backstabdmg; + } dmg += addMultiplierToPlayerLogger(damager,target,"Isolation Damage Mult",dmg * calculateIsolationMultiplier(shooter,target)); dmg += addMultiplierToPlayerLogger(damager,target,"STRENGTH Mult",dmg * calculateStrengthEffectMultiplier(shooter,target)); dmg += addMultiplierToPlayerLogger(damager,target,"WEAKNESS Mult",dmg * calculateWeaknessEffectMultiplier(shooter,target)); @@ -264,7 +268,9 @@ public class CustomDamage { dmg -= getDamageReduction(target); } addToLoggerActual(damager,dmg); - addToPlayerRawDamage(dmg,target); + if (reason==null || !reason.equalsIgnoreCase("Test Damage")) { + addToPlayerRawDamage(dmg,target); + } if (!isFlagSet(flags, TRUEDMG)) { if (target instanceof Player) { if (PlayerMode.getPlayerMode((Player)target)!=PlayerMode.BARBARIAN) { @@ -648,7 +654,7 @@ public class CustomDamage { GenericFunctions.addSuppressionTime(target, 15); } if (isFlagSet(pd.lasthitproperties,IS_PREEMPTIVE)) { - if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(p), p, ItemSet.WOLFSBANE, 7)) { + if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.WOLFSBANE, 7)) { if (pd.slayermodehp+2=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getHotbarItems(target), (Player)target, ItemSet.ALUSTINE, 2, 2); + aPlugin.API.getTotalExperience((Player)target)>=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getBaubles(target), (Player)target, ItemSet.ALUSTINE, 2, 2); } public static boolean CanResistDotsWithExperienceSet(Entity damager, LivingEntity target, String reason) { - return target instanceof Player && ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(target), (Player)target, ItemSet.ALUSTINE, 3) && + return target instanceof Player && ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getBaubles(target), (Player)target, ItemSet.ALUSTINE, 3) && ((reason!=null && (reason.equalsIgnoreCase("poison") || reason.equalsIgnoreCase("wither") || reason.equalsIgnoreCase("fire_tick") || reason.equalsIgnoreCase("lava") || reason.equalsIgnoreCase("fire")))) && - aPlugin.API.getTotalExperience((Player)target)>=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getHotbarItems(target), (Player)target, ItemSet.ALUSTINE, 3, 3); + aPlugin.API.getTotalExperience((Player)target)>=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getBaubles(target), (Player)target, ItemSet.ALUSTINE, 3, 3); } private static boolean canHitMobDueToWeakness(Entity damager) { @@ -1803,11 +1811,11 @@ public class CustomDamage { } } - dodgechance+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getHotbarItems(p), p, ItemSet.GLADOMAIN, 3, 3)/100d; - if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(p), p, ItemSet.GLADOMAIN, 7)) { - dodgechance+=(93.182445*pd.velocity)*(0.05+(0.01*ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getHotbarItems(p), p, ItemSet.GLADOMAIN, 7, 4))); //For every 1m, give 5%. + dodgechance+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.GLADOMAIN, 3, 3)/100d; + if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.GLADOMAIN, 7)) { + dodgechance+=(93.182445*pd.velocity)*(0.05+(0.01*ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.GLADOMAIN, 7, 4))); //For every 1m, give 5%. } - if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(p), p, ItemSet.MOONSHADOW, 7) && + if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.MOONSHADOW, 7) && GenericFunctions.hasStealth(p)) { dodgechance+=0.4; } @@ -1864,24 +1872,28 @@ public class CustomDamage { darknessdiv += ItemSet.GetTotalBaseAmount(GenericFunctions.getEquipment(p), p, ItemSet.RUDOLPH)/100d; } } else { - LivingEntityDifficulty diff = EntityUtils.GetStrongestNearbyEntityDifficulty(EntityType.MAGMA_CUBE, target, 4); - double reduction = 0.0d; - if (diff!=null) { - switch (diff) { - case DANGEROUS:{ - reduction=0.4d; - }break; - case DEADLY:{ - reduction=0.6d; - }break; - case HELLFIRE:{ - reduction=0.8d; - }break; - default:{ - reduction=0.2d; + LivingEntityStructure les = LivingEntityStructure.getLivingEntityStructure(target); + if (!les.checkedforcubes) { + LivingEntityDifficulty diff = EntityUtils.GetStrongestNearbyEntityDifficulty(EntityType.MAGMA_CUBE, target, 4); + double reduction = 0.0d; + if (diff!=null) { + switch (diff) { + case DANGEROUS:{ + reduction=0.4d; + }break; + case DEADLY:{ + reduction=0.6d; + }break; + case HELLFIRE:{ + reduction=0.8d; + }break; + default:{ + reduction=0.2d; + } } + magmacubediv+=Math.min(reduction,1); } - magmacubediv+=Math.min(reduction,1); + les.checkedforcubes=true; } } @@ -2346,7 +2358,7 @@ public class CustomDamage { dmg += ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(shooter),(Player)shooter, ItemSet.LORASAADI, 2, 2); dmg += ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(shooter),(Player)shooter, ItemSet.LORASAADI, 3, 3); dmg += ItemSet.GetTotalBaseAmount(GenericFunctions.getEquipment(shooter), (Player)shooter, ItemSet.LORASYS); - dmg += ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(shooter), (Player)shooter, ItemSet.ALUSTINE, 7)?((Player)shooter).getLevel():0; + //dmg += ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(shooter), (Player)shooter, ItemSet.ALUSTINE, 7)?((Player)shooter).getLevel():0; /*dmg += ItemSet.TotalBaseAmountBasedOnSetBonusCount((Player)shooter, ItemSet.JAMDAK, 3, 3); dmg += ItemSet.TotalBaseAmountBasedOnSetBonusCount((Player)shooter, ItemSet.DARNYS, 3, 3); dmg += ItemSet.TotalBaseAmountBasedOnSetBonusCount((Player)shooter, ItemSet.ALIKAHN, 3, 3); @@ -2572,8 +2584,8 @@ public class CustomDamage { critchance += (PlayerMode.isStriker(p)?0.2:0.0); critchance += ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p,ItemSet.PANROS,4,4)/100d; critchance += (PlayerMode.isRanger(p)?(GenericFunctions.getPotionEffectLevel(PotionEffectType.SLOW, p)+1)*0.1:0.0); - critchance += ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getHotbarItems(p), p, ItemSet.MOONSHADOW, 5, 4)/100d; - critchance += ItemSet.GetTotalBaseAmount(GenericFunctions.getHotbarItems(p), p, ItemSet.WOLFSBANE)/100d; + critchance += ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.MOONSHADOW, 5, 4)/100d; + critchance += ItemSet.GetTotalBaseAmount(GenericFunctions.getBaubles(p), p, ItemSet.WOLFSBANE)/100d; critchance += API.getPlayerBonuses(p).getBonusCriticalChance(); critchance += (pd.slayermegahit)?1.0:0.0; if (reason!=null && reason.equalsIgnoreCase("power swing")) { @@ -2606,7 +2618,7 @@ public class CustomDamage { critdmg+=1.0; } critdmg+=API.getPlayerBonuses(p).getBonusCriticalDamage(); - critdmg+=ItemSet.GetTotalBaseAmount(GenericFunctions.getHotbarItems(p), p, ItemSet.MOONSHADOW)/100d; + critdmg+=ItemSet.GetTotalBaseAmount(GenericFunctions.getBaubles(p), p, ItemSet.MOONSHADOW)/100d; } TwosideKeeper.log("Crit Damage is "+critdmg, 5); return critdmg; @@ -3073,7 +3085,7 @@ public class CustomDamage { */ public static double calculateCooldownReduction(Player p) { double cooldown = 0.0; - cooldown+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getHotbarItems(p), p, ItemSet.GLADOMAIN, 2, 2)/100d; + cooldown+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.GLADOMAIN, 2, 2)/100d; cooldown+=ItemSet.GetTotalBaseAmount(GenericFunctions.getEquipment(p), p, ItemSet.VIXEN)/100d; return cooldown; } @@ -3155,7 +3167,7 @@ public class CustomDamage { double mult = 0.0; LivingEntity shooter = getDamagerEntity(damager); if (shooter instanceof Player) { - mult += ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getHotbarItems(shooter), (Player)shooter, ItemSet.MOONSHADOW, 3, 3)/100; + mult += ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getBaubles(shooter), (Player)shooter, ItemSet.MOONSHADOW, 3, 3)/100; } return mult; } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/BaublePouch.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/BaublePouch.java new file mode 100644 index 0000000..cf15ad4 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/BaublePouch.java @@ -0,0 +1,82 @@ +package sig.plugin.TwosideKeeper.HelperStructures.Common; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.Dropper; +import org.bukkit.block.Hopper; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import net.md_5.bungee.api.ChatColor; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemCubeUtils; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemUtils; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; + +public class BaublePouch { + public final static String POUCHID_LINE = ChatColor.DARK_GREEN+"POUCH#"; + public static boolean isBaublePouch(ItemStack item) { + return (ItemUtils.isValidItem(item) && + ItemUtils.LoreContainsSubstring(item, POUCHID_LINE)); + } + public static Location getBaublePouchLoc(int id) { + int posx = id % 960; + int posy = 66; //Hoppers are at 64. So these cannot be directly above them as the items will get sucked in. + int posz = id / 960; + return new Location(Bukkit.getWorld("FilterCube"),posx,posy,posz); + } + public static Block getBaublePouchBlock(int id) { + Block b = Bukkit.getWorld("FilterCube").getBlockAt(getBaublePouchLoc(id)); + return b; + } + public static Dropper getBaublePouchDropper(int id) { + Dropper h = (Dropper)Bukkit.getWorld("FilterCube").getBlockAt(getBaublePouchLoc(id)).getState(); + return h; + } + public static void createNewBaublePouch(int id) { + Block b = getBaublePouchBlock(id); + b.getWorld().getBlockAt(getBaublePouchLoc(id)).setType(Material.DROPPER); + } + public static int getBaublePouchID(ItemStack item) { + if (isBaublePouch(item)) { + String id = ItemUtils.GetLoreLineContainingSubstring(item, POUCHID_LINE).split("#")[1]; + return Integer.parseInt(id); + } else { + return -1; + } + } + public static HashMap insertItemsIntoBaublePouch(int id, ItemStack...items) { + Dropper d = getBaublePouchDropper(id); + Inventory inv = d.getInventory(); + return inv.addItem(items); + } + public static void openBaublePouch(Player p, ItemStack item) { + if (isBaublePouch(item)) { + int id = getBaublePouchID(item); + Dropper d = getBaublePouchDropper(id); + d.getChunk().load(); + p.openInventory(d.getInventory()); + SoundUtils.playLocalSound(p, Sound.ITEM_ARMOR_EQUIP_LEATHER, 1.0f, 1.0f); + } else { + p.sendMessage(ChatColor.RED+"Could not open Bauble Pouch! Please let the admin know this did not work."); + } + } + public static List getBaublePouchContents(int id) { + List itemlist = new ArrayList(); + Dropper d = getBaublePouchDropper(id); + Inventory inv = d.getInventory(); + for (ItemStack item : inv.getContents()) { + if (ItemUtils.isValidItem(item)) { + itemlist.add(item); + } + } + return itemlist; + } +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index 6d8188f..d810be6 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -3499,7 +3499,7 @@ public class GenericFunctions { pd.slayermodehp = p.getMaxHealth(); ItemStack[] equips = p.getEquipment().getArmorContents(); - ItemStack[] hotbar = GenericFunctions.getHotbarItems(p); + ItemStack[] hotbar = GenericFunctions.getBaubles(p); if (ItemSet.HasSetBonusBasedOnSetBonusCount(hotbar, p, ItemSet.GLADOMAIN, 5) && pd.lastlifesavertime+GenericFunctions.GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN, p)<=TwosideKeeper.getServerTickTime()) { @@ -4139,23 +4139,8 @@ public class GenericFunctions { } } - public static boolean hasSlayerSetItemOnHotbar(Player p) { - for (int i=0;i<9;i++) { - if (i==9) { - i=40; - } - ItemStack item = p.getInventory().getContents()[i]; - ItemSet set = TwosideKeeperAPI.getItemSet(item); - if (set!=null && - (set==ItemSet.LORASYS || - set==ItemSet.GLADOMAIN || - set==ItemSet.MOONSHADOW || - set==ItemSet.WOLFSBANE || - set==ItemSet.ALUSTINE)) { - return true; - } - } - return false; + public static boolean hasBaublePouchInOffHand(Player p) { + return BaublePouch.isBaublePouch(p.getEquipment().getItemInOffHand()); } public static boolean WearingNoArmor(Player p) { @@ -4289,7 +4274,7 @@ public class GenericFunctions { pd.last_strikerspell=TwosideKeeper.getServerTickTime(); } SoundUtils.playLocalSound(p, Sound.UI_BUTTON_CLICK, 1.0f, 1.0f); - aPlugin.API.damageItem(p, weaponused, (weaponused.getType().getMaxDurability()/10)+7); + aPlugin.API.damageItem(p.getInventory(), weaponused, (weaponused.getType().getMaxDurability()/10)+7); final Player p1 = p; int mult=2; @@ -4362,16 +4347,16 @@ public class GenericFunctions { aPlugin.API.sendCooldownPacket(player, name, GetModifiedCooldown(TwosideKeeper.ASSASSINATE_COOLDOWN,player)); } pd.lastassassinatetime=TwosideKeeper.getServerTickTime(); - if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(player), player, ItemSet.WOLFSBANE, 5)) { - GenericFunctions.addIFrame(player, (int)ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getHotbarItems(player), player, ItemSet.WOLFSBANE, 5, 4)); + if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getBaubles(player), player, ItemSet.WOLFSBANE, 5)) { + GenericFunctions.addIFrame(player, (int)ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getBaubles(player), player, ItemSet.WOLFSBANE, 5, 4)); } else { GenericFunctions.addIFrame(player, 10); } - if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(player), player, ItemSet.WOLFSBANE, 3)) { + if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getBaubles(player), player, ItemSet.WOLFSBANE, 3)) { GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SPEED, 100, 4, player); - GenericFunctions.addSuppressionTime(target, (int)ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getHotbarItems(player), player, ItemSet.WOLFSBANE, 3, 3)); + GenericFunctions.addSuppressionTime(target, (int)ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getBaubles(player), player, ItemSet.WOLFSBANE, 3, 3)); } - if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(player), player, ItemSet.WOLFSBANE, 7) && + if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getBaubles(player), player, ItemSet.WOLFSBANE, 7) && target.getLocation().distanceSquared(originalloc)<=25) { pd.lastassassinatetime = TwosideKeeper.getServerTickTime()-TwosideKeeper.ASSASSINATE_COOLDOWN+40; if (name!=Material.SKULL_ITEM || pd.lastlifesavertime+GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN,player) baubles = BaublePouch.getBaublePouchContents(BaublePouch.getBaublePouchID(baublepouch)); + ItemStack[] array = new ItemStack[baubles.size()]; + array = baubles.toArray(array); + TwosideKeeper.log("Baubles: "+ArrayUtils.toString(array), 5); + return array; + } else { + return new ItemStack[]{ + }; + } + } + public static ItemStack[] getHotbarItems(LivingEntity p) { Player pl = (Player)p; return new ItemStack[]{ @@ -4659,7 +4659,7 @@ public class GenericFunctions { public static boolean AllowedToBeEquippedToOffHand(Player p, ItemStack item, int clickedslot) { //TwosideKeeper.log("Slot:"+clickedslot, 0); 36-44 is hotbar. - return (ArrowQuiver.isValidQuiver(item)); /*|| + return (ArrowQuiver.isValidQuiver(item) || BaublePouch.isBaublePouch(item)); /*|| (item.getType()==Material.SHIELD && (clickedslot<36 || !p.getEquipment().getItemInMainHand().equals(p.getInventory().getContents()[clickedslot-36])) && (PlayerMode.isDefender(p) || PlayerMode.isNormal(p))));*/ } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/JobRecipe.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/JobRecipe.java index 11df2a1..9ce169a 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/JobRecipe.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/JobRecipe.java @@ -16,9 +16,22 @@ public class JobRecipe { this.rec=rec; } + public String getName() { + return name; + } + + public String getCommandName() { + return name.replaceAll(" ", "_"); + } + + public Recipe getRecipe() { + return rec; + } + public static void InitializeJobRecipes() { Map newrecipes = aPlugin.API.getAddedRecipes(); for (String namer : newrecipes.keySet()) { + TwosideKeeper.log("Added recipe: "+namer, 4); Recipe r = newrecipes.get(namer); TwosideKeeper.jobrecipes.add(new JobRecipe(namer,r)); } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/RecipeLinker.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/RecipeLinker.java index 294694a..344809b 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/RecipeLinker.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/RecipeLinker.java @@ -383,6 +383,12 @@ public enum RecipeLinker { CustomItem.WorldShop2(), new ItemStack(Material.TRAPPED_CHEST,1),new ItemStack(Material.SIGN,1),null, CustomItem.DirtSubstitute(), + }), + baublepouch(RecipeCategory.CONTAINERS,ChatColor.YELLOW,"Bauble Pouch",new ItemStack[]{ + CustomItem.BaublePouch(), + new ItemStack(Material.LEATHER),new ItemStack(Material.LEATHER),new ItemStack(Material.LEATHER), + new ItemStack(Material.LEATHER),new ItemStack(Material.CHORUS_FLOWER),new ItemStack(Material.LEATHER), + new ItemStack(Material.LEATHER),new ItemStack(Material.LEATHER),new ItemStack(Material.LEATHER), }); String name = ""; diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/CustomItem.java b/src/sig/plugin/TwosideKeeper/HelperStructures/CustomItem.java index 6dbfd48..540034c 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/CustomItem.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/CustomItem.java @@ -24,6 +24,7 @@ import sig.plugin.TwosideKeeper.Artifact; import sig.plugin.TwosideKeeper.Recipes; import sig.plugin.TwosideKeeper.TwosideKeeper; import sig.plugin.TwosideKeeper.HelperStructures.Common.ArrowQuiver; +import sig.plugin.TwosideKeeper.HelperStructures.Common.BaublePouch; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemUtils; @@ -116,6 +117,28 @@ public class CustomItem { TwosideKeeper.PIERCING_ARROW_RECIPE = PiercingArrowRecipe(); TwosideKeeper.WORLD_SHOP_RECIPE = WorldShopRecipe(); TwosideKeeper.WORLD_SHOP2_RECIPE = WorldShop2Recipe(); + TwosideKeeper.BAUBLE_POUCH_RECIPE = BaublePouchRecipe(); + } + + private static ShapelessRecipe BaublePouchRecipe() { + ShapelessRecipe rec = new ShapelessRecipe(BaublePouch()); + rec.addIngredient(4, Material.LEATHER); + rec.addIngredient(1, Material.CHORUS_FLOWER); + rec.addIngredient(4, Material.LEATHER); + return rec; + } + + public static ItemStack BaublePouch() { + ItemStack baublePouch = new ItemStack(Material.CHORUS_FLOWER); + ItemUtils.addLore(baublePouch, ChatColor.AQUA+"A handy 9-slot pouch that"); + ItemUtils.addLore(baublePouch, ChatColor.AQUA+"can hold Baubles of any"); + ItemUtils.addLore(baublePouch, ChatColor.AQUA+"sort."); + ItemUtils.addLore(baublePouch, ChatColor.AQUA+""); + ItemUtils.addLore(baublePouch, BaublePouch.POUCHID_LINE+"0"); + ItemUtils.setDisplayName(baublePouch, ChatColor.GREEN+"Bauble Pouch"); + baublePouch.addUnsafeEnchantment(Enchantment.LUCK, 1); + ItemUtils.hideEnchantments(baublePouch); + return baublePouch.clone(); } public static ItemStack VacuumCube() { diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/ItemSet.java b/src/sig/plugin/TwosideKeeper/HelperStructures/ItemSet.java index 7e916b9..31dead6 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/ItemSet.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/ItemSet.java @@ -319,21 +319,37 @@ public enum ItemSet { lore.add(ChatColor.LIGHT_PURPLE+"Slayer Amulet"); lore.add(ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+" Gladomain Set"); lore.add(ChatColor.YELLOW+"+"+ItemSet.GetBaseAmount(set, tier, 1)+" HP"); + lore.add(""); + lore.add(ChatColor.GRAY+" Must be inserted into a "+ChatColor.BLUE+"Bauble Pouch"); + lore.add(ChatColor.GRAY+" to benefit from the effects."); + lore.add(""); }break; case MOONSHADOW:{ lore.add(ChatColor.LIGHT_PURPLE+"Slayer Trinket"); lore.add(ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+" Moonshadow Set"); lore.add(ChatColor.YELLOW+"+"+ItemSet.GetBaseAmount(set, tier, 1)+"% Crit Damage"); + lore.add(""); + lore.add(ChatColor.GRAY+" Must be inserted into a "+ChatColor.BLUE+"Bauble Pouch"); + lore.add(ChatColor.GRAY+" to benefit from the effects."); + lore.add(""); }break; case WOLFSBANE:{ lore.add(ChatColor.LIGHT_PURPLE+"Slayer Ornament"); lore.add(ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+" Wolfsbane Set"); lore.add(ChatColor.YELLOW+"+"+ItemSet.GetBaseAmount(set, tier, 1)+"% Critical Chance"); + lore.add(""); + lore.add(ChatColor.GRAY+" Must be inserted into a "+ChatColor.BLUE+"Bauble Pouch"); + lore.add(ChatColor.GRAY+" to benefit from the effects."); + lore.add(""); }break; case ALUSTINE:{ lore.add(ChatColor.LIGHT_PURPLE+"Slayer Charm"); lore.add(ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+" Alustine Set"); lore.add(ChatColor.YELLOW+"+"+ItemSet.GetBaseAmount(set, tier, 1)+"% EXP Gain"); + lore.add(""); + lore.add(ChatColor.GRAY+" Must be inserted into a "+ChatColor.BLUE+"Bauble Pouch"); + lore.add(ChatColor.GRAY+" to benefit from the effects."); + lore.add(""); }break; case BLITZEN: lore.add(ChatColor.BLUE+"Holiday Gear"); @@ -568,9 +584,9 @@ public enum ItemSet { lore.add(ChatColor.DARK_AQUA+" "+ChatColor.WHITE+" Collecting experience has a "+Math.min((ItemSet.GetBaseAmount(set, tier, 4)/20d)*100d,100)+"% chance"); lore.add(ChatColor.DARK_AQUA+" "+ChatColor.WHITE+" to restore 2 HP (1 Heart)."); lore.add(ChatColor.DARK_AQUA+" 7 - "+ChatColor.WHITE+" Provides the Following Bonuses:"); - lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"Deal additional base damage equal to the"); - lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"number of levels you have. Drains XP equal"); - lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"to the number of levels you have per hit."); + lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"Deals true damage equal to the number"); + lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"of levels you have. Drains XP equal to"); + lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"the number of levels you have per hit."); }break; case BLITZEN: lore.add(ChatColor.GOLD+""+ChatColor.ITALIC+"Set Bonus:"); diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/PlayerMode.java b/src/sig/plugin/TwosideKeeper/HelperStructures/PlayerMode.java index cae9f9f..08df138 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/PlayerMode.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/PlayerMode.java @@ -86,7 +86,7 @@ public enum PlayerMode { ), SLAYER(ChatColor.DARK_BLUE,"SL","Slayer", ChatColor.DARK_BLUE+""+ChatColor.BOLD+"Slayer mode Perks: "+ChatColor.RESET+"\n" - + ChatColor.WHITE+"->Players are identified as 'Slayers' by wearing no armor, and wearing a Bauble in their hotbar.\n" + + ChatColor.WHITE+"->Players are identified as 'Slayers' by wearing no armor, and wearing a Bauble Pouch in their off hand.\n" + ChatColor.GRAY+"->Slayers can make use of up to 9 Baubles by placing them on their hotbar (Ideally you would want to use one slot for a weapon). Each Bauble adds a certain amount of stats to the Slayer, making them more efficient.\n" + ChatColor.WHITE+"->Slayers take a maximum of 1 Heart (2 HP) in damage from all attacks, making this mode essentially 5 lives.\n" + ChatColor.GRAY+"->Slayers are not affected by any Health Recovery and Health Regeneration effects. This mode only heals from kills, being out of combat for 1 minute, using the Amulet's set effect, or sleeping. However, Absorption will still work for a Slayer. Absorption hearts just get removed with normal damage calculation rules.\n" @@ -302,7 +302,7 @@ public enum PlayerMode { if (p!=null && !p.isDead()) { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); if (needsUpdating(pd)) { - if (p.getEquipment().getItemInMainHand()!=null && GenericFunctions.hasSlayerSetItemOnHotbar(p) && + if (p.getEquipment().getItemInMainHand()!=null && GenericFunctions.hasBaublePouchInOffHand(p) && GenericFunctions.WearingNoArmor(p)) { return true; } else { diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Pronouns.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Pronouns.java index fd1f9a4..4bc6f96 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Pronouns.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Pronouns.java @@ -71,7 +71,7 @@ public class Pronouns { "exploded.", "decided there was a better life worth living.", "exploded by the after shock.", - "was shredded by the secondary explsion.", + "was shredded by the secondary explosion.", "exploded into pieces.", "could not handle the after shock.", "was feeling a little greedy, blindly walking into the demolition zone.", diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/EntityUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/EntityUtils.java index ca9a29b..6b5b40f 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/EntityUtils.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/EntityUtils.java @@ -9,6 +9,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.ItemStack; +import sig.plugin.TwosideKeeper.LivingEntityStructure; import sig.plugin.TwosideKeeper.MonsterController; import sig.plugin.TwosideKeeper.HelperStructures.LivingEntityDifficulty; @@ -28,6 +29,8 @@ public class EntityUtils { LivingEntityDifficulty strongest = null; for (Entity e : ents) { if (e instanceof LivingEntity) { + LivingEntityStructure les = LivingEntityStructure.getLivingEntityStructure((LivingEntity)e); + les.checkedforcubes=true; LivingEntityDifficulty diff = MonsterController.getLivingEntityDifficulty((LivingEntity)e); if (e!=null && e.getType()==type && (strongest==null || !strongest.isStronger(diff))) { strongest = diff; diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemCubeUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemCubeUtils.java index e256400..7128f15 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemCubeUtils.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemCubeUtils.java @@ -87,7 +87,8 @@ public class ItemCubeUtils { } public static boolean SomeoneHasAFilterCubeOpen() { for (Player p : Bukkit.getOnlinePlayers()) { - if (p.getOpenInventory()!=null && p.getOpenInventory().getTopInventory()!=null && p.getOpenInventory().getTopInventory().getType()==InventoryType.HOPPER) { + if (p.getOpenInventory()!=null && p.getOpenInventory().getTopInventory()!=null && (p.getOpenInventory().getTopInventory().getType()==InventoryType.HOPPER || + p.getOpenInventory().getTopInventory().getType()==InventoryType.DROPPER /*Keep open for Bauble Pouches*/)) { TwosideKeeper.log("Keep this open! "+p.getName()+" is using it!", 5); return true; } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java index c3b483d..6cdd691 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java @@ -50,6 +50,11 @@ public class ItemUtils { item.setItemMeta(m); } + public static String getDisplayName(ItemStack item) { + ItemMeta m = item.getItemMeta(); + return m.getDisplayName(); + } + public static boolean isValidLoreItem(ItemStack item) { return (item!=null && item.hasItemMeta() && item.getItemMeta().hasLore()); } @@ -124,8 +129,8 @@ public class ItemUtils { } } - private static boolean isValidItem(ItemStack item) { - return (item!=null && item.hasItemMeta()); + public static boolean isValidItem(ItemStack item) { + return (item!=null && item.getType()!=Material.AIR); } public static boolean isArtifactDust(ItemStack item) { @@ -266,4 +271,9 @@ public class ItemUtils { Color newcol = Color.fromRGB(r, g, b); return newcol; } + + public static boolean isValidItem(ItemStack[] equips) { + // TODO Auto-generated method stub + return false; + } } diff --git a/src/sig/plugin/TwosideKeeper/LivingEntityStructure.java b/src/sig/plugin/TwosideKeeper/LivingEntityStructure.java index 19d8b52..b1577dd 100644 --- a/src/sig/plugin/TwosideKeeper/LivingEntityStructure.java +++ b/src/sig/plugin/TwosideKeeper/LivingEntityStructure.java @@ -23,6 +23,7 @@ public class LivingEntityStructure { public HashMap glowcolorlist = new HashMap(); //public long lastSpiderBallThrow = 0; public BossMonster bm = null; + public boolean checkedforcubes=false; public LivingEntityStructure(LivingEntity m) { target=null; diff --git a/src/sig/plugin/TwosideKeeper/Recipes.java b/src/sig/plugin/TwosideKeeper/Recipes.java index dc80cfe..a6f0e47 100644 --- a/src/sig/plugin/TwosideKeeper/Recipes.java +++ b/src/sig/plugin/TwosideKeeper/Recipes.java @@ -366,4 +366,7 @@ public class Recipes { recipe.addIngredient(Material.OBSIDIAN); Bukkit.addRecipe(recipe); } + public static void Initialize_BaublePouch_Recipe() { + Bukkit.addRecipe(TwosideKeeper.BAUBLE_POUCH_RECIPE); + } } diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 7d35732..7503fc7 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -161,6 +161,7 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ShapelessRecipe; import org.bukkit.inventory.meta.ItemMeta; @@ -191,6 +192,7 @@ import net.minecraft.server.v1_9_R1.EnumParticle; import net.minecraft.server.v1_9_R1.MinecraftServer; import sig.plugin.AutoPluginUpdate.AnnounceUpdateEvent; import sig.plugin.TwosideKeeper.Events.EntityDamagedEvent; +import sig.plugin.TwosideKeeper.Events.PlayerDodgeEvent; import sig.plugin.TwosideKeeper.HelperStructures.AnvilItem; import sig.plugin.TwosideKeeper.HelperStructures.ArtifactAbility; import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem; @@ -216,6 +218,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.ArrowQuiver; +import sig.plugin.TwosideKeeper.HelperStructures.Common.BaublePouch; import sig.plugin.TwosideKeeper.HelperStructures.Common.BlockModifyQueue; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; import sig.plugin.TwosideKeeper.HelperStructures.Common.Habitation; @@ -226,6 +229,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.Effects.EarthWaveTask; import sig.plugin.TwosideKeeper.HelperStructures.Effects.LavaPlume; import sig.plugin.TwosideKeeper.HelperStructures.Effects.TemporaryIce; import sig.plugin.TwosideKeeper.HelperStructures.Effects.TemporaryLava; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.ArrayUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.BlockUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.EntityUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.InventoryUtils; @@ -257,6 +261,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static double RECYCLEDECAYAMT=20.0; //% chance lost when there's another item of the same type already in there. public static double DAYMULT=2.0; //How much the day and night length will be multiplied by. public static int ITEMCUBEID=0; //The current number of Item Cubes in existence. + public static int BAUBLEPOUCHID=0; //The current number of Bauble Pouches in existence. public static int ARROWQUIVERID=0; //The current number of Arrow Quivers in existence. public static String MOTD=""; //The MOTD announcement to be announced every hour. public static double ARMOR_LEATHER_HP=0.5f; @@ -400,6 +405,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static CustomPotion LIFE_VIAL; public static CustomPotion HARDENING_VIAL; public static ItemStack DEAL_OF_THE_DAY_ITEM; + public static ShapelessRecipe BAUBLE_POUCH_RECIPE; public static final int POTION_DEBUG_LEVEL=5; public static final int SPAWN_DEBUG_LEVEL=5; @@ -731,7 +737,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } ChargeZombie.BreakBlocksAroundArea(cz.m,1); } - } + } for (CustomMonster cs : custommonsters.values()) { if (cs.m==null || !cs.m.isValid() || !cs.isAlive()) { //This has to be removed... @@ -890,6 +896,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Recipes.Initialize_CustomArrow_Recipes(); Recipes.Initialize_NotchApple_Recipe(); Recipes.Initialize_NewRedstoneLamp_Recipe(); + Recipes.Initialize_BaublePouch_Recipe(); + + Bukkit.getScheduler().runTaskLater(this,()->{JobRecipe.InitializeJobRecipes();},1); Bukkit.createWorld(new WorldCreator("FilterCube")); @@ -1593,7 +1602,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } }break; case "ADDHOTBARCUBE":{ - Collection remaining = ItemCubeUtils.addItems(Integer.parseInt(args[1]), GenericFunctions.getHotbarItems(p)); + Collection remaining = ItemCubeUtils.addItems(Integer.parseInt(args[1]), GenericFunctions.getBaubles(p)); if (remaining.size()>0) { for (ItemStack item : remaining) { p.sendMessage("Could not fit "+GenericFunctions.UserFriendlyMaterialName(item)+" "+((item.getAmount()>1)?"x"+item.getAmount():"")); @@ -1637,6 +1646,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); pd.regenpool += Integer.parseInt(args[1]); }break; + case "BAUBLEPOUCH":{ + BaublePouch.getBaublePouchContents(BaublePouch.getBaublePouchID(p.getEquipment().getItemInOffHand())); + }break; } } //LivingEntity m = MonsterController.convertMonster((Monster)p.getWorld().spawnEntity(p.getLocation(),EntityType.ZOMBIE), MonsterDifficulty.ELITE); @@ -2199,12 +2211,37 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } private void DisplayCraftingRecipe(Player p, String string) { - RecipeLinker l = RecipeLinker.valueOf(string); - ItemStack[] newarray = Arrays.copyOfRange(l.getRec(), 1, l.getRec().length); - if (p.hasPermission("createViaCraftMenu") && (getServerType()==ServerType.TEST || getServerType()==ServerType.QUIET)) { - GenericFunctions.giveItem(p, l.getRec()[0]); - } else { - aPlugin.API.viewRecipe(p, l.getRec()[0], newarray); + try { + RecipeLinker l = RecipeLinker.valueOf(string); + ItemStack[] newarray = Arrays.copyOfRange(l.getRec(), 1, l.getRec().length); + if (p.hasPermission("createViaCraftMenu") && (getServerType()==ServerType.TEST || getServerType()==ServerType.QUIET)) { + GenericFunctions.giveItem(p, l.getRec()[0]); + } else { + aPlugin.API.viewRecipe(p, l.getRec()[0], newarray); + } + } + catch (IllegalArgumentException ec) { + //Try a Job Recipe. + for (JobRecipe jr : jobrecipes) { + TwosideKeeper.log("Comparing _"+jr.getName()+"_ to _"+string+"_", 5); + if (jr.getCommandName().equalsIgnoreCase(string)) { + //Display that recipe, it matches! + TwosideKeeper.log("Found "+jr.getName(), 5); + Recipe rec = jr.getRecipe(); + if (p.hasPermission("createViaCraftMenu") && (getServerType()==ServerType.TEST || getServerType()==ServerType.QUIET)) { + GenericFunctions.giveItem(p,jr.getRecipe().getResult()); + } else { + if (rec instanceof ShapedRecipe) { + aPlugin.API.viewRecipe(p, (ShapedRecipe)jr.getRecipe()); + } else { + aPlugin.API.viewRecipe(p, (ShapelessRecipe)jr.getRecipe()); + } + } + return; + } + } + TwosideKeeper.log(ArrayUtils.toString(ec.getStackTrace()),0); + p.sendMessage(ChatColor.RED+"Something terrible has happened! Please inform the admin of this issue!"); } } private void DisplayArguments(Player p) { @@ -2259,23 +2296,26 @@ public class TwosideKeeper extends JavaPlugin implements Listener { fin.addExtra(tc); } } - /*if (RecipeCategory.valueOf(arg)==RecipeCategory.MISC_ITEMS) { + if (RecipeCategory.valueOf(arg)==RecipeCategory.MISC_ITEMS) { //Display the Custom Recipes. - j++; - JobRecipe jr = - TextComponent tc = new TextComponent(ChatColor.values()[j+2]+"["+val.getColor()+val.getName()+ChatColor.values()[j+2]+"] "); - if (p.hasPermission("createViaCraftMenu") && (getServerType()==ServerType.TEST || getServerType()==ServerType.QUIET)) { - tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder("Click to be given a "+val.getColor()+val.getName()).create())); - } else { - tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder("Click to view the recipe for "+val.getColor()+val.getName()).create())); - } - tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/craft "+val.name()+" view")); - if (j>2) { - tc.addExtra("\n"); - j=0; + TwosideKeeper.log("In miscellaneous.", 5); + for (JobRecipe jr : TwosideKeeper.jobrecipes) { + TwosideKeeper.log("JobRecipe: "+jr.getName(), 5); + TextComponent tc = new TextComponent("["+ChatColor.YELLOW+jr.getName()+"] "); + j++; + if (p.hasPermission("createViaCraftMenu") && (getServerType()==ServerType.TEST || getServerType()==ServerType.QUIET)) { + tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder("Click to be given a "+ChatColor.YELLOW+jr.getName()).create())); + } else { + tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder("Click to view the recipe for "+ChatColor.YELLOW+jr.getName()).create())); + } + tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/craft "+jr.getCommandName()+" view")); + if (j>2) { + tc.addExtra("\n"); + j=0; + } + fin.addExtra(tc); } - fin.addExtra(tc); - }*/ + } p.spigot().sendMessage(fin); } @@ -3172,66 +3212,38 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } - //Check for a bow shift-right click. - if (ev.getAction()==Action.RIGHT_CLICK_AIR || ev.getAction()==Action.RIGHT_CLICK_BLOCK - || ev.getAction()==Action.LEFT_CLICK_BLOCK + //Check for a bow shift+left click. + if (ev.getAction()==Action.LEFT_CLICK_BLOCK || ev.getAction()==Action.LEFT_CLICK_AIR) { if (PlayerMode.isRanger(p) && p.isSneaking() && p.getEquipment().getItemInMainHand().getType()==Material.BOW) { //Rotate Bow Modes. GenericFunctions.logAndRemovePotionEffectFromEntity(PotionEffectType.SLOW,p); BowMode mode = GenericFunctions.getBowMode(p); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); - if (ev.getAction().name().contains("RIGHT")) { - if (pd.lastbowmodeswitch+6>=getServerTickTime()) { - return; - } - switch (mode) { - case CLOSE:{ - SoundUtils.playLocalSound(p, Sound.ENTITY_ZOMBIE_INFECT, 0.5f, 0.1f); - GenericFunctions.setBowMode(p,BowMode.SNIPE); - aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_arrowbarrage, ARROWBARRAGE_COOLDOWN)); - }break; - case SNIPE:{ - SoundUtils.playLocalSound(p, Sound.BLOCK_BREWING_STAND_BREW, 0.5f, 0.1f); - GenericFunctions.setBowMode(p,BowMode.DEBILITATION); - aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_siphon, SIPHON_COOLDOWN)); - }break; - case DEBILITATION:{ - SoundUtils.playLocalSound(p, Sound.BLOCK_CHEST_LOCKED, 0.5f, 3.5f); - GenericFunctions.setBowMode(p,BowMode.CLOSE); - aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_dodge, DODGE_COOLDOWN)); - }break; - } - pd.lastbowmodeswitch=getServerTickTime(); - } else { - if (pd.lastbowmodeswitch+6>=getServerTickTime()) { - return; - } - switch (mode) { - case CLOSE:{ - SoundUtils.playLocalSound(p, Sound.BLOCK_BREWING_STAND_BREW, 0.5f, 0.1f); - GenericFunctions.setBowMode(p,BowMode.DEBILITATION); - //GenericFunctions.applyModeName(p.getEquipment().getItemInMainHand()); - p.updateInventory(); - aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_siphon, SIPHON_COOLDOWN)); - }break; - case SNIPE:{ - SoundUtils.playLocalSound(p, Sound.BLOCK_CHEST_LOCKED, 0.5f, 3.5f); - GenericFunctions.setBowMode(p,BowMode.CLOSE); - //GenericFunctions.applyModeName(p.getEquipment().getItemInMainHand()); - p.updateInventory(); - aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_dodge, DODGE_COOLDOWN)); - }break; - case DEBILITATION:{ - SoundUtils.playLocalSound(p, Sound.ENTITY_ZOMBIE_INFECT, 0.5f, 0.1f); - GenericFunctions.setBowMode(p,BowMode.SNIPE); - //GenericFunctions.applyModeName(p.getEquipment().getItemInMainHand()); - p.updateInventory(); - aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_arrowbarrage, ARROWBARRAGE_COOLDOWN)); - }break; - } - pd.lastbowmodeswitch=getServerTickTime(); + switch (mode) { + case CLOSE:{ + SoundUtils.playLocalSound(p, Sound.BLOCK_BREWING_STAND_BREW, 0.5f, 0.1f); + GenericFunctions.setBowMode(p,BowMode.DEBILITATION); + //GenericFunctions.applyModeName(p.getEquipment().getItemInMainHand()); + p.updateInventory(); + aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_siphon, SIPHON_COOLDOWN)); + }break; + case SNIPE:{ + SoundUtils.playLocalSound(p, Sound.BLOCK_CHEST_LOCKED, 0.5f, 3.5f); + GenericFunctions.setBowMode(p,BowMode.CLOSE); + //GenericFunctions.applyModeName(p.getEquipment().getItemInMainHand()); + p.updateInventory(); + aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_dodge, DODGE_COOLDOWN)); + }break; + case DEBILITATION:{ + SoundUtils.playLocalSound(p, Sound.ENTITY_ZOMBIE_INFECT, 0.5f, 0.1f); + GenericFunctions.setBowMode(p,BowMode.SNIPE); + //GenericFunctions.applyModeName(p.getEquipment().getItemInMainHand()); + p.updateInventory(); + aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_arrowbarrage, ARROWBARRAGE_COOLDOWN)); + }break; } + pd.lastbowmodeswitch=getServerTickTime(); ev.setCancelled(true); return; } @@ -3276,14 +3288,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener { /*aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetModifiedCooldown(TwosideKeeper.ERUPTION_COOLDOWN,p)); pd.last_shovelspell=TwosideKeeper.getServerTickTime()+GenericFunctions.GetModifiedCooldown(TwosideKeeper.ERUPTION_COOLDOWN,p);*/ pd.lastusedearthwave=TwosideKeeper.getServerTickTime(); - aPlugin.API.damageItem(p, weapon, (int) (weapon.getType().getMaxDurability()*0.05+5)); + aPlugin.API.damageItem(p.getInventory(), weapon, (int) (weapon.getType().getMaxDurability()*0.05+5)); for (int x=-1;x<2;x++) { for (int z=-1;z<2;z++) { if (x!=0 && z!=0) { Location newblock = checkloc.clone(); if (!GenericFunctions.isSoftBlock(newblock.getBlock().getRelative(x, 0, z).getType())) { TwosideKeeper.log("NOT SOFT!", 0); - aPlugin.API.damageItem(p, weapon, (int) (weapon.getType().getMaxDurability()*0.01+1)); + aPlugin.API.damageItem(p.getInventory(), weapon, (int) (weapon.getType().getMaxDurability()*0.01+1)); } } } @@ -3456,6 +3468,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.getPlayer().updateInventory(); return; } + if (ev.getAction()==Action.RIGHT_CLICK_AIR || (ev.getPlayer().isSneaking() && ev.getAction()==Action.RIGHT_CLICK_AIR) || (ev.getPlayer().isSneaking() && ev.getAction()==Action.RIGHT_CLICK_BLOCK)) { + if (BaublePouch.isBaublePouch(ev.getPlayer().getInventory().getItemInMainHand())) { + BaublePouch.openBaublePouch(ev.getPlayer(), ev.getPlayer().getInventory().getItemInMainHand()); + ev.setCancelled(true); + return; + } + } if (ev.getAction()==Action.RIGHT_CLICK_AIR || (ev.getPlayer().isSneaking() && ev.getAction()==Action.RIGHT_CLICK_AIR) || (ev.getPlayer().isSneaking() && ev.getAction()==Action.RIGHT_CLICK_BLOCK && !GenericFunctions.isDumpableContainer(ev.getClickedBlock().getType()))) { if (ev.getPlayer().getInventory().getItemInMainHand().hasItemMeta() && ev.getPlayer().getInventory().getItemInMainHand().getItemMeta().hasLore() && @@ -4118,6 +4137,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.setCancelled(true); return; } + + if (BaublePouch.isBaublePouch(ev.getItemInHand())) { //Do not allow bauble pouches to be built. + ev.setCancelled(true); + return; + } } @EventHandler(priority=EventPriority.LOWEST,ignoreCancelled = true) @@ -4384,6 +4408,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } } + if (BaublePouch.isBaublePouch(ev.getCurrentItem())) { + //Modify the Bauble Pouch # line to the next bauble pouch ID. + if (ev.isShiftClick()) { + ev.setCancelled(true); + } else { + ItemUtils.ModifyLoreLineContainingSubstring(ev.getCurrentItem(), BaublePouch.POUCHID_LINE, BaublePouch.POUCHID_LINE+BAUBLEPOUCHID); + BaublePouch.createNewBaublePouch(BAUBLEPOUCHID); + BAUBLEPOUCHID++; + } + } } @@ -4547,7 +4581,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (pd.last_rejuvenate+GenericFunctions.GetModifiedCooldown(TwosideKeeper.REJUVENATE_COOLDOWN,ev.getPlayer())<=TwosideKeeper.getServerTickTime() && PlayerMode.isDefender(ev.getPlayer())) { GenericFunctions.PerformRejuvenate(ev.getPlayer()); pd.last_rejuvenate = TwosideKeeper.getServerTickTime(); - aPlugin.API.damageItem(ev.getPlayer(), ev.getItemDrop().getItemStack(), 400); + aPlugin.API.damageItem(ev.getPlayer().getInventory(), ev.getItemDrop().getItemStack(), 400); } ev.getPlayer().getEquipment().setItemInMainHand(new ItemStack(Material.AIR)); } @@ -4888,6 +4922,36 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } + //Check for a right-click for a Bauble Pouch. + if (ev.getClick()==ClickType.RIGHT && ((ev.getInventory().getType()!=InventoryType.WORKBENCH && ev.getRawSlot()>=0) || + (ev.getInventory().getType()==InventoryType.WORKBENCH && ev.getRawSlot()>9))) { + ItemStack item = ev.getCurrentItem(); + if (BaublePouch.isBaublePouch(item)) { + BaublePouch.openBaublePouch((Player)ev.getWhoClicked(), item); + ev.setCancelled(true); + return; + } + } + //Check for a left-click for a Bauble Pouch. + if (ev.getClick()==ClickType.LEFT && ItemUtils.isValidItem(ev.getCursor())) { + //Attempt to insert the items into the Bauble Pouch. + ItemStack item = ev.getCurrentItem(); + if (BaublePouch.isBaublePouch(item)) { + HashMap remaining = BaublePouch.insertItemsIntoBaublePouch(BaublePouch.getBaublePouchID(item), ev.getCursor()); + if (remaining.size()>0) { + for (Integer numb : remaining.keySet()) { + ItemStack extra = remaining.get(numb); + ev.setCursor(extra); + } + } else { + ev.setCursor(new ItemStack(Material.AIR)); + } + ((Player)ev.getWhoClicked()).updateInventory(); + ev.setCancelled(true); + return; + } + } + if ((ev.getClick()==ClickType.SHIFT_LEFT || ev.getClick()==ClickType.SHIFT_RIGHT) && ev.getInventory().getType()==InventoryType.CRAFTING && ev.getWhoClicked().getInventory().getExtraContents()[0]==null && GenericFunctions.AllowedToBeEquippedToOffHand((Player)ev.getWhoClicked(),ev.getCurrentItem(),ev.getRawSlot()) && @@ -5692,6 +5756,32 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } } + + //TODO Nerf Durability + @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) + public void dodgeEvent(PlayerDodgeEvent ev) { + Player p = ev.getPlayer(); + PlayerMode pm = PlayerMode.getPlayerMode(p); + if (!pm.isRanger(p)) { + if (p.isBlocking() || pm.isDefender(p)) { + //Only reduce durability of the shield. + ItemStack[] equips = GenericFunctions.getEquipment(p, true); + if (GenericFunctions.isEquip(equips[0])) { + aPlugin.API.damageItem(p.getInventory(), equips[0], 3+((int)((equips[0].getType().getMaxDurability()*0.01)+1))); + } + if (GenericFunctions.isEquip(equips[1])) { + aPlugin.API.damageItem(p.getInventory(), equips[0], 3+((int)((equips[0].getType().getMaxDurability()*0.01)+1))); + } + } else { + ItemStack[] equips = GenericFunctions.getArmor(p, false); + for (ItemStack equip : equips) { + if (GenericFunctions.isEquip(equip)) { + aPlugin.API.damageItem(p.getInventory(), equip, 3+((int)((equip.getType().getMaxDurability()*0.01)+1))); + } + } + } + } + } @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) public void updateHealthbarDamageEvent(EntityDamageEvent ev) { @@ -5861,7 +5951,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { dmgdealt=0.25; } else if (PlayerMode.isSlayer((Player)ev.getEntity()) && - ItemSet.GetSetCount(GenericFunctions.getHotbarItems((Player)ev.getEntity()), ItemSet.LORASYS, (Player)ev.getEntity())>0) { + ItemSet.GetSetCount(GenericFunctions.getEquipment((Player)ev.getEntity()), ItemSet.LORASYS, (Player)ev.getEntity())>0) { dmgdealt=0.0; } } @@ -6146,10 +6236,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (amt>500) { testamt=500; } - ev.setAmount((int)(ev.getAmount()+(ev.getAmount()*(ItemSet.GetTotalBaseAmount(GenericFunctions.getHotbarItems(ev.getPlayer()), ev.getPlayer(), ItemSet.ALUSTINE)/100d)))); + ev.setAmount((int)(ev.getAmount()+(ev.getAmount()*(ItemSet.GetTotalBaseAmount(GenericFunctions.getBaubles(ev.getPlayer()), ev.getPlayer(), ItemSet.ALUSTINE)/100d)))); - if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(p), p, ItemSet.ALUSTINE, 5)) { - if (Math.random()<=Math.min((ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getHotbarItems(p), p, ItemSet.ALUSTINE, 5, 4)/20d),1)) { + if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.ALUSTINE, 5)) { + if (Math.random()<=Math.min((ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.ALUSTINE, 5, 4)/20d),1)) { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) { if (pd.slayermodehp+2 mobs = GenericFunctions.getNearbyMobs(m.getLocation(), 8); List mobs = CustomDamage.trimNonMonsterEntities(m.getNearbyEntities(8, 8, 8)); @@ -6501,13 +6591,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } else { GenericFunctions.addStackingPotionEffect(p, PotionEffectType.INCREASE_DAMAGE, 10*20, 9); } - if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(p), p, ItemSet.GLADOMAIN, 7)) { + if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.GLADOMAIN, 7)) { pd.slayermegahit=true; } GenericFunctions.applyStealth(p, false); } else { //Failed Assassination. - if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(p), p, ItemSet.WOLFSBANE, 2)) { - pd.lastassassinatetime-=GenericFunctions.GetModifiedCooldown(TwosideKeeper.ASSASSINATE_COOLDOWN,p)*(ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getHotbarItems(p), p, ItemSet.WOLFSBANE, 2, 2)/100d); + if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.WOLFSBANE, 2)) { + pd.lastassassinatetime-=GenericFunctions.GetModifiedCooldown(TwosideKeeper.ASSASSINATE_COOLDOWN,p)*(ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.WOLFSBANE, 2, 2)/100d); ItemStack[] inv = p.getInventory().getContents(); for (int i=0;i<9;i++) { if (inv[i]!=null && (inv[i].getType()!=Material.SKULL_ITEM || pd.lastlifesavertime+GenericFunctions.GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN,p)0)?4:2; + int restore_amt = (ItemSet.GetSetCount(GenericFunctions.getEquipment(p), ItemSet.LORASYS, p)>0)?4:2; if (pd.slayermodehp+restore_amt