Archiviert
13
0

Fix FreezeListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2024-05-16 17:02:45 +02:00
Ursprung 21424c0251
Commit 6d170be583

Datei anzeigen

@ -21,6 +21,9 @@ package de.steamwar.teamserver.listener;
import de.steamwar.core.Core;
import de.steamwar.teamserver.Builder;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -39,11 +42,18 @@ public class FreezeListener implements Listener {
public static boolean freeze = true;
public FreezeListener() {
Bukkit.getScheduler().runTaskTimer(Builder.getInstance(), () -> {
if (!freeze) return;
Bukkit.getOnlinePlayers().forEach(player -> {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§cWorld frozen"));
});
}, 1, 1);
}
@EventHandler
public void onEntitySpawn(EntitySpawnEvent e) {
if (!freeze) {
return;
}
if (!freeze) return;
e.setCancelled(true);
if (e.getEntityType() == EntityType.PRIMED_TNT) {
Bukkit.getScheduler().runTaskLater(Builder.getInstance(), () -> {
@ -55,8 +65,7 @@ public class FreezeListener implements Listener {
@EventHandler
public void onBlockCanBuild(BlockCanBuildEvent e) {
if (!e.isBuildable()) return;
if (!freeze)
return;
if (freeze) return;
if (e.getMaterial() == Material.TNT) {
e.setBuildable(false);
e.getBlock().setType(Material.TNT, false);
@ -114,7 +123,9 @@ public class FreezeListener implements Listener {
@EventHandler
public void onInventoryMoveEvent(InventoryMoveItemEvent e) {
if (freeze) {
if (e.getDestination().getLocation() != null && freeze) {
e.setCancelled(true);
} else if (e.getSource().getLocation() != null && freeze) {
e.setCancelled(true);
}
}
@ -135,7 +146,7 @@ public class FreezeListener implements Listener {
public void onBlockPlace(BlockPlaceEvent e) {
if (Core.getVersion() < 19) return;
if (!e.getItemInHand().getType().isBlock()) return;
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
if (freeze) {
e.setCancelled(true);
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
e.getBlock().setType(e.getItemInHand().getType(), false);