mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2025-01-27 10:31:34 +01:00
Show selected portal and deduplicate code
This commit is contained in:
parent
14ccbbcd0f
commit
4fd0275d3a
@ -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":
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user