diff --git a/src/plugin.yml b/src/plugin.yml index 9fb6592..bca24ed 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper -version: 3.4.7e +version: 3.5.0 commands: money: description: Tells the player the amount of money they are holding. @@ -76,4 +76,9 @@ commands: description: Display statistics for damage and defense. usage: /stats [username] permission: TwosideKeeper.money + permission-message: No permissions! + awakenedartifact: + description: Used for upgrading awakened artifacts. + usage: /awakenedartifact + permission: TwosideKeeper.money permission-message: No permissions! \ No newline at end of file diff --git a/src/sig/plugin/TwosideKeeper/Artifact.java b/src/sig/plugin/TwosideKeeper/Artifact.java index 720c383..43aa16d 100644 --- a/src/sig/plugin/TwosideKeeper/Artifact.java +++ b/src/sig/plugin/TwosideKeeper/Artifact.java @@ -126,6 +126,7 @@ public class Artifact { } public static ItemStack convert(ItemStack item, ArtifactItem type, boolean reprint_lore) { //Converts an item to an artifact. + item = item.clone(); ItemMeta m = item.getItemMeta(); List l = new ArrayList(); if (item.getItemMeta().hasLore()) { @@ -272,6 +273,9 @@ public class Artifact { } else if (type.toString().contains("BOOTS")) { return "BOOTS"; + } else + if (type.toString().contains("ROD")) { + return "FISHING ROD"; } else { return ""; } diff --git a/src/sig/plugin/TwosideKeeper/AwakenedArtifact.java b/src/sig/plugin/TwosideKeeper/AwakenedArtifact.java index 1512f34..6f41b4e 100644 --- a/src/sig/plugin/TwosideKeeper/AwakenedArtifact.java +++ b/src/sig/plugin/TwosideKeeper/AwakenedArtifact.java @@ -2,6 +2,7 @@ package sig.plugin.TwosideKeeper; import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import org.bukkit.ChatColor; @@ -11,15 +12,21 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; +import sig.plugin.TwosideKeeper.HelperStructures.ArtifactAbility; import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItemType; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; public class AwakenedArtifact { int experience_points=0; + public static HashMap ability_map = new HashMap(); + public static HashMap name_map = new HashMap(); private static String drawEXPMeter(int exp) { String bar =""; - for (int i=0;i=50) { @@ -67,13 +74,24 @@ public class AwakenedArtifact { int totalval = getEXP(artifact)+amt; if (totalval>1000) { //LEVEL UP! - ItemStack item = addLV(artifact,totalval/1000, p); - item = setEXP(item,totalval%1000); - item = addAP(item,1); - p.sendMessage("Your "+artifact.getItemMeta().getDisplayName()+ChatColor.RESET+" has upgraded to "+ChatColor.YELLOW+"Level "+getLV(artifact)+"!"); - p.sendMessage("You have "+getAP(item)+" Ability Points to spend!"); - p.spigot().sendMessage(new TextComponent("Test")); - return item; + if (getLV(artifact)<999) { + ItemStack item = addLV(artifact,totalval/1000, p); + item = setEXP(item,totalval%1000); + item = addAP(item,1); + p.sendMessage("Your "+artifact.getItemMeta().getDisplayName()+ChatColor.RESET+" has upgraded to "+ChatColor.YELLOW+"Level "+getLV(artifact)+"!"); + p.sendMessage("You have "+getAP(item)+" Ability Point"+((getAP(item)==1)?"":"s")+" to spend!"); + + TextComponent tc = new TextComponent("Click "); + TextComponent ac = new TextComponent(ChatColor.GREEN+"[HERE]"+ChatColor.WHITE); + ac.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder(ChatColor.ITALIC+"Click to add another skill point!").create())); + ac.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/awakenedartifact")); + tc.addExtra(ac); + tc.addExtra(" to open up the ability upgrade menu."); + p.spigot().sendMessage(tc); + return item; + } else { + return artifact; + } } else { return setEXP(artifact,totalval); } @@ -150,19 +168,23 @@ public class AwakenedArtifact { } public static ItemStack addPotentialEXP(ItemStack artifact,int exp,Player p) { //Adds experience, but only based on the potential of the item. - int missingdurability = artifact.getDurability(); - if (missingdurability!=0) { - double mult = Math.min(10d/missingdurability, 1); - //Multiply the value. If it's less than 1, there is only a chance exp will be added. - double expadded = exp*mult; - if (expadded<1 && - Math.random()<=expadded) { - return addEXP(artifact,1,p); + if (GenericFunctions.isArtifactEquip(artifact)) { + int missingdurability = artifact.getDurability(); + if (missingdurability!=0) { + double mult = Math.min(10d/missingdurability, 1); + //Multiply the value. If it's less than 1, there is only a chance exp will be added. + double expadded = exp*mult; + if (expadded<1 && + Math.random()<=expadded) { + return addEXP(artifact,1,p); + } else { + return addEXP(artifact,(int)expadded,p); + } } else { - return addEXP(artifact,(int)expadded,p); + return addEXP(artifact,exp,p); } } else { - return addEXP(artifact,exp,p); + return artifact; } } public static String drawPotential(ItemStack artifact) { @@ -191,7 +213,8 @@ public class AwakenedArtifact { } public static ItemStack convertToAwakenedArtifact(ItemStack artifact, int tier, int dataval) { ItemStack item = artifact.clone(); - item = Artifact.convert(item,true); + TwosideKeeper.log("Trying to create data "+dataval, 5); + item = Artifact.convert(item,false); GenericFunctions.addObscureHardenedItemBreaks(item, 5); ItemMeta m = item.getItemMeta(); m.setDisplayName(ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+" "+GenericFunctions.CapitalizeFirstLetters(ArtifactItemType.getTypeFromData(dataval).getItemName())+" Artifact"); @@ -205,7 +228,8 @@ public class AwakenedArtifact { lore.add(ChatColor.BLUE+" (0/1000) "+"Potential: "+drawPotential(artifact)); df = new DecimalFormat("000"); lore.add(ChatColor.GRAY+"Level "+df.format(0)); - lore.add(ChatColor.GOLD+"Ability Points: 0/0"); + lore.add(ChatColor.GOLD+"Ability Points: 0/0"); + //AP is on line 7 (element 6) m.setLore(lore); item.setItemMeta(m); item.addUnsafeEnchantment(Enchantment.LUCK, tier); diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java index 12ea5e3..057aae8 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java @@ -1,8 +1,24 @@ package sig.plugin.TwosideKeeper.HelperStructures; import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.lang.WordUtils; import org.bukkit.ChatColor; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import sig.plugin.TwosideKeeper.AwakenedArtifact; +import sig.plugin.TwosideKeeper.TwosideKeeper; +import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; public enum ArtifactAbility { //Enum Structure: @@ -10,59 +26,422 @@ public enum ArtifactAbility { //Temporary abilities: Work for 1 level and wear off afterward. //Weapon Abilities - DAMAGE("Strike","Improves Base Damage by [VAL]",1.0,1.0,100), - ARMOR_PEN("Piercing","[VAL]% of your damage is ignored by resistances. ([PENDMG] damage)",1.0,1.0,100,1), - EXECUTION("Execute","Deals [VAL] extra damage for every 20% of target's missing health.",2.0,1.0,100,1), - LIFESTEAL("Lifesteal","Heals [VAL]% of the damage dealt to targets back to your health pool.",1.0,1.0,100,1), + DAMAGE("Strike","Improves Base Damage by [VAL]",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1), + ARMOR_PEN("Piercing","[VAL]% of your damage is ignored by resistances. ([PENDMG] damage)",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1), + EXECUTION("Execute","Deals [VAL] extra damage for every 20% of target's missing health.",new double[]{2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1), + LIFESTEAL("Lifesteal","Heals [VAL]% of the damage dealt to targets back to your health pool.",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1), + CRITICAL("Critical","[VAL]% chance to deal double damage.",new double[]{2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1), + CRIT_DMG("Crit Damage","Critical Strikes deal [VAL]% damage.",new double[]{210.0,210.0,210.0,210.0,210.0,210.0,210.0,210.0,210.0,210.0}, + new double[]{5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0},100,1), + PROVOKE("Provoke","Your attacks provoke enemies for [VAL] seconds.",new double[]{3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,10), + HIGHWINDER("Highwinder","While moving, you deal [VAL] extra damage for every 1m of speed.",new double[]{0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5}, + new double[]{0.7,0.7,0.7,0.7,0.7,0.7,0.7,0.7,0.7,0.7},100,15), + COMBO("Belligerent","[VAL]% more damage for each successive strike on a mob. Resets on a failed swing or after 5 seconds of no combat.",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,30), + + //Bow Abilities + MARKSMAN("Marksman","Increases headshot hitbox size by [VAL]% .",new double[]{8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0}, + new double[]{0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8},100,1), + SIEGESTANCE("Siege Stance","Activate by Sneaking for three seconds. Sneak again to de-activate.\n\n" + + "Applies Slowness V and Resistance VI. While in Siege Stance you fire clusters of 7 arrows per shot. Each arrow deals [VAL] damage.",new double[]{3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,20), + ARROWSHOWER("Arrow Shower","Shift-Left Click to activate. Applies Slowness X for three seconds while firing arrows into the sky and onto enemies in a large area in front of you. Each arrow deals [VAL] damage.",new double[]{0.7,0.7,0.7,0.7,0.7,0.7,0.7,0.7,0.7,0.7}, + new double[]{0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4},100,40), + TARGETING("Targeting","Left-click a mob to target them. Fire arrows to release homing missiles at your target. Each missile explodes and deals [VAL] damage.",new double[]{10,10,10,10,10,10,10,10,10,10}, + new double[]{0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3},100,75), + ENDERTURRET("Ender Turret","Place Eyes of Ender in your hotbar to use as ammo. Each eye fired launches forward and upward before releasing a barrage of homing missiles that lock onto enemy targets. Each missile explodes and deals [VAL] damage.",new double[]{25,25,25,25,25,25,25,25,25,25}, + new double[]{0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5},100,100), //Armor abilities - DAMAGE_REDUCTION("Defense","Increases Base Damage reduction by [VAL]%",1.0,2.0,100,1), - HEALTH("Health","Increases Maximum Health by [VAL].",1.0,1.0,100,1), - HEALTH_REGEN("Regeneration","Regenerates an extra [VAL] health every 5 seconds.",0.5,1.0,100,1), - STATUS_EFFECT_RESISTANCE("Resistance","When a debuff is applied",0.5,1.0,100,1), - SURVIVOR("Survivor","Taking fatal damage will not kill you and instead consume this ability, removes all debuffs, and leaving you with 1 HP.",-1,0,1,10), + DAMAGE_REDUCTION("Defense","Increases Base Damage reduction by [VAL]%",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, + new double[]{2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0},100,1), + HEALTH("Health","Increases Maximum Health by [VAL].",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1), + HEALTH_REGEN("Regeneration","Regenerates an extra [VAL] health every 5 seconds.",new double[]{0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1), + STATUS_EFFECT_RESISTANCE("Resistance","When a debuff is applied, there is a [VAL]% chance to remove it.",new double[]{20,20,20,20,20,20,20,20,20,20}, + new double[]{4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0},100,1), + SHADOWWALKER("Shadow Walker","Increases your speed in dark areas. Damage Reduction increases by [VAL]% in dark areas. Dodge chance increases by [DODGEVAL]% in dark areas.",new double[]{5,5,5,5,5,5,5,5,5,5}, + new double[]{1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5},100,5), + SURVIVOR("Survivor","Taking fatal damage will not kill you and instead consume this ability, removes all debuffs, and leaving you with 1 HP.",new double[]{-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0}, + new double[]{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},1,10), + DODGE("Dodge","You have a [VAL]% chance to dodge incoming damage from any damage source.",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, + new double[]{3,3,3,3,3,3,3,3,3,3},100,20), + GRACEFULDODGE("Graceful Dodge","You have a [VAL]% chance to dodge incoming damage from attacks that deal [FATALDMG] or more damage.",new double[]{10,10,10,10,10,10,10,10,10,10}, + new double[]{0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8},100,45), + + //Pickaxe abilities + SCAVENGE("Scavenge","Breaks off resources from armor. [VAL]% chance per hit.",new double[]{5,5,5,5,5,5,5,5,5,5}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,20), + + //Shovel abilities + SUPPRESS("Suppression","Suppresses a mob on hit for [VAL] seconds.\n\n" + + "Suppression prevents movement, attacking, and teleportation.",new double[]{0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,10), + + //Axe abilities + BREAKDOWN("Break Down","Breaks down armor on mobs. Each hit has a [VAL]% chance to remove a piece of armor from a mob.",new double[]{3,3,3,3,3,3,3,3,3,3}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1), + BUTCHERY("Butchery","Broken down armor have a [VAL]% chance to drop onto the ground.",new double[]{10,10,10,10,10,10,10,10,10,10}, + new double[]{0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8},100,5), + + //Scythe abilities + DEATHMARK("Death Mark","Applies a Death Mark stack to a target. Death marks last for 5 seconds, and refresh on each hit.\n\nMarks can be detonated at any time by right-clicking. Each death mark stack applied deals [VAL] damage.",new double[]{0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1}, + new double[]{0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6},100,10), + AOE("Area of Effect","Deals damage to targets up to [VAL]m from the main target hit.",new double[]{0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1), + + //General abilities + GREED("Greed","Increases Drop rate by [VAL]% . Health is halved, health regeneration is halved, and damage reduction is halved. Consumes one level of Greed per level up.",new double[]{50,50,50,50,50,50,50,50,50,50}, + new double[]{2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0},100,10), + GROWTH("Growth","Increases artifact EXP gained by [VAL]% . Health is halved, health regeneration is halved, and damage reduction is halved. Consumes one level of Growth per level up.",new double[]{100,100,100,100,100,100,100,100,100,100}, + new double[]{2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0},100,10), + REMOVE_CURSE("Remove Curse","Removes a level of a curse from the Artifact.",new double[]{-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0}, + new double[]{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},1,1), + PRESERVATION("Preservation","Potential decays [VAL]% slower.",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, + new double[]{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},1,20), + EXP_MULT("Mega XP","Increases experience dropped from monsters by [VAL]% .",new double[]{5,5,5,5,5,5,5,5,5,5}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,20), + + //Bad stuff + REDUCEDMG("Weakness","[VAL]% Decrease in Base Damage.",new double[]{8,8,8,8,8,8,8,8,8,8}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,3), + REDUCEDEF("Imperil","[VAL]% Decrease in Damage Reduction",new double[]{8,8,8,8,8,8,8,8,8,8}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,5), + LIFE_REDUCTION("Health Cut","[VAL]% decrease in maximum health.",new double[]{30,30,30,30,30,30,30,30,30,30}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,5), + LOWER_DEFENSE("Debilitate","[VAL]% decrease in damage reduction.",new double[]{30,30,30,30,30,30,30,30,30,30}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,5), + TELEPORT("Teleport","[VAL]% chance to teleport the player to a random location on artifact experience gain.",new double[]{3,3,3,3,3,3,3,3,3,3}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,10), + DRAINING("Draining","[VAL]% chance to remove a level of experience on artifact experience gain.",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,10), + NOREGEN("Weary","No health regenerates.",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,15), + STARVATION("Starvation","[VAL]% chance to cause [HUNGERVAL] seconds of Hunger on experience gain.",new double[]{5,5,5,5,5,5,5,5,5,5}, + new double[]{0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1},100,15), + BURN("Flammable","All burn damage deals x[VAL] damage.",new double[]{4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,25), + FROZEN("Frozen","Player will be inflicted with increasing levels of slowness and fatigue until finally frozen and killed.",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},1,45), + PETRIFICATION("Petrification","Player will be inflicted with increasing levels of slowness and fatigue until finally petrified and killed.",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},1,45), ; + static int LINE_SIZE=50; String name; String desc; - double baseval; - double decayval; + double[] baseval; + double[] decayval; int maxlv; + int requirement; - ArtifactAbility(String name, String desc, double baseval, double decayval, int maxlv) { + ArtifactAbility(String name, String desc, double[] baseval, double[] decayval, int maxlv, int requirement) { this.name=name; this.desc=desc; this.baseval=baseval; this.decayval=decayval; this.maxlv=maxlv; + this.requirement=requirement; + AwakenedArtifact.ability_map.put(this,this.name); + AwakenedArtifact.name_map.put(this.name,this); } - public double calculateValue(int lv) { + public String GetName() { + return this.name; + } + + public String GetDescription() { + return this.desc; + } + + public double GetBaseValue(int tier) { + return this.baseval[tier-1]; + } + + public double GetDecayValue(int tier) { + return this.decayval[tier-1]; + } + + public int GetMaxLevel() { + return maxlv; + } + + public int GetMinLevel() { + return requirement; + } + + + + public static double calculateValue(ArtifactAbility ability, int artifacttier, int abilitylevel) { double sum=0; - for(int i=0;i getEnchantments(ItemStack item) { + HashMap abilities = new HashMap(); + if (GenericFunctions.isArtifactEquip(item)) { + List lore = item.getItemMeta().getLore(); + //From Element 7 and onwards, we know these are abilities added to the item. Retrieve them. + for (int i=7;i lore = m.getLore(); + if (containsEnchantment(ability,item)) { + //We just need to find the line and upgrade it then. + for (int i=0;i map = getEnchantments(item); + if (map.containsKey(REDUCEDMG) || + map.containsKey(REDUCEDEF) || + map.containsKey(LIFE_REDUCTION) || + map.containsKey(LOWER_DEFENSE) || + map.containsKey(TELEPORT) || + map.containsKey(DRAINING) || + map.containsKey(NOREGEN) || + map.containsKey(STARVATION) || + map.containsKey(BURN) || + map.containsKey(FROZEN) || + map.containsKey(PETRIFICATION)) { + return true; + } else { + return false; + } + } + + static boolean containsEnchantment(ArtifactAbility ability, ItemStack item) { + return getEnchantments(item).containsKey(ability); + } + + public static ItemStack upgradeEnchantment(Player p, ItemStack item, ArtifactAbility ability) { + //Verifies that the enchantment can be upgraded firstly. + //Get the level we are upgrading to. + int level = getEnchantmentLevel(ability,item); + if (AwakenedArtifact.getAP(item)>0) { + if (ability.GetMaxLevel()>level && ability.GetMinLevel()<=AwakenedArtifact.getLV(item)) { + //This is allowed. Proceed. + item = applyEnchantment(ability,level+1,item); + AwakenedArtifact.addAP(item, -1); + p.sendMessage(ChatColor.AQUA+"Successfully applied "+ChatColor.BLUE+ability.GetName()+" "+(level+1)+ChatColor.AQUA+" to your artifact!"); + int apamt = AwakenedArtifact.getAP(item); + if (apamt>0) { + TextComponent tc = new TextComponent(" You have "+ChatColor.GREEN+apamt+ChatColor.WHITE+" ability point"+((apamt==1)?"":"s")+" remaining! Click "); + TextComponent ac = new TextComponent(ChatColor.GREEN+"[HERE]"+ChatColor.WHITE); + ac.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder(ChatColor.ITALIC+"Click to add another skill point!").create())); + ac.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/awakenedartifact")); + tc.addExtra(ac); + tc.addExtra(" to open up the ability upgrade menu."); + p.spigot().sendMessage(tc); + } + } else { + if (ability.GetMaxLevel()<=level) { + p.sendMessage(ChatColor.RED+"This ability cannot be upgraded any further!"); + } else { + p.sendMessage(ChatColor.RED+"You need to reach level "+ability.GetMinLevel()+" on your artifact item first!"); + } + } + } else { + p.sendMessage(ChatColor.RED+"Insufficient AP to level up this upgrade! Earn more AP first!"); + } + return item; + } + + public static TextComponent DisplayAbility(ArtifactAbility ability, double playerdmgval, ItemStack targetitem, int slot) { + boolean unlocked=true; + String lockedreason = ""; + if (AwakenedArtifact.getLV(targetitem)=ability.GetMaxLevel()) { + unlocked=false; + if (AwakenedArtifact.getLV(targetitem)=ability.GetMaxLevel()) { + lockedreason=ChatColor.GRAY+""+ChatColor.ITALIC+"Your Artifact has reached the maximum level for this ability!"; + } + } + int enchantlevel=0; + if (containsEnchantment(ability,targetitem)) { + enchantlevel=getEnchantmentLevel(ability,targetitem); + } + String displaystring = ""; + if (enchantlevel>0) { + displaystring = displayDescriptionUpgrade(ability,targetitem.getEnchantmentLevel(Enchantment.LUCK),enchantlevel,enchantlevel+1,playerdmgval); + } else { + displaystring = displayDescription(ability,targetitem.getEnchantmentLevel(Enchantment.LUCK),enchantlevel+1,playerdmgval); + } + TextComponent tc = new TextComponent(((unlocked)?ChatColor.GREEN:ChatColor.RED)+"["+ability.GetName()+" "+(enchantlevel+1)+"] "); + tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder(WordUtils.wrap(ChatColor.BLUE+ability.GetName()+"\n\n"+displaystring+((lockedreason.equalsIgnoreCase(""))?"":"\n\n"),LINE_SIZE,"\n",true)+WordUtils.wrap(lockedreason,LINE_SIZE,"\n"+net.md_5.bungee.api.ChatColor.GRAY,true)).create())); + if (slot!=0) { + //Apply the enchantment to the proper item slot. + tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/awakenedartifact levelup "+ability.name()+" "+slot)); + } else { + tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/awakenedartifact levelup "+ability.name())); + } + if (getEnchantmentLevel(ability,targetitem) getPartyMembers(Player p) { + //Find the party this player is in. + Party part = null; + for (int i=0;i PartyList = new ArrayList(); + public static List PartyList = new ArrayList(); public List colors_used = new ArrayList(); public List chargezombies = new ArrayList(); @@ -250,7 +252,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(); + sig.plugin.TwosideKeeper.Recipes.Initialize_Artifact_Recipes(); sig.plugin.TwosideKeeper.Recipes.Initialize_ArtifactHelper_Recipes(); sig.plugin.TwosideKeeper.Recipes.Initialize_Check_Recipe(); @@ -313,6 +315,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { playerdata.put(((Player)Bukkit.getOnlinePlayers().toArray()[i]).getUniqueId(), new PlayerStructure((Player)Bukkit.getOnlinePlayers().toArray()[i],getServerTickTime())); //playerdata.add(new PlayerStructure((Player)Bukkit.getOnlinePlayers().toArray()[i],getServerTickTime())); } + Player p; //Announce the server has restarted soon after. if (SERVER_TYPE!=ServerType.QUIET) { @@ -606,16 +609,17 @@ public class TwosideKeeper extends JavaPlugin implements Listener { DecimalFormat df = new DecimalFormat("0.00"); if (cmd.getName().equalsIgnoreCase("fix")) { Player p = (Player)sender; - //p.sendMessage(p.getEquipment().getItemInMainHand().toString()); - //sender.sendMessage("Localized Name is "+GenericFunctions.UserFriendlyMaterialName(p.getEquipment().getItemInMainHand().getType(),p.getEquipment().getItemInMainHand().getData().getData())); if (Artifact.isMalleableBase(p.getEquipment().getItemInMainHand()) && MalleableBaseQuest.getTimeStarted(p.getEquipment().getItemInMainHand())<=147337849) { p.getEquipment().setItemInMainHand(MalleableBaseQuest.setTimeStarted(p.getEquipment().getItemInMainHand(), getServerTickTime())); } - //ItemStack item = p.getEquipment().getItemInMainHand(); - //AwakenedArtifact.addPotentialEXP(item, 100, p); - //p.sendMessage(tpstracker.getTPS()+""); - //GenericFunctions.addObscureHardenedItemBreaks(p.getEquipment().getItemInMainHand(), 4); + if (SERVER_TYPE==ServerType.TEST || SERVER_TYPE==ServerType.QUIET) { + + //ItemStack item = p.getEquipment().getItemInMainHand(); + //AwakenedArtifact.addPotentialEXP(item, 100, p); + //p.sendMessage(tpstracker.getTPS()+""); + //GenericFunctions.addObscureHardenedItemBreaks(p.getEquipment().getItemInMainHand(), 4); + } return true; } else if (cmd.getName().equalsIgnoreCase("money")) { @@ -766,6 +770,27 @@ public class TwosideKeeper extends JavaPlugin implements Listener { showPlayerStats((Player)sender); return true; } + } else + if (cmd.getName().equalsIgnoreCase("awakenedartifact")) { + if (args.length==2 && args[0].equalsIgnoreCase("levelup")) { + Player p = (Player)sender; + //Argument0 is "levelup" + //Argument1 is the enum of the ability. + //See if we can level this item up! + //Upgrade! + ArtifactAbility.upgradeEnchantment(p,p.getEquipment().getItemInMainHand(),ArtifactAbility.valueOf(args[1])); + } else + if (args.length==3 && args[0].equalsIgnoreCase("levelup")) { + //argument2 is the equip slot to apply it to. + Player p = (Player)sender; + ArtifactAbility.upgradeEnchantment(p,p.getInventory().getItem(Integer.parseInt(args[2])),ArtifactAbility.valueOf(args[1])); + } else { + //Display the generic levelup message. + Player p = Bukkit.getPlayer(sender.getName()); + p.sendMessage("");p.sendMessage(""); + p.spigot().sendMessage(ArtifactAbility.GenerateMenu(ArtifactItemType.getArtifactItemTypeFromItemStack(p.getEquipment().getItemInMainHand()).getUpgradePath(), CalculateDamageReduction(1,p,p), p.getEquipment().getItemInMainHand())); + } + return true; } } else { //Implement console/admin version later (Let's you check any name's money.) @@ -914,6 +939,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (thisp.getLevel()>=value) { //Take that amount of exp away from the player. Give them money in return. int startlv = thisp.getLevel(); + double amtgained=0; for (int i=startlv;i>=startlv-value;i--) { switch (i) { case 0: @@ -934,7 +960,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { case 15: case 16: { - givePlayerMoney(thisp,(2*i+7)*XP_CONVERSION_RATE); + amtgained = (2*i+7)*XP_CONVERSION_RATE; + givePlayerMoney(thisp,amtgained); }break; case 17: case 18: @@ -952,15 +979,17 @@ public class TwosideKeeper extends JavaPlugin implements Listener { case 30: case 31: { - givePlayerMoney(thisp,(5*i-38)*XP_CONVERSION_RATE); + amtgained = (5*i-38)*XP_CONVERSION_RATE; + givePlayerMoney(thisp,amtgained); }break; default:{ - givePlayerMoney(thisp,(9*i-158)*XP_CONVERSION_RATE); + amtgained = (9*i-158)*XP_CONVERSION_RATE; + givePlayerMoney(thisp,amtgained); } } } thisp.setLevel(thisp.getLevel()-value); - ev.getPlayer().sendMessage(ChatColor.GOLD+"CONVERSION COMPLETE!"); + ev.getPlayer().sendMessage(ChatColor.GOLD+"CONVERSION COMPLETE!"+ChatColor.WHITE+" Converted "+value+" levels of experience into "+ChatColor.YELLOW+"$"+df.format(amtgained)+ChatColor.WHITE+"."); ev.getPlayer().sendMessage(" Now Holding: "+ChatColor.BLUE+"$"+df.format(getPlayerMoney(ev.getPlayer()))); } else { thisp.sendMessage(ChatColor.RED+"You do not have that many levels. You can convert as many as "+ChatColor.WHITE+thisp.getLevel()+ChatColor.RED+" levels."); @@ -1600,11 +1629,15 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Location oldBedPos = ev.getPlayer().getBedSpawnLocation(); log(ev.getPlayer()+" Right-clicked bed. Set bed spawn to "+BedPos.toString(),3); ev.getPlayer().setBedSpawnLocation(BedPos); - log(oldBedPos.toString()+"::"+ev.getPlayer().getBedSpawnLocation().toString(),5); - if (oldBedPos.getBlockX()!=ev.getPlayer().getBedSpawnLocation().getBlockX() || - oldBedPos.getBlockY()!=ev.getPlayer().getBedSpawnLocation().getBlockY() || - oldBedPos.getBlockZ()!=ev.getPlayer().getBedSpawnLocation().getBlockZ()) - ev.getPlayer().sendMessage(ChatColor.BLUE+""+ChatColor.ITALIC+"New bed respawn location set."); + if (ev.getPlayer().getBedSpawnLocation()!=null) { + log(oldBedPos.toString()+"::"+ev.getPlayer().getBedSpawnLocation().toString(),5); + if (oldBedPos.getBlockX()!=ev.getPlayer().getBedSpawnLocation().getBlockX() || + oldBedPos.getBlockY()!=ev.getPlayer().getBedSpawnLocation().getBlockY() || + oldBedPos.getBlockZ()!=ev.getPlayer().getBedSpawnLocation().getBlockZ()) + ev.getPlayer().sendMessage(ChatColor.BLUE+""+ChatColor.ITALIC+"New bed respawn location set."); + } else { + ev.getPlayer().sendMessage(ChatColor.BLUE+""+ChatColor.ITALIC+"New bed respawn location set."); + } } if (ev.getAction()==Action.RIGHT_CLICK_BLOCK && ev.getClickedBlock().getType().toString().contains("RAIL") && @@ -2343,7 +2376,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { @EventHandler(priority=EventPriority.LOW) public void onInventoryClick(InventoryClickEvent ev) { final Player player = (Player)ev.getWhoClicked(); - log("Raw Slot Clicked: "+ev.getRawSlot(),5); + log("Raw Slot Clicked: "+ev.getRawSlot(),5); //5,6,7,8 for gear slots. Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { @Override public void run() { @@ -2856,9 +2889,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public void MonsterSpawnEvent(CreatureSpawnEvent ev) { if ((ev.getSpawnReason().equals(SpawnReason.NATURAL) || ev.getSpawnReason().equals(SpawnReason.SPAWNER_EGG) || - ev.getSpawnReason().equals(SpawnReason.REINFORCEMENTS)) && + ev.getSpawnReason().equals(SpawnReason.REINFORCEMENTS) || + ev.getSpawnReason().equals(SpawnReason.VILLAGE_INVASION)) && ev.getEntity() instanceof Monster) { - if (ev.getSpawnReason().equals(SpawnReason.REINFORCEMENTS)) { + if (ev.getSpawnReason().equals(SpawnReason.REINFORCEMENTS) || ev.getSpawnReason().equals(SpawnReason.VILLAGE_INVASION)) { //Remove this one and spawn another one. Location loc = ev.getEntity().getLocation().clone(); Monster m = (Monster)loc.getWorld().spawnEntity(loc, EntityType.ZOMBIE); @@ -3594,6 +3628,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { TwosideSpleefGames.PassEvent(ev); Player p = ev.getPlayer(); + TwosideKeeperAPI.addArtifactEXP(p.getEquipment().getItemInMainHand(), 100, p); if (p!=null) { log(p.getName()+" has broken block "+GenericFunctions.UserFriendlyMaterialName(new ItemStack(ev.getBlock().getType())),3); } @@ -4048,6 +4083,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.getInventory().getItem(i).getType()!=Material.AIR && Artifact.isArtifact(ev.getInventory().getItem(i))) { items_found++; + TwosideKeeper.log("Items Found: "+items_found, 5); if (ev.getInventory().getItem(i).getType()==Material.PUMPKIN_SEEDS) { //We are not supposed to be in here! pumpkin_seeds=true; @@ -4085,11 +4121,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (ev.getInventory().getItem(i)!=null && ev.getInventory().getItem(i).getType()!=Material.AIR && !Artifact.isArtifact(ev.getInventory().getItem(i))) { - log("One of these is not an artifact",2); + log("One of these is not an artifact",5); ev.getInventory().setResult(new ItemStack(Material.AIR)); //Don't allow it, an item is not an artifact! } } - if (items_found==1 && slot_found!=0 && ev.getInventory().getResult().getType()!=null && ev.getInventory().getResult().getType()!=Material.AIR) { + if (items_found==1 && ev.getInventory().getResult().getType()!=null && ev.getInventory().getResult().getType()!=Material.AIR) { //This is a recipe->Base item conversion. ItemStack newitem = ArtifactItemType.getTypeFromData(ev.getInventory().getItem(slot_found).getDurability()).getTieredItem(tier_found); @@ -4111,12 +4147,34 @@ public class TwosideKeeper extends JavaPlugin implements Listener { m.setLore(transferlore); newartifact.setItemMeta(m); //Lines can all be transferred over. No lines need to be preserved. + + //Transfer over all old enchantments. Don't transfer enchantments weaker than current enchantments. + ItemStack resultitem = ev.getInventory().getResult().clone(); + for (int i=0;inewartifact.getEnchantmentLevel(e)) { + log("Contains "+e.toString()+" "+newartifact.getEnchantmentLevel(e), 2); + //These are the enchantments that clash. If the resultitem ones are greater, apply them to the new item. + newartifact.addUnsafeEnchantment(e, artifact_item.getEnchantmentLevel(e)); + log("Applied "+e.getName()+" "+artifact_item.getEnchantmentLevel(e)+" to the artifact",2); + } + } + for (int i=0;i lore = m.getLore(); @@ -5516,6 +5575,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { store2 = CalculateWeaponDamage(p,null); } pd.damagedealt=store2; + pd.damagereduction=store1; DecimalFormat df = new DecimalFormat("0.0"); p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Base Damage: "+ChatColor.RESET+""+ChatColor.DARK_PURPLE+df.format(pd.damagedealt)); p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Damage Reduction: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format((1.0-pd.damagereduction)*100)+"%"); diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java index a5e1cc3..dce2a16 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java @@ -1,5 +1,7 @@ package sig.plugin.TwosideKeeper; +import java.util.List; + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.EntityType; @@ -112,6 +114,11 @@ public final class TwosideKeeperAPI { public static ServerType getServerType() { return TwosideKeeper.getServerType(); } + + //Party COMMANDS. + public static List getPartyMembers(Player p) { + return Party.getPartyMembers(p); + } //Combat COMMANDS. public static double getModifiedDamage(double dmg_amt, LivingEntity p) {