SteamWar/BauSystem2.0
Archiviert
12
0

Fixing...
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Signed-off-by: Chaoscaot <chaoscaot@zohomail.eu>
Dieser Commit ist enthalten in:
Chaoscaot 2023-06-07 21:46:38 +02:00
Ursprung 29851ca4ca
Commit 5a09ece591
3 geänderte Dateien mit 34 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.script.event;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptRunner;
import de.steamwar.bausystem.features.script.lua.SteamWarGlobalLuaPlugin;
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
@ -53,9 +54,9 @@ public class EventListener implements Listener {
private static final Map<Player, Long> LAST_FS = new HashMap<>();
{
static {
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
LAST_FS.entrySet().removeIf(entry -> System.currentTimeMillis() - entry.getValue() > 200);
LAST_FS.entrySet().removeIf(entry -> TPSUtils.currentTick.get() - entry.getValue() > 4);
}, 2, 2);
}
@ -64,21 +65,21 @@ public class EventListener implements Listener {
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfJoin, LuaValue.NIL);
}
@EventHandler
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerQuit(PlayerQuitEvent event) {
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfLeave, LuaValue.NIL);
}
@EventHandler
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
if (LAST_FS.containsKey(event.getPlayer())) {
event.setCancelled(ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.DoubleSwap, LuaValue.NIL));
} else {
LAST_FS.put(event.getPlayer(), System.currentTimeMillis());
LAST_FS.put(event.getPlayer(), TPSUtils.currentTick.get());
}
}
@EventHandler
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event) {
LuaTable table = new LuaTable();
table.set("x", event.getBlock().getX());
@ -88,7 +89,7 @@ public class EventListener implements Listener {
event.setCancelled(ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.PlaceBlock, table));
}
@EventHandler
@EventHandler(priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event) {
LuaTable table = new LuaTable();
table.set("x", event.getBlock().getX());
@ -100,7 +101,7 @@ public class EventListener implements Listener {
private final Set<Player> ignore = new HashSet<>();
@EventHandler
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
if (ignore.remove(event.getPlayer())) {
return;
@ -126,7 +127,7 @@ public class EventListener implements Listener {
}
}
@EventHandler
@EventHandler(priority = EventPriority.HIGH)
public void onEntitySpawn(EntitySpawnEvent event) {
if (event.getEntityType() != EntityType.PRIMED_TNT) {
return;
@ -140,7 +141,7 @@ public class EventListener implements Listener {
}
}
@EventHandler
@EventHandler(priority = EventPriority.HIGH)
public void onEntityExplode(EntityExplodeEvent event) {
if (event.getEntityType() != EntityType.PRIMED_TNT) {
return;
@ -165,7 +166,7 @@ public class EventListener implements Listener {
event.setCancelled(cancel);
}
@EventHandler
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerDropItem(PlayerDropItemEvent event) {
ignore.add(event.getPlayer());
LuaTable table = new LuaTable();
@ -173,7 +174,7 @@ public class EventListener implements Listener {
event.setCancelled(ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.DropItem, table));
}
@EventHandler
@EventHandler(priority = EventPriority.HIGH)
public void onEntityDeath(EntityDeathEvent event) {
for (Player player : Bukkit.getOnlinePlayers()) {
LuaTable table = new LuaTable();

Datei anzeigen

@ -41,17 +41,17 @@ public class PlayerLib implements LuaLib {
table.set("chat", new Print(player));
table.set("actionbar", new SendActionbar(player));
table.set("x", getterAndSetter(player.getLocation()::getX, player.getLocation()::setX));
table.set("y", getterAndSetter(player.getLocation()::getY, player.getLocation()::setY));
table.set("z", getterAndSetter(player.getLocation()::getZ, player.getLocation()::setZ));
table.set("yaw", getterAndSetter(player.getLocation()::getYaw, player.getLocation()::setYaw));
table.set("pitch", getterAndSetter(player.getLocation()::getPitch, player.getLocation()::setPitch));
table.set("x", getterAndSetter(() -> player.getLocation().getX(), player.getLocation()::setX));
table.set("y", getterAndSetter(() -> player.getLocation().getY(), player.getLocation()::setY));
table.set("z", getterAndSetter(() -> player.getLocation().getZ(), player.getLocation()::setZ));
table.set("yaw", getterAndSetter(() -> player.getLocation().getYaw(), player.getLocation()::setYaw));
table.set("pitch", getterAndSetter(() -> player.getLocation().getPitch(), player.getLocation()::setPitch));
table.set("sneaking", getter(player::isSneaking));
table.set("sprinting", getter(player::isSprinting));
table.set("slot", getterAndSetter(player.getInventory()::getHeldItemSlot, player.getInventory()::setHeldItemSlot));
table.set("item", getter(player.getInventory().getItemInMainHand().getType()::name));
table.set("offHandItem", getter(player.getInventory().getItemInOffHand().getType()::name));
table.set("slot", getterAndSetter(() -> player.getInventory().getHeldItemSlot(), player.getInventory()::setHeldItemSlot));
table.set("item", getter(() -> player.getInventory().getItemInMainHand().getType().name()));
table.set("offHandItem", getter(() -> player.getInventory().getItemInOffHand().getType().name()));
return table;
}

Datei anzeigen

@ -18,6 +18,8 @@
* [BlockEvent](#blockevent)
* [InteractEvent](#interactevent)
* [Position](#position)
* [Instabile APIs](#instabile-apis)
* [_worldedit](#worldedit)
* [Beispiele](#beispiele)
* [Hello, World!](#hello-world)
* [Code](#code)
@ -173,7 +175,7 @@ Es gibt folgende Variablen:
| Name | Beschreibung |
|----------|----------------------------------|
| `events` | Siehe: [Event Type](#event-type) |
| `events` | Siehe: [Event Type](#eventtypen) |
## Hotkeys
@ -242,6 +244,16 @@ Die Position ist ein Objekt mit folgenden Variablen:
| `y` | Die Y-Koordinate |
| `z` | Die Z-Koordinate |
# Instabile APIs
Hier sind einige APIs aufgelistet, die nicht stabil sind und sich jederzeit ändern können.
## _worldedit
| Name | Signatur | Beschreibung |
|-------------|-----------------------------------------------------------|-----------------------------------|
| `selection` | selection(Liste\<Pos>), selection(): {min: Pos, max: Pos} | Die aktuelle auswahl des Spielers |
# Beispiele