/[projects]/miscJava/minecraft-plugins/hoeruputils/src/HoerupUtils.java
ViewVC logotype

Diff of /miscJava/minecraft-plugins/hoeruputils/src/HoerupUtils.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1183 by torben, Sat Oct 30 17:38:46 2010 UTC revision 1184 by torben, Tue Nov 2 13:53:49 2010 UTC
# Line 1  Line 1 
1    
2  import java.util.logging.*;  import java.util.logging.*;
3    import java.util.*;
4    
5  public class HoerupUtils extends Plugin {  public class HoerupUtils extends Plugin {
6    
7          final static Logger log = Logger.getLogger("HoerupUtils");          final static Logger log = Logger.getLogger("HoerupUtils");
8    
9          private boolean adminDestroy = false;          //private boolean adminDestroy = false;
10            private Set<String> adminDestroyers = new HashSet<String>();
11    
12          private void registerCommands() {          private void registerCommands() {
13                  etc e = etc.getInstance();                  etc e = etc.getInstance();
# Line 41  public class HoerupUtils extends Plugin Line 43  public class HoerupUtils extends Plugin
43                  registerCommands();                  registerCommands();
44          }          }
45    
46            final static int HAND_EMPTY = -1;
47    
48    
49          public class AdminDestroy  extends PluginListener {              public class AdminDestroy  extends PluginListener {    
50                  public boolean onBlockDestroy(Player player, Block block) {                  public boolean onBlockDestroy(Player player, Block block) {
51                          if (adminDestroy == true && player.isAdmin() ) {                          if (player.isAdmin() && adminDestroyers.contains(player.getName() ) ) {
52                                    if (player.getItemInHand() == HAND_EMPTY) {
53                                  block.setType(0);                                          block.setType(0);
54                                  etc.getServer().setBlock(block);                                          etc.getServer().setBlock(block);
55                                            return true;
56                                  return true;                                  }
57                          }                          }
58                          return false;                          return false;
59                  }                  }
# Line 97  public class HoerupUtils extends Plugin Line 101  public class HoerupUtils extends Plugin
101                          return  (srv.getBlockIdAt(x,y,z) == BLOCK_AIR && srv.getBlockIdAt(x,y+1,z) == BLOCK_AIR);                          return  (srv.getBlockIdAt(x,y,z) == BLOCK_AIR && srv.getBlockIdAt(x,y+1,z) == BLOCK_AIR);
102                  }                  }
103    
104                    
105    
106                    public void adminDestroy(Player player, String[] split) {
107                            String name = player.getName();
108                            if (adminDestroyers.contains(name) ) {
109                                    adminDestroyers.remove(name);
110                                    player.sendMessage("Admindestroy disabled");
111                            } else {
112                                    adminDestroyers.add(name);
113                                    player.sendMessage("Admindestroy enabled");
114                            }
115                    }
116    
117    
118                  @Override                  @Override
119                  public boolean onCommand(Player player, java.lang.String[] split) {                  public boolean onCommand(Player player, java.lang.String[] split) {
120                          if ( split[0].equals("/admindestroy") && player.canUseCommand("/admindestroy") ) {                          if ( split[0].equals("/admindestroy") && player.canUseCommand("/admindestroy") ) {
121                                  adminDestroy = !adminDestroy;                                  adminDestroy(player,split);
                                 player.sendMessage("Admindestroy enabled=" + adminDestroy);  
   
122                                  return true;                                  return true;
123                          } else if( split[0].equals("/setpos") && player.canUseCommand("/setpos") ) {                          } else if( split[0].equals("/setpos") && player.canUseCommand("/setpos") ) {
124                                  setPos(player, split);                                  setPos(player, split);

Legend:
Removed from v.1183  
changed lines
  Added in v.1184

  ViewVC Help
Powered by ViewVC 1.1.20