Fixed handling of double chests and cleaned WorldEditListener up a bit

This commit is contained in:
zml2008 2012-03-20 17:53:15 -07:00
parent 79f2d68e60
commit 86011a0d0d
2 changed files with 21 additions and 19 deletions

View File

@ -27,6 +27,7 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
import org.bukkit.block.Furnace; import org.bukkit.block.Furnace;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
@ -388,6 +389,9 @@ public class BukkitWorld extends LocalWorld {
org.bukkit.inventory.InventoryHolder chest = (org.bukkit.inventory.InventoryHolder) state; org.bukkit.inventory.InventoryHolder chest = (org.bukkit.inventory.InventoryHolder) state;
Inventory inven = chest.getInventory(); Inventory inven = chest.getInventory();
if (chest instanceof Chest) {
inven = ((Chest) chest).getBlockInventory();
}
inven.clear(); inven.clear();
return true; return true;
} }
@ -697,6 +701,9 @@ public class BukkitWorld extends LocalWorld {
org.bukkit.inventory.InventoryHolder container = (org.bukkit.inventory.InventoryHolder) state; org.bukkit.inventory.InventoryHolder container = (org.bukkit.inventory.InventoryHolder) state;
Inventory inven = container.getInventory(); Inventory inven = container.getInventory();
if (container instanceof Chest) {
inven = ((Chest) container).getBlockInventory();
}
int size = inven.getSize(); int size = inven.getSize();
BaseItemStack[] contents = new BaseItemStack[size]; BaseItemStack[] contents = new BaseItemStack[size];
@ -737,6 +744,9 @@ public class BukkitWorld extends LocalWorld {
org.bukkit.inventory.InventoryHolder chest = (org.bukkit.inventory.InventoryHolder) state; org.bukkit.inventory.InventoryHolder chest = (org.bukkit.inventory.InventoryHolder) state;
Inventory inven = chest.getInventory(); Inventory inven = chest.getInventory();
if (chest instanceof Chest) {
inven = ((Chest) chest).getBlockInventory();
}
int size = inven.getSize(); int size = inven.getSize();
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {

View File

@ -84,12 +84,8 @@ public class WorldEditListener implements Listener {
* *
* @param event Relevant event details * @param event Relevant event details
*/ */
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if (event.isCancelled()) {
return;
}
String[] split = event.getMessage().split(" "); String[] split = event.getMessage().split(" ");
if (split.length > 0) { if (split.length > 0) {
@ -181,12 +177,8 @@ public class WorldEditListener implements Listener {
} }
} }
@EventHandler @EventHandler(ignoreCancelled = true)
public void onPlayerChat(PlayerChatEvent event) { public void onPlayerChat(PlayerChatEvent event) {
if (event.isCancelled()) {
return;
}
Matcher matcher = cuipattern.matcher(event.getMessage()); Matcher matcher = cuipattern.matcher(event.getMessage());
if (matcher.find()) { if (matcher.find()) {
String type = matcher.group(1); String type = matcher.group(1);
@ -196,7 +188,7 @@ public class WorldEditListener implements Listener {
try { try {
plugin.getSession(event.getPlayer()).setCUIVersion(Integer.parseInt(args)); plugin.getSession(event.getPlayer()).setCUIVersion(Integer.parseInt(args));
event.setCancelled(true); event.setCancelled(true);
} catch( NumberFormatException e ) { } catch(NumberFormatException ignore) {
} }
} }