32 |
//System.out.println( ">>" + label); //DEBUG |
//System.out.println( ">>" + label); //DEBUG |
33 |
|
|
34 |
if ( label.equals("levelarea") ) { |
if ( label.equals("levelarea") ) { |
35 |
if (validateLevelOrFill(player, args) ) { |
if (validateLevelOrFill(player, label, args) ) { |
36 |
levelArea(player, loc, args); |
levelArea(player, loc, args); |
37 |
} |
} |
38 |
return true; |
return true; |
40 |
|
|
41 |
|
|
42 |
if ( label.equals("fillarea") ) { |
if ( label.equals("fillarea") ) { |
43 |
if (validateLevelOrFill(player, args) ) { |
if (validateLevelOrFill(player, label, args) ) { |
44 |
fillArea(player, loc, args); |
fillArea(player, loc, args); |
45 |
} |
} |
46 |
return true; |
return true; |
62 |
} |
} |
63 |
|
|
64 |
|
|
65 |
void slopeArea(Player player, Location loc, String[] args) { |
void slopeArea(Player player, Location loc, String[] split) { |
66 |
int radius = Integer.parseInt(args[1]); |
int radius; |
67 |
|
try { |
68 |
|
radius = Integer.parseInt(split[0]); |
69 |
|
} catch (Exception e) { |
70 |
|
player.sendMessage("setsurface: radius must be an integer"); |
71 |
|
return; |
72 |
|
} |
73 |
|
|
74 |
System.out.println("Player " + player.getName() + " used slopearea with radius=" + radius); |
System.out.println("Player " + player.getName() + " used slopearea with radius=" + radius); |
75 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
if (split.length != 3) { |
if (split.length != 2) { |
108 |
player.sendMessage("Usage /setsurface [radius] [blockID]"); |
player.sendMessage("Usage /setsurface [radius] [blockID]"); |
109 |
return; |
return; |
110 |
} |
} |
112 |
|
|
113 |
int radius; |
int radius; |
114 |
try { |
try { |
115 |
radius = Integer.parseInt(split[1]); |
radius = Integer.parseInt(split[0]); |
116 |
} catch (Exception e) { |
} catch (Exception e) { |
117 |
player.sendMessage("setsurface: radius must be an integer"); |
player.sendMessage("setsurface: radius must be an integer"); |
118 |
return; |
return; |
126 |
|
|
127 |
int blockid; |
int blockid; |
128 |
try { |
try { |
129 |
blockid = Integer.parseInt(split[2]); |
blockid = Integer.parseInt(split[1]); |
130 |
} catch (Exception e) { |
} catch (Exception e) { |
131 |
player.sendMessage("setsurface: blockid must be an integer"); |
player.sendMessage("setsurface: blockid must be an integer"); |
132 |
return; |
return; |
160 |
for (int x=(playerX-radius); x<=(playerX+radius); x++) { |
for (int x=(playerX-radius); x<=(playerX+radius); x++) { |
161 |
for (int z=(playerZ-radius); z<=(playerZ+radius); z++) { |
for (int z=(playerZ-radius); z<=(playerZ+radius); z++) { |
162 |
//int y = getGroundLevel(x,z) - 1; |
//int y = getGroundLevel(x,z) - 1; |
163 |
int y = world.getHighestBlockYAt(x, z); |
int y = world.getHighestBlockYAt(x, z) - 1; |
164 |
|
|
165 |
world.getBlockAt(x, y, z).setTypeId(blockid); |
world.getBlockAt(x, y, z).setTypeId(blockid); |
166 |
} |
} |
167 |
} |
} |
168 |
} |
} |
169 |
|
|
170 |
private boolean validateLevelOrFill(Player player, String[] split) { |
private boolean validateLevelOrFill(Player player, String label, String[] split) { |
171 |
if (split.length < 2 || split.length > 3) { |
if (split.length < 1 || split.length > 2) { |
172 |
player.sendMessage("Usage: " + split[0] + " [radius]"); |
player.sendMessage("Usage: " + label + " [radius]"); |
173 |
return false; |
return false; |
174 |
} |
} |
175 |
|
|
176 |
int radius; |
int radius; |
177 |
try { |
try { |
178 |
radius = Integer.parseInt(split[1]); |
radius = Integer.parseInt(split[0]); |
179 |
} catch (Exception e) { |
} catch (Exception e) { |
180 |
player.sendMessage(split[0] + ": radius must be an integer"); |
player.sendMessage(label + ": radius must be an integer"); |
181 |
return false; |
return false; |
182 |
} |
} |
183 |
|
|
184 |
if (radius > 20) { |
if (radius > 20) { |
185 |
player.sendMessage(split[0] + ": radius may not exceed 20"); |
player.sendMessage(label + ": radius may not exceed 20"); |
186 |
return false; |
return false; |
187 |
} |
} |
188 |
|
|
189 |
if (split.length == 3) { |
if (split.length == 2) { |
190 |
int id; |
int id; |
191 |
try { |
try { |
192 |
id = Integer.parseInt( split[2] ); |
id = Integer.parseInt( split[1] ); |
193 |
} catch (Exception e) { |
} catch (Exception e) { |
194 |
player.sendMessage(split[0] + ": id must be an integer"); |
player.sendMessage(label + ": id must be an integer"); |
195 |
return false; |
return false; |
196 |
} |
} |
197 |
if ( id == 46) { |
if ( id == 46) { |
205 |
} |
} |
206 |
|
|
207 |
private void fillArea(Player player, Location loc, String[] split) { |
private void fillArea(Player player, Location loc, String[] split) { |
208 |
int radius = Integer.parseInt(split[1]); |
int radius = Integer.parseInt(split[0]); |
209 |
|
|
210 |
int material = Material.DIRT.getId(); |
int material = Material.DIRT.getId(); |
211 |
|
|
212 |
if (split.length == 3) { |
if (split.length == 2) { |
213 |
material = Integer.parseInt( split[2] ); |
material = Integer.parseInt( split[1] ); |
214 |
} |
} |
215 |
|
|
216 |
System.out.println("Player " + player.getName() + " used fillarea with radius=" + radius); |
System.out.println("Player " + player.getName() + " used fillarea with radius=" + radius); |
238 |
|
|
239 |
private void levelArea(Player player, Location loc, String[] split) { |
private void levelArea(Player player, Location loc, String[] split) { |
240 |
|
|
241 |
int radius = Integer.parseInt(split[1]); |
int radius = Integer.parseInt(split[0]); |
242 |
|
|
243 |
System.out.println("Player " + player.getName() + " used levelarea with radius=" + radius); |
System.out.println("Player " + player.getName() + " used levelarea with radius=" + radius); |
244 |
|
|