Merge branch 'master' into TestBlockPaste-Without-Water
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Commit
eec5e97842
@ -250,7 +250,7 @@ SCRIPT_MENU_GUI_ITEM_ADD_NAME = §eInsert
|
|||||||
SCRIPT_MENU_GUI_ITEM_ADD_LORE = §7Click with a book to insert
|
SCRIPT_MENU_GUI_ITEM_ADD_LORE = §7Click with a book to insert
|
||||||
|
|
||||||
SCRIPT_MENU_GUI_ENTER_NAME = §eEnter a name
|
SCRIPT_MENU_GUI_ENTER_NAME = §eEnter a name
|
||||||
SCRIPT_DEPRECATED=§cThe function §8'§e{0}§8'§c is deprecated and will be removed in the future. Please use §8'§e{1}§8'§c instead.
|
SCRIPT_DEPRECATED=§cThe function §8\'§e{0}§8\'§c is deprecated and will be removed in the future. Please use §8\'§e{1}§8\'§c instead.
|
||||||
|
|
||||||
# Shield Printing
|
# Shield Printing
|
||||||
SHIELD_PRINTING_HELP_START = §8/§eshieldprinting start §8- §7Starts the shield printing
|
SHIELD_PRINTING_HELP_START = §8/§eshieldprinting start §8- §7Starts the shield printing
|
||||||
|
@ -50,13 +50,7 @@ public class ScriptRunner {
|
|||||||
|
|
||||||
public static void runScript(String script, Player player) {
|
public static void runScript(String script, Player player) {
|
||||||
Globals globals = SteamWarPlatform.createClickGlobals(player);
|
Globals globals = SteamWarPlatform.createClickGlobals(player);
|
||||||
|
catchScript("SCRIPT_ERROR_CLICK", player, () -> globals.load(script).call());
|
||||||
try {
|
|
||||||
globals.load(script).call();
|
|
||||||
} catch (Exception e) {
|
|
||||||
String[] sp = e.getMessage().split(":");
|
|
||||||
BauSystem.MESSAGE.send("SCRIPT_ERROR_CLICK", player, String.join(":", Arrays.copyOfRange(sp, 1, sp.length)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateGlobalScript(Player player) {
|
public static void updateGlobalScript(Player player) {
|
||||||
@ -72,12 +66,7 @@ public class ScriptRunner {
|
|||||||
commandRegister -> COMMAND_MAP.computeIfAbsent(player, player1 -> new HashMap<>()).put(commandRegister.getName(), commandRegister));
|
commandRegister -> COMMAND_MAP.computeIfAbsent(player, player1 -> new HashMap<>()).put(commandRegister.getName(), commandRegister));
|
||||||
|
|
||||||
for (String script : scripts) {
|
for (String script : scripts) {
|
||||||
try {
|
catchScript("SCRIPT_ERROR_GLOBAL", player, () -> globals.load(script).call());
|
||||||
globals.load(script).call();
|
|
||||||
} catch (Exception e) {
|
|
||||||
String[] sp = e.getMessage().split(":");
|
|
||||||
BauSystem.MESSAGE.send("SCRIPT_ERROR_GLOBAL", player, String.join(":", Arrays.copyOfRange(sp, 1, sp.length)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,13 +108,10 @@ public class ScriptRunner {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final LuaValue finalEventValue = eventValue;
|
||||||
|
|
||||||
for (LuaFunction luaFunction : luaFunctions) {
|
for (LuaFunction luaFunction : luaFunctions) {
|
||||||
try {
|
catchScript("SCRIPT_ERROR_GLOBAL", player, () -> luaFunction.call(finalEventValue));
|
||||||
luaFunction.call(eventValue);
|
|
||||||
} catch (Exception e) {
|
|
||||||
String[] sp = e.getMessage().split(":");
|
|
||||||
BauSystem.MESSAGE.send("SCRIPT_ERROR_GLOBAL", player, String.join(":", Arrays.copyOfRange(sp, 1, sp.length)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wrappedEvent instanceof Cancellable) {
|
if (wrappedEvent instanceof Cancellable) {
|
||||||
@ -192,22 +178,30 @@ public class ScriptRunner {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
catchScript("SCRIPT_ERROR_GLOBAL", player, () -> commandRegister.getFunction().call(args));
|
||||||
commandRegister.getFunction().call(args);
|
|
||||||
} catch (Exception e) {
|
|
||||||
String[] sp = e.getMessage().split(":");
|
|
||||||
BauSystem.MESSAGE.send("SCRIPT_ERROR_GLOBAL", player, String.join(":", Arrays.copyOfRange(sp, 1, sp.length)));
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void callHotkey(int mods, int key, Player player, boolean pressed) {
|
public static void callHotkey(int mods, int key, Player player, boolean pressed) {
|
||||||
Hotkey hotkey = Hotkey.fromChar(key, mods);
|
Hotkey hotkey = Hotkey.fromChar(key, mods);
|
||||||
|
catchScript("SCRIPT_ERROR_GLOBAL", player, () -> HOTKEY_MAP.getOrDefault(player, Collections.emptyMap()).getOrDefault(hotkey, Collections.emptyList()).forEach(luaFunction -> luaFunction.call(LuaValue.valueOf(pressed))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void catchScript(String errorMsg, Player player, Runnable run) {
|
||||||
try {
|
try {
|
||||||
HOTKEY_MAP.getOrDefault(player, Collections.emptyMap()).getOrDefault(hotkey, Collections.emptyList()).forEach(luaFunction -> luaFunction.call(LuaValue.valueOf(pressed)));
|
run.run();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String[] sp = e.getMessage().split(":");
|
String[] sp = e.getMessage().split(":");
|
||||||
BauSystem.MESSAGE.send("SCRIPT_ERROR_GLOBAL", player, String.join(":", Arrays.copyOfRange(sp, 1, sp.length)));
|
int index = 0;
|
||||||
|
for (int i = sp.length - 1; i >= 0; i--) {
|
||||||
|
String[] ss = sp[i].split(" ");
|
||||||
|
boolean num = ss[0].chars().mapToObj(Character::isDigit).allMatch(b -> b);
|
||||||
|
if (num && !ss[0].isEmpty()) {
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BauSystem.MESSAGE.send(errorMsg, player, String.join(":", Arrays.copyOfRange(sp, index, sp.length)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
|||||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.features.script.ScriptRunner;
|
||||||
import de.steamwar.bausystem.features.script.lua.libs.LuaLib;
|
import de.steamwar.bausystem.features.script.lua.libs.LuaLib;
|
||||||
import de.steamwar.bausystem.features.world.WorldEditListener;
|
import de.steamwar.bausystem.features.world.WorldEditListener;
|
||||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||||
@ -79,7 +80,7 @@ public class SteamWarLuaPlugin extends TwoArgFunction {
|
|||||||
LuaFunction callback = arg2.checkfunction();
|
LuaFunction callback = arg2.checkfunction();
|
||||||
|
|
||||||
SWAnvilInv inv = new SWAnvilInv(player, message);
|
SWAnvilInv inv = new SWAnvilInv(player, message);
|
||||||
inv.setCallback(s -> callback.call(valueOf(s)));
|
inv.setCallback(s -> ScriptRunner.catchScript("SCRIPT_ERROR_CLICK", player, () -> callback.call(valueOf(s))));
|
||||||
inv.open();
|
inv.open();
|
||||||
|
|
||||||
return LuaValue.NIL;
|
return LuaValue.NIL;
|
||||||
@ -91,7 +92,7 @@ public class SteamWarLuaPlugin extends TwoArgFunction {
|
|||||||
long time = arg1.checklong();
|
long time = arg1.checklong();
|
||||||
LuaFunction callback = arg2.checkfunction();
|
LuaFunction callback = arg2.checkfunction();
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> callback.call(), time);
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> ScriptRunner.catchScript("SCRIPT_ERROR_CLICK", player, callback::call), time);
|
||||||
return LuaValue.NIL;
|
return LuaValue.NIL;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren