2019-08-06 20:26:04 +02:00
|
|
|
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.hasPermission(player, Permission.world)){
|
|
|
|
player.sendMessage(BauSystem.PREFIX + "§cDu darfst diese Welt nicht einfrieren");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(frozen){
|
|
|
|
HandlerList.unregisterAll(this);
|
2019-08-06 20:49:49 +02:00
|
|
|
Bukkit.broadcastMessage(BauSystem.PREFIX + "§aDie Welt wurde aufgetaut");
|
2019-08-06 20:26:04 +02:00
|
|
|
}else{
|
|
|
|
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
2019-08-06 20:49:49 +02:00
|
|
|
Bukkit.broadcastMessage(BauSystem.PREFIX + "§cDie Welt wurde eingefroren");
|
2019-08-06 20:26:04 +02:00
|
|
|
}
|
|
|
|
frozen = !frozen;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void onPhysicsEvent(BlockPhysicsEvent e){
|
|
|
|
e.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|