Script System Lua #178
@ -113,6 +113,6 @@ public class ScriptRunner {
|
|||||||
|
|
||||||
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);
|
||||||
HOTKEY_MAP.get(player).getOrDefault(hotkey, Collections.emptyList()).forEach(luaFunction -> luaFunction.call(LuaValue.valueOf(pressed)));
|
HOTKEY_MAP.getOrDefault(player, Collections.emptyMap()).getOrDefault(hotkey, Collections.emptyList()).forEach(luaFunction -> luaFunction.call(LuaValue.valueOf(pressed)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,13 @@ package de.steamwar.bausystem.features.script.event;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.script.ScriptRunner;
|
import de.steamwar.bausystem.features.script.ScriptRunner;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.linkage.api.Plain;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class HotkeyListener implements PluginMessageListener {
|
public class HotkeyListener implements PluginMessageListener, Plain {
|
||||||
|
|
||||||
{
|
{
|
||||||
Bukkit.getServer().getMessenger().registerIncomingPluginChannel(BauSystem.getInstance(), "sw:hotkeys", this);
|
Bukkit.getServer().getMessenger().registerIncomingPluginChannel(BauSystem.getInstance(), "sw:hotkeys", this);
|
||||||
@ -43,10 +44,10 @@ public class HotkeyListener implements PluginMessageListener {
|
|||||||
if (!(key >= 'A' && key <= 'Z' || key >= '0' && key <= '9')) return;
|
if (!(key >= 'A' && key <= 'Z' || key >= '0' && key <= '9')) return;
|
||||||
if (message.length >= 9) {
|
if (message.length >= 9) {
|
||||||
int mods = (message[5] & 0xFF) << 24 | (message[6] & 0xFF) << 16 | (message[7] & 0xFF) << 8 | (message[8] & 0xFF);
|
int mods = (message[5] & 0xFF) << 24 | (message[6] & 0xFF) << 16 | (message[7] & 0xFF) << 8 | (message[8] & 0xFF);
|
||||||
// player.sendMessage("Hotkey: " + (char) key + " " + action + " " + Long.toBinaryString(mods));
|
player.sendMessage("Hotkey: " + (char) key + " " + action + " " + Long.toBinaryString(mods));
|
||||||
ScriptRunner.callHotkey(mods, key, player, action == 1);
|
ScriptRunner.callHotkey(mods, key, player, action == 1);
|
||||||
} else {
|
} else {
|
||||||
// player.sendMessage("Hotkey: " + (char) key + " " + action);
|
player.sendMessage("Hotkey: " + (char) key + " " + action);
|
||||||
ScriptRunner.callHotkey(0, key, player, action == 1);
|
ScriptRunner.callHotkey(0, key, player, action == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,6 @@ public class SteamWarGlobalLuaPlugin extends TwoArgFunction {
|
|||||||
SelfJoin,
|
SelfJoin,
|
||||||
SelfLeave,
|
SelfLeave,
|
||||||
DropItem,
|
DropItem,
|
||||||
EntityDeath;
|
EntityDeath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
SCRIPT.md
12
SCRIPT.md
@ -162,10 +162,10 @@ Die `global`-Api stellt Funktionen zur Verfügung um auf Events, Commands und Ho
|
|||||||
Es gibt folgende Funktionen:
|
Es gibt folgende Funktionen:
|
||||||
Chaoscaot markierte diese Unterhaltung als gelöst
Veraltet
|
|||||||
|
|
||||||
| Name | Signature | Beschreibung |
|
| Name | Signature | Beschreibung |
|
||||||
Chaoscaot markierte diese Unterhaltung als gelöst
Lixfel
hat
Was unterscheidet diese Global-API von der obengenannten global-API? Absolut verwirrend, muss mindestens unbenannt werden. Was unterscheidet diese Global-API von der obengenannten global-API? Absolut verwirrend, muss mindestens unbenannt werden.
|
|||||||
|-----------|---------------------------------|---------------------------------|
|
|-----------|-----------------------------------|-----------------------------------------------------------------------------|
|
||||||
| `event` | event(EventType, Function(Any)) | Registriere einen Event Handler |
|
| `event` | event(EventType, Function(Any)) | Registriere einen Event Handler |
|
||||||
| `command` | command(String, Function(Any)) | Registriere einen Command |
|
| `command` | command(String, Function(Args)) | Registriere einen Command |
|
||||||
| `hotkey` | hotkey(String, Function(Any)) | Registriere einen Hotkey |
|
| `hotkey` | hotkey(String, Function(Boolean)) | Registriere einen Hotkey, the function gets a boolean if the key is pressed |
|
||||||
|
|
||||||
Es gibt folgende Variablen:
|
Es gibt folgende Variablen:
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ Ein einfacher Command Redefiner.
|
|||||||
|
|
||||||
#### Code
|
#### Code
|
||||||
```lua
|
```lua
|
||||||
function handler(event)
|
function handler(args)
|
||||||
exec("stoplag")
|
exec("stoplag")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -285,9 +285,11 @@ Ein Hotkey zum pasten des Clipboard-Inhalts.
|
|||||||
|
|
||||||
#### Code
|
#### Code
|
||||||
```lua
|
```lua
|
||||||
function handler(event)
|
function handler(pressed)
|
||||||
|
if pressed then
|
||||||
exec("/paste -o")
|
exec("/paste -o")
|
||||||
end
|
end
|
||||||
Chaoscaot markierte diese Unterhaltung als gelöst
Veraltet
Lixfel
hat
Pasten Pasten
|
|||||||
|
end
|
||||||
|
|
||||||
hotkey("ctrl+v", handler)
|
hotkey("ctrl+v", handler)
|
||||||
```
|
```
|
In neuem Issue referenzieren
Einen Benutzer sperren
ich glaube eher das Limit statt der Limit?