Fix major Item Duping bug. Include framework for new artifact abilities.

testdev
sigonasr2 8 years ago
parent 84ead5b445
commit 942654e0d1
  1. 1
      .classpath
  2. BIN
      TwosideKeeper.jar
  3. 2
      src/plugin.yml
  4. 1
      src/sig/plugin/TwosideKeeper/Boss/Arena.java
  5. 5
      src/sig/plugin/TwosideKeeper/Boss/EliteGuardian.java
  6. 26
      src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java
  7. 2
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/Camera.java
  8. 13
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java
  9. 7
      src/sig/plugin/TwosideKeeper/HelperStructures/ItemCube.java
  10. 33
      src/sig/plugin/TwosideKeeper/HelperStructures/Utils/InventoryUtils.java
  11. 52
      src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemCubeUtils.java
  12. 23
      src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java
  13. 50
      src/sig/plugin/TwosideKeeper/TwosideKeeper.java

@ -6,5 +6,6 @@
<classpathentry kind="lib" path="D:/Documents/Test Server/plugins/GlowAPI_v1.4.4.jar"/> <classpathentry kind="lib" path="D:/Documents/Test Server/plugins/GlowAPI_v1.4.4.jar"/>
<classpathentry kind="lib" path="D:/Documents/Test Server/spigot-1.9.2-R0.1-SNAPSHOT.jar"/> <classpathentry kind="lib" path="D:/Documents/Test Server/spigot-1.9.2-R0.1-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="D:/Documents/Test Server/plugins/aPlugin (99).jar"/> <classpathentry kind="lib" path="D:/Documents/Test Server/plugins/aPlugin (99).jar"/>
<classpathentry kind="src" path="/AutoPluginUpdate"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

Binary file not shown.

@ -1,6 +1,6 @@
name: TwosideKeeper name: TwosideKeeper
main: sig.plugin.TwosideKeeper.TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper
version: 3.10.9c version: 3.10.9dr1
loadbefore: [aPlugin] loadbefore: [aPlugin]
commands: commands:
money: money:

@ -97,6 +97,7 @@ public class Arena {
} }
} }
for (Player p : Bukkit.getOnlinePlayers()) { for (Player p : Bukkit.getOnlinePlayers()) {
TwosideKeeper.log("Checking for "+p.getName(), 0);
if (p.getGameMode()==GameMode.SURVIVAL) { if (p.getGameMode()==GameMode.SURVIVAL) {
if (arenaplayers.contains(p)) { if (arenaplayers.contains(p)) {
if (!insideBoundaries(p)) { if (!insideBoundaries(p)) {

@ -23,6 +23,7 @@ public class EliteGuardian extends EliteMonster{
int cutscenetimer=0; int cutscenetimer=0;
Camera cam; Camera cam;
Arena arena; Arena arena;
Location startedspot;
public EliteGuardian(Monster m) { public EliteGuardian(Monster m) {
super(m); super(m);
@ -95,9 +96,11 @@ public class EliteGuardian extends EliteMonster{
arena.AddPlayers(nearby2.toArray(new Player[nearby2.size()])); arena.AddPlayers(nearby2.toArray(new Player[nearby2.size()]));
arena.AssembleArena(); arena.AssembleArena();
TwosideKeeper.arenas.add(arena); TwosideKeeper.arenas.add(arena);
startedspot = m.getLocation().clone();
} }
} }
m.setAI(false); m.setAI(false);
m.setVelocity(new Vector(0,0,0));
break; break;
case RUNNINGCUTSCENE: case RUNNINGCUTSCENE:
cutscenetimer++; cutscenetimer++;
@ -106,6 +109,8 @@ public class EliteGuardian extends EliteMonster{
cam.Cleanup(); cam.Cleanup();
} }
m.setAI(false); m.setAI(false);
m.setVelocity(new Vector(0,0,0));
m.teleport(startedspot);
break; break;
default: default:
break; break;

@ -80,10 +80,18 @@ public enum ArtifactAbility {
new double[]{1.0,0.975,0.95,0.925,0.9,0.875,0.85,0.825,0.8,0.75,0.7,0.65,0.6,0.55,0.5},10000,40,UpgradePath.SWORD,1), new double[]{1.0,0.975,0.95,0.925,0.9,0.875,0.85,0.825,0.8,0.75,0.7,0.65,0.6,0.55,0.5},10000,40,UpgradePath.SWORD,1),
//Pickaxe abilities //Pickaxe abilities
SCAVENGE("Scavenge",ChatColor.GRAY+"[Unimplemented] Breaks off resources from armor. [VAL]% chance per hit.",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, /*SCAVENGE("Scavenge",ChatColor.GRAY+"[Unimplemented] Breaks off resources from armor. [VAL]% chance per hit.",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},
new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1000,UpgradePath.PICKAXE,1), new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1000,UpgradePath.PICKAXE,1),
MINES("Land Mine",ChatColor.GRAY+"[Unimplemented]While in combat, throw your pickaxe to send land mines towards your enemies. On contact they deal [VAL] damage.",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, MINES("Land Mine",ChatColor.GRAY+"[Unimplemented]While in combat, throw your pickaxe to send land mines towards your enemies. On contact they deal [VAL] damage.",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},
new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1000,UpgradePath.PICKAXE,1), new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1000,UpgradePath.PICKAXE,1),*/
MINES("Land Mine",ChatColor.GOLD+"Shift+Right-click"+ChatColor.RESET+" air to place down a land mine. Land mines detonate when enemies step near the mine location, dealing [VAL] damage. Mines will automatically detonate after 15 seconds of no activity.\n\nYou can place a maximum of "+ChatColor.GOLD+"[MINEAMT]"+ChatColor.RESET+" mine[MINEAMTPLURAL] at once.",new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},
new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},10000,40,UpgradePath.PICKAXE,1),
OREHARVESTER("Ore Harvester",ChatColor.GOLD+"Shift+Right-click"+ChatColor.RESET+" an ore block to convert the block into a temporary buff. The buff lasts for [VAL] seconds. Duration can be stacked for longer buffs.\n\n "+DisplayOreBonus("Coal Ore","+[COALORE_BONUS]% Critical Damage")+"\n"+DisplayOreBonus("Iron Ore","+[IRONORE_BONUS]% Block Chance")+"\n"+DisplayOreBonus("Gold Ore","+[GOLDORE_BONUS]% Critical Strike Chance")+"\n"+DisplayOreBonus("Redstone Ore","+[REDSTONEORE_BONUS] Maximum Health")+"\n"+DisplayOreBonus("Lapis Lazuli Ore","+[LAPISORE_BONUS] Health Regeneration")+"\n"+DisplayOreBonus("Diamond Ore","+[COALORE_BONUS]% Damage Reduction")+"\n"+DisplayOreBonus("Emerald Ore","+[COALORE_BONUS] Base Damage")+"\n"+LevelCost(40),new double[]{10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0},
new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},10000,100,UpgradePath.PICKAXE,40),
IMPACT("Impact","Damaging an enemy deals [VAL]% of an enemy's health as bonus physical damage on hit."+LevelCost(5),new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},
new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},250,20,UpgradePath.PICKAXE,5),
FORCESTRIKE("Force Strike","Perform an attack that slams an enemy against a wall. Enemies take [FORCESTRIKEVAL] damage on a successful slam, crumbling the walls behind them.\n\n"+ChatColor.YELLOW+"15 second cooldown",new double[]{2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0},
new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},10000,350,UpgradePath.PICKAXE,1),
//Shovel abilities //Shovel abilities
SUPPRESS("Suppression","Suppresses a mob on hit for [VAL] seconds.\n\n" SUPPRESS("Suppression","Suppresses a mob on hit for [VAL] seconds.\n\n"
@ -636,7 +644,13 @@ public enum ArtifactAbility {
text=DisplayAbility(EARTHWAVE,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} text=DisplayAbility(EARTHWAVE,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");}
} else } else
if (path==UpgradePath.PICKAXE) { if (path==UpgradePath.PICKAXE) {
text=DisplayAbility(SCAVENGE,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} //text=DisplayAbility(SCAVENGE,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");}
if (TwosideKeeper.NEWARTIFACTABILITIES_ACTIVATED) {
text=DisplayAbility(MINES,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");}
text=DisplayAbility(OREHARVESTER,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");}
text=DisplayAbility(IMPACT,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");}
text=DisplayAbility(FORCESTRIKE,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");}
}
} }
} }
@ -650,6 +664,10 @@ public enum ArtifactAbility {
return msg1; return msg1;
} }
static String DisplayOreBonus(String oretype, String bonus) {
return ChatColor.LIGHT_PURPLE+oretype+": "+ChatColor.YELLOW+" "+bonus;
}
public static String displayDescription(ArtifactAbility ability, int tier, int abilitylv, double playerdmgval) { //Level to display information for. public static String displayDescription(ArtifactAbility ability, int tier, int abilitylv, double playerdmgval) { //Level to display information for.
String msg = ability.GetDescription(); String msg = ability.GetDescription();
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
@ -666,6 +684,7 @@ public enum ArtifactAbility {
msg=msg.replace("[AOEVAL]", ChatColor.BLUE+df.format(1+calculateValue(ability,tier,abilitylv))+ChatColor.RESET); msg=msg.replace("[AOEVAL]", ChatColor.BLUE+df.format(1+calculateValue(ability,tier,abilitylv))+ChatColor.RESET);
msg=msg.replace("[POTVAL]", ChatColor.BLUE+df.format(5+calculateValue(ability,tier,abilitylv))+ChatColor.RESET); msg=msg.replace("[POTVAL]", ChatColor.BLUE+df.format(5+calculateValue(ability,tier,abilitylv))+ChatColor.RESET);
msg=msg.replace("[GRACEFULVAL]", ChatColor.BLUE+df.format(0.1+calculateValue(ability,tier,abilitylv))+ChatColor.RESET); msg=msg.replace("[GRACEFULVAL]", ChatColor.BLUE+df.format(0.1+calculateValue(ability,tier,abilitylv))+ChatColor.RESET);
msg=msg.replace("[FORCESTRIKEVAL]", ChatColor.BLUE+df.format(60+calculateValue(ability,tier,abilitylv))+ChatColor.RESET);
return msg; return msg;
} }
public static String displayDescriptionUpgrade(ArtifactAbility ability, int tier, int fromlv, int tolv, double playerdmgval) { //Level to display information for. public static String displayDescriptionUpgrade(ArtifactAbility ability, int tier, int fromlv, int tolv, double playerdmgval) { //Level to display information for.
@ -684,6 +703,7 @@ public enum ArtifactAbility {
msg=msg.replace("[AOEVAL]", DisplayChangedValue(df.format(1+calculateValue(ability,tier,fromlv))+ChatColor.RESET,df.format(1+calculateValue(ability,tier,tolv))+ChatColor.RESET)); msg=msg.replace("[AOEVAL]", DisplayChangedValue(df.format(1+calculateValue(ability,tier,fromlv))+ChatColor.RESET,df.format(1+calculateValue(ability,tier,tolv))+ChatColor.RESET));
msg=msg.replace("[POTVAL]", DisplayChangedValue(df.format(5+calculateValue(ability,tier,fromlv))+ChatColor.RESET,df.format(5+calculateValue(ability,tier,tolv))+ChatColor.RESET)); msg=msg.replace("[POTVAL]", DisplayChangedValue(df.format(5+calculateValue(ability,tier,fromlv))+ChatColor.RESET,df.format(5+calculateValue(ability,tier,tolv))+ChatColor.RESET));
msg=msg.replace("[GRACEFULVAL]", DisplayChangedValue(df.format(0.1+calculateValue(ability,tier,fromlv))+ChatColor.RESET,df.format(0.1+calculateValue(ability,tier,tolv))+ChatColor.RESET)); msg=msg.replace("[GRACEFULVAL]", DisplayChangedValue(df.format(0.1+calculateValue(ability,tier,fromlv))+ChatColor.RESET,df.format(0.1+calculateValue(ability,tier,tolv))+ChatColor.RESET));
msg=msg.replace("[FORCESTRIKEVAL]", DisplayChangedValue(df.format(60+calculateValue(ability,tier,fromlv))+ChatColor.RESET,df.format(60+calculateValue(ability,tier,tolv))+ChatColor.RESET));
return msg; return msg;
} }

@ -64,7 +64,7 @@ public class Camera {
Player p = Bukkit.getPlayer(id); Player p = Bukkit.getPlayer(id);
if (p!=null && p.isValid()) { if (p!=null && p.isValid()) {
p.setGameMode(GameMode.SPECTATOR); p.setGameMode(GameMode.SPECTATOR);
p.setFlying(true); if (p.getAllowFlight()) {p.setFlying(true);}
p.setSpectatorTarget(p); p.setSpectatorTarget(p);
} else { } else {
TwosideKeeper.ScheduleRemoval(camera_viewerlocs, p); TwosideKeeper.ScheduleRemoval(camera_viewerlocs, p);

@ -123,12 +123,12 @@ public class GenericFunctions {
public static ItemStack breakHardenedItem(ItemStack item, Player p) { public static ItemStack breakHardenedItem(ItemStack item, Player p) {
/*StackTraceElement[] stacktrace = new Throwable().getStackTrace(); StackTraceElement[] stacktrace = new Throwable().getStackTrace();
StringBuilder stack = new StringBuilder("Mini stack tracer:"); StringBuilder stack = new StringBuilder("Mini stack tracer:");
for (int i=0;i<Math.min(10, stacktrace.length);i++) { for (int i=0;i<Math.min(10, stacktrace.length);i++) {
stack.append("\n"+stacktrace[i].getClassName()+": **"+stacktrace[i].getFileName()+"** "+stacktrace[i].getMethodName()+"():"+stacktrace[i].getLineNumber()); stack.append("\n"+stacktrace[i].getClassName()+": **"+stacktrace[i].getFileName()+"** "+stacktrace[i].getMethodName()+"():"+stacktrace[i].getLineNumber());
} }
TwosideKeeper.log("Trace:"+stack, 0);*/ TwosideKeeper.log("Trace:"+stack, 0);
int break_count = getHardenedItemBreaks(item); int break_count = getHardenedItemBreaks(item);
if (break_count>0) { if (break_count>0) {
ItemMeta m = item.getItemMeta(); ItemMeta m = item.getItemMeta();
@ -150,6 +150,9 @@ public class GenericFunctions {
if ((break_count-1)<0) { if ((break_count-1)<0) {
break_count=0; break_count=0;
} }
if (p!=null) {
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f);
}
TwosideKeeper.log("Setting breaks remaining to "+(break_count-1),3); TwosideKeeper.log("Setting breaks remaining to "+(break_count-1),3);
break; break;
} }
@ -163,22 +166,25 @@ public class GenericFunctions {
break_count--; break_count--;
if (p!=null && break_count==0) { 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!"); p.sendMessage(ChatColor.GOLD+"WARNING!"+ChatColor.GREEN+ " Your "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(item)+ChatColor.WHITE+" is going to break soon!");
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f);
} }
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 {
//This item is technically destroyed. //This item is technically destroyed.
TwosideKeeper.log("Break count was 0.", 0);
if (p!=null) { if (p!=null) {
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f);
TwosideKeeper.log("Played break sound.", 0);
} }
if (isArtifactEquip(item)) { if (isArtifactEquip(item)) {
//We can turn it into dust! //We can turn it into dust!
TwosideKeeper.log("This is an artifact equip.", 0);
if (p!=null) { if (p!=null) {
p.sendMessage(ChatColor.LIGHT_PURPLE+"You still feel the artifact's presence inside of you..."); p.sendMessage(ChatColor.LIGHT_PURPLE+"You still feel the artifact's presence inside of you...");
} }
return convertArtifactToDust(item); return convertArtifactToDust(item);
} }
TwosideKeeper.log("Return null here.", 0);
return null; return null;
} }
} }
@ -3367,6 +3373,7 @@ public class GenericFunctions {
//This is an item cube. Update its lore. //This is an item cube. Update its lore.
int id = Integer.parseInt(ItemUtils.GetLoreLineContainingSubstring(item, ChatColor.DARK_PURPLE+"ID#").split("#")[1]); int id = Integer.parseInt(ItemUtils.GetLoreLineContainingSubstring(item, ChatColor.DARK_PURPLE+"ID#").split("#")[1]);
ItemCubeUtils.updateVacuumCubeSuctionLoreLine(item); ItemCubeUtils.updateVacuumCubeSuctionLoreLine(item);
//ItemCubeUtils.updateFilterCubeFilterLoreLine(item);
if (TwosideKeeper.PLAYERJOINTOGGLE) { if (TwosideKeeper.PLAYERJOINTOGGLE) {
ItemCubeUtils.updateItemCubeUpdateList(item); ItemCubeUtils.updateItemCubeUpdateList(item);
} }

@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.InventoryUtils;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils;
public class ItemCube { public class ItemCube {
@ -41,25 +42,27 @@ public class ItemCube {
public static void addToViewersOfItemCube(int idnumb, ItemStack cursor, Player check) { public static void addToViewersOfItemCube(int idnumb, ItemStack cursor, Player check) {
Inventory inv = getViewingItemCubeInventory(idnumb, check); Inventory inv = getViewingItemCubeInventory(idnumb, check);
if (inv!=null) { if (inv!=null && cursor!=null) {
inv.addItem(cursor); inv.addItem(cursor);
} }
} }
public static void addToViewersOfItemCube(int idnumb, ItemStack[] cursor, Player check) { public static void addToViewersOfItemCube(int idnumb, ItemStack[] cursor, Player check) {
Inventory inv = getViewingItemCubeInventory(idnumb, check); Inventory inv = getViewingItemCubeInventory(idnumb, check);
cursor = InventoryUtils.RemoveAllNullItems(cursor);
if (inv!=null) { if (inv!=null) {
inv.addItem(cursor); inv.addItem(cursor);
} }
} }
public static void removeFromViewersofItemCube(int idnumb, ItemStack cursor, Player check) { public static void removeFromViewersofItemCube(int idnumb, ItemStack cursor, Player check) {
Inventory inv = getViewingItemCubeInventory(idnumb, check); Inventory inv = getViewingItemCubeInventory(idnumb, check);
if (inv!=null) { if (inv!=null && cursor!=null) {
inv.removeItem(cursor); inv.removeItem(cursor);
} }
} }
public static void removeFromViewersofItemCube(int idnumb, ItemStack[] cursor, Player check) { public static void removeFromViewersofItemCube(int idnumb, ItemStack[] cursor, Player check) {
Inventory inv = getViewingItemCubeInventory(idnumb, check); Inventory inv = getViewingItemCubeInventory(idnumb, check);
cursor = InventoryUtils.RemoveAllNullItems(cursor);
if (inv!=null) { if (inv!=null) {
inv.removeItem(cursor); inv.removeItem(cursor);
} }

@ -1,6 +1,7 @@
package sig.plugin.TwosideKeeper.HelperStructures.Utils; package sig.plugin.TwosideKeeper.HelperStructures.Utils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -61,7 +62,13 @@ public class InventoryUtils {
} }
} }
} }
ItemCube.addToViewersOfItemCube(id,remaining,null);
Inventory collectionOfItems = AddItemsThatHaveBeenAddedToOurInventoryForOtherVacuumCubeViewers(p,
remaining, itemCubeContents, remainingitems);
//TwosideKeeper.log(Arrays.toString(collectionOfItems.getContents()), 0);
ItemCube.addToViewersOfItemCube(id,collectionOfItems.getContents(),null);
TwosideKeeper.itemCube_saveConfig(id, itemslist, CubeType.VACUUM); TwosideKeeper.itemCube_saveConfig(id, itemslist, CubeType.VACUUM);
TwosideKeeper.itemcube_updates.put(id, itemcube_list);//This Item Cube can be saved. TwosideKeeper.itemcube_updates.put(id, itemcube_list);//This Item Cube can be saved.
/*for (ItemStack i : remainingitems.values()) { /*for (ItemStack i : remainingitems.values()) {
@ -74,6 +81,20 @@ public class InventoryUtils {
} }
return remaining; return remaining;
} }
public static Inventory AddItemsThatHaveBeenAddedToOurInventoryForOtherVacuumCubeViewers(Player p,
ItemStack[] remaining, List<ItemStack> itemCubeContents, HashMap<Integer, ItemStack> remainingitems) {
Inventory collectionOfItems = Bukkit.createInventory(p, itemCubeContents.size());
for (int i=0;i<remaining.length;i++) {
collectionOfItems.addItem(remaining[i].clone());
}
for (int number : remainingitems.keySet()) {
ItemStack it = remainingitems.get(number);
collectionOfItems.removeItem(it);
}
return collectionOfItems;
}
public static boolean isCarryingFilterCube(Player p) { public static boolean isCarryingFilterCube(Player p) {
for (ItemStack items : p.getInventory().getContents()) { for (ItemStack items : p.getInventory().getContents()) {
if (items!=null && CustomItem.isFilterCube(items)) { if (items!=null && CustomItem.isFilterCube(items)) {
@ -227,4 +248,14 @@ public class InventoryUtils {
public static String getInventoryHash(Inventory destination) { public static String getInventoryHash(Inventory destination) {
return destination.getLocation().getX()+destination.getLocation().getY()+destination.getLocation().getZ()+destination.getLocation().getWorld().getName(); return destination.getLocation().getX()+destination.getLocation().getY()+destination.getLocation().getZ()+destination.getLocation().getWorld().getName();
} }
public static ItemStack[] RemoveAllNullItems(ItemStack[] contents) {
List<ItemStack> items = new ArrayList<ItemStack>();
for (int i=0;i<contents.length;i++) {
if (contents[i]!=null) {
items.add(contents[i]);
}
}
return items.toArray(new ItemStack[items.size()]);
}
} }

@ -27,6 +27,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.Common.ItemContainer;
public class ItemCubeUtils { public class ItemCubeUtils {
public final static String SUCTION_STRING = ChatColor.GRAY+"Block Collection: "; public final static String SUCTION_STRING = ChatColor.GRAY+"Block Collection: ";
public final static String FILTER_STRING = ChatColor.GRAY+"Filter Blocks: ";
public static int getItemCubeID(ItemStack item) { public static int getItemCubeID(ItemStack item) {
return Integer.parseInt(ItemUtils.GetLoreLineContainingSubstring(item, ChatColor.DARK_PURPLE+"ID#").split("#")[1]); return Integer.parseInt(ItemUtils.GetLoreLineContainingSubstring(item, ChatColor.DARK_PURPLE+"ID#").split("#")[1]);
} }
@ -309,6 +310,28 @@ public class ItemCubeUtils {
return false; return false;
} }
} }
public static boolean isFilterOn(int id) {
File config;
config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data");
FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
CubeType type = CubeType.getCubeTypeFromID(workable.getInt("cubetype"));
if (type==CubeType.FILTER) {
if (workable.contains("filter")) {
return workable.getBoolean("filter");
} else {
workable.set("filter", true);
try {
workable.save(config);
} catch (IOException e) {
e.printStackTrace();
}
return true;
}
} else {
return false;
}
}
public static void toggleSuction(int id) { public static void toggleSuction(int id) {
File config; File config;
config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data"); config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data");
@ -328,6 +351,25 @@ public class ItemCubeUtils {
} }
} }
} }
public static void toggleFilter(int id) {
File config;
config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data");
FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
CubeType type = CubeType.getCubeTypeFromID(workable.getInt("cubetype"));
if (type==CubeType.FILTER) {
if (isSuctionOn(id)) {
workable.set("filter",false);
} else {
workable.set("filter",true);
}
try {
workable.save(config);
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void updateVacuumCubeSuctionLoreLine(ItemStack item) { public static void updateVacuumCubeSuctionLoreLine(ItemStack item) {
if (getCubeType(ItemCubeUtils.getItemCubeID(item))==CubeType.VACUUM) { if (getCubeType(ItemCubeUtils.getItemCubeID(item))==CubeType.VACUUM) {
ItemUtils.DeleteAllLoreLinesAtAndAfterLineContainingSubstring(item, ChatColor.WHITE+"Contents ("); ItemUtils.DeleteAllLoreLinesAtAndAfterLineContainingSubstring(item, ChatColor.WHITE+"Contents (");
@ -338,6 +380,16 @@ public class ItemCubeUtils {
} }
} }
} }
public static void updateFilterCubeFilterLoreLine(ItemStack item) {
if (getCubeType(ItemCubeUtils.getItemCubeID(item))==CubeType.FILTER) {
ItemUtils.DeleteAllLoreLinesAtAndAfterLineContainingSubstring(item, ChatColor.WHITE+"Contents (");
if (ItemUtils.LoreContainsSubstring(item, FILTER_STRING)) {
ItemUtils.ModifyLoreLineContainingSubstring(item, FILTER_STRING, FILTER_STRING+(ItemCubeUtils.isFilterOn(ItemCubeUtils.getItemCubeID(item))?ChatColor.GREEN+"ON":ChatColor.RED+"OFF"));
} else {
ItemUtils.addLore(item, FILTER_STRING+(ItemCubeUtils.isFilterOn(ItemCubeUtils.getItemCubeID(item))?ChatColor.GREEN+"ON":ChatColor.RED+"OFF"));
}
}
}
public static void updateItemCubeUpdateList(ItemStack item) { public static void updateItemCubeUpdateList(ItemStack item) {
List<ItemContainer> itemcube_list = new ArrayList<ItemContainer>(); List<ItemContainer> itemcube_list = new ArrayList<ItemContainer>();
for (ItemStack items : ItemCubeUtils.getItemCubeContents(ItemCubeUtils.getItemCubeID(item))) { for (ItemStack items : ItemCubeUtils.getItemCubeContents(ItemCubeUtils.getItemCubeID(item))) {

@ -316,4 +316,27 @@ public class ItemUtils {
public static boolean hasDisplayName(ItemStack item) { public static boolean hasDisplayName(ItemStack item) {
return getDisplayName(item)!=null; return getDisplayName(item)!=null;
} }
public static void reduceEquipDurability(Player p, boolean mainhand, boolean offhand, boolean armor, int amt, double pct) {
if (mainhand && GenericFunctions.isEquip(p.getEquipment().getItemInMainHand())) {
aPlugin.API.damageItem(p, p.getEquipment().getItemInMainHand(), amt+(int)(p.getEquipment().getItemInMainHand().getType().getMaxDurability()*pct+1));
}
if (offhand && GenericFunctions.isEquip(p.getEquipment().getItemInOffHand())) {
aPlugin.API.damageItem(p, p.getEquipment().getItemInOffHand(), amt+(int)(p.getEquipment().getItemInOffHand().getType().getMaxDurability()*pct+1));
}
if (armor) {
if (GenericFunctions.isEquip(p.getEquipment().getHelmet())) {
aPlugin.API.damageItem(p, p.getEquipment().getHelmet(), amt+(int)(p.getEquipment().getHelmet().getType().getMaxDurability()*pct+1));
}
if (GenericFunctions.isEquip(p.getEquipment().getChestplate())) {
aPlugin.API.damageItem(p, p.getEquipment().getChestplate(), amt+(int)(p.getEquipment().getChestplate().getType().getMaxDurability()*pct+1));
}
if (GenericFunctions.isEquip(p.getEquipment().getLeggings())) {
aPlugin.API.damageItem(p, p.getEquipment().getLeggings(), amt+(int)(p.getEquipment().getLeggings().getType().getMaxDurability()*pct+1));
}
if (GenericFunctions.isEquip(p.getEquipment().getBoots())) {
aPlugin.API.damageItem(p, p.getEquipment().getBoots(), amt+(int)(p.getEquipment().getBoots().getType().getMaxDurability()*pct+1));
}
}
}
} }

@ -676,6 +676,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
private final class ControlChargeZombies implements Runnable { private final class ControlChargeZombies implements Runnable {
public void run(){ public void run(){
//Control charge zombies.. //Control charge zombies..
long time = System.nanoTime();
for (ChargeZombie cz : chargezombies.values()) { for (ChargeZombie cz : chargezombies.values()) {
if (cz.m==null || !cz.m.isValid() || !cz.isAlive() || !cz.hasTarget() || (cz.GetZombie().getWorld().getName().equalsIgnoreCase("world") && cz.GetZombie().getLocation().getY()>32)) { if (cz.m==null || !cz.m.isValid() || !cz.isAlive() || !cz.hasTarget() || (cz.GetZombie().getWorld().getName().equalsIgnoreCase("world") && cz.GetZombie().getLocation().getY()>32)) {
//This has to be removed... //This has to be removed...
@ -757,6 +758,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
} }
TwosideKeeper.HeartbeatLogger.AddEntry("Charge Zombie Handling", (int)(System.nanoTime()-time));time=System.nanoTime();
for (CustomMonster cs : custommonsters.values()) { for (CustomMonster cs : custommonsters.values()) {
if (cs.m==null || !cs.m.isValid() || !cs.isAlive()) { if (cs.m==null || !cs.m.isValid() || !cs.isAlive()) {
//This has to be removed... //This has to be removed...
@ -769,6 +771,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
cs.runTick(); cs.runTick();
} }
} }
TwosideKeeper.HeartbeatLogger.AddEntry("Custom Monster Handling", (int)(System.nanoTime()-time));time=System.nanoTime();
//Control elite monsters. //Control elite monsters.
for (EliteMonster em : elitemonsters) { for (EliteMonster em : elitemonsters) {
if (!em.m.isValid()) { if (!em.m.isValid()) {
@ -778,6 +781,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
em.runTick(); em.runTick();
} }
} }
TwosideKeeper.HeartbeatLogger.AddEntry("Elite Monster Handling", (int)(System.nanoTime()-time));time=System.nanoTime();
for (Entity e : suppressed_entities) { for (Entity e : suppressed_entities) {
if (e==null || !e.isValid() || if (e==null || !e.isValid() ||
GenericFunctions.getSuppressionTime(e)<=0) { GenericFunctions.getSuppressionTime(e)<=0) {
@ -789,16 +793,22 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ScheduleRemoval(suppressed_entities,e); ScheduleRemoval(suppressed_entities,e);
} }
} }
TwosideKeeper.HeartbeatLogger.AddEntry("Suppressed Entity Handling", (int)(System.nanoTime()-time));time=System.nanoTime();
for (LavaPlume lp : lavaplume_list) { for (LavaPlume lp : lavaplume_list) {
if (!lp.runTick()) { if (!lp.runTick()) {
ScheduleRemoval(lavaplume_list,lp); ScheduleRemoval(lavaplume_list,lp);
} }
} }
TwosideKeeper.HeartbeatLogger.AddEntry("Lava Plume Handling", (int)(System.nanoTime()-time));time=System.nanoTime();
for (Player p : Bukkit.getOnlinePlayers()) { for (Player p : Bukkit.getOnlinePlayers()) {
long time1 = System.nanoTime();
runServerHeartbeat.runFilterCubeCollection(p); runServerHeartbeat.runFilterCubeCollection(p);
TwosideKeeper.HeartbeatLogger.AddEntry("Player Cycle Handling->Filter Cube Handling", (int)(System.nanoTime()-time1));time1=System.nanoTime();
runServerHeartbeat.runVacuumCubeSuckup(p); runServerHeartbeat.runVacuumCubeSuckup(p);
TwosideKeeper.HeartbeatLogger.AddEntry("Player Cycle Handling->Vacuum Cube Handling", (int)(System.nanoTime()-time1));time1=System.nanoTime();
if (PlayerStructure.GetPlayerStructure(p).last_rejuvenate+200>TwosideKeeper.getServerTickTime()) { if (PlayerStructure.GetPlayerStructure(p).last_rejuvenate+200>TwosideKeeper.getServerTickTime()) {
GenericFunctions.HealEntity(p, 5); GenericFunctions.HealEntity(p, 5);
TwosideKeeper.HeartbeatLogger.AddEntry("Player Cycle Handling->Rejuvenate Handling", (int)(System.nanoTime()-time1));time1=System.nanoTime();
} }
/*if (p.getVehicle() instanceof EnderDragon) { /*if (p.getVehicle() instanceof EnderDragon) {
EnderDragon ed = (EnderDragon)p.getVehicle(); EnderDragon ed = (EnderDragon)p.getVehicle();
@ -806,21 +816,25 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ed.teleport(ed.getLocation().setDirection(p.getLocation().getDirection())); ed.teleport(ed.getLocation().setDirection(p.getLocation().getDirection()));
}*/ }*/
} }
TwosideKeeper.HeartbeatLogger.AddEntry("Player Cycle Handling", (int)(System.nanoTime()-time));time=System.nanoTime();
for (TemporaryLava tl : temporary_lava_list) { for (TemporaryLava tl : temporary_lava_list) {
if (!tl.runTick()) { if (!tl.runTick()) {
ScheduleRemoval(temporary_lava_list,tl); ScheduleRemoval(temporary_lava_list,tl);
} }
} }
TwosideKeeper.HeartbeatLogger.AddEntry("Temporary Lava Handling", (int)(System.nanoTime()-time));time=System.nanoTime();
for (TemporaryIce tl : temporary_ice_list) { for (TemporaryIce tl : temporary_ice_list) {
if (!tl.run()) { if (!tl.run()) {
ScheduleRemoval(temporary_ice_list,tl); ScheduleRemoval(temporary_ice_list,tl);
} }
} }
TwosideKeeper.HeartbeatLogger.AddEntry("Temporary Ice Handling", (int)(System.nanoTime()-time));time=System.nanoTime();
for (Camera cam : cameras) { for (Camera cam : cameras) {
if (!cam.runTick()) { if (!cam.runTick()) {
ScheduleRemoval(cameras,cam); ScheduleRemoval(cameras,cam);
} }
} }
TwosideKeeper.HeartbeatLogger.AddEntry("Temporary Camera Handling", (int)(System.nanoTime()-time));time=System.nanoTime();
} }
private void UpdateLavaBlock(Block lavamod) { private void UpdateLavaBlock(Block lavamod) {
@ -1069,7 +1083,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
getServer().getScheduler().scheduleSyncRepeatingTask(this, new runServerTick(), 1l, 1l); getServer().getScheduler().scheduleSyncRepeatingTask(this, new runServerTick(), 1l, 1l);
//log(Calendar.getInstance().get(Calendar.DAY_OF_WEEK)+"",0); //log(Calendar.getInstance().get(Calendar.DAY_OF_WEEK)+"",0);
log("This is here to change the file size if necessary Kappa",5); log("This is here to change the file size if necessary Kappa Kappa Kappa No Copy-pasterino Kappachino Lulu c: Please update version number.",5);
} }
private static void InitializeBotCommands() { private static void InitializeBotCommands() {
@ -1732,6 +1746,19 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
c.setCameraAroundCircle(Double.parseDouble(args[1]), Double.parseDouble(args[2]), new Location(Bukkit.getWorld("world"),0,64,0), 5); c.setCameraAroundCircle(Double.parseDouble(args[1]), Double.parseDouble(args[2]), new Location(Bukkit.getWorld("world"),0,64,0), 5);
} }
}break; }break;
case "DAMAGE":{
int val = Integer.parseInt(args[1]);
ItemUtils.reduceEquipDurability(p, true, true, true, val, 0);
}break;
case "BREAK":{
ItemStack[] armor = GenericFunctions.getArmor(p,true);
for (ItemStack item : armor) {
if (GenericFunctions.isEquip(item)) {
PlayerItemBreakEvent ev = new PlayerItemBreakEvent(p,item);
Bukkit.getPluginManager().callEvent(ev);
}
}
}break;
} }
} }
//LivingEntity m = MonsterController.convertMonster((Monster)p.getWorld().spawnEntity(p.getLocation(),EntityType.ZOMBIE), MonsterDifficulty.ELITE); //LivingEntity m = MonsterController.convertMonster((Monster)p.getWorld().spawnEntity(p.getLocation(),EntityType.ZOMBIE), MonsterDifficulty.ELITE);
@ -1820,6 +1847,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
h.getInventory().setItem(0, new ItemStack(Material.DIAMOND_BARDING)); h.getInventory().setItem(0, new ItemStack(Material.DIAMOND_BARDING));
h.setPassenger(s);*/ h.setPassenger(s);*/
ItemStack shield = new ItemStack(Material.SHIELD);
shield.setDurability((short) (shield.getType().getMaxDurability()-1));
GenericFunctions.giveItem(p, shield);
//Arrow newar = p.getWorld().spawnArrow(p.getLocation(), p.getLocation().getDirection(), 1f, 12f); //Arrow newar = p.getWorld().spawnArrow(p.getLocation(), p.getLocation().getDirection(), 1f, 12f);
//GenericFunctions.setBowMode(p.getEquipment().getItemInMainHand(), BowMode.SNIPE); //GenericFunctions.setBowMode(p.getEquipment().getItemInMainHand(), BowMode.SNIPE);
//p.sendMessage("This is bow mode "+GenericFunctions.getBowMode(p.getEquipment().getItemInMainHand())); //p.sendMessage("This is bow mode "+GenericFunctions.getBowMode(p.getEquipment().getItemInMainHand()));
@ -5148,6 +5179,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ItemStack item = ev.getCurrentItem(); ItemStack item = ev.getCurrentItem();
if (CustomItem.isFilterCube(item)) { if (CustomItem.isFilterCube(item)) {
int cubeid = ItemCubeUtils.getItemCubeID(item); int cubeid = ItemCubeUtils.getItemCubeID(item);
//ItemCubeUtils.toggleFilter(cubeid);
Hopper targethopper = ItemCubeUtils.getFilterCubeHopper(cubeid); Hopper targethopper = ItemCubeUtils.getFilterCubeHopper(cubeid);
targethopper.getChunk().load(); targethopper.getChunk().load();
GenericFunctions.renameHopper(targethopper, ChatColor.stripColor(((ItemUtils.hasDisplayName(item))?ItemUtils.getDisplayName(item):"Filter Inventory ID#"+cubeid))); GenericFunctions.renameHopper(targethopper, ChatColor.stripColor(((ItemUtils.hasDisplayName(item))?ItemUtils.getDisplayName(item):"Filter Inventory ID#"+cubeid)));
@ -6039,20 +6071,22 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (!pm.isRanger(p)) { if (!pm.isRanger(p)) {
if (p.isBlocking() || pm.isDefender(p)) { if (p.isBlocking() || pm.isDefender(p)) {
//Only reduce durability of the shield. //Only reduce durability of the shield.
ItemStack[] equips = GenericFunctions.getEquipment(p, true); /*ItemStack[] equips = GenericFunctions.getEquipment(p, true);
if (GenericFunctions.isEquip(equips[0])) { if (GenericFunctions.isEquip(equips[0])) {
aPlugin.API.damageItem(p, equips[0], 3+((int)((equips[0].getType().getMaxDurability()*0.01)+1))); aPlugin.API.damageItem(p, equips[0], 3+((int)((equips[0].getType().getMaxDurability()*0.01)+1)));
} }
if (GenericFunctions.isEquip(equips[1])) { if (GenericFunctions.isEquip(equips[1])) {
aPlugin.API.damageItem(p, equips[0], 3+((int)((equips[0].getType().getMaxDurability()*0.01)+1))); aPlugin.API.damageItem(p, equips[0], 3+((int)((equips[0].getType().getMaxDurability()*0.01)+1)));
} }*/
ItemUtils.reduceEquipDurability(p, true, true, false, 3, 0.01);
} else { } else {
ItemStack[] equips = GenericFunctions.getArmor(p, false); /*ItemStack[] equips = GenericFunctions.getArmor(p, false);
for (ItemStack equip : equips) { for (ItemStack equip : equips) {
if (GenericFunctions.isEquip(equip)) { if (GenericFunctions.isEquip(equip)) {
aPlugin.API.damageItem(p, equip, 3+((int)((equip.getType().getMaxDurability()*0.01)+1))); aPlugin.API.damageItem(p, equip, 3+((int)((equip.getType().getMaxDurability()*0.01)+1)));
} }
} }*/
ItemUtils.reduceEquipDurability(p, false, false, true, 3, 0.01);
} }
} }
} }
@ -7366,13 +7400,17 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
Player p = ev.getPlayer(); Player p = ev.getPlayer();
ItemStack item = ev.getBrokenItem(); ItemStack item = ev.getBrokenItem();
//See if this item has lore. //See if this item has lore.
TwosideKeeper.log("Break item event triggered for "+item, 0);
if (GenericFunctions.getHardenedItemBreaks(item)>0) { if (GenericFunctions.getHardenedItemBreaks(item)>0) {
//item.setAmount(1); //item.setAmount(1);
TwosideKeeper.log("Hardened Item Breaks is greater than 0", 0);
GenericFunctions.breakHardenedItem(item,p); GenericFunctions.breakHardenedItem(item,p);
} else } else
{ {
TwosideKeeper.log("Hardened Item Breaks is less than or equal to 0... Breaking.", 0);
ItemStack test = GenericFunctions.breakHardenedItem(item,p); ItemStack test = GenericFunctions.breakHardenedItem(item,p);
if (test!=null) { if (test!=null) {
TwosideKeeper.log("Exited hardened item break. Result returned was not null! "+test, 0);
//We have to give this player the item! //We have to give this player the item!
if (test.getAmount()==0) { if (test.getAmount()==0) {
test.setAmount(1); //We can't give 0 of something. test.setAmount(1); //We can't give 0 of something.
@ -7389,6 +7427,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (!foundone) { if (!foundone) {
GenericFunctions.giveItem(p, test); GenericFunctions.giveItem(p, test);
} }
} else {
TwosideKeeper.log("Exited hardened item break. Result returned was null!", 0);
} }
breakdownItem(item,p); breakdownItem(item,p);
} }

Loading…
Cancel
Save