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(); |
17 |
} |
} |
18 |
|
|
19 |
@Override |
@Override |
20 |
public void disable() { |
public void enable() { |
21 |
registerCommands(); |
registerCommands(); |
22 |
} |
} |
23 |
|
|
24 |
@Override |
@Override |
25 |
public void enable() { |
public void disable() { |
26 |
etc e = etc.getInstance(); |
etc e = etc.getInstance(); |
27 |
e.removeCommand("/setpos"); |
e.removeCommand("/setpos"); |
28 |
e.removeCommand("/whereis"); |
e.removeCommand("/whereis"); |
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(); |
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 { |
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) { |
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 |
|
|
169 |
|
public void slopeArea(Player player, java.lang.String[] split) { |
170 |
|
int radius = Integer.parseInt(split[1]); |
171 |
|
|
172 |
|
System.out.println("Player " + player.getName() + " used slopearea with radius=" + radius); |
173 |
|
|
174 |
|
|
175 |
|
int playerX = roundPos( player.getX() ); |
176 |
|
int playerY = (int) player.getY(); |
177 |
|
int playerZ = roundPos( player.getZ() ); |
178 |
|
|
179 |
|
Server srv = etc.getServer(); |
180 |
|
|
181 |
|
for (int x=(playerX-radius); x<=(playerX+radius); x++) { |
182 |
|
for (int z=(playerZ-radius); z<=(playerZ+radius); z++) { |
183 |
|
|
184 |
|
|
185 |
|
int xdist = Math.abs(playerX-x); |
186 |
|
int zdist = Math.abs(playerZ-z); |
187 |
|
|
188 |
|
int dist = Math.max(xdist,zdist); |
189 |
|
|
190 |
|
//for (int y=playerY; y<=playerY+radius; y++) { |
191 |
|
for (int y=(playerY+dist); y<=128; y++) { |
192 |
|
srv.setBlockAt(BLOCK_AIR, x, y, z); |
193 |
|
} |
194 |
|
|
195 |
|
} |
196 |
|
|
|
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"); |
|
197 |
} |
} |
198 |
} |
} |
199 |
|
|
|
|
|
200 |
@Override |
@Override |
201 |
public boolean onCommand(Player player, java.lang.String[] split) { |
public boolean onCommand(Player player, java.lang.String[] split) { |
202 |
if ( split[0].equals("/admindestroy") && player.canUseCommand("/admindestroy") ) { |
if (! player.canUseCommand(split[0]) ) { |
203 |
adminDestroy(player,split); |
return false; |
204 |
return true; |
} |
205 |
} else if( split[0].equals("/setpos") && player.canUseCommand("/setpos") ) { |
|
206 |
|
if( split[0].equals("/setpos") && player.canUseCommand("/setpos") ) { |
207 |
setPos(player, split); |
setPos(player, split); |
208 |
return true; |
return true; |
209 |
} else if ( split[0].equals("/whereis" ) && player.canUseCommand("/whereis")) { |
} else if ( split[0].equals("/whereis" ) && player.canUseCommand("/whereis")) { |
210 |
whereIs(player, split); |
whereIs(player, split); |
211 |
return true; |
return true; |
212 |
} else if (split[0].equals("/levelarea") && player.canUseCommand("/levelarea")) { |
} else if ( (split[0].equals("/levelarea") || split[0].equals("/la")) && player.canUseCommand("/levelarea")) { |
213 |
if (validateLevelOrFill(player,split)) { |
if (validateLevelOrFill(player,split)) { |
214 |
levelArea(player, split); |
levelArea(player, split); |
215 |
} |
} |
216 |
return true; |
return true; |
217 |
|
} else if (split[0].equals("/slopearea") ) { |
218 |
|
if (validateLevelOrFill(player,split)) { |
219 |
|
slopeArea(player,split); |
220 |
|
} |
221 |
|
return true; |
222 |
} else if (split[0].equals("/fillarea") && player.canUseCommand("/fillarea")) { |
} else if (split[0].equals("/fillarea") && player.canUseCommand("/fillarea")) { |
223 |
if (validateLevelOrFill(player,split)) { |
if (validateLevelOrFill(player,split)) { |
224 |
fillArea(player, split); |
fillArea(player, split); |