SteamWar/BauSystem2.0
Archiviert
12
0

Fix BindCommand
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2024-02-01 21:48:14 +01:00
Ursprung f83ba6ab96
Commit 2ba51e66e0

Datei anzeigen

@ -1,9 +1,17 @@
package de.steamwar.bausystem.features.util; package de.steamwar.bausystem.features.util;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.extension.platform.Actor;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.script.ScriptCommand; import de.steamwar.bausystem.features.script.ScriptCommand;
import de.steamwar.bausystem.features.script.ScriptRunner; import de.steamwar.bausystem.features.script.ScriptRunner;
import de.steamwar.bausystem.features.world.WorldEditListener;
import de.steamwar.bausystem.utils.WorldEditUtils;
import de.steamwar.command.PreviousArguments; import de.steamwar.command.PreviousArguments;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeMapper;
@ -20,14 +28,18 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType; import org.bukkit.persistence.PersistentDataType;
import org.luaj.vm2.LuaValue;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.*; import java.util.*;
import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Linked @Linked
public class BindCommand extends SWCommand implements Listener { public class BindCommand extends SWCommand implements Listener {
private static final boolean hasFAWE = Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit") != null;
@Linked @Linked
public static class UnBindCommand extends SWCommand { public static class UnBindCommand extends SWCommand {
@ -107,7 +119,21 @@ public class BindCommand extends SWCommand implements Listener {
PlayerCommandPreprocessEvent playerCommandPreprocessEvent = new PlayerCommandPreprocessEvent(event.getPlayer(), "/" + command); PlayerCommandPreprocessEvent playerCommandPreprocessEvent = new PlayerCommandPreprocessEvent(event.getPlayer(), "/" + command);
Bukkit.getPluginManager().callEvent(playerCommandPreprocessEvent); Bukkit.getPluginManager().callEvent(playerCommandPreprocessEvent);
if (playerCommandPreprocessEvent.isCancelled()) return; if (playerCommandPreprocessEvent.isCancelled()) return;
Bukkit.getLogger().log(Level.INFO, event.getPlayer().getName() + " dispatched command: " + command);
String[] commandSplit = command.split(" ");
if (!commandSplit[0].equals("select") && hasFAWE && WorldEditListener.isWorldEditCommand("/" + commandSplit[0])) {
if (!Permission.WORLDEDIT.hasPermission(event.getPlayer())) {
return;
}
EditSession editSession = WorldEditUtils.getEditSession(event.getPlayer());
Actor actor = BukkitAdapter.adapt(event.getPlayer());
WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().handleCommandOnCurrentThread(new CommandEvent(actor, command, editSession));
editSession.flushSession();
WorldEditUtils.addToPlayer(event.getPlayer(), editSession);
} else {
Bukkit.getServer().dispatchCommand(event.getPlayer(), command); Bukkit.getServer().dispatchCommand(event.getPlayer(), command);
}
}, 1); }, 1);
} }