->Leather artifact armor pieces now go up to Unbreaking XV. These

unbreaking levels also display properly on the items.
->Vendetta is now used by Defenders by shift-left clicking, allowing
Defenders to still use left-click for basic provoking.
->Vendetta now stores 1% of mitigation damage as Thorns true damage, to
be applied the next time something hits a Defender.
->Vendetta mitigation damage percent lowered from 30% -> 25%.
->Defender damage absorption was non-existent since the damage
calculation rework. It has now been reimplemented properly.
->Vendetta tooltip updated.
->A sound effect now plays when Slayers leave or get hit out of stealth.
->Added AddItemToRecyclingCenter() to API.
->getCooldownReduction() is now visible in the API.
->Death Loot now safely fails if something bad happens, and no longer
stores a mirror inventory on the server; this prevents items from being
permanently lost, or being duped.
dev
sigonasr2 9 years ago
parent ff86174fd4
commit c270d91fb7
  1. BIN
      TwosideKeeper.jar
  2. 2
      src/plugin.yml
  3. 70
      src/sig/plugin/TwosideKeeper/AwakenedArtifact.java
  4. 27
      src/sig/plugin/TwosideKeeper/CustomDamage.java
  5. 30
      src/sig/plugin/TwosideKeeper/DeathManager.java
  6. 2
      src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java
  7. 14
      src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactItemType.java
  8. 61
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java
  9. 6
      src/sig/plugin/TwosideKeeper/HelperStructures/DeathStructure.java
  10. 7
      src/sig/plugin/TwosideKeeper/HelperStructures/ItemSet.java
  11. 6
      src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java
  12. 7
      src/sig/plugin/TwosideKeeper/PlayerStructure.java
  13. 14
      src/sig/plugin/TwosideKeeper/RecyclingCenter.java
  14. 14
      src/sig/plugin/TwosideKeeper/TwosideKeeper.java
  15. 5
      src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java
  16. 8
      src/sig/plugin/TwosideKeeper/runServerHeartbeat.java

Binary file not shown.

@ -1,6 +1,6 @@
name: TwosideKeeper
main: sig.plugin.TwosideKeeper.TwosideKeeper
version: 3.8.6b
version: 3.8.6c
commands:
money:
description: Tells the player the amount of money they are holding.

@ -40,7 +40,7 @@ public class AwakenedArtifact {
artifact.hasItemMeta() &&
artifact.getItemMeta().hasLore() &&
Artifact.isArtifact(artifact)) {
String expline = artifact.getItemMeta().getLore().get(4);
String expline = artifact.getItemMeta().getLore().get(findPotentialLine(artifact.getItemMeta().getLore()));
String exp = (expline.split("\\(")[1]).split("/")[0];
int expval = Integer.parseInt(exp);
return expval;
@ -57,8 +57,8 @@ public class AwakenedArtifact {
ItemMeta m = artifact.getItemMeta();
List<String> lore = m.getLore();
DecimalFormat df = new DecimalFormat("00");
lore.set(3, ChatColor.YELLOW+"EXP"+ChatColor.RESET+" ["+drawEXPMeter(amt)+"] "+df.format((((double)amt/1000)*100))+"%"); //Update the EXP bar.
lore.set(4, ChatColor.BLUE+" ("+amt+"/1000) "+"Potential: "+drawPotential(artifact,getPotential(artifact)));
lore.set(findEXPBarLine(lore), ChatColor.YELLOW+"EXP"+ChatColor.RESET+" ["+drawEXPMeter(amt)+"] "+df.format((((double)amt/1000)*100))+"%"); //Update the EXP bar.
lore.set(findPotentialLine(lore), ChatColor.BLUE+" ("+amt+"/1000) "+"Potential: "+drawPotential(artifact,getPotential(artifact)));
m.setLore(lore);
artifact.setItemMeta(m);
return artifact;
@ -66,6 +66,24 @@ public class AwakenedArtifact {
//TwosideKeeper.log("Could not set the EXP value for artifact "+artifact.toString(), 1);
return artifact;
}
private static int findPotentialLine(List<String> lore) {
for (int i=0;i<lore.size();i++) {
if (lore.get(i).contains(ChatColor.BLUE+" (")) {
return i;
}
}
TwosideKeeper.log("Could not find the Potential line for this item!!! This should never happen!\nLore Set: "+lore.toString(), 0);
return -1;
}
private static int findEXPBarLine(List<String> lore) {
for (int i=0;i<lore.size();i++) {
if (lore.get(i).contains(ChatColor.YELLOW+"EXP"+ChatColor.RESET+" [")) {
return i;
}
}
TwosideKeeper.log("Could not find the EXP line for this item!!! This should never happen!\nLore Set: "+lore.toString(), 0);
return -1;
}
public static ItemStack addEXP(ItemStack artifact, int amt, Player p) {
int totalval = getEXP(artifact)+amt;
if (totalval>=1000) {
@ -108,7 +126,7 @@ public class AwakenedArtifact {
artifact.hasItemMeta() &&
artifact.getItemMeta().hasLore() &&
Artifact.isArtifact(artifact)) {
String lvline = artifact.getItemMeta().getLore().get(5);
String lvline = artifact.getItemMeta().getLore().get(findLVLine(artifact.getItemMeta().getLore()));
String lv = lvline.split(" ")[1];
int LV = Integer.parseInt(lv);
return LV;
@ -116,6 +134,15 @@ public class AwakenedArtifact {
//TwosideKeeper.log("Could not retrieve LV value for artifact "+artifact.toString(), 1);
return -1; //If we got here, something bad happened.
}
private static int findLVLine(List<String> lore) {
for (int i=0;i<lore.size();i++) {
if (lore.get(i).contains(ChatColor.GRAY+"Level ")) {
return i;
}
}
TwosideKeeper.log("Could not find the Level line for this item!!! This should never happen!\nLore Set: "+lore.toString(), 0);
return -1;
}
public static ItemStack setLV(ItemStack artifact, int amt, Player p) {
if (artifact!=null &&
artifact.getType()!=Material.AIR &&
@ -125,8 +152,8 @@ public class AwakenedArtifact {
ItemMeta m = artifact.getItemMeta();
List<String> lore = m.getLore();
DecimalFormat df = new DecimalFormat("000");
lore.set(5, ChatColor.GRAY+"Level "+df.format(amt));
lore.set(6, ChatColor.GOLD+"Ability Points: "+getAP(artifact)+"/"+amt);
lore.set(findLVLine(lore), ChatColor.GRAY+"Level "+df.format(amt));
lore.set(findAPLine(lore), ChatColor.GOLD+"Ability Points: "+getAP(artifact)+"/"+amt);
m.setLore(lore);
artifact.setItemMeta(m);
return artifact;
@ -134,6 +161,15 @@ public class AwakenedArtifact {
//TwosideKeeper.log("Could not set the LV value for artifact "+artifact.toString(), 1);
return artifact;
}
public static int findAPLine(List<String> lore) {
for (int i=0;i<lore.size();i++) {
if (lore.get(i).contains(ChatColor.GOLD+"Ability Points: ")) {
return i;
}
}
TwosideKeeper.log("Could not find the AP line for this item!!! This should never happen!\nLore Set: "+lore.toString(), 0);
return -1;
}
public static ItemStack addAP(ItemStack artifact, int amt) {
if (artifact!=null &&
artifact.getType()!=Material.AIR &&
@ -143,7 +179,7 @@ public class AwakenedArtifact {
ItemMeta m = artifact.getItemMeta();
List<String> lore = m.getLore();
int currentAP = getAP(artifact);
lore.set(6, ChatColor.GOLD+"Ability Points: "+(currentAP+amt)+"/"+getMaxAP(artifact));
lore.set(findAPLine(lore), ChatColor.GOLD+"Ability Points: "+(currentAP+amt)+"/"+getMaxAP(artifact));
m.setLore(lore);
artifact.setItemMeta(m);
return artifact;
@ -159,7 +195,7 @@ public class AwakenedArtifact {
Artifact.isArtifact(artifact)) {
ItemMeta m = artifact.getItemMeta();
List<String> lore = m.getLore();
lore.set(6, ChatColor.GOLD+"Ability Points: "+(newamt)+"/"+getMaxAP(artifact));
lore.set(findAPLine(lore), ChatColor.GOLD+"Ability Points: "+(newamt)+"/"+getMaxAP(artifact));
m.setLore(lore);
artifact.setItemMeta(m);
return artifact;
@ -175,7 +211,7 @@ public class AwakenedArtifact {
Artifact.isArtifact(artifact)) {
ItemMeta m = artifact.getItemMeta();
List<String> lore = m.getLore();
String apline = lore.get(6);
String apline = lore.get(findAPLine(lore));
/*int level = getLV(artifact); //This is how many total we have.
int apused = 0;
HashMap<ArtifactAbility,Integer> enchants = ArtifactAbility.getEnchantments(artifact);
@ -197,7 +233,7 @@ public class AwakenedArtifact {
ItemMeta m = artifact.getItemMeta();
List<String> lore = m.getLore();
int currentMaxAP = getMaxAP(artifact);
lore.set(6, ChatColor.GOLD+"Ability Points: "+getAP(artifact)+"/"+(currentMaxAP+amt));
lore.set(findAPLine(lore), ChatColor.GOLD+"Ability Points: "+getAP(artifact)+"/"+(currentMaxAP+amt));
m.setLore(lore);
artifact.setItemMeta(m);
return artifact;
@ -213,7 +249,7 @@ public class AwakenedArtifact {
Artifact.isArtifact(artifact)) {
ItemMeta m = artifact.getItemMeta();
List<String> lore = m.getLore();
lore.set(6, ChatColor.GOLD+"Ability Points: "+getAP(artifact)+"/"+(newamt));
lore.set(findAPLine(lore), ChatColor.GOLD+"Ability Points: "+getAP(artifact)+"/"+(newamt));
m.setLore(lore);
artifact.setItemMeta(m);
return artifact;
@ -229,7 +265,7 @@ public class AwakenedArtifact {
Artifact.isArtifact(artifact)) {
ItemMeta m = artifact.getItemMeta();
List<String> lore = m.getLore();
String apline = lore.get(6);
String apline = lore.get(findAPLine(lore));
/*int level = getLV(artifact); //This is how many total we have.
int apused = 0;
HashMap<ArtifactAbility,Integer> enchants = ArtifactAbility.getEnchantments(artifact);
@ -249,7 +285,7 @@ public class AwakenedArtifact {
if (GenericFunctions.isArtifactEquip(artifact)) {
ItemMeta m = artifact.getItemMeta();
List<String> lore = m.getLore();
String potentialline = lore.get(4);
String potentialline = lore.get(findPotentialLine(lore));
return Integer.parseInt(ChatColor.stripColor(potentialline.split("Potential: ")[1].replace("%", "")));
} else {
//TwosideKeeper.log("Could not get the Potential value for artifact "+artifact.toString(), 1);
@ -261,8 +297,8 @@ public class AwakenedArtifact {
ItemMeta m = artifact.getItemMeta();
List<String> lore = m.getLore();
int potential = amt;
String potentialline = lore.get(4).split("Potential: ")[0]+"Potential: "+drawPotential(artifact,potential);
lore.set(4, potentialline);
String potentialline = lore.get(findPotentialLine(lore)).split("Potential: ")[0]+"Potential: "+drawPotential(artifact,potential);
lore.set(findPotentialLine(lore), potentialline);
m.setLore(lore);
artifact.setItemMeta(m);
return artifact;
@ -276,8 +312,8 @@ public class AwakenedArtifact {
ItemMeta m = artifact.getItemMeta();
List<String> lore = m.getLore();
int potential = getPotential(artifact)+amt;
String potentialline = lore.get(4).split("Potential: ")[0]+"Potential: "+drawPotential(artifact,potential);
lore.set(4, potentialline);
String potentialline = lore.get(findPotentialLine(lore)).split("Potential: ")[0]+"Potential: "+drawPotential(artifact,potential);
lore.set(findPotentialLine(lore), potentialline);
m.setLore(lore);
artifact.setItemMeta(m);
return artifact;

@ -321,8 +321,12 @@ public class CustomDamage {
if (PlayerMode.isDefender(p)) {
GenericFunctions.addStackingPotionEffect(p, PotionEffectType.DAMAGE_RESISTANCE, 20*5, 4);
if (p.isBlocking() && ItemSet.hasFullSet(GenericFunctions.getEquipment(p), p, ItemSet.SONGSTEEL)) {
pd.vendetta_amt+=((1-CalculateDamageReduction(1,target,damager))*pd.lastrawdamage)*0.3;
GenericFunctions.sendActionBarMessage(p, ChatColor.YELLOW+"Vendetta: "+ChatColor.GREEN+Math.round(pd.vendetta_amt)+" dmg stored");
pd.vendetta_amt+=((1-CalculateDamageReduction(1,target,damager))*pd.lastrawdamage)*0.25;
if (TwosideKeeper.getMaxThornsLevelOnEquipment(target)>0) {
pd.thorns_amt+=((1-CalculateDamageReduction(1,target,damager))*pd.lastrawdamage)*0.01;
}
DecimalFormat df = new DecimalFormat("0.00");
GenericFunctions.sendActionBarMessage(p, ChatColor.YELLOW+"Vendetta: "+ChatColor.GREEN+Math.round(pd.vendetta_amt)+((pd.thorns_amt>0)?"/"+ChatColor.GOLD+df.format(pd.thorns_amt):"")+ChatColor.GREEN+" dmg stored");
}
}
if (getDamagerEntity(damager) instanceof Enderman) {
@ -365,6 +369,8 @@ public class CustomDamage {
pd.slayermegahit=false;
pd.lastcombat=TwosideKeeper.getServerTickTime();
damage = calculateDefenderAbsorption(p, damager, damage);
if (GenericFunctions.AttemptRevive(p, damage, reason)) {
damage=0;
}
@ -906,8 +912,12 @@ public class CustomDamage {
double rawdmg = CalculateDamage(0,damager,target,null,null,TRUEDMG)*(1d/CalculateDamageReduction(1,target,damager));
if (p.isBlocking() && ItemSet.hasFullSet(GenericFunctions.getEquipment(p), p, ItemSet.SONGSTEEL)) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.vendetta_amt+=((1-CalculateDamageReduction(1,target,damager))*rawdmg);
GenericFunctions.sendActionBarMessage(p, ChatColor.YELLOW+"Vendetta: "+ChatColor.GREEN+Math.round(pd.vendetta_amt)+" dmg stored");
pd.vendetta_amt+=((1-CalculateDamageReduction(1,target,damager))*(rawdmg*0.95));
if (TwosideKeeper.getMaxThornsLevelOnEquipment(target)>0) {
pd.thorns_amt+=((1-CalculateDamageReduction(1,target,damager))*(rawdmg*0.01));
}
DecimalFormat df = new DecimalFormat("0.00");
GenericFunctions.sendActionBarMessage(p, ChatColor.YELLOW+"Vendetta: "+ChatColor.GREEN+Math.round(pd.vendetta_amt)+((pd.thorns_amt>0)?"/"+ChatColor.GOLD+df.format(pd.thorns_amt):"")+ChatColor.GREEN+" dmg stored");
}
return true;
}
@ -1565,10 +1575,11 @@ public class CustomDamage {
return mult;
}
public static double calculateDefenderAbsorption(LivingEntity entity, double dmg) {
public static double calculateDefenderAbsorption(LivingEntity entity, Entity damager, double dmg) {
//See if we're in a party with a defender.
if (entity instanceof Player) {
Player p = (Player)entity;
LivingEntity shooter = getDamagerEntity(damager);
List<Player> partymembers = TwosideKeeperAPI.getPartyMembers(p);
for (int i=0;i<partymembers.size();i++) {
Player check = partymembers.get(i);
@ -1581,9 +1592,9 @@ public class CustomDamage {
dmg = dmg/2;
//Send the rest of the damage to the defender.
double defenderdmg = dmg;
defenderdmg=CalculateDamageReduction(dmg, check, entity);
ApplyDamage(defenderdmg, p, check, null, "Defender Tank");
TwosideKeeper.log("Damage was absorbed by "+check.getName()+". Took "+defenderdmg+" reduced damage. Original damage: "+dmg,2);
//defenderdmg=CalculateDamageReduction(dmg, check, entity);
ApplyDamage(defenderdmg, shooter, check, null, "Defender Tank", IGNOREDODGE|IGNORE_DAMAGE_TICK);
//TwosideKeeper.log("Damage was absorbed by "+check.getName()+". Took "+defenderdmg+" reduced damage. Original damage: "+dmg,0);
break;
}
}

@ -110,35 +110,7 @@ public class DeathManager {
DeathStructure structure = getDeathStructure(p);
Inventory deathinv = Bukkit.getServer().createInventory(p, 45, "Death Loot");
for (int i=0;i<structure.deathinventory.size();i++) {
/*
if (i>=36) {
if (pd.deathinventory.get(i).getType().toString().contains("BOOTS")) {
p.getInventory().setBoots(pd.deathinventory.get(i));
} else
if (pd.deathinventory.get(i).getType().toString().contains("SHIELD")) {
p.getInventory().setItemInOffHand(pd.deathinventory.get(i));
} else
if (pd.deathinventory.get(i).getType().toString().contains("LEGGINGS")) {
p.getInventory().setLeggings(pd.deathinventory.get(i));
} else
if (pd.deathinventory.get(i).getType().toString().contains("CHESTPLATE")) {
p.getInventory().setChestplate(pd.deathinventory.get(i));
} else
if (pd.deathinventory.get(i).getType().toString().contains("HELMET")) {
p.getInventory().setHelmet(pd.deathinventory.get(i));
} else {
//What is this? Just drop it.
p.getLocation().getWorld().dropItem(p.getLocation(), pd.deathinventory.get(i));
}
} else {
p.getInventory().addItem(pd.deathinventory.get(i));
}*/
if (structure.deathinventory.get(i)!=null &&
structure.deathinventory.get(i).getType()!=Material.AIR) {
deathinv.addItem(structure.deathinventory.get(i));
}
}
GenericFunctions.TransferItemsToInventory(p.getInventory(), deathinv);
double totalmoney = TwosideKeeper.getPlayerMoney(Bukkit.getPlayer(p.getName()))+TwosideKeeper.getPlayerBankMoney(Bukkit.getPlayer(p.getName()));
int price = 1;
if (structure.deathloc.getBlockY()<=60) {

@ -222,7 +222,7 @@ public enum ArtifactAbility {
if (GenericFunctions.isArtifactEquip(item)) {
List<String> 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.size();i++) {
for (int i=AwakenedArtifact.findAPLine(lore)+1;i<lore.size();i++) {
String[] splitstring = lore.get(i).split(" ");
TwosideKeeper.log(splitstring.length+"",5);
String newstring = "";

@ -588,7 +588,7 @@ public enum ArtifactItemType {
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 1);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 1);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 4);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 6);
}
if (upgrade==UpgradePath.TOOL ||
upgrade==UpgradePath.SHOVEL ||
@ -622,7 +622,7 @@ public enum ArtifactItemType {
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 2);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 2);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 5);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 8);
}
if (upgrade==UpgradePath.TOOL ||
upgrade==UpgradePath.SHOVEL ||
@ -656,7 +656,7 @@ public enum ArtifactItemType {
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 4);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 4);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 6);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 6);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
}
if (upgrade==UpgradePath.TOOL ||
upgrade==UpgradePath.SHOVEL ||
@ -691,7 +691,7 @@ public enum ArtifactItemType {
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 7);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 7);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 7);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 7);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 11);
}
if (upgrade==UpgradePath.TOOL ||
upgrade==UpgradePath.SHOVEL ||
@ -729,7 +729,7 @@ public enum ArtifactItemType {
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 8);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 8);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 8);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 8);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 13);
}
if (upgrade==UpgradePath.TOOL ||
upgrade==UpgradePath.SHOVEL ||
@ -766,7 +766,7 @@ public enum ArtifactItemType {
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 9);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 9);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 9);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 9);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 14);
}
if (upgrade==UpgradePath.TOOL ||
upgrade==UpgradePath.SHOVEL ||
@ -804,7 +804,7 @@ public enum ArtifactItemType {
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 15);
}
if (upgrade==UpgradePath.TOOL ||
upgrade==UpgradePath.SHOVEL ||

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -3108,15 +3109,51 @@ public class GenericFunctions {
return item;
}
private static void UpdateArtifactItemType(ItemStack item) {
public static void UpdateArtifactItemType(ItemStack item) {
if (isArtifactArmor(item) &&
item.getType()!=Material.SULPHUR) {
double durabilityratio = item.getDurability()/item.getType().getMaxDurability();
item.setType(Material.valueOf("LEATHER_"+item.getType().name().split("_")[1]));
item.setDurability((short)(durabilityratio*item.getType().getMaxDurability()));
UpdateDisplayedEnchantments(item);
}
}
private static void UpdateDisplayedEnchantments(ItemStack item) {
ItemMeta m = item.getItemMeta();
m.addItemFlags(ItemFlag.HIDE_ENCHANTS);
m.setLore(ClearAllPreviousEnchantmentLines(m.getLore()));
item.setItemMeta(m);
AddNewEnchantmentLines(item);
}
private static void AddNewEnchantmentLines(ItemStack item) {
Set<Enchantment> map = item.getEnchantments().keySet();
ItemMeta m = item.getItemMeta();
List<String> lore = m.getLore();
int artifact_lv = item.getEnchantmentLevel(Enchantment.LUCK);
for (Enchantment e : map) {
int lv = item.getEnchantments().get(e);
if (!e.getName().equalsIgnoreCase("luck")) {
lore.add(0," "+ChatColor.BLACK+ChatColor.WHITE+ChatColor.GRAY+WorldShop.getRealName(e)+" "+WorldShop.toRomanNumeral(lv));
}
}
lore.add(0,ChatColor.GOLD+""+ChatColor.BLACK+ChatColor.GOLD+"Tier "+artifact_lv+ChatColor.RESET+ChatColor.GOLD+" "+GenericFunctions.UserFriendlyMaterialName(item.getType())+" Artifact");
m.setLore(lore);
item.setItemMeta(m);
}
private static List<String> ClearAllPreviousEnchantmentLines(List<String> lore) {
for (int i=0;i<lore.size();i++) {
if (lore.get(i).contains(" "+ChatColor.BLACK+ChatColor.WHITE+ChatColor.GRAY) ||
lore.get(i).contains(ChatColor.GOLD+""+ChatColor.BLACK+ChatColor.GOLD+"Tier ")) {
lore.remove(i);
i--;
}
}
return lore;
}
private static void UpdateHuntersCompass(ItemStack item) {
if (item.getType()==Material.COMPASS &&
item.containsEnchantment(Enchantment.LUCK)) {
@ -3941,6 +3978,7 @@ public class GenericFunctions {
public static void removeStealth(Player p) {
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.INVISIBILITY, p);
GenericFunctions.addIFrame(p, 10);
p.playSound(p.getLocation(), Sound.BLOCK_REDSTONE_TORCH_BURNOUT, 1.0f, 1.0f);
}
public static boolean hasStealth(Player p) {
@ -4099,7 +4137,7 @@ public class GenericFunctions {
public static boolean isIsolatedTarget(Monster m, Player p) {
return ((GlowAPI.isGlowing(m, p) &&
GlowAPI.getGlowColor(m, p).equals(Color.WHITE)) ||
GenericFunctions.GetNearbyMonsterCount(m, 10)==0) &&
GenericFunctions.GetNearbyMonsterCount(m, 12)==0) &&
PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER;
}
@ -4183,7 +4221,7 @@ public class GenericFunctions {
if (prefix.length()>0) {
aPlugin.API.sendActionBarMessage(p, message+" "+prefix);
} else {
if (message.length()>0) {
if (message.length()>0) {
aPlugin.API.sendActionBarMessage(p, message);
}
}
@ -4197,4 +4235,21 @@ public class GenericFunctions {
return ent.getCustomName().split(ChatColor.RESET+" ")[0];
}
}
public static void TransferItemsToInventory(Inventory from, Inventory to) {
List<ItemStack> inventory = new ArrayList<ItemStack>();
for (int i=0;i<from.getContents().length;i++) {
if (from.getItem(i)!=null) {
inventory.add(from.getItem(i));
}
}
ItemStack[] list = inventory.toArray(new ItemStack[inventory.size()]);
HashMap<Integer,ItemStack> items = to.addItem(list);
for (int i=0;i<items.size();i++) {
//from.addItem(items.get(i));
TwosideKeeper.log("Could not add "+items.get(i).toString()+" to inventory. Recycling it... THIS SHOULD NOT HAPPEN THOUGH!", 0);
TwosideKeeperAPI.addItemToRecyclingCenter(items.get(i));
}
from.clear();
}
}

@ -8,17 +8,17 @@ import org.bukkit.inventory.ItemStack;
public class DeathStructure {
public List<ItemStack> deathinventory;
//public List<ItemStack> deathinventory;
public Location deathloc;
public String p;
public DeathStructure(List<ItemStack> di, Location dl, Player p) {
this.deathinventory=di;
//this.deathinventory=di;
this.deathloc=dl;
this.p=p.getName();
}
public String toString() {
return "Death Inventory: "+deathinventory.size()+" items, belongs to Player "+p+". Death location is "+deathloc.toString();
return "Belongs to Player "+p+". Death location is "+deathloc.toString();
}
}

@ -294,9 +294,10 @@ public enum ItemSet {
lore.add(ChatColor.DARK_AQUA+" 3 - "+ChatColor.WHITE+" +"+ItemSet.GetBaseAmount(set, tier, 3)+" Absorption Health (30 seconds)");
lore.add(ChatColor.DARK_AQUA+" 4 - "+ChatColor.WHITE+" +"+ItemSet.GetBaseAmount(set, tier, 4)+"% Damage Reduction");
lore.add(ChatColor.DARK_AQUA+" 5 - "+ChatColor.WHITE+" Vendetta");
lore.add(ChatColor.GRAY+" Blocking stores 30% of mitigation damage.");
lore.add(ChatColor.GRAY+" Attacking with a shield unleashes all stored");
lore.add(ChatColor.GRAY+" mitigation damage.");
lore.add(ChatColor.GRAY+" Blocking stores 25% of mitigation damage.");
lore.add(ChatColor.GRAY+" 1% of damage is stored as thorns true damage.");
lore.add(ChatColor.GRAY+" Shift+Left-Click with a shield to unleash");
lore.add(ChatColor.GRAY+" all of your stored mitigation damage.");
}break;
case DAWNTRACKER:{
lore.add(ChatColor.GOLD+""+ChatColor.ITALIC+"Set Bonus:");

@ -108,13 +108,13 @@ public class WorldShop {
public static String GetItemInfo(ItemStack item) {
//Gets all the info about this item in one gigantic string. (Separated by new lines. Useful for tellraw()).
String message = "";
if (GenericFunctions.isArtifactEquip(item)) {
if (GenericFunctions.isArtifactEquip(item) && !GenericFunctions.isArtifactArmor(item) /*Artifact armor already has this info displayed.*/) {
if (item.hasItemMeta() &&
item.getItemMeta().hasDisplayName()) {
message+="\n"+ChatColor.GOLD+ChatColor.BOLD+"T"+item.getEnchantmentLevel(Enchantment.LUCK)+ChatColor.RESET+ChatColor.GOLD+" "+GenericFunctions.UserFriendlyMaterialName(item.getType())+" Artifact \n";
}
} else
if (item.hasItemMeta() &&
if (!GenericFunctions.isArtifactArmor(item) && item.hasItemMeta() &&
item.getItemMeta().hasDisplayName()) {
message+="\n"+ChatColor.DARK_GRAY+"Item Type: "+ChatColor.ITALIC+ChatColor.GRAY+GenericFunctions.UserFriendlyMaterialName(item.getType())+"\n";
}
@ -531,7 +531,7 @@ public class WorldShop {
}
}
static String getRealName(Enchantment enchant) {
public static String getRealName(Enchantment enchant) {
if (enchant.getName().equalsIgnoreCase("arrow_damage")) {return "Power";}
if (enchant.getName().equalsIgnoreCase("arrow_fire")) {return "Flame";}
if (enchant.getName().equalsIgnoreCase("arrow_infinite")) {return "Infinity";}

@ -109,6 +109,7 @@ public class PlayerStructure {
public long lastassassinatetime=0;
public long lastlifesavertime=0;
public boolean slayermegahit=false;
public double thorns_amt = 0.0;
public long iframetime = 0;
@ -257,18 +258,18 @@ public class PlayerStructure {
workable.set("spleef_wins", spleef_wins);
workable.set("sounds_enabled", sounds_enabled);
workable.set("hasDied", hasDied);
ConfigurationSection deathlootlist = workable.createSection("deathloot");
//ConfigurationSection deathlootlist = workable.createSection("deathloot");
if (DeathManager.deathStructureExists(Bukkit.getPlayer(name))) {
DeathStructure ds = DeathManager.getDeathStructure(Bukkit.getPlayer(name));
deathloc_x = ds.deathloc.getX();
deathloc_y = ds.deathloc.getY();
deathloc_z = ds.deathloc.getZ();
deathloc_world = ds.deathloc.getWorld().getName();
for (int i=0;i<ds.deathinventory.size();i++) {
/*for (int i=0;i<ds.deathinventory.size();i++) {
if (ds.deathinventory.get(i)!=null) {
deathlootlist.set("item"+i, ds.deathinventory.get(i));
}
}
}*/
}
workable.set("deathloc_x", deathloc_x);
workable.set("deathloc_y", deathloc_y);

@ -164,9 +164,9 @@ public class RecyclingCenter {
return TwosideKeeper.TwosideRecyclingCenter.nodes.contains(new Location(b.getWorld(),b.getLocation().getBlockX(),b.getLocation().getBlockY(),b.getLocation().getBlockZ()));
}
public void AddItemToRecyclingCenter(Item i) {
public void AddItemToRecyclingCenter(ItemStack i) {
//There is a % chance of it going to a recycling center.
if (IsItemAllowed(i.getItemStack())) {
if (IsItemAllowed(i)) {
//Recycle allowed. Now figure out which node to go to.
if (getNumberOfNodes()>0) {
Location rand_node=getRandomNode();
@ -177,20 +177,20 @@ public class RecyclingCenter {
if (b.getState()!=null) {
Chest c = (Chest) b.getState();
for (int j=0;j<27;j++) {
if (c.getBlockInventory().getItem(j)!=null && c.getBlockInventory().getItem(j).getType()==i.getItemStack().getType()) {
if (c.getBlockInventory().getItem(j)!=null && c.getBlockInventory().getItem(j).getType()==i.getType()) {
}
}
int itemslot = (int)Math.floor(Math.random()*27);
ItemStack oldItem = c.getBlockInventory().getItem(itemslot);
//There is also a chance to move this item to another random spot.
if (!isCommon(i.getItemStack().getType())) {
if (!isCommon(i.getType())) {
if (oldItem!=null && Math.random()*100<=TwosideKeeper.RECYCLECHANCE) {
int itemslot2 = (int)Math.floor(Math.random()*27);
c.getBlockInventory().setItem(itemslot2, oldItem);
}
c.getBlockInventory().setItem(itemslot, i.getItemStack());
populateItemList(i.getItemStack());
TwosideKeeper.log("Sent "+ChatColor.AQUA+GenericFunctions.UserFriendlyMaterialName(i.getItemStack())+((i.getItemStack().getAmount()>1)?ChatColor.YELLOW+" x"+i.getItemStack().getAmount():"")+ChatColor.RESET+" to Recycling Center Node "+rand_node.toString(),2);
c.getBlockInventory().setItem(itemslot, i);
populateItemList(i);
TwosideKeeper.log("Sent "+ChatColor.AQUA+GenericFunctions.UserFriendlyMaterialName(i)+((i.getAmount()>1)?ChatColor.YELLOW+" x"+i.getAmount():"")+ChatColor.RESET+" to Recycling Center Node "+rand_node.toString(),2);
}
}
}

@ -2723,7 +2723,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
pd = PlayerStructure.GetPlayerStructure(p);
pd.hasDied=true;
pd.vendetta_amt=0.0;
p.getInventory().clear();
//p.getInventory().clear();
}
for (int i=0;i<elitemonsters.size();i++) {
EliteMonster em = elitemonsters.get(i);
@ -3676,7 +3676,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
TwosideRecyclingCenter.AddItemToRecyclingCenter(i);
TwosideRecyclingCenter.AddItemToRecyclingCenter(i.getItemStack());
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
@ -3920,7 +3920,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
private double getMaxThornsLevelOnEquipment(Entity damager) {
public static double getMaxThornsLevelOnEquipment(Entity damager) {
int maxthornslevel = 0;
LivingEntity shooter = CustomDamage.getDamagerEntity(damager);
if (shooter instanceof LivingEntity) {
@ -3953,6 +3953,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
ev.getEntity().getWorld().playSound(ev.getEntity().getLocation(), Sound.ENCHANT_THORNS_HIT, 1.0f, 1.0f);
CustomDamage.setupTrueDamage(ev);
if (ev.getDamager() instanceof Player) {
Player p = (Player)ev.getDamager();
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
dmgdealt += pd.thorns_amt;
pd.thorns_amt=0;
}
CustomDamage.ApplyDamage(dmgdealt, ev.getDamager(), (LivingEntity)ev.getEntity(), null, ev.getCause().name(), CustomDamage.TRUEDMG);
ev.setCancelled(true);
} else
@ -3981,7 +3987,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (CustomDamage.getDamagerEntity(ev.getDamager()) instanceof Player) {
Player p = (Player)CustomDamage.getDamagerEntity(ev.getDamager());
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (PlayerMode.isDefender(p) && ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.SONGSTEEL,5) && pd.vendetta_amt>0.0) { //Deal Vendetta damage instead.
if (PlayerMode.isDefender(p) && p.isSneaking() && ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.SONGSTEEL,5) && pd.vendetta_amt>0.0) { //Deal Vendetta damage instead.
p.playSound(p.getLocation(), Sound.BLOCK_GLASS_BREAK, 1.0f, 0.5f);
GenericFunctions.removeNoDamageTick((LivingEntity)ev.getEntity(), ev.getDamager());
CustomDamage.ApplyDamage(pd.vendetta_amt, ev.getDamager(), (LivingEntity)ev.getEntity(), null, "Vendetta");

@ -348,6 +348,9 @@ public final class TwosideKeeperAPI {
public static boolean isRecyclingCenter(Block b) {
return RecyclingCenter.isRecyclingCenter(b);
}
public static void addItemToRecyclingCenter(ItemStack item) {
TwosideKeeper.TwosideRecyclingCenter.AddItemToRecyclingCenter(item);
}
//Item Set COMMANDS.
public static boolean isSetItem(ItemStack item) {
@ -433,7 +436,7 @@ public final class TwosideKeeperAPI {
* @param p
* @return
*/
public double getCooldownReduction(Player p) {
public static double getCooldownReduction(Player p) {
return CustomDamage.calculateCooldownReduction(p);
}
}

@ -118,6 +118,9 @@ final class runServerHeartbeat implements Runnable {
PlayerStructure pd = (PlayerStructure)TwosideKeeper.playerdata.get(p.getUniqueId());
GenericFunctions.RemoveNewDebuffs(p);
ItemStack[] equips2 = GenericFunctions.getEquipment(p);
for (int i=0;i<equips2.length;i++) {GenericFunctions.UpdateArtifactItemType(equips2[i]);}
if (p.isSprinting() && pd.lastsprintcheck+(20*5)<serverTickTime) {
pd.lastsprintcheck=serverTickTime;
GenericFunctions.ApplySwiftAegis(p);
@ -184,6 +187,11 @@ final class runServerHeartbeat implements Runnable {
ItemStack[] equips = p.getEquipment().getArmorContents();
if (pd.lastcombat+(20*60)<serverTickTime) {
pd.vendetta_amt=0;
pd.thorns_amt=0;
}
if (pd.last_regen_time+TwosideKeeper.HEALTH_REGENERATION_RATE<=serverTickTime) {
pd.last_regen_time=serverTickTime;
//See if this player needs to be healed.

Loading…
Cancel
Save