From bdd437eebdc25a9e1c6826e51ebba9458081d6ee Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 28 Jul 2023 14:57:32 +0200 Subject: [PATCH] Add Inventory notice and fix region.get Signed-off-by: Chaoscaot --- BauSystem_Main/src/BauSystem.properties | 1 + BauSystem_Main/src/BauSystem_de.properties | 1 + .../script/lua/libs/InventoryLib.java | 1 + .../features/script/lua/libs/RegionLib.java | 24 +++++++++---------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index acfe8f78..4e82a448 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -250,6 +250,7 @@ SCRIPT_MENU_GUI_ITEM_ADD_NAME = §eInsert SCRIPT_MENU_GUI_ITEM_ADD_LORE = §7Click with a book to insert SCRIPT_MENU_GUI_ENTER_NAME = §eEnter a name +SCRIPT_DEPRECATED=§cThe function §8'§e{0}§8'§c is depricated and will be removed in the future. Please use §8'§e{1}§8'§c instead. # Shield Printing SHIELD_PRINTING_HELP_START = §8/§eshieldprinting start §8- §7Starts the shield printing diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index df48d2e6..cb1184a8 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -240,6 +240,7 @@ SCRIPT_MENU_GUI_ITEM_LORE_4 = §7Mittelklick zum anschauen SCRIPT_MENU_GUI_NAME = §eSkript-Menü SCRIPT_MENU_GUI_ITEM_ADD_NAME = §eHinzufügen SCRIPT_MENU_GUI_ITEM_ADD_LORE = §7Klicke mit einem Buch zum hinzufügen +SCRIPT_DEPRECATED=§cDie Funktion §e{0}§c ist veraltet und wird demnächst entfernt. Bitte benutze §e{1}§c. # Shield Printing SHIELD_PRINTING_HELP_START = §8/§eshieldprinting start §8- §7Starte das Schild drucken diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/InventoryLib.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/InventoryLib.java index 685ea98a..1d14b305 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/InventoryLib.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/InventoryLib.java @@ -59,6 +59,7 @@ public class InventoryLib implements LuaLib { table.set("setItem", new VarArgFunction() { @Override public Varargs invoke(Varargs args) { + BauSystem.MESSAGE.send("SCRIPT_DEPRECATED", player, "inventory.setItem", "inventory.item"); int slot = args.checkint(1); Material material = SWItem.getMaterial(args.checkjstring(2)); String name = ChatColor.translateAlternateColorCodes('&', args.checkjstring(3)); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java index 240ec061..f0fc72ad 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java @@ -47,25 +47,25 @@ public class RegionLib implements LuaLib { private LuaTable create(Region region, Player player) { LuaTable table = LuaValue.tableOf(); - table.set("name", getter(() -> Region.getRegion(player.getLocation()).getName())); - table.set("type", getter(() -> Region.getRegion(player.getLocation()).getPrototype().getName())); + table.set("name", getter(() -> region.getName())); + table.set("type", getter(() -> region.getPrototype().getName())); LuaValue tntLib = LuaValue.tableOf(); - tntLib.set("mode", getter(() -> Region.getRegion(player.getLocation()).getPlain(Flag.TNT, TNTMode.class).name())); - tntLib.set("enabled", getter(() -> Region.getRegion(player.getLocation()).getPlain(Flag.TNT, TNTMode.class) != TNTMode.DENY)); - tntLib.set("onlyTb", getter(() -> Region.getRegion(player.getLocation()).getPlain(Flag.TNT, TNTMode.class) == TNTMode.ONLY_TB)); + tntLib.set("mode", getter(() -> region.getPlain(Flag.TNT, TNTMode.class).name())); + tntLib.set("enabled", getter(() -> region.getPlain(Flag.TNT, TNTMode.class) != TNTMode.DENY)); + tntLib.set("onlyTb", getter(() -> region.getPlain(Flag.TNT, TNTMode.class) == TNTMode.ONLY_TB)); table.set("tnt", tntLib); - table.set("fire", getter(() -> Region.getRegion(player.getLocation()).getPlain(Flag.FIRE, FireMode.class) == FireMode.ALLOW)); - table.set("freeze", getter(() -> Region.getRegion(player.getLocation()).getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE)); - table.set("protect", getter(() -> Region.getRegion(player.getLocation()).getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.ACTIVE)); + table.set("fire", getter(() -> region.getPlain(Flag.FIRE, FireMode.class) == FireMode.ALLOW)); + table.set("freeze", getter(() -> region.getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE)); + table.set("protect", getter(() -> region.getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.ACTIVE)); LuaValue traceLib = LuaValue.tableOf(); - traceLib.set("active", getter(() -> !Region.getRegion(player.getLocation()).isGlobal() && Recorder.INSTANCE.get(Region.getRegion(player.getLocation())) instanceof ActiveTracer)); - traceLib.set("auto", getter(() -> !Region.getRegion(player.getLocation()).isGlobal() && Recorder.INSTANCE.get(Region.getRegion(player.getLocation())) instanceof AutoTraceRecorder)); - traceLib.set("status", getter(() -> Recorder.INSTANCE.get(Region.getRegion(player.getLocation())).scriptState())); - traceLib.set("time", getter(() -> Recorder.INSTANCE.get(Region.getRegion(player.getLocation())).scriptTime())); + traceLib.set("active", getter(() -> !region.isGlobal() && Recorder.INSTANCE.get(region) instanceof ActiveTracer)); + traceLib.set("auto", getter(() -> !region.isGlobal() && Recorder.INSTANCE.get(region) instanceof AutoTraceRecorder)); + traceLib.set("status", getter(() -> Recorder.INSTANCE.get(region).scriptState())); + traceLib.set("time", getter(() -> Recorder.INSTANCE.get(region).scriptTime())); table.set("trace", traceLib);