Advertisement
fleft17

Untitled

Jan 4th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.17 KB | None | 0 0
  1. package me.fleftuhc.fleftuhc;
  2.  
  3. import java.util.logging.Logger;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Location;
  8. import org.bukkit.Material;
  9. 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. import org.bukkit.plugin.Plugin;
  16.  
  17. public class SetWalls implements CommandExecutor{
  18.     public static Plugin plugin;
  19.     public final Logger logger = Logger.getLogger("Minecraft");
  20.  
  21.     private static final String prefix = ChatColor.DARK_GRAY + "[" + ChatColor.BLUE + "Fleft's" + ChatColor.AQUA + "UHC" + ChatColor.DARK_GRAY + "] " + ChatColor.WHITE;
  22.  
  23.    
  24.     public boolean onCommand(CommandSender sender, Command cmd,
  25.             String commandlabel, String[] args) {
  26.         if (cmd.getName().equalsIgnoreCase("setwalls")) {
  27.             Player player = (Player)sender;
  28.             if (player.hasPermission("FleftUHC.SetWalls")){
  29.                 if (Bukkit.getWorld(args[1]) != null) {
  30.  
  31.                     try {
  32.  
  33.        
  34.                              
  35.  
  36.                          
  37.                         String world = args[1];
  38.                         String radiusString = args[0];
  39.                         int radius = Integer.parseInt(radiusString);
  40.                         Location loc1 = new Location(Bukkit.getWorld(world), radius, 256, radius);
  41.                         Location loc2 = new Location(Bukkit.getWorld(world), radius, 0, 0-radius);
  42.                         int minX = Math.min(loc1.getBlockX(), loc2.getBlockX());
  43.                         int minY = Math.min(loc1.getBlockY(), loc2.getBlockY());
  44.                         int minZ = Math.min(loc1.getBlockZ(), loc2.getBlockZ());
  45.                         int maxX = Math.max(loc1.getBlockX(), loc2.getBlockX());
  46.                         int maxY = Math.max(loc1.getBlockY(), loc2.getBlockY());
  47.                         int maxZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ());
  48.                         World theWorld = Bukkit.getWorld(world);
  49.  
  50.                         Bukkit.broadcastMessage(prefix + "Setting walls with radius " + args[0] + ", expect a lag spike.");
  51.  
  52.  
  53.                         for(int x = minX; x <= maxX; x++){
  54.                             for(int y = minY; y <= maxY; y++){
  55.                                 for(int z = minZ; z <= maxZ; z++){
  56.                                     Block block = theWorld.getBlockAt(x, y, z);
  57.                                     block.setType(Material.BEDROCK);
  58.                                 }
  59.                             }
  60.                         }
  61.  
  62.                         Bukkit.broadcastMessage(prefix + "1/4 Completed!");
  63.                         Location loc12 = new Location(Bukkit.getWorld(world), 0-radius, 256, 0-radius);
  64.                         Location loc22 = new Location(Bukkit.getWorld(world), 0-radius, 0, radius);
  65.                         int minX2 = Math.min(loc12.getBlockX(), loc22.getBlockX());
  66.                         int minY2 = Math.min(loc12.getBlockY(), loc22.getBlockY());
  67.                         int minZ2 = Math.min(loc12.getBlockZ(), loc22.getBlockZ());
  68.                         int maxX2 = Math.max(loc12.getBlockX(), loc22.getBlockX());
  69.                         int maxY2 = Math.max(loc12.getBlockY(), loc22.getBlockY());
  70.                         int maxZ2 = Math.max(loc12.getBlockZ(), loc22.getBlockZ());
  71.  
  72.  
  73.  
  74.  
  75.                         for(int x = minX2; x <= maxX2; x++){
  76.                             for(int y = minY2; y <= maxY2; y++){
  77.                                 for(int z = minZ2; z <= maxZ2; z++){
  78.                                     Block block = theWorld.getBlockAt(x, y, z);
  79.                                     block.setType(Material.BEDROCK);
  80.                                 }
  81.                             }
  82.                         }
  83.                         Bukkit.broadcastMessage(prefix + "2/4 Completed!");
  84.                         Location loc13 = new Location(Bukkit.getWorld(world), radius, 256, 0-radius);
  85.                         Location loc23 = new Location(Bukkit.getWorld(world), 0-radius, 0, 0-radius);
  86.                         int minX3 = Math.min(loc13.getBlockX(), loc23.getBlockX());
  87.                         int minY3 = Math.min(loc13.getBlockY(), loc23.getBlockY());
  88.                         int minZ3 = Math.min(loc13.getBlockZ(), loc23.getBlockZ());
  89.                         int maxX3 = Math.max(loc13.getBlockX(), loc23.getBlockX());
  90.                         int maxY3 = Math.max(loc13.getBlockY(), loc23.getBlockY());
  91.                         int maxZ3 = Math.max(loc13.getBlockZ(), loc23.getBlockZ());
  92.  
  93.  
  94.  
  95.                         for(int x = minX3; x <= maxX3; x++){
  96.                             for(int y = minY3; y <= maxY3; y++){
  97.                                 for(int z = minZ3; z <= maxZ3; z++){
  98.                                     Block block = theWorld.getBlockAt(x, y, z);
  99.                                     block.setType(Material.BEDROCK);
  100.                                 }
  101.                             }
  102.                         }
  103.                         Bukkit.broadcastMessage(prefix + "3/4 Completed!");
  104.                         Location loc14 = new Location(Bukkit.getWorld(world), 0-radius, 256, radius);
  105.                         Location loc24 = new Location(Bukkit.getWorld(world), radius, 0, radius);
  106.                         int minX4 = Math.min(loc14.getBlockX(), loc24.getBlockX());
  107.                         int minY4 = Math.min(loc14.getBlockY(), loc24.getBlockY());
  108.                         int minZ4 = Math.min(loc14.getBlockZ(), loc24.getBlockZ());
  109.                         int maxX4 = Math.max(loc14.getBlockX(), loc24.getBlockX());
  110.                         int maxY4 = Math.max(loc14.getBlockY(), loc24.getBlockY());
  111.                         int maxZ4 = Math.max(loc14.getBlockZ(), loc24.getBlockZ());
  112.  
  113.  
  114.  
  115.                         for(int x = minX4; x <= maxX4; x++){
  116.                             for(int y = minY4; y <= maxY4; y++){
  117.                                 for(int z = minZ4; z <= maxZ4; z++){
  118.                                     Block block = theWorld.getBlockAt(x, y, z);
  119.                                     block.setType(Material.BEDROCK);
  120.                                 }
  121.                             }
  122.                         }
  123.                         Bukkit.broadcastMessage(prefix + "4/4 Completed!");
  124.  
  125.  
  126.                     }
  127.                     catch (NumberFormatException ex) {
  128.                         player.sendMessage((String) prefix + args[0] + " is not a number!");
  129.                         return false;
  130.                     }
  131.                 }
  132.                 else {
  133.                     player.sendMessage(prefix + args[1] + " is not a world!");
  134.                 }
  135.  
  136.             }
  137.             else {
  138.                 player.sendMessage(prefix + "No permission!");
  139.             }
  140.  
  141.  
  142.  
  143.  
  144.  
  145.         }
  146.  
  147.  
  148.         return true;
  149.     }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement