Advertisement
Vilsol

CommandX

Feb 12th, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.11 KB | None | 0 0
  1. import java.util.HashMap;
  2. import java.util.Iterator;
  3.  
  4. import org.bukkit.Location;
  5. import org.bukkit.Material;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandExecutor;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10.  
  11. public class CommandX implements CommandExecutor {
  12.  
  13.     private HashMap<Location, Material> blocks = new HashMap<Location, Material>();
  14.     private boolean drawn = false;
  15.    
  16.     @Override
  17.     public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  18.         if(!(sender instanceof Player)) return true;
  19.         Player plr = (Player) sender;
  20.  
  21.         if(drawn == false){
  22.             for(int X = plr.getLocation().getBlockX() - 50; X < plr.getLocation().getBlockX() + 50; X++){
  23.                 if(X >= plr.getLocation().getBlockX() - 2 && X <= plr.getLocation().getBlockX() + 2) continue;
  24.                 Location l = new Location(plr.getWorld(), X, plr.getLocation().getBlockY(), plr.getLocation().getBlockZ());
  25.                 blocks.put(l, l.getBlock().getType());
  26.                 l.getBlock().setType(Material.GLASS);
  27.             }
  28.  
  29.             for(int Y = plr.getLocation().getBlockY() - 50; Y < plr.getLocation().getBlockY() + 50; Y++){
  30.                 if(Y >= plr.getLocation().getBlockY() - 2 && Y <= plr.getLocation().getBlockY() + 2) continue;
  31.                 if(Y < 0) Y = 0;
  32.                 Location l = new Location(plr.getWorld(), plr.getLocation().getBlockX(), Y, plr.getLocation().getBlockZ());
  33.                 blocks.put(l, l.getBlock().getType());
  34.                 l.getBlock().setType(Material.GLASS);
  35.             }
  36.  
  37.             for(int Z = plr.getLocation().getBlockZ() - 50; Z < plr.getLocation().getBlockZ() + 50; Z++){
  38.                 if(Z >= plr.getLocation().getBlockZ() - 2 && Z <= plr.getLocation().getBlockZ() + 2) continue;
  39.                 Location l = new Location(plr.getWorld(), plr.getLocation().getBlockX(), plr.getLocation().getBlockY(), Z);
  40.                 blocks.put(l, l.getBlock().getType());
  41.                 l.getBlock().setType(Material.GLASS);
  42.             }
  43.         }else{
  44.             Iterator<Location> i = blocks.keySet().iterator();
  45.             while(i.hasNext()){
  46.                 Location l = i.next();
  47.                 l.getBlock().setType(blocks.get(l));
  48.                 i.remove();
  49.             }
  50.             blocks.clear();
  51.         }
  52.        
  53.         drawn = !drawn;
  54.        
  55.         return true;
  56.     }
  57.    
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement