/[projects]/miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/creative/GeneralContractorCommands.java
ViewVC logotype

Diff of /miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/creative/GeneralContractorCommands.java

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

revision 1729 by torben, Tue Mar 13 07:58:31 2012 UTC revision 1730 by torben, Tue Mar 13 08:30:39 2012 UTC
# Line 23  public class GeneralContractorCommands i Line 23  public class GeneralContractorCommands i
23          }          }
24    
25          final static int Y_MAX = 255;          final static int Y_MAX = 255;
26            final int valid_block_array[] = {1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 35, 41, 42, 43, 44, 45, 48, 49, 56, 57, 73, 74, 79, 80, 82} ;
27    
28          HashMap<String,StoredCommand> commands = new HashMap<String,StoredCommand>();          HashMap<String,StoredCommand> commands = new HashMap<String,StoredCommand>();
29    
30    
31                    
32          //@Override          //@Override
33          public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {          public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
# Line 41  public class GeneralContractorCommands i Line 44  public class GeneralContractorCommands i
44                          return true;                          return true;
45                  }                  }
46    
                 commands.put(player.getName(), new StoredCommand(label,args) );  
47    
48                  if (label.equals("replay") || label.equals("*") ) {                  if ( command.getLabel().equals("replay")  ) {
49                          StoredCommand cmd = commands.get(player.getName() );                          StoredCommand cmd = commands.get(player.getName() );
50                          if (cmd != null) {                          if (cmd != null) {
51                                  label = cmd.label;                                  label = cmd.label;
52                                  args = cmd.args;                                  args = cmd.args;
53                          }                          }
54                    } else {
55                            commands.put(player.getName(), new StoredCommand(label,args) );
56                  }                  }
57                                    
58                  //System.out.println( ">>" + label); //DEBUG                  //System.out.println( ">>" + label); //DEBUG
# Line 78  public class GeneralContractorCommands i Line 82  public class GeneralContractorCommands i
82                          setSurface(player, loc, args);                            setSurface(player, loc, args);  
83                          return true;                          return true;
84                  }                  }
85    
86                    if (label.equals("platform") ) {
87                            platform(player,loc,args);
88                            return true;
89                    }
90                    
91                    
92                  return false;                  return false;
# Line 121  public class GeneralContractorCommands i Line 130  public class GeneralContractorCommands i
130                  }                                }              
131          }          }
132                    
133          private void setSurface(Player player, Location loc, String[] split) {          private void platform(Player player, Location loc, String[] split) {
134                  int valid_block_array[] = {1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 35, 41, 42, 43, 44, 45, 48, 49, 56, 57, 73, 74, 79, 80, 82} ;  
135                    if (split.length != 2) {
136                            player.sendMessage("Usage /platform [radius] [blockID]");
137                            return;
138                    }
139    
140                    int radius;
141                    try {
142                            radius = Integer.parseInt(split[0]);
143                    } catch (Exception e) {
144                            player.sendMessage("platform: radius must be an integer");
145                            return;
146                    }
147    
148                    if (radius > 20) {
149                            player.sendMessage("platform: radius may not exceed 20");
150                            return;
151                    }
152    
153                    int blockid;
154                    try {
155                            blockid = Integer.parseInt(split[1]);
156                    } catch (Exception e) {
157                            player.sendMessage("platform: blockid must be an integer");
158                            return;
159                    }
160    /*
161                    boolean validblock = false;
162                    for (int i=0; i<valid_block_array.length; i++) {
163                            if (valid_block_array[i] == blockid) {
164                                    validblock = true;
165                                    break;
166                            }
167                    }
168    
169                    if ( !validblock ) {
170                            player.sendMessage("setsurface: block now allowed");
171                            return;
172                    }*/
173    
174                    int playerX = loc.getBlockX();
175                    int playerY = loc.getBlockY();
176                    int playerZ = loc.getBlockZ();
177    
178                    
179                    World world = loc.getWorld();
180    
181                    for (int x=(playerX-radius); x<=(playerX+radius); x++) {
182                            for (int z=(playerZ-radius); z<=(playerZ+radius); z++) {
183                                    int y = playerY - 1;
184                                    
185                                    world.getBlockAt(x, y, z).setTypeId(blockid);
186                            }
187                    }
188            }
189    
190            private void setSurface(Player player, Location loc, String[] split) {
191    
192                  if (split.length != 2) {                  if (split.length != 2) {
193                          player.sendMessage("Usage /setsurface [radius] [blockID]");                          player.sendMessage("Usage /setsurface [radius] [blockID]");
194                          return;                          return;
195                  }                  }
196    
   
197                  int radius;                  int radius;
198                  try {                  try {
199                          radius = Integer.parseInt(split[0]);                          radius = Integer.parseInt(split[0]);
# Line 145  public class GeneralContractorCommands i Line 207  public class GeneralContractorCommands i
207                          return;                          return;
208                  }                  }
209    
   
210                  int blockid;                  int blockid;
211                  try {                  try {
212                          blockid = Integer.parseInt(split[1]);                          blockid = Integer.parseInt(split[1]);
# Line 177  public class GeneralContractorCommands i Line 238  public class GeneralContractorCommands i
238                  }                  }
239                                    
240                  World world = loc.getWorld();                  World world = loc.getWorld();
                   
241    
242                  for (int x=(playerX-radius); x<=(playerX+radius); x++) {                  for (int x=(playerX-radius); x<=(playerX+radius); x++) {
243                          for (int z=(playerZ-radius); z<=(playerZ+radius); z++) {                          for (int z=(playerZ-radius); z<=(playerZ+radius); z++) {

Legend:
Removed from v.1729  
changed lines
  Added in v.1730

  ViewVC Help
Powered by ViewVC 1.1.20