TestBlockPaste-Without-Water #146
@ -68,13 +68,14 @@ public class ResetCommand extends SWCommand {
|
|||||||
Region region = regionCheck(p);
|
Region region = regionCheck(p);
|
||||||
if (region == null) return;
|
if (region == null) return;
|
||||||
|
|
||||||
if (bauServer.getOwner() != p.getUniqueId()) {
|
if (!p.getUniqueId().equals(bauServer.getOwner())) {
|
||||||
if (Punishment.isPunished(SteamwarUser.get(p.getUniqueId()), Punishment.PunishmentType.NoSchemSharing, punishment -> BauSystem.MESSAGE.parse("REGION_TB_NO_SCHEMSHARING", p, punishment.getEndTime()))) {
|
if (Punishment.isPunished(SteamwarUser.get(bauServer.getOwner()), Punishment.PunishmentType.NoSchemReceiving, punishment -> BauSystem.MESSAGE.send("REGION_TB_NO_SCHEMRECEIVING", p, punishment.getEndTime()))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (Punishment.isPunished(SteamwarUser.get(bauServer.getOwner()), Punishment.PunishmentType.NoSchemReceiving, punishment -> BauSystem.MESSAGE.parse("REGION_TB_NO_SCHEMRECEIVING", p, punishment.getEndTime()))) {
|
if (Punishment.isPunished(SteamwarUser.get(p.getUniqueId()), Punishment.PunishmentType.NoSchemSharing, punishment -> BauSystem.MESSAGE.send("REGION_TB_NO_SCHEMSHARING", p, punishment.getEndTime()))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (node.isDir()) {
|
if (node.isDir()) {
|
||||||
BauSystem.MESSAGE.send("ONLY_SCHEMS", p);
|
BauSystem.MESSAGE.send("ONLY_SCHEMS", p);
|
||||||
|
@ -86,13 +86,14 @@ public class TestblockCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bauServer.getOwner() != p.getUniqueId()) {
|
if (!p.getUniqueId().equals(bauServer.getOwner())) {
|
||||||
zOnlyKroks markierte diese Unterhaltung als gelöst
Veraltet
|
|||||||
if (Punishment.isPunished(SteamwarUser.get(p.getUniqueId()), Punishment.PunishmentType.NoSchemSharing, punishment -> BauSystem.MESSAGE.parse("REGION_TB_NO_SCHEMSHARING", p, punishment.getEndTime()))) {
|
if (Punishment.isPunished(SteamwarUser.get(bauServer.getOwner()), Punishment.PunishmentType.NoSchemReceiving, punishment -> BauSystem.MESSAGE.send("REGION_TB_NO_SCHEMRECEIVING", p, punishment.getEndTime()))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (Punishment.isPunished(SteamwarUser.get(bauServer.getOwner()), Punishment.PunishmentType.NoSchemReceiving, punishment -> BauSystem.MESSAGE.parse("REGION_TB_NO_SCHEMRECEIVING", p, punishment.getEndTime()))) {
|
if (Punishment.isPunished(SteamwarUser.get(p.getUniqueId()), Punishment.PunishmentType.NoSchemSharing, punishment -> BauSystem.MESSAGE.send("REGION_TB_NO_SCHEMSHARING", p, punishment.getEndTime()))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
region.reset(node, RegionType.TESTBLOCK, regionExtensionType, ignoreAir, onlyColors, removeTNT, removeWater);
|
region.reset(node, RegionType.TESTBLOCK, regionExtensionType, ignoreAir, onlyColors, removeTNT, removeWater);
|
||||||
|
@ -20,13 +20,16 @@
|
|||||||
package de.steamwar.bausystem.features.script;
|
package de.steamwar.bausystem.features.script;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.features.script.lua.SteamWarPlatform;
|
import de.steamwar.bausystem.features.script.lua.SteamWarPlatform;
|
||||||
|
import de.steamwar.bausystem.utils.ItemUtils;
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.sql.Script;
|
import de.steamwar.sql.Script;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -39,6 +42,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class ScriptGUI implements Listener {
|
public class ScriptGUI implements Listener {
|
||||||
@ -119,7 +123,18 @@ public class ScriptGUI implements Listener {
|
|||||||
open(player);
|
open(player);
|
||||||
} else {
|
} else {
|
||||||
SWAnvilInv inv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ENTER_NAME", player), name == null ? "" : name);
|
SWAnvilInv inv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ENTER_NAME", player), name == null ? "" : name);
|
||||||
inv.setCallback(s -> saveWithName(player, meta, s));
|
AtomicBoolean saved = new AtomicBoolean(false);
|
||||||
|
ItemStack itemStack = player.getOpenInventory().getCursor();
|
||||||
|
inv.setCallback(s -> {
|
||||||
|
saveWithName(player, meta, s);
|
||||||
|
saved.set(true);
|
||||||
|
});
|
||||||
|
inv.addCloseCallback(() -> {
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
|
if (saved.get()) return;
|
||||||
|
SWUtils.giveItemToPlayer(player, itemStack);
|
||||||
|
}, 1);
|
||||||
|
});
|
||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,10 @@ import de.steamwar.linkage.Linked;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.luaj.vm2.LuaTable;
|
import org.luaj.vm2.LuaTable;
|
||||||
import org.luaj.vm2.LuaValue;
|
import org.luaj.vm2.LuaValue;
|
||||||
|
import org.luaj.vm2.Varargs;
|
||||||
import org.luaj.vm2.lib.OneArgFunction;
|
import org.luaj.vm2.lib.OneArgFunction;
|
||||||
import org.luaj.vm2.lib.TwoArgFunction;
|
import org.luaj.vm2.lib.TwoArgFunction;
|
||||||
|
import org.luaj.vm2.lib.VarArgFunction;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ -49,7 +51,7 @@ public class StorageLib implements LuaLib {
|
|||||||
global.set("get", new OneArgFunction() {
|
global.set("get", new OneArgFunction() {
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue arg) {
|
public LuaValue call(LuaValue arg) {
|
||||||
return GLOBAL_STORAGE.get(arg.checkjstring());
|
return GLOBAL_STORAGE.getOrDefault(arg.checkjstring(), NIL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
global.set("set", new TwoArgFunction() {
|
global.set("set", new TwoArgFunction() {
|
||||||
@ -58,7 +60,35 @@ public class StorageLib implements LuaLib {
|
|||||||
return GLOBAL_STORAGE.put(arg1.checkjstring(), arg2);
|
return GLOBAL_STORAGE.put(arg1.checkjstring(), arg2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
global.set("has", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue arg) {
|
||||||
|
return valueOf(GLOBAL_STORAGE.containsKey(arg.checkjstring()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
global.set("remove", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue arg) {
|
||||||
|
return GLOBAL_STORAGE.remove(arg.checkjstring());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
global.set("accessor", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue arg) {
|
||||||
|
String key = arg.checkjstring();
|
||||||
|
return new VarArgFunction() {
|
||||||
|
@Override
|
||||||
|
public Varargs invoke(Varargs args) {
|
||||||
|
if (args.narg() == 0) {
|
||||||
|
return GLOBAL_STORAGE.getOrDefault(key, NIL);
|
||||||
|
} else {
|
||||||
|
GLOBAL_STORAGE.put(key, args.arg(1));
|
||||||
|
return NIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
storageLib.set("global", global);
|
storageLib.set("global", global);
|
||||||
|
|
||||||
LuaTable playerStorage = new LuaTable();
|
LuaTable playerStorage = new LuaTable();
|
||||||
@ -66,7 +96,7 @@ public class StorageLib implements LuaLib {
|
|||||||
playerStorage.set("get", new OneArgFunction() {
|
playerStorage.set("get", new OneArgFunction() {
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue arg) {
|
public LuaValue call(LuaValue arg) {
|
||||||
return playerStorageMap.get(arg.checkjstring());
|
return playerStorageMap.getOrDefault(arg.checkjstring(), NIL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
playerStorage.set("set", new TwoArgFunction() {
|
playerStorage.set("set", new TwoArgFunction() {
|
||||||
@ -75,6 +105,35 @@ public class StorageLib implements LuaLib {
|
|||||||
return playerStorageMap.put(arg1.checkjstring(), arg2);
|
return playerStorageMap.put(arg1.checkjstring(), arg2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
playerStorage.set("has", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue arg) {
|
||||||
|
return valueOf(playerStorageMap.containsKey(arg.checkjstring()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
playerStorage.set("remove", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue arg) {
|
||||||
|
return playerStorageMap.remove(arg.checkjstring());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
playerStorage.set("accessor", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue arg) {
|
||||||
|
String key = arg.checkjstring();
|
||||||
|
return new VarArgFunction() {
|
||||||
|
@Override
|
||||||
|
public Varargs invoke(Varargs args) {
|
||||||
|
if (args.narg() == 0) {
|
||||||
|
return playerStorageMap.getOrDefault(key, NIL);
|
||||||
|
} else {
|
||||||
|
playerStorageMap.put(key, args.arg(1));
|
||||||
|
return NIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
storageLib.set("player", playerStorage);
|
storageLib.set("player", playerStorage);
|
||||||
|
|
||||||
LuaTable regionStorage = new LuaTable();
|
LuaTable regionStorage = new LuaTable();
|
||||||
@ -82,7 +141,7 @@ public class StorageLib implements LuaLib {
|
|||||||
regionStorage.set("get", new OneArgFunction() {
|
regionStorage.set("get", new OneArgFunction() {
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue arg) {
|
public LuaValue call(LuaValue arg) {
|
||||||
return regionStorageMap.get(arg.checkjstring());
|
return regionStorageMap.getOrDefault(arg.checkjstring(), NIL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
regionStorage.set("set", new TwoArgFunction() {
|
regionStorage.set("set", new TwoArgFunction() {
|
||||||
@ -91,6 +150,35 @@ public class StorageLib implements LuaLib {
|
|||||||
return regionStorageMap.put(arg1.checkjstring(), arg2);
|
return regionStorageMap.put(arg1.checkjstring(), arg2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
regionStorage.set("has", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue arg) {
|
||||||
|
return valueOf(regionStorageMap.containsKey(arg.checkjstring()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
regionStorage.set("remove", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue arg) {
|
||||||
|
return regionStorageMap.remove(arg.checkjstring());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
regionStorage.set("accessor", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue arg) {
|
||||||
|
String key = arg.checkjstring();
|
||||||
|
return new VarArgFunction() {
|
||||||
|
@Override
|
||||||
|
public Varargs invoke(Varargs args) {
|
||||||
|
if (args.narg() == 0) {
|
||||||
|
return regionStorageMap.getOrDefault(key, NIL);
|
||||||
|
} else {
|
||||||
|
regionStorageMap.put(key, args.arg(1));
|
||||||
|
return NIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
storageLib.set("region", regionStorage);
|
storageLib.set("region", regionStorage);
|
||||||
|
|
||||||
return storageLib;
|
return storageLib;
|
||||||
|
14
SCRIPT.md
14
SCRIPT.md
@ -207,9 +207,21 @@ Es gibt folgende Module:
|
|||||||
Alle Module haben folgende Funktionen:
|
Alle Module haben folgende Funktionen:
|
||||||
|
|
||||||
| Name | Signature | Beschreibung |
|
| Name | Signature | Beschreibung |
|
||||||
|-----------|--------------------|------------------------------------------------------------------------------------------------------------|
|
|------------|----------------------------|--------------------------------------------------------|
|
||||||
| `get` | get(String): Any | Gibt den Wert des Schlüssels zurück |
|
| `get` | get(String): Any | Gibt den Wert des Schlüssels zurück |
|
||||||
| `set` | set(String, Any) | Setzt den Wert des Schlüssels auf den angegebenen Wert |
|
| `set` | set(String, Any) | Setzt den Wert des Schlüssels auf den angegebenen Wert |
|
||||||
|
| `has` | has(String): Boolean | Prüft ob ein Wert vorhanden ist |
|
||||||
|
| `remove` | remove(String) | Löscht den Schlüssel |
|
||||||
|
| `accessor` | accessor(String): Accessor | Gibt einen Accessor zurück |
|
||||||
|
|
||||||
|
Ein Accessor ist ein Objekt, womit du direkt auf einen Wert zugreifen kannst und es ändern kannst.
|
||||||
|
Es geht wie folgt:
|
||||||
|
```lua
|
||||||
|
keyAccessor = storage.player.accessor("key")
|
||||||
|
|
||||||
|
keyAccessor("Hello World") -- Setzt den Wert auf "Hello World"
|
||||||
|
print(keyAccessor()) -- Gibt den Wert zurück
|
||||||
|
```
|
||||||
|
|
||||||
## inventory
|
## inventory
|
||||||
Das `inventory`-Modul stellt Funktionen zur Verfügung, um ein Inventar zu öffnen.
|
Das `inventory`-Modul stellt Funktionen zur Verfügung, um ein Inventar zu öffnen.
|
||||||
|
16
sw.def.lua
16
sw.def.lua
@ -255,6 +255,22 @@ function storageLib.get(key) return nil end
|
|||||||
---@return void
|
---@return void
|
||||||
function storageLib.set(key, value) end
|
function storageLib.set(key, value) end
|
||||||
|
|
||||||
|
---@param key string
|
||||||
|
---@return boolean
|
||||||
|
function storageLib.has(key) return nil end
|
||||||
|
|
||||||
|
---@param key string
|
||||||
|
---@return void
|
||||||
|
function storageLib.remove(key) end
|
||||||
|
|
||||||
|
---@param key string
|
||||||
|
---@return Accessor
|
||||||
|
function storageLib.accessor(key) return nil end
|
||||||
|
|
||||||
|
---@class Accessor
|
||||||
|
---@overload fun(): any
|
||||||
|
---@overload fun(value: any)
|
||||||
|
|
||||||
---@class Selection
|
---@class Selection
|
||||||
---@field max Position
|
---@field max Position
|
||||||
---@field min Position
|
---@field min Position
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Siehe oben