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 |
|
|
|
|
|
|
|
|
|
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")) { |
176 |
whereIs(player, split); |
whereIs(player, split); |
177 |
return true; |
return true; |
178 |
} else if (split[0].equals("/levelarea") && player.canUseCommand("/levelarea")) { |
} else if ( (split[0].equals("/levelarea") || split[0].equals("/la")) && player.canUseCommand("/levelarea")) { |
179 |
if (validateLevelOrFill(player,split)) { |
if (validateLevelOrFill(player,split)) { |
180 |
levelArea(player, split); |
levelArea(player, split); |
181 |
} |
} |