From 4daffec161bf7dbcb5cfb5b63d9c61a2de154a92 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 16 Oct 2016 22:03:41 +0200 Subject: [PATCH 01/10] Failsafe for Elytras in Anvils --- src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java b/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java index 96f69e3b8..2cebc21b7 100644 --- a/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java +++ b/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java @@ -290,7 +290,8 @@ public class ItemListener implements Listener { @EventHandler public void onAnvil(InventoryClickEvent e) { if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.ANVIL) { - if (SlimefunItem.getByItem(e.getInventory().getContents()[0]) != null && !SlimefunItem.isDisabled(e.getInventory().getContents()[0]) && e.getInventory().getContents()[0].getType() != Material.ELYTRA) { + if (SlimefunItem.getByItem(e.getInventory().getContents()[0]) != null && !SlimefunItem.isDisabled(e.getInventory().getContents()[0])) { + if (SlimefunManager.isItemSimiliar(e.getInventory().getContents()[0], new ItemStack(Material.ELYTRA))) return; e.setCancelled(true); Messages.local.sendTranslation((Player) e.getWhoClicked(), "anvil.not-working", true); } From ab4562334401777276f76447aa70956b4f298346 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 16 Oct 2016 22:08:07 +0200 Subject: [PATCH 02/10] Failsafe for Elytras in Anvils (2/2) --- src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java b/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java index 2cebc21b7..200360712 100644 --- a/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java +++ b/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java @@ -290,8 +290,9 @@ public class ItemListener implements Listener { @EventHandler public void onAnvil(InventoryClickEvent e) { if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.ANVIL) { + if (SlimefunManager.isItemSimiliar(e.getInventory().getContents()[0], SlimefunItems.ELYTRA)) return; + if (SlimefunItem.getByItem(e.getInventory().getContents()[0]) != null && !SlimefunItem.isDisabled(e.getInventory().getContents()[0])) { - if (SlimefunManager.isItemSimiliar(e.getInventory().getContents()[0], new ItemStack(Material.ELYTRA))) return; e.setCancelled(true); Messages.local.sendTranslation((Player) e.getWhoClicked(), "anvil.not-working", true); } From f3d9346619d2e30adbf660cde62f1285f8d4a89a Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 30 Oct 2016 11:01:01 +0100 Subject: [PATCH 03/10] Cargo Nodes can now be opened by anyone permitted to access Inventories in that Area --- .../SlimefunItem/machines/CargoCraftingNode.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoCraftingNode.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoCraftingNode.java index 0778e108c..119947189 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoCraftingNode.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoCraftingNode.java @@ -28,7 +28,7 @@ public class CargoCraftingNode extends SlimefunItem { public CargoCraftingNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe) { super(category, item, name, recipeType, recipe); - new BlockMenuPreset(name, "§3Input Node") { + new BlockMenuPreset(name, "§3Input Node") { @Override public void init() { @@ -39,7 +39,7 @@ public class CargoCraftingNode extends SlimefunItem { @Override public void newInstance(final BlockMenu menu, final Block b) { try { - menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1")); + menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1")); menu.addMenuClickHandler(41, new MenuClickHandler() { @Override @@ -52,7 +52,7 @@ public class CargoCraftingNode extends SlimefunItem { } }); - menu.replaceExistingItem(42, new CustomItem(new MaterialData(Material.WOOL, (byte) ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency"))))), "§bChannel ID: §3" + (((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")))) + 1))); + menu.replaceExistingItem(42, new CustomItem(new MaterialData(Material.WOOL, (byte) ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency"))))), "§bChannel ID: §3" + (((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")))) + 1))); menu.addMenuClickHandler(42, new MenuClickHandler() { @Override @@ -61,7 +61,7 @@ public class CargoCraftingNode extends SlimefunItem { } }); - menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1")); + menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1")); menu.addMenuClickHandler(43, new MenuClickHandler() { @Override @@ -81,7 +81,7 @@ public class CargoCraftingNode extends SlimefunItem { @Override public boolean canOpen(Block b, Player p) { - boolean open = BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.cargo.bypass"); + boolean open = CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b) || p.hasPermission("slimefun.cargo.bypass"); if (!open) { Messages.local.sendTranslation(p, "inventory.no-access", true); } @@ -126,7 +126,7 @@ public class CargoCraftingNode extends SlimefunItem { }); } - preset.addItem(2, new CustomItem(new MaterialData(Material.WORKBENCH), "§eRecipe", "", "§bPut in the Recipe you want to craft"), + preset.addItem(2, new CustomItem(new MaterialData(Material.WORKBENCH), "§eRecipe", "", "§bPut in the Recipe you want to craft"), new MenuClickHandler() { @Override From 4ec9cfda225a5b56fdd38ca9f99753e0e1b7c9bc Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 30 Oct 2016 11:01:47 +0100 Subject: [PATCH 04/10] Permission Update for Cargo Input Nodes --- .../SlimefunItem/machines/CargoInputNode.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoInputNode.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoInputNode.java index 7098b5b0c..704afdd90 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoInputNode.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoInputNode.java @@ -30,7 +30,7 @@ public class CargoInputNode extends SlimefunItem { public CargoInputNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { super(category, item, name, recipeType, recipe, recipeOutput); - new BlockMenuPreset(name, "§3Input Node") { + new BlockMenuPreset(name, "§3Input Node") { @Override public void init() { @@ -42,7 +42,7 @@ public class CargoInputNode extends SlimefunItem { public void newInstance(final BlockMenu menu, final Block b) { try { if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-type") == null || BlockStorage.getBlockInfo(b, "filter-type").equals("whitelist")) { - menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL), "§7Type: §rWhitelist", "", "§e> Click to change it to Blacklist")); + menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL), "§7Type: §rWhitelist", "", "§e> Click to change it to Blacklist")); menu.addMenuClickHandler(15, new MenuClickHandler() { @Override @@ -54,7 +54,7 @@ public class CargoInputNode extends SlimefunItem { }); } else { - menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL, (byte) 15), "§7Type: §8Blacklist", "", "§e> Click to change it to Whitelist")); + menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL, (byte) 15), "§7Type: §8Blacklist", "", "§e> Click to change it to Whitelist")); menu.addMenuClickHandler(15, new MenuClickHandler() { @Override @@ -67,7 +67,7 @@ public class CargoInputNode extends SlimefunItem { } if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-durability") == null || BlockStorage.getBlockInfo(b, "filter-durability").equals("false")) { - menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.STONE_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §4\u2718", "", "§e> Click to toggle whether the Durability has to match")); + menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.STONE_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §4\u2718", "", "§e> Click to toggle whether the Durability has to match")); menu.addMenuClickHandler(16, new MenuClickHandler() { @Override @@ -79,7 +79,7 @@ public class CargoInputNode extends SlimefunItem { }); } else { - menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.GOLD_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §2\u2714", "", "§e> Click to toggle whether the Durability has to match")); + menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.GOLD_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §2\u2714", "", "§e> Click to toggle whether the Durability has to match")); menu.addMenuClickHandler(16, new MenuClickHandler() { @Override @@ -92,7 +92,7 @@ public class CargoInputNode extends SlimefunItem { } if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "round-robin") == null || BlockStorage.getBlockInfo(b, "round-robin").equals("false")) { - menu.replaceExistingItem(24, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDc4ZjJiN2U1ZTc1NjM5ZWE3ZmI3OTZjMzVkMzY0YzRkZjI4YjQyNDNlNjZiNzYyNzdhYWRjZDYyNjEzMzcifX19"), "§7Round-Robin Mode: §4\u2718", "", "§e> Click to enable Round Robin Mode", "§e(Items will be equally distributed on the Channel)")); + menu.replaceExistingItem(24, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDc4ZjJiN2U1ZTc1NjM5ZWE3ZmI3OTZjMzVkMzY0YzRkZjI4YjQyNDNlNjZiNzYyNzdhYWRjZDYyNjEzMzcifX19"), "§7Round-Robin Mode: §4\u2718", "", "§e> Click to enable Round Robin Mode", "§e(Items will be equally distributed on the Channel)")); menu.addMenuClickHandler(24, new MenuClickHandler() { @Override @@ -104,7 +104,7 @@ public class CargoInputNode extends SlimefunItem { }); } else { - menu.replaceExistingItem(24, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDc4ZjJiN2U1ZTc1NjM5ZWE3ZmI3OTZjMzVkMzY0YzRkZjI4YjQyNDNlNjZiNzYyNzdhYWRjZDYyNjEzMzcifX19"), "§7Round-Robin Mode: §2\u2714", "", "§e> Click to disable Round Robin Mode", "§e(Items will be equally distributed on the Channel)")); + menu.replaceExistingItem(24, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDc4ZjJiN2U1ZTc1NjM5ZWE3ZmI3OTZjMzVkMzY0YzRkZjI4YjQyNDNlNjZiNzYyNzdhYWRjZDYyNjEzMzcifX19"), "§7Round-Robin Mode: §2\u2714", "", "§e> Click to disable Round Robin Mode", "§e(Items will be equally distributed on the Channel)")); menu.addMenuClickHandler(24, new MenuClickHandler() { @Override @@ -117,7 +117,7 @@ public class CargoInputNode extends SlimefunItem { } if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-lore") == null || BlockStorage.getBlockInfo(b, "filter-lore").equals("true")) { - menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §2\u2714", "", "§e> Click to toggle whether the Lore has to match")); + menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §2\u2714", "", "§e> Click to toggle whether the Lore has to match")); menu.addMenuClickHandler(25, new MenuClickHandler() { @Override @@ -129,7 +129,7 @@ public class CargoInputNode extends SlimefunItem { }); } else { - menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §4\u2718", "", "§e> Click to toggle whether the Lore has to match")); + menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §4\u2718", "", "§e> Click to toggle whether the Lore has to match")); menu.addMenuClickHandler(25, new MenuClickHandler() { @Override @@ -141,7 +141,7 @@ public class CargoInputNode extends SlimefunItem { }); } - menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1")); + menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1")); menu.addMenuClickHandler(41, new MenuClickHandler() { @Override @@ -160,7 +160,7 @@ public class CargoInputNode extends SlimefunItem { int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")))); if (channel == 16) { - menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "§bChannel ID: §3" + (channel + 1))); + menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "§bChannel ID: §3" + (channel + 1))); menu.addMenuClickHandler(42, new MenuClickHandler() { @Override @@ -170,7 +170,7 @@ public class CargoInputNode extends SlimefunItem { }); } else { - menu.replaceExistingItem(42, new CustomItem(new MaterialData(Material.WOOL, (byte) channel), "§bChannel ID: §3" + (channel + 1))); + menu.replaceExistingItem(42, new CustomItem(new MaterialData(Material.WOOL, (byte) channel), "§bChannel ID: §3" + (channel + 1))); menu.addMenuClickHandler(42, new MenuClickHandler() { @Override @@ -180,7 +180,7 @@ public class CargoInputNode extends SlimefunItem { }); } - menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1")); + menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1")); menu.addMenuClickHandler(43, new MenuClickHandler() { @Override @@ -207,7 +207,7 @@ public class CargoInputNode extends SlimefunItem { @Override public boolean canOpen(Block b, Player p) { - boolean open = BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.cargo.bypass"); + boolean open = CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b) || p.hasPermission("slimefun.cargo.bypass"); if (!open) { Messages.local.sendTranslation(p, "inventory.no-access", true); } @@ -257,7 +257,7 @@ public class CargoInputNode extends SlimefunItem { }); } - preset.addItem(2, new CustomItem(new MaterialData(Material.PAPER), "§3Items", "", "§bPut in all Items you want to", "§bblacklist/whitelist"), + preset.addItem(2, new CustomItem(new MaterialData(Material.PAPER), "§3Items", "", "§bPut in all Items you want to", "§bblacklist/whitelist"), new MenuClickHandler() { @Override From 55f192d82e921c1f25c93d72e23a8a6419696b26 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 30 Oct 2016 11:02:16 +0100 Subject: [PATCH 05/10] Permission Update for Cargo Output Nodes --- .../SlimefunItem/machines/CargoOutputNode.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoOutputNode.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoOutputNode.java index 84d0d46a7..3a6dd1506 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoOutputNode.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoOutputNode.java @@ -30,7 +30,7 @@ public class CargoOutputNode extends SlimefunItem { public CargoOutputNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { super(category, item, name, recipeType, recipe, recipeOutput); - new BlockMenuPreset(name, "§6Output Node") { + new BlockMenuPreset(name, "§6Output Node") { @Override public void init() { @@ -42,7 +42,7 @@ public class CargoOutputNode extends SlimefunItem { public void newInstance(final BlockMenu menu, final Block b) { try { - menu.replaceExistingItem(12, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1")); + menu.replaceExistingItem(12, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1")); menu.addMenuClickHandler(12, new MenuClickHandler() { @Override @@ -61,7 +61,7 @@ public class CargoOutputNode extends SlimefunItem { int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")))); if (channel == 16) { - menu.replaceExistingItem(13, new CustomItem(SlimefunItems.CHEST_TERMINAL, "§bChannel ID: §3" + (channel + 1))); + menu.replaceExistingItem(13, new CustomItem(SlimefunItems.CHEST_TERMINAL, "§bChannel ID: §3" + (channel + 1))); menu.addMenuClickHandler(13, new MenuClickHandler() { @Override @@ -71,7 +71,7 @@ public class CargoOutputNode extends SlimefunItem { }); } else { - menu.replaceExistingItem(13, new CustomItem(new MaterialData(Material.WOOL, (byte) channel), "§bChannel ID: §3" + (channel + 1))); + menu.replaceExistingItem(13, new CustomItem(new MaterialData(Material.WOOL, (byte) channel), "§bChannel ID: §3" + (channel + 1))); menu.addMenuClickHandler(13, new MenuClickHandler() { @Override @@ -81,7 +81,7 @@ public class CargoOutputNode extends SlimefunItem { }); } - menu.replaceExistingItem(14, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1")); + menu.replaceExistingItem(14, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1")); menu.addMenuClickHandler(14, new MenuClickHandler() { @Override @@ -108,7 +108,7 @@ public class CargoOutputNode extends SlimefunItem { @Override public boolean canOpen(Block b, Player p) { - boolean open = BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.cargo.bypass"); + boolean open = CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b) || p.hasPermission("slimefun.cargo.bypass"); if (!open) { Messages.local.sendTranslation(p, "inventory.no-access", true); } From dea3e7fa0d0c427091c31a6de53b26619fd963f9 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 30 Oct 2016 11:02:56 +0100 Subject: [PATCH 06/10] Fixed Opening Permission for Advanced Cargo Output Node --- .../machines/AdvancedCargoOutputNode.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AdvancedCargoOutputNode.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AdvancedCargoOutputNode.java index 0334f02c7..dace43198 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AdvancedCargoOutputNode.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AdvancedCargoOutputNode.java @@ -29,7 +29,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { public AdvancedCargoOutputNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { super(category, item, name, recipeType, recipe, recipeOutput); - new BlockMenuPreset(name, "§cOutput Node") { + new BlockMenuPreset(name, "§cOutput Node") { @Override public void init() { @@ -41,7 +41,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { public void newInstance(final BlockMenu menu, final Block b) { try { if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-type") == null || BlockStorage.getBlockInfo(b, "filter-type").equals("whitelist")) { - menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL), "§7Type: §rWhitelist", "", "§e> Click to change it to Blacklist")); + menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL), "§7Type: §rWhitelist", "", "§e> Click to change it to Blacklist")); menu.addMenuClickHandler(15, new MenuClickHandler() { @Override @@ -53,7 +53,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { }); } else { - menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL, (byte) 15), "§7Type: §8Blacklist", "", "§e> Click to change it to Whitelist")); + menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL, (byte) 15), "§7Type: §8Blacklist", "", "§e> Click to change it to Whitelist")); menu.addMenuClickHandler(15, new MenuClickHandler() { @Override @@ -66,7 +66,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { } if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-durability") == null || BlockStorage.getBlockInfo(b, "filter-durability").equals("false")) { - menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.STONE_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §4\u2718", "", "§e> Click to toggle whether the Durability has to match")); + menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.STONE_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §4\u2718", "", "§e> Click to toggle whether the Durability has to match")); menu.addMenuClickHandler(16, new MenuClickHandler() { @Override @@ -78,7 +78,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { }); } else { - menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.GOLD_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §2\u2714", "", "§e> Click to toggle whether the Durability has to match")); + menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.GOLD_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §2\u2714", "", "§e> Click to toggle whether the Durability has to match")); menu.addMenuClickHandler(16, new MenuClickHandler() { @Override @@ -91,7 +91,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { } if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-lore") == null || BlockStorage.getBlockInfo(b, "filter-lore").equals("true")) { - menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §2\u2714", "", "§e> Click to toggle whether the Lore has to match")); + menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §2\u2714", "", "§e> Click to toggle whether the Lore has to match")); menu.addMenuClickHandler(25, new MenuClickHandler() { @Override @@ -103,7 +103,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { }); } else { - menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §4\u2718", "", "§e> Click to toggle whether the Lore has to match")); + menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §4\u2718", "", "§e> Click to toggle whether the Lore has to match")); menu.addMenuClickHandler(25, new MenuClickHandler() { @Override @@ -115,7 +115,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { }); } - menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1")); + menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1")); menu.addMenuClickHandler(41, new MenuClickHandler() { @Override @@ -134,7 +134,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")))); if (channel == 16) { - menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "§bChannel ID: §3" + (channel + 1))); + menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "§bChannel ID: §3" + (channel + 1))); menu.addMenuClickHandler(42, new MenuClickHandler() { @Override @@ -144,7 +144,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { }); } else { - menu.replaceExistingItem(42, new CustomItem(new MaterialData(Material.WOOL, (byte) channel), "§bChannel ID: §3" + (channel + 1))); + menu.replaceExistingItem(42, new CustomItem(new MaterialData(Material.WOOL, (byte) channel), "§bChannel ID: §3" + (channel + 1))); menu.addMenuClickHandler(42, new MenuClickHandler() { @Override @@ -154,7 +154,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { }); } - menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1")); + menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1")); menu.addMenuClickHandler(43, new MenuClickHandler() { @Override @@ -181,7 +181,11 @@ public class AdvancedCargoOutputNode extends SlimefunItem { @Override public boolean canOpen(Block b, Player p) { - return BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.cargo.bypass"); + boolean open = CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b) || p.hasPermission("slimefun.cargo.bypass"); + if (!open) { + Messages.local.sendTranslation(p, "inventory.no-access", true); + } + return open; } @Override @@ -226,7 +230,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { }); } - preset.addItem(2, new CustomItem(new MaterialData(Material.PAPER), "§3Items", "", "§bPut in all Items you want to", "§bblacklist/whitelist"), + preset.addItem(2, new CustomItem(new MaterialData(Material.PAPER), "§3Items", "", "§bPut in all Items you want to", "§bblacklist/whitelist"), new MenuClickHandler() { @Override From aba9353ff21158a3bb07aeeb799d76558a1a9ae9 Mon Sep 17 00:00:00 2001 From: mrCookieSlime Date: Sun, 30 Oct 2016 11:13:20 +0100 Subject: [PATCH 07/10] Fixed Imports + Elytra Failsafe (3) --- .../machines/AdvancedCargoOutputNode.java | 14 +++--- .../machines/CargoCraftingNode.java | 13 ++--- .../SlimefunItem/machines/CargoInputNode.java | 13 ++--- .../machines/CargoOutputNode.java | 13 ++--- .../Slimefun/listeners/ItemListener.java | 48 +++++++++---------- 5 files changed, 53 insertions(+), 48 deletions(-) diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AdvancedCargoOutputNode.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AdvancedCargoOutputNode.java index dace43198..65c465918 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AdvancedCargoOutputNode.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AdvancedCargoOutputNode.java @@ -1,5 +1,12 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.MaterialData; + +import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem; @@ -10,18 +17,13 @@ import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason; +import me.mrCookieSlime.Slimefun.Setup.Messages; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - public class AdvancedCargoOutputNode extends SlimefunItem { private static final int[] border = {0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18, 22, 23, 24, 26, 27, 31, 32, 33, 34, 35, 36, 40, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53}; diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoCraftingNode.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoCraftingNode.java index 119947189..2c601f3f4 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoCraftingNode.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoCraftingNode.java @@ -1,5 +1,12 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.MaterialData; + +import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem; @@ -15,12 +22,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - public class CargoCraftingNode extends SlimefunItem { private static final int[] border = {0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 22, 23, 24, 25, 26, 27, 31, 32, 33, 34, 35, 36, 40, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53}; diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoInputNode.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoInputNode.java index 704afdd90..e83737bdb 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoInputNode.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoInputNode.java @@ -1,5 +1,12 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.MaterialData; + +import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem; @@ -17,12 +24,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - public class CargoInputNode extends SlimefunItem { private static final int[] border = {0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18, 22, 23, 26, 27, 31, 32, 33, 34, 35, 36, 40, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53}; diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoOutputNode.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoOutputNode.java index 3a6dd1506..b45701d68 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoOutputNode.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoOutputNode.java @@ -1,5 +1,12 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.MaterialData; + +import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem; @@ -17,12 +24,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - public class CargoOutputNode extends SlimefunItem { private static final int[] border = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}; diff --git a/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java b/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java index 200360712..fd284dcf4 100644 --- a/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java +++ b/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java @@ -3,6 +3,29 @@ package me.mrCookieSlime.Slimefun.listeners; import java.util.List; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Skull; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.inventory.CraftItemEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Variable; import me.mrCookieSlime.CSCoreLibPlugin.events.ItemUseEvent; @@ -27,29 +50,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.Skull; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Player; -import org.bukkit.entity.Wither; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.inventory.CraftItemEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerItemConsumeEvent; -import org.bukkit.inventory.EquipmentSlot; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - public class ItemListener implements Listener { public ItemListener(SlimefunStartup plugin) { @@ -290,7 +290,7 @@ public class ItemListener implements Listener { @EventHandler public void onAnvil(InventoryClickEvent e) { if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.ANVIL) { - if (SlimefunManager.isItemSimiliar(e.getInventory().getContents()[0], SlimefunItems.ELYTRA)) return; + if (SlimefunManager.isItemSimiliar(e.getInventory().getContents()[0], SlimefunItems.ELYTRA, true)) return; if (SlimefunItem.getByItem(e.getInventory().getContents()[0]) != null && !SlimefunItem.isDisabled(e.getInventory().getContents()[0])) { e.setCancelled(true); From 0c0456003a85babc4fa7f6d7fb5ba56186b62ec1 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 31 Oct 2016 10:09:08 +0100 Subject: [PATCH 08/10] Update CSCoreLibLoader.java --- .../CSCoreLibSetup/CSCoreLibLoader.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/me/mrCookieSlime/CSCoreLibSetup/CSCoreLibLoader.java b/src/me/mrCookieSlime/CSCoreLibSetup/CSCoreLibLoader.java index ee99114b4..847aea2a8 100644 --- a/src/me/mrCookieSlime/CSCoreLibSetup/CSCoreLibLoader.java +++ b/src/me/mrCookieSlime/CSCoreLibSetup/CSCoreLibLoader.java @@ -67,7 +67,7 @@ public class CSCoreLibLoader { final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); final JSONArray array = (JSONArray) JSONValue.parse(reader.readLine()); - download = new URL((String) ((JSONObject) array.get(array.size() - 1)).get("downloadUrl")); + download = traceURL(((String) ((JSONObject) array.get(array.size() - 1)).get("downloadUrl")).replace("https:", "http:")); file = new File("plugins/" + (String) ((JSONObject) array.get(array.size() - 1)).get("name") + ".jar"); return true; @@ -83,6 +83,30 @@ public class CSCoreLibLoader { } } + private URL traceURL(String location) throws IOException { + HttpURLConnection connection = null; + + while (true) { + URL url = new URL(location); + connection = (HttpURLConnection) url.openConnection(); + + connection.setInstanceFollowRedirects(false); + connection.setConnectTimeout(5000); + connection.addRequestProperty("User-Agent", "Auto Updater (by mrCookieSlime)"); + + switch (connection.getResponseCode()) { + case HttpURLConnection.HTTP_MOVED_PERM: + case HttpURLConnection.HTTP_MOVED_TEMP: + String loc = connection.getHeaderField("Location"); + location = new URL(new URL(location), loc).toExternalForm(); + continue; + } + break; + } + + return connection.getURL(); + } + private void install() { BufferedInputStream input = null; FileOutputStream output = null; From 13f208a3b608da114958780e2489e9bd70b12375 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Nov 2016 09:39:13 +0100 Subject: [PATCH 09/10] Fixed Ancient Altar Dupe Bug --- .../Slimefun/listeners/AncientAltarListener.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/me/mrCookieSlime/Slimefun/listeners/AncientAltarListener.java b/src/me/mrCookieSlime/Slimefun/listeners/AncientAltarListener.java index 4f2b63814..92c697719 100644 --- a/src/me/mrCookieSlime/Slimefun/listeners/AncientAltarListener.java +++ b/src/me/mrCookieSlime/Slimefun/listeners/AncientAltarListener.java @@ -77,7 +77,7 @@ public class AncientAltarListener implements Listener { else if (item.getName().equals("ANCIENT_ALTAR")) { e.setCancelled(true); - ItemStack catalyst = e.getPlayer().getInventory().getItemInMainHand(); + ItemStack catalyst = new CustomItem(e.getPlayer().getInventory().getItemInMainHand(), 1); List pedestals = Pedestals.getPedestals(b); if (!altars.contains(e.getClickedBlock())) { @@ -145,7 +145,7 @@ public class AncientAltarListener implements Listener { if (stack != null && !stack.getType().equals(Material.AIR)) { PlayerInventory.consumeItemInHand(p); String nametag = StringUtils.formatItemName(stack, false); - Item entity = b.getWorld().dropItem(b.getLocation().add(0.5, 1.2, 0.5), new CustomItem(new CustomItem(stack, 1), "§5§dALTAR §3Probe - §e" + System.nanoTime())); + Item entity = b.getWorld().dropItem(b.getLocation().add(0.5, 1.2, 0.5), new CustomItem(new CustomItem(stack, 1), "§5§dALTAR §3Probe - §e" + System.nanoTime())); entity.setVelocity(new Vector(0, 0.1, 0)); entity.setMetadata("no_pickup", new FixedMetadataValue(SlimefunStartup.instance, "altar_item")); entity.setCustomNameVisible(true); @@ -157,7 +157,7 @@ public class AncientAltarListener implements Listener { @EventHandler public void onPickup(PlayerPickupItemEvent e) { if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true); - else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith("§5§dALTAR §3Probe - §e")) { + else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith("§5§dALTAR §3Probe - §e")) { e.setCancelled(true); e.getItem().remove(); } From 24774ec8780a30cdf7afb96bfd19c8901c8d30a7 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Nov 2016 18:13:44 +0100 Subject: [PATCH 10/10] Fixed Import --- .../CSCoreLibSetup/CSCoreLibLoader.java | 297 +++++++++--------- 1 file changed, 149 insertions(+), 148 deletions(-) diff --git a/src/me/mrCookieSlime/CSCoreLibSetup/CSCoreLibLoader.java b/src/me/mrCookieSlime/CSCoreLibSetup/CSCoreLibLoader.java index 847aea2a8..765db59cf 100644 --- a/src/me/mrCookieSlime/CSCoreLibSetup/CSCoreLibLoader.java +++ b/src/me/mrCookieSlime/CSCoreLibSetup/CSCoreLibLoader.java @@ -1,148 +1,149 @@ -package me.mrCookieSlime.CSCoreLibSetup; - -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; - -import org.bukkit.plugin.Plugin; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - -public class CSCoreLibLoader { - - Plugin plugin; - URL url; - URL download; - File file; - - public CSCoreLibLoader(Plugin plugin) { - this.plugin = plugin; - try { - this.url = new URL("https://api.curseforge.com/servermods/files?projectIds=88802"); - } catch (MalformedURLException e) { - } - } - - public boolean load() { - if (plugin.getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) return true; - else { - System.err.println(" "); - System.err.println("#################### - FATAL ERROR - ####################"); - System.err.println(" "); - System.err.println(plugin.getName() + " could not be properly installed!"); - System.err.println("It appears that you have not installed CS-CoreLib"); - System.err.println("And because of that, CS-CoreLib is now going to be"); - System.err.println("downloaded and installed."); - System.err.println("But for the time being " + plugin.getName() + " will remain disabled"); - System.err.println("After the installation process has finished,"); - System.out.println("you will be asked to restart your Server."); - System.err.println("- mrCookieSlime"); - System.err.println(" "); - System.err.println("#################### - FATAL ERROR - ####################"); - System.err.println(" "); - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - - @Override - public void run() { - if (connect()) install(); - } - }, 10L); - return false; - } - } - - private boolean connect() { - try { - final URLConnection connection = this.url.openConnection(); - connection.setConnectTimeout(5000); - connection.addRequestProperty("User-Agent", "CS-CoreLib Loader (by mrCookieSlime)"); - connection.setDoOutput(true); - - final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); - final JSONArray array = (JSONArray) JSONValue.parse(reader.readLine()); - download = traceURL(((String) ((JSONObject) array.get(array.size() - 1)).get("downloadUrl")).replace("https:", "http:")); - file = new File("plugins/" + (String) ((JSONObject) array.get(array.size() - 1)).get("name") + ".jar"); - - return true; - } catch (IOException e) { - System.err.println(" "); - System.err.println("#################### - FATAL ERROR - ####################"); - System.err.println(" "); - System.err.println("Could not connect to BukkitDev, is it down?"); - System.err.println(" "); - System.err.println("#################### - FATAL ERROR - ####################"); - System.err.println(" "); - return false; - } - } - - private URL traceURL(String location) throws IOException { - HttpURLConnection connection = null; - - while (true) { - URL url = new URL(location); - connection = (HttpURLConnection) url.openConnection(); - - connection.setInstanceFollowRedirects(false); - connection.setConnectTimeout(5000); - connection.addRequestProperty("User-Agent", "Auto Updater (by mrCookieSlime)"); - - switch (connection.getResponseCode()) { - case HttpURLConnection.HTTP_MOVED_PERM: - case HttpURLConnection.HTTP_MOVED_TEMP: - String loc = connection.getHeaderField("Location"); - location = new URL(new URL(location), loc).toExternalForm(); - continue; - } - break; - } - - return connection.getURL(); - } - - private void install() { - BufferedInputStream input = null; - FileOutputStream output = null; - try { - input = new BufferedInputStream(download.openStream()); - output = new FileOutputStream(file); - - final byte[] data = new byte[1024]; - int read; - while ((read = input.read(data, 0, 1024)) != -1) { - output.write(data, 0, read); - } - } catch (Exception ex) { - System.err.println(" "); - System.err.println("#################### - FATAL ERROR - ####################"); - System.err.println(" "); - System.err.println("Could not download CS-CoreLib"); - System.err.println(" "); - System.err.println("#################### - FATAL ERROR - ####################"); - System.err.println(" "); - } finally { - try { - if (input != null) input.close(); - if (output != null) output.close(); - System.err.println(" "); - System.err.println("#################### - WARNING - ####################"); - System.err.println(" "); - System.err.println("Please restart your Server to finish the Installation"); - System.err.println("of " + plugin.getName() + " and CS-CoreLib"); - System.err.println(" "); - System.err.println("#################### - WARNING - ####################"); - System.err.println(" "); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - -} +package me.mrCookieSlime.CSCoreLibSetup; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; + +import org.bukkit.plugin.Plugin; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; + +public class CSCoreLibLoader { + + Plugin plugin; + URL url; + URL download; + File file; + + public CSCoreLibLoader(Plugin plugin) { + this.plugin = plugin; + try { + this.url = new URL("https://api.curseforge.com/servermods/files?projectIds=88802"); + } catch (MalformedURLException e) { + } + } + + public boolean load() { + if (plugin.getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) return true; + else { + System.err.println(" "); + System.err.println("#################### - FATAL ERROR - ####################"); + System.err.println(" "); + System.err.println(plugin.getName() + " could not be properly installed!"); + System.err.println("It appears that you have not installed CS-CoreLib"); + System.err.println("And because of that, CS-CoreLib is now going to be"); + System.err.println("downloaded and installed."); + System.err.println("But for the time being " + plugin.getName() + " will remain disabled"); + System.err.println("After the installation process has finished,"); + System.out.println("you will be asked to restart your Server."); + System.err.println("- mrCookieSlime"); + System.err.println(" "); + System.err.println("#################### - FATAL ERROR - ####################"); + System.err.println(" "); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + + @Override + public void run() { + if (connect()) install(); + } + }, 10L); + return false; + } + } + + private boolean connect() { + try { + final URLConnection connection = this.url.openConnection(); + connection.setConnectTimeout(5000); + connection.addRequestProperty("User-Agent", "CS-CoreLib Loader (by mrCookieSlime)"); + connection.setDoOutput(true); + + final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + final JSONArray array = (JSONArray) JSONValue.parse(reader.readLine()); + download = traceURL(((String) ((JSONObject) array.get(array.size() - 1)).get("downloadUrl")).replace("https:", "http:")); + file = new File("plugins/" + (String) ((JSONObject) array.get(array.size() - 1)).get("name") + ".jar"); + + return true; + } catch (IOException e) { + System.err.println(" "); + System.err.println("#################### - FATAL ERROR - ####################"); + System.err.println(" "); + System.err.println("Could not connect to BukkitDev, is it down?"); + System.err.println(" "); + System.err.println("#################### - FATAL ERROR - ####################"); + System.err.println(" "); + return false; + } + } + + private URL traceURL(String location) throws IOException { + HttpURLConnection connection = null; + + while (true) { + URL url = new URL(location); + connection = (HttpURLConnection) url.openConnection(); + + connection.setInstanceFollowRedirects(false); + connection.setConnectTimeout(5000); + connection.addRequestProperty("User-Agent", "Auto Updater (by mrCookieSlime)"); + + switch (connection.getResponseCode()) { + case HttpURLConnection.HTTP_MOVED_PERM: + case HttpURLConnection.HTTP_MOVED_TEMP: + String loc = connection.getHeaderField("Location"); + location = new URL(new URL(location), loc).toExternalForm(); + continue; + } + break; + } + + return connection.getURL(); + } + + private void install() { + BufferedInputStream input = null; + FileOutputStream output = null; + try { + input = new BufferedInputStream(download.openStream()); + output = new FileOutputStream(file); + + final byte[] data = new byte[1024]; + int read; + while ((read = input.read(data, 0, 1024)) != -1) { + output.write(data, 0, read); + } + } catch (Exception ex) { + System.err.println(" "); + System.err.println("#################### - FATAL ERROR - ####################"); + System.err.println(" "); + System.err.println("Could not download CS-CoreLib"); + System.err.println(" "); + System.err.println("#################### - FATAL ERROR - ####################"); + System.err.println(" "); + } finally { + try { + if (input != null) input.close(); + if (output != null) output.close(); + System.err.println(" "); + System.err.println("#################### - WARNING - ####################"); + System.err.println(" "); + System.err.println("Please restart your Server to finish the Installation"); + System.err.println("of " + plugin.getName() + " and CS-CoreLib"); + System.err.println(" "); + System.err.println("#################### - WARNING - ####################"); + System.err.println(" "); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + +}