/[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 1195 by torben, Sat Nov 20 08:42:06 2010 UTC revision 1196 by torben, Sat Nov 20 08:59:03 2010 UTC
# Line 6  public class HoerupUtils extends Plugin Line 6  public class HoerupUtils extends Plugin
6    
7          final static Logger log = Logger.getLogger("HoerupUtils");          final static Logger log = Logger.getLogger("HoerupUtils");
8    
         //private boolean adminDestroy = false;  
         private Set<String> adminDestroyers = new HashSet<String>();  
9    
10          private void registerCommands() {          private void registerCommands() {
11                  etc e = etc.getInstance();                  etc e = etc.getInstance();
# Line 38  public class HoerupUtils extends Plugin Line 36  public class HoerupUtils extends Plugin
36          public void initialize() {          public void initialize() {
37                  PluginLoader loader = etc.getLoader();                  PluginLoader loader = etc.getLoader();
38                  loader.addListener( PluginLoader.Hook.COMMAND, new HoerupUtilsPlugin(), this, PluginListener.Priority.MEDIUM );                  loader.addListener( PluginLoader.Hook.COMMAND, new HoerupUtilsPlugin(), this, PluginListener.Priority.MEDIUM );
                 loader.addListener( PluginLoader.Hook.BLOCK_DESTROYED, new AdminDestroy(), this, PluginListener.Priority.MEDIUM );  
39                  loader.addListener( PluginLoader.Hook.LOGIN, new ConnectedUsers(), this, PluginListener.Priority.MEDIUM );                  loader.addListener( PluginLoader.Hook.LOGIN, new ConnectedUsers(), this, PluginListener.Priority.MEDIUM );
40    
41                  Jail j = new Jail();                  Jail j = new Jail();
# Line 46  public class HoerupUtils extends Plugin Line 43  public class HoerupUtils extends Plugin
43                  loader.addListener( PluginLoader.Hook.COMMAND, j, this, PluginListener.Priority.MEDIUM );                  loader.addListener( PluginLoader.Hook.COMMAND, j, this, PluginListener.Priority.MEDIUM );
44                  loader.addListener( PluginLoader.Hook.PLAYER_MOVE, j, this, PluginListener.Priority.MEDIUM );                  loader.addListener( PluginLoader.Hook.PLAYER_MOVE, j, this, PluginListener.Priority.MEDIUM );
45    
46                    AdminDestroy adm = new AdminDestroy();
47                    loader.addListener( PluginLoader.Hook.COMMAND, adm, this, PluginListener.Priority.MEDIUM);
48                    loader.addListener( PluginLoader.Hook.BLOCK_DESTROYED, adm, this, PluginListener.Priority.MEDIUM );
49                    loader.addListener( PluginLoader.Hook.DISCONNECT, adm, this, PluginListener.Priority.MEDIUM );
50    
51    
52                  registerCommands();                  registerCommands();
53          }          }
54    
         final static int HAND_EMPTY = -1;  
55    
56    
57          class ConnectedUsers extends PluginListener {          class ConnectedUsers extends PluginListener {
# Line 70  public class HoerupUtils extends Plugin Line 70  public class HoerupUtils extends Plugin
70                  }                  }
71          }          }
72    
         public class AdminDestroy  extends PluginListener {      
                 public boolean onBlockDestroy(Player player, Block block) {  
                         if (player.isAdmin() && adminDestroyers.contains(player.getName() ) ) {  
                                 if (player.getItemInHand() == HAND_EMPTY) {  
   
                                         int oldType = block.getType();  
   
                                         block.setType(0);  
                                         etc.getServer().setBlock(block);  
   
                                         if (oldType > 4 && oldType != 13) {  //dont drop stone or dirt, gravel  
                                                 etc.getServer().dropItem(block.getX(), block.getY(), block.getZ(), oldType); // diamond resource block  should drop diamonds and not a new diamond resource block  
                                         }  
   
                                         return true;  
                                 }  
                         }  
                         return false;  
                 }  
         }  
73    
74          public static String getBearingStr(int angle) {          public static String getBearingStr(int angle) {
75                  if (angle < 22) {                  if (angle < 22) {
# Line 186  public class HoerupUtils extends Plugin Line 166  public class HoerupUtils extends Plugin
166                          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);
167                  }                  }
168    
                   
   
                 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");  
                         }  
                 }  
   
169    
170                  @Override                  @Override
171                  public boolean onCommand(Player player, java.lang.String[] split) {                  public boolean onCommand(Player player, java.lang.String[] split) {
172                          if ( split[0].equals("/admindestroy") && player.canUseCommand("/admindestroy") ) {                          if( split[0].equals("/setpos") && player.canUseCommand("/setpos") ) {
                                 adminDestroy(player,split);  
                                 return true;  
                         } else if( split[0].equals("/setpos") && player.canUseCommand("/setpos") ) {  
173                                  setPos(player, split);                                  setPos(player, split);
174                                  return true;                                  return true;
175                          } else if ( split[0].equals("/whereis" ) && player.canUseCommand("/whereis")) {                          } else if ( split[0].equals("/whereis" ) && player.canUseCommand("/whereis")) {

Legend:
Removed from v.1195  
changed lines
  Added in v.1196

  ViewVC Help
Powered by ViewVC 1.1.20