Tons of bugfixes and modifications to artifact mechanics. Added

Scythe-specific abilities.
This commit is contained in:
sigonasr2 2016-07-12 00:21:23 -05:00
parent cbcf1b810c
commit dc338d3a64
9 changed files with 344 additions and 173 deletions

Binary file not shown.

View File

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

View File

@ -26,7 +26,7 @@ public class AwakenedArtifact {
public static HashMap<String,ArtifactAbility> name_map = new HashMap(); public static HashMap<String,ArtifactAbility> name_map = new HashMap();
private static String drawEXPMeter(int exp) { private static String drawEXPMeter(int exp) {
String bar =""; String bar ="";
for (int i=0;i<(exp/100)%1000;i++) { for (int i=0;i<((exp%1000)/100);i++) {
bar+=Character.toString((char)0x2588); bar+=Character.toString((char)0x2588);
} }
if (exp%100>=50) { if (exp%100>=50) {
@ -74,9 +74,8 @@ public class AwakenedArtifact {
int totalval = getEXP(artifact)+amt; int totalval = getEXP(artifact)+amt;
if (totalval>=1000) { if (totalval>=1000) {
//LEVEL UP! //LEVEL UP!
if (getLV(artifact)<1000) {
ItemStack item = addLV(artifact,totalval/1000, p); ItemStack item = addLV(artifact,totalval/1000, p);
item = setEXP(item,totalval%1000); item = setEXP(item,totalval-1000);
item = addAP(item,1); item = addAP(item,1);
if (getPotential(item)>10) { if (getPotential(item)>10) {
item = addPotential(item,-getPotential(item)/10); item = addPotential(item,-getPotential(item)/10);
@ -100,9 +99,6 @@ public class AwakenedArtifact {
} else { } else {
return setEXP(artifact,totalval); return setEXP(artifact,totalval);
} }
} else {
return setEXP(artifact,totalval);
}
} }
public static int getLV(ItemStack artifact) { public static int getLV(ItemStack artifact) {
if (artifact!=null && if (artifact!=null &&
@ -203,8 +199,6 @@ public class AwakenedArtifact {
public static ItemStack addPotentialEXP(ItemStack artifact,int exp,Player p) { public static ItemStack addPotentialEXP(ItemStack artifact,int exp,Player p) {
//Adds experience, but only based on the potential of the item. //Adds experience, but only based on the potential of the item.
if (GenericFunctions.isArtifactEquip(artifact)) { if (GenericFunctions.isArtifactEquip(artifact)) {
int missingdurability = artifact.getDurability();
if (missingdurability!=0) {
double mult = getPotential(artifact)/100d; double mult = getPotential(artifact)/100d;
//Multiply the value. If it's less than 1, there is only a chance exp will be added. //Multiply the value. If it's less than 1, there is only a chance exp will be added.
double expadded = exp*mult; double expadded = exp*mult;
@ -215,9 +209,6 @@ public class AwakenedArtifact {
} else { } else {
return addEXP(artifact,(int)expadded,p); return addEXP(artifact,(int)expadded,p);
} }
} else {
return addEXP(artifact,exp,p);
}
} else { } else {
return artifact; return artifact;
} }

View File

@ -94,7 +94,6 @@ public class DeathManager {
public static void continueAction(Player p) { public static void continueAction(Player p) {
//Pick 5 //Pick 5
DeathStructure structure = getDeathStructure(p); DeathStructure structure = getDeathStructure(p);
Inventory deathinv = Bukkit.getServer().createInventory(p, 45, "Death Loot"); Inventory deathinv = Bukkit.getServer().createInventory(p, 45, "Death Loot");
@ -127,7 +126,7 @@ public class DeathManager {
deathinv.addItem(structure.deathinventory.get(i)); deathinv.addItem(structure.deathinventory.get(i));
} }
} }
double totalmoney = TwosideKeeper.getPlayerMoney(p)+TwosideKeeper.getPlayerBankMoney(p); double totalmoney = TwosideKeeper.getPlayerMoney(Bukkit.getPlayer(p.getName()))+TwosideKeeper.getPlayerBankMoney(Bukkit.getPlayer(p.getName()));
int price = 1; int price = 1;
if (structure.deathloc.getBlockY()<=60) { if (structure.deathloc.getBlockY()<=60) {
price += 24-(structure.deathloc.getBlockY()/2.5); price += 24-(structure.deathloc.getBlockY()/2.5);

View File

@ -95,16 +95,18 @@ public enum ArtifactAbility {
new double[]{0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8},100,1000,UpgradePath.AXE), new double[]{0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8},100,1000,UpgradePath.AXE),
//Scythe abilities //Scythe abilities
AOE("Area of Effect",ChatColor.GRAY+"[Unimplemented] Deals damage to targets up to [VAL]m from the main target hit.",new double[]{0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4}, AOE("Area of Effect","Deals damage to targets up to [VAL]m from the main target hit.",new double[]{0.4,0.45,0.5,0.55,0.6,0.65,0.70,0.75,0.80,0.85},
new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1000,UpgradePath.SCYTHE), new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1,UpgradePath.SCYTHE),
DEATHMARK("Death Mark",ChatColor.GRAY+"[Unimplemented] 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}, DEATHMARK("Death Mark","Applies a Death Mark stack to enemies hit. Death mark stacks 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] true damage.",new double[]{0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0},
new double[]{0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6},100,1000,UpgradePath.SCYTHE), new double[]{0.6,0.575,0.55,0.525,0.5,0.475,0.45,0.425,0.4,0.375},100,10,UpgradePath.SCYTHE),
//General abilities //General abilities
AUTOREPAIR("Auto Repair",ChatColor.GRAY+"[Unimplemented] [REPAIRCHANCE]% chance to repair [VAL] durability to the artifact item every 10 seconds.\n\nThe item must be sitting in your hotbar or must be equipped for this ability to work.",new double[]{10,15,20,25,27.5,30,32.5,35,37.5,40},
new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},10,1,UpgradePath.ALL),
GREED("Greed",ChatColor.GRAY+"[Unimplemented] 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}, GREED("Greed",ChatColor.GRAY+"[Unimplemented] 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,1000,UpgradePath.ALL), new double[]{2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0},100,1000,UpgradePath.ALL),
GROWTH("Growth",ChatColor.GRAY+"[Unimplemented] 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}, /*GROWTH("Growth",ChatColor.GRAY+"[Unimplemented] 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,1000,UpgradePath.ALL), new double[]{2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0},100,1000,UpgradePath.ALL),*/
REMOVE_CURSE("Remove Curse",ChatColor.GRAY+"[Unimplemented] 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}, REMOVE_CURSE("Remove Curse",ChatColor.GRAY+"[Unimplemented] 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,1000,UpgradePath.ALL), new double[]{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},1,1000,UpgradePath.ALL),
PRESERVATION("Preservation",ChatColor.GRAY+"[Unimplemented] 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}, PRESERVATION("Preservation",ChatColor.GRAY+"[Unimplemented] 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},
@ -521,7 +523,7 @@ public enum ArtifactAbility {
} }
text=DisplayAbility(GREED,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} text=DisplayAbility(GREED,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");}
text=DisplayAbility(GROWTH,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} text=DisplayAbility(AUTOREPAIR,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");}
text=DisplayAbility(REMOVE_CURSE,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} text=DisplayAbility(REMOVE_CURSE,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");}
text=DisplayAbility(PRESERVATION,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} text=DisplayAbility(PRESERVATION,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");}
text=DisplayAbility(EXP_MULT,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} text=DisplayAbility(EXP_MULT,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");}
@ -532,10 +534,11 @@ public enum ArtifactAbility {
public static String displayDescription(ArtifactAbility ability, int tier, int abilitylv, double playerdmgval) { //Level to display information for. public static String displayDescription(ArtifactAbility ability, int tier, int abilitylv, double playerdmgval) { //Level to display information for.
String msg = ability.GetDescription(); String msg = ability.GetDescription();
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
msg=msg.replace("[VAL]", df.format(calculateValue(ability,tier,abilitylv))); msg=msg.replace("[VAL]", ChatColor.BLUE+df.format(calculateValue(ability,tier,abilitylv))+ChatColor.RESET);
msg=msg.replace("[PENDMG]", df.format(calculateValue(ability,tier,abilitylv)/100*playerdmgval)); //Based on multiplying [VAL] by the base damage value. 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]", df.format(10*abilitylv)); msg=msg.replace("[HUNGERVAL]", ChatColor.BLUE+df.format(10*abilitylv)+ChatColor.RESET);
msg=msg.replace("[FATALDMG]", df.format(120*abilitylv)); msg=msg.replace("[FATALDMG]", ChatColor.BLUE+df.format(120*abilitylv)+ChatColor.RESET);
msg=msg.replace("[REPAIRCHANCE]", ChatColor.BLUE+df.format(tier)+ChatColor.RESET);
return msg; return msg;
} }
public static String displayDescriptionUpgrade(ArtifactAbility ability, int tier, int fromlv, int tolv, double playerdmgval) { //Level to display information for. public static String displayDescriptionUpgrade(ArtifactAbility ability, int tier, int fromlv, int tolv, double playerdmgval) { //Level to display information for.
@ -545,6 +548,7 @@ 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("[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("[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("[FATALDMG]", DisplayChangedValue(df.format(120-fromlv),df.format(120-tolv)));
msg=msg.replace("[REPAIRCHANCE]", DisplayChangedValue(df.format(tier),df.format(tier)));
return msg; return msg;
} }

View File

@ -9,18 +9,19 @@ import org.bukkit.inventory.ShapelessRecipe;
import sig.plugin.TwosideKeeper.Artifact; import sig.plugin.TwosideKeeper.Artifact;
import sig.plugin.TwosideKeeper.TwosideKeeper; import sig.plugin.TwosideKeeper.TwosideKeeper;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
public enum ArtifactItemType { public enum ArtifactItemType {
AXE(0,"AXE",TierType.ALL,UpgradePath.AXE,new String[]{"EEx","EEx","xEx"}, AXE(0,"AXE",TierType.ALL,UpgradePath.AXE,new String[]{"EEx","EEx","xEx"},
new ItemStack[]{ new ItemStack[]{
new ItemStack(Material.GOLD_AXE), //T1 new ItemStack(Material.STONE_AXE), //T1
new ItemStack(Material.WOOD_AXE), //T2 new ItemStack(Material.STONE_AXE), //T2
new ItemStack(Material.WOOD_AXE), //T3 new ItemStack(Material.STONE_AXE), //T3
new ItemStack(Material.STONE_AXE), //T4 new ItemStack(Material.IRON_AXE), //T4
new ItemStack(Material.STONE_AXE), //T5 new ItemStack(Material.IRON_AXE), //T5
new ItemStack(Material.IRON_AXE), //T6 new ItemStack(Material.IRON_AXE), //T6
new ItemStack(Material.IRON_AXE), //T7 new ItemStack(Material.DIAMOND_AXE), //T7
new ItemStack(Material.IRON_AXE), //T8 new ItemStack(Material.DIAMOND_AXE), //T8
new ItemStack(Material.DIAMOND_AXE), //T9 new ItemStack(Material.DIAMOND_AXE), //T9
new ItemStack(Material.DIAMOND_AXE), //T10 new ItemStack(Material.DIAMOND_AXE), //T10
}, },
@ -38,14 +39,14 @@ public enum ArtifactItemType {
}), }),
SWORD(1,"SWORD",TierType.ALL,UpgradePath.SWORD,new String[]{"EEE","EEE","EEE"}, SWORD(1,"SWORD",TierType.ALL,UpgradePath.SWORD,new String[]{"EEE","EEE","EEE"},
new ItemStack[]{ new ItemStack[]{
new ItemStack(Material.GOLD_SWORD), //T1 new ItemStack(Material.STONE_SWORD), //T1
new ItemStack(Material.WOOD_SWORD), //T2 new ItemStack(Material.STONE_SWORD), //T2
new ItemStack(Material.WOOD_SWORD), //T3 new ItemStack(Material.STONE_SWORD), //T3
new ItemStack(Material.STONE_SWORD), //T4 new ItemStack(Material.IRON_SWORD), //T4
new ItemStack(Material.STONE_SWORD), //T5 new ItemStack(Material.IRON_SWORD), //T5
new ItemStack(Material.IRON_SWORD), //T6 new ItemStack(Material.IRON_SWORD), //T6
new ItemStack(Material.IRON_SWORD), //T7 new ItemStack(Material.DIAMOND_SWORD), //T7
new ItemStack(Material.IRON_SWORD), //T8 new ItemStack(Material.DIAMOND_SWORD), //T8
new ItemStack(Material.DIAMOND_SWORD), //T9 new ItemStack(Material.DIAMOND_SWORD), //T9
new ItemStack(Material.DIAMOND_SWORD), //T10 new ItemStack(Material.DIAMOND_SWORD), //T10
}, },
@ -63,27 +64,27 @@ public enum ArtifactItemType {
}), }),
PICKAXE(2,"PICKAXE",TierType.ALL,UpgradePath.PICKAXE,new String[]{"EEE","xEx","xEx"}, PICKAXE(2,"PICKAXE",TierType.ALL,UpgradePath.PICKAXE,new String[]{"EEE","xEx","xEx"},
new ItemStack[]{ new ItemStack[]{
new ItemStack(Material.GOLD_PICKAXE), //T1 new ItemStack(Material.STONE_PICKAXE), //T1
new ItemStack(Material.WOOD_PICKAXE), //T2 new ItemStack(Material.STONE_PICKAXE), //T2
new ItemStack(Material.WOOD_PICKAXE), //T3 new ItemStack(Material.STONE_PICKAXE), //T3
new ItemStack(Material.STONE_PICKAXE), //T4 new ItemStack(Material.IRON_PICKAXE), //T4
new ItemStack(Material.STONE_PICKAXE), //T5 new ItemStack(Material.IRON_PICKAXE), //T5
new ItemStack(Material.IRON_PICKAXE), //T6 new ItemStack(Material.IRON_PICKAXE), //T6
new ItemStack(Material.IRON_PICKAXE), //T7 new ItemStack(Material.DIAMOND_PICKAXE), //T7
new ItemStack(Material.IRON_PICKAXE), //T8 new ItemStack(Material.DIAMOND_PICKAXE), //T8
new ItemStack(Material.DIAMOND_PICKAXE), //T9 new ItemStack(Material.DIAMOND_PICKAXE), //T9
new ItemStack(Material.DIAMOND_PICKAXE), //T10 new ItemStack(Material.DIAMOND_PICKAXE), //T10
}), }),
HOE(3,"SCYTHE",TierType.ALL,UpgradePath.SCYTHE,new String[]{"EEx","xEx","xEx"}, HOE(3,"SCYTHE",TierType.ALL,UpgradePath.SCYTHE,new String[]{"EEx","xEx","xEx"},
new ItemStack[]{ new ItemStack[]{
new ItemStack(Material.GOLD_HOE), //T1 new ItemStack(Material.STONE_HOE), //T1
new ItemStack(Material.WOOD_HOE), //T2 new ItemStack(Material.STONE_HOE), //T2
new ItemStack(Material.WOOD_HOE), //T3 new ItemStack(Material.STONE_HOE), //T3
new ItemStack(Material.STONE_HOE), //T4 new ItemStack(Material.IRON_HOE), //T4
new ItemStack(Material.STONE_HOE), //T5 new ItemStack(Material.IRON_HOE), //T5
new ItemStack(Material.IRON_HOE), //T6 new ItemStack(Material.IRON_HOE), //T6
new ItemStack(Material.IRON_HOE), //T7 new ItemStack(Material.DIAMOND_HOE), //T7
new ItemStack(Material.IRON_HOE), //T8 new ItemStack(Material.DIAMOND_HOE), //T8
new ItemStack(Material.DIAMOND_HOE), //T9 new ItemStack(Material.DIAMOND_HOE), //T9
new ItemStack(Material.DIAMOND_HOE), //T10 new ItemStack(Material.DIAMOND_HOE), //T10
}), }),
@ -102,14 +103,14 @@ public enum ArtifactItemType {
}), }),
SHOVEL(5,"SHOVEL",TierType.ALL,UpgradePath.SHOVEL,new String[]{"E","E","E"}, SHOVEL(5,"SHOVEL",TierType.ALL,UpgradePath.SHOVEL,new String[]{"E","E","E"},
new ItemStack[]{ new ItemStack[]{
new ItemStack(Material.GOLD_SPADE), //T1 new ItemStack(Material.STONE_SPADE), //T1
new ItemStack(Material.WOOD_SPADE), //T2 new ItemStack(Material.STONE_SPADE), //T2
new ItemStack(Material.WOOD_SPADE), //T3 new ItemStack(Material.STONE_SPADE), //T3
new ItemStack(Material.STONE_SPADE), //T4 new ItemStack(Material.IRON_SPADE), //T4
new ItemStack(Material.STONE_SPADE), //T5 new ItemStack(Material.IRON_SPADE), //T5
new ItemStack(Material.IRON_SPADE), //T6 new ItemStack(Material.IRON_SPADE), //T6
new ItemStack(Material.IRON_SPADE), //T7 new ItemStack(Material.DIAMOND_SPADE), //T7
new ItemStack(Material.IRON_SPADE), //T8 new ItemStack(Material.DIAMOND_SPADE), //T8
new ItemStack(Material.DIAMOND_SPADE), //T9 new ItemStack(Material.DIAMOND_SPADE), //T9
new ItemStack(Material.DIAMOND_SPADE), //T10 new ItemStack(Material.DIAMOND_SPADE), //T10
}), }),

View File

@ -1924,4 +1924,88 @@ public class GenericFunctions {
sender.sendMessage(ErrorMessage); sender.sendMessage(ErrorMessage);
TwosideKeeper.log(ErrorMessage, 1); TwosideKeeper.log(ErrorMessage, 1);
} }
public static ChatColor getDeathMarkColor(int stacks) {
if (stacks<3) {
return ChatColor.DARK_GREEN;
} else
if (stacks<6) {
return ChatColor.GREEN;
} else
if (stacks<10) {
return ChatColor.YELLOW;
} else
if (stacks<15) {
return ChatColor.GOLD;
} else
if (stacks<20) {
return ChatColor.RED;
} else
if (stacks<30) {
return ChatColor.DARK_RED;
} else {
return ChatColor.DARK_GRAY;
}
}
public static void ApplyDeathMark(LivingEntity ent) {
int stackamt = 0;
if (ent.hasPotionEffect(PotionEffectType.UNLUCK)) {
//Add to the current stack of unluck.
for (int i1=0;i1<ent.getActivePotionEffects().size();i1++) {
if (Iterables.get(ent.getActivePotionEffects(), i1).getType().equals(PotionEffectType.UNLUCK)) {
int lv = Iterables.get(ent.getActivePotionEffects(), i1).getAmplifier();
ent.removePotionEffect(PotionEffectType.UNLUCK);
TwosideKeeper.log("Death mark stack is now T"+(lv+1), 5);
stackamt=lv+2;
ent.addPotionEffect(new PotionEffect(PotionEffectType.UNLUCK,99,lv+1));
break;
}
}
} else {
ent.removePotionEffect(PotionEffectType.UNLUCK);
TwosideKeeper.log("Death mark stack is now T1", 5);
ent.addPotionEffect(new PotionEffect(PotionEffectType.UNLUCK,99,0));
stackamt=1;
}
//Modify the color of the name of the monster.
if (ent instanceof Monster) {
Monster m = (Monster)ent;
m.setCustomNameVisible(true);
if (m.getCustomName()!=null) {
m.setCustomName(getDeathMarkColor(stackamt)+ChatColor.stripColor(m.getCustomName()));
} else {
m.setCustomName(getDeathMarkColor(stackamt)+CapitalizeFirstLetters(m.getType().toString().replace("_", " ")));
}
}
}
public static int GetDeathMarkAmt(LivingEntity ent) {
if (ent.hasPotionEffect(PotionEffectType.UNLUCK)) {
//Add to the current stack of unluck.
for (int i1=0;i1<ent.getActivePotionEffects().size();i1++) {
if (Iterables.get(ent.getActivePotionEffects(), i1).getType().equals(PotionEffectType.UNLUCK)) {
return Iterables.get(ent.getActivePotionEffects(), i1).getAmplifier()+1;
}
}
}
return 0;
}
public static void ResetMobName(LivingEntity ent) {
if (ent instanceof Monster) {
Monster m = (Monster)ent;
m.setCustomNameVisible(false);
m.setCustomName(ChatColor.stripColor(m.getCustomName()));
if (m.getCustomName().contains("Dangerous")) {
m.setCustomName(ChatColor.DARK_AQUA+m.getCustomName());
}
if (m.getCustomName().contains("Deadly")) {
m.setCustomName(ChatColor.GOLD+m.getCustomName());
}
if (m.getCustomName().contains("Hellfire")) {
m.setCustomName(ChatColor.DARK_RED+m.getCustomName());
}
}
}
} }

View File

@ -53,6 +53,7 @@ public class PlayerStructure {
public int pickeditems=-1; public int pickeditems=-1;
public boolean sounds_enabled=true; public boolean sounds_enabled=true;
public double velocity; public double velocity;
public long last_deathmark=TwosideKeeper.getServerTickTime();
public double prev_weapondmg=0.0; public double prev_weapondmg=0.0;
public double prev_buffdmg=0.0; public double prev_buffdmg=0.0;
@ -85,6 +86,7 @@ public class PlayerStructure {
this.title_task=-1; this.title_task=-1;
this.sounds_enabled=true; this.sounds_enabled=true;
this.debuffcount=0; this.debuffcount=0;
this.last_deathmark=TwosideKeeper.getServerTickTime();
//Set defaults first, in case this is a new user. //Set defaults first, in case this is a new user.
loadConfig(); loadConfig();

View File

@ -31,6 +31,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Bat; import org.bukkit.entity.Bat;
import org.bukkit.entity.ComplexLivingEntity; import org.bukkit.entity.ComplexLivingEntity;
@ -259,7 +260,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
sig.plugin.TwosideKeeper.Recipes.Initialize_ArtifactHelper_Recipes(); sig.plugin.TwosideKeeper.Recipes.Initialize_ArtifactHelper_Recipes();
sig.plugin.TwosideKeeper.Recipes.Initialize_Check_Recipe(); sig.plugin.TwosideKeeper.Recipes.Initialize_Check_Recipe();
Bukkit.createWorld(new WorldCreator("ItemCube")); //Bukkit.createWorld(new WorldCreator("ItemCube"));
filesave=getDataFolder(); //Store the location of where our data folder is. filesave=getDataFolder(); //Store the location of where our data folder is.
log("Data folder at "+filesave+".",3); log("Data folder at "+filesave+".",3);
@ -377,10 +378,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (SERVER_TYPE==ServerType.MAIN) { //Only perform this on the official servers. Test servers do not require constant updating. if (SERVER_TYPE==ServerType.MAIN) { //Only perform this on the official servers. Test servers do not require constant updating.
//Every 5 minutes, check for a plugin update. //Every 5 minutes, check for a plugin update.
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){ Bukkit.getScheduler().scheduleSyncRepeatingTask(this, pluginupdater, 20*300, 20*300);
public void run(){
pluginupdater.FetchPlugins();
}}, 20*300, 20*300);
} }
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){ getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
@ -658,6 +656,29 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
MalleableBaseQuest.getTimeStarted(p.getEquipment().getItemInMainHand())<=147337849) { MalleableBaseQuest.getTimeStarted(p.getEquipment().getItemInMainHand())<=147337849) {
p.getEquipment().setItemInMainHand(MalleableBaseQuest.setTimeStarted(p.getEquipment().getItemInMainHand(), getServerTickTime())); p.getEquipment().setItemInMainHand(MalleableBaseQuest.setTimeStarted(p.getEquipment().getItemInMainHand(), getServerTickTime()));
} }
if (GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) &&
p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK)<=3) {
//Change the tool to Stone. If possible.
if (p.getEquipment().getItemInMainHand().getType().toString().contains("SWORD")) {
p.getEquipment().getItemInMainHand().setType(Material.STONE_SWORD);
}else
if (p.getEquipment().getItemInMainHand().getType().toString().contains("PICKAXE")) {
p.getEquipment().getItemInMainHand().setType(Material.STONE_PICKAXE);
}else
if (p.getEquipment().getItemInMainHand().getType().toString().contains("AXE")) {
p.getEquipment().getItemInMainHand().setType(Material.STONE_AXE);
}else
if (p.getEquipment().getItemInMainHand().getType().toString().contains("HOE")) {
p.getEquipment().getItemInMainHand().setType(Material.STONE_HOE);
}else
if (p.getEquipment().getItemInMainHand().getType().toString().contains("SPADE")) {
p.getEquipment().getItemInMainHand().setType(Material.STONE_SPADE);
}
}
if (SERVER_TYPE==ServerType.TEST || SERVER_TYPE==ServerType.QUIET) { if (SERVER_TYPE==ServerType.TEST || SERVER_TYPE==ServerType.QUIET) {
//ItemStack item = p.getEquipment().getItemInMainHand(); //ItemStack item = p.getEquipment().getItemInMainHand();
@ -668,7 +689,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
return true; return true;
} else } else
if (cmd.getName().equalsIgnoreCase("money")) { if (cmd.getName().equalsIgnoreCase("money")) {
sender.sendMessage("You are currently holding "+ChatColor.GREEN+"$"+df.format(getPlayerMoney((Player)sender))); sender.sendMessage("You are currently holding "+ChatColor.GREEN+"$"+df.format(getPlayerMoney(Bukkit.getPlayer(sender.getName()))));
return true; return true;
} else } else
if (cmd.getName().equalsIgnoreCase("enchant_advanced")) { if (cmd.getName().equalsIgnoreCase("enchant_advanced")) {
@ -896,8 +917,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//MESSAGE: Sound.NOTE_STICKS, 0.6f, 0.85f); //MESSAGE: Sound.NOTE_STICKS, 0.6f, 0.85f);
} }
} }
if (SERVER_TYPE==ServerType.MAIN && !restarting_server) { if (SERVER_TYPE==ServerType.MAIN && !restarting_server) {
pluginupdater.FetchPlugins(); Bukkit.getScheduler().scheduleSyncDelayedTask(this, pluginupdater,1);
} }
playerdata.put(ev.getPlayer().getUniqueId(), new PlayerStructure(ev.getPlayer(),getServerTickTime())); playerdata.put(ev.getPlayer().getUniqueId(), new PlayerStructure(ev.getPlayer(),getServerTickTime()));
log("[TASK] New Player Data has been added. Size of array: "+playerdata.size(),4); log("[TASK] New Player Data has been added. Size of array: "+playerdata.size(),4);
@ -994,67 +1016,18 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
Integer value=Integer.parseInt(ev.getMessage()); Integer value=Integer.parseInt(ev.getMessage());
if (value>=1) { if (value>=1) {
if (thisp.getLevel()>=value) { if (aPlugin.API.getTotalExperience(thisp)>=value) {
//Take that amount of exp away from the player. Give them money in return. double amtgained=value/100d;
int startlv = thisp.getLevel();
double amtgained=0;
for (int i=startlv;i>=startlv-value;i--) {
switch (i) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
{
amtgained = (2*i+7)*XP_CONVERSION_RATE;
givePlayerMoney(thisp,amtgained); givePlayerMoney(thisp,amtgained);
}break; aPlugin.API.setTotalExperience(thisp, aPlugin.API.getTotalExperience(thisp)-value);
case 17: ev.getPlayer().sendMessage(ChatColor.GOLD+"CONVERSION COMPLETE!"+ChatColor.WHITE+" Converted "+value+" experience points into "+ChatColor.YELLOW+"$"+df.format(amtgained)+ChatColor.WHITE+".");
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
case 25:
case 26:
case 27:
case 28:
case 29:
case 30:
case 31:
{
amtgained = (5*i-38)*XP_CONVERSION_RATE;
givePlayerMoney(thisp,amtgained);
}break;
default:{
amtgained = (9*i-158)*XP_CONVERSION_RATE;
givePlayerMoney(thisp,amtgained);
}
}
}
thisp.setLevel(thisp.getLevel()-value);
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()))); ev.getPlayer().sendMessage(" Now Holding: "+ChatColor.BLUE+"$"+df.format(getPlayerMoney(ev.getPlayer())));
} else { } 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."); thisp.sendMessage(ChatColor.RED+"You do not have that many experience points. You can convert up to "+ChatColor.WHITE+thisp.getLevel()+ChatColor.RED+" experience points.");
thisp.sendMessage(ChatColor.WHITE+" Cancelled out of Conversion terminal."); thisp.sendMessage(ChatColor.WHITE+" Cancelled out of Conversion terminal.");
} }
} else { } else {
thisp.sendMessage(ChatColor.RED+"You must convert at least "+ChatColor.WHITE+"1 level."); thisp.sendMessage(ChatColor.RED+"You must convert at least "+ChatColor.WHITE+"1 experience point.");
thisp.sendMessage(ChatColor.WHITE+" Cancelled out of Conversion terminal."); thisp.sendMessage(ChatColor.WHITE+" Cancelled out of Conversion terminal.");
} }
} else { } else {
@ -1568,6 +1541,49 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.getPlayer().sendMessage(ChatColor.DARK_BLUE+"New Recycling Center successfully created at "+ev.getClickedBlock().getLocation().toString()); ev.getPlayer().sendMessage(ChatColor.DARK_BLUE+"New Recycling Center successfully created at "+ev.getClickedBlock().getLocation().toString());
} }
//Check for a Scythe right click here.
if ((ev.getAction()==Action.RIGHT_CLICK_AIR || ev.getAction()==Action.RIGHT_CLICK_BLOCK) &&
GenericFunctions.isArtifactEquip(player.getEquipment().getItemInMainHand())) {
PlayerStructure pd = (PlayerStructure)playerdata.get(player.getUniqueId()); //Make sure it's off cooldown.
if (pd.last_deathmark+240<getServerTickTime()) {
boolean bursted=false;
if (ArtifactAbility.getEnchantmentLevel(ArtifactAbility.DEATHMARK, player.getEquipment().getItemInMainHand())>0) {
double dmg = ArtifactAbility.calculateValue(ArtifactAbility.DEATHMARK, player.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.DEATHMARK, player.getEquipment().getItemInMainHand()));
//Look for nearby mobs up to 10 blocks away.
List<Entity> nearby = player.getNearbyEntities(10, 10, 10);
for (int i=0;i<nearby.size();i++) {
if (nearby.get(i) instanceof Monster) {
Monster m = (Monster)nearby.get(i);
if (m.hasPotionEffect(PotionEffectType.UNLUCK) && !m.isDead()) {
//This has stacks, burst!
bursted=true;
aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), 240);
pd.last_deathmark = getServerTickTime();
int stackamt = GenericFunctions.GetDeathMarkAmt(m);
if (stackamt*dmg<m.getHealth()) {
m.setTarget(player);
m.damage(0.01,player);
m.setHealth(m.getHealth()-(stackamt*dmg));
m.setTarget(player);
} else {
//It's dead, kill it.
m.setTarget(player);
m.damage(0.01,player);
m.setHealth(0);
}
m.removePotionEffect(PotionEffectType.UNLUCK);
player.playSound(m.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f);
}
}
}
}
if (bursted) {
//Cancel this then, because we decided to burst our stacks instead.
ev.setCancelled(true);
}
}
}
//Check stuff here. //Check stuff here.
if (ev.getAction()==Action.RIGHT_CLICK_AIR || if (ev.getAction()==Action.RIGHT_CLICK_AIR ||
ev.getAction()==Action.RIGHT_CLICK_BLOCK) { ev.getAction()==Action.RIGHT_CLICK_BLOCK) {
@ -2064,7 +2080,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
banksessions.put(ev.getPlayer().getUniqueId(), bs); banksessions.put(ev.getPlayer().getUniqueId(), bs);
} }
ev.getPlayer().sendMessage(ChatColor.GOLD+"Say/Type the amount of experience you want to convert today."); ev.getPlayer().sendMessage(ChatColor.GOLD+"Say/Type the amount of experience you want to convert today.");
ev.getPlayer().sendMessage(" Currently Have: "+ChatColor.GREEN+ev.getPlayer().getLevel()+" levels"); ev.getPlayer().sendMessage(" Currently Have: "+ChatColor.GREEN+aPlugin.API.getTotalExperience(ev.getPlayer())+" experience points");
} else } else
if (s.getLine(1).equalsIgnoreCase(ChatColor.DARK_GREEN+"CASH CHECK")) { if (s.getLine(1).equalsIgnoreCase(ChatColor.DARK_GREEN+"CASH CHECK")) {
if (Check.isSignedBankCheck(ev.getPlayer().getEquipment().getItemInMainHand())) { if (Check.isSignedBankCheck(ev.getPlayer().getEquipment().getItemInMainHand())) {
@ -2139,7 +2155,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setCancelled(true); ev.setCancelled(true);
} }
if (Artifact.isArtifact(ev.getItemInHand())) { if (Artifact.isArtifact(ev.getItemInHand()) && !GenericFunctions.isArtifactEquip(ev.getItemInHand())) {
ev.setCancelled(true); ev.setCancelled(true);
} }
} }
@ -2321,7 +2337,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
double amounttotake = DeathManager.CountOccupiedSlots(p.getInventory())*DeathManager.CalculateDeathPrice(p); double amounttotake = DeathManager.CountOccupiedSlots(p.getInventory())*DeathManager.CalculateDeathPrice(p);
if (getPlayerMoney(p)>=amounttotake) { if (getPlayerMoney(p)>=amounttotake) {
givePlayerMoney(p,getPlayerMoney(p)-amounttotake); givePlayerMoney(p,-amounttotake);
} else { } else {
double diff = amounttotake-getPlayerMoney(p); double diff = amounttotake-getPlayerMoney(p);
givePlayerMoney(p,-getPlayerMoney(p)); givePlayerMoney(p,-getPlayerMoney(p));
@ -3281,6 +3297,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setDamage(DamageModifier.MAGIC,0); ev.setDamage(DamageModifier.MAGIC,0);
ev.setDamage(DamageModifier.RESISTANCE,0); ev.setDamage(DamageModifier.RESISTANCE,0);
ev.setDamage(DamageModifier.ARMOR,0); ev.setDamage(DamageModifier.ARMOR,0);
ev.setDamage(DamageModifier.ABSORPTION,0);
int dmgmult = 1; int dmgmult = 1;
@ -3300,13 +3317,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
mm.setTarget(p); mm.setTarget(p);
} }
ev.setDamage(CalculateDamageReduction(ev.getDamage()*dmgmult*ENEMY_DMG_MULT,p,m)); double rawdmg = ev.getDamage()*dmgmult*ENEMY_DMG_MULT;
ev.setDamage(CalculateDamageReduction(rawdmg,p,m));
//Artifact armor will receive EXP. //Artifact armor will receive EXP.
for (int i=0;i<p.getEquipment().getArmorContents().length;i++) { for (int i=0;i<p.getEquipment().getArmorContents().length;i++) {
if (GenericFunctions.isArtifactEquip(p.getEquipment().getArmorContents()[i]) && if (GenericFunctions.isArtifactEquip(p.getEquipment().getArmorContents()[i]) &&
GenericFunctions.isArtifactArmor(p.getEquipment().getArmorContents()[i])) { GenericFunctions.isArtifactArmor(p.getEquipment().getArmorContents()[i])) {
AwakenedArtifact.addPotentialEXP(p.getEquipment().getArmorContents()[i], (int)ev.getFinalDamage()*5, p); AwakenedArtifact.addPotentialEXP(p.getEquipment().getArmorContents()[i], (int)rawdmg, p);
} }
} }
@ -3377,11 +3395,59 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
double ratio = 1.0-CalculateDamageReduction(1,m,p);
if (GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) && if (GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) &&
GenericFunctions.isArtifactWeapon(p.getEquipment().getItemInMainHand())) { GenericFunctions.isArtifactWeapon(p.getEquipment().getItemInMainHand())) {
double ratio = 1.0-CalculateDamageReduction(1,m,p);
log("EXP ratio is "+ratio,5); log("EXP ratio is "+ratio,5);
AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), (int)(ratio*20)+5, p); AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), (int)(ratio*20)+5, p);
List<LivingEntity> hitlist = new ArrayList<LivingEntity>();
//Apply Death mark to these mobs that got hit.
boolean applyDeathmark=false;
if (ArtifactAbility.getEnchantmentLevel(ArtifactAbility.DEATHMARK, p.getEquipment().getItemInMainHand())>0) {
hitlist.add(m);
applyDeathmark=true;
GenericFunctions.ApplyDeathMark(m);
}
//Deal AoE damage.
double checkrange = ArtifactAbility.calculateValue(ArtifactAbility.AOE, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.AOE, p.getEquipment().getItemInMainHand()));
List<Entity> entities = m.getNearbyEntities(checkrange, checkrange, checkrange);
for (int i=0;i<entities.size();i++) {
if (entities.get(i) instanceof Monster || entities.get(i) instanceof Animals) {
LivingEntity ent = (LivingEntity)entities.get(i);
DealDamageToMob(p.getInventory().getItemInMainHand(),p,ent);
if (ent instanceof Monster) {
if (!ent.hasPotionEffect(PotionEffectType.GLOWING)) {
((Monster)ent).setTarget(p);
}
if (applyDeathmark) {
hitlist.add(ent);
GenericFunctions.ApplyDeathMark(ent);
}
}
AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), (int)(ratio*20)+5, p);
ent.damage(0.01);
}
}
final List<LivingEntity> finallist = hitlist;
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
for (int i=0;i<finallist.size();i++) {
LivingEntity le = finallist.get(i);
if (le!=null && !le.isDead() && !le.hasPotionEffect(PotionEffectType.UNLUCK)) {
GenericFunctions.ResetMobName(le);
//They don't have death marks anymore, so we just remove their name color.
}
}
}}
,100);
}
//Artifact armor will receive a tiny bit of EXP.
for (int i=0;i<p.getEquipment().getArmorContents().length;i++) {
if (GenericFunctions.isArtifactEquip(p.getEquipment().getArmorContents()[i]) &&
GenericFunctions.isArtifactArmor(p.getEquipment().getArmorContents()[i])) {
AwakenedArtifact.addPotentialEXP(p.getEquipment().getArmorContents()[i], (int)(ratio*10)+1, p);
}
} }
//ev.setCancelled(true); //ev.setCancelled(true);
@ -3406,6 +3472,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setDamage(DamageModifier.MAGIC,0); ev.setDamage(DamageModifier.MAGIC,0);
ev.setDamage(DamageModifier.RESISTANCE,0); ev.setDamage(DamageModifier.RESISTANCE,0);
ev.setDamage(DamageModifier.ARMOR,0); ev.setDamage(DamageModifier.ARMOR,0);
ev.setDamage(DamageModifier.ABSORPTION,0);
int dmgmult = 1; int dmgmult = 1;
@ -3429,13 +3496,15 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
log("Original damage: "+ev.getDamage(),5); log("Original damage: "+ev.getDamage(),5);
log("Modified damage: "+ev.getDamage()*dmgmult*ENEMY_DMG_MULT,4); log("Modified damage: "+ev.getDamage()*dmgmult*ENEMY_DMG_MULT,4);
ev.setDamage(CalculateDamageReduction(ev.getDamage()*dmgmult*ENEMY_DMG_MULT,p,ev.getDamager())); double rawdmg = ev.getDamage()*dmgmult*ENEMY_DMG_MULT;
ev.setDamage(CalculateDamageReduction(rawdmg,p,ev.getDamager()));
for (int i=0;i<p.getEquipment().getArmorContents().length;i++) { for (int i=0;i<p.getEquipment().getArmorContents().length;i++) {
if (GenericFunctions.isArtifactEquip(p.getEquipment().getArmorContents()[i]) && if (GenericFunctions.isArtifactEquip(p.getEquipment().getArmorContents()[i]) &&
GenericFunctions.isArtifactArmor(p.getEquipment().getArmorContents()[i])) { GenericFunctions.isArtifactArmor(p.getEquipment().getArmorContents()[i])) {
AwakenedArtifact.addPotentialEXP(p.getEquipment().getArmorContents()[i], (int)ev.getFinalDamage(), p); AwakenedArtifact.addPotentialEXP(p.getEquipment().getArmorContents()[i], (int)rawdmg, p);
} }
} }
@ -3510,14 +3579,21 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setDamage(CalculateDamageReduction(ev.getDamage(),m,p)+truedmg); ev.setDamage(CalculateDamageReduction(ev.getDamage(),m,p)+truedmg);
log("Reduced damage is "+ev.getDamage(),5); log("Reduced damage is "+ev.getDamage(),5);
double ratio = 1.0-CalculateDamageReduction(1,m,p);
if (GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) && if (GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) &&
GenericFunctions.isArtifactWeapon(p.getEquipment().getItemInMainHand())) { GenericFunctions.isArtifactWeapon(p.getEquipment().getItemInMainHand())) {
double ratio = 1.0-CalculateDamageReduction(1,m,p);
log("EXP ratio is "+ratio,5); log("EXP ratio is "+ratio,5);
AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), (int)(ratio*20), p); AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), (int)(ratio*20), p);
} }
//Artifact armor will receive a tiny bit of EXP.
for (int i=0;i<p.getEquipment().getArmorContents().length;i++) {
if (GenericFunctions.isArtifactEquip(p.getEquipment().getArmorContents()[i]) &&
GenericFunctions.isArtifactArmor(p.getEquipment().getArmorContents()[i])) {
AwakenedArtifact.addPotentialEXP(p.getEquipment().getArmorContents()[i], (int)(ratio*10)+1, p);
}
}
//Make this monster the player's new target. //Make this monster the player's new target.
PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId()); PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
//Found the player structure. Set the target. //Found the player structure. Set the target.
@ -3939,35 +4015,40 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (armor.getType().toString().contains("BOOTS") && if (armor.getType().toString().contains("BOOTS") &&
p.getEquipment().getBoots()==null) { p.getEquipment().getBoots()==null) {
p.getEquipment().setBoots(armor); p.getEquipment().setBoots(armor);
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(ev.getItem().getItemStack())); p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(ev.getItem().getItemStack().getItemMeta().hasDisplayName()?ev.getItem().getItemStack().getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(ev.getItem().getItemStack())));
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
ev.getItem().remove(); ev.getItem().remove();
ev.setCancelled(true); ev.setCancelled(true);
} else } else
if (armor.getType().toString().contains("LEGGINGS") && if (armor.getType().toString().contains("LEGGINGS") &&
p.getEquipment().getLeggings()==null) { p.getEquipment().getLeggings()==null) {
p.getEquipment().setLeggings(armor); p.getEquipment().setLeggings(armor);
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(ev.getItem().getItemStack())); p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(ev.getItem().getItemStack().getItemMeta().hasDisplayName()?ev.getItem().getItemStack().getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(ev.getItem().getItemStack())));
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
ev.getItem().remove(); ev.getItem().remove();
ev.setCancelled(true); ev.setCancelled(true);
} else } else
if (armor.getType().toString().contains("CHESTPLATE") && if (armor.getType().toString().contains("CHESTPLATE") &&
p.getEquipment().getChestplate()==null) { p.getEquipment().getChestplate()==null) {
p.getEquipment().setChestplate(armor); p.getEquipment().setChestplate(armor);
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(ev.getItem().getItemStack())); p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(ev.getItem().getItemStack().getItemMeta().hasDisplayName()?ev.getItem().getItemStack().getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(ev.getItem().getItemStack())));
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
ev.getItem().remove(); ev.getItem().remove();
ev.setCancelled(true); ev.setCancelled(true);
} else } else
if (armor.getType().toString().contains("HELMET") && if (armor.getType().toString().contains("HELMET") &&
p.getEquipment().getHelmet()==null) { p.getEquipment().getHelmet()==null) {
p.getEquipment().setHelmet(armor); p.getEquipment().setHelmet(armor);
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(ev.getItem().getItemStack())); p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(ev.getItem().getItemStack().getItemMeta().hasDisplayName()?ev.getItem().getItemStack().getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(ev.getItem().getItemStack())));
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
ev.getItem().remove(); ev.getItem().remove();
ev.setCancelled(true); ev.setCancelled(true);
} else } else
if (armor.getType().toString().contains("SHIELD") && if (armor.getType().toString().contains("SHIELD") &&
p.getEquipment().getItemInOffHand()==null) { p.getInventory().getExtraContents()[0]==null) {
p.getEquipment().setItemInOffHand(armor); p.getInventory().setExtraContents(new ItemStack[]{armor});
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(ev.getItem().getItemStack())); p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(ev.getItem().getItemStack().getItemMeta().hasDisplayName()?ev.getItem().getItemStack().getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(ev.getItem().getItemStack())));
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
ev.getItem().remove(); ev.getItem().remove();
ev.setCancelled(true); ev.setCancelled(true);
} }
@ -4270,14 +4351,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
if (items_found==2 && slot_found!=0 && ev.getInventory().getResult().getType()!=null && ev.getInventory().getResult().getType()!=Material.AIR) { if (items_found==2 && slot_found!=0 && ev.getInventory().getResult().getType()!=null && ev.getInventory().getResult().getType()!=Material.AIR) {
log("Artifact tier: "+artifact_tier+", Tier Found: "+tier_found,2); log("Artifact tier: "+artifact_tier+", Tier Found: "+tier_found,2);
if (artifact_tier+1!=tier_found) { if (artifact_tier!=tier_found || tier_found==10) {
ev.getInventory().setResult(new ItemStack(Material.AIR)); ev.getInventory().setResult(new ItemStack(Material.AIR));
} else { } else {
ItemStack newitem = ArtifactItemType.getTypeFromData(ev.getInventory().getItem(slot_found).getDurability()).getTieredItem(tier_found); ItemStack newitem = ArtifactItemType.getTypeFromData(ev.getInventory().getItem(slot_found).getDurability()).getTieredItem(tier_found+1);
//Add more information for this. //Add more information for this.
ItemStack newartifact = AwakenedArtifact.convertToAwakenedArtifact(newitem, tier_found, ev.getInventory().getItem(slot_found).getDurability()).clone(); ItemStack newartifact = AwakenedArtifact.convertToAwakenedArtifact(newitem, tier_found+1, ev.getInventory().getItem(slot_found).getDurability()).clone();
List<String> transferlore = artifact_item.getItemMeta().getLore(); List<String> transferlore = artifact_item.getItemMeta().getLore();
ItemMeta m = newartifact.getItemMeta(); ItemMeta m = newartifact.getItemMeta();
m.setLore(transferlore); m.setLore(transferlore);
@ -5036,7 +5117,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (GenericFunctions.isDefender(p)) { if (GenericFunctions.isDefender(p)) {
hp+=10; hp+=10;
p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,40,(p.isBlocking())?1:0)); p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,60,(p.isBlocking())?1:0));
}
if (p.hasPotionEffect(PotionEffectType.ABSORPTION)) {
Collection<PotionEffect> player_effects = p.getActivePotionEffects();
for (int i=0;i<player_effects.size();i++) {
if (Iterables.get(player_effects, i).getType().equals(PotionEffectType.ABSORPTION)) {
hp += (Iterables.get(player_effects, i).getAmplifier()+1)*4;
}
}
} }
p.setMaxHealth(hp); p.setMaxHealth(hp);