Fixed arg finding

This commit is contained in:
sekwah 2018-02-22 04:25:30 +00:00 committed by Sekwah
parent b6c59ba93d
commit 5f450dad58
6 changed files with 11 additions and 5 deletions

View File

@ -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

View File

@ -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<AdvancedPortal> 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) {

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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()));