Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-09 13:00:05 +01:00
Fixed handling of double chests and cleaned WorldEditListener up a bit
Dieser Commit ist enthalten in:
Ursprung
79f2d68e60
Commit
86011a0d0d
@ -27,6 +27,7 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
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 class BukkitWorld extends LocalWorld {
|
||||
|
||||
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 @@ public class BukkitWorld extends LocalWorld {
|
||||
|
||||
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 @@ public class BukkitWorld extends LocalWorld {
|
||||
|
||||
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 @@ import java.util.regex.Pattern;
|
||||
* 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 class WorldEditListener implements Listener {
|
||||
*
|
||||
* @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 class WorldEditListener implements Listener {
|
||||
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 class WorldEditListener implements Listener {
|
||||
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 class WorldEditListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren