diff --git a/pom.xml b/pom.xml index 731b96145..7e043a92d 100644 --- a/pom.xml +++ b/pom.xml @@ -55,44 +55,76 @@ org.bukkit bukkit - 1.12-R0.1-SNAPSHOT provided com.sk89q.worldedit worldedit-bukkit - 6.1.1-SNAPSHOT com.github.TheBusyBiscuit CS-CoreLib - v1.5.18 me.minebuilders clearlag-core - 2.9.7 system ${project.basedir}/lib/Clearlag.jar net.coreprotect CoreProtect - 2.14.2 me.mrCookieSlime EmeraldEnchants - 2.0 system ${project.basedir}/lib/EmeraldEnchants v2.0.jar me.mrCookieSlime ExoticGarden - 1.2.0 system ${project.basedir}/lib/ExoticGarden v1.2.0.jar + + + + org.bukkit + bukkit + 1.12-R0.1-SNAPSHOT + + + com.sk89q.worldedit + worldedit-bukkit + 6.1.1-SNAPSHOT + + + com.github.TheBusyBiscuit + CS-CoreLib + v1.5.18 + + + me.minebuilders + clearlag-core + 2.9.7 + + + net.coreprotect + CoreProtect + 2.14.2 + + + me.mrCookieSlime + EmeraldEnchants + 2.0 + + + me.mrCookieSlime + ExoticGarden + 1.2.0 + + + diff --git a/src/me/mrCookieSlime/Slimefun/AncientAltar/RitualAnimation.java b/src/me/mrCookieSlime/Slimefun/AncientAltar/RitualAnimation.java index 209fa31f8..004e65b83 100644 --- a/src/me/mrCookieSlime/Slimefun/AncientAltar/RitualAnimation.java +++ b/src/me/mrCookieSlime/Slimefun/AncientAltar/RitualAnimation.java @@ -1,7 +1,6 @@ package me.mrCookieSlime.Slimefun.AncientAltar; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import me.mrCookieSlime.CSCoreLibPlugin.general.Particles.MC_1_8.ParticleEffect; diff --git a/src/me/mrCookieSlime/Slimefun/Android/ProgrammableAndroid.java b/src/me/mrCookieSlime/Slimefun/Android/ProgrammableAndroid.java index ea6af4535..cfc99cb76 100644 --- a/src/me/mrCookieSlime/Slimefun/Android/ProgrammableAndroid.java +++ b/src/me/mrCookieSlime/Slimefun/Android/ProgrammableAndroid.java @@ -131,7 +131,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { @Override public boolean canOpen(Block b, Player p) { - boolean open = BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.android.bypass"); + boolean open = BlockStorage.getLocationInfo(b.getLocation(), "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.android.bypass"); if (!open) { Messages.local.sendTranslation(p, "inventory.no-access", true); } @@ -208,7 +208,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { @Override public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { - boolean allow = reason.equals(UnregisterReason.PLAYER_BREAK) && (BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.android.bypass")); + boolean allow = reason.equals(UnregisterReason.PLAYER_BREAK) && (BlockStorage.getLocationInfo(b.getLocation(), "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.android.bypass")); if (allow) { BlockMenu inv = BlockStorage.getInventory(b); @@ -238,12 +238,12 @@ public abstract class ProgrammableAndroid extends SlimefunItem { if (!(b.getState() instanceof Skull)) { return; } - } catch(NullPointerException x) { + } catch (NullPointerException x) { return; } - if (BlockStorage.getBlockInfo(b, "paused").equals("false")) { - float fuel = Float.parseFloat(BlockStorage.getBlockInfo(b, "fuel")); + if (BlockStorage.getLocationInfo(b.getLocation(), "paused").equals("false")) { + float fuel = Float.parseFloat(BlockStorage.getLocationInfo(b.getLocation(), "fuel")); if (fuel == 0) { ItemStack item = BlockStorage.getInventory(b).getItemInSlot(43); if (item != null) { @@ -260,8 +260,8 @@ public abstract class ProgrammableAndroid extends SlimefunItem { } } else { - String[] script = BlockStorage.getBlockInfo(b, "script").split("-"); - int index = Integer.parseInt(BlockStorage.getBlockInfo(b, "index")) + 1; + String[] script = BlockStorage.getLocationInfo(b.getLocation(), "script").split("-"); + int index = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "index")) + 1; if (index >= script.length) index = 0; boolean refresh = true; BlockStorage.addBlockInfo(b, "fuel", String.valueOf(fuel - 1)); @@ -271,7 +271,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { switch(part) { case GO_DOWN: { try { - BlockFace face = BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation")); + BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation")); Block block = b.getRelative(BlockFace.DOWN); move(b, face, block); } catch (Exception e) { @@ -281,7 +281,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { } case GO_FORWARD: { try { - BlockFace face = BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation")); + BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation")); Block block = b.getRelative(face); move(b, face, block); } catch (Exception e) { @@ -291,7 +291,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { } case GO_UP: { try { - BlockFace face = BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation")); + BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation")); Block block = b.getRelative(BlockFace.UP); move(b, face, block); } catch (Exception e) { @@ -304,7 +304,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { break; } case TURN_LEFT: { - int rotIndex = directions.indexOf(BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation"))) - 1; + int rotIndex = directions.indexOf(BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) - 1; if (rotIndex < 0) rotIndex = directions.size() - 1; BlockFace dir = directions.get(rotIndex); Skull skull = (Skull) b.getState(); @@ -314,7 +314,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { break; } case TURN_RIGHT: { - int rotIndex = directions.indexOf(BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation"))) + 1; + int rotIndex = directions.indexOf(BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) + 1; if (rotIndex == directions.size()) rotIndex = 0; BlockFace dir = directions.get(rotIndex); Skull skull = (Skull) b.getState(); @@ -324,7 +324,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { break; } case DIG_FORWARD: { - Block block = b.getRelative(BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation"))); + Block block = b.getRelative(BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))); mine(b, block); break; } @@ -351,25 +351,25 @@ public abstract class ProgrammableAndroid extends SlimefunItem { break; } case MOVE_AND_DIG_FORWARD: { - BlockFace face = BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation")); + BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation")); Block block = b.getRelative(face); movedig(b, face, block); break; } case MOVE_AND_DIG_UP: { - BlockFace face = BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation")); + BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation")); Block block = b.getRelative(BlockFace.UP); movedig(b, face, block); break; } case MOVE_AND_DIG_DOWN: { - BlockFace face = BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation")); + BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation")); Block block = b.getRelative(BlockFace.DOWN); movedig(b, face, block); break; } case INTERFACE_ITEMS: { - BlockFace face = BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation")); + BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation")); Block block = b.getRelative(face); if (BlockStorage.check(block, "ANDROID_INTERFACE_ITEMS") && block.getState() instanceof Dispenser) { Dispenser d = (Dispenser) block.getState(); @@ -390,7 +390,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { break; } case INTERFACE_FUEL: { - BlockFace face = BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation")); + BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation")); Block block = b.getRelative(face); if (BlockStorage.check(block, "ANDROID_INTERFACE_FUEL") && block.getState() instanceof Dispenser) { Dispenser d = (Dispenser) block.getState(); @@ -417,7 +417,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { break; } case FARM_FORWARD: { - BlockFace face = BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation")); + BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation")); Block block = b.getRelative(face); farm(b, block); break; @@ -428,7 +428,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { break; } case FARM_EXOTIC_FORWARD: { - BlockFace face = BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation")); + BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation")); Block block = b.getRelative(face); exoticFarm(b, block); break; @@ -439,7 +439,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { break; } case CHOP_TREE: { - BlockFace face = BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation")); + BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation")); Block block = b.getRelative(face); if (block.getType().equals(Material.LOG) || block.getType().equals(Material.LOG_2)) { List list = new ArrayList(); @@ -450,7 +450,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { Block log = list.get(list.size() - 1).getBlock(); Collection drops = log.getDrops(); log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType()); - if (!drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), log)) { + if (!drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), log)) { ItemStack[] items = drops.toArray(new ItemStack[drops.size()]); if (fits(b, items)) { pushItems(b, items); @@ -474,7 +474,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { entities: for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) { - switch (BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation"))) { + switch (BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) { case NORTH: { if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() < b.getZ()) { if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance); @@ -527,7 +527,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { entities: for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) { if (n instanceof Animals) continue; - switch (BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation"))) { + switch (BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) { case NORTH: { if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() < b.getZ()) { if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance); @@ -581,7 +581,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { entities: for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) { if (n instanceof Monster) continue; - switch (BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation"))) { + switch (BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) { case NORTH: { if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() < b.getZ()) { if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance); @@ -636,7 +636,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) { if (n instanceof Monster) continue; if (n instanceof Ageable && !((Ageable) n).isAdult()) continue; - switch (BlockFace.valueOf(BlockStorage.getBlockInfo(b, "rotation"))) { + switch (BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) { case NORTH: { if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() < b.getZ()) { if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance); @@ -705,26 +705,27 @@ public abstract class ProgrammableAndroid extends SlimefunItem { skull.update(true, false); CustomSkull.setSkull(block, CustomSkull.getTexture(getItem())); b.setType(Material.AIR); - BlockStorage.moveBlockInfo(b, block); + BlockStorage.moveBlockInfo(b.getLocation(), block.getLocation()); } } private void mine(Block b, Block block) { Collection drops = block.getDrops(); - if (!blockblacklist.contains(block.getType()) && !drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), block)) { + if (!blockblacklist.contains(block.getType()) && !drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), block)) { SlimefunItem item = BlockStorage.check(block); - if(item != null) { - if(fits(b, item.getItem())) { - if(SlimefunItem.blockhandler.containsKey(item.getID())) { + if (item != null) { + if (fits(b, item.getItem())) { + if (SlimefunItem.blockhandler.containsKey(item.getID())) { if (SlimefunItem.blockhandler.get(item.getID()).onBreak(null, block, item, UnregisterReason.ANDROID_DIG)) { pushItems(b, BlockStorage.retrieve(block)); - if(SlimefunItem.blockhandler.containsKey(item.getID())) SlimefunItem.blockhandler.get(item.getID()).onBreak(null, block, item, UnregisterReason.ANDROID_DIG); + if (SlimefunItem.blockhandler.containsKey(item.getID())) SlimefunItem.blockhandler.get(item.getID()).onBreak(null, block, item, UnregisterReason.ANDROID_DIG); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); block.setType(Material.AIR); } } } - }else { + } + else { ItemStack[] items = drops.toArray(new ItemStack[drops.size()]); if (fits(b, items)) { pushItems(b, items); @@ -738,12 +739,12 @@ public abstract class ProgrammableAndroid extends SlimefunItem { @SuppressWarnings("deprecation") private void movedig(Block b, BlockFace face, Block block) { Collection drops = block.getDrops(); - if (!blockblacklist.contains(block.getType()) && !drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), block)) { + if (!blockblacklist.contains(block.getType()) && !drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), block)) { try { SlimefunItem item = BlockStorage.check(block); - if(item != null) { - if(fits(b, item.getItem())) { - if(SlimefunItem.blockhandler.containsKey(item.getID())) { + if (item != null) { + if (fits(b, item.getItem())) { + if (SlimefunItem.blockhandler.containsKey(item.getID())) { if (SlimefunItem.blockhandler.get(item.getID()).onBreak(null, block, item, UnregisterReason.ANDROID_DIG)) { pushItems(b, BlockStorage.retrieve(block)); @@ -757,7 +758,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { skull.update(true, false); CustomSkull.setSkull(block, CustomSkull.getTexture(getItem())); b.setType(Material.AIR); - BlockStorage.moveBlockInfo(b, block); + BlockStorage.moveBlockInfo(b.getLocation(), block.getLocation()); } } } @@ -775,10 +776,10 @@ public abstract class ProgrammableAndroid extends SlimefunItem { skull.update(true, false); CustomSkull.setSkull(block, CustomSkull.getTexture(getItem())); b.setType(Material.AIR); - BlockStorage.moveBlockInfo(b, block); + BlockStorage.moveBlockInfo(b.getLocation(), block.getLocation()); } } - } catch(Exception x) { + } catch (Exception x) { x.printStackTrace(); } } @@ -957,7 +958,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { @Override public boolean onClick(Player p, int slot, ItemStack stack, ClickAction action) { try { - openScript(p, b, BlockStorage.getBlockInfo(b, "script")); + openScript(p, b, BlockStorage.getLocationInfo(b.getLocation(), "script")); } catch (Exception e) { e.printStackTrace(); } @@ -1152,7 +1153,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem { @Override public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) { - final String code = BlockStorage.getBlockInfo(b, "script"); + final String code = BlockStorage.getLocationInfo(b.getLocation(), "script"); int num = 1; for (Config script: getUploadedScripts()) { @@ -1564,4 +1565,5 @@ public abstract class ProgrammableAndroid extends SlimefunItem { return list; } -} \ No newline at end of file + +} diff --git a/src/me/mrCookieSlime/Slimefun/Commands/SlimefunCommand.java b/src/me/mrCookieSlime/Slimefun/Commands/SlimefunCommand.java index 6caa55e89..0f77a8e08 100644 --- a/src/me/mrCookieSlime/Slimefun/Commands/SlimefunCommand.java +++ b/src/me/mrCookieSlime/Slimefun/Commands/SlimefunCommand.java @@ -107,14 +107,14 @@ public class SlimefunCommand implements CommandExecutor, Listener { } else if (args[0].equalsIgnoreCase("guide")) { if (sender instanceof Player) { - if(sender.hasPermission("slimefun.command.guide"))((Player) sender).getInventory().addItem(SlimefunGuide.getItem(SlimefunStartup.getCfg().getBoolean("guide.default-view-book"))); + if (sender.hasPermission("slimefun.command.guide"))((Player) sender).getInventory().addItem(SlimefunGuide.getItem(SlimefunStartup.getCfg().getBoolean("guide.default-view-book"))); else Messages.local.sendTranslation(sender, "messages.no-permission", true); } else Messages.local.sendTranslation(sender, "messages.only-players", true); } - else if(args[0].equalsIgnoreCase("open_guide")) { + else if (args[0].equalsIgnoreCase("open_guide")) { if (sender instanceof Player) { - if(sender.hasPermission("slimefun.command.open_guide")) SlimefunGuide.openGuide((Player) sender, SlimefunStartup.getCfg().getBoolean("guide.default-view-book")); + if (sender.hasPermission("slimefun.command.open_guide")) SlimefunGuide.openGuide((Player) sender, SlimefunStartup.getCfg().getBoolean("guide.default-view-book")); else Messages.local.sendTranslation(sender, "messages.no-permission", true); } else Messages.local.sendTranslation(sender, "messages.only-players", true); @@ -142,18 +142,18 @@ public class SlimefunCommand implements CommandExecutor, Listener { double y = Integer.parseInt(args[2]) + 0.4D; double z = Integer.parseInt(args[3]) + 0.5D; - if (BlockStorage.getBlockInfo(((Player) sender).getWorld().getBlockAt(Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])), "floor") != null) { + if (BlockStorage.getLocationInfo(((Player) sender).getWorld().getBlockAt(Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])).getLocation(), "floor") != null) { Elevator.ignored.add(((Player) sender).getUniqueId()); float yaw = ((Player) sender).getEyeLocation().getYaw() + 180; if (yaw > 180) yaw = -180 + (yaw - 180); ((Player) sender).teleport(new Location(((Player) sender).getWorld(), x, y, z, yaw, ((Player) sender).getEyeLocation().getPitch())); try { - TitleBuilder title = (TitleBuilder) new TitleBuilder(20, 60, 20).addText("&r" + ChatColor.translateAlternateColorCodes('&', BlockStorage.getBlockInfo(((Player) sender).getWorld().getBlockAt(Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])), "floor"))); + TitleBuilder title = (TitleBuilder) new TitleBuilder(20, 60, 20).addText("&r" + ChatColor.translateAlternateColorCodes('&', BlockStorage.getLocationInfo(((Player) sender).getWorld().getBlockAt(Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])).getLocation(), "floor"))); TitleBuilder subtitle = (TitleBuilder) new TitleBuilder(20, 60, 20).addText(" "); title.send(TitleType.TITLE, ((Player) sender)); subtitle.send(TitleType.SUBTITLE, ((Player) sender)); - } catch(Exception x1) { + } catch (Exception x1) { x1.printStackTrace(); } } diff --git a/src/me/mrCookieSlime/Slimefun/GPS/Elevator.java b/src/me/mrCookieSlime/Slimefun/GPS/Elevator.java index efbddcf27..6bbc2e3f8 100644 --- a/src/me/mrCookieSlime/Slimefun/GPS/Elevator.java +++ b/src/me/mrCookieSlime/Slimefun/GPS/Elevator.java @@ -30,7 +30,7 @@ public class Elevator { public static void openEditor(Player p, final Block b) { ChestMenu menu = new ChestMenu("Elevator Settings"); - menu.addItem(4, new CustomItem(new MaterialData(Material.NAME_TAG), "&7Floor Name &e(Click to edit)", "", "&r" + ChatColor.translateAlternateColorCodes('&', BlockStorage.getBlockInfo(b, "floor")))); + menu.addItem(4, new CustomItem(new MaterialData(Material.NAME_TAG), "&7Floor Name &e(Click to edit)", "", "&r" + ChatColor.translateAlternateColorCodes('&', BlockStorage.getLocationInfo(b.getLocation(), "floor")))); menu.addMenuClickHandler(4, new MenuClickHandler() { @Override @@ -75,7 +75,7 @@ public class Elevator { for (int y = b.getWorld().getMaxHeight(); y > 0; y--) { Block block = b.getWorld().getBlockAt(b.getX(), y, b.getZ()); if (BlockStorage.check(block, "ELEVATOR_PLATE")) { - String floor = ChatColor.translateAlternateColorCodes('&', BlockStorage.getBlockInfo(block, "floor")); + String floor = ChatColor.translateAlternateColorCodes('&', BlockStorage.getLocationInfo(block.getLocation(), "floor")); if (block.getY() == b.getY()) { tellraw.addText("&7> " + index + ". &r" + floor + "\n"); tellraw.addHoverEvent(HoverAction.SHOW_TEXT, "\n&eThis is the Floor you are currently on:\n&r" + floor + "\n"); diff --git a/src/me/mrCookieSlime/Slimefun/Hashing/ItemHash.java b/src/me/mrCookieSlime/Slimefun/Hashing/ItemHash.java index c707fb156..26007e050 100644 --- a/src/me/mrCookieSlime/Slimefun/Hashing/ItemHash.java +++ b/src/me/mrCookieSlime/Slimefun/Hashing/ItemHash.java @@ -38,7 +38,7 @@ public class ItemHash { StringBuilder builder = new StringBuilder(LENGTH * 2); for (char c: item.getHash().toCharArray()) { - builder.append('§'); + builder.append('§'); builder.append(c); } @@ -47,7 +47,7 @@ public class ItemHash { public static SlimefunItem fromString(String input) { if (input == null || input.length() != LENGTH * 2) return null; - String hex = input.replaceAll("§", ""); + String hex = input.replaceAll("§", ""); if (hex.length() != LENGTH || !map.containsKey(hex)) return null; diff --git a/src/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java b/src/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java index c8894068a..2c02d4564 100644 --- a/src/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java +++ b/src/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java @@ -288,7 +288,7 @@ public class SlimefunItems { /* Alloy (Iron + Silicon) */ public static ItemStack FERROSILICON = new CustomItem(Material.IRON_INGOT, "&bFerrosilicon" , 0); /* Alloy (Iron + Gold) */ - public static ItemStack GILDED_IRON = new CustomItem(Material.GOLD_INGOT, "&6&lGilded Iron", 0); + public static ItemStack GILDED_IRON = new CustomItem(Material.GOLD_INGOT, "&6&lGilded Iron", 0); /* Alloy (Redston + Ferrosilicon) */ public static ItemStack REDSTONE_ALLOY = new CustomItem(Material.CLAY_BRICK, "&cRedstone Alloy Ingot", 0); /* Alloy (Iron + Copper) */ diff --git a/src/me/mrCookieSlime/Slimefun/Objects/Category.java b/src/me/mrCookieSlime/Slimefun/Objects/Category.java index 0c6ed26c3..2e6ed0181 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/Category.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/Category.java @@ -5,8 +5,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; -import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem; -import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.MenuItem; import me.mrCookieSlime.Slimefun.Lists.Categories; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.URID.URID; diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AReactor.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AReactor.java index a589acbc5..65a34e8ff 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AReactor.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AReactor.java @@ -48,16 +48,16 @@ public abstract class AReactor extends SlimefunItem { public static Map progress = new HashMap(); private static final BlockFace[] cooling = - { - BlockFace.NORTH, - BlockFace.NORTH_EAST, - BlockFace.EAST, - BlockFace.SOUTH_EAST, - BlockFace.SOUTH, - BlockFace.SOUTH_WEST, - BlockFace.WEST, - BlockFace.NORTH_WEST - }; + { + BlockFace.NORTH, + BlockFace.NORTH_EAST, + BlockFace.EAST, + BlockFace.SOUTH_EAST, + BlockFace.SOUTH, + BlockFace.SOUTH_WEST, + BlockFace.WEST, + BlockFace.NORTH_WEST + }; private Set recipes = new HashSet(); @@ -65,7 +65,7 @@ public abstract class AReactor extends SlimefunItem { private static final int[] border_1 = {9, 10, 11, 18, 20, 27, 29, 36, 38, 45, 46, 47}; private static final int[] border_2 = {15, 16, 17, 24, 26, 33, 35, 42, 44, 51, 52, 53}; private static final int[] border_3 = {30, 31, 32, 39, 41, 48, 49, 50}; - private static final int[] border_4 = {25, 34, 43}; //No coolant border + private static final int[] border_4 = {25, 34, 43}; // No coolant border public AReactor(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) { super(category, item, id, recipeType, recipe); @@ -80,10 +80,10 @@ public abstract class AReactor extends SlimefunItem { @Override public void newInstance(final BlockMenu menu, final Block b) { try { - if (BlockStorage.getBlockInfo(b, "reactor-mode") == null){ + if (BlockStorage.getLocationInfo(b.getLocation(), "reactor-mode") == null){ BlockStorage.addBlockInfo(b, "reactor-mode", "generator"); } - if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "reactor-mode").equals("generator")) { + if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "reactor-mode").equals("generator")) { menu.replaceExistingItem(4, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTM0M2NlNThkYTU0Yzc5OTI0YTJjOTMzMWNmYzQxN2ZlOGNjYmJlYTliZTQ1YTdhYzg1ODYwYTZjNzMwIn19fQ=="), "&7Focus: &eElectricity", "", "&6Your Reactor will focus on Power Generation", "&6If your Energy Network doesn't need Power", "&6it will not produce any either", "", "&7> Click to change the Focus to &eProduction")); menu.addMenuClickHandler(4, new MenuClickHandler() { @@ -220,7 +220,7 @@ public abstract class AReactor extends SlimefunItem { }); - for (int i : border_2) { + for (int i : border_2) { preset.addItem(i, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte) 9), " "), new MenuClickHandler() { @@ -236,19 +236,19 @@ public abstract class AReactor extends SlimefunItem { preset.addItem(7, new CustomItem(this.getCoolant(), "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode")); } else { - preset.addItem(7, new CustomItem(new MaterialData(Material.BARRIER), "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells")); + preset.addItem(7, new CustomItem(new MaterialData(Material.BARRIER), "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells")); - for (int i : border_4) { - preset.addItem(i, new CustomItem(new ItemStack(Material.BARRIER), "&cNo Coolant Required"), - new MenuClickHandler() { + for (int i : border_4) { + preset.addItem(i, new CustomItem(new ItemStack(Material.BARRIER), "&cNo Coolant Required"), + new MenuClickHandler() { - @Override - public boolean onClick(Player player, int i, ItemStack itemStack, ClickAction clickAction) { - return false; - } - }); - } - } + @Override + public boolean onClick(Player player, int i, ItemStack itemStack, ClickAction clickAction) { + return false; + } + }); + } + } } public abstract String getInventoryTitle(); @@ -326,18 +326,18 @@ public abstract class AReactor extends SlimefunItem { }); - ItemStack item = getProgressBar().clone(); - ItemMeta im = item.getItemMeta(); - im.setDisplayName(" "); - List lore = new ArrayList(); - lore.add(MachineHelper.getProgress(timeleft, processing.get(l).getTicks())); - lore.add(MachineHelper.getCoolant(timeleft, processing.get(l).getTicks())); - lore.add(""); - lore.add(MachineHelper.getTimeLeft(timeleft / 2)); - im.setLore(lore); - item.setItemMeta(im); + ItemStack item = getProgressBar().clone(); + ItemMeta im = item.getItemMeta(); + im.setDisplayName(" "); + List lore = new ArrayList(); + lore.add(MachineHelper.getProgress(timeleft, processing.get(l).getTicks())); + lore.add(MachineHelper.getCoolant(timeleft, processing.get(l).getTicks())); + lore.add(""); + lore.add(MachineHelper.getTimeLeft(timeleft / 2)); + im.setLore(lore); + item.setItemMeta(im); - BlockStorage.getInventory(l).replaceExistingItem(22, item); + BlockStorage.getInventory(l).replaceExistingItem(22, item); if (needsCooling()) { boolean coolant = (processing.get(l).getTicks() - timeleft) % 25 == 0; diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AdvancedCargoOutputNode.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AdvancedCargoOutputNode.java index 54c605294..ed8bf7ff7 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AdvancedCargoOutputNode.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AdvancedCargoOutputNode.java @@ -42,7 +42,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { @Override 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")) { + if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-type") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-type").equals("whitelist")) { menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL), "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist")); menu.addMenuClickHandler(15, new MenuClickHandler() { @@ -67,7 +67,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { }); } - if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-durability") == null || BlockStorage.getBlockInfo(b, "filter-durability").equals("false")) { + if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability") == null || BlockStorage.getLocationInfo(b.getLocation(), "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.addMenuClickHandler(16, new MenuClickHandler() { @@ -92,7 +92,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { }); } - if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-lore") == null || BlockStorage.getBlockInfo(b, "filter-lore").equals("true")) { + if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore") == null || BlockStorage.getLocationInfo(b.getLocation(), "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.addMenuClickHandler(25, new MenuClickHandler() { @@ -122,7 +122,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { @Override public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) { - int channel = Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")) - 1; + int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) - 1; if (channel < 0) { if (CargoNet.EXTRA_CHANNELS) channel = 16; else channel = 15; @@ -133,7 +133,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { } }); - int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")))); + int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")))); if (channel == 16) { menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "&bChannel ID: &3" + (channel + 1))); @@ -161,7 +161,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem { @Override public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) { - int channel = Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")) + 1; + int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) + 1; if (CargoNet.EXTRA_CHANNELS) { if (channel > 16) channel = 0; diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AutomatedCraftingChamber.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AutomatedCraftingChamber.java index e875dc6da..c0ccde2c8 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AutomatedCraftingChamber.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/AutomatedCraftingChamber.java @@ -58,7 +58,7 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem { @Override public void newInstance(final BlockMenu menu, final Block b) { - if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "enabled") == null || BlockStorage.getBlockInfo(b, "enabled").equals("false")) { + if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "enabled") == null || BlockStorage.getLocationInfo(b.getLocation(), "enabled").equals("false")) { menu.replaceExistingItem(6, new CustomItem(new MaterialData(Material.SULPHUR), "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine")); menu.addMenuClickHandler(6, new MenuClickHandler() { @@ -256,7 +256,7 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem { } protected void tick(Block b) { - if (BlockStorage.getBlockInfo(b, "enabled").equals("false")) return; + if (BlockStorage.getLocationInfo(b.getLocation(), "enabled").equals("false")) return; if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return; BlockMenu menu = BlockStorage.getInventory(b); diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoCraftingNode.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoCraftingNode.java index 8f4ad9bbe..510978492 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoCraftingNode.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoCraftingNode.java @@ -45,7 +45,7 @@ public class CargoCraftingNode extends SlimefunItem { @Override public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) { - int channel = Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")) - 1; + int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) - 1; if (channel < 0) channel = 15; BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channel)); newInstance(menu, b); @@ -53,7 +53,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.getLocationInfo(b.getLocation(), "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency"))))), "&bChannel ID: &3" + (((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")))) + 1))); menu.addMenuClickHandler(42, new MenuClickHandler() { @Override @@ -67,7 +67,7 @@ public class CargoCraftingNode extends SlimefunItem { @Override public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) { - int channel = Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")) + 1; + int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) + 1; if (channel > 15) channel = 0; BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channel)); newInstance(menu, b); diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoInputNode.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoInputNode.java index 90686153d..dafb6432e 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoInputNode.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoInputNode.java @@ -42,7 +42,7 @@ public class CargoInputNode extends SlimefunItem { @Override 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")) { + if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-type") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-type").equals("whitelist")) { menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL), "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist")); menu.addMenuClickHandler(15, new MenuClickHandler() { @@ -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")) { + if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability") == null || BlockStorage.getLocationInfo(b.getLocation(), "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.addMenuClickHandler(16, new MenuClickHandler() { @@ -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")) { + if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "round-robin") == null || BlockStorage.getLocationInfo(b.getLocation(), "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.addMenuClickHandler(24, new MenuClickHandler() { @@ -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")) { + if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore") == null || BlockStorage.getLocationInfo(b.getLocation(), "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.addMenuClickHandler(25, new MenuClickHandler() { @@ -147,7 +147,7 @@ public class CargoInputNode extends SlimefunItem { @Override public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) { - int channel = Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")) - 1; + int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) - 1; if (channel < 0) { if (CargoNet.EXTRA_CHANNELS) channel = 16; else channel = 15; @@ -158,7 +158,7 @@ public class CargoInputNode extends SlimefunItem { } }); - int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")))); + int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")))); if (channel == 16) { menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "&bChannel ID: &3" + (channel + 1))); @@ -186,7 +186,7 @@ public class CargoInputNode extends SlimefunItem { @Override public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) { - int channel = Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")) + 1; + int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) + 1; if (CargoNet.EXTRA_CHANNELS) { if (channel > 16) channel = 0; diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoOutputNode.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoOutputNode.java index 486742457..33a084ffb 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoOutputNode.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CargoOutputNode.java @@ -48,7 +48,7 @@ public class CargoOutputNode extends SlimefunItem { @Override public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) { - int channel = Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")) - 1; + int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) - 1; if (channel < 0) { if (CargoNet.EXTRA_CHANNELS) channel = 16; else channel = 15; @@ -59,7 +59,7 @@ public class CargoOutputNode extends SlimefunItem { } }); - int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")))); + int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")))); if (channel == 16) { menu.replaceExistingItem(13, new CustomItem(SlimefunItems.CHEST_TERMINAL, "&bChannel ID: &3" + (channel + 1))); @@ -87,7 +87,7 @@ public class CargoOutputNode extends SlimefunItem { @Override public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) { - int channel = Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")) + 1; + int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) + 1; if (CargoNet.EXTRA_CHANNELS) { if (channel > 16) channel = 0; diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/WitherAssembler.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/WitherAssembler.java index e840cb664..f03e498d6 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/WitherAssembler.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/WitherAssembler.java @@ -52,7 +52,7 @@ public class WitherAssembler extends SlimefunItem { @Override public void newInstance(final BlockMenu menu, final Block b) { try { - if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "enabled") == null || BlockStorage.getBlockInfo(b, "enabled").equals("false")) { + if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "enabled") == null || BlockStorage.getLocationInfo(b.getLocation(), "enabled").equals("false")) { menu.replaceExistingItem(22, new CustomItem(new MaterialData(Material.SULPHUR), "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine")); menu.addMenuClickHandler(22, new MenuClickHandler() { @@ -77,14 +77,14 @@ public class WitherAssembler extends SlimefunItem { }); } - double offset = (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "offset") == null) ? 3.0F: Double.valueOf(BlockStorage.getBlockInfo(b, "offset")); + double offset = (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "offset") == null) ? 3.0F: Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset")); menu.replaceExistingItem(31, new CustomItem(new MaterialData(Material.PISTON_BASE), "&7Offset: &3" + offset + " Block(s)", "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1")); menu.addMenuClickHandler(31, new MenuClickHandler() { @Override public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) { - double offset = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getBlockInfo(b, "offset")) + (arg3.isRightClicked() ? -0.1F: 0.1F)); + double offset = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset")) + (arg3.isRightClicked() ? -0.1F: 0.1F)); BlockStorage.addBlockInfo(b, "offset", String.valueOf(offset)); newInstance(menu, b); return false; @@ -239,7 +239,7 @@ public class WitherAssembler extends SlimefunItem { @SuppressWarnings("deprecation") @Override public void tick(final Block b, SlimefunItem sf, Config data) { - if (BlockStorage.getBlockInfo(b, "enabled").equals("false")) return; + if (BlockStorage.getLocationInfo(b.getLocation(), "enabled").equals("false")) return; if (lifetime % 60 == 0) { if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return; @@ -297,7 +297,7 @@ public class WitherAssembler extends SlimefunItem { ChargableBlock.addCharge(b, -getEnergyConsumption()); - final double offset = Double.parseDouble(BlockStorage.getBlockInfo(b, "offset")); + final double offset = Double.parseDouble(BlockStorage.getLocationInfo(b.getLocation(), "offset")); Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/XPCollector.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/XPCollector.java index 70f12376d..e8d989357 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/XPCollector.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/XPCollector.java @@ -186,7 +186,7 @@ public class XPCollector extends SlimefunItem { } private int getEXP(Block b) { - Config cfg = BlockStorage.getBlockInfo(b); + Config cfg = BlockStorage.getLocationInfo(b.getLocation()); if (cfg.contains("stored-exp")) return Integer.parseInt(cfg.getString("stored-exp")); else { BlockStorage.addBlockInfo(b, "stored-exp", "0"); diff --git a/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java b/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java index f7173b848..15ae30bb8 100644 --- a/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java +++ b/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java @@ -164,10 +164,18 @@ public class SlimefunSetup { new ItemStack[] {null, new ItemStack(Material.LOG), null, null, new ItemStack(Material.LOG), null, null, new ItemStack(Material.LOG), null}) .register(true); + new SlimefunItem(Categories.WEAPONS, SlimefunItems.GRANDMAS_WALKING_STICK, "GRANDMAS_WALKING_STICK2", RecipeType.ENHANCED_CRAFTING_TABLE, + new ItemStack[] {null, new ItemStack(Material.LOG_2), null, null, new ItemStack(Material.LOG_2), null, null, new ItemStack(Material.LOG_2), null}, true) + .register(true); + new SlimefunItem(Categories.WEAPONS, SlimefunItems.GRANDPAS_WALKING_STICK, "GRANDPAS_WALKING_STICK", RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {new ItemStack(Material.LEATHER), new ItemStack(Material.LOG), new ItemStack(Material.LEATHER), null, new ItemStack(Material.LOG), null, null, new ItemStack(Material.LOG), null}) .register(true); + new SlimefunItem(Categories.WEAPONS, SlimefunItems.GRANDPAS_WALKING_STICK, "GRANDPAS_WALKING_STICK2", RecipeType.ENHANCED_CRAFTING_TABLE, + new ItemStack[] {new ItemStack(Material.LEATHER), new ItemStack(Material.LOG_2), new ItemStack(Material.LEATHER), null, new ItemStack(Material.LOG_2), null, null, new ItemStack(Material.LOG_2), null}, true) + .register(true); + new SlimefunItem(Categories.PORTABLE, SlimefunItems.PORTABLE_CRAFTER, "PORTABLE_CRAFTER", RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {new ItemStack(Material.BOOK), new ItemStack(Material.WORKBENCH), null, null, null, null, null, null, null}) .register(true, new ItemInteractionHandler() { @@ -198,7 +206,7 @@ public class SlimefunSetup { SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("ENHANCED_CRAFTING_TABLE"); if (mb.isMultiBlock(machine)) { - if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { + if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState(); @@ -346,7 +354,7 @@ public class SlimefunSetup { SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("GRIND_STONE"); if (mb.isMultiBlock(machine)) { - if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { + if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState(); Inventory inv = disp.getInventory(); @@ -387,7 +395,7 @@ public class SlimefunSetup { SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("ARMOR_FORGE"); if (mb.isMultiBlock(machine)) { - if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { + if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState(); final Inventory inv = disp.getInventory(); @@ -459,7 +467,7 @@ public class SlimefunSetup { SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("ORE_CRUSHER"); if (mb.isMultiBlock(machine)) { - if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { + if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState(); Inventory inv = disp.getInventory(); @@ -500,7 +508,7 @@ public class SlimefunSetup { SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("COMPRESSOR"); if (mb.isMultiBlock(machine)) { - if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { + if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState(); final Inventory inv = disp.getInventory(); @@ -613,8 +621,6 @@ public class SlimefunSetup { @Override public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) { if (SlimefunManager.isItemSimiliar(item, SlimefunItems.MAGIC_EYE_OF_ENDER, true)) { - //It don't works - //e.setCanceled(true); e.getParentEvent().setCancelled(true); PlayerInventory.update(p); if (p.getInventory().getHelmet() != null && p.getInventory().getChestplate() != null && p.getInventory().getLeggings() != null && p.getInventory().getBoots() != null) { @@ -731,7 +737,7 @@ public class SlimefunSetup { SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("SMELTERY"); if (mb.isMultiBlock(machine)) { - if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { + if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState(); Inventory inv = disp.getInventory(); @@ -763,7 +769,7 @@ public class SlimefunSetup { p.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1); Block raw_disp = b.getRelative(BlockFace.DOWN); Hopper chamber = null; - if(BlockStorage.check(raw_disp.getRelative(BlockFace.EAST).getState().getBlock(), "IGNITION_CHAMBER")) { + if (BlockStorage.check(raw_disp.getRelative(BlockFace.EAST).getState().getBlock(), "IGNITION_CHAMBER")) { chamber = (Hopper) raw_disp.getRelative(BlockFace.EAST).getState(); } else if (BlockStorage.check(raw_disp.getRelative(BlockFace.WEST).getState().getBlock(), "IGNITION_CHAMBER")) { chamber = (Hopper) raw_disp.getRelative(BlockFace.WEST).getState(); @@ -774,11 +780,11 @@ public class SlimefunSetup { } if (SlimefunStartup.chance(100, (Integer) Slimefun.getItemValue("SMELTERY", "chance.fireBreak"))) { - if(chamber != null) { + if (chamber != null) { if (chamber.getInventory().contains(Material.FLINT_AND_STEEL)) { ItemStack item = chamber.getInventory().getItem(chamber.getInventory().first(Material.FLINT_AND_STEEL)); item.setDurability((short) (item.getDurability() + 1)); - if(item.getDurability() >= item.getType().getMaxDurability()) { + if (item.getDurability() >= item.getType().getMaxDurability()) { item.setAmount(0); p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1); } @@ -830,7 +836,7 @@ public class SlimefunSetup { SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("PRESSURE_CHAMBER"); if (mb.isMultiBlock(machine)) { - if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { + if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { Dispenser disp = (Dispenser) b.getRelative(BlockFace.UP).getRelative(BlockFace.UP).getState(); final Inventory inv = disp.getInventory(); @@ -1166,7 +1172,7 @@ public class SlimefunSetup { SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("MAGIC_WORKBENCH"); if (mb.isMultiBlock(machine)) { - if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { + if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { Dispenser disp = null; @@ -1406,7 +1412,7 @@ public class SlimefunSetup { SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("ORE_WASHER"); if (mb.isMultiBlock(machine)) { - if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { + if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { Dispenser disp = (Dispenser) b.getRelative(BlockFace.UP).getState(); Inventory inv = disp.getInventory(); @@ -1895,11 +1901,11 @@ public class SlimefunSetup { @Override public boolean onInteract(Player p, MultiBlock mb, Block b) { if (mb.isMultiBlock(SlimefunItem.getByID("SAW_MILL"))) { - if(CSCoreLib.getLib().getProtectionManager().canBuild(p.getUniqueId(), b.getRelative(BlockFace.UP), true)) { + if (CSCoreLib.getLib().getProtectionManager().canBuild(p.getUniqueId(), b.getRelative(BlockFace.UP), true)) { if (Slimefun.hasUnlocked(p, SlimefunItems.SAW_MILL, true)) { if (b.getRelative(BlockFace.UP).getType() == Material.LOG || b.getRelative(BlockFace.UP).getType() == Material.LOG_2) { Block log = b.getRelative(BlockFace.UP); - if(!BlockStorage.hasBlockInfo(log)) { + if (!BlockStorage.hasBlockInfo(log)) { ItemStack item = log.getType() == Material.LOG ? new CustomItem(Material.WOOD, log.getData() % 4, 8) : new CustomItem(Material.WOOD, (log.getData() % 2) + 4, 8); log.getWorld().dropItemNaturally(log.getLocation(), item); log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType()); @@ -1959,9 +1965,16 @@ public class SlimefunSetup { @Override public boolean onInteract(final Player p, MultiBlock mb, final Block b) { if (mb.isMultiBlock(SlimefunItem.getByID("DIGITAL_MINER"))) { - if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { + if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { if (Slimefun.hasUnlocked(p, SlimefunItems.DIGITAL_MINER, true)) { - Chest chest = (Chest) b.getRelative(BlockFace.UP).getState(); + Block chestBlock = b.getRelative(BlockFace.UP); + + if(!(BlockStorage.check(chestBlock.getRelative(BlockFace.WEST), "SOLAR_PANEL") && BlockStorage.check(chestBlock.getRelative(BlockFace.EAST), "SOLAR_PANEL")) && + !(BlockStorage.check(chestBlock.getRelative(BlockFace.NORTH), "SOLAR_PANEL") && BlockStorage.check(chestBlock.getRelative(BlockFace.SOUTH), "SOLAR_PANEL"))) { + return false; + } + + Chest chest = (Chest) chestBlock.getState(); final Inventory inv = chest.getInventory(); List ores = new ArrayList(); for (int x = b.getX() - 4; x < b.getX() + 4; x++) { @@ -2037,9 +2050,16 @@ public class SlimefunSetup { @Override public boolean onInteract(final Player p, MultiBlock mb, final Block b) { if (mb.isMultiBlock(SlimefunItem.getByID("ADVANCED_DIGITAL_MINER"))) { - if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { + if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { if (Slimefun.hasUnlocked(p, SlimefunItems.ADVANCED_DIGITAL_MINER, true)) { - Chest chest = (Chest) b.getRelative(BlockFace.UP).getState(); + Block chestBlock = b.getRelative(BlockFace.UP); + + if(!(BlockStorage.check(chestBlock.getRelative(BlockFace.WEST), "SOLAR_PANEL") && BlockStorage.check(chestBlock.getRelative(BlockFace.EAST), "SOLAR_PANEL")) && + !(BlockStorage.check(chestBlock.getRelative(BlockFace.NORTH), "SOLAR_PANEL") && BlockStorage.check(chestBlock.getRelative(BlockFace.SOUTH), "SOLAR_PANEL"))) { + return false; + } + + Chest chest = (Chest) chestBlock.getState(); final Inventory inv = chest.getInventory(); List ores = new ArrayList(); for (int x = b.getX() - 6; x < b.getX() + 6; x++) { @@ -2126,7 +2146,7 @@ public class SlimefunSetup { if (e.getClickedBlock() != null) { SlimefunItem machine = BlockStorage.check(e.getClickedBlock()); if (machine != null && machine.getID().equals("COMPOSTER")) { - if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), e.getClickedBlock(), true)) { + if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), e.getClickedBlock(), true)) { final ItemStack input = p.getInventory().getItemInMainHand(); final Block b = e.getClickedBlock(); for (ItemStack convert: RecipeType.getRecipeInputs(machine)) { @@ -2305,7 +2325,7 @@ public class SlimefunSetup { @Override public boolean onInteract(final Player p, MultiBlock mb, final Block b) { if (mb.isMultiBlock(SlimefunItem.getByID("AUTOMATED_PANNING_MACHINE"))) { - if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { + if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { final ItemStack input = p.getInventory().getItemInMainHand(); ItemStack output = null; if (SlimefunStartup.chance(100, (Integer) Slimefun.getItemValue("GOLD_PAN", "chance.SIFTED_ORE"))) output = SlimefunItems.SIFTED_ORE; @@ -2448,7 +2468,7 @@ public class SlimefunSetup { if (e.getClickedBlock() != null) { SlimefunItem machine = BlockStorage.check(e.getClickedBlock()); if (machine != null && machine.getID().equals("CRUCIBLE")) { - if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), e.getClickedBlock(), true)) { + if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), e.getClickedBlock(), true)) { final ItemStack input = p.getInventory().getItemInMainHand(); final Block block = e.getClickedBlock().getRelative(BlockFace.UP); for (ItemStack convert: RecipeType.getRecipeInputs(machine)) { @@ -2809,7 +2829,7 @@ public class SlimefunSetup { SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("JUICER"); if (mb.isMultiBlock(machine)) { - if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { + if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) { if (Slimefun.hasUnlocked(p, SlimefunItems.JUICER, true)) { Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState(); Inventory inv = disp.getInventory(); @@ -3998,10 +4018,10 @@ public class SlimefunSetup { public void tick(Block b, SlimefunItem item, Config data) { int charge = ChargableBlock.getCharge(b); if (charge > 0) { - Slimefun.getGPSNetwork().updateTransmitter(b, UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), NetworkStatus.ONLINE); + Slimefun.getGPSNetwork().updateTransmitter(b, UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.ONLINE); ChargableBlock.setCharge(b, charge - 1); } - else Slimefun.getGPSNetwork().updateTransmitter(b, UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), NetworkStatus.OFFLINE); + else Slimefun.getGPSNetwork().updateTransmitter(b, UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.OFFLINE); } @Override @@ -4023,7 +4043,7 @@ public class SlimefunSetup { @Override public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { - Slimefun.getGPSNetwork().updateTransmitter(b, UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), NetworkStatus.OFFLINE); + Slimefun.getGPSNetwork().updateTransmitter(b, UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.OFFLINE); return true; } }); @@ -4036,11 +4056,11 @@ public class SlimefunSetup { public void tick(Block b, SlimefunItem item, Config data) { int charge = ChargableBlock.getCharge(b); if (charge > 2) { - Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 4 + 100, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), NetworkStatus.ONLINE); + Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 4 + 100, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.ONLINE); ChargableBlock.setCharge(b, charge - 3); } else { - Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 4 + 100, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), NetworkStatus.OFFLINE); + Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 4 + 100, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.OFFLINE); } } @@ -4063,7 +4083,7 @@ public class SlimefunSetup { @Override public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { - Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 4 + 100, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), NetworkStatus.OFFLINE); + Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 4 + 100, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.OFFLINE); return true; } }); @@ -4076,11 +4096,11 @@ public class SlimefunSetup { public void tick(Block b, SlimefunItem item, Config data) { int charge = ChargableBlock.getCharge(b); if (charge > 10) { - Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 16 + 500, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), NetworkStatus.ONLINE); + Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 16 + 500, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.ONLINE); ChargableBlock.setCharge(b, charge - 11); } else { - Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 16 + 500, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), NetworkStatus.OFFLINE); + Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 16 + 500, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.OFFLINE); } } @@ -4103,7 +4123,7 @@ public class SlimefunSetup { @Override public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { - Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 16 + 500, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), NetworkStatus.OFFLINE); + Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 16 + 500, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.OFFLINE); return true; } }); @@ -4116,11 +4136,11 @@ public class SlimefunSetup { public void tick(Block b, SlimefunItem item, Config data) { int charge = ChargableBlock.getCharge(b); if (charge > 45) { - Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 64 + 800, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), NetworkStatus.ONLINE); + Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 64 + 800, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.ONLINE); ChargableBlock.setCharge(b, charge - 46); } else { - Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 64 + 800, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), NetworkStatus.OFFLINE); + Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 64 + 800, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.OFFLINE); } } @@ -4143,7 +4163,7 @@ public class SlimefunSetup { @Override public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { - Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 64 + 800, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), NetworkStatus.OFFLINE); + Slimefun.getGPSNetwork().updateTransmitter(new Location(b.getWorld(), b.getX(), b.getY() * 64 + 800, b.getZ()).getBlock(), UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.OFFLINE); return true; } }); @@ -4717,7 +4737,7 @@ public class SlimefunSetup { @Override public void onInteract(final Player p, final Block b) throws Exception { - GPSNetwork.openTeleporterGUI(p, UUID.fromString(BlockStorage.getBlockInfo(b, "owner")), b, Slimefun.getGPSNetwork().getNetworkComplexity(UUID.fromString(BlockStorage.getBlockInfo(b, "owner")))); + GPSNetwork.openTeleporterGUI(p, UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), b, Slimefun.getGPSNetwork().getNetworkComplexity(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")))); } } diff --git a/src/me/mrCookieSlime/Slimefun/SlimefunGuide.java b/src/me/mrCookieSlime/Slimefun/SlimefunGuide.java index 9acaddc47..867635f3b 100644 --- a/src/me/mrCookieSlime/Slimefun/SlimefunGuide.java +++ b/src/me/mrCookieSlime/Slimefun/SlimefunGuide.java @@ -399,25 +399,25 @@ public class SlimefunGuide { actions.add(null); } } - texts.add("&8\u21E8 &6Tier " + tier); + texts.add(ChatColor.translateAlternateColorCodes('&', "&8\u21E8 &6Tier " + tier)); tooltips.add(null); actions.add(null); } if (category instanceof LockedCategory && !((LockedCategory) category).hasUnlocked(p)) { - StringBuilder parents = new StringBuilder("&4&lLOCKED\n\n&7In order to unlock this Category,\n&7you need to unlock all Items from\n&7the following Categories first:\n"); + StringBuilder parents = new StringBuilder(ChatColor.translateAlternateColorCodes('&', "&4&lLOCKED\n\n&7In order to unlock this Category,\n&7you need to unlock all Items from\n&7the following Categories first:\n")); for (Category parent: ((LockedCategory) category).getParents()) { - parents.append("\n&c" + StringUtils.formatItemName(parent.getItem(), false)); + parents.append(ChatColor.translateAlternateColorCodes('&', "\n&c" + StringUtils.formatItemName(parent.getItem(), false))); } - texts.add(shorten("&c" , StringUtils.formatItemName(category.getItem(), false))); + texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&c" , StringUtils.formatItemName(category.getItem(), false)))); tooltips.add(parents.toString()); actions.add(null); } else if (category instanceof SeasonCategory) { if (((SeasonCategory) category).isUnlocked()) { - texts.add(shorten("&a", StringUtils.formatItemName(category.getItem(), false))); - tooltips.add("&eClick to open the following Category:\n" + StringUtils.formatItemName(category.getItem(), false)); + texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&a", StringUtils.formatItemName(category.getItem(), false)))); + tooltips.add(ChatColor.translateAlternateColorCodes('&', "&eClick to open the following Category:\n" + StringUtils.formatItemName(category.getItem(), false))); actions.add(new PlayerRunnable(1) { @Override @@ -434,8 +434,8 @@ public class SlimefunGuide { } } else { - texts.add(shorten("&a", StringUtils.formatItemName(category.getItem(), false))); - tooltips.add("&eClick to open the following Category:\n" + StringUtils.formatItemName(category.getItem(), false)); + texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&a", StringUtils.formatItemName(category.getItem(), false)))); + tooltips.add(ChatColor.translateAlternateColorCodes('&', "&eClick to open the following Category:\n" + StringUtils.formatItemName(category.getItem(), false))); actions.add(new PlayerRunnable(1) { @Override @@ -468,7 +468,7 @@ public class SlimefunGuide { for (int i = 0; i < texts.size(); i = i + 10) { TellRawMessage page = new TellRawMessage(); - page.addText("&b&l- Slimefun Guide -\n\n"); + page.addText(ChatColor.translateAlternateColorCodes('&', "&b&l- Slimefun Guide -\n\n")); for (int j = i; j < texts.size() && j < i + 10; j++) { page.addText(texts.get(j) + "\n"); if (tooltips.get(j) != null) page.addHoverEvent(HoverAction.SHOW_TEXT, tooltips.get(j)); @@ -476,15 +476,15 @@ public class SlimefunGuide { } // page.addText("\n"); // if (i > 0) { -// page.addText("&c<- Prev"); -// page.addHoverEvent(HoverAction.SHOW_TEXT, "&eGo to Page " + (i)); +// page.addText(ChatColor.translateAlternateColorCodes('&', "&c<- Prev")); +// page.addHoverEvent(HoverAction.SHOW_TEXT, ChatColor.translateAlternateColorCodes('&', "&eGo to Page " + (i))); // page.addClickEvent(me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage.ClickAction.CHANGE_PAGE, String.valueOf(i)); // page.addText(" "); // } // if (texts.size() > i * 10) { // page.addText(" "); -// page.addText("&cNext ->"); -// page.addHoverEvent(HoverAction.SHOW_TEXT, "&eGo to Page " + (i + 2)); +// page.addText(ChatColor.translateAlternateColorCodes('&', "&cNext ->")); +// page.addHoverEvent(HoverAction.SHOW_TEXT, ChatColor.translateAlternateColorCodes('&', "&eGo to Page " + (i + 2))); // page.addClickEvent(me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage.ClickAction.CHANGE_PAGE, String.valueOf(i + 2)); // } pages.add(page); @@ -604,8 +604,8 @@ public class SlimefunGuide { else { List parents = new ArrayList(); parents.add(""); - parents.add("&rYou need to unlock all Items"); - parents.add("&rfrom the following Categories first:"); + parents.add(ChatColor.translateAlternateColorCodes('&', "&rYou need to unlock all Items")); + parents.add(ChatColor.translateAlternateColorCodes('&', "&rfrom the following Categories first:")); parents.add(""); for (Category parent: ((LockedCategory) category).getParents()) { parents.add(parent.getItem().getItemMeta().getDisplayName()); @@ -674,8 +674,8 @@ public class SlimefunGuide { if (survival && !Slimefun.hasUnlocked(p, item, false) && item.getResearch() != null) { final Research research = item.getResearch(); - texts.add(shorten("&7", StringUtils.formatItemName(item.getItem(), false))); - tooltips.add(StringUtils.formatItemName(item.getItem(), false) + "\n&c&lLOCKED\n\n&7Cost: " + (p.getLevel() >= research.getCost() ? "&b": "&4") + research.getCost() + " Levels\n\n&a> Click to unlock"); + texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&7", StringUtils.formatItemName(item.getItem(), false)))); + tooltips.add(ChatColor.translateAlternateColorCodes('&', StringUtils.formatItemName(item.getItem(), false) + "\n&c&lLOCKED\n\n&7Cost: " + (p.getLevel() >= research.getCost() ? "&b": "&4") + research.getCost() + " Levels\n\n&a> Click to unlock")); actions.add(new PlayerRunnable(2) { @Override @@ -715,7 +715,7 @@ public class SlimefunGuide { }); } else { - texts.add(shorten("&a", StringUtils.formatItemName(item.getItem(), false))); + texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&a", StringUtils.formatItemName(item.getItem(), false)))); StringBuilder tooltip = new StringBuilder(); @@ -727,7 +727,7 @@ public class SlimefunGuide { } } - tooltip.append("\n\n&e&oClick for more Info"); + tooltip.append(ChatColor.translateAlternateColorCodes('&', "\n\n&e&oClick for more Info")); tooltips.add(tooltip.toString()); actions.add(new PlayerRunnable(2) { @@ -741,23 +741,23 @@ public class SlimefunGuide { } } else { - texts.add(shorten("&4", StringUtils.formatItemName(item.getItem(), false))); - tooltips.add("&cNo Permission!"); + texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&4", StringUtils.formatItemName(item.getItem(), false)))); + tooltips.add(ChatColor.translateAlternateColorCodes('&', "&cNo Permission!")); actions.add(null); } } for (int i = 0; i < texts.size(); i = i + 10) { TellRawMessage page = new TellRawMessage(); - page.addText("&b&l- Slimefun Guide -\n\n"); + page.addText(ChatColor.translateAlternateColorCodes('&', "&b&l- Slimefun Guide -\n\n")); for (int j = i; j < texts.size() && j < i + 10; j++) { page.addText(texts.get(j) + "\n"); if (tooltips.get(j) != null) page.addHoverEvent(HoverAction.SHOW_TEXT, tooltips.get(j)); if (actions.get(j) != null) page.addClickEvent(actions.get(j)); } page.addText("\n"); - page.addText("&6\u21E6 &lBack"); - page.addHoverEvent(HoverAction.SHOW_TEXT, "&eClick to go back to the Category Overview"); + page.addText(ChatColor.translateAlternateColorCodes('&', "&6\u21E6 &lBack")); + page.addHoverEvent(HoverAction.SHOW_TEXT, ChatColor.translateAlternateColorCodes('&', "&eClick to go back to the Category Overview")); page.addClickEvent(new PlayerRunnable(2) { @Override @@ -984,7 +984,7 @@ public class SlimefunGuide { if (sfItem != null) { recipe = sfItem.getRecipe(); recipeType = sfItem.getRecipeType().toItem(); - recipeOutput = sfItem.getCustomOutput() != null ? sfItem.getCustomOutput(): sfItem.getItem(); + recipeOutput = sfItem.getRecipeOutput() != null ? sfItem.getRecipeOutput(): sfItem.getItem(); } else { List recipes = new ArrayList(); @@ -1118,7 +1118,7 @@ public class SlimefunGuide { }); if (sfItem != null) { - if (Slimefun.getItemConfig().contains(sfItem.getName() + ".wiki")) { + if (Slimefun.getItemConfig().contains(sfItem.getID() + ".wiki")) { try { menu.addItem(8, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzY2OTJmOTljYzZkNzgyNDIzMDQxMTA1NTM1ODk0ODQyOThiMmU0YTAyMzNiNzY3NTNmODg4ZTIwN2VmNSJ9fX0="), "&rView this Item in our Wiki &7(Slimefun Wiki)", "", "&7\u21E8 Click to open")); menu.addMenuClickHandler(8, new MenuClickHandler() { @@ -1127,7 +1127,7 @@ public class SlimefunGuide { public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) { p.closeInventory(); p.sendMessage(""); - p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o" + Slimefun.getItemConfig().getString(sfItem.getName() + ".wiki"))); + p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o" + Slimefun.getItemConfig().getString(sfItem.getID() + ".wiki"))); p.sendMessage(""); return false; } @@ -1136,7 +1136,7 @@ public class SlimefunGuide { e.printStackTrace(); } } - if (Slimefun.getItemConfig().contains(sfItem.getName() + ".youtube")) { + if (Slimefun.getItemConfig().contains(sfItem.getID() + ".youtube")) { try { menu.addItem(7, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzNTNmZDBmODYzMTQzNTM4NzY1ODYwNzViOWJkZjBjNDg0YWFiMDMzMWI4NzJkZjExYmQ1NjRmY2IwMjllZCJ9fX0="), "&rDemonstration Video &7(Youtube)", "", "&7\u21E8 Click to watch")); menu.addMenuClickHandler(7, new MenuClickHandler() { @@ -1145,7 +1145,7 @@ public class SlimefunGuide { public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) { p.closeInventory(); p.sendMessage(""); - p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o" + Slimefun.getItemConfig().getString(sfItem.getName() + ".youtube"))); + p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o" + Slimefun.getItemConfig().getString(sfItem.getID() + ".youtube"))); p.sendMessage(""); return false; } diff --git a/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java b/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java index a811b8d25..4fdd4b688 100644 --- a/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java +++ b/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java @@ -34,6 +34,7 @@ import me.mrCookieSlime.Slimefun.GitHub.GitHubConnector; import me.mrCookieSlime.Slimefun.GitHub.GitHubSetup; import me.mrCookieSlime.Slimefun.Hashing.ItemHash; import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; +import me.mrCookieSlime.Slimefun.Misc.BookDesign; import me.mrCookieSlime.Slimefun.Objects.MultiBlock; import me.mrCookieSlime.Slimefun.Objects.Research; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunArmorPiece; @@ -223,7 +224,9 @@ public class SlimefunStartup extends JavaPlugin { Player p = e.getPlayer(); if (!getWhitelist().getBoolean(p.getWorld().getName() + ".enabled")) return; if (!getWhitelist().getBoolean(p.getWorld().getName() + ".enabled-items.SLIMEFUN_GUIDE")) return; - p.getInventory().addItem(SlimefunGuide.getItem(config.getBoolean("guide.default-view-book"))); + + if (config.getBoolean("guide.default-view-book")) p.getInventory().addItem(SlimefunGuide.getItem(BookDesign.BOOK)); + else p.getInventory().addItem(SlimefunGuide.getItem(BookDesign.CHEST)); } } @@ -285,7 +288,7 @@ public class SlimefunStartup extends JavaPlugin { Class.forName("com.sk89q.worldedit.extent.Extent"); new WESlimefunManager(); System.out.println("[Slimefun] Successfully hooked into WorldEdit!"); - } catch(Exception x) { + } catch (Exception x) { System.err.println("[Slimefun] Failed to hook into WorldEdit!"); System.err.println("[Slimefun] Maybe consider updating WorldEdit or Slimefun?"); } @@ -376,7 +379,7 @@ public class SlimefunStartup extends JavaPlugin { Bukkit.getScheduler().scheduleSyncDelayedTask(this, new BukkitRunnable() { @Override public void run() { - exoticGarden = getServer().getPluginManager().isPluginEnabled("ExoticGarden"); //Had to do it this way, otherwise it seems disabled. + exoticGarden = getServer().getPluginManager().isPluginEnabled("ExoticGarden"); // Had to do it this way, otherwise it seems disabled. } }, 0); @@ -416,8 +419,7 @@ public class SlimefunStartup extends JavaPlugin { } SlimefunBackup.start(); - } catch(Exception x) { - } + } catch (Exception x) {} // Prevent Memory Leaks config = null; diff --git a/src/me/mrCookieSlime/Slimefun/api/BlockInfoConfig.java b/src/me/mrCookieSlime/Slimefun/api/BlockInfoConfig.java new file mode 100644 index 000000000..8cffcb7c2 --- /dev/null +++ b/src/me/mrCookieSlime/Slimefun/api/BlockInfoConfig.java @@ -0,0 +1,132 @@ +package me.mrCookieSlime.Slimefun.api; + +import java.io.File; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.bukkit.configuration.file.FileConfiguration; + +import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; + +public class BlockInfoConfig extends Config { + private Map data; + public BlockInfoConfig() { + this(new HashMap<>()); + } + public BlockInfoConfig(Map data) { + super((File)null,(FileConfiguration)null); + this.data=data; + } + public Map getMap(){ + return data; + } + @Override + protected void store(String path, Object value) { + if (value != null && !(value instanceof String)) { + throw new UnsupportedOperationException("Can't set \""+path+"\" to \""+value+"\" (type: "+value.getClass().getSimpleName()+") because BlockInfoConfig only supports Strings"); + } + checkPath(path); + if (value == null) { + data.remove(path); + } else { + data.put(path, (String) value); + } + } + + + private void checkPath(String path) { + if (path.contains(".")) { + throw new UnsupportedOperationException("BlockInfoConfig only supports Map (path: " + path+")"); + } + } + + @Override + public boolean contains(String path) { + checkPath(path); + return data.containsKey(path); + } + + @Override + public Object getValue(String path) { + checkPath(path); + return data.get(path); + } + + @Override + public String getString(String path) { + checkPath(path); + return data.get(path); + } + + @Override + public Set getKeys() { + return data.keySet(); + } + + private UnsupportedOperationException invalidType(String path) { + return new UnsupportedOperationException("Can't get \""+path+"\" because BlockInfoConfig only supports String values"); + } + + @Override + public int getInt(String path) { + throw invalidType(path); + } + + @Override + public boolean getBoolean(String path) { + throw invalidType(path); + } + + @Override + public List getStringList(String path) { + throw invalidType(path); + } + + @Override + public List getIntList(String path) { + throw invalidType(path); + } + + @Override + public Double getDouble(String path) { + throw invalidType(path); + } + + @Override + public Set getKeys(String path) { + throw invalidType(path); + } + + @Override + public File getFile() { + throw new UnsupportedOperationException(); + } + + @Override + public FileConfiguration getConfiguration() { + throw new UnsupportedOperationException(); + } + + @Override + public void save() { + throw new UnsupportedOperationException(); + } + + @Override + public void save(File file) { + throw new UnsupportedOperationException(); + } + + @Override + public void createFile() { + throw new UnsupportedOperationException(); + } + + @Override + public void reload() { + throw new UnsupportedOperationException(); + } + +} diff --git a/src/me/mrCookieSlime/Slimefun/api/BlockStorage.java b/src/me/mrCookieSlime/Slimefun/api/BlockStorage.java index 0f609a41e..ed7a95bc6 100644 --- a/src/me/mrCookieSlime/Slimefun/api/BlockStorage.java +++ b/src/me/mrCookieSlime/Slimefun/api/BlockStorage.java @@ -39,7 +39,7 @@ public class BlockStorage { private World world; - private Map storage = new HashMap(); + private Map storage = new HashMap<>(); private static Map map_chunks = new HashMap(); private Map inventories = new HashMap(); @@ -73,7 +73,7 @@ public class BlockStorage { try { World w = Bukkit.getWorld(l.split(";")[0]); if (w != null) return new Location(w, Integer.parseInt(l.split(";")[1]), Integer.parseInt(l.split(";")[2]), Integer.parseInt(l.split(";")[3])); - } catch(NumberFormatException x) { + } catch (NumberFormatException x) { } return null; } @@ -103,7 +103,10 @@ public class BlockStorage { String chunk_string = locationToChunkString(l); try { totalBlocks++; - storage.put(l, cfg.getString(key)); + String json = cfg.getString(key); + Config blockInfo = parseBlockInfo(l, json); + if (blockInfo == null) continue; + storage.put(l, blockInfo); if (SlimefunItem.isTicking(file.getName().replace(".sfb", ""))) { Set locations = ticking_chunks.containsKey(chunk_string) ? ticking_chunks.get(chunk_string): new HashSet(); @@ -111,7 +114,7 @@ public class BlockStorage { ticking_chunks.put(chunk_string, locations); if (!loaded_tickers.contains(chunk_string)) loaded_tickers.add(chunk_string); } - } catch(Exception x) { + } catch (Exception x) { System.err.println("[Slimefun] Failed to load " + file.getName() + "(ERR: " + key + ")"); x.printStackTrace(); } @@ -134,7 +137,7 @@ public class BlockStorage { for (String key: cfg.getKeys(false)) { try { if (world.getName().equals(key.split(";")[0])) map_chunks.put(key, cfg.getString(key)); - } catch(Exception x) { + } catch (Exception x) { System.err.println("[Slimefun] Failed to load " + chunks.getName() + " for World \"" + world.getName() + "\" (ERR: " + key + ")"); x.printStackTrace(); } @@ -157,7 +160,7 @@ public class BlockStorage { inventories.put(l, new BlockMenu(preset, l, cfg)); } } - catch(Exception x) { + catch (Exception x) { } } } @@ -264,7 +267,7 @@ public class BlockStorage { public static ItemStack retrieve(Block block) { if (!hasBlockInfo(block)) return null; else { - final SlimefunItem item = SlimefunItem.getByID(getBlockInfo(block, "id")); + final SlimefunItem item = SlimefunItem.getByID(getLocationInfo(block.getLocation(), "id")); clearBlockInfo(block); if (item == null) return null; else return item.getItem(); @@ -282,30 +285,9 @@ public class BlockStorage { } public static Config getLocationInfo(Location l) { - try { BlockStorage storage = getStorage(l.getWorld()); - Config cfg = new Config("data-storage/Slimefun/temp.yml"); - if (!storage.storage.containsKey(l)) return cfg; - - for (Map.Entry entry: parseJSON(getJSONData(l)).entrySet()) { - cfg.setValue(entry.getKey(), entry.getValue()); - } - - return cfg; - } catch(Exception x) { - System.err.println(x.getClass().getName()); - System.err.println("[Slimefun] Failed to parse BlockInfo for Block @ " + l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ()); - try { - System.err.println(getJSONData(l)); - } catch (Exception x2) { - System.err.println("No Metadata found!"); - } - System.err.println("[Slimefun] "); - System.err.println("[Slimefun] IGNORE THIS ERROR UNLESS IT IS SPAMMING"); - System.err.println("[Slimefun] "); - x.printStackTrace(); - return new Config("data-storage/Slimefun/temp.yml"); - } + Config cfg = storage.storage.get(l); + return cfg == null ? new BlockInfoConfig() : cfg; } private static Map parseJSON(String json) { @@ -328,18 +310,36 @@ public class BlockStorage { return map; } - private static String getJSONData(Location l) { - BlockStorage storage = getStorage(l.getWorld()); - return storage.storage.get(l); + private static BlockInfoConfig parseBlockInfo(Location l, String json){ + try { + return new BlockInfoConfig(parseJSON(json)); + } catch(Exception x) { + System.err.println(x.getClass().getName()); + System.err.println("[Slimefun] Failed to parse BlockInfo for Block @ " + l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ()); + System.err.println(json); + System.err.println("[Slimefun] "); + System.err.println("[Slimefun] IGNORE THIS ERROR UNLESS IT IS SPAMMING"); + System.err.println("[Slimefun] "); + x.printStackTrace(); + return null; + } + } + + @SuppressWarnings("unchecked") + private static String serializeBlockInfo(Config cfg) { + JSONObject json = new JSONObject(); + for (String key: cfg.getKeys()) { + json.put(key, cfg.getString(key)); + } + return json.toJSONString(); } - private static String getJSONData(Chunk chunk) { return map_chunks.get(serializeChunk(chunk)); } @Deprecated public static String getBlockInfo(Block block, String key) { - return getBlockInfo(block.getLocation(), key); + return getLocationInfo(block.getLocation(), key); } @Deprecated @@ -348,7 +348,7 @@ public class BlockStorage { } public static String getLocationInfo(Location l, String key) { - return parseJSON(getJSONData(l)).get(key); + return getBlockInfo(l).getString(key); } public static void addBlockInfo(Location l, String key, String value) { @@ -364,8 +364,7 @@ public class BlockStorage { } public static void addBlockInfo(Location l, String key, String value, boolean updateTicker) { - Config cfg = new Config("data-storage/Slimefun/temp.yml"); - if (hasBlockInfo(l)) cfg = getBlockInfo(l); + Config cfg = hasBlockInfo(l) ? getLocationInfo(l) : new BlockInfoConfig(); cfg.setValue(key, value); setBlockInfo(l, cfg, updateTicker); } @@ -376,45 +375,36 @@ public class BlockStorage { public static boolean hasBlockInfo(Location l) { BlockStorage storage = getStorage(l.getWorld()); - return storage != null && storage.storage.containsKey(l) && getBlockInfo(l, "id") != null; + return storage != null && storage.storage.containsKey(l) && getLocationInfo(l, "id") != null; } - + public static void setBlockInfo(Block block, Config cfg, boolean updateTicker) { setBlockInfo(block.getLocation(), cfg, updateTicker); } - - @SuppressWarnings("unchecked") + public static void setBlockInfo(Location l, Config cfg, boolean updateTicker) { - _integrated_removeBlockInfo(l, false); - - JSONObject json = new JSONObject(); - for (String key: cfg.getKeys()) { - json.put(key, cfg.getString(key)); - } - - setBlockInfo(l, json.toJSONString(), updateTicker); - } - - public static void setBlockInfo(Block b, String json, boolean updateTicker) { - setBlockInfo(b.getLocation(), json, updateTicker); - } - - public static void setBlockInfo(Location l, String json, boolean updateTicker) { BlockStorage storage = getStorage(l.getWorld()); - storage.storage.put(l, json); - Map parsed = parseJSON(json); - if (BlockMenuPreset.isInventory(parsed.get("id"))) { - if (BlockMenuPreset.isUniversalInventory(parsed.get("id"))) { - if (!universal_inventories.containsKey(parsed.get("id"))) storage.loadUniversalInventory(BlockMenuPreset.getPreset(parsed.get("id"))); + storage.storage.put(l, cfg); + if (BlockMenuPreset.isInventory(cfg.getString("id"))) { + if (BlockMenuPreset.isUniversalInventory(cfg.getString("id"))) { + if (!universal_inventories.containsKey(cfg.getString("id"))) storage.loadUniversalInventory(BlockMenuPreset.getPreset(cfg.getString("id"))); } else if (!storage.hasInventory(l)) { File file = new File("data-storage/Slimefun/stored-inventories/" + serializeLocation(l) + ".sfi"); - if (file.exists()) storage.inventories.put(l, new BlockMenu(BlockMenuPreset.getPreset(parsed.get("id")), l, new Config(file))); - else storage.loadInventory(l, BlockMenuPreset.getPreset(parsed.get("id"))); + if (file.exists()) storage.inventories.put(l, new BlockMenu(BlockMenuPreset.getPreset(cfg.getString("id")), l, new Config(file))); + else storage.loadInventory(l, BlockMenuPreset.getPreset(cfg.getString("id"))); } } - refreshCache(getStorage(l.getWorld()), l, parsed.get("id"), json, updateTicker); + refreshCache(getStorage(l.getWorld()), l, cfg.getString("id"), serializeBlockInfo(cfg), updateTicker); + } + public static void setBlockInfo(Block b, String json, boolean updateTicker) { + setBlockInfo(b.getLocation(), json, updateTicker); + } + public static void setBlockInfo(Location l, String json, boolean updateTicker) { + Config blockInfo = json == null ? new BlockInfoConfig() : parseBlockInfo(l, json); + if (blockInfo == null) return; + setBlockInfo(l, blockInfo, updateTicker); } public static void clearBlockInfo(Block block) { @@ -436,7 +426,7 @@ public class BlockStorage { public static void _integrated_removeBlockInfo(Location l, boolean destroy) { BlockStorage storage = getStorage(l.getWorld()); if (hasBlockInfo(l)) { - refreshCache(storage, l, getBlockInfo(l).getString("id"), null, destroy); + refreshCache(storage, l, getLocationInfo(l).getString("id"), null, destroy); storage.storage.remove(l); } @@ -477,7 +467,7 @@ public class BlockStorage { if (!hasBlockInfo(from)) return; BlockStorage storage = getStorage(from.getWorld()); - setBlockInfo(to, getBlockInfo(from), true); + setBlockInfo(to, getLocationInfo(from), true); if (storage.inventories.containsKey(from)) { BlockMenu menu = storage.inventories.get(from); storage.inventories.put(to, menu); @@ -485,7 +475,7 @@ public class BlockStorage { menu.move(to); } - refreshCache(storage, from, getBlockInfo(from).getString("id"), null, true); + refreshCache(storage, from, getLocationInfo(from).getString("id"), null, true); storage.storage.remove(from); String chunk_string = locationToChunkString(from); @@ -500,11 +490,6 @@ public class BlockStorage { } } - @Deprecated - private static void refreshCache(BlockStorage storage, Block b, String key, String value, boolean updateTicker) { - refreshCache(storage, b.getLocation(), key, value, updateTicker); - } - private static void refreshCache(BlockStorage storage, Location l, String key, String value, boolean updateTicker) { Config cfg = storage.cache_blocks.containsKey(key) ? storage.cache_blocks.get(key): new Config(path_blocks + l.getWorld().getName() + "/" + key + ".sfb"); cfg.setValue(serializeLocation(l), value); @@ -530,7 +515,7 @@ public class BlockStorage { public static SlimefunItem check(Location l) { if (!hasBlockInfo(l)) return null; - return SlimefunItem.getByID(getBlockInfo(l, "id")); + return SlimefunItem.getByID(getLocationInfo(l, "id")); } public static String checkID(Block block) { @@ -543,16 +528,16 @@ public class BlockStorage { public static String checkID(Location l) { if (!hasBlockInfo(l)) return null; - return getBlockInfo(l, "id"); + return getLocationInfo(l, "id"); } public static boolean check(Location l, String slimefunItem) { if (!hasBlockInfo(l)) return false; try { - String id = getBlockInfo(l, "id"); + String id = getLocationInfo(l, "id"); return id != null && id.equalsIgnoreCase(slimefunItem); } - catch(NullPointerException x) { + catch (NullPointerException x) { return false; } } @@ -577,7 +562,7 @@ public class BlockStorage { @Deprecated public static Set getTickingBlocks(String chunk) { Set ret = new HashSet(); - for(Location l: getTickingLocations(chunk)) { + for (Location l: getTickingLocations(chunk)) { ret.add(l.getBlock()); } return ret; @@ -600,7 +585,7 @@ public class BlockStorage { public void clearInventory(Location l) { BlockMenu menu = getInventory(l); - for(HumanEntity human: new ArrayList<>(menu.toInventory().getViewers())) { + for (HumanEntity human: new ArrayList<>(menu.toInventory().getViewers())) { human.closeInventory(); } @@ -654,7 +639,7 @@ public class BlockStorage { } return cfg; - } catch(Exception x) { + } catch (Exception x) { System.err.println(x.getClass().getName()); System.err.println("[Slimefun] Failed to parse ChunkInfo for Chunk @ " + chunk.getX() + ", " + chunk.getZ()); try { @@ -704,7 +689,7 @@ public class BlockStorage { } public static String getBlockInfoAsJson(Location l) { - return getJSONData(l); + return serializeBlockInfo(getLocationInfo(l)); } public boolean hasUniversalInventory(Block block) { diff --git a/src/me/mrCookieSlime/Slimefun/api/TickerTask.java b/src/me/mrCookieSlime/Slimefun/api/TickerTask.java index 4a99de0c0..48cac81c9 100644 --- a/src/me/mrCookieSlime/Slimefun/api/TickerTask.java +++ b/src/me/mrCookieSlime/Slimefun/api/TickerTask.java @@ -79,21 +79,21 @@ public class TickerTask implements Runnable { if (item != null) { machines++; try { - item.getTicker().update(); - if (item.getTicker().isSynchronized()) { + item.getBlockTicker().update(); + if (item.getBlockTicker().isSynchronized()) { Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { @Override public void run() { try { long timestamp3 = System.currentTimeMillis(); - item.getTicker().tick(b, item, BlockStorage.getBlockInfo(l)); + item.getBlockTicker().tick(b, item, BlockStorage.getLocationInfo(l)); map_machinetime.put(item.getID(), (map_machinetime.containsKey(item.getID()) ? map_machinetime.get(item.getID()): 0) + (System.currentTimeMillis() - timestamp3)); map_chunk.put(c, (map_chunk.containsKey(c) ? map_chunk.get(c): 0) + 1); map_machine.put(item.getID(), (map_machine.containsKey(item.getID()) ? map_machine.get(item.getID()): 0) + 1); block_timings.put(l, System.currentTimeMillis() - timestamp3); - } catch(Exception x) { + } catch (Exception x) { int errors = 0; if (bugged.containsKey(l)) errors = bugged.get(l); errors++; @@ -197,15 +197,15 @@ public class TickerTask implements Runnable { } else { long timestamp3 = System.currentTimeMillis(); - item.getTicker().tick(b, item, BlockStorage.getBlockInfo(l)); + item.getBlockTicker().tick(b, item, BlockStorage.getLocationInfo(l)); map_machinetime.put(item.getID(), (map_machinetime.containsKey(item.getID()) ? map_machinetime.get(item.getID()): 0) + (System.currentTimeMillis() - timestamp3)); map_chunk.put(c, (map_chunk.containsKey(c) ? map_chunk.get(c): 0) + 1); map_machine.put(item.getID(), (map_machine.containsKey(item.getID()) ? map_machine.get(item.getID()): 0) + 1); block_timings.put(l, System.currentTimeMillis() - timestamp3); } - tickers.add(item.getTicker()); - } catch(Exception x) { + tickers.add(item.getBlockTicker()); + } catch (Exception x) { int errors = 0; if (bugged.containsKey(l)) errors = bugged.get(l); diff --git a/src/me/mrCookieSlime/Slimefun/api/energy/ChargableBlock.java b/src/me/mrCookieSlime/Slimefun/api/energy/ChargableBlock.java index 261e6ac63..10819fc54 100644 --- a/src/me/mrCookieSlime/Slimefun/api/energy/ChargableBlock.java +++ b/src/me/mrCookieSlime/Slimefun/api/energy/ChargableBlock.java @@ -71,7 +71,7 @@ public class ChargableBlock { } public static int getCharge(Location l) { - String charge = BlockStorage.getBlockInfo(l, "energy-charge"); + String charge = BlockStorage.getLocationInfo(l, "energy-charge"); if (charge != null) return Integer.parseInt(charge); else { BlockStorage.addBlockInfo(l, "energy-charge", "0", false); @@ -173,7 +173,7 @@ public class ChargableBlock { } public static int getMaxCharge(Location l) { - Config cfg = BlockStorage.getBlockInfo(l); + Config cfg = BlockStorage.getLocationInfo(l); if (!cfg.contains("id")) { BlockStorage.clearBlockInfo(l); return 0; diff --git a/src/me/mrCookieSlime/Slimefun/api/energy/EnergyNet.java b/src/me/mrCookieSlime/Slimefun/api/energy/EnergyNet.java index c910a23cf..6557feb49 100644 --- a/src/me/mrCookieSlime/Slimefun/api/energy/EnergyNet.java +++ b/src/me/mrCookieSlime/Slimefun/api/energy/EnergyNet.java @@ -11,7 +11,6 @@ import me.mrCookieSlime.Slimefun.SlimefunStartup; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.TickerTask; -import me.mrCookieSlime.Slimefun.api.network.Network; import me.mrCookieSlime.Slimefun.holograms.EnergyHologram; import org.bukkit.Bukkit; @@ -77,7 +76,7 @@ public class EnergyNet extends Network { public static EnergyNet getNetworkFromLocationOrCreate(Location l) { EnergyNet energy_network = getNetworkFromLocation(l); - if(energy_network == null) { + if (energy_network == null) { energy_network = new EnergyNet(l); registerNetwork(energy_network); } @@ -97,8 +96,8 @@ public class EnergyNet extends Network { } public Network.Component classifyLocation(Location l) { - if(regulator.equals(l)) return Network.Component.REGULATOR; - switch(getComponent(l)) { + if (regulator.equals(l)) return Network.Component.REGULATOR; + switch (getComponent(l)) { case DISTRIBUTOR: return Network.Component.CONNECTOR; case CONSUMER: @@ -110,11 +109,11 @@ public class EnergyNet extends Network { } public void locationClassificationChange(Location l, Network.Component from, Network.Component to) { - if(from == Network.Component.TERMINUS) { + if (from == Network.Component.TERMINUS) { input.remove(l); output.remove(l); } - switch(getComponent(l)) { + switch (getComponent(l)) { case DISTRIBUTOR: if (ChargableBlock.isCapacitor(l)) storage.add(l); break; @@ -124,11 +123,13 @@ public class EnergyNet extends Network { case SOURCE: input.add(l); break; + default: + break; } } public void tick(Block b) { - if(!regulator.equals(b.getLocation())) { + if (!regulator.equals(b.getLocation())) { EnergyHologram.update(b, "&4Multiple Energy Regulators connected"); return; } @@ -143,7 +144,7 @@ public class EnergyNet extends Network { for (final Location source: input) { long timestamp = System.currentTimeMillis(); SlimefunItem item = BlockStorage.check(source); - double energy = item.getEnergyTicker().generateEnergy(source, item, BlockStorage.getBlockInfo(source)); + double energy = item.getEnergyTicker().generateEnergy(source, item, BlockStorage.getLocationInfo(source)); if (item.getEnergyTicker().explode(source)) { BlockStorage.clearBlockInfo(source); diff --git a/src/me/mrCookieSlime/Slimefun/api/item_transport/CargoManager.java b/src/me/mrCookieSlime/Slimefun/api/item_transport/CargoManager.java index 0a21f4b63..34f70476d 100644 --- a/src/me/mrCookieSlime/Slimefun/api/item_transport/CargoManager.java +++ b/src/me/mrCookieSlime/Slimefun/api/item_transport/CargoManager.java @@ -195,7 +195,7 @@ public class CargoManager { String id = BlockStorage.checkID(block); if (id.equals("CARGO_NODE_OUTPUT")) return true; - Config blockInfo = BlockStorage.getBlockInfo(block); // Store the returned Config instance to avoid heavy calls + Config blockInfo = BlockStorage.getLocationInfo(block.getLocation()); // Store the returned Config instance to avoid heavy calls BlockMenu menu = BlockStorage.getInventory(block.getLocation()); boolean lore = blockInfo.getString("filter-lore").equals("true"); diff --git a/src/me/mrCookieSlime/Slimefun/api/item_transport/CargoNet.java b/src/me/mrCookieSlime/Slimefun/api/item_transport/CargoNet.java index a75c9a5db..fd9ba00b1 100644 --- a/src/me/mrCookieSlime/Slimefun/api/item_transport/CargoNet.java +++ b/src/me/mrCookieSlime/Slimefun/api/item_transport/CargoNet.java @@ -26,7 +26,6 @@ import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHan import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem; import me.mrCookieSlime.CSCoreLibPlugin.general.Math.DoubleHandler; -import me.mrCookieSlime.CSCoreLibPlugin.general.Particles.MC_1_8.ParticleEffect; import me.mrCookieSlime.Slimefun.SlimefunStartup; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager.DataType; @@ -46,7 +45,7 @@ public class CargoNet extends Network { private static int[] slots = new int[] {19, 20, 21, 28, 29, 30, 37, 38, 39}; - //Chest Terminal Stuff + // Chest Terminal Stuff private static final ChestTerminalSorter sorter = new ChestTerminalSorter(); public static final int[] terminal_slots = new int[] {0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, 18, 19, 20, 21, 22, 23, 24, 27, 28, 29, 30, 31, 32, 33, 36, 37, 38, 39, 40, 41, 42}; private static final ItemStack terminal_noitem_item = new CustomItem(new MaterialData(Material.BARRIER), "&4No Item cached"); @@ -64,7 +63,7 @@ public class CargoNet extends Network { public static CargoNet getNetworkFromLocationOrCreate(Location l) { CargoNet cargo_network = getNetworkFromLocation(l); - if(cargo_network == null) { + if (cargo_network == null) { cargo_network = new CargoNet(l); registerNetwork(cargo_network); } @@ -96,7 +95,7 @@ public class CargoNet extends Network { public Network.Component classifyLocation(Location l) { String id = BlockStorage.checkID(l); - if(id == null) return null; + if (id == null) return null; switch(id) { case "CARGO_MANAGER": return Component.REGULATOR; @@ -115,7 +114,7 @@ public class CargoNet extends Network { } public void locationClassificationChange(Location l, Component from, Component to) { - if(from == Component.TERMINUS) { + if (from == Component.TERMINUS) { inputNodes.remove(l); outputNodes.remove(l); advancedOutputNodes.remove(l); @@ -123,7 +122,7 @@ public class CargoNet extends Network { imports.remove(l); exports.remove(l); } - if(to == Component.TERMINUS) { + if (to == Component.TERMINUS) { switch(BlockStorage.checkID(l)) { case "CARGO_NODE_INPUT": inputNodes.add(l); @@ -148,7 +147,7 @@ public class CargoNet extends Network { } public void tick(final Block b) { - if(!regulator.equals(b.getLocation())) { + if (!regulator.equals(b.getLocation())) { CargoHologram.update(b, "&4Multiple Cargo Regulators connected"); return; } @@ -164,16 +163,16 @@ public class CargoNet extends Network { final Map> output = new HashMap>(); - for(Location outputNode: outputNodes) { + for (Location outputNode: outputNodes) { Integer frequency = getFrequency(outputNode); - if(!output.containsKey(frequency)) { + if (!output.containsKey(frequency)) { output.put(frequency, new ArrayList()); } output.get(frequency).add(outputNode); } - for(Location outputNode: advancedOutputNodes) { + for (Location outputNode: advancedOutputNodes) { Integer frequency = getFrequency(outputNode); - if(!output.containsKey(frequency)) { + if (!output.containsKey(frequency)) { output.put(frequency, new ArrayList()); } output.get(frequency).add(outputNode); @@ -182,14 +181,14 @@ public class CargoNet extends Network { //Chest Terminal Stuff final Set providers = new HashSet(); final Set destinations; - if(output.containsKey(16)) { + if (output.containsKey(16)) { destinations = new HashSet(output.get(16)); } else { destinations = new HashSet(); } - for(Location inputNode: inputNodes) { + for (Location inputNode: inputNodes) { int frequency = getFrequency(inputNode); - if(frequency == 16) { + if (frequency == 16) { providers.add(inputNode); } } @@ -200,7 +199,7 @@ public class CargoNet extends Network { @Override public void run() { - if (BlockStorage.getBlockInfo(b, "visualizer") == null) { + if (BlockStorage.getLocationInfo(b.getLocation(), "visualizer") == null) { self.display(); } //Chest Terminal Code @@ -239,7 +238,7 @@ public class CargoNet extends Network { } if (!items.isEmpty()) { - int index = Integer.parseInt(BlockStorage.getBlockInfo(bus, "index")); + int index = Integer.parseInt(BlockStorage.getLocationInfo(bus, "index")); index++; if (index > (items.size() - 1)) index = 0; @@ -325,20 +324,20 @@ public class CargoNet extends Network { } } } - //All operations happen here: Everything gets iterated from the Input Nodes. (Apart from ChestTerminal Buses) + // All operations happen here: Everything gets iterated from the Input Nodes. (Apart from ChestTerminal Buses) for (Location input: inputNodes) { Integer frequency = getFrequency(input); - if(frequency < 0 || frequency > 15) { + if (frequency < 0 || frequency > 15) { continue; } Block inputTarget = getAttachedBlock(input.getBlock()); ItemStack stack = null; int previousSlot = -1; - boolean roundrobin = BlockStorage.getBlockInfo(input, "round-robin").equals("true"); + boolean roundrobin = BlockStorage.getLocationInfo(input, "round-robin").equals("true"); if (inputTarget != null) { - ItemSlot slot = CargoManager.withdraw(input.getBlock(), storage, inputTarget, Integer.parseInt(BlockStorage.getBlockInfo(input, "index"))); + ItemSlot slot = CargoManager.withdraw(input.getBlock(), storage, inputTarget, Integer.parseInt(BlockStorage.getLocationInfo(input, "index"))); if (slot != null) { stack = slot.getItem(); previousSlot = slot.getSlot(); @@ -419,8 +418,8 @@ public class CargoNet extends Network { } else if (storage.hasInventory(target.getLocation())) { BlockMenu menu = BlockStorage.getInventory(target.getLocation()); - if (BlockStorage.checkID(target.getLocation()).startsWith("BARREL_") && BlockStorage.getBlockInfo(target.getLocation(), "storedItems") != null) { - int stored = Integer.valueOf(BlockStorage.getBlockInfo(target.getLocation(), "storedItems")); + if (BlockStorage.checkID(target.getLocation()).startsWith("BARREL_") && BlockStorage.getLocationInfo(target.getLocation(), "storedItems") != null) { + int stored = Integer.valueOf(BlockStorage.getLocationInfo(target.getLocation(), "storedItems")); for (int slot: menu.getPreset().getSlotsAccessedByItemTransport(menu, ItemTransportFlow.WITHDRAW, null)) { ItemStack is = menu.getItemInSlot(slot); if (is != null && CargoManager.matchesFilter(l.getBlock(), is, -1)) { @@ -481,7 +480,7 @@ public class CargoNet extends Network { for (final Location l: terminals) { BlockMenu menu = BlockStorage.getInventory(l); - int page = Integer.parseInt(BlockStorage.getBlockInfo(l, "page")); + int page = Integer.parseInt(BlockStorage.getLocationInfo(l, "page")); if (!items.isEmpty() && items.size() < (page - 1) * terminal_slots.length + 1) { page = 1; BlockStorage.addBlockInfo(l, "page", String.valueOf(1)); @@ -557,7 +556,7 @@ public class CargoNet extends Network { private static int getFrequency(Location l) { int freq = 0; try { - freq = Integer.parseInt(BlockStorage.getBlockInfo(l).getString("frequency")); + freq = Integer.parseInt(BlockStorage.getLocationInfo(l).getString("frequency")); } catch (Exception e) {} return freq; } diff --git a/src/me/mrCookieSlime/Slimefun/api/network/Network.java b/src/me/mrCookieSlime/Slimefun/api/network/Network.java index aed9e82b6..d91126e86 100644 --- a/src/me/mrCookieSlime/Slimefun/api/network/Network.java +++ b/src/me/mrCookieSlime/Slimefun/api/network/Network.java @@ -7,8 +7,6 @@ import java.util.HashSet; import java.util.ArrayDeque; import java.util.ArrayList; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; import org.bukkit.Location; import me.mrCookieSlime.CSCoreLibPlugin.general.Particles.MC_1_8.ParticleEffect; diff --git a/src/me/mrCookieSlime/Slimefun/holograms/Projector.java b/src/me/mrCookieSlime/Slimefun/holograms/Projector.java index 8f1424798..3f4b55588 100644 --- a/src/me/mrCookieSlime/Slimefun/holograms/Projector.java +++ b/src/me/mrCookieSlime/Slimefun/holograms/Projector.java @@ -24,8 +24,8 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage; public class Projector { public static ArmorStand getArmorStand(Block projector) { - String nametag = ChatColor.translateAlternateColorCodes('&', BlockStorage.getBlockInfo(projector, "text")); - double offset = Double.valueOf(BlockStorage.getBlockInfo(projector, "offset")); + String nametag = ChatColor.translateAlternateColorCodes('&', BlockStorage.getLocationInfo(projector.getLocation(), "text")); + double offset = Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), "offset")); Location l = new Location(projector.getWorld(), projector.getX() + 0.5, projector.getY() + offset, projector.getZ() + 0.5); for (Entity n: l.getChunk().getEntities()) { @@ -42,7 +42,7 @@ public class Projector { public static void openEditor(Player p, final Block projector) { ChestMenu menu = new ChestMenu("Hologram Settings"); - menu.addItem(0, new CustomItem(new MaterialData(Material.NAME_TAG), "&7Text &e(Click to edit)", "", "&r" + ChatColor.translateAlternateColorCodes('&', BlockStorage.getBlockInfo(projector, "text")))); + menu.addItem(0, new CustomItem(new MaterialData(Material.NAME_TAG), "&7Text &e(Click to edit)", "", "&r" + ChatColor.translateAlternateColorCodes('&', BlockStorage.getLocationInfo(projector.getLocation(), "text")))); menu.addMenuClickHandler(0, new MenuClickHandler() { @Override @@ -64,12 +64,12 @@ public class Projector { } }); - menu.addItem(1, new CustomItem(new MaterialData(Material.WATCH), "&7Offset: &e" + DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getBlockInfo(projector, "offset")) + 1.0D), "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1")); + menu.addItem(1, new CustomItem(new MaterialData(Material.WATCH), "&7Offset: &e" + DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), "offset")) + 1.0D), "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1")); menu.addMenuClickHandler(1, new MenuClickHandler() { @Override public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) { - double offset = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getBlockInfo(projector, "offset")) + (arg3.isRightClicked() ? -0.1F: 0.1F)); + double offset = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), "offset")) + (arg3.isRightClicked() ? -0.1F: 0.1F)); ArmorStand hologram = getArmorStand(projector); Location l = new Location(projector.getWorld(), projector.getX() + 0.5, projector.getY() + offset, projector.getZ() + 0.5); hologram.teleport(l); diff --git a/src/me/mrCookieSlime/Slimefun/listeners/BlockListener.java b/src/me/mrCookieSlime/Slimefun/listeners/BlockListener.java index 3d61ad586..379493af1 100644 --- a/src/me/mrCookieSlime/Slimefun/listeners/BlockListener.java +++ b/src/me/mrCookieSlime/Slimefun/listeners/BlockListener.java @@ -34,6 +34,7 @@ public class BlockListener implements Listener { plugin.getServer().getPluginManager().registerEvents(this, plugin); } + @SuppressWarnings("deprecation") @EventHandler public void onBlockFall(EntityChangeBlockEvent event) { if (event.getEntity() instanceof FallingBlock) { diff --git a/src/me/mrCookieSlime/Slimefun/listeners/ItemPickupListener.java b/src/me/mrCookieSlime/Slimefun/listeners/ItemPickupListener.java index d25ceeda6..8505f9ee4 100644 --- a/src/me/mrCookieSlime/Slimefun/listeners/ItemPickupListener.java +++ b/src/me/mrCookieSlime/Slimefun/listeners/ItemPickupListener.java @@ -13,6 +13,7 @@ import org.bukkit.event.player.PlayerPickupItemEvent; * * @since 4.1.11 */ +@SuppressWarnings("deprecation") public class ItemPickupListener implements Listener { public ItemPickupListener(SlimefunStartup plugin) { diff --git a/src/me/mrCookieSlime/Slimefun/listeners/TeleporterListener.java b/src/me/mrCookieSlime/Slimefun/listeners/TeleporterListener.java index df886f5e7..7cf52335f 100644 --- a/src/me/mrCookieSlime/Slimefun/listeners/TeleporterListener.java +++ b/src/me/mrCookieSlime/Slimefun/listeners/TeleporterListener.java @@ -45,7 +45,7 @@ public class TeleporterListener implements Listener { } } else if (item.getID().equals("GPS_ACTIVATION_DEVICE_PERSONAL")) { - if (BlockStorage.getBlockInfo(e.getClickedBlock(), "owner").equals(e.getPlayer().getUniqueId().toString())) { + if (BlockStorage.getLocationInfo(e.getClickedBlock().getLocation(), "owner").equals(e.getPlayer().getUniqueId().toString())) { SlimefunItem teleporter = BlockStorage.check(e.getClickedBlock().getRelative(BlockFace.DOWN)); if (teleporter instanceof Teleporter) {