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

Annotation of /miscJava/bukkit-minecraft-plugins/HoerupUtils/src/dk/thoerup/bukkit/hoeruputils/SuperMiner.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1590 - (hide annotations) (download)
Tue Aug 16 16:04:01 2011 UTC (12 years, 9 months ago) by torben
File size: 2971 byte(s)
added /wall commando og fixet bug in (power/super)miner
1 torben 1521 package dk.thoerup.bukkit.hoeruputils;
2    
3 torben 1522 import java.util.HashSet;
4     import java.util.Set;
5     import java.util.Random;
6    
7 torben 1521 import org.bukkit.Location;
8 torben 1522 import org.bukkit.Material;
9 torben 1521 import org.bukkit.World;
10     import org.bukkit.block.Block;
11     import org.bukkit.command.Command;
12     import org.bukkit.command.CommandExecutor;
13     import org.bukkit.command.CommandSender;
14     import org.bukkit.entity.Player;
15 torben 1522 import org.bukkit.event.block.BlockDamageEvent;
16     import org.bukkit.event.block.BlockListener;
17     import org.bukkit.event.player.PlayerListener;
18     import org.bukkit.event.player.PlayerQuitEvent;
19 torben 1521
20 torben 1522 public class SuperMiner extends BlockListener implements CommandExecutor {
21 torben 1521
22 torben 1522
23     Random rand = new Random();
24    
25     Set<String> miners = new HashSet<String>();
26 torben 1521
27 torben 1585 final static int radius = 5;
28    
29 torben 1521 @Override
30 torben 1522 public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
31    
32     if (! (sender instanceof Player) ) {
33 torben 1521 return false;
34     }
35    
36 torben 1586 /* if (!sender.isOp()) {
37 torben 1522 sender.sendMessage("Only ops can use superminer");
38     return true;
39 torben 1586 }*/
40 torben 1522
41    
42     Player p = (Player) sender;
43 torben 1521
44 torben 1586 if (! p.hasPermission("hoeruputils.superminer") ) {
45     p.sendMessage("You don't have permissions to use superminer");
46     return true;
47     }
48    
49 torben 1522 if (miners.contains(p.getName())) {
50     miners.remove( p.getName() );
51     p.sendMessage("SuperMiner disabled");
52     } else {
53     miners.add( p.getName() );
54     p.sendMessage("SuperMiner enabled - go dig some tunnels (with a fish)");
55     }
56    
57    
58     return true;
59     }
60 torben 1521
61 torben 1522
62    
63     public void onBlockDamage(BlockDamageEvent event) {
64     Player p = event.getPlayer();
65    
66    
67     if (p.getItemInHand().getType() == Material.RAW_FISH) {
68     if ( miners.contains(p.getName()) ) {
69    
70     Block b = event.getBlock();
71    
72     superMiner(p, p.getWorld(), p.getLocation() );
73     }
74     }
75    
76     }
77 torben 1521
78    
79 torben 1522 public void superMiner(Player player, World world, Location location) {
80 torben 1521
81 torben 1522
82     Location l = location;
83    
84 torben 1585 for (int x=(radius*-1); x<=radius; x++) {
85     for (int y=0; y<=radius; y++) {
86     for (int z=(radius*-1); z<=radius; z++) {
87 torben 1522
88     Block b = world.getBlockAt( l.getBlockX()+x, l.getBlockY()+y, l.getBlockZ()+z);
89    
90     int id = b.getTypeId();
91    
92 torben 1524 if (id == 1 || id == 2 || id == 3 || id == 4 || id == 8 || id == 9 || id == 10 || id == 11 || id == 13 || id == 87) {
93 torben 1522 b.setTypeId( 0 );
94     }
95     }
96    
97    
98     }
99     }
100    
101     }
102    
103    
104    
105     public PlayerQuitListener getPlayerQuitListener() {
106     return new PlayerQuitListener();
107     }
108    
109    
110     public class PlayerQuitListener extends PlayerListener {
111     @Override
112     public void onPlayerQuit(PlayerQuitEvent event) {
113     Player p = event.getPlayer();
114    
115     if (miners.contains(p.getName())) {
116     miners.remove( p.getName() );
117 torben 1521 }
118     }
119     }
120 torben 1522
121 torben 1521 }

  ViewVC Help
Powered by ViewVC 1.1.20