diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index e89d453..14dc4d4 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/plugin.yml b/src/plugin.yml index 3ecf281..81315a9 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper -version: 3.5.1a +version: 3.5.2 commands: money: description: Tells the player the amount of money they are holding. diff --git a/src/sig/plugin/TwosideKeeper/AwakenedArtifact.java b/src/sig/plugin/TwosideKeeper/AwakenedArtifact.java index adeb4af..ea913cf 100644 --- a/src/sig/plugin/TwosideKeeper/AwakenedArtifact.java +++ b/src/sig/plugin/TwosideKeeper/AwakenedArtifact.java @@ -12,6 +12,8 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import com.google.common.collect.Iterables; + import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; @@ -77,10 +79,23 @@ public class AwakenedArtifact { ItemStack item = addLV(artifact,totalval/1000, p); item = setEXP(item,totalval-1000); item = addAP(item,1); - if (getPotential(item)>10) { - item = addPotential(item,-getPotential(item)/10); + double potentialred = 10.0d; + potentialred/=1+(ArtifactAbility.calculateValue(ArtifactAbility.PRESERVATION, artifact.getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.PRESERVATION, artifact))/100d); + TwosideKeeper.log("Potential reduction is reduced by "+(10-potentialred), 2); + if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, item)) { + if (ArtifactAbility.getEnchantmentLevel(ArtifactAbility.GREED, item)>1) { + item = ArtifactAbility.applyEnchantment(ArtifactAbility.GREED, ArtifactAbility.getEnchantmentLevel(ArtifactAbility.GREED, item)-1, item); + } else { + item = ArtifactAbility.removeEnchantment(ArtifactAbility.GREED, item); + } + } + if (getPotential(item)>potentialred) { + item = addPotential(item,(int)(-getPotential(item)/potentialred)); + if (Math.random() < (potentialred % 1)) { + item = addPotential(item,1); + } } else { - if (Math.random()<=getPotential(item)/10.0d) { + if (Math.random()<=getPotential(item)/potentialred) { item = addPotential(item,-1); } } @@ -143,8 +158,8 @@ public class AwakenedArtifact { List lore = m.getLore(); DecimalFormat df = new DecimalFormat("000"); String apline = lore.get(6); - int currentAP = Integer.parseInt(((apline.split("/")[0]).split(": ")[1])); - lore.set(6, ChatColor.GOLD+"Ability Points: "+(currentAP+amt)+"/"+getLV(artifact)); + int currentAP = getAP(artifact); + lore.set(6, ChatColor.GOLD+"Ability Points: "+(currentAP)+"/"+getLV(artifact)); m.setLore(lore); artifact.setItemMeta(m); return artifact; @@ -162,7 +177,14 @@ public class AwakenedArtifact { List lore = m.getLore(); DecimalFormat df = new DecimalFormat("000"); String apline = lore.get(6); - return Integer.parseInt(((apline.split("/")[0]).split(": ")[1])); + int level = getLV(artifact); //This is how many total we have. + int apused = 0; + HashMap enchants = ArtifactAbility.getEnchantments(artifact); + for (int i=0;i lore = m.getLore(); + if (containsEnchantment(ability,item)) { + for (int i=0;i map = getEnchantments(item); if (map.containsKey(REDUCEDMG) || @@ -372,6 +395,22 @@ public enum ArtifactAbility { } return false; } + + public static ItemStack downgradeEnchantment(Player p, ItemStack item, ArtifactAbility ability) { + if (isCompatibleWithUpgrade(item,ability.upgrade)) { + if (getEnchantmentLevel(ability,item)>1) { //This is more than 1 level, so we just remove one level from it. + //This is allowed. Proceed. + item = applyEnchantment(ability,getEnchantmentLevel(ability,item)-1,item); + AwakenedArtifact.addAP(item, 1); + } else { + //Just remove it completely. + removeEnchantment(ability,item); + } + } else { + p.sendMessage(ChatColor.RED+"This upgrade is not compatible with this item!"); + } + return item; + } public static ItemStack upgradeEnchantment(Player p, ItemStack item, ArtifactAbility ability) { //Verifies that the enchantment can be upgraded firstly. @@ -516,6 +555,8 @@ public enum ArtifactAbility { text=DisplayAbility(EXECUTION,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} if (path==UpgradePath.SHOVEL) { text=DisplayAbility(SUPPRESS,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} + text=DisplayAbility(ERUPTION,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} + text=DisplayAbility(EARTHWAVE,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} } else if (path==UpgradePath.PICKAXE) { text=DisplayAbility(SCAVENGE,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} @@ -538,7 +579,8 @@ public enum ArtifactAbility { msg=msg.replace("[PENDMG]", ChatColor.BLUE+df.format(calculateValue(ability,tier,abilitylv)/100*playerdmgval)+ChatColor.RESET); //Based on multiplying [VAL] by the base damage value. msg=msg.replace("[HUNGERVAL]", ChatColor.BLUE+df.format(10*abilitylv)+ChatColor.RESET); msg=msg.replace("[FATALDMG]", ChatColor.BLUE+df.format(120*abilitylv)+ChatColor.RESET); - msg=msg.replace("[REPAIRCHANCE]", ChatColor.BLUE+df.format(tier)+ChatColor.RESET); + msg=msg.replace("[REPAIRCHANCE]", ChatColor.BLUE+df.format(tier/3)+ChatColor.RESET); + msg=msg.replace("[DODGEVAL]", ChatColor.BLUE+df.format(tier)+ChatColor.RESET); return msg; } public static String displayDescriptionUpgrade(ArtifactAbility ability, int tier, int fromlv, int tolv, double playerdmgval) { //Level to display information for. @@ -548,7 +590,8 @@ public enum ArtifactAbility { msg=msg.replace("[PENDMG]", DisplayChangedValue(df.format(calculateValue(ability,tier,fromlv)/100*playerdmgval),df.format(calculateValue(ability,tier,tolv)/100*playerdmgval))); //Based on multiplying [VAL] by the base damage value. msg=msg.replace("[HUNGERVAL]", DisplayBadChangedValue(df.format(10*fromlv),df.format(10*tolv))); msg=msg.replace("[FATALDMG]", DisplayChangedValue(df.format(120-fromlv),df.format(120-tolv))); - msg=msg.replace("[REPAIRCHANCE]", DisplayChangedValue(df.format(tier),df.format(tier))); + msg=msg.replace("[REPAIRCHANCE]", DisplayChangedValue(df.format(tier),df.format(tier/3))); + msg=msg.replace("[DODGEVAL]", DisplayChangedValue(df.format(tier),df.format(tier))); return msg; } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index 1dbd75d..adba0ca 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -33,6 +33,7 @@ import sig.plugin.TwosideKeeper.Artifact; import sig.plugin.TwosideKeeper.AwakenedArtifact; import sig.plugin.TwosideKeeper.MonsterController; import sig.plugin.TwosideKeeper.TwosideKeeper; +import sig.plugin.TwosideKeeper.HelperStructures.ArtifactAbility; import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; public class GenericFunctions { @@ -1612,7 +1613,8 @@ public class GenericFunctions { } public static boolean isEquip(ItemStack item) { - if (item.getType().toString().contains("SPADE") || + if (item!=null && + item.getType()!=Material.AIR && (item.getType().toString().contains("SPADE") || item.getType().toString().contains("AXE") || item.getType().toString().contains("SWORD") || item.getType().toString().contains("BOW") || @@ -1622,7 +1624,7 @@ public class GenericFunctions { item.getType().toString().contains("CHESTPLATE") || item.getType().toString().contains("LEGGINGS") || item.getType().toString().contains("HELMET") || - item.getType().toString().contains("FISHING_ROD")) { + item.getType().toString().contains("FISHING_ROD"))) { return true; } else { return false; @@ -1630,12 +1632,13 @@ public class GenericFunctions { } public static boolean isTool(ItemStack item) { - if (item.getType().toString().contains("SPADE") || + if (item!=null && + item.getType()!=Material.AIR && (item.getType().toString().contains("SPADE") || item.getType().toString().contains("AXE") || item.getType().toString().contains("SWORD") || item.getType().toString().contains("HOE") || item.getType().toString().contains("FISHING_ROD") || - item.getType().toString().contains("BOW")) { + item.getType().toString().contains("BOW"))) { return true; } else { return false; @@ -1643,9 +1646,10 @@ public class GenericFunctions { } public static boolean isHarvestingTool(ItemStack item) { - if (item.getType().toString().contains("SPADE") || + if (item!=null && + item.getType()!=Material.AIR && (item.getType().toString().contains("SPADE") || item.getType().toString().contains("AXE") || - item.getType().toString().contains("HOE")) { + item.getType().toString().contains("HOE"))) { return true; } else { return false; @@ -1653,11 +1657,12 @@ public class GenericFunctions { } public static boolean isWeapon(ItemStack item) { - if (item.getType().toString().contains("BOW") || + if (item!=null && + item.getType()!=Material.AIR && (item.getType().toString().contains("BOW") || item.getType().toString().contains("AXE") || item.getType().toString().contains("SWORD") || item.getType().toString().contains("FISHING_ROD") || - item.getType().toString().contains("HOE")) { + item.getType().toString().contains("HOE"))) { return true; } else { return false; @@ -1665,10 +1670,11 @@ public class GenericFunctions { } public static boolean isArmor(ItemStack item) { - if (item.getType().toString().contains("BOOTS") || + if (item!=null && + item.getType()!=Material.AIR && (item.getType().toString().contains("BOOTS") || item.getType().toString().contains("CHESTPLATE") || item.getType().toString().contains("LEGGINGS") || - item.getType().toString().contains("HELMET")) { + item.getType().toString().contains("HELMET"))) { return true; } else { return false; @@ -1676,21 +1682,23 @@ public class GenericFunctions { } public static boolean isArtifactWeapon(ItemStack item) { - if (item.getType().toString().contains("BOW") || + if (item!=null && + item.getType()!=Material.AIR && (item.getType().toString().contains("BOW") || item.getType().toString().contains("AXE") || item.getType().toString().contains("SWORD") || item.getType().toString().contains("FISHING_ROD") || - item.getType().toString().contains("HOE")) { + item.getType().toString().contains("HOE"))) { return true; } else { return false; } } public static boolean isArtifactArmor(ItemStack item) { - if (item.getType().toString().contains("BOOTS") || + if (item!=null && + item.getType()!=Material.AIR && (item.getType().toString().contains("BOOTS") || item.getType().toString().contains("CHESTPLATE") || item.getType().toString().contains("LEGGINGS") || - item.getType().toString().contains("HELMET")) { + item.getType().toString().contains("HELMET"))) { return true; } else { return false; @@ -1698,9 +1706,10 @@ public class GenericFunctions { } public static boolean isArtifactTool(ItemStack item) { - if (item.getType().toString().contains("SPADE") || + if (item!=null && + item.getType()!=Material.AIR && (item.getType().toString().contains("SPADE") || item.getType().toString().contains("AXE")|| - item.getType().toString().contains("HOE")) { + item.getType().toString().contains("HOE"))) { return true; } else { return false; @@ -2036,4 +2045,97 @@ public class GenericFunctions { } return item; } + + public static double CalculateDodgeChance(Player p) { + double dodgechance = 0.0d; + dodgechance+=(ArtifactAbility.calculateValue(ArtifactAbility.DODGE, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.DODGE, p.getEquipment().getItemInMainHand()))/100d); + + for (int i=0;idmg) { + target.setHealth(target.getHealth()-dmg); + if (damager!=null) { + target.damage(0.01); + } else { + target.damage(0.01,damager); + } + } else { + target.setHealth(0); + if (damager!=null) { + target.damage(0.01); + } else { + target.damage(0.01,damager); + } + } + } } diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index 7455c99..1f115f9 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -54,6 +54,9 @@ public class PlayerStructure { public boolean sounds_enabled=true; public double velocity; public long last_deathmark=TwosideKeeper.getServerTickTime(); + public long last_shovelspell=TwosideKeeper.getServerTickTime(); + public int swordcombo=0; + public long last_swordhit=TwosideKeeper.getServerTickTime(); public double prev_weapondmg=0.0; public double prev_buffdmg=0.0; @@ -87,6 +90,9 @@ public class PlayerStructure { this.sounds_enabled=true; this.debuffcount=0; this.last_deathmark=TwosideKeeper.getServerTickTime(); + this.last_shovelspell=TwosideKeeper.getServerTickTime(); + this.swordcombo=0; + this.last_swordhit=TwosideKeeper.getServerTickTime(); //Set defaults first, in case this is a new user. loadConfig(); diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 8866634..3da4242 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -16,8 +16,11 @@ import java.util.logging.LogRecord; import org.apache.commons.lang.WordUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Particle; import org.bukkit.Server.Spigot; import org.bukkit.Sound; import org.bukkit.WorldCreator; @@ -32,6 +35,7 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Animals; +import org.bukkit.entity.AreaEffectCloud; import org.bukkit.entity.Arrow; import org.bukkit.entity.Bat; import org.bukkit.entity.ComplexLivingEntity; @@ -46,6 +50,7 @@ import org.bukkit.entity.Horse.Variant; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Item; import org.bukkit.entity.LightningStrike; +import org.bukkit.entity.LingeringPotion; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Monster; import org.bukkit.entity.Player; @@ -63,6 +68,7 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.SignChangeEvent; +import org.bukkit.event.entity.AreaEffectCloudApplyEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -132,8 +138,10 @@ import org.bukkit.metadata.MetadataValue; import org.bukkit.metadata.Metadatable; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import org.bukkit.potion.PotionType; import org.bukkit.projectiles.ProjectileSource; import org.bukkit.util.Vector; @@ -141,6 +149,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; import aPlugin.DiscordMessageSender; +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; @@ -508,16 +517,32 @@ public class TwosideKeeper extends JavaPlugin implements Listener { !p.isDead() && //Um, don't heal them if they're dead...That's just weird. p.getHealth()=16) { + + double totalregen = 1+(p.getMaxHealth()*0.05); ItemStack[] equips = p.getEquipment().getArmorContents(); double bonusregen = 0.0; for (int i1=0;i1p.getMaxHealth())?p.getMaxHealth():p.getHealth()+1+(p.getMaxHealth()*0.05)+bonusregen); + + + totalregen += bonusregen; + + for (int i1=0;i1p.getMaxHealth())?p.getMaxHealth():p.getHealth()+totalregen); } } @@ -556,7 +581,24 @@ public class TwosideKeeper extends JavaPlugin implements Listener { p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Base Damage: "+ChatColor.RESET+""+ChatColor.DARK_PURPLE+df.format(pd.damagedealt)+" "+ChatColor.GRAY+ChatColor.ITALIC+"Damage Reduction: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+Math.round((1.0-pd.damagereduction)*100)+"%"); } }*/ + for (int i3=0;i3=900) { + if (p.getInventory().getArmorContents()[Integer.parseInt(args[1])-900]!=null) { + p.spigot().sendMessage(ArtifactAbility.GenerateMenu(ArtifactItemType.getArtifactItemTypeFromItemStack(p.getInventory().getArmorContents()[Integer.parseInt(args[1])-900]).getUpgradePath(), CalculateDamageReduction(1,p,p), p.getInventory().getArmorContents()[Integer.parseInt(args[1])-900])); + } + } else { + if (p.getEquipment().getItemInMainHand()!=null) { + p.spigot().sendMessage(ArtifactAbility.GenerateMenu(ArtifactItemType.getArtifactItemTypeFromItemStack(p.getEquipment().getItemInMainHand()).getUpgradePath(), CalculateDamageReduction(1,p,p), p.getEquipment().getItemInMainHand())); + } + } + } else if (args.length==2 && args[0].equalsIgnoreCase("levelup")) { Player p = (Player)sender; //Argument0 is "levelup" @@ -859,8 +919,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } 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())); + if (p.getEquipment().getItemInMainHand()!=null && + p.getEquipment().getItemInMainHand().getType()!=Material.AIR) { + 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 @@ -3166,6 +3229,30 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } //final double pcthp = ((p.getHealth())/p.getMaxHealth())*100; + + double dodgechance = GenericFunctions.CalculateDodgeChance(p); + if (Math.random()<=dodgechance) { + //Cancel this event, we dodged the attack. + p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_SWEEP, 3.0f, 1.0f); + log("Triggered Dodge.",2); + for (int i=0;i=p.getHealth()) { + //The player actually died from this attack. + log("The player died from this attack. "+ev.getFinalDamage()+">"+p.getHealth(),2); + } + } } @EventHandler(priority=EventPriority.LOW) @@ -3373,6 +3469,21 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //of a new custom damage calculation. if (p.getInventory().getItemInMainHand().getType()!=Material.BOW) { DealDamageToMob(p.getInventory().getItemInMainHand(),p,m); + if (ArtifactAbility.containsEnchantment(ArtifactAbility.PROVOKE, p.getEquipment().getItemInMainHand())) { + ArtifactAbility.calculateValue(ArtifactAbility.PROVOKE, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.PROVOKE, p.getEquipment().getItemInMainHand())); + ItemStack equip = p.getEquipment().getItemInMainHand(); + if (ArtifactAbility.containsEnchantment(ArtifactAbility.PROVOKE, equip)) { + m.addPotionEffect( + new PotionEffect(PotionEffectType.GLOWING, + (int)(ArtifactAbility.calculateValue(ArtifactAbility.PROVOKE, equip.getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.PROVOKE, equip))*20), + 0) + ); + if (m instanceof Monster) { + Monster mon = (Monster)m; + mon.setTarget(p); + } + } + } } if (m instanceof Monster) { if (m.getType()==EntityType.SPIDER && @@ -3403,7 +3514,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { double ratio = 1.0-CalculateDamageReduction(1,m,p); if (GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) && - GenericFunctions.isArtifactWeapon(p.getEquipment().getItemInMainHand())) { + GenericFunctions.isArtifactWeapon(p.getEquipment().getItemInMainHand())) { log("EXP ratio is "+ratio,5); AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), (int)(ratio*20)+5, p); List hitlist = new ArrayList(); @@ -3446,6 +3557,46 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } }} ,100); + + if (ArtifactAbility.containsEnchantment(ArtifactAbility.COMBO, p.getEquipment().getItemInMainHand())) { + PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId()); + if (pd.last_swordhit+40>=getServerTickTime()) { + pd.last_swordhit=getServerTickTime(); + pd.swordcombo++; + log("Sword combo count is "+pd.swordcombo,2); + } + } + } + PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId()); + if (GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) && + p.getEquipment().getItemInMainHand().getType().toString().contains("SPADE") && p.isSneaking()) { + if (ArtifactAbility.containsEnchantment(ArtifactAbility.ERUPTION, p.getEquipment().getItemInMainHand()) && + pd.last_shovelspell nearby = p.getNearbyEntities(2, 2, 2); + for (int i=0;i affected = ev.getAffectedEntities(); + for (int i=0;i=hp) { + p.setHealth(hp); + } p.setMaxHealth(hp); if (!p.isDead()) { p.setHealth(p.getHealth()); @@ -5423,7 +5668,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (Math.random()<=0.01*ArtifactAbility.calculateValue(ArtifactAbility.CRITICAL, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.CRITICAL, p.getEquipment().getItemInMainHand()))) { //Landed a critical strike. //log("Critical strike!",2); - p.getLocation().getWorld().playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_CRIT, 1.0f, 1.0f); + if (p instanceof Player) { + ((Player)p).playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_CRIT, 1.0f, 1.0f); + } double dmgamt = 2+(ArtifactAbility.calculateValue(ArtifactAbility.CRIT_DMG, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.CRIT_DMG, p.getEquipment().getItemInMainHand()))-200)/100; log("Crit dmg multiplied by x"+dmgamt,4); basedmg*=dmgamt; @@ -5433,6 +5680,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { log("Highwinder damage is "+dmgamt,5); basedmg+=dmgamt; + + double combopct = pd.swordcombo*ArtifactAbility.calculateValue(ArtifactAbility.COMBO, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.COMBO, p.getEquipment().getItemInMainHand()))/100d; + log(combopct+" dmg added.",2); + basedmg = basedmg + (basedmg*combopct); } if (pd!=null) { @@ -5698,6 +5949,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener { double reductionamt = ArtifactAbility.calculateValue(ArtifactAbility.DAMAGE_REDUCTION, armor[i].getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.DAMAGE_REDUCTION, armor[i])); dmgreduction+=reductionamt; log("Reducing damage by "+reductionamt+"%",5); + if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, armor[i])) { + dmgreduction /= Math.pow(ArtifactAbility.getEnchantmentLevel(ArtifactAbility.GREED, armor[i]),2); + } } } } @@ -5716,11 +5970,27 @@ public class TwosideKeeper extends JavaPlugin implements Listener { PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId()); partylevel = pd.partybonus; if (partylevel>9) {partylevel=9;} + log("Light level: "+p.getLocation().add(0,0,0).getBlock().getLightLevel(),2); + for (int i=0;i10)?10:resistlevel; protectionlevel=(protectionlevel>100)?100:protectionlevel; partylevel=(partylevel>100)?100:partylevel; @@ -5882,31 +6152,36 @@ public class TwosideKeeper extends JavaPlugin implements Listener { double old_armordef = pd.prev_armordef; double store1=CalculateDamageReduction(1,p,p); - double store2=old_weapondmg; - if (GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) { - store2 = CalculateWeaponDamage(p,null); - } + double 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)+"%"); - TextComponent msg = DisplayPerks(p.getEquipment().getItemInMainHand(),"Weapon",p);if (!msg.toPlainText().equalsIgnoreCase("")) {p.spigot().sendMessage(msg);}; - msg = DisplayPerks(p.getEquipment().getHelmet(),"Helmet",p);if (!msg.toPlainText().equalsIgnoreCase("")) {p.spigot().sendMessage(msg);}; - msg = DisplayPerks(p.getEquipment().getChestplate(),"Chestplate",p);if (!msg.toPlainText().equalsIgnoreCase("")) {p.spigot().sendMessage(msg);}; - msg = DisplayPerks(p.getEquipment().getLeggings(),"Legging",p);if (!msg.toPlainText().equalsIgnoreCase("")) {p.spigot().sendMessage(msg);}; - msg = DisplayPerks(p.getEquipment().getBoots(),"Boot",p);if (!msg.toPlainText().equalsIgnoreCase("")) {p.spigot().sendMessage(msg);}; + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Base Damage: "+ChatColor.RESET+""+ChatColor.DARK_PURPLE+df.format(store2)); + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Damage Reduction: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format((1.0-store1)*100)+"%"); + TextComponent msg = DisplayPerks(p.getEquipment().getItemInMainHand(),"Weapon",p,0);if (!msg.toPlainText().equalsIgnoreCase("")) {p.spigot().sendMessage(msg);}; + msg = DisplayPerks(p.getEquipment().getHelmet(),"Helmet",p,903);if (!msg.toPlainText().equalsIgnoreCase("")) {p.spigot().sendMessage(msg);}; + msg = DisplayPerks(p.getEquipment().getChestplate(),"Chestplate",p,902);if (!msg.toPlainText().equalsIgnoreCase("")) {p.spigot().sendMessage(msg);}; + msg = DisplayPerks(p.getEquipment().getLeggings(),"Legging",p,901);if (!msg.toPlainText().equalsIgnoreCase("")) {p.spigot().sendMessage(msg);}; + msg = DisplayPerks(p.getEquipment().getBoots(),"Boot",p,900);if (!msg.toPlainText().equalsIgnoreCase("")) {p.spigot().sendMessage(msg);}; p.sendMessage("----------"); } - public static TextComponent DisplayPerks(ItemStack item,String type,Player p) { + public static TextComponent DisplayPerks(ItemStack item,String type,Player p, int slot) { TextComponent tc = new TextComponent(""); if (GenericFunctions.isArtifactEquip(item) && ArtifactAbility.getEnchantments(item).size()>0) { //log("Getting perks...",2); HashMap enchants = ArtifactAbility.getEnchantments(item); tc.addExtra(""); - tc.addExtra(ChatColor.GRAY+""+ChatColor.ITALIC+type+" Perks: \n"); + tc.addExtra(ChatColor.GRAY+""+ChatColor.ITALIC+type+" Perks: "); + if (AwakenedArtifact.getAP(item)>0) { + TextComponent tc1 = new TextComponent(ChatColor.GREEN+"["+Character.toString((char)0x25b2)+"]"); + tc1.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder("Click to upgrade abilities on this artifact. "+ChatColor.GREEN+"Available AP: "+ChatColor.BLUE+AwakenedArtifact.getAP(item)).create())); + tc1.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/awakenedartifact menu "+slot)); + tc.addExtra(tc1); + } + + tc.addExtra("\n"); int j=0; for (int i=0;i