Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.Iterator;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- public class CommandX implements CommandExecutor {
- private HashMap<Location, Material> blocks = new HashMap<Location, Material>();
- private boolean drawn = false;
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if(!(sender instanceof Player)) return true;
- Player plr = (Player) sender;
- if(drawn == false){
- for(int X = plr.getLocation().getBlockX() - 50; X < plr.getLocation().getBlockX() + 50; X++){
- if(X >= plr.getLocation().getBlockX() - 2 && X <= plr.getLocation().getBlockX() + 2) continue;
- Location l = new Location(plr.getWorld(), X, plr.getLocation().getBlockY(), plr.getLocation().getBlockZ());
- blocks.put(l, l.getBlock().getType());
- l.getBlock().setType(Material.GLASS);
- }
- for(int Y = plr.getLocation().getBlockY() - 50; Y < plr.getLocation().getBlockY() + 50; Y++){
- if(Y >= plr.getLocation().getBlockY() - 2 && Y <= plr.getLocation().getBlockY() + 2) continue;
- if(Y < 0) Y = 0;
- Location l = new Location(plr.getWorld(), plr.getLocation().getBlockX(), Y, plr.getLocation().getBlockZ());
- blocks.put(l, l.getBlock().getType());
- l.getBlock().setType(Material.GLASS);
- }
- for(int Z = plr.getLocation().getBlockZ() - 50; Z < plr.getLocation().getBlockZ() + 50; Z++){
- if(Z >= plr.getLocation().getBlockZ() - 2 && Z <= plr.getLocation().getBlockZ() + 2) continue;
- Location l = new Location(plr.getWorld(), plr.getLocation().getBlockX(), plr.getLocation().getBlockY(), Z);
- blocks.put(l, l.getBlock().getType());
- l.getBlock().setType(Material.GLASS);
- }
- }else{
- Iterator<Location> i = blocks.keySet().iterator();
- while(i.hasNext()){
- Location l = i.next();
- l.getBlock().setType(blocks.get(l));
- i.remove();
- }
- blocks.clear();
- }
- drawn = !drawn;
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement