From ce7ca37cbf542bb01d3ef9004a6639b0161106cd Mon Sep 17 00:00:00 2001 From: Brianna O'Keefe Date: Tue, 12 Feb 2019 17:30:29 -0500 Subject: [PATCH] Fixed null values. --- .../com/songoda/epichoppers/api/hopper/Hopper.java | 2 -- .../epichoppers/api/hopper/levels/modules/Module.java | 2 +- .../com/songoda/epichoppers/EpicHoppersPlugin.java | 3 +-- .../com/songoda/epichoppers/handlers/HopHandler.java | 6 +++--- .../java/com/songoda/epichoppers/hopper/EHopper.java | 10 ---------- .../hopper/levels/modules/ModuleAutoCrafting.java | 3 +-- .../hopper/levels/modules/ModuleAutoSell.java | 3 +-- .../hopper/levels/modules/ModuleBlockBreak.java | 2 +- .../hopper/levels/modules/ModuleSuction.java | 4 +--- 9 files changed, 9 insertions(+), 26 deletions(-) diff --git a/EpicHoppers-API/src/main/java/com/songoda/epichoppers/api/hopper/Hopper.java b/EpicHoppers-API/src/main/java/com/songoda/epichoppers/api/hopper/Hopper.java index 8cfa8ae..5d4f384 100644 --- a/EpicHoppers-API/src/main/java/com/songoda/epichoppers/api/hopper/Hopper.java +++ b/EpicHoppers-API/src/main/java/com/songoda/epichoppers/api/hopper/Hopper.java @@ -12,8 +12,6 @@ import java.util.UUID; public interface Hopper { - org.bukkit.block.Hopper getHopper(); - /** * This will link this hopper with another hopper. * diff --git a/EpicHoppers-API/src/main/java/com/songoda/epichoppers/api/hopper/levels/modules/Module.java b/EpicHoppers-API/src/main/java/com/songoda/epichoppers/api/hopper/levels/modules/Module.java index c8f107d..c20e38c 100644 --- a/EpicHoppers-API/src/main/java/com/songoda/epichoppers/api/hopper/levels/modules/Module.java +++ b/EpicHoppers-API/src/main/java/com/songoda/epichoppers/api/hopper/levels/modules/Module.java @@ -9,7 +9,7 @@ public interface Module { String getName(); - void run(Hopper hopper); + void run(Hopper hopper, org.bukkit.block.Hopper hopperBlock); List getBlockedItems(Hopper hopper); diff --git a/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/EpicHoppersPlugin.java b/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/EpicHoppersPlugin.java index 6471e8b..d5b3f9f 100644 --- a/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/EpicHoppersPlugin.java +++ b/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/EpicHoppersPlugin.java @@ -169,8 +169,6 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers { List blackList = row.get("blacklist").asItemStackList(); List voidList = row.get("void").asItemStackList(); - int autoSell = row.get("autosell").asInt(); - Material autoCrafting = Material.valueOf(row.get("autocrafting").asString() == null ? "AIR" : row.get("autocrafting").asString()); String blackLoc = row.get("black").asString(); @@ -310,6 +308,7 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers { for (Hopper hopper : hopperManager.getHoppers().values()) { if (hopper.getLevel() == null || hopper.getLocation() == null) continue; + String locationStr = Methods.serializeLocation(hopper.getLocation()); storage.prepareSaveItem("sync", new StorageItem("location", locationStr), diff --git a/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/handlers/HopHandler.java b/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/handlers/HopHandler.java index b280e34..fba8e0d 100644 --- a/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/handlers/HopHandler.java +++ b/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/handlers/HopHandler.java @@ -63,7 +63,7 @@ public class HopHandler { for (Module module : hopper.getLevel().getRegisteredModules()) { // Run Module - module.run(hopper); + module.run(hopper, hopperState); // Add banned materials to list. List materials = module.getBlockedItems(hopper); @@ -82,9 +82,9 @@ public class HopHandler { linked.add(check); - Collection nearbyEntite = hopper.getLocation().getWorld().getNearbyEntities(check, .5, .5, .5); + Collection nearbyEntities = hopper.getLocation().getWorld().getNearbyEntities(check, .5, .5, .5); - for (Entity entity : nearbyEntite) { + for (Entity entity : nearbyEntities) { if (entity.getType() == EntityType.MINECART_HOPPER) override = ((HopperMinecart) entity).getInventory(); else if (entity.getType() == EntityType.MINECART_CHEST) diff --git a/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/EHopper.java b/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/EHopper.java index e93f5e4..8735592 100644 --- a/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/EHopper.java +++ b/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/EHopper.java @@ -49,7 +49,6 @@ public class EHopper implements Hopper { if (!location.getWorld().isChunkLoaded(location.getBlockX() >> 4, location.getBlockZ() >> 4)) return; - this.reloadHopper(); this.syncName(); } @@ -159,15 +158,6 @@ public class EHopper implements Hopper { } } - @Override - public org.bukkit.block.Hopper getHopper() { - return hopper; - } - - public void reloadHopper() { - this.hopper = (org.bukkit.block.Hopper) (location.getBlock() != null && location.getBlock().getType() == Material.HOPPER ? location.getBlock().getState() : null); - } - @Override public void link(Block toLink, boolean filtered, Player player) { try { diff --git a/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleAutoCrafting.java b/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleAutoCrafting.java index 98a3085..9ee829d 100644 --- a/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleAutoCrafting.java +++ b/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleAutoCrafting.java @@ -38,8 +38,7 @@ public class ModuleAutoCrafting implements Module { return "AutoCrafting"; } - public void run(Hopper hopper) { - org.bukkit.block.Hopper hopperBlock = hopper.getHopper(); + public void run(Hopper hopper, org.bukkit.block.Hopper hopperBlock) { if (hopper.getAutoCrafting() == null || hopperBlock == null || hopperBlock.getInventory() == null) return; if (hopper.getAutoCrafting() != null && canMove(hopperBlock.getInventory(), new ItemStack(hopper.getAutoCrafting()))) { diff --git a/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleAutoSell.java b/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleAutoSell.java index 4e8f70c..f36b4fd 100644 --- a/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleAutoSell.java +++ b/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleAutoSell.java @@ -29,8 +29,7 @@ public class ModuleAutoSell implements Module { } @Override - public void run(Hopper hopper) { - org.bukkit.block.Hopper hopperBlock = hopper.getHopper(); + public void run(Hopper hopper, org.bukkit.block.Hopper hopperBlock) { if (hopperBlock == null || hopperBlock.getInventory() == null) return; if (((EHopper) hopper).getAutoSellTimer() == -9999) return; diff --git a/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleBlockBreak.java b/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleBlockBreak.java index 8cc3636..cb5dde1 100644 --- a/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleBlockBreak.java +++ b/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleBlockBreak.java @@ -28,7 +28,7 @@ public class ModuleBlockBreak implements Module { } @Override - public void run(Hopper hopper) { + public void run(Hopper hopper, org.bukkit.block.Hopper hopperBlock) { Block block = hopper.getLocation().getBlock(); if (!blockTick.containsKey(block)) { diff --git a/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java b/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java index 565a077..dc4e978 100644 --- a/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java +++ b/EpicHoppers-Plugin/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java @@ -54,11 +54,9 @@ public class ModuleSuction implements Module { } @Override - public void run(Hopper hopper) { + public void run(Hopper hopper, org.bukkit.block.Hopper hopperBlock) { double radius = amount + .5; - org.bukkit.block.Hopper hopperBlock = hopper.getHopper(); - Collection nearbyEntite = hopper.getLocation().getWorld().getNearbyEntities(hopper.getLocation().add(0.5, 0.5, 0.5), radius, radius, radius); for (Entity entity : nearbyEntite) {