mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-29 05:36:04 +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 {
|
public interface Hopper {
|
||||||
|
|
||||||
org.bukkit.block.Hopper getHopper();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will link this hopper with another hopper.
|
* This will link this hopper with another hopper.
|
||||||
*
|
*
|
||||||
|
@ -9,7 +9,7 @@ public interface Module {
|
|||||||
|
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
void run(Hopper hopper);
|
void run(Hopper hopper, org.bukkit.block.Hopper hopperBlock);
|
||||||
|
|
||||||
List<Material> getBlockedItems(Hopper hopper);
|
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> blackList = row.get("blacklist").asItemStackList();
|
||||||
List<ItemStack> voidList = row.get("void").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());
|
Material autoCrafting = Material.valueOf(row.get("autocrafting").asString() == null ? "AIR" : row.get("autocrafting").asString());
|
||||||
|
|
||||||
String blackLoc = row.get("black").asString();
|
String blackLoc = row.get("black").asString();
|
||||||
@ -310,6 +308,7 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
|||||||
for (Hopper hopper : hopperManager.getHoppers().values()) {
|
for (Hopper hopper : hopperManager.getHoppers().values()) {
|
||||||
if (hopper.getLevel() == null || hopper.getLocation() == null)
|
if (hopper.getLevel() == null || hopper.getLocation() == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
String locationStr = Methods.serializeLocation(hopper.getLocation());
|
String locationStr = Methods.serializeLocation(hopper.getLocation());
|
||||||
|
|
||||||
storage.prepareSaveItem("sync", new StorageItem("location", locationStr),
|
storage.prepareSaveItem("sync", new StorageItem("location", locationStr),
|
||||||
|
@ -63,7 +63,7 @@ public class HopHandler {
|
|||||||
|
|
||||||
for (Module module : hopper.getLevel().getRegisteredModules()) {
|
for (Module module : hopper.getLevel().getRegisteredModules()) {
|
||||||
// Run Module
|
// Run Module
|
||||||
module.run(hopper);
|
module.run(hopper, hopperState);
|
||||||
|
|
||||||
// Add banned materials to list.
|
// Add banned materials to list.
|
||||||
List<Material> materials = module.getBlockedItems(hopper);
|
List<Material> materials = module.getBlockedItems(hopper);
|
||||||
@ -82,9 +82,9 @@ public class HopHandler {
|
|||||||
|
|
||||||
linked.add(check);
|
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)
|
if (entity.getType() == EntityType.MINECART_HOPPER)
|
||||||
override = ((HopperMinecart) entity).getInventory();
|
override = ((HopperMinecart) entity).getInventory();
|
||||||
else if (entity.getType() == EntityType.MINECART_CHEST)
|
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))
|
if (!location.getWorld().isChunkLoaded(location.getBlockX() >> 4, location.getBlockZ() >> 4))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.reloadHopper();
|
|
||||||
this.syncName();
|
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
|
@Override
|
||||||
public void link(Block toLink, boolean filtered, Player player) {
|
public void link(Block toLink, boolean filtered, Player player) {
|
||||||
try {
|
try {
|
||||||
|
@ -38,8 +38,7 @@ public class ModuleAutoCrafting implements Module {
|
|||||||
return "AutoCrafting";
|
return "AutoCrafting";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(Hopper hopper) {
|
public void run(Hopper hopper, org.bukkit.block.Hopper hopperBlock) {
|
||||||
org.bukkit.block.Hopper hopperBlock = hopper.getHopper();
|
|
||||||
if (hopper.getAutoCrafting() == null || hopperBlock == null || hopperBlock.getInventory() == null) return;
|
if (hopper.getAutoCrafting() == null || hopperBlock == null || hopperBlock.getInventory() == null) return;
|
||||||
if (hopper.getAutoCrafting() != null && canMove(hopperBlock.getInventory(), new ItemStack(hopper.getAutoCrafting()))) {
|
if (hopper.getAutoCrafting() != null && canMove(hopperBlock.getInventory(), new ItemStack(hopper.getAutoCrafting()))) {
|
||||||
|
|
||||||
|
@ -29,8 +29,7 @@ public class ModuleAutoSell implements Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Hopper hopper) {
|
public void run(Hopper hopper, org.bukkit.block.Hopper hopperBlock) {
|
||||||
org.bukkit.block.Hopper hopperBlock = hopper.getHopper();
|
|
||||||
if (hopperBlock == null || hopperBlock.getInventory() == null) return;
|
if (hopperBlock == null || hopperBlock.getInventory() == null) return;
|
||||||
|
|
||||||
if (((EHopper) hopper).getAutoSellTimer() == -9999) return;
|
if (((EHopper) hopper).getAutoSellTimer() == -9999) return;
|
||||||
|
@ -28,7 +28,7 @@ public class ModuleBlockBreak implements Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Hopper hopper) {
|
public void run(Hopper hopper, org.bukkit.block.Hopper hopperBlock) {
|
||||||
Block block = hopper.getLocation().getBlock();
|
Block block = hopper.getLocation().getBlock();
|
||||||
|
|
||||||
if (!blockTick.containsKey(block)) {
|
if (!blockTick.containsKey(block)) {
|
||||||
|
@ -54,11 +54,9 @@ public class ModuleSuction implements Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Hopper hopper) {
|
public void run(Hopper hopper, org.bukkit.block.Hopper hopperBlock) {
|
||||||
double radius = amount + .5;
|
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);
|
Collection<Entity> nearbyEntite = hopper.getLocation().getWorld().getNearbyEntities(hopper.getLocation().add(0.5, 0.5, 0.5), radius, radius, radius);
|
||||||
|
|
||||||
for (Entity entity : nearbyEntite) {
|
for (Entity entity : nearbyEntite) {
|
||||||
|
Loading…
Reference in New Issue
Block a user