From 332d722ed7e915bcdd3ab71778d98e66ba1d29af Mon Sep 17 00:00:00 2001 From: sekwah41 Date: Fri, 2 Feb 2018 09:31:44 +0000 Subject: [PATCH] added extra info to world locations --- Resources/lang/en_GB.lang | 1 + .../advancedportals/core/api/managers/PortalManager.java | 8 ++++++-- .../sekwah/advancedportals/core/data/PlayerLocation.java | 4 +++- .../sekwah/advancedportals/core/data/PortalLocation.java | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Resources/lang/en_GB.lang b/Resources/lang/en_GB.lang index 6290752..85b7e51 100644 --- a/Resources/lang/en_GB.lang +++ b/Resources/lang/en_GB.lang @@ -55,6 +55,7 @@ command.selector.detailedhelp=Gives you a portal selector to select the regions portal.invalidselection=You must have both pos1 and pos2 selected to create a portal. portal.noname=No name for the portal has been given. portal.takenname=The name given for the portal is already taken. +portal.selection.differentworlds=Both the selected points need to be in the same world. portal.selector.poschange=\u00A7eYou have selected pos%1$s X:%2$s Y:%3$s Z:%4$s diff --git a/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java b/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java index 251dc73..2c00561 100644 --- a/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java +++ b/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java @@ -136,8 +136,12 @@ public class PortalManager { int minY = Math.min(loc1.posY, loc2.posY); int minZ = Math.min(loc1.posZ, loc2.posZ); - PortalLocation maxLoc = new PortalLocation(maxX, maxY, maxZ); - PortalLocation minLoc = new PortalLocation(minX, minY, minZ); + if(!loc1.worldName.equalsIgnoreCase(loc2.worldName)) { + throw new PortalException(Lang.translate("portal.selection.differentworlds")); + } + + PortalLocation maxLoc = new PortalLocation(loc1.worldName, maxX, maxY, maxZ); + PortalLocation minLoc = new PortalLocation(loc1.worldName, minX, minY, minZ); AdvancedPortal portal = new AdvancedPortal(maxLoc, minLoc); for(PortalTag portalTag : tags) { diff --git a/src/com/sekwah/advancedportals/core/data/PlayerLocation.java b/src/com/sekwah/advancedportals/core/data/PlayerLocation.java index 88ad306..03532c0 100644 --- a/src/com/sekwah/advancedportals/core/data/PlayerLocation.java +++ b/src/com/sekwah/advancedportals/core/data/PlayerLocation.java @@ -5,8 +5,10 @@ public class PlayerLocation { public final double posX; public final double posY; public final double posZ; + public final String worldName; - public PlayerLocation(double posX, double posY, double posZ) { + public PlayerLocation(String worldName, double posX, double posY, double posZ) { + this.worldName = worldName; this.posX = posX; this.posY = posY; this.posZ = posZ; diff --git a/src/com/sekwah/advancedportals/core/data/PortalLocation.java b/src/com/sekwah/advancedportals/core/data/PortalLocation.java index 36388a5..70b0cf2 100644 --- a/src/com/sekwah/advancedportals/core/data/PortalLocation.java +++ b/src/com/sekwah/advancedportals/core/data/PortalLocation.java @@ -5,8 +5,10 @@ public class PortalLocation { public final int posX; public final int posY; public final int posZ; + public final String worldName; - public PortalLocation(int posX, int posY, int posZ) { + public PortalLocation(String worldName, int posX, int posY, int posZ) { + this.worldName = worldName; this.posX = posX; this.posY = posY; this.posZ = posZ;