/[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 1196 by torben, Sat Nov 20 08:59:03 2010 UTC revision 1201 by torben, Sat Dec 4 11:38:36 2010 UTC
# Line 14  public class HoerupUtils extends Plugin Line 14  public class HoerupUtils extends Plugin
14                  e.addCommand("/fillarea", "");                  e.addCommand("/fillarea", "");
15                  e.addCommand("/levelarea", "");                  e.addCommand("/levelarea", "");
16                  e.addCommand("/setsurface", "");                  e.addCommand("/setsurface", "");
17                    e.addCommand("/slopearea", "");
18                    e.addCommand("/admindestroy","");
19          }          }
20                    
21          @Override          @Override
# Line 29  public class HoerupUtils extends Plugin Line 31  public class HoerupUtils extends Plugin
31                  e.removeCommand("/fillarea");                  e.removeCommand("/fillarea");
32                  e.removeCommand("/levelarea");                  e.removeCommand("/levelarea");
33                  e.removeCommand("/setsurface");                  e.removeCommand("/setsurface");
34                    e.removeCommand("/slopearea");
35                    e.removeCommand("/admindestroy");
36          }          }
37    
38                    
# Line 130  public class HoerupUtils extends Plugin Line 134  public class HoerupUtils extends Plugin
134                  final static int BLOCK_GRASS = 2;                  final static int BLOCK_GRASS = 2;
135                  final static int BLOCK_DIRT = 3;                  final static int BLOCK_DIRT = 3;
136    
137                    private HashMap<String, String[]> commands = new HashMap<String,String[]>();
138    
139                    
140    
141                  //http://www.minecraftforum.net/viewtopic.php?f=35&t=14739                  //http://www.minecraftforum.net/viewtopic.php?f=35&t=14739
# Line 166  public class HoerupUtils extends Plugin Line 172  public class HoerupUtils extends Plugin
172                          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);
173                  }                  }
174    
175                    public void slopeArea(Player player, java.lang.String[] split) {
176                            int radius = Integer.parseInt(split[1]);
177    
178                            System.out.println("Player " + player.getName() + " used slopearea with radius=" + radius);
179                            
180    
181                            int playerX = roundPos( player.getX() );
182                            int playerY = (int) player.getY();
183                            int playerZ = roundPos( player.getZ() );
184                            
185                            Server srv = etc.getServer();
186    
187                            for (int x=(playerX-radius); x<=(playerX+radius); x++) {
188                                    for (int z=(playerZ-radius); z<=(playerZ+radius); z++) {
189    
190    
191                                            int xdist = Math.abs(playerX-x);
192                                            int zdist = Math.abs(playerZ-z);
193    
194                                            int dist = Math.max(xdist,zdist);
195    
196                                            //for (int y=playerY; y<=playerY+radius; y++) {
197                                            for (int y=(playerY+dist); y<=128; y++) {
198                                                    srv.setBlockAt(BLOCK_AIR, x, y, z);
199                                            }
200    
201                                    }
202    
203                            }
204                    }
205    
206                  @Override                  @Override
207                  public boolean onCommand(Player player, java.lang.String[] split) {                  public boolean onCommand(Player player, java.lang.String[] split) {
208                          if( split[0].equals("/setpos") && player.canUseCommand("/setpos") ) {                          if (! player.canUseCommand(split[0]) ) {
209                                    return false;
210                            }
211    
212                            if ( split[0].equals("/levelarea") || split[0].equals("/la") || split[0].equals("/slopearea") || split[0].equals("/fillarea") || split[0].equals("/setsurface") ) {
213                                    commands.put(player.getName(), split);
214                            }
215                            
216                            if ( split[0].equals("//") ) {
217                                    String cmd[] = commands.get(player.getName() );
218                                    if (cmd != null) {
219                                            onCommand(player, commands.get(player.getName() ) );
220                                    } else {
221                                            player.sendMessage("//: no recorded command found");
222                                    }
223                                    return true;
224                            } else if( split[0].equals("/setpos") && player.canUseCommand("/setpos") ) {
225                                  setPos(player, split);                                  setPos(player, split);
226                                  return true;                                  return true;
227                          } else if ( split[0].equals("/whereis" ) && player.canUseCommand("/whereis")) {                          } else if ( split[0].equals("/whereis" ) && player.canUseCommand("/whereis")) {
228                                  whereIs(player, split);                                  whereIs(player, split);
229                                  return true;                                  return true;
230                          } else if (split[0].equals("/levelarea") && player.canUseCommand("/levelarea")) {                          } else if ( (split[0].equals("/levelarea") || split[0].equals("/la"))  && player.canUseCommand("/levelarea")) {
231                                  if (validateLevelOrFill(player,split)) {                                  if (validateLevelOrFill(player,split)) {
232                                          levelArea(player, split);                                          levelArea(player, split);
233                                  }                                  }
234                                  return true;                                  return true;
235                            } else if (split[0].equals("/slopearea") ) {
236                                    if (validateLevelOrFill(player,split)) {
237                                            slopeArea(player,split);
238                                    }
239                                    return true;
240                          } else if (split[0].equals("/fillarea") && player.canUseCommand("/fillarea")) {                          } else if (split[0].equals("/fillarea") && player.canUseCommand("/fillarea")) {
241                                  if (validateLevelOrFill(player,split)) {                                  if (validateLevelOrFill(player,split)) {
242                                          fillArea(player, split);                                          fillArea(player, split);

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

  ViewVC Help
Powered by ViewVC 1.1.20