I've tried to add the feature of setting a lever and a button to indicate the fill status of the chest and to pulse each time an item is catched. (Setting the lever does work ...)
While doing this, I spotted some parts of the code that might be buggy:
+++b/com/narrowtux/DropChest/EntityWatcher.java
@@ -72,11 +107,15 @@ public class EntityWatcher implements Runnable {
}
item.setItemStack(stack);
}
-
if(dci.getPercentFull()>=plugin.config.getWarnFillStatus()/100.0)
-
boolean is_nearly_full = dci.getPercentFull() >= plugin.config.getWarnFillStatus()
-
do_lever_buttons(world, position, is_nearly_full);
-
if(is_nearly_full)
dci.warnNearlyFull();
+/* bug? vv /
if(allin){
break;
}
+/ do we stop at the first full chest? */
continue;
}
}
I think this part will do the following: Having two chests and an item between then, the code will first look at the first chest and, if it's full, stop processing the chain of chests. The second chest, possibly having some free space, will not be looked at. I did not test it.
@@ -50,17 +83,19 @@ public class EntityWatcher implements Runnable {
}
if(!DropChestItem.acceptsBlockType(block.getType())){
//Try to load the chunk.
-
+// copy/paste bug? -> world.loadChunk(x, z);
continue;
}
At this point, the last if statement made sure the chunk at (x,z) is loaded.
And now to my part, just in case you're curious:
@@ -21,6 +27,33 @@ public class EntityWatcher implements Runnable {
this.plugin = plugin;
}
-
private void do_lever_buttons(World world, Vector position, boolean is_nerly_full) {
-
int x = (int)position.getX();
-
int y = (int)position.getY();
-
int z = (int)position.getZ();
-
do_lever_button(world, x-1, y, z, is_nerly_full);
-
do_lever_button(world, x+1, y, z, is_nerly_full);
-
do_lever_button(world, x, y-1, z, is_nerly_full);
-
do_lever_button(world, x, y+1, z, is_nerly_full);
-
do_lever_button(world, x, y, z-1, is_nerly_full);
-
do_lever_button(world, x, y, z+1, is_nerly_full);
-
-
private void do_lever_button(World world, int x, int y, int z, boolean is_nerly_full) {
-
Server server = plugin.getServer();
-
if (x < 0 || y < 0 || z < 0)
-
-
Block lever = world.getBlockAt(x, y, z);
-
if (lever.getType() == Material.LEVER) {
-
-
lever.setData((byte)(lever.getData() | 0x8));
-
-
lever.setData((byte)(lever.getData() & ~0x8));
+// server.broadcastMessage("tried to set lever at "+x+","+y+","+z);
+// } else if (lever.getType() == Material.STONE_BUTTON) {
+// lever.setData((byte)(lever.getData() | 0x8), true);
+// server.broadcastMessage("tried to push button at "+x+","+y+","+z);
-
-
}
@Override
public void run() {
try{
Pushing the button does not work, but setting the lever works great. I'm not sure pressing a button will work at all ...