diff --git a/src/de/steamwar/bausystem/BauSystem.java b/src/de/steamwar/bausystem/BauSystem.java index d7cf605..74343cb 100644 --- a/src/de/steamwar/bausystem/BauSystem.java +++ b/src/de/steamwar/bausystem/BauSystem.java @@ -77,6 +77,7 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("bauinfo").setExecutor(new CommandInfo()); getCommand("protect").setExecutor(new CommandProtect()); getCommand("skull").setExecutor(new CommandSkull()); + getCommand("freeze").setExecutor(new CommandFreeze()); Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(new RegionListener(), this); diff --git a/src/de/steamwar/bausystem/commands/CommandFreeze.java b/src/de/steamwar/bausystem/commands/CommandFreeze.java new file mode 100644 index 0000000..95ddec3 --- /dev/null +++ b/src/de/steamwar/bausystem/commands/CommandFreeze.java @@ -0,0 +1,46 @@ +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); + Bukkit.broadcastMessage(BauSystem.PREFIX + "§cDie Welt wurde eingefroren"); + }else{ + Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); + Bukkit.broadcastMessage(BauSystem.PREFIX + "§aDie Welt wurde aufgetaut"); + } + frozen = !frozen; + return false; + } + + @EventHandler + public void onPhysicsEvent(BlockPhysicsEvent e){ + e.setCancelled(true); + } +} diff --git a/src/plugin.yml b/src/plugin.yml index a5cf254..729b54f 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -15,5 +15,6 @@ commands: bauinfo: speed: skull: + freeze: nightvision: aliases: nv \ No newline at end of file