mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-25 11:46:45 +01:00
Fixed null values.
This commit is contained in:
parent
0c9fff9410
commit
ce7ca37cbf
@ -12,8 +12,6 @@ import java.util.UUID;
|
||||
|
||||
public interface Hopper {
|
||||
|
||||
org.bukkit.block.Hopper getHopper();
|
||||
|
||||
/**
|
||||
* This will link this hopper with another hopper.
|
||||
*
|
||||
|
@ -9,7 +9,7 @@ public interface Module {
|
||||
|
||||
String getName();
|
||||
|
||||
void run(Hopper hopper);
|
||||
void run(Hopper hopper, org.bukkit.block.Hopper hopperBlock);
|
||||
|
||||
List<Material> getBlockedItems(Hopper hopper);
|
||||
|
||||
|
@ -169,8 +169,6 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
||||
List<ItemStack> blackList = row.get("blacklist").asItemStackList();
|
||||
List<ItemStack> 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),
|
||||
|
@ -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<Material> materials = module.getBlockedItems(hopper);
|
||||
@ -82,9 +82,9 @@ public class HopHandler {
|
||||
|
||||
linked.add(check);
|
||||
|
||||
Collection<Entity> nearbyEntite = hopper.getLocation().getWorld().getNearbyEntities(check, .5, .5, .5);
|
||||
Collection<Entity> 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)
|
||||
|
@ -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 {
|
||||
|
@ -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()))) {
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
@ -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<Entity> nearbyEntite = hopper.getLocation().getWorld().getNearbyEntities(hopper.getLocation().add(0.5, 0.5, 0.5), radius, radius, radius);
|
||||
|
||||
for (Entity entity : nearbyEntite) {
|
||||
|
Loading…
Reference in New Issue
Block a user