diff --git a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java index bb731706..9502256a 100644 --- a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java +++ b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java @@ -374,15 +374,16 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal by that name exists!"); } } else { - if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) { + if (player.hasMetadata("selectedPortal")) { + player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Your currently selected portal has been shown, it will dissapear shortly!"); + Selection.Show(player, this.plugin, player.getMetadata("selectedPortal").get(0).asString()); + } else if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) { if (player.getMetadata("Pos1World").get(0).asString().equals(player.getMetadata("Pos2World").get(0).asString()) && player.getMetadata("Pos1World").get(0).asString().equals(player.getLocation().getWorld().getName())) { player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Your currently selected area has been shown, it will dissapear shortly!"); - Selection.Show(player, this.plugin); - } else { - player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The points you have selected need to be in the same world!"); + Selection.Show(player, this.plugin, null); } } else { - player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to have both points selected!"); + player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No regions selected!"); } } case "reload": diff --git a/src/com/sekwah/advancedportals/Selection.java b/src/com/sekwah/advancedportals/Selection.java index 28d1e0de..d617ca11 100644 --- a/src/com/sekwah/advancedportals/Selection.java +++ b/src/com/sekwah/advancedportals/Selection.java @@ -34,85 +34,6 @@ public class Selection { @SuppressWarnings("deprecation") public static void Show(final Player player, final AdvancedPortalsPlugin plugin, String portalName) { - ConfigAccessor portalConfig = new ConfigAccessor(plugin, "portals.yml"); - - int LowX = portalConfig.getConfig().getInt(portalName + ".pos2.X"); - int LowY = portalConfig.getConfig().getInt(portalName + ".pos2.Y"); - int LowZ = portalConfig.getConfig().getInt(portalName + ".pos2.Z"); - - int HighX = portalConfig.getConfig().getInt(portalName + ".pos1.X"); - int HighY = portalConfig.getConfig().getInt(portalName + ".pos1.Y"); - int HighZ = portalConfig.getConfig().getInt(portalName + ".pos1.Z"); - - final Location pos1 = new Location(player.getWorld(), LowX, LowY, LowZ); - final Location pos2 = new Location(player.getWorld(), HighX, HighY, HighZ); - - /* - * There are alot of for loops at the moment, when i find an easier way to do these other that a load of if statements - * then i will change it, but for now its the best way i can think of for doing this. - */ - - for (int x = LowX; x <= HighX; x++) { - Location loc = new Location(player.getWorld(), x, LowY, LowZ); - player.sendBlockChange(loc, blockType, metadata); - } - for (int x = LowX; x <= HighX; x++) { - Location loc = new Location(player.getWorld(), x, LowY, HighZ); - player.sendBlockChange(loc, blockType, metadata); - } - for (int z = LowZ; z <= HighZ; z++) { - Location loc = new Location(player.getWorld(), LowX, LowY, z); - player.sendBlockChange(loc, blockType, metadata); - } - for (int z = LowZ; z <= HighZ; z++) { - Location loc = new Location(player.getWorld(), HighX, LowY, z); - player.sendBlockChange(loc, blockType, metadata); - } - for (int y = LowY; y <= HighY; y++) { - Location loc = new Location(player.getWorld(), LowX, y, LowZ); - player.sendBlockChange(loc, blockType, metadata); - } - for (int y = LowY; y <= HighY; y++) { - Location loc = new Location(player.getWorld(), LowX, y, HighZ); - player.sendBlockChange(loc, blockType, metadata); - } - for (int y = LowY; y <= HighY; y++) { - Location loc = new Location(player.getWorld(), HighX, y, LowZ); - player.sendBlockChange(loc, blockType, metadata); - } - for (int y = LowY; y <= HighY; y++) { - Location loc = new Location(player.getWorld(), HighX, y, HighZ); - player.sendBlockChange(loc, blockType, metadata); - } - for (int x = LowX; x <= HighX; x++) { - Location loc = new Location(player.getWorld(), x, HighY, HighZ); - player.sendBlockChange(loc, blockType, metadata); - } - for (int x = LowX; x <= HighX; x++) { - Location loc = new Location(player.getWorld(), x, HighY, LowZ); - player.sendBlockChange(loc, blockType, metadata); - } - for (int z = LowZ; z <= HighZ; z++) { - Location loc = new Location(player.getWorld(), LowX, HighY, z); - player.sendBlockChange(loc, blockType, metadata); - } - for (int z = LowZ; z <= HighZ; z++) { - Location loc = new Location(player.getWorld(), HighX, HighY, z); - player.sendBlockChange(loc, blockType, metadata); - } - - - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - public void run() { - Selection.Hide(player, plugin, pos1, pos2); - } - }, timeout * 20); - - } - - @SuppressWarnings("deprecation") - public static void Show(final Player player, final AdvancedPortalsPlugin plugin) { - int LowX = 0; int LowY = 0; int LowZ = 0; @@ -121,31 +42,43 @@ public class Selection { int HighY = 0; int HighZ = 0; - if (player.getMetadata("Pos1X").get(0).asInt() > player.getMetadata("Pos2X").get(0).asInt()) { - LowX = player.getMetadata("Pos2X").get(0).asInt(); - HighX = player.getMetadata("Pos1X").get(0).asInt(); + if (portalName != null) { + ConfigAccessor portalConfig = new ConfigAccessor(plugin, "portals.yml"); + + LowX = portalConfig.getConfig().getInt(portalName + ".pos2.X"); + LowY = portalConfig.getConfig().getInt(portalName + ".pos2.Y"); + LowZ = portalConfig.getConfig().getInt(portalName + ".pos2.Z"); + + HighX = portalConfig.getConfig().getInt(portalName + ".pos1.X"); + HighY = portalConfig.getConfig().getInt(portalName + ".pos1.Y"); + HighZ = portalConfig.getConfig().getInt(portalName + ".pos1.Z"); } else { - LowX = player.getMetadata("Pos1X").get(0).asInt(); - HighX = player.getMetadata("Pos2X").get(0).asInt(); - } - if (player.getMetadata("Pos1Y").get(0).asInt() > player.getMetadata("Pos2Y").get(0).asInt()) { - LowY = player.getMetadata("Pos2Y").get(0).asInt(); - HighY = player.getMetadata("Pos1Y").get(0).asInt(); - } else { - LowY = player.getMetadata("Pos1Y").get(0).asInt(); - HighY = player.getMetadata("Pos2Y").get(0).asInt(); - } - if (player.getMetadata("Pos1Z").get(0).asInt() > player.getMetadata("Pos2Z").get(0).asInt()) { - LowZ = player.getMetadata("Pos2Z").get(0).asInt(); - HighZ = player.getMetadata("Pos1Z").get(0).asInt(); - } else { - LowZ = player.getMetadata("Pos1Z").get(0).asInt(); - HighZ = player.getMetadata("Pos2Z").get(0).asInt(); + if (player.getMetadata("Pos1X").get(0).asInt() > player.getMetadata("Pos2X").get(0).asInt()) { + LowX = player.getMetadata("Pos2X").get(0).asInt(); + HighX = player.getMetadata("Pos1X").get(0).asInt(); + } else { + LowX = player.getMetadata("Pos1X").get(0).asInt(); + HighX = player.getMetadata("Pos2X").get(0).asInt(); + } + if (player.getMetadata("Pos1Y").get(0).asInt() > player.getMetadata("Pos2Y").get(0).asInt()) { + LowY = player.getMetadata("Pos2Y").get(0).asInt(); + HighY = player.getMetadata("Pos1Y").get(0).asInt(); + } else { + LowY = player.getMetadata("Pos1Y").get(0).asInt(); + HighY = player.getMetadata("Pos2Y").get(0).asInt(); + } + if (player.getMetadata("Pos1Z").get(0).asInt() > player.getMetadata("Pos2Z").get(0).asInt()) { + LowZ = player.getMetadata("Pos2Z").get(0).asInt(); + HighZ = player.getMetadata("Pos1Z").get(0).asInt(); + } else { + LowZ = player.getMetadata("Pos1Z").get(0).asInt(); + HighZ = player.getMetadata("Pos2Z").get(0).asInt(); + } } final Location pos1 = new Location(player.getWorld(), LowX, LowY, LowZ); final Location pos2 = new Location(player.getWorld(), HighX, HighY, HighZ); - + /* * There are alot of for loops at the moment, when i find an easier way to do these other that a load of if statements * then i will change it, but for now its the best way i can think of for doing this.