package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Welt; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPhysicsEvent; public class CommandFreeze implements CommandExecutor, Listener { private boolean frozen = false; @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(!(sender instanceof Player)) return false; Player player = (Player) sender; if (Welt.noPermission(player, Permission.world)){ player.sendMessage(BauSystem.PREFIX + "§cDu darfst diese Welt nicht einfrieren"); return false; } if(frozen){ HandlerList.unregisterAll(this); Bukkit.broadcastMessage(BauSystem.PREFIX + "§aDie Welt wurde aufgetaut"); }else{ Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); Bukkit.broadcastMessage(BauSystem.PREFIX + "§cDie Welt wurde eingefroren"); } frozen = !frozen; return false; } @EventHandler public void onPhysicsEvent(BlockPhysicsEvent e){ e.setCancelled(true); } }