1 |
|
2 |
import java.util.logging.*; |
3 |
import java.util.*; |
4 |
|
5 |
public class AdminDestroy extends PluginListener { |
6 |
|
7 |
final static Logger log = Logger.getLogger("Minecraft"); |
8 |
|
9 |
//private boolean adminDestroy = false; |
10 |
private Set<String> adminDestroyers = new HashSet<String>(); |
11 |
|
12 |
|
13 |
final static int HAND_EMPTY = -1; |
14 |
|
15 |
@Override |
16 |
public void onDisconnect(Player player) { |
17 |
adminDestroyers.remove( player.getName() ); |
18 |
} |
19 |
|
20 |
@Override |
21 |
public boolean onBlockDestroy(Player player, Block block) { |
22 |
if (adminDestroyers.contains(player.getName() ) ) { |
23 |
if (player.getItemInHand() == HAND_EMPTY) { |
24 |
|
25 |
int oldType = block.getType(); |
26 |
|
27 |
block.setType(0); |
28 |
etc.getServer().setBlock(block); |
29 |
|
30 |
if (oldType > 4 && oldType != 13) { //dont drop stone or dirt, gravel |
31 |
etc.getServer().dropItem(block.getX(), block.getY(), block.getZ(), oldType); // diamond resource block should drop diamonds and not a new diamond resource block |
32 |
} |
33 |
|
34 |
return true; |
35 |
} |
36 |
} |
37 |
return false; |
38 |
} |
39 |
|
40 |
@Override |
41 |
public boolean onCommand(Player player, java.lang.String[] split) { |
42 |
if ( split[0].equals("/admindestroy") && player.canUseCommand("/admindestroy") ) { |
43 |
adminDestroy(player,split); |
44 |
return true; |
45 |
} |
46 |
return false; |
47 |
} |
48 |
|
49 |
public void adminDestroy(Player player, String[] split) { |
50 |
String name = player.getName(); |
51 |
if (adminDestroyers.contains(name) ) { |
52 |
adminDestroyers.remove(name); |
53 |
player.sendMessage("Admindestroy disabled"); |
54 |
} else { |
55 |
adminDestroyers.add(name); |
56 |
player.sendMessage("Admindestroy enabled"); |
57 |
} |
58 |
} |
59 |
} |