mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-27 05:00:08 +08:00
Fixed handling of double chests and cleaned WorldEditListener up a bit
This commit is contained in:
parent
79f2d68e60
commit
86011a0d0d
@ -27,6 +27,7 @@
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.block.Sign;
|
||||
@ -388,6 +389,9 @@ public boolean clearContainerBlockContents(Vector pt) {
|
||||
|
||||
org.bukkit.inventory.InventoryHolder chest = (org.bukkit.inventory.InventoryHolder) state;
|
||||
Inventory inven = chest.getInventory();
|
||||
if (chest instanceof Chest) {
|
||||
inven = ((Chest) chest).getBlockInventory();
|
||||
}
|
||||
inven.clear();
|
||||
return true;
|
||||
}
|
||||
@ -697,6 +701,9 @@ private BaseItemStack[] getContainerBlockContents(Vector pt) {
|
||||
|
||||
org.bukkit.inventory.InventoryHolder container = (org.bukkit.inventory.InventoryHolder) state;
|
||||
Inventory inven = container.getInventory();
|
||||
if (container instanceof Chest) {
|
||||
inven = ((Chest) container).getBlockInventory();
|
||||
}
|
||||
int size = inven.getSize();
|
||||
BaseItemStack[] contents = new BaseItemStack[size];
|
||||
|
||||
@ -737,6 +744,9 @@ private boolean setContainerBlockContents(Vector pt, BaseItemStack[] contents) {
|
||||
|
||||
org.bukkit.inventory.InventoryHolder chest = (org.bukkit.inventory.InventoryHolder) state;
|
||||
Inventory inven = chest.getInventory();
|
||||
if (chest instanceof Chest) {
|
||||
inven = ((Chest) chest).getBlockInventory();
|
||||
}
|
||||
int size = inven.getSize();
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
|
@ -44,20 +44,20 @@
|
||||
* Handles all events thrown in relation to a Player
|
||||
*/
|
||||
public class WorldEditListener implements Listener {
|
||||
|
||||
|
||||
private WorldEditPlugin plugin;
|
||||
private boolean ignoreLeftClickAir = false;
|
||||
private final static Pattern cuipattern = Pattern.compile("u00a74u00a75u00a73u00a74([^\\|]*)\\|?(.*)");
|
||||
|
||||
/**
|
||||
* Called when a player plays an animation, such as an arm swing
|
||||
*
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
|
||||
/**
|
||||
* Construct the object;
|
||||
*
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public WorldEditListener(WorldEditPlugin plugin) {
|
||||
@ -84,19 +84,15 @@ public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String[] split = event.getMessage().split(" ");
|
||||
|
||||
if (split.length > 0) {
|
||||
split = plugin.getWorldEdit().commandDetection(split);
|
||||
split[0] = "/" + split[0];
|
||||
}
|
||||
|
||||
|
||||
final String newMessage = StringUtil.joinString(split, " ");
|
||||
|
||||
if (!newMessage.equals(event.getMessage())) {
|
||||
@ -104,7 +100,7 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
if (event.getMessage().length() > 0) {
|
||||
plugin.getServer().dispatchCommand(event.getPlayer(),
|
||||
plugin.getServer().dispatchCommand(event.getPlayer(),
|
||||
event.getMessage().substring(1));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
@ -122,7 +118,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.useItemInHand() == Result.DENY) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final LocalPlayer player = plugin.wrapPlayer(event.getPlayer());
|
||||
final LocalWorld world = player.getWorld();
|
||||
final WorldEdit we = plugin.getWorldEdit();
|
||||
@ -181,25 +177,21 @@ public void run() {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Matcher matcher = cuipattern.matcher(event.getMessage());
|
||||
if (matcher.find()) {
|
||||
String type = matcher.group(1);
|
||||
String args = matcher.group(2);
|
||||
|
||||
|
||||
if( type.equals("v") ) {
|
||||
try {
|
||||
plugin.getSession(event.getPlayer()).setCUIVersion(Integer.parseInt(args));
|
||||
event.setCancelled(true);
|
||||
} catch( NumberFormatException e ) {
|
||||
} catch(NumberFormatException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user