From 5f450dad587aacb9921f238a1280899a366430b5 Mon Sep 17 00:00:00 2001 From: sekwah Date: Thu, 22 Feb 2018 04:25:30 +0000 Subject: [PATCH] Fixed arg finding --- Resources/lang/en_GB.lang | 1 + .../advancedportals/core/api/managers/PortalManager.java | 8 ++++++-- .../core/commands/subcommands/CreateSubCommand.java | 2 +- .../commands/subcommands/desti/CreateDestiSubCommand.java | 2 +- .../subcommands/portal/CreatePortalSubCommand.java | 2 +- .../commands/subcommands/portal/RemoveSubCommand.java | 1 + 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Resources/lang/en_GB.lang b/Resources/lang/en_GB.lang index 58f80072..cda0c84e 100644 --- a/Resources/lang/en_GB.lang +++ b/Resources/lang/en_GB.lang @@ -55,6 +55,7 @@ command.remove.error= Removing the portal was blocked: command.remove.noname=No portal by that name was found command.remove.invalidselection=The portal selection you had is no longer valid command.remove.noselection=You don't have a portal selected +command.create.complete= The portal has been successfully removed. command.selector= You have been given a portal selector. command.selector.help=Gives you a portal region selector diff --git a/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java b/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java index 6e2c58bf..fd710913 100644 --- a/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java +++ b/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java @@ -104,7 +104,7 @@ public class PortalManager { return this.createPortal(name, player, this.portalSelectorLeftClick.get(player.getUUID().toString()), this.portalSelectorRightClick.get(player.getUUID().toString()), tags); } else { - throw new PortalException("portal.invalidselection"); + throw new PortalException("portal.error.invalidselection"); } } @@ -220,9 +220,13 @@ public class PortalManager { for(DataTag portalTag : portal.getArgs()) { TagHandler.Creation creation = AdvancedPortalsCore.getPortalTagRegistry().getCreationHandler(portalTag.NAME); - creation.created(portal, player, portalTag.VALUE); + if(creation != null) { + creation.destroyed(portal, player, portalTag.VALUE); + } } + this.portalHashMap.remove(portalName); + AdvancedPortalsCore.getPortalManager().savePortals(); } private AdvancedPortal getPortal(String portalName) { diff --git a/src/com/sekwah/advancedportals/core/commands/subcommands/CreateSubCommand.java b/src/com/sekwah/advancedportals/core/commands/subcommands/CreateSubCommand.java index 468f3acb..d8ab71a8 100644 --- a/src/com/sekwah/advancedportals/core/commands/subcommands/CreateSubCommand.java +++ b/src/com/sekwah/advancedportals/core/commands/subcommands/CreateSubCommand.java @@ -26,7 +26,7 @@ public abstract class CreateSubCommand { else { String detectedTag = this.getTag(args[i].toLowerCase()); if(detectedTag != null) { - String arg = args[i].substring(detectedTag.length()); + String arg = args[i].substring(detectedTag.length() + 1); if(arg.length() > 0 && arg.charAt(0) == '"') { argBeingParsed = detectedTag; currentParsedValue = arg; diff --git a/src/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java b/src/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java index e488e09e..0ce836c6 100644 --- a/src/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java +++ b/src/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java @@ -52,7 +52,7 @@ public class CreateDestiSubCommand extends CreateSubCommand implements SubComman protected String getTag(String arg) { int splitLoc = arg.indexOf(":"); if(splitLoc != -1) { - return arg.substring(0,splitLoc + 1); + return arg.substring(0,splitLoc); } return null; } diff --git a/src/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java b/src/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java index e778ee47..23474b62 100644 --- a/src/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java +++ b/src/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java @@ -49,7 +49,7 @@ public class CreatePortalSubCommand extends CreateSubCommand implements SubComma protected String getTag(String arg) { int splitLoc = arg.indexOf(":"); if(splitLoc != -1) { - return arg.substring(0,splitLoc + 1); + return arg.substring(0,splitLoc); } return null; } diff --git a/src/com/sekwah/advancedportals/core/commands/subcommands/portal/RemoveSubCommand.java b/src/com/sekwah/advancedportals/core/commands/subcommands/portal/RemoveSubCommand.java index 9ce801e0..b0ef588f 100644 --- a/src/com/sekwah/advancedportals/core/commands/subcommands/portal/RemoveSubCommand.java +++ b/src/com/sekwah/advancedportals/core/commands/subcommands/portal/RemoveSubCommand.java @@ -20,6 +20,7 @@ public class RemoveSubCommand implements SubCommand { if(args.length > 1) { try { AdvancedPortalsCore.getPortalManager().removePortal(args[1], sender.getPlayerContainer()); + sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translateColor("command.remove.complete")); } catch (PortalException portalTagExeption) { sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateColor("command.remove.error") + " " + Lang.translate(portalTagExeption.getMessage()));