diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index 5861f01..61654e1 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/plugin.yml b/src/plugin.yml index 97c3a7c..94f9dd5 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper -version: 3.8.4 +version: 3.8.4b commands: money: description: Tells the player the amount of money they are holding. diff --git a/src/sig/plugin/TwosideKeeper/AutoUpdatePlugin.java b/src/sig/plugin/TwosideKeeper/AutoUpdatePlugin.java index d4f4e94..9cd97eb 100644 --- a/src/sig/plugin/TwosideKeeper/AutoUpdatePlugin.java +++ b/src/sig/plugin/TwosideKeeper/AutoUpdatePlugin.java @@ -89,6 +89,9 @@ public class AutoUpdatePlugin implements Runnable { DiscordMessageSender.sendItalicizedRawMessageDiscord("The server has detected a new version of "+ChatColor.YELLOW+plugins.get(ii).name+"."); Bukkit.broadcastMessage("The server has detected a new version of "+ChatColor.YELLOW+plugins.get(ii).name+"."+ChatColor.GRAY+ChatColor.ITALIC+"If all players leave, the update will occur immediately."); } + if (restarting) { + TwosideKeeper.updateServer(); + } }},1); TwosideKeeper.log("New hash: "+md5, 2); plugins.get(i).hash = md5; @@ -104,9 +107,6 @@ public class AutoUpdatePlugin implements Runnable { }*/ } } - if (restarting) { - TwosideKeeper.updateServer(); - } } public void AddPlugin(String name, String url) { diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index 6db734b..ac35d56 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -114,7 +114,9 @@ public class GenericFunctions { 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!"); } - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); + if (p!=null) { + p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); + } return breakObscureHardenedItem(item); } else { lore.set(i, ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+(break_count-1)); @@ -130,17 +132,80 @@ public class GenericFunctions { 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!"); + p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); } - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); return item; //By setting the amount to 1, you refresh the item in the player's inventory. } else { //This item is technically destroyed. - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); - return new ItemStack(Material.AIR); + if (p!=null) { + p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); + } + if (isArtifactEquip(item)) { + //We can turn it into dust! + if (p!=null) { + p.sendMessage(ChatColor.LIGHT_PURPLE+"You still feel the artifact's presence inside of you..."); + } + return convertArtifactToDust(item); + } + return null; } } + public static ItemStack convertArtifactToDust(ItemStack item) { + //Add one line of lore to indicate it's broken dust. + ItemMeta m = item.getItemMeta(); + List oldlore = m.getLore(); + oldlore.add(0,ChatColor.DARK_BLUE+""+ChatColor.MAGIC+item.getType()); + oldlore.add(1,ChatColor.GOLD+""+ChatColor.BOLD+"[ARTIFACT DUST]"); + oldlore.add(2,ChatColor.DARK_BLUE+""+ChatColor.MAGIC+item.getType()); + oldlore.add(3,ChatColor.DARK_PURPLE+"Its physical form may be lost"); + oldlore.add(4,ChatColor.DARK_PURPLE+"but there might still be some"); + oldlore.add(5,ChatColor.DARK_PURPLE+"power hidden within..."); + oldlore.add(6,""); + + for (int i=0;i oldlore = m.getLore(); + Material gettype = Material.valueOf(ChatColor.stripColor(oldlore.get(0))); + oldlore.remove(6); + oldlore.remove(5); + oldlore.remove(4); + oldlore.remove(3); + oldlore.remove(2); + oldlore.remove(1); + oldlore.remove(0); + + for (int i=0;i newlore = new ArrayList(); diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java b/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java index 6aa81db..4083e44 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java @@ -464,9 +464,61 @@ public class WorldShop { if (message.endsWith("\n")) { message.substring(0, message.length()-1); } + + message=obfuscateAllMagicCodes(message); + return message; } + private static String obfuscateAllMagicCodes(String message) { + StringBuilder newstring = new StringBuilder(""); + boolean isMagic=false; + boolean WillBeMagic=false; + int linenumb = 0; + int charnumb = 0; + boolean isColorCode=false; + for (int i=0;i0 && !pd.opened_another_cube) { + int index = pd.itemcubelist.size()-1; + Integer itemcubeid = pd.itemcubelist.get(index); + TwosideKeeper.log("Popping Item Cube ID "+index+" from "+p.getName()+"'s list.", 2); + pd.itemcubelist.remove(index); + + Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() { + public void run() { + if (!ItemCube.isSomeoneViewingItemCube(itemcubeid,p)) { + //pd.itemcubeviews.add(p.getOpenInventory()); + CubeType size = TwosideKeeper.itemCube_getCubeType(itemcubeid); + int inv_size = 9; + if (size!=CubeType.NORMAL) { + inv_size=27; + } + Inventory temp = Bukkit.getServer().createInventory(p, inv_size, "Item Cube #"+itemcubeid); + TwosideKeeper.openItemCubeInventory(temp); + InventoryView newinv = p.openInventory(temp); + pd.isViewingItemCube=true; + p.playSound(p.getLocation(),Sound.BLOCK_CHEST_OPEN,1.0f,1.0f); + } else { + p.openInventory(ItemCube.getViewingItemCubeInventory(itemcubeid, p)); + pd.isViewingItemCube=true; + p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f); + } + }},1); + } + } + public static void removeAllItemCubeWindows(Player p) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + pd.itemcubelist.clear(); + } + /*int id = 0; //LEGACY CODE. int size = 0; public ItemCubeWindow(int id, int size) { @@ -80,5 +122,5 @@ public class ItemCubeWindow { return p.getOpenInventory().getTopInventory().getSize(); } return -1; - } + }*/ } diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index c985583..5ddadc2 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -92,6 +92,7 @@ public class PlayerStructure { public long lastdeath = 0; public int previousparty = -1; public long lastblock = 0; + public List itemcubelist = new ArrayList(); public double prev_weapondmg=0.0; public double prev_buffdmg=0.0; @@ -110,6 +111,7 @@ public class PlayerStructure { public boolean isPlayingSpleef=false; public long lastrightclick = 0; + public boolean opened_another_cube=false; //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) { diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 2e8a080..96c356a 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -3245,6 +3245,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } p.playSound(p.getLocation(), Sound.BLOCK_CHEST_CLOSE, 1.0f, 1.0f); itemCube_saveConfig(id,itemcube_contents); + ItemCubeWindow.popItemCubeWindow(p); pd.isViewingItemCube=false; } if (ev.getInventory().getLocation()!=null) { @@ -3462,6 +3463,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } + if (ev.getInventory().getTitle().contains("Item Cube #") && + ev.getRawSlot()==-999) { + //log("Cursor: "+ev.getCursor().toString(),2); + ItemStack item = ev.getCursor(); + if (item.getType()==Material.AIR) { + ItemCubeWindow.removeAllItemCubeWindows((Player)ev.getWhoClicked()); + ev.getWhoClicked().closeInventory(); + } + } + //LEFT CLICK STUFF. //WARNING! This only happens for ITEM CUBES! Do not add other items in here! pd = (PlayerStructure) playerdata.get(ev.getWhoClicked().getUniqueId()); @@ -3745,8 +3756,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //p.playSound(p.getLocation(), Sound.BLOCK_NOTE_HARP, 0.4f, 0.2f); ev.setCancelled(true); } else { - log("This is an Item Cube.",5); Player p = (Player)ev.getWhoClicked(); + if (itemcubeid!=-1) { + //This means we are viewing an item cube currently. Add it to our list. + ItemCubeWindow.addItemCubeWindow(p, itemcubeid); + } + log("This is an Item Cube.",5); int inventory_size; if (ev.getCurrentItem().getType()==Material.CHEST) { inventory_size=9; @@ -3758,9 +3773,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.setCancelled(true); ev.setResult(Result.DENY); //pd.itemcubeviews.add(p.getOpenInventory()); + pd.opened_another_cube=true; Inventory temp = Bukkit.getServer().createInventory(p, inventory_size, "Item Cube #"+idnumb); openItemCubeInventory(temp); InventoryView newinv = p.openInventory(temp); + pd.opened_another_cube=false; pd.isViewingItemCube=true; p.playSound(p.getLocation(),Sound.BLOCK_CHEST_OPEN,1.0f,1.0f); } else { @@ -3768,8 +3785,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.setResult(Result.DENY); //ItemCube.displayErrorMessage(p); //pd.itemcubeviews.add(p.getOpenInventory()); + pd.opened_another_cube=true; p.openInventory(ItemCube.getViewingItemCubeInventory(idnumb, p)); pd.isViewingItemCube=true; + pd.opened_another_cube=false; p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f); } } @@ -4933,9 +4952,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener { GenericFunctions.breakHardenedItem(item,p); } else { + ItemStack test = GenericFunctions.breakHardenedItem(item,p); + if (test!=null) { + //We have to give this player the item! + GenericFunctions.giveItem(p, test); + } breakdownItem(item,p); } - } @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) @@ -6108,7 +6131,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } return ItemCube_items; } - public CubeType itemCube_getCubeType(int id){ + public static CubeType itemCube_getCubeType(int id){ List ItemCube_items = new ArrayList(); File config; config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data");