SteamWar/BauSystem2.0
Archiviert
12
0

Add lever toggleability in frozen region
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-08-08 20:24:10 +02:00
Ursprung 2edc08943a
Commit 32ab629a81

Datei anzeigen

@ -9,6 +9,8 @@ import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
import de.steamwar.core.Core;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.type.Switch;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -16,6 +18,7 @@ import org.bukkit.event.block.*;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
@Linked(LinkageType.LISTENER)
public class FreezeListener implements Listener {
@ -158,4 +161,17 @@ public class FreezeListener implements Listener {
e.setCancelled(true);
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if (Region.getRegion(e.getClickedBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
Block block = e.getClickedBlock();
if (block.getType() == Material.LEVER) {
Switch data = ((Switch) block.getBlockData());
data.setPowered(!data.isPowered());
block.setBlockData(data, false);
}
}
}
}