Artifact Crafting System now exists! Misc. Bugfixes relating to anvil

naming. MalleableBaseQuest now handles multiple forming items at the
same time. Zombie Leaders accurately labeled now deeper underground.
Damage Reduction and Base Damage notifications do not appear as often
now. Only under substantial changes to damage or reduction to reduce
spam. All related artifact recipes have been added. Loot tables updated
to reflect new availability of Artifact Crafting drops. Malleable Base
Drop now scales with the resource obtained for it. Fixed a drop not
properly appearing from Wither Skeletons. Updated API and generic
functions to include a new hardened item notification along with more
fixes to naming functions and more support methods. Added
GetModifiedDamage() to API.
dev
sigonasr2 9 years ago
parent ee6784447a
commit f453499468
  1. BIN
      TwosideKeeper.jar
  2. 4
      src/plugin.yml
  3. 87
      src/sig/plugin/TwosideKeeper/Artifact.java
  4. 3
      src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactItem.java
  5. 618
      src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactItemType.java
  6. 118
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java
  7. 24
      src/sig/plugin/TwosideKeeper/HelperStructures/MalleableBaseQuest.java
  8. 2
      src/sig/plugin/TwosideKeeper/HelperStructures/MonsterType.java
  9. 4
      src/sig/plugin/TwosideKeeper/MonsterController.java
  10. 2
      src/sig/plugin/TwosideKeeper/Party.java
  11. 5
      src/sig/plugin/TwosideKeeper/PlayerStructure.java
  12. 78
      src/sig/plugin/TwosideKeeper/Recipes.java
  13. 742
      src/sig/plugin/TwosideKeeper/TwosideKeeper.java
  14. 11
      src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java

Binary file not shown.

@ -1,6 +1,6 @@
name: TwosideKeeper name: TwosideKeeper
main: sig.plugin.TwosideKeeper.TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper
version: 3.3.5 version: 3.4
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.
@ -24,7 +24,7 @@ commands:
permission-message: No permissions! permission-message: No permissions!
artifact: artifact:
description: Gives the player an artifact. description: Gives the player an artifact.
usage: /artifact <ArtifactType> usage: /artifact <ArtifactType> [amt]
permission: TwosideKeeper.artifact permission: TwosideKeeper.artifact
permission-message: No permissions! permission-message: No permissions!
recyclingcenter: recyclingcenter:

@ -11,6 +11,8 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.MaterialData; import org.bukkit.material.MaterialData;
import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem; import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem;
import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItemType;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
public class Artifact { public class Artifact {
public static ItemStack createArtifactItem(ArtifactItem type) { public static ItemStack createArtifactItem(ArtifactItem type) {
@ -58,6 +60,9 @@ public class Artifact {
case MYSTERIOUS_ESSENCE: case MYSTERIOUS_ESSENCE:
i=new ItemStack(Material.PUMPKIN_SEEDS); i=new ItemStack(Material.PUMPKIN_SEEDS);
break; break;
case ARTIFACT_RECIPE:
i=new ItemStack(Material.STAINED_GLASS_PANE);
break;
default: default:
i=new ItemStack(Material.AIR); i=new ItemStack(Material.AIR);
break; break;
@ -153,10 +158,26 @@ public class Artifact {
//Converts an item to an artifact. //Converts an item to an artifact.
return convert(item, ArtifactItem.ARTIFACT_ESSENCE, true); return convert(item, ArtifactItem.ARTIFACT_ESSENCE, true);
} }
public static ItemStack convert_equip(ItemStack item, int tier, ArtifactItemType ait) {
//Converts an item to an artifact.
ItemMeta m = item.getItemMeta();
List<String> l = new ArrayList<String>();
if (item.getItemMeta().hasLore()) {
l = item.getItemMeta().getLore();
}
l.add(ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+ChatColor.RESET+ChatColor.GOLD+" "+GenericFunctions.CapitalizeFirstLetters(ait.getItemName())+" Artifact");
l.add(ChatColor.GOLD+""+ChatColor.ITALIC+"Artifact Item");
m.setLore(l);
item.setItemMeta(m);
item.addUnsafeEnchantment(Enchantment.LUCK, tier);
return item;
}
public static boolean isArtifact(ItemStack item) { public static boolean isArtifact(ItemStack item) {
if (item.hasItemMeta() && if (item.hasItemMeta() &&
item.getItemMeta().hasLore() && item.getItemMeta().hasLore() &&
item.getItemMeta().getLore().contains(ChatColor.GOLD+""+ChatColor.ITALIC+"Artifact Crafting Item")) { (item.getItemMeta().getLore().contains(ChatColor.GOLD+""+ChatColor.ITALIC+"Artifact Crafting Item") ||
item.getItemMeta().getLore().contains(ChatColor.GOLD+""+ChatColor.ITALIC+"Artifact Item"))) {
//This is an artifact. //This is an artifact.
return true; return true;
} else { } else {
@ -182,4 +203,68 @@ public class Artifact {
return false; return false;
} }
} }
/**
* This method adds in related information based on what type of recipe the item is.
* @param tier
* @param item
*/
public static ItemStack createRecipe(int tier, ArtifactItemType item) {
if (tier==0) {
ItemStack newitem = convert(new ItemStack(Material.STAINED_GLASS_PANE,1,(short)item.getDataValue()));
ItemMeta m = newitem.getItemMeta();
List<String> lore = m.getLore();
lore.add(0,ChatColor.YELLOW+"Base Crafting Recipe");
//lore.add(1,ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+ChatColor.RESET+ChatColor.GOLD+" "+GenericFunctions.CapitalizeFirstLetters(item.getItemName())+" Recipe");
m.setLore(lore);
m.setDisplayName(ChatColor.BOLD+"Base Artifact "+GenericFunctions.CapitalizeFirstLetters(item.getItemName())+" Recipe");
newitem.setItemMeta(m);
return newitem;
} else
{
ItemStack newitem = convert(new ItemStack(Material.STAINED_GLASS_PANE,1,(short)item.getDataValue()));
ItemMeta m = newitem.getItemMeta();
List<String> lore = m.getLore();
lore.add(0,ChatColor.YELLOW+GenericFunctions.CapitalizeFirstLetters(item.getItemName())+" Crafting Recipe");
lore.add(1,ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+ChatColor.RESET+ChatColor.GOLD+" "+GenericFunctions.CapitalizeFirstLetters(item.getItemName())+" Recipe");
m.setLore(lore);
m.setDisplayName(ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+ChatColor.RESET+ChatColor.GOLD+" Artifact "+GenericFunctions.CapitalizeFirstLetters(item.getItemName())+" Recipe");
newitem.setItemMeta(m);
return newitem;
}
}
public static String returnRawTool(Material type) {
if (type.toString().contains("PICKAXE")) {
return "PICKAXE";
} else
if (type.toString().contains("AXE")) {
return "AXE";
} else
if (type.toString().contains("SPADE")) {
return "SHOVEL";
} else
if (type.toString().contains("SWORD")) {
return "SWORD";
} else
if (type.toString().contains("BOW")) {
return "BOW";
} else
if (type.toString().contains("HOE")) {
return "HOE";
} else
if (type.toString().contains("CHESTPLATE")) {
return "CHESTPLATE";
} else
if (type.toString().contains("HELMET")) {
return "HELMET";
} else
if (type.toString().contains("LEGGINGS")) {
return "LEGGINGS";
} else
if (type.toString().contains("BOOTS")) {
return "BOOTS";
} else {
return "";
}
}
} }

@ -14,5 +14,6 @@ public enum ArtifactItem {
DIVINE_ESSENCE, DIVINE_ESSENCE,
DIVINE_CORE, DIVINE_CORE,
DIVINE_BASE, DIVINE_BASE,
MALLEABLE_BASE MALLEABLE_BASE,
ARTIFACT_RECIPE
} }

@ -0,0 +1,618 @@
package sig.plugin.TwosideKeeper.HelperStructures;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe;
import sig.plugin.TwosideKeeper.Artifact;
import sig.plugin.TwosideKeeper.TwosideKeeper;
public enum ArtifactItemType {
AXE(0,"AXE",TierType.ALL,UpgradePath.TOOL,new String[]{"EEx","EEx","xEx"},
new ItemStack[]{
new ItemStack(Material.GOLD_AXE), //T1
new ItemStack(Material.WOOD_AXE), //T2
new ItemStack(Material.WOOD_AXE), //T3
new ItemStack(Material.STONE_AXE), //T4
new ItemStack(Material.STONE_AXE), //T5
new ItemStack(Material.IRON_AXE), //T6
new ItemStack(Material.IRON_AXE), //T7
new ItemStack(Material.IRON_AXE), //T8
new ItemStack(Material.DIAMOND_AXE), //T9
new ItemStack(Material.DIAMOND_AXE), //T10
},
new double[]{
1.0d, //T1
1.5d, //T2
2.0d, //T3
2.5d, //T4
3.0d, //T5
3.5d, //T6
4.0d, //T7
4.5d, //T8
5.0d, //T9
6.0d //T10
}),
SWORD(1,"SWORD",TierType.ALL,UpgradePath.WEAPON,new String[]{"EEE","EEE","EEE"},
new ItemStack[]{
new ItemStack(Material.GOLD_SWORD), //T1
new ItemStack(Material.WOOD_SWORD), //T2
new ItemStack(Material.WOOD_SWORD), //T3
new ItemStack(Material.STONE_SWORD), //T4
new ItemStack(Material.STONE_SWORD), //T5
new ItemStack(Material.IRON_SWORD), //T6
new ItemStack(Material.IRON_SWORD), //T7
new ItemStack(Material.IRON_SWORD), //T8
new ItemStack(Material.DIAMOND_SWORD), //T9
new ItemStack(Material.DIAMOND_SWORD), //T10
},
new double[]{
2.0d, //T1
3.0d, //T2
4.0d, //T3
5.0d, //T4
6.0d, //T5
7.0d, //T6
8.0d, //T7
9.0d, //T8
10.0d, //T9
12.0d //T10
}),
PICKAXE(2,"PICKAXE",TierType.ALL,UpgradePath.TOOL,new String[]{"EEE","xEx","xEx"},
new ItemStack[]{
new ItemStack(Material.GOLD_PICKAXE), //T1
new ItemStack(Material.WOOD_PICKAXE), //T2
new ItemStack(Material.WOOD_PICKAXE), //T3
new ItemStack(Material.STONE_PICKAXE), //T4
new ItemStack(Material.STONE_PICKAXE), //T5
new ItemStack(Material.IRON_PICKAXE), //T6
new ItemStack(Material.IRON_PICKAXE), //T7
new ItemStack(Material.IRON_PICKAXE), //T8
new ItemStack(Material.DIAMOND_PICKAXE), //T9
new ItemStack(Material.DIAMOND_PICKAXE), //T10
}),
HOE(3,"HOE",TierType.ALL,UpgradePath.TOOL,new String[]{"EEx","xEx","xEx"},
new ItemStack[]{
new ItemStack(Material.GOLD_HOE), //T1
new ItemStack(Material.WOOD_HOE), //T2
new ItemStack(Material.WOOD_HOE), //T3
new ItemStack(Material.STONE_HOE), //T4
new ItemStack(Material.STONE_HOE), //T5
new ItemStack(Material.IRON_HOE), //T6
new ItemStack(Material.IRON_HOE), //T7
new ItemStack(Material.IRON_HOE), //T8
new ItemStack(Material.DIAMOND_HOE), //T9
new ItemStack(Material.DIAMOND_HOE), //T10
}),
BOW(4,"BOW",TierType.ONE,UpgradePath.BOW,new String[]{"EEx","ExE","EEx"},
new ItemStack[]{
new ItemStack(Material.BOW), //T1
new ItemStack(Material.BOW), //T2
new ItemStack(Material.BOW), //T3
new ItemStack(Material.BOW), //T4
new ItemStack(Material.BOW), //T5
new ItemStack(Material.BOW), //T6
new ItemStack(Material.BOW), //T7
new ItemStack(Material.BOW), //T8
new ItemStack(Material.BOW), //T9
new ItemStack(Material.BOW), //T10
}),
SHOVEL(5,"SPADE",TierType.ALL,UpgradePath.TOOL,new String[]{"E","E","E"},
new ItemStack[]{
new ItemStack(Material.GOLD_SPADE), //T1
new ItemStack(Material.WOOD_SPADE), //T2
new ItemStack(Material.WOOD_SPADE), //T3
new ItemStack(Material.STONE_SPADE), //T4
new ItemStack(Material.STONE_SPADE), //T5
new ItemStack(Material.IRON_SPADE), //T6
new ItemStack(Material.IRON_SPADE), //T7
new ItemStack(Material.IRON_SPADE), //T8
new ItemStack(Material.DIAMOND_SPADE), //T9
new ItemStack(Material.DIAMOND_SPADE), //T10
}),
HELMET(6,"HELMET",TierType.ARMOR,UpgradePath.ARMOR,new String[]{"EEE","ExE"},
new ItemStack[]{
new ItemStack(Material.LEATHER_HELMET), //T1
new ItemStack(Material.LEATHER_HELMET), //T2
new ItemStack(Material.GOLD_HELMET), //T3
new ItemStack(Material.IRON_HELMET), //T4
new ItemStack(Material.IRON_HELMET), //T5
new ItemStack(Material.IRON_HELMET), //T6
new ItemStack(Material.DIAMOND_HELMET), //T7
new ItemStack(Material.DIAMOND_HELMET), //T8
new ItemStack(Material.DIAMOND_HELMET), //T9
new ItemStack(Material.LEATHER_HELMET), //T10
},
new double[]{
3.75d, //T1
5.0d, //T2
6.25d, //T3
7.50d, //T4
8.75d, //T5
11.25d, //T6
13.75d, //T7
16.25d, //T8
18.75d, //T9
22.50d //T10
},
new int[]{
2, //T1
3, //T2
4, //T3
5, //T4
6, //T5
7, //T6
9, //T7
10, //T8
12, //T9
14 //T10
}),
CHESTPLATE(7,"CHESTPLATE",TierType.ARMOR,UpgradePath.ARMOR,new String[]{"ExE","EEE","EEE"},
new ItemStack[]{
new ItemStack(Material.LEATHER_CHESTPLATE), //T1
new ItemStack(Material.LEATHER_CHESTPLATE), //T2
new ItemStack(Material.GOLD_CHESTPLATE), //T3
new ItemStack(Material.IRON_CHESTPLATE), //T4
new ItemStack(Material.IRON_CHESTPLATE), //T5
new ItemStack(Material.IRON_CHESTPLATE), //T6
new ItemStack(Material.DIAMOND_CHESTPLATE), //T7
new ItemStack(Material.DIAMOND_CHESTPLATE), //T8
new ItemStack(Material.DIAMOND_CHESTPLATE), //T9
new ItemStack(Material.LEATHER_CHESTPLATE), //T10
},
new double[]{
3.75d, //T1
5.0d, //T2
6.25d, //T3
7.50d, //T4
8.75d, //T5
11.25d, //T6
13.75d, //T7
16.25d, //T8
18.75d, //T9
22.50d //T10
},
new int[]{
2, //T1
3, //T2
4, //T3
5, //T4
6, //T5
7, //T6
9, //T7
10, //T8
12, //T9
14 //T10
}),
LEGGINGS(8,"LEGGINGS",TierType.ARMOR,UpgradePath.ARMOR,new String[]{"EEE","ExE","ExE"},
new ItemStack[]{
new ItemStack(Material.LEATHER_LEGGINGS), //T1
new ItemStack(Material.LEATHER_LEGGINGS), //T2
new ItemStack(Material.GOLD_LEGGINGS), //T3
new ItemStack(Material.IRON_LEGGINGS), //T4
new ItemStack(Material.IRON_LEGGINGS), //T5
new ItemStack(Material.IRON_LEGGINGS), //T6
new ItemStack(Material.DIAMOND_LEGGINGS), //T7
new ItemStack(Material.DIAMOND_LEGGINGS), //T8
new ItemStack(Material.DIAMOND_LEGGINGS), //T9
new ItemStack(Material.LEATHER_LEGGINGS), //T10
},
new double[]{
3.75d, //T1
5.0d, //T2
6.25d, //T3
7.50d, //T4
8.75d, //T5
11.25d, //T6
13.75d, //T7
16.25d, //T8
18.75d, //T9
22.50d //T10
},
new int[]{
2, //T1
3, //T2
4, //T3
5, //T4
6, //T5
7, //T6
9, //T7
10, //T8
12, //T9
14 //T10
}),
BOOTS(9,"BOOTS",TierType.ARMOR,UpgradePath.ARMOR,new String[]{"ExE","ExE"},
new ItemStack[]{
new ItemStack(Material.LEATHER_BOOTS), //T1
new ItemStack(Material.LEATHER_BOOTS), //T2
new ItemStack(Material.GOLD_BOOTS), //T3
new ItemStack(Material.IRON_BOOTS), //T4
new ItemStack(Material.IRON_BOOTS), //T5
new ItemStack(Material.IRON_BOOTS), //T6
new ItemStack(Material.DIAMOND_BOOTS), //T7
new ItemStack(Material.DIAMOND_BOOTS), //T8
new ItemStack(Material.DIAMOND_BOOTS), //T9
new ItemStack(Material.LEATHER_BOOTS), //T10
},
new double[]{
3.75d, //T1
5.0d, //T2
6.25d, //T3
7.50d, //T4
8.75d, //T5
11.25d, //T6
13.75d, //T7
16.25d, //T8
18.75d, //T9
22.50d //T10
},
new int[]{
2, //T1
3, //T2
4, //T3
5, //T4
6, //T5
7, //T6
9, //T7
10, //T8
12, //T9
14 //T10
});
int data;
String itemname;
TierType tier;
UpgradePath upgrade;
String[] recipe;
ItemStack[] itemtiers;
double[] damageamt;
int[] healthamt;
ArtifactItemType(int dataval, String itemname, TierType tier, UpgradePath upgrade, String[] recipe, ItemStack[] itemtiers, double[] damageamt, int[] healthamt) {
ArtifactItemType(dataval,itemname,tier,upgrade,recipe,itemtiers,damageamt,healthamt);
}
ArtifactItemType(int dataval, String itemname, TierType tier, UpgradePath upgrade, String[] recipe, ItemStack[] itemtiers, double[] damageamt) {
ArtifactItemType(dataval,itemname,tier,upgrade,recipe,itemtiers,damageamt,new int[]{});
}
ArtifactItemType(int dataval, String itemname, TierType tier, UpgradePath upgrade, String[] recipe, ItemStack[] itemtiers) {
ArtifactItemType(dataval,itemname,tier,upgrade,recipe,itemtiers,new double[]{},new int[]{});
}
private void ArtifactItemType(int dataval, String itemname, TierType tier, UpgradePath upgrade, String[] recipe, ItemStack[] itemtiers, double[] damageamt, int[] healthamt) {
this.data=dataval;
this.itemname=itemname;
this.tier=tier;
this.upgrade=upgrade;
this.recipe=recipe;
this.itemtiers=itemtiers;
this.damageamt = damageamt;
this.healthamt = healthamt;
};
public int getDataValue() {
return this.data;
}
public String getItemName() {
return this.itemname;
}
public TierType getTier() {
return this.tier;
}
public UpgradePath getUpgradePath() {
return this.upgrade;
}
public double getDamageAmt(int tier) {
if (this.damageamt.length>=tier) {
TwosideKeeper.log("Returning value "+this.damageamt[tier-1], 5);
return this.damageamt[tier-1];
} else {
return -1;
}
}
public int getHealthAmt(int tier) {
if (this.healthamt.length>=tier) {
return this.healthamt[tier-1];
} else {
return -1;
}
}
public ShapedRecipe defineBaseRecipe() {
ShapedRecipe axe_layout_recipe = new ShapedRecipe(Artifact.createRecipe(0, this));
axe_layout_recipe.shape(recipe);
axe_layout_recipe.setIngredient('E', Material.PUMPKIN_SEEDS);
return axe_layout_recipe;
}
public void defineAllDecompRecipes() {
for (int i=0;i<10;i++) {
ShapelessRecipe decomp_recipe = new ShapelessRecipe(Artifact.createRecipe(i+1, this));
decomp_recipe.addIngredient(itemtiers[i].getType());
Bukkit.addRecipe(decomp_recipe);
}
}
public ItemStack getTieredItem(int tier) {
ItemStack ouritem = itemtiers[tier-1];
switch (tier) {
case 1:{
switch (upgrade) {
case WEAPON:{
ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
}break;
case BOW:{
ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
}break;
case ARMOR:{
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
}break;
case TOOL:{
ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 1);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
}break;
}
}break;
case 2:{
switch (upgrade) {
case WEAPON:{
ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 2);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 2);
}break;
case BOW:{
ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 2);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 2);
}break;
case ARMOR:{
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 2);
}break;
case TOOL:{
ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 2);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 2);
}break;
}
}break;
case 3:{
switch (upgrade) {
case WEAPON:{
ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 3);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 3);
ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 1);
}break;
case BOW:{
ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 4);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 3);
}break;
case ARMOR:{
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 1);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 1);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 1);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 1);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 3);
}break;
case TOOL:{
ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 3);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 3);
}break;
}
}break;
case 4:{
switch (upgrade) {
case WEAPON:{
ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 4);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 4);
ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 1);
}break;
case BOW:{
ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 5);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 4);
}break;
case ARMOR:{
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 2);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 1);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 1);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 5);
}break;
case TOOL:{
ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 4);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 4);
}break;
}
}break;
case 5:{
switch (upgrade) {
case WEAPON:{
ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 6);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 6);
ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 2);
}break;
case BOW:{
ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 7);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 6);
}break;
case ARMOR:{
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 6);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 2);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 2);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 7);
}break;
case TOOL:{
ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 6);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 6);
}break;
}
}break;
case 6:{
switch (upgrade) {
case WEAPON:{
ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 8);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 8);
ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
}break;
case BOW:{
ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 10);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 8);
}break;
case ARMOR:{
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 8);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 6);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 4);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 4);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 6);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
}break;
case TOOL:{
ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 8);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 8);
ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 1);
}break;
}
}break;
case 7:{
switch (upgrade) {
case WEAPON:{
ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 5);
ouritem.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1);
}break;
case BOW:{
ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 12);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
ouritem.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1);
}break;
case ARMOR:{
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 14);
}break;
case TOOL:{
ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 2);
ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 2);
}break;
}
}break;
case 8:{
switch (upgrade) {
case WEAPON:{
ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 14);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 7);
ouritem.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1);
}break;
case BOW:{
ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 14);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
ouritem.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1);
}break;
case ARMOR:{
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 12);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 12);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 12);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 12);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 12);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 14);
}break;
case TOOL:{
ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 14);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 4);
ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 6);
}break;
}
}break;
case 9:{
switch (upgrade) {
case WEAPON:{
ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 18);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 9);
ouritem.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1);
}break;
case BOW:{
ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 18);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
ouritem.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 1);
ouritem.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1);
}break;
case ARMOR:{
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 16);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 16);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 16);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 16);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 16);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 18);
}break;
case TOOL:{
ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 18);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 7);
ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 12);
}break;
}
}break;
case 10:{
switch (upgrade) {
case WEAPON:{
ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 40);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 20);
ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10);
ouritem.addUnsafeEnchantment(Enchantment.KNOCKBACK, 2);
}break;
case BOW:{
ouritem.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 40);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 20);
ouritem.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 2);
ouritem.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1);
}break;
case ARMOR:{
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 20);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 20);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 20);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 20);
ouritem.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 20);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 75);
}break;
case TOOL:{
ouritem.addUnsafeEnchantment(Enchantment.DIG_SPEED, 40);
ouritem.addUnsafeEnchantment(Enchantment.DURABILITY, 20);
ouritem.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 10);
ouritem.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 20);
}break;
}break;
}
}
return ouritem;
}
}
enum TierType {
ALL, //Contains Wooden, Stone, Iron, Gold, Diamond Variants of this item.
ONE, //Only the specified item exists for this type of Artifact.
ARMOR //The armor type contains Leather, Iron, Gold, and Diamond Variants.
}
enum UpgradePath {
WEAPON, //Weapon Upgrade Path - Boosts mostly offensive based statistics.
BOW, //Bow Upgrade Path - Boosts mostly offensive based statistics, but for a bow.
ARMOR, //Armor Upgrade Path - Boosts mostly defensive based statistics.
TOOL //Tool Upgrade Path - Boosts mostly utility based statistics.
}

@ -14,6 +14,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.inventory.meta.PotionMeta;
import sig.plugin.TwosideKeeper.Artifact;
import sig.plugin.TwosideKeeper.TwosideKeeper; import sig.plugin.TwosideKeeper.TwosideKeeper;
import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; import sig.plugin.TwosideKeeper.HelperStructures.WorldShop;
@ -27,7 +28,12 @@ public class GenericFunctions {
int loreline=-1; int loreline=-1;
for (int i=0;i<item_meta.getLore().size();i++) { for (int i=0;i<item_meta.getLore().size();i++) {
if (item_meta.getLore().get(i).contains(ChatColor.GRAY+"Breaks Remaining: ")) { if (item_meta.getLore().get(i).contains(ChatColor.GRAY+"Breaks Remaining: ")) {
return Integer.parseInt(item.getItemMeta().getLore().get(i).split(": "+ChatColor.YELLOW)[1]); if (item_meta.getLore().get(i).contains(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.MAGIC)) {
TwosideKeeper.log("This is obscure. Breaks is "+(Integer.parseInt(item.getItemMeta().getLore().get(i).split(": "+ChatColor.MAGIC)[1])), 2);
return Integer.parseInt(item.getItemMeta().getLore().get(i).split(": "+ChatColor.MAGIC)[1]);
} else {
return Integer.parseInt(item.getItemMeta().getLore().get(i).split(": "+ChatColor.YELLOW)[1]);
}
} }
} }
return 0; return 0;
@ -36,14 +42,31 @@ public class GenericFunctions {
} }
public static ItemStack breakHardenedItem(ItemStack item) { public static ItemStack breakHardenedItem(ItemStack item) {
return breakHardenedItem(item,null);
}
public static ItemStack breakHardenedItem(ItemStack item, Player p) {
int break_count = getHardenedItemBreaks(item); int break_count = getHardenedItemBreaks(item);
boolean is_magic = false;
if (break_count>0) { if (break_count>0) {
ItemMeta m = item.getItemMeta(); ItemMeta m = item.getItemMeta();
List<String> lore = item.getItemMeta().getLore(); List<String> lore = item.getItemMeta().getLore();
for (int i=0;i<lore.size();i++) { for (int i=0;i<lore.size();i++) {
if (lore.get(i).contains(ChatColor.GRAY+"Breaks Remaining: ")) { if (lore.get(i).contains(ChatColor.GRAY+"Breaks Remaining: ")) {
lore.set(i, ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+(break_count-1)); if (lore.get(i).contains(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.MAGIC)) {
TwosideKeeper.log("Setting breaks remaining to "+(break_count-1),3); is_magic=true;
TwosideKeeper.log("This is obscure.", 2);
break_count--;
if (p!=null && break_count==0) {
p.sendMessage(ChatColor.GOLD+"WARNING!"+ChatColor.GREEN+ " Your "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(item)+ChatColor.WHITE+" is going to break soon! You should let it recharge by waiting 24 hours!");
}
return breakObscureHardenedItem(item);
} else {
lore.set(i, ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+(break_count-1));
TwosideKeeper.log("Setting breaks remaining to "+(break_count-1),3);
}
} }
} }
m.setLore(lore); m.setLore(lore);
@ -51,6 +74,67 @@ public class GenericFunctions {
item.setAmount(1); item.setAmount(1);
item.setDurability((short)0); item.setDurability((short)0);
TwosideKeeper.log("New item is "+item.toString(),4); TwosideKeeper.log("New item is "+item.toString(),4);
break_count--;
if (p!=null && break_count==0) {
p.sendMessage(ChatColor.GOLD+"WARNING!"+ChatColor.GREEN+ " Your "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(item)+ChatColor.WHITE+" is going to break soon!");
}
return item;
//By setting the amount to 1, you refresh the item in the player's inventory.
} else {
//This item is technically destroyed.
return new ItemStack(Material.AIR);
}
}
public static int getObscureHardenedItemBreaks(ItemStack item) {
if (item.hasItemMeta() &&
item.getItemMeta().hasLore()) {
ItemMeta item_meta = item.getItemMeta();
int breaks_remaining=-1;
int loreline=-1;
for (int i=0;i<item_meta.getLore().size();i++) {
if (item_meta.getLore().get(i).contains(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.MAGIC)) {
return Integer.parseInt(item.getItemMeta().getLore().get(i).split(": "+ChatColor.MAGIC)[1]);
}
}
return 0;
}
return 0;
}
public static ItemStack breakObscureHardenedItem(ItemStack item) {
int break_count = getObscureHardenedItemBreaks(item)-1;
int break_line = -1;
if (break_count>-1) {
ItemMeta m = item.getItemMeta();
List<String> lore = item.getItemMeta().getLore();
for (int i=0;i<lore.size();i++) {
if (lore.get(i).contains(ChatColor.GRAY+"Breaks Remaining: ")) {
break_line = i;
}
if (lore.get(i).contains(ChatColor.BLUE+""+ChatColor.MAGIC)) {
//See what the previous time was.
long time = Long.parseLong(ChatColor.stripColor(lore.get(i)));
TwosideKeeper.log("The old time was "+time, 2);
if (TwosideKeeper.getServerTickTime()-time>=1728000) //1.7M ticks per day.
{
int charges_stored = (int)((TwosideKeeper.getServerTickTime()-time)/1728000);
TwosideKeeper.log(charges_stored+" charges stored. Adding them.", 2);
break_count+=charges_stored;
lore.set(i, ChatColor.BLUE+""+ChatColor.MAGIC+TwosideKeeper.getServerTickTime());
TwosideKeeper.log("Setting time to "+TwosideKeeper.getServerTickTime(),3);
}
}
}
if (break_count>5) {break_count=5;}
lore.set(break_line, ChatColor.GRAY+"Breaks Remaining: "+ChatColor.MAGIC+(break_count));
TwosideKeeper.log("Setting breaks remaining to "+(break_count),3);
m.setLore(lore);
item.setItemMeta(m);
item.setAmount(1);
item.setDurability((short)0);
TwosideKeeper.log("New item is "+item.toString(),2);
return item; return item;
//By setting the amount to 1, you refresh the item in the player's inventory. //By setting the amount to 1, you refresh the item in the player's inventory.
} else { } else {
@ -1054,6 +1138,21 @@ public class GenericFunctions {
} }
} }
public static boolean isEquip(ItemStack item) {
if (item.getType().toString().contains("SPADE") ||
item.getType().toString().contains("AXE") ||
item.getType().toString().contains("SWORD") ||
item.getType().toString().contains("HOE") ||
item.getType().toString().contains("BOOTS") ||
item.getType().toString().contains("CHESTPLATE") ||
item.getType().toString().contains("LEGGINGS") ||
item.getType().toString().contains("HELMET")) {
return true;
} else {
return false;
}
}
public static boolean isTool(ItemStack item) { public static boolean isTool(ItemStack item) {
if (item.getType().toString().contains("SPADE") || if (item.getType().toString().contains("SPADE") ||
item.getType().toString().contains("AXE") || item.getType().toString().contains("AXE") ||
@ -1065,6 +1164,16 @@ public class GenericFunctions {
} }
} }
public static boolean isWeapon(ItemStack item) {
if (item.getType().toString().contains("BOW") ||
item.getType().toString().contains("AXE") ||
item.getType().toString().contains("SWORD")) {
return true;
} else {
return false;
}
}
public static boolean isArmor(ItemStack item) { public static boolean isArmor(ItemStack item) {
if (item.getType().toString().contains("BOOTS") || if (item.getType().toString().contains("BOOTS") ||
item.getType().toString().contains("CHESTPLATE") || item.getType().toString().contains("CHESTPLATE") ||
@ -1086,8 +1195,7 @@ public class GenericFunctions {
public static boolean isRareItem(ItemStack it) { public static boolean isRareItem(ItemStack it) {
if (((it.getItemMeta().hasDisplayName() && (it.getItemMeta().getDisplayName().contains("Mega") || if (((it.getItemMeta().hasDisplayName() && (it.getItemMeta().getDisplayName().contains("Mega") ||
it.getItemMeta().getDisplayName().contains("Hardened") || it.getItemMeta().getDisplayName().contains("Hardened"))) ||
ChatColor.getByChar(it.getItemMeta().getDisplayName().charAt(0))!=null)) ||
isHardenedItem(it) isHardenedItem(it)
)) { )) {
TwosideKeeper.log("Returning it!", 5); TwosideKeeper.log("Returning it!", 5);

@ -82,17 +82,27 @@ public class MalleableBaseQuest {
long starttime = getTimeStarted(base); long starttime = getTimeStarted(base);
long currenttime = TwosideKeeper.getServerTickTime(); long currenttime = TwosideKeeper.getServerTickTime();
if (currenttime-starttime<=36000) { //30 min passed. Divine tier. int amt = base.getAmount();
return Artifact.createArtifactItem(ArtifactItem.DIVINE_BASE);
if (currenttime-starttime<=54000) { //45 min passed. Divine tier.
ItemStack newbase = Artifact.createArtifactItem(ArtifactItem.DIVINE_BASE);
newbase.setAmount(amt);
return newbase;
} else } else
if (currenttime-starttime<=72000) { //1 hour passed. Lost tier. if (currenttime-starttime<=144000) { //2 hours passed. Lost tier.
return Artifact.createArtifactItem(ArtifactItem.LOST_BASE); ItemStack newbase = Artifact.createArtifactItem(ArtifactItem.LOST_BASE);
newbase.setAmount(amt);
return newbase;
} else } else
if (currenttime-starttime<=144000) { //2 hours passed. Ancient tier. if (currenttime-starttime<=288000) { //4 hours passed. Ancient tier.
return Artifact.createArtifactItem(ArtifactItem.ANCIENT_BASE); ItemStack newbase = Artifact.createArtifactItem(ArtifactItem.ANCIENT_BASE);
newbase.setAmount(amt);
return newbase;
} else } else
{ //>2 hours passed. Artifact tier. { //>2 hours passed. Artifact tier.
return Artifact.createArtifactItem(ArtifactItem.ARTIFACT_BASE); ItemStack newbase = Artifact.createArtifactItem(ArtifactItem.ARTIFACT_BASE);
newbase.setAmount(amt);
return newbase;
}/* else //Too harsh. We are not going to make the player start all over. }/* else //Too harsh. We are not going to make the player start all over.
{ {
//This failed. Turn it back into a Malleable base. //This failed. Turn it back into a Malleable base.

@ -1,5 +1,7 @@
package sig.plugin.TwosideKeeper.HelperStructures; package sig.plugin.TwosideKeeper.HelperStructures;
import org.bukkit.entity.EntityType;
public enum MonsterType { public enum MonsterType {
BLAZE, BLAZE,
CAVESPIDER, CAVESPIDER,

@ -534,8 +534,8 @@ public class MonsterController {
( (
(md==MonsterDifficulty.NORMAL && ent.getMaxHealth()>20) || (md==MonsterDifficulty.NORMAL && ent.getMaxHealth()>20) ||
(md==MonsterDifficulty.DANGEROUS && ent.getMaxHealth()>20*2) || (md==MonsterDifficulty.DANGEROUS && ent.getMaxHealth()>20*2) ||
(md==MonsterDifficulty.NORMAL && ent.getMaxHealth()>20*2) || (md==MonsterDifficulty.DEADLY && ent.getMaxHealth()>20*2) ||
(md==MonsterDifficulty.NORMAL && ent.getMaxHealth()>20*4) (md==MonsterDifficulty.HELLFIRE && ent.getMaxHealth()>20*4)
) )
{ {
return true; return true;

@ -25,7 +25,7 @@ public class Party {
TwosideKeeper.log("Party Region Position: "+region.toString(),5); TwosideKeeper.log("Party Region Position: "+region.toString(),5);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives remove Party"+color); //Make sure the party is cleared out if it was used for something before... Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives remove Party"+color); //Make sure the party is cleared out if it was used for something before...
//Bukkit.getScoreboardManager().getMainScoreboard().registerNewObjective("Party"+color, "dummy"); //Bukkit.getScoreboardManager().getMainScoreboard().registerNewObjective("Party"+color, "dummy");
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives add Party"+color+" dummy Your Party"); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives add Party"+color+" dummy Party");
//Bukkit.getScoreboardManager().getMainScoreboard().getObjective("Party"+color).setDisplaySlot(DisplaySlot.SIDEBAR); //Bukkit.getScoreboardManager().getMainScoreboard().getObjective("Party"+color).setDisplaySlot(DisplaySlot.SIDEBAR);
String color_txt = ""; String color_txt = "";
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives setdisplay sidebar.team."+ConvertColor(color)+" Party"+color); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives setdisplay sidebar.team."+ConvertColor(color)+" Party"+color);

@ -51,6 +51,11 @@ public class PlayerStructure {
public int pickeditems=-1; public int pickeditems=-1;
public boolean sounds_enabled=true; public boolean sounds_enabled=true;
public double prev_weapondmg=0.0;
public double prev_buffdmg=0.0;
public double prev_partydmg=0.0;
public double prev_armordef=0.0;
//Needs the instance of the player object to get all other info. Only to be called at the beginning. //Needs the instance of the player object to get all other info. Only to be called at the beginning.
public PlayerStructure(Player p, long serverTickTime) { public PlayerStructure(Player p, long serverTickTime) {
if (p!=null) { if (p!=null) {

@ -14,6 +14,9 @@ import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.Dye; import org.bukkit.material.Dye;
import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem;
import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItemType;
public class Recipes { public class Recipes {
public static void Initialize_ItemCube_Recipes() { public static void Initialize_ItemCube_Recipes() {
ItemStack item_ItemCube = new ItemStack(Material.CHEST); ItemStack item_ItemCube = new ItemStack(Material.CHEST);
@ -99,7 +102,7 @@ public class Recipes {
blockarmorpc.setItemMeta(blockarmorpc_meta); blockarmorpc.setItemMeta(blockarmorpc_meta);
ShapedRecipe BlockArmor = new ShapedRecipe(blockarmorpc); ShapedRecipe BlockArmor = new ShapedRecipe(blockarmorpc);
BlockArmor.shape("aaa","axa","xxx"); BlockArmor.shape("aaa","axa");
BlockArmor.setIngredient('a', Material.IRON_BLOCK); BlockArmor.setIngredient('a', Material.IRON_BLOCK);
Bukkit.addRecipe(BlockArmor); Bukkit.addRecipe(BlockArmor);
@ -167,7 +170,7 @@ public class Recipes {
blockarmorpc.setItemMeta(blockarmorpc_meta); blockarmorpc.setItemMeta(blockarmorpc_meta);
BlockArmor = new ShapedRecipe(blockarmorpc); BlockArmor = new ShapedRecipe(blockarmorpc);
BlockArmor.shape("aaa","axa","xxx"); BlockArmor.shape("aaa","axa");
BlockArmor.setIngredient('a', Material.GOLD_BLOCK); BlockArmor.setIngredient('a', Material.GOLD_BLOCK);
Bukkit.addRecipe(BlockArmor); Bukkit.addRecipe(BlockArmor);
@ -235,7 +238,7 @@ public class Recipes {
blockarmorpc.setItemMeta(blockarmorpc_meta); blockarmorpc.setItemMeta(blockarmorpc_meta);
BlockArmor = new ShapedRecipe(blockarmorpc); BlockArmor = new ShapedRecipe(blockarmorpc);
BlockArmor.shape("aaa","axa","xxx"); BlockArmor.shape("aaa","axa");
BlockArmor.setIngredient('a', Material.DIAMOND_BLOCK); BlockArmor.setIngredient('a', Material.DIAMOND_BLOCK);
Bukkit.addRecipe(BlockArmor); Bukkit.addRecipe(BlockArmor);
@ -462,6 +465,9 @@ public class Recipes {
stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.PURPUR_BLOCK,1)); stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.PURPUR_BLOCK,1));
stone_construction_recipe.addIngredient(2, Material.PURPUR_SLAB); stone_construction_recipe.addIngredient(2, Material.PURPUR_SLAB);
Bukkit.addRecipe(stone_construction_recipe); Bukkit.addRecipe(stone_construction_recipe);
stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.QUARTZ,4));
stone_construction_recipe.addIngredient(1, Material.QUARTZ_BLOCK);
Bukkit.addRecipe(stone_construction_recipe);
ItemStack modded_plank = new ItemStack(Material.STEP,1); ItemStack modded_plank = new ItemStack(Material.STEP,1);
modded_plank.setDurability((short)2); modded_plank.setDurability((short)2);
ItemMeta m = modded_plank.getItemMeta(); ItemMeta m = modded_plank.getItemMeta();
@ -472,4 +478,70 @@ public class Recipes {
stone_construction_recipe.addIngredient(1, Material.SLIME_BALL); stone_construction_recipe.addIngredient(1, Material.SLIME_BALL);
Bukkit.addRecipe(stone_construction_recipe); Bukkit.addRecipe(stone_construction_recipe);
} }
public static void Initialize_Artifact_Recipes() {
//Essence Recipes.
//T0
for (int i=0;i<ArtifactItemType.values().length;i++) {
Bukkit.addRecipe(ArtifactItemType.values()[i].defineBaseRecipe());
ArtifactItemType.values()[i].defineAllDecompRecipes();
//T1,T4,T7 Recipes
ShapelessRecipe newrecipe = new ShapelessRecipe(Artifact.convert_equip(ArtifactItemType.values()[i].getTieredItem(1),1,ArtifactItemType.values()[i]));
newrecipe.addIngredient(2, Material.STAINED_GLASS_PANE, ArtifactItemType.values()[i].getDataValue());
newrecipe.addIngredient(Material.SUGAR);
Bukkit.addRecipe(newrecipe);
newrecipe = new ShapelessRecipe(Artifact.convert_equip(ArtifactItemType.values()[i].getTieredItem(2),2,ArtifactItemType.values()[i]));
newrecipe.addIngredient(2, Material.STAINED_GLASS_PANE, ArtifactItemType.values()[i].getDataValue());
newrecipe.addIngredient(Material.MAGMA_CREAM);
Bukkit.addRecipe(newrecipe);
newrecipe = new ShapelessRecipe(Artifact.convert_equip(ArtifactItemType.values()[i].getTieredItem(3),3,ArtifactItemType.values()[i]));
newrecipe.addIngredient(2, Material.STAINED_GLASS_PANE, ArtifactItemType.values()[i].getDataValue());
newrecipe.addIngredient(Material.CLAY_BALL);
Bukkit.addRecipe(newrecipe);
newrecipe = new ShapelessRecipe(Artifact.convert_equip(ArtifactItemType.values()[i].getTieredItem(10),10,ArtifactItemType.values()[i]));
newrecipe.addIngredient(2, Material.STAINED_GLASS_PANE, ArtifactItemType.values()[i].getDataValue());
newrecipe.addIngredient(Material.SUGAR);
newrecipe.addIngredient(Material.MAGMA_CREAM);
newrecipe.addIngredient(Material.CLAY_BALL);
Bukkit.addRecipe(newrecipe);
}
ShapelessRecipe upgraderecipe = new ShapelessRecipe(Artifact.createArtifactItem(ArtifactItem.DIVINE_ESSENCE));
upgraderecipe.addIngredient(Material.NETHER_STAR);
upgraderecipe.addIngredient(Material.SUGAR);
Bukkit.addRecipe(upgraderecipe);
upgraderecipe = new ShapelessRecipe(Artifact.createArtifactItem(ArtifactItem.DIVINE_CORE));
upgraderecipe.addIngredient(Material.NETHER_STAR);
upgraderecipe.addIngredient(Material.MAGMA_CREAM);
Bukkit.addRecipe(upgraderecipe);
upgraderecipe = new ShapelessRecipe(Artifact.createArtifactItem(ArtifactItem.DIVINE_BASE));
upgraderecipe.addIngredient(Material.NETHER_STAR);
upgraderecipe.addIngredient(Material.CLAY_BALL);
Bukkit.addRecipe(upgraderecipe);
ItemStack newitem = Artifact.createArtifactItem(ArtifactItem.ARTIFACT_ESSENCE);
newitem.setAmount(2);
upgraderecipe = new ShapelessRecipe(newitem);
upgraderecipe.addIngredient(Material.SUGAR);
Bukkit.addRecipe(upgraderecipe);
newitem = Artifact.createArtifactItem(ArtifactItem.ARTIFACT_CORE);
newitem.setAmount(2);
upgraderecipe = new ShapelessRecipe(newitem);
upgraderecipe.addIngredient(Material.MAGMA_CREAM);
Bukkit.addRecipe(upgraderecipe);
newitem = Artifact.createArtifactItem(ArtifactItem.ARTIFACT_BASE);
newitem.setAmount(2);
upgraderecipe = new ShapelessRecipe(newitem);
upgraderecipe.addIngredient(Material.CLAY_BALL);
Bukkit.addRecipe(upgraderecipe);
newitem = Artifact.createArtifactItem(ArtifactItem.ARTIFACT_ESSENCE);
upgraderecipe = new ShapelessRecipe(newitem);
upgraderecipe.addIngredient(2,Material.SUGAR);
Bukkit.addRecipe(upgraderecipe);
newitem = Artifact.createArtifactItem(ArtifactItem.ARTIFACT_CORE);
upgraderecipe = new ShapelessRecipe(newitem);
upgraderecipe.addIngredient(2,Material.MAGMA_CREAM);
Bukkit.addRecipe(upgraderecipe);
newitem = Artifact.createArtifactItem(ArtifactItem.ARTIFACT_BASE);
upgraderecipe = new ShapelessRecipe(newitem);
upgraderecipe.addIngredient(2,Material.CLAY_BALL);
Bukkit.addRecipe(upgraderecipe);
}
} }

@ -117,6 +117,7 @@ import com.google.common.collect.Iterators;
import aPlugin.DiscordMessageSender; import aPlugin.DiscordMessageSender;
import net.minecraft.server.v1_9_R1.Vector3f; import net.minecraft.server.v1_9_R1.Vector3f;
import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem; import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem;
import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItemType;
import sig.plugin.TwosideKeeper.HelperStructures.CubeType; import sig.plugin.TwosideKeeper.HelperStructures.CubeType;
import sig.plugin.TwosideKeeper.HelperStructures.DeathStructure; import sig.plugin.TwosideKeeper.HelperStructures.DeathStructure;
import sig.plugin.TwosideKeeper.HelperStructures.ItemRarity; import sig.plugin.TwosideKeeper.HelperStructures.ItemRarity;
@ -161,6 +162,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public double XP_CONVERSION_RATE=0.01; //How much money per exp point? public double XP_CONVERSION_RATE=0.01; //How much money per exp point?
public static int WORLD_SHOP_ID=0; //The shop ID number we are on. public static int WORLD_SHOP_ID=0; //The shop ID number we are on.
public static int LOGGING_LEVEL=0; //The logging level the server will output in for the console. 0 = No Debug Messages. Toggled with /log. public static int LOGGING_LEVEL=0; //The logging level the server will output in for the console. 0 = No Debug Messages. Toggled with /log.
public static double ARTIFACT_RARITY=1.5; //The multiplier of artifact drops.
public static File filesave; public static File filesave;
public static List<PlayerStructure> playerdata; public static List<PlayerStructure> playerdata;
public static SpleefManager TwosideSpleefGames; public static SpleefManager TwosideSpleefGames;
@ -215,6 +217,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
sig.plugin.TwosideKeeper.Recipes.Initialize_ItemDeconstruction_Recipes(); sig.plugin.TwosideKeeper.Recipes.Initialize_ItemDeconstruction_Recipes();
sig.plugin.TwosideKeeper.Recipes.Initialize_WoolRecolor_Recipes(); sig.plugin.TwosideKeeper.Recipes.Initialize_WoolRecolor_Recipes();
sig.plugin.TwosideKeeper.Recipes.Initialize_SlabReconstruction_Recipes(); sig.plugin.TwosideKeeper.Recipes.Initialize_SlabReconstruction_Recipes();
sig.plugin.TwosideKeeper.Recipes.Initialize_Artifact_Recipes();
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);
@ -261,6 +264,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
for (int i=0;i<Bukkit.getOnlinePlayers().toArray().length;i++) { for (int i=0;i<Bukkit.getOnlinePlayers().toArray().length;i++) {
playerdata.add(new PlayerStructure((Player)Bukkit.getOnlinePlayers().toArray()[i],getServerTickTime())); playerdata.add(new PlayerStructure((Player)Bukkit.getOnlinePlayers().toArray()[i],getServerTickTime()));
} }
//Announce the server has restarted soon after.
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@Override
public void run() {
DiscordMessageSender.sendItalicizedRawMessageDiscord("The server has been restarted.\nRunning v."+Bukkit.getPluginManager().getPlugin("TwosideKeeper").getDescription().getVersion()+" of TwosideKeeper\nRunning v"+Bukkit.getPluginManager().getPlugin("aPlugin").getDescription().getVersion()+" of Jobs.");
}
},100);
//This is the constant timing method. //This is the constant timing method.
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){ getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
@ -377,12 +388,19 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//Check damage reduction by sending an artifical "1" damage to the player. //Check damage reduction by sending an artifical "1" damage to the player.
if (!p.isDead()) {setPlayerMaxHealth(p);} if (!p.isDead()) {setPlayerMaxHealth(p);}
p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p)); p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p));
double old_weapondmg = pd.prev_weapondmg;
double old_buffdmg = pd.prev_buffdmg;
double old_partydmg = pd.prev_partydmg;
double old_armordef = pd.prev_armordef;
double store1=CalculateDamageReduction(1,p,p),store2=CalculateWeaponDamage(p,null); double store1=CalculateDamageReduction(1,p,p),store2=CalculateWeaponDamage(p,null);
if (store1!=pd.damagereduction || store2!=pd.damagedealt) { if (store1!=pd.damagereduction || store2!=pd.damagedealt) {
pd.damagereduction = store1; pd.damagereduction = store1;
pd.damagedealt = store2; pd.damagedealt = store2;
DecimalFormat df = new DecimalFormat("0.0"); DecimalFormat df = new DecimalFormat("0.0");
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)+"%"); if ((old_weapondmg != pd.prev_weapondmg && GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) ||
(old_armordef != pd.prev_armordef && old_partydmg == pd.prev_partydmg && old_buffdmg == pd.prev_buffdmg)) {
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)+"%");
}
} }
@ -560,6 +578,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} else } else
if (cmd.getName().equalsIgnoreCase("artifact")) { if (cmd.getName().equalsIgnoreCase("artifact")) {
Player p = (Player)sender; Player p = (Player)sender;
if (args.length==2) {
ItemStack newartifact = Artifact.createArtifactItem(ArtifactItem.valueOf(args[0]));
newartifact.setAmount(Integer.parseInt((args[1])));
p.getInventory().addItem(newartifact);
} else
if (args.length==1) { if (args.length==1) {
p.getInventory().addItem(Artifact.createArtifactItem(ArtifactItem.valueOf(args[0]))); p.getInventory().addItem(Artifact.createArtifactItem(ArtifactItem.valueOf(args[0])));
} else { } else {
@ -1539,7 +1562,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
ev.setKeepInventory(true); ev.setKeepInventory(true);
DeathManager.addNewDeathStructure(ev.getDrops(), p.getLocation(), p); DeathManager.addNewDeathStructure(ev.getDrops(), (p.getLocation().getY()<0)?p.getLocation().add(0,100,0) //This means they fell into the void. Might as well put it way higher.
:p.getLocation(), p);
p.getInventory().clear(); p.getInventory().clear();
} }
} }
@ -1594,8 +1618,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
@EventHandler(priority=EventPriority.LOW) @EventHandler(priority=EventPriority.LOW)
public void onItemCraft(CraftItemEvent ev) { public void onItemCraft(CraftItemEvent ev) {
log(ev.getCurrentItem().getItemMeta().toString(),5); //log(ev.getCurrentItem().getItemMeta().toString(),5);
log("Original Result item is "+ev.getInventory().getItem(0).toString(),4);
if (ev.getInventory().getResult()!=null &&
ev.getInventory().getResult().getType()!=Material.AIR &&
Artifact.isArtifact(ev.getInventory().getResult()) && GenericFunctions.isEquip(ev.getInventory().getResult())) {
Player p = (Player)(Bukkit.getPlayer(ev.getWhoClicked().getName()));
p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_USE, 1.0f, 1.0f);
}
//Item cube should be in slot 4. //Item cube should be in slot 4.
if (ev.getInventory().getItem(5)!=null) { if (ev.getInventory().getItem(5)!=null) {
ItemMeta inventory_itemMeta=ev.getInventory().getItem(5).getItemMeta(); ItemMeta inventory_itemMeta=ev.getInventory().getItem(5).getItemMeta();
@ -1833,21 +1863,19 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.getInventory().getItem(0).getItemMeta().hasDisplayName()) { ev.getInventory().getItem(0).getItemMeta().hasDisplayName()) {
//It's possible we may have to fix the color code for this item. Check the first two characters. //It's possible we may have to fix the color code for this item. Check the first two characters.
String oldname = ev.getInventory().getItem(0).getItemMeta().getDisplayName(); String oldname = ev.getInventory().getItem(0).getItemMeta().getDisplayName();
ChatColor first = ChatColor.getByChar(oldname.charAt(1)); String strippedname = ChatColor.stripColor(oldname);
log("First character is "+first,4); String colorcodes = oldname.replace(strippedname, "");
ChatColor second = ChatColor.getByChar(oldname.charAt(0)); if (colorcodes.length()==2) {
log("Second character is "+second,4); colorcodes=colorcodes.substring(1);
if (first!=null) { } else
if (second!=null) { if (colorcodes.length()==4) {
ItemMeta m = ev.getCurrentItem().getItemMeta(); colorcodes=Character.toString(colorcodes.charAt(1))+Character.toString(colorcodes.charAt(3));
m.setDisplayName(first+""+second+ev.getCurrentItem().getItemMeta().getDisplayName().substring(2));
ev.getCurrentItem().setItemMeta(m);
} else {
ItemMeta m = ev.getCurrentItem().getItemMeta();
m.setDisplayName(first+ev.getCurrentItem().getItemMeta().getDisplayName().substring(1));
ev.getCurrentItem().setItemMeta(m);
}
} }
log("Color codes are: <"+colorcodes+">. Length is "+colorcodes.length(),4);
//ev.getWhoClicked().sendMessage(ChatColor.getByChar(colorcodes)+"This is the color.");
ItemMeta m = ev.getCurrentItem().getItemMeta();
m.setDisplayName(ChatColor.getByChar(colorcodes)+m.getDisplayName().replaceFirst(colorcodes, ""));
ev.getCurrentItem().setItemMeta(m);
} }
} }
@ -2400,7 +2428,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//Recycle allowed. Now figure out which node to go to. //Recycle allowed. Now figure out which node to go to.
if (TwosideRecyclingCenter.getNumberOfNodes()>0) { if (TwosideRecyclingCenter.getNumberOfNodes()>0) {
Location rand_node=TwosideRecyclingCenter.getRandomNode(); Location rand_node=TwosideRecyclingCenter.getRandomNode();
Block b = Bukkit.getWorld("world").getBlockAt(rand_node); rand_node.getWorld().loadChunk(rand_node.getChunk()); //Load that chunk to make sure we can throw items into it.
Block b = rand_node.getWorld().getBlockAt(rand_node);
if (b!=null && b.getType()==Material.CHEST || if (b!=null && b.getType()==Material.CHEST ||
b.getType()==Material.TRAPPED_CHEST) { b.getType()==Material.TRAPPED_CHEST) {
if (b.getState()!=null) { if (b.getState()!=null) {
@ -2567,7 +2596,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public void expEvent(PlayerExpChangeEvent ev) { public void expEvent(PlayerExpChangeEvent ev) {
double val = Math.random(); double val = Math.random();
log("ExpChange event: "+val,5); log("ExpChange event: "+val,5);
if (val<=0.00125) { int amt = ev.getAmount();
if (val<=((double)amt/(double)50)*(0.00125)*ARTIFACT_RARITY) {
ev.getPlayer().getWorld().dropItemNaturally(ev.getPlayer().getLocation(), Artifact.createArtifactItem(ArtifactItem.MALLEABLE_BASE)); ev.getPlayer().getWorld().dropItemNaturally(ev.getPlayer().getLocation(), Artifact.createArtifactItem(ArtifactItem.MALLEABLE_BASE));
ev.getPlayer().sendMessage(ChatColor.LIGHT_PURPLE+"A strange item has appeared nearby."); ev.getPlayer().sendMessage(ChatColor.LIGHT_PURPLE+"A strange item has appeared nearby.");
} }
@ -2733,7 +2763,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
*/ */
Location arrowLoc = ((Arrow)(ev.getDamager())).getLocation(); Location arrowLoc = ((Arrow)(ev.getDamager())).getLocation();
Location monsterHead = m.getEyeLocation().add(0,0.075,0); Location monsterHead = m.getEyeLocation().add(0,0.105,0);
boolean headshot=false; boolean headshot=false;
if (ev.getDamager().getTicksLived()>=4) { if (ev.getDamager().getTicksLived()>=4) {
@ -2777,7 +2807,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
} }
if (Math.random()<0.00390625*dropmult) { if (Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) {
ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ARTIFACT_ESSENCE)); ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ARTIFACT_ESSENCE));
} }
if (m.getType()==EntityType.ZOMBIE && if (m.getType()==EntityType.ZOMBIE &&
@ -2795,27 +2825,27 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} else { } else {
allowed=true; allowed=true;
if (allowed && Math.random()<0.00390625*dropmult) { }
switch ((int)(Math.random()*4)) { if (allowed && Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) {
case 0:{ switch ((int)(Math.random()*4)) {
ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.LOST_CORE)); case 0:{
}break; ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.LOST_CORE));
case 1:{ }break;
ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ANCIENT_CORE)); case 1:{
}break; ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ANCIENT_CORE));
case 2:{ }break;
ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ARTIFACT_CORE)); case 2:{
}break; ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ARTIFACT_CORE));
case 3:{ }break;
ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.DIVINE_CORE)); case 3:{
}break; ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.DIVINE_CORE));
} }break;
} }
} }
} }
if (m.getType()==EntityType.ENDER_DRAGON || if (m.getType()==EntityType.ENDER_DRAGON ||
m.getType()==EntityType.WITHER) { m.getType()==EntityType.WITHER) {
if (Math.random()<0.125*dropmult) { if (Math.random()<0.125*dropmult*ARTIFACT_RARITY) {
switch ((int)(Math.random()*4)) { switch ((int)(Math.random()*4)) {
case 0:{ case 0:{
ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.LOST_CORE)); ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.LOST_CORE));
@ -2833,7 +2863,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
if (m.getType()==EntityType.ENDERMAN) { if (m.getType()==EntityType.ENDERMAN) {
if (Math.random()<0.00390625*dropmult) { if (Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) {
switch ((int)(Math.random()*12)) { switch ((int)(Math.random()*12)) {
case 0:{ case 0:{
ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ARTIFACT_ESSENCE)); ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ARTIFACT_ESSENCE));
@ -2904,7 +2934,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
ev.getDrops().add(raresword); ev.getDrops().add(raresword);
} }
if (Math.random()<0.00390625*dropmult) { if (Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) {
ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ANCIENT_ESSENCE)); ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ANCIENT_ESSENCE));
} }
} }
@ -3172,7 +3202,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.getDrops().add(raresword); ev.getDrops().add(raresword);
} }
if (Math.random()<0.00390625*dropmult) { if (Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) {
ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.LOST_ESSENCE)); ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.LOST_ESSENCE));
} }
final List<ItemStack> drops = new ArrayList<ItemStack>(); final List<ItemStack> drops = new ArrayList<ItemStack>();
@ -3525,7 +3555,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
ev.getDrops().add(raresword); ev.getDrops().add(raresword);
} }
if (Math.random()<0.00390625*dropmult) { if (Math.random()<0.00390625*dropmult*ARTIFACT_RARITY) {
ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.DIVINE_ESSENCE)); ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.DIVINE_ESSENCE));
} }
} }
@ -3593,7 +3623,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//See if this item has lore. //See if this item has lore.
if (GenericFunctions.getHardenedItemBreaks(item)>0) { if (GenericFunctions.getHardenedItemBreaks(item)>0) {
//item.setAmount(1); //item.setAmount(1);
GenericFunctions.breakHardenedItem(item); GenericFunctions.breakHardenedItem(item,p);
} else } else
{ {
p.sendMessage(ChatColor.DARK_RED+"Your "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(item)+ChatColor.DARK_RED+" has broken!"); p.sendMessage(ChatColor.DARK_RED+"Your "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(item)+ChatColor.DARK_RED+" has broken!");
@ -3834,13 +3864,280 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
@EventHandler(priority=EventPriority.LOW) @EventHandler(priority=EventPriority.LOW)
public void onItemCraftEvent(PrepareItemCraftEvent ev) { public void onItemCraftEvent(PrepareItemCraftEvent ev) {
ItemStack result = ev.getInventory().getResult(); ItemStack result = ev.getInventory().getResult();
if (result.getType()==Material.TNT) { if (result.getType()==Material.TNT) {
result.setAmount(result.getAmount()*5); //TNT recipes are 5 times as effective. result.setAmount(result.getAmount()*5); //TNT recipes are 5 times as effective.
} }
//Look for the base material.
if (Artifact.isArtifact(ev.getInventory().getResult()) && result.getType()!=Material.STAINED_GLASS_PANE && GenericFunctions.isEquip(result)) {
log("This is an artifact we are crafting...Begin search",4);
boolean good = false;
ItemStack stainedglass1 = null; //Gets set if stained glass is an artifact.
ItemStack stainedglass2 = null; //Gets set if stained glass is an artifact.
ItemStack baseitem = null; //Gets set if a base item is an artifact.
ItemStack baseitem2 = null; //Gets set if a base item is an artifact.
ItemStack baseitem3 = null; //Gets set if a base item is an artifact.
int baseitemcount=0;
int totaltierval=0;
for (int i=0;i<ev.getInventory().getSize();i++) {
if (ev.getInventory().getItem(i)!=null &&
(ev.getInventory().getItem(i).getType()==Material.CLAY_BALL ||
ev.getInventory().getItem(i).getType()==Material.MAGMA_CREAM ||
ev.getInventory().getItem(i).getType()==Material.SUGAR ||
ev.getInventory().getItem(i).getType()==Material.STAINED_GLASS_PANE) &&
Artifact.isArtifact(ev.getInventory().getItem(i))) {
//This is the base item.
if (ev.getInventory().getItem(i).getType()==Material.STAINED_GLASS_PANE) {
if (stainedglass1==null) {
stainedglass1 = ev.getInventory().getItem(i);
} else {
stainedglass2 = ev.getInventory().getItem(i);
}
log("Found the glass pane.",4);
} else {
if (baseitem==null && ev.getInventory().getItem(i).getType()==Material.CLAY_BALL) {
baseitem = ev.getInventory().getItem(i);
log("Found the Base.",4);
} else
if (baseitem2==null && ev.getInventory().getItem(i).getType()==Material.MAGMA_CREAM) {
baseitem2 = ev.getInventory().getItem(i);
log("Found the Core.",4);
} else
if (baseitem3==null && ev.getInventory().getItem(i).getType()==Material.SUGAR) {
baseitem3 = ev.getInventory().getItem(i);
log("Found the Essence.",4);
}
baseitemcount++;
log("Found the base item.",4);
}
if (stainedglass1!=null && stainedglass2!=null && (baseitem!=null || baseitem2!=null || baseitem3!=null)) {
good=true;
}
}
}
if (!good) {
ev.getInventory().setResult(new ItemStack(Material.AIR));
} else {
//Now we have to determine the tier of the next recipe.
int tierval = 0;
if (baseitem3!=null && baseitem3.getType()==Material.SUGAR) {
tierval+=1+(baseitem3.getEnchantmentLevel(Enchantment.LUCK)-1)*3;
}
if (baseitem2!=null && baseitem2.getType()==Material.MAGMA_CREAM) {
tierval+=2+(baseitem2.getEnchantmentLevel(Enchantment.LUCK)-1)*3;
}
if (baseitem!=null && baseitem.getType()==Material.CLAY_BALL) {
tierval+=3+(baseitem.getEnchantmentLevel(Enchantment.LUCK)-1)*3;
}
if (baseitem!=null && baseitem2!=null && baseitem3!=null) {
totaltierval = (3+(baseitem.getEnchantmentLevel(Enchantment.LUCK)-1)*3) +
(2+(baseitem2.getEnchantmentLevel(Enchantment.LUCK)-1)*3) +
(1+(baseitem3.getEnchantmentLevel(Enchantment.LUCK)-1)*3);
log("Total Tier Value is "+totaltierval,2);
tierval=10;
}
//See if the glasspane is equal to our tierval.
//Grab the tierval.
int recipe_tier = stainedglass1.getEnchantmentLevel(Enchantment.LUCK);
int recipe_tier2 = stainedglass2.getEnchantmentLevel(Enchantment.LUCK);
log("The tier of this recipe is "+recipe_tier+"::"+tierval+"::"+recipe_tier2,2);
if (recipe_tier!=tierval ||
recipe_tier2!=tierval ||
(tierval>=10 && baseitemcount!=3) ||
(totaltierval!=33 && baseitemcount==3)/*This tier is not allowed through this recipe.*/) {
//Not allowed, sorry.
ev.getInventory().setResult(new ItemStack(Material.AIR));
} else {
//This is allowed. Modify the name of the item.
List<String> oldlore = result.getItemMeta().getLore();
ItemStack artifactitem = ArtifactItemType.valueOf(Artifact.returnRawTool(ev.getInventory().getResult().getType())).getTieredItem(recipe_tier);
ItemMeta m = artifactitem.getItemMeta();
m.setDisplayName(ChatColor.GOLD+""+ChatColor.BOLD+""+"T"+tierval+ChatColor.RESET+ChatColor.GOLD+" Artifact "+GenericFunctions.CapitalizeFirstLetters(Artifact.returnRawTool(artifactitem.getType())));
oldlore.set(0, ChatColor.GOLD+""+ChatColor.BOLD+"T"+tierval+ChatColor.RESET+ChatColor.GOLD+" "+GenericFunctions.CapitalizeFirstLetters(Artifact.returnRawTool(artifactitem.getType()))+" Recipe");
oldlore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.MAGIC+5);
oldlore.add(ChatColor.BLUE+""+ChatColor.MAGIC+getServerTickTime());double dmgval = ArtifactItemType.valueOf(Artifact.returnRawTool(artifactitem.getType())).getDamageAmt(tierval);
int healthval = ArtifactItemType.valueOf(Artifact.returnRawTool(artifactitem.getType())).getHealthAmt(tierval);
if (dmgval!=-1) {
if (GenericFunctions.isArmor(artifactitem)) {
oldlore.add(ChatColor.YELLOW+"+"+dmgval+"%"+ChatColor.BLUE+" Damage Reduction");
} else {
oldlore.add(ChatColor.YELLOW+"+"+dmgval+ChatColor.BLUE+" Damage");
}
}
if (healthval!=-1) {
oldlore.add(ChatColor.YELLOW+"+"+healthval+ChatColor.BLUE+" Health");
}
m.setLore(oldlore);
artifactitem.setItemMeta(m);
artifactitem.addUnsafeEnchantment(Enchantment.LUCK, tierval);
ev.getInventory().setResult(artifactitem);
}
}
}
else
//We are looking for an artifact recipe.
if (result.getType()==Material.STAINED_GLASS_PANE && Artifact.isArtifact(result)) {
for (int i=0;i<ev.getInventory().getSize();i++) {
if (ev.getInventory().getItem(i)!=null &&
ev.getInventory().getItem(i).getType()!=Material.AIR &&
!Artifact.isArtifact(ev.getInventory().getItem(i))) {
ev.getInventory().setResult(new ItemStack(Material.AIR));
break;
}
}
}
else
//We are looking for an artifact conversion recipe.
if ((result.getType()==Material.SUGAR ||
result.getType()==Material.MAGMA_CREAM ||
result.getType()==Material.CLAY_BALL) && Artifact.isArtifact(result)) {
//This is a conversion recipe. Decide how to handle it.
log("Handling this recipe...",4);
boolean nether_star_found=false;
boolean using_artifact_item=false;
int valid_items=0;
List<ItemStack> items_found = new ArrayList<ItemStack>();
for (int i=1;i<ev.getInventory().getSize();i++) {
if (ev.getInventory().getItem(i)!=null &&
ev.getInventory().getItem(i).getType()==Material.NETHER_STAR) {
log(" Nether Star Found.",5);
nether_star_found=true;
valid_items++;
} else
if (ev.getInventory().getItem(i)!=null &&
(ev.getInventory().getItem(i).getType()==Material.SUGAR ||
ev.getInventory().getItem(i).getType()==Material.MAGMA_CREAM ||
ev.getInventory().getItem(i).getType()==Material.CLAY_BALL)) {
log(" Other Item Found.",5);
items_found.add(ev.getInventory().getItem(i));
if (ev.getInventory().getItem(i).getEnchantmentLevel(Enchantment.LUCK)!=1) {
//Invalid.
log(" Not a valid tier: "+ev.getInventory().getItem(i).getEnchantmentLevel(Enchantment.LUCK),4);
ev.getInventory().setResult(new ItemStack(Material.AIR));
} else {
valid_items++;
}
} else
if (ev.getInventory().getItem(i)!=null &&
ev.getInventory().getItem(i).getType()!=Material.AIR &&
!Artifact.isArtifact(ev.getInventory().getItem(i))) {
log(" This is "+ev.getInventory().getItem(i).getType(),2);
ev.getInventory().setResult(new ItemStack(Material.AIR));
}
}
if (!nether_star_found) {
//This is a conversion recipe.
if (items_found.size()==2) {
//This is a conversion UP recipe.
if (items_found.get(0).equals(items_found.get(1))) {
//Now that we know these are the same. We can figure out which recipe to make.
String mat_suffix = "";
if (items_found.get(0).getType()==Material.SUGAR) {
mat_suffix = "ESSENCE";
} else
if (items_found.get(0).getType()==Material.MAGMA_CREAM) {
mat_suffix = "CORE";
} else
if (items_found.get(0).getType()==Material.CLAY_BALL) {
mat_suffix = "BASE";
}
if (items_found.get(0).getEnchantmentLevel(Enchantment.LUCK)==1) {
//This will give us Ancient tier.
ev.getInventory().setResult(Artifact.createArtifactItem(ArtifactItem.valueOf("ANCIENT_"+mat_suffix)));
} else
if (items_found.get(0).getEnchantmentLevel(Enchantment.LUCK)==2) {
//This will give us Lost tier.
ev.getInventory().setResult(Artifact.createArtifactItem(ArtifactItem.valueOf("LOST_"+mat_suffix)));
} else
if (items_found.get(0).getEnchantmentLevel(Enchantment.LUCK)==3) {
//This will give us tier.
ev.getInventory().setResult(Artifact.createArtifactItem(ArtifactItem.valueOf("DIVINE_"+mat_suffix)));
} else
if (items_found.get(0).getEnchantmentLevel(Enchantment.LUCK)==4) {
//This produces nothing... No tier above Divine.
ev.getInventory().setResult(new ItemStack(Material.AIR));
}
}
}if (items_found.size()==1) {
//This is a conversion DOWN recipe.
//Find out what tier this is supposed to be.
String mat_suffix = "";
if (items_found.get(0).getType()==Material.SUGAR) {
mat_suffix = "ESSENCE";
} else
if (items_found.get(0).getType()==Material.MAGMA_CREAM) {
mat_suffix = "CORE";
} else
if (items_found.get(0).getType()==Material.CLAY_BALL) {
mat_suffix = "BASE";
}
if (items_found.get(0).getEnchantmentLevel(Enchantment.LUCK)==1) {
//No result. This is the lowest tier.
ev.getInventory().setResult(new ItemStack(Material.AIR));
} else
if (items_found.get(0).getEnchantmentLevel(Enchantment.LUCK)==2) {
//This produces Artifact Essence.
ItemStack newitem = Artifact.createArtifactItem(ArtifactItem.valueOf("ARTIFACT_"+mat_suffix));
newitem.setAmount(2);
ev.getInventory().setResult(newitem);
} else
if (items_found.get(0).getEnchantmentLevel(Enchantment.LUCK)==3) {
//This produces Ancient Essence.
ItemStack newitem = Artifact.createArtifactItem(ArtifactItem.valueOf("ANCIENT_"+mat_suffix));
newitem.setAmount(2);
ev.getInventory().setResult(newitem);
} else
if (items_found.get(0).getEnchantmentLevel(Enchantment.LUCK)==4) {
//This produces Lost Essence.
ItemStack newitem = Artifact.createArtifactItem(ArtifactItem.valueOf("LOST_"+mat_suffix));
newitem.setAmount(2);
ev.getInventory().setResult(newitem);
}
}
}
}
else
//We are looking for an artifact recipe.
if (ev.getInventory().getResult()!=null &&
ev.getInventory().getResult().getType()!=Material.AIR) {
//We are looking for an artifact piece.
int items_found=0;
int slot_found=0;
for (int i=0;i<ev.getInventory().getSize();i++) {
if (ev.getInventory().getItem(i)!=null &&
ev.getInventory().getItem(i).getType()!=Material.AIR &&
Artifact.isArtifact(ev.getInventory().getItem(i))) {
items_found++;
slot_found=i;
}
}
if (items_found==1) {
int tier = ev.getInventory().getItem(slot_found).getEnchantmentLevel(Enchantment.LUCK);
//Decompose this into a higher tier of the next item.
if (tier<10) {
ItemStack newitem = Artifact.convert(new ItemStack(Material.STAINED_GLASS_PANE,1,(short)ArtifactItemType.valueOf(Artifact.returnRawTool(ev.getInventory().getItem(slot_found).getType())).getDataValue()));
ItemMeta m = newitem.getItemMeta();
List<String> lore = m.getLore();
lore.add(0,ChatColor.GOLD+""+ChatColor.BOLD+"T"+(tier+1)+" Crafting Recipe");
//lore.add(1,ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+ChatColor.RESET+ChatColor.GOLD+" "+GenericFunctions.CapitalizeFirstLetters(item.getItemName())+" Recipe");
m.setLore(lore);
m.setDisplayName(ChatColor.GOLD+""+ChatColor.BOLD+"T"+(tier+1)+" Artifact "+GenericFunctions.CapitalizeFirstLetters(Artifact.returnRawTool(ev.getInventory().getItem(slot_found).getType()))+" Recipe");
newitem.setItemMeta(m);
newitem.addUnsafeEnchantment(Enchantment.LUCK, tier+1);
ev.getInventory().setResult(newitem);
}
}
}
} }
@EventHandler(priority=EventPriority.LOW) @EventHandler(priority=EventPriority.LOW)
@ -3927,6 +4224,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
getConfig().set("XP_CONVERSION_RATE", XP_CONVERSION_RATE); getConfig().set("XP_CONVERSION_RATE", XP_CONVERSION_RATE);
getConfig().set("WORLD_SHOP_ID", WORLD_SHOP_ID); getConfig().set("WORLD_SHOP_ID", WORLD_SHOP_ID);
getConfig().set("LOGGING_LEVEL", LOGGING_LEVEL); getConfig().set("LOGGING_LEVEL", LOGGING_LEVEL);
getConfig().set("ARTIFACT_RARITY", ARTIFACT_RARITY);
//getConfig().set("MOTD", MOTD); //It makes no sense to save the MOTD as it will never be modified in-game. //getConfig().set("MOTD", MOTD); //It makes no sense to save the MOTD as it will never be modified in-game.
saveConfig(); saveConfig();
@ -3973,6 +4271,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
getConfig().addDefault("XP_CONVERSION_RATE", XP_CONVERSION_RATE); getConfig().addDefault("XP_CONVERSION_RATE", XP_CONVERSION_RATE);
getConfig().addDefault("WORLD_SHOP_ID", WORLD_SHOP_ID); getConfig().addDefault("WORLD_SHOP_ID", WORLD_SHOP_ID);
getConfig().addDefault("LOGGING_LEVEL", LOGGING_LEVEL); getConfig().addDefault("LOGGING_LEVEL", LOGGING_LEVEL);
getConfig().addDefault("ARTIFACT_RARITY", ARTIFACT_RARITY);
getConfig().options().copyDefaults(true); getConfig().options().copyDefaults(true);
saveConfig(); saveConfig();
SERVERTICK = getConfig().getLong("SERVERTICK"); SERVERTICK = getConfig().getLong("SERVERTICK");
@ -4000,6 +4299,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
XP_CONVERSION_RATE = getConfig().getDouble("XP_CONVERSION_RATE"); XP_CONVERSION_RATE = getConfig().getDouble("XP_CONVERSION_RATE");
WORLD_SHOP_ID = getConfig().getInt("WORLD_SHOP_ID"); WORLD_SHOP_ID = getConfig().getInt("WORLD_SHOP_ID");
LOGGING_LEVEL = getConfig().getInt("LOGGING_LEVEL"); LOGGING_LEVEL = getConfig().getInt("LOGGING_LEVEL");
ARTIFACT_RARITY = getConfig().getDouble("ARTIFACT_RARITY");
getMOTD(); getMOTD();
//Informational reports to the console. //Informational reports to the console.
@ -4014,7 +4314,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
getLogger().info("[CONFIG] Food healing amount is "+FOOD_HEAL_AMT+" health per food item."); getLogger().info("[CONFIG] Food healing amount is "+FOOD_HEAL_AMT+" health per food item.");
getLogger().info("[CONFIG] Enemy Damage Multiplier x"+ENEMY_DMG_MULT+". Explosion Damage Multiplier x"+EXPLOSION_DMG_MULT); getLogger().info("[CONFIG] Enemy Damage Multiplier x"+ENEMY_DMG_MULT+". Explosion Damage Multiplier x"+EXPLOSION_DMG_MULT);
getLogger().info("[CONFIG] Headshots have to be "+(HEADSHOT_ACC*100)+"% accurate."); getLogger().info("[CONFIG] Headshots have to be "+(HEADSHOT_ACC*100)+"% accurate.");
getLogger().info("[CONFIG] Rare Drop Rate is currently "+(RARE_DROP_RATE*100)+"%"); getLogger().info("[CONFIG] Rare Drop Rate is currently "+(RARE_DROP_RATE*100)+"%. Artifact Drop Rarity is x"+ARTIFACT_RARITY);
getLogger().info("[CONFIG] Party Chunk Size Detection is set to "+(PARTY_CHUNK_SIZE)+" chunks."); getLogger().info("[CONFIG] Party Chunk Size Detection is set to "+(PARTY_CHUNK_SIZE)+" chunks.");
getLogger().info("[CONFIG] XP Conversion rate is $"+XP_CONVERSION_RATE+" per XP Point."); getLogger().info("[CONFIG] XP Conversion rate is $"+XP_CONVERSION_RATE+" per XP Point.");
getLogger().info("[CONFIG] Console Logging Level set to "+LOGGING_LEVEL+"."); getLogger().info("[CONFIG] Console Logging Level set to "+LOGGING_LEVEL+".");
@ -4440,28 +4740,38 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (equipment[i]!=null) { if (equipment[i]!=null) {
boolean is_block_form=false; boolean is_block_form=false;
//Determine if the piece is block form. //Determine if the piece is block form.
if (equipment[i].hasItemMeta() && //If this is an artifact armor, we totally override the base damage reduction.
equipment[i].getItemMeta().hasLore()) { if (GenericFunctions.isArmor(equipment[i]) && Artifact.isArtifact(equipment[i])) {
for (int j=0;j<equipment[i].getItemMeta().getLore().size();j++) { //Let's change up the damage.
if (equipment[i].getItemMeta().getLore().get(j).contains(ChatColor.GRAY+"Breaks Remaining:")) { log("This is getting through",5);
//This is a block version. int dmgval = ArtifactItemType.valueOf(Artifact.returnRawTool(equipment[i].getType())).getHealthAmt(equipment[i].getEnchantmentLevel(Enchantment.LUCK));
is_block_form=true; if (dmgval!=-1) {
break; hp += dmgval;
}
} else {
if (equipment[i].hasItemMeta() &&
equipment[i].getItemMeta().hasLore()) {
for (int j=0;j<equipment[i].getItemMeta().getLore().size();j++) {
if (equipment[i].getItemMeta().getLore().get(j).contains(ChatColor.GRAY+"Breaks Remaining:")) {
//This is a block version.
is_block_form=true;
break;
}
} }
} }
} if (equipment[i].getType().toString().contains("LEATHER")) {
if (equipment[i].getType().toString().contains("LEATHER")) { //This is a leather piece.
//This is a leather piece. hp+=ARMOR_LEATHER_HP;
hp+=ARMOR_LEATHER_HP; } else if (equipment[i].getType().toString().contains("IRON")) {
} else if (equipment[i].getType().toString().contains("IRON")) { //This is an iron piece.
//This is an iron piece. hp+=(is_block_form)?ARMOR_IRON2_HP:ARMOR_IRON_HP;
hp+=(is_block_form)?ARMOR_IRON2_HP:ARMOR_IRON_HP; } else if (equipment[i].getType().toString().contains("GOLD")) {
} else if (equipment[i].getType().toString().contains("GOLD")) { //This is a gold piece.
//This is a gold piece. hp+=(is_block_form)?ARMOR_GOLD2_HP:ARMOR_GOLD_HP;
hp+=(is_block_form)?ARMOR_GOLD2_HP:ARMOR_GOLD_HP; } else if (equipment[i].getType().toString().contains("DIAMOND")) {
} else if (equipment[i].getType().toString().contains("DIAMOND")) { //This is a diamond piece.
//This is a diamond piece. hp+=(is_block_form)?ARMOR_DIAMOND2_HP:ARMOR_DIAMOND_HP;
hp+=(is_block_form)?ARMOR_DIAMOND2_HP:ARMOR_DIAMOND_HP; }
} }
} }
} }
@ -4667,6 +4977,77 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (GenericFunctions.isHardenedItem(weapon)) { if (GenericFunctions.isHardenedItem(weapon)) {
basedmg*=2; basedmg*=2;
} }
//If this is an artifact weapon, we totally override the base damage.
if (GenericFunctions.isTool(weapon) && Artifact.isArtifact(weapon)) {
//Let's change up the damage.
double dmgval = ArtifactItemType.valueOf(Artifact.returnRawTool(weapon.getType())).getDamageAmt(weapon.getEnchantmentLevel(Enchantment.LUCK));
if (dmgval!=-1) {
basedmg = dmgval+1.0;
} else {
basedmg = 1.0d;
}
}
if (weapon.getType()==Material.BOW) {
basedmg = 4.5;
}
PlayerStructure pd = null;
int partylevel = 0;
for (int j=0;j<playerdata.size();j++) {
if (playerdata.get(j).name.equalsIgnoreCase(p.getName())) {
pd = playerdata.get(j);
if (playerdata.get(j).partybonus>0) {
partylevel = playerdata.get(j).partybonus;
log("Party level is "+partylevel,5);
if (partylevel>9) {partylevel=9;}
pd.prev_partydmg = partylevel;
}
}
}
int sharpnesslevel=0;
//Apply player enchantments next.
//Each sharpness level increases damage by 0.5.
//Both Smite and Bane of Arthropods increases damage by 1.0 per level.
if (p.getEquipment().getItemInMainHand()!=null) {
if (weapon.getType()==Material.BOW) {
if (p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.ARROW_DAMAGE)>0) {
sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.ARROW_DAMAGE);
log("Player "+p.getName()+" has Power "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.ARROW_DAMAGE)+".",5);
}
}
else {
if (p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL)>0) {
sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL);
log("Player "+p.getName()+" has Sharpness "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL)+".",5);
} else
if (target!=null) {
if ((target.getType()==EntityType.ZOMBIE || target.getType()==EntityType.PIG_ZOMBIE ||
target.getType()==EntityType.WITHER || target.getType()==EntityType.SKELETON) &&
p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)>0) {
sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)*2;
log("Player "+p.getName()+" has Smite "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)+".",5);
} else
if ((target.getType()==EntityType.SPIDER || target.getType()==EntityType.CAVE_SPIDER ||
target.getType()==EntityType.SILVERFISH || target.getType()==EntityType.ENDERMITE) &&
p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS)>0) {
sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS)*2;
log("Player "+p.getName()+" has Bane of Arthropods "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS)+".",5);
}
}
}
}
if (pd!=null) {
pd.prev_weapondmg = basedmg;
}
int weaknesslevel = 0; int weaknesslevel = 0;
int strengthlevel = 0; int strengthlevel = 0;
@ -4685,46 +5066,18 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
weaknesslevel = Iterables.get(player_effects, i).getAmplifier()+1; weaknesslevel = Iterables.get(player_effects, i).getAmplifier()+1;
log("Found weakness on this player. Weakness level: "+(weaknesslevel),5); log("Found weakness on this player. Weakness level: "+(weaknesslevel),5);
} }
} if (pd!=null) {
pd.prev_buffdmg = strengthlevel;
int partylevel = 0;
for (int j=0;j<playerdata.size();j++) {
if (playerdata.get(j).name.equalsIgnoreCase(p.getName()) && playerdata.get(j).partybonus>0) {
partylevel = playerdata.get(j).partybonus;
log("Party level is "+partylevel,5);
if (partylevel>9) {partylevel=9;}
}
}
int sharpnesslevel=0;
//Apply player enchantments next.
//Each sharpness level increases damage by 0.5.
//Both Smite and Bane of Arthropods increases damage by 1.0 per level.
if (p.getEquipment().getItemInMainHand()!=null) {
if (p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL)>0) {
sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL);
log("Player "+p.getName()+" has Sharpness "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL)+".",5);
} else
if (target!=null) {
if ((target.getType()==EntityType.ZOMBIE || target.getType()==EntityType.PIG_ZOMBIE ||
target.getType()==EntityType.WITHER || target.getType()==EntityType.SKELETON) &&
p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)>0) {
sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)*2;
log("Player "+p.getName()+" has Smite "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)+".",5);
} else
if ((target.getType()==EntityType.SPIDER || target.getType()==EntityType.CAVE_SPIDER ||
target.getType()==EntityType.SILVERFISH || target.getType()==EntityType.ENDERMITE) &&
p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS)>0) {
sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS)*2;
log("Player "+p.getName()+" has Bane of Arthropods "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS)+".",5);
}
} }
} }
return (basedmg+(sharpnesslevel*0.5)) double finalamt = (basedmg+(sharpnesslevel*0.5))
/((10-partylevel)*0.1) /((10-partylevel)*0.1)
/((10-strengthlevel)*0.1) /((10-strengthlevel)*0.1)
*((10-weaknesslevel)*0.1); *((10-weaknesslevel)*0.1);
return finalamt;
} }
public void DealCalculatedDamage(ItemStack weapon, LivingEntity p, LivingEntity target) { public void DealCalculatedDamage(ItemStack weapon, LivingEntity p, LivingEntity target) {
@ -4750,63 +5103,74 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
protectionlevel+=monsterEquipment[i].getEnchantmentLevel(Enchantment.PROTECTION_ENVIRONMENTAL); protectionlevel+=monsterEquipment[i].getEnchantmentLevel(Enchantment.PROTECTION_ENVIRONMENTAL);
//Protection is 1% damage reduction per level of protection. //Protection is 1% damage reduction per level of protection.
} }
switch (monsterEquipment[i].getType()) { //If this is an artifact armor, we totally override the base damage reduction.
case LEATHER_HELMET:{ if (GenericFunctions.isArmor(monsterEquipment[i]) && Artifact.isArtifact(monsterEquipment[i])) {
dmgreduction+=3.0*((isMonster)?2:1); //We multiply it all by 2 since we are giving them the "block" version of the armor. //Let's change up the damage.
}break; double dmgval = ArtifactItemType.valueOf(Artifact.returnRawTool(monsterEquipment[i].getType())).getDamageAmt(monsterEquipment[i].getEnchantmentLevel(Enchantment.LUCK));
case LEATHER_CHESTPLATE:{ if (dmgval!=-1) {
dmgreduction+=3.0*((isMonster)?2:1); dmgreduction += dmgval;
}break; }
case LEATHER_LEGGINGS:{ } else {
dmgreduction+=3.0*((isMonster)?2:1); switch (monsterEquipment[i].getType()) {
}break; case LEATHER_HELMET:{
case LEATHER_BOOTS:{ dmgreduction+=3.0*((isMonster)?2:1); //We multiply it all by 2 since we are giving them the "block" version of the armor.
dmgreduction+=3.0*((isMonster)?2:1); }break;
}break; case LEATHER_CHESTPLATE:{
case IRON_HELMET:{ dmgreduction+=3.0*((isMonster)?2:1);
dmgreduction+=5.0*((isMonster)?2:1); }break;
}break; case LEATHER_LEGGINGS:{
case IRON_CHESTPLATE:{ dmgreduction+=3.0*((isMonster)?2:1);
dmgreduction+=5.0*((isMonster)?2:1); }break;
}break; case LEATHER_BOOTS:{
case IRON_LEGGINGS:{ dmgreduction+=3.0*((isMonster)?2:1);
dmgreduction+=5.0*((isMonster)?2:1); }break;
}break; case IRON_HELMET:{
case IRON_BOOTS:{ dmgreduction+=5.0*((isMonster)?2:1);
dmgreduction+=5.0*((isMonster)?2:1); }break;
}break; case IRON_CHESTPLATE:{
case GOLD_HELMET:{ dmgreduction+=5.0*((isMonster)?2:1);
dmgreduction+=10.0*((isMonster)?2:1); }break;
}break; case IRON_LEGGINGS:{
case GOLD_CHESTPLATE:{ dmgreduction+=5.0*((isMonster)?2:1);
dmgreduction+=10.0*((isMonster)?2:1); }break;
}break; case IRON_BOOTS:{
case GOLD_LEGGINGS:{ dmgreduction+=5.0*((isMonster)?2:1);
dmgreduction+=10.0*((isMonster)?2:1); }break;
}break; case GOLD_HELMET:{
case GOLD_BOOTS:{ dmgreduction+=10.0*((isMonster)?2:1);
dmgreduction+=10.0*((isMonster)?2:1); }break;
}break; case GOLD_CHESTPLATE:{
case DIAMOND_HELMET:{ dmgreduction+=10.0*((isMonster)?2:1);
dmgreduction+=8.0*((isMonster)?2:1); }break;
}break; case GOLD_LEGGINGS:{
case DIAMOND_CHESTPLATE:{ dmgreduction+=10.0*((isMonster)?2:1);
dmgreduction+=8.0*((isMonster)?2:1); }break;
}break; case GOLD_BOOTS:{
case DIAMOND_LEGGINGS:{ dmgreduction+=10.0*((isMonster)?2:1);
dmgreduction+=8.0*((isMonster)?2:1); }break;
}break; case DIAMOND_HELMET:{
case DIAMOND_BOOTS:{ dmgreduction+=8.0*((isMonster)?2:1);
dmgreduction+=8.0*((isMonster)?2:1); }break;
}break; case DIAMOND_CHESTPLATE:{
default: { dmgreduction+=8.0*((isMonster)?2:1);
dmgreduction+=0.0*((isMonster)?2:1); }break;
case DIAMOND_LEGGINGS:{
dmgreduction+=8.0*((isMonster)?2:1);
}break;
case DIAMOND_BOOTS:{
dmgreduction+=8.0*((isMonster)?2:1);
}break;
default: {
dmgreduction+=0.0*((isMonster)?2:1);
}
} }
} }
} }
} }
//Now apply resistances if any. //Now apply resistances if any.
//Resistance effect reduces damage by 10% per level of resistance. //Resistance effect reduces damage by 10% per level of resistance.
int resistlevel = 0; int resistlevel = 0;
@ -4846,7 +5210,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
public double CalculateDamageReduction(double basedmg,LivingEntity target,Entity damager) { static public double CalculateDamageReduction(double basedmg,LivingEntity target,Entity damager) {
ItemStack[] armor = target.getEquipment().getArmorContents(); ItemStack[] armor = target.getEquipment().getArmorContents();
double dmgreduction = 0.0; double dmgreduction = 0.0;
@ -4869,31 +5233,41 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
boolean isBlockArmor = GenericFunctions.isHardenedItem(armor[i]); boolean isBlockArmor = GenericFunctions.isHardenedItem(armor[i]);
switch (armor[i].getType()) {
case LEATHER_BOOTS: //If this is an artifact armor, we totally override the base damage reduction.
case LEATHER_LEGGINGS: if (GenericFunctions.isArmor(armor[i]) && Artifact.isArtifact(armor[i])) {
case LEATHER_CHESTPLATE: //Let's change up the damage.
case LEATHER_HELMET: { double dmgval = ArtifactItemType.valueOf(Artifact.returnRawTool(armor[i].getType())).getDamageAmt(armor[i].getEnchantmentLevel(Enchantment.LUCK));
dmgreduction+=3*((isBlockArmor)?2:1); if (dmgval!=-1) {
}break; dmgreduction += dmgval;
case IRON_BOOTS: }
case IRON_LEGGINGS: } else {
case IRON_CHESTPLATE: switch (armor[i].getType()) {
case IRON_HELMET: { case LEATHER_BOOTS:
dmgreduction+=5*((isBlockArmor)?2:1); case LEATHER_LEGGINGS:
}break; case LEATHER_CHESTPLATE:
case GOLD_BOOTS: case LEATHER_HELMET: {
case GOLD_LEGGINGS: dmgreduction+=3*((isBlockArmor)?2:1);
case GOLD_CHESTPLATE: }break;
case GOLD_HELMET: { case IRON_BOOTS:
dmgreduction+=10*((isBlockArmor)?2:1); case IRON_LEGGINGS:
}break; case IRON_CHESTPLATE:
case DIAMOND_BOOTS: case IRON_HELMET: {
case DIAMOND_LEGGINGS: dmgreduction+=5*((isBlockArmor)?2:1);
case DIAMOND_CHESTPLATE: }break;
case DIAMOND_HELMET: { case GOLD_BOOTS:
dmgreduction+=8*((isBlockArmor)?2:1); case GOLD_LEGGINGS:
}break; case GOLD_CHESTPLATE:
case GOLD_HELMET: {
dmgreduction+=10*((isBlockArmor)?2:1);
}break;
case DIAMOND_BOOTS:
case DIAMOND_LEGGINGS:
case DIAMOND_CHESTPLATE:
case DIAMOND_HELMET: {
dmgreduction+=8*((isBlockArmor)?2:1);
}break;
}
} }
} }
} }
@ -4907,12 +5281,17 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
PlayerStructure pd = null;
if (target instanceof Player) { if (target instanceof Player) {
Player p = (Player)target; Player p = (Player)target;
for (int j=0;j<playerdata.size();j++) { for (int j=0;j<playerdata.size();j++) {
if (playerdata.get(j).name.equalsIgnoreCase(p.getName()) && playerdata.get(j).partybonus>0) { if (playerdata.get(j).name.equalsIgnoreCase(p.getName())) {
partylevel = playerdata.get(j).partybonus; pd = playerdata.get(j);
if (partylevel>9) {partylevel=9;} if (playerdata.get(j).partybonus>0) {
partylevel = playerdata.get(j).partybonus;
if (partylevel>9) {partylevel=9;}
}
} }
} }
} }
@ -4929,6 +5308,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
*((GenericFunctions.isDefender(target))?0.9:(target.getEquipment().getItemInOffHand()!=null && target.getEquipment().getItemInOffHand().getType()==Material.SHIELD)?0.95:1); *((GenericFunctions.isDefender(target))?0.9:(target.getEquipment().getItemInOffHand()!=null && target.getEquipment().getItemInOffHand().getType()==Material.SHIELD)?0.95:1);
log(finaldmg+" damage calculated for: "+target.getName()+".",5); log(finaldmg+" damage calculated for: "+target.getName()+".",5);
if (pd!=null) {
pd.prev_armordef = finaldmg;
}
return finaldmg; return finaldmg;
} }

@ -2,6 +2,7 @@ package sig.plugin.TwosideKeeper;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster; import org.bukkit.entity.Monster;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -64,9 +65,17 @@ public final class TwosideKeeperAPI {
return GenericFunctions.getHardenedItemBreaks(i); return GenericFunctions.getHardenedItemBreaks(i);
} }
public static ItemStack breakHardenedItem(ItemStack i) { public static ItemStack breakHardenedItem(ItemStack i) {
return GenericFunctions.breakHardenedItem(i); return GenericFunctions.breakHardenedItem(i,null);
}
public static ItemStack breakHardenedItem(ItemStack i, Player p) {
return GenericFunctions.breakHardenedItem(i,p);
} }
//Combat COMMANDS.
public static double getModifiedDamage(double dmg_amt, LivingEntity p) {
return TwosideKeeper.CalculateDamageReduction(dmg_amt, p, p);
}
//Spleef COMMANDS. //Spleef COMMANDS.
public static boolean isPlayingSpleef(Player p) { public static boolean isPlayingSpleef(Player p) {
return SpleefManager.playerIsPlayingSpleef(p); return SpleefManager.playerIsPlayingSpleef(p);

Loading…
Cancel
Save