Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.fleftuhc.fleftuhc;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.Plugin;
- public class SetWalls implements CommandExecutor{
- public static Plugin plugin;
- public final Logger logger = Logger.getLogger("Minecraft");
- private static final String prefix = ChatColor.DARK_GRAY + "[" + ChatColor.BLUE + "Fleft's" + ChatColor.AQUA + "UHC" + ChatColor.DARK_GRAY + "] " + ChatColor.WHITE;
- public boolean onCommand(CommandSender sender, Command cmd,
- String commandlabel, String[] args) {
- if (cmd.getName().equalsIgnoreCase("setwalls")) {
- Player player = (Player)sender;
- if (player.hasPermission("FleftUHC.SetWalls")){
- if (Bukkit.getWorld(args[1]) != null) {
- try {
- String world = args[1];
- String radiusString = args[0];
- int radius = Integer.parseInt(radiusString);
- Location loc1 = new Location(Bukkit.getWorld(world), radius, 256, radius);
- Location loc2 = new Location(Bukkit.getWorld(world), radius, 0, 0-radius);
- int minX = Math.min(loc1.getBlockX(), loc2.getBlockX());
- int minY = Math.min(loc1.getBlockY(), loc2.getBlockY());
- int minZ = Math.min(loc1.getBlockZ(), loc2.getBlockZ());
- int maxX = Math.max(loc1.getBlockX(), loc2.getBlockX());
- int maxY = Math.max(loc1.getBlockY(), loc2.getBlockY());
- int maxZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ());
- World theWorld = Bukkit.getWorld(world);
- Bukkit.broadcastMessage(prefix + "Setting walls with radius " + args[0] + ", expect a lag spike.");
- for(int x = minX; x <= maxX; x++){
- for(int y = minY; y <= maxY; y++){
- for(int z = minZ; z <= maxZ; z++){
- Block block = theWorld.getBlockAt(x, y, z);
- block.setType(Material.BEDROCK);
- }
- }
- }
- Bukkit.broadcastMessage(prefix + "1/4 Completed!");
- Location loc12 = new Location(Bukkit.getWorld(world), 0-radius, 256, 0-radius);
- Location loc22 = new Location(Bukkit.getWorld(world), 0-radius, 0, radius);
- int minX2 = Math.min(loc12.getBlockX(), loc22.getBlockX());
- int minY2 = Math.min(loc12.getBlockY(), loc22.getBlockY());
- int minZ2 = Math.min(loc12.getBlockZ(), loc22.getBlockZ());
- int maxX2 = Math.max(loc12.getBlockX(), loc22.getBlockX());
- int maxY2 = Math.max(loc12.getBlockY(), loc22.getBlockY());
- int maxZ2 = Math.max(loc12.getBlockZ(), loc22.getBlockZ());
- for(int x = minX2; x <= maxX2; x++){
- for(int y = minY2; y <= maxY2; y++){
- for(int z = minZ2; z <= maxZ2; z++){
- Block block = theWorld.getBlockAt(x, y, z);
- block.setType(Material.BEDROCK);
- }
- }
- }
- Bukkit.broadcastMessage(prefix + "2/4 Completed!");
- Location loc13 = new Location(Bukkit.getWorld(world), radius, 256, 0-radius);
- Location loc23 = new Location(Bukkit.getWorld(world), 0-radius, 0, 0-radius);
- int minX3 = Math.min(loc13.getBlockX(), loc23.getBlockX());
- int minY3 = Math.min(loc13.getBlockY(), loc23.getBlockY());
- int minZ3 = Math.min(loc13.getBlockZ(), loc23.getBlockZ());
- int maxX3 = Math.max(loc13.getBlockX(), loc23.getBlockX());
- int maxY3 = Math.max(loc13.getBlockY(), loc23.getBlockY());
- int maxZ3 = Math.max(loc13.getBlockZ(), loc23.getBlockZ());
- for(int x = minX3; x <= maxX3; x++){
- for(int y = minY3; y <= maxY3; y++){
- for(int z = minZ3; z <= maxZ3; z++){
- Block block = theWorld.getBlockAt(x, y, z);
- block.setType(Material.BEDROCK);
- }
- }
- }
- Bukkit.broadcastMessage(prefix + "3/4 Completed!");
- Location loc14 = new Location(Bukkit.getWorld(world), 0-radius, 256, radius);
- Location loc24 = new Location(Bukkit.getWorld(world), radius, 0, radius);
- int minX4 = Math.min(loc14.getBlockX(), loc24.getBlockX());
- int minY4 = Math.min(loc14.getBlockY(), loc24.getBlockY());
- int minZ4 = Math.min(loc14.getBlockZ(), loc24.getBlockZ());
- int maxX4 = Math.max(loc14.getBlockX(), loc24.getBlockX());
- int maxY4 = Math.max(loc14.getBlockY(), loc24.getBlockY());
- int maxZ4 = Math.max(loc14.getBlockZ(), loc24.getBlockZ());
- for(int x = minX4; x <= maxX4; x++){
- for(int y = minY4; y <= maxY4; y++){
- for(int z = minZ4; z <= maxZ4; z++){
- Block block = theWorld.getBlockAt(x, y, z);
- block.setType(Material.BEDROCK);
- }
- }
- }
- Bukkit.broadcastMessage(prefix + "4/4 Completed!");
- }
- catch (NumberFormatException ex) {
- player.sendMessage((String) prefix + args[0] + " is not a number!");
- return false;
- }
- }
- else {
- player.sendMessage(prefix + args[1] + " is not a world!");
- }
- }
- else {
- player.sendMessage(prefix + "No permission!");
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement