Fix FAWE exec()
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
d606c01bdf
Commit
e7a80981bb
@ -19,13 +19,21 @@
|
||||
|
||||
package de.steamwar.bausystem.features.script.lua;
|
||||
|
||||
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.features.script.lua.libs.LuaLib;
|
||||
import de.steamwar.bausystem.features.world.WorldEditListener;
|
||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.luaj.vm2.LuaFunction;
|
||||
import org.luaj.vm2.LuaTable;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
@ -36,9 +44,12 @@ import org.luaj.vm2.lib.TwoArgFunction;
|
||||
import org.luaj.vm2.lib.VarArgFunction;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SteamWarLuaPlugin extends TwoArgFunction {
|
||||
|
||||
private static final boolean hasFAWE = Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit") != null;
|
||||
|
||||
protected static final Map<Class<?>, List<LuaLib>> LUA_LIBS = new HashMap<>();
|
||||
|
||||
public static void add(LuaLib luaLib) {
|
||||
@ -103,8 +114,24 @@ public class SteamWarLuaPlugin extends TwoArgFunction {
|
||||
env.set("exec", new VarArgFunction() {
|
||||
@Override
|
||||
public Varargs invoke(Varargs args) {
|
||||
player.performCommand(varArgsToString(args));
|
||||
String command = varArgsToString(args);
|
||||
PlayerCommandPreprocessEvent preprocessEvent = new PlayerCommandPreprocessEvent(player, "/" + command);
|
||||
Bukkit.getServer().getPluginManager().callEvent(preprocessEvent);
|
||||
if (preprocessEvent.isCancelled()) {
|
||||
return LuaValue.NIL;
|
||||
}
|
||||
|
||||
Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command);
|
||||
String[] commandSplit = command.split(" ");
|
||||
if (!commandSplit[0].equals("select") && hasFAWE && WorldEditListener.isWorldEditCommand("/" + commandSplit[0])) {
|
||||
EditSession editSession = WorldEditUtils.getEditSession(player);
|
||||
Actor actor = BukkitAdapter.adapt(player);
|
||||
WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().handleCommandOnCurrentThread(new CommandEvent(actor, command, editSession));
|
||||
editSession.flushSession();
|
||||
WorldEditUtils.addToPlayer(player, editSession);
|
||||
} else {
|
||||
Bukkit.getServer().dispatchCommand(player, command);
|
||||
}
|
||||
return LuaValue.NIL;
|
||||
}
|
||||
});
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren