--- miscJava/minecraft-plugins/hoeruputils/src/HoerupUtils.java 2010/10/30 17:38:46 1183 +++ miscJava/minecraft-plugins/hoeruputils/src/HoerupUtils.java 2010/11/02 13:53:49 1184 @@ -1,11 +1,13 @@ import java.util.logging.*; +import java.util.*; public class HoerupUtils extends Plugin { final static Logger log = Logger.getLogger("HoerupUtils"); - private boolean adminDestroy = false; + //private boolean adminDestroy = false; + private Set adminDestroyers = new HashSet(); private void registerCommands() { etc e = etc.getInstance(); @@ -41,15 +43,17 @@ registerCommands(); } + final static int HAND_EMPTY = -1; + public class AdminDestroy extends PluginListener { public boolean onBlockDestroy(Player player, Block block) { - if (adminDestroy == true && player.isAdmin() ) { - - block.setType(0); - etc.getServer().setBlock(block); - - return true; + if (player.isAdmin() && adminDestroyers.contains(player.getName() ) ) { + if (player.getItemInHand() == HAND_EMPTY) { + block.setType(0); + etc.getServer().setBlock(block); + return true; + } } return false; } @@ -97,14 +101,24 @@ return (srv.getBlockIdAt(x,y,z) == BLOCK_AIR && srv.getBlockIdAt(x,y+1,z) == BLOCK_AIR); } + + + public void adminDestroy(Player player, String[] split) { + String name = player.getName(); + if (adminDestroyers.contains(name) ) { + adminDestroyers.remove(name); + player.sendMessage("Admindestroy disabled"); + } else { + adminDestroyers.add(name); + player.sendMessage("Admindestroy enabled"); + } + } @Override public boolean onCommand(Player player, java.lang.String[] split) { if ( split[0].equals("/admindestroy") && player.canUseCommand("/admindestroy") ) { - adminDestroy = !adminDestroy; - player.sendMessage("Admindestroy enabled=" + adminDestroy); - + adminDestroy(player,split); return true; } else if( split[0].equals("/setpos") && player.canUseCommand("/setpos") ) { setPos(player, split);