diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index 884a60b..30f7705 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/plugin.yml b/src/plugin.yml index 00f03ca..155560e 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper -version: 3.4.2 +version: 3.4.3 commands: money: description: Tells the player the amount of money they are holding. diff --git a/src/sig/plugin/TwosideKeeper/Artifact.java b/src/sig/plugin/TwosideKeeper/Artifact.java index 3b6911a..7b95ba6 100644 --- a/src/sig/plugin/TwosideKeeper/Artifact.java +++ b/src/sig/plugin/TwosideKeeper/Artifact.java @@ -174,7 +174,9 @@ public class Artifact { return item; } public static boolean isArtifact(ItemStack item) { - if (item.hasItemMeta() && + if (item!=null && + item.getType()!=Material.AIR && + item.hasItemMeta() && item.getItemMeta().hasLore() && (item.getItemMeta().getLore().contains(ChatColor.GOLD+""+ChatColor.ITALIC+"Artifact Crafting Item") || item.getItemMeta().getLore().contains(ChatColor.GOLD+""+ChatColor.ITALIC+"Artifact Item"))) { diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/ItemCube.java b/src/sig/plugin/TwosideKeeper/HelperStructures/ItemCube.java new file mode 100644 index 0000000..974d92d --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/ItemCube.java @@ -0,0 +1,29 @@ +package sig.plugin.TwosideKeeper.HelperStructures; + +import org.bukkit.Bukkit; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import com.google.common.collect.Iterables; + +public class ItemCube { + public static boolean isSomeoneViewingItemCube(int id, Player checker) { + for (int i=0;i-1 || (ev.getMessage().indexOf("() ")>-1 && ev.getMessage().indexOf("() ")==0)) { ev.setMessage(ev.getMessage().replace("()", "("+ev.getPlayer().getLocation().getBlockX()+","+ev.getPlayer().getLocation().getBlockY()+","+ev.getPlayer().getLocation().getBlockZ()+")")); } - for (int i=0;i-1 || (ev.getMessage().indexOf("[] ")>-1 && ev.getMessage().indexOf("[] ")==0)) { @@ -1282,7 +1277,17 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } - @EventHandler(priority=EventPriority.LOW) + public static void playMessageNotification(Player player) { + for (int i=0;i9)) && ev.getCurrentItem()!=null) { + if (ev.getCurrentItem().hasItemMeta() && (ev.getCurrentItem().getType()!=Material.AIR)) { + ItemMeta item_meta = ev.getCurrentItem().getItemMeta(); + if (item_meta.hasLore()) { + List item_meta_lore = item_meta.getLore(); + if (item_meta_lore.size()==4 && item_meta_lore.get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { + int idnumb = Integer.parseInt(item_meta_lore.get(3).split("#")[1]); + int itemcubeid = -1; + if (ev.getWhoClicked().getOpenInventory().getTitle().contains("Item Cube #")) { + itemcubeid = Integer.parseInt(ev.getWhoClicked().getOpenInventory().getTitle().split("#")[1]); //This is the ID of the window we are looking at, if one exists. + } else { + itemcubeid = -1; + } + CubeType cubetype = CubeType.NORMAL; + //This is an Item Cube. + //Check to see if the cursor item is an item cube. + if ((ev.getCurrentItem().getType()==Material.CHEST || + ev.getCurrentItem().getType()==Material.STORAGE_MINECART || + ev.getCurrentItem().getType()==Material.ENDER_CHEST) && + ev.getCurrentItem().hasItemMeta() && + ev.getCurrentItem().getItemMeta().hasLore()) { + log("The clicked item has lore...",5); + for (int i=0;i virtual_inventory = itemCube_loadConfig(idnumb); - boolean stack_available=false; - //Now we will see if there are any places to stack blocks on. - int quantity=ev.getCursor().getAmount(); - log("Amount held: "+quantity,5); - for (int i=0;ivirtual_inventory.get(i).getAmount()) { + if (!ItemCube.isSomeoneViewingItemCube(idnumb,(Player)ev.getWhoClicked())) { + if (idnumb!=itemcubeid) { + log(idnumb+" does not match "+itemcubeid,5); + //Try to insert item inside this item cube. + List virtual_inventory = itemCube_loadConfig(idnumb); + boolean stack_available=false; + //Now we will see if there are any places to stack blocks on. + int quantity=ev.getCursor().getAmount(); + log("Amount held: "+quantity,5); + for (int i=0;ivirtual_inventory.get(i).getAmount()) { + log("Entered Loop",5); + //This is the same, and we have room to throw some in. + int space=virtual_inventory.get(i).getMaxStackSize()-virtual_inventory.get(i).getAmount(); //How much space is here. + log("There is space for "+space+" blocks.",5); + if (space>=quantity) { + //We are done, because we can store everything. + virtual_inventory.get(i).setAmount(virtual_inventory.get(i).getAmount()+quantity); + quantity=0; + final int ider = idnumb; + final List items = virtual_inventory; + final CubeType type = cubetype; + /*//OLD ENDER ITEM CUBE CODE. + if (itemCube_getCubeType(idnumb)==CubeType.ENDER) { + log("This is an Ender Item Cube transfer click.",5); + //We are going to look at all players and see if they have this inventory open. + final int id = idnumb; + for (int j=0;j0) { + //We can't fit this anywhere else. So we put the rest back to the cursor. + ev.getCursor().setAmount(quantity); + } else { + stack_available=true; + } + + if (stack_available) { + ev.setCursor(new ItemStack(Material.AIR)); + itemCube_saveConfig(idnumb,virtual_inventory,cubetype); + } else { + //Look for an empty space. + for (int i=0;i items = virtual_inventory; + final CubeType type = cubetype; + + /*//OLD ENDER ITEM CUBE CODE + * if (itemCube_getCubeType(idnumb)==CubeType.ENDER) { + log("This is an Ender Item Cube transfer click.",5); + //We are going to look at all players and see if they have this inventory open. + final int id = idnumb; + for (int j=0;jev.getView().getTopInventory().getItem(i).getAmount()) { log("Entered Loop",5); - //This is the same, and we have room to throw some in. - int space=virtual_inventory.get(i).getMaxStackSize()-virtual_inventory.get(i).getAmount(); //How much space is here. - log("There is space for "+space+" blocks.",5); - if (space>=quantity) { - //We are done, because we can store everything. - virtual_inventory.get(i).setAmount(virtual_inventory.get(i).getAmount()+quantity); - quantity=0; + //This is the same, and we have room to throw some in. + int space=ev.getView().getTopInventory().getItem(i).getMaxStackSize()-ev.getView().getTopInventory().getItem(i).getAmount(); //How much space is here. + log("There is space for "+space+" blocks.",5); + if (space>=quantity) { + //We are done, because we can store everything. + ev.getView().getTopInventory().getItem(i).setAmount(ev.getView().getTopInventory().getItem(i).getAmount()+quantity); + quantity=0; + List itemlist = new ArrayList(); + for (int j=0;j items = virtual_inventory; + final List items = itemlist; final CubeType type = cubetype; - + /* OLD ENDER ITEM CUBE CODE. if (itemCube_getCubeType(idnumb)==CubeType.ENDER) { log("This is an Ender Item Cube transfer click.",5); //We are going to look at all players and see if they have this inventory open. @@ -2249,7 +2382,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (p.getOpenInventory()!=null && !p.getName().equalsIgnoreCase(ev.getWhoClicked().getName()) && p.getOpenInventory().getTitle().contentEquals("Item Cube #"+idnumb)) { - + p.closeInventory(); } } @@ -2262,41 +2395,20 @@ public class TwosideKeeper extends JavaPlugin implements Listener { },2); } else { itemCube_saveConfig(ider,items,type); - } - ev.setCursor(new ItemStack(Material.AIR)); - break; + }*/ + ev.setCursor(new ItemStack(Material.AIR)); + break; } else { //We still have more. Store what we can. quantity-=space; log("Still have "+quantity+" blocks left.",5); - virtual_inventory.get(i).setAmount(virtual_inventory.get(i).getMaxStackSize()); - itemCube_saveConfig(idnumb,virtual_inventory,cubetype); - } - } - } - if (quantity>0) { - //We can't fit this anywhere else. So we put the rest back to the cursor. - ev.getCursor().setAmount(quantity); - } else { - stack_available=true; - } - - if (stack_available) { - ev.setCursor(new ItemStack(Material.AIR)); - itemCube_saveConfig(idnumb,virtual_inventory,cubetype); - } else { - //Look for an empty space. - for (int i=0;i items = virtual_inventory; - final CubeType type = cubetype; - - if (itemCube_getCubeType(idnumb)==CubeType.ENDER) { + ev.getView().getTopInventory().getItem(i).setAmount(ev.getView().getTopInventory().getItem(i).getMaxStackSize()); + List itemlist = new ArrayList(); + for (int j=0;j items = itemlist; + final CubeType type = cubetype; Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { @Override public void run() { itemCube_saveConfig(ider,items,type); } },2); - break; - } else { - itemCube_saveConfig(ider,items,type); - } + }*/ + } + } + } + if (quantity>0) { + //We can't fit this anywhere else. So we put the rest back to the cursor. + ev.getCursor().setAmount(quantity); + } else { + stack_available=true; + } + + if (stack_available) { + ev.setCursor(new ItemStack(Material.AIR)); + } else { + for (int i=0;iev.getView().getTopInventory().getItem(i).getAmount()) { - log("Entered Loop",5); - //This is the same, and we have room to throw some in. - int space=ev.getView().getTopInventory().getItem(i).getMaxStackSize()-ev.getView().getTopInventory().getItem(i).getAmount(); //How much space is here. - log("There is space for "+space+" blocks.",5); - if (space>=quantity) { - //We are done, because we can store everything. - ev.getView().getTopInventory().getItem(i).setAmount(ev.getView().getTopInventory().getItem(i).getAmount()+quantity); - quantity=0; - List itemlist = new ArrayList(); - for (int j=0;j items = itemlist; - final CubeType type = cubetype; - if (itemCube_getCubeType(idnumb)==CubeType.ENDER) { - log("This is an Ender Item Cube transfer click.",5); - //We are going to look at all players and see if they have this inventory open. - final int id = idnumb; - for (int j=0;j itemlist = new ArrayList(); - for (int j=0;j items = itemlist; - final CubeType type = cubetype; - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - @Override - public void run() { - itemCube_saveConfig(ider,items,type); - } - },2); - } - } - } - } - if (quantity>0) { - //We can't fit this anywhere else. So we put the rest back to the cursor. - ev.getCursor().setAmount(quantity); - } else { - stack_available=true; - } - - if (stack_available) { - ev.setCursor(new ItemStack(Material.AIR)); - } else { - for (int i=0;i 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); + newitem1.setItemMeta(m); + newitem1.addUnsafeEnchantment(Enchantment.LUCK, tier+1); + ev.getInventory().setResult(newitem1); } } } @@ -4894,10 +4970,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } p.setMaxHealth(hp); - p.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(hp); if (!p.isDead()) { p.setHealth(p.getHealth()); } + p.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(hp); } diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java index 0d92eba..4717ccb 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java @@ -96,6 +96,11 @@ public final class TwosideKeeperAPI { public static double getModifiedDamage(double dmg_amt, LivingEntity p) { return TwosideKeeper.CalculateDamageReduction(dmg_amt, p, p); } + + //Spleef COMMANDS. + public static void playMessageNotification(Player sender) { + TwosideKeeper.playMessageNotification(sender); + } //Spleef COMMANDS. public static boolean isPlayingSpleef(Player p) {