mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2025-03-12 06:41:12 +01:00
feat: add error messages for the destination commands
This commit is contained in:
parent
013d41d65d
commit
c3e60fa02e
@ -44,9 +44,14 @@ public class CreateDestiSubCommand extends CreateTaggedSubCommand {
|
||||
destinationTags.add(nameTag);
|
||||
}
|
||||
|
||||
if (nameTag == null) {
|
||||
sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("command.error.noname"));
|
||||
return;
|
||||
}
|
||||
|
||||
Destination destination = destinationServices.createDesti(player, player.getLoc(), destinationTags);
|
||||
if(destination != null) {
|
||||
sender.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("command.createdesti.complete"));
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(Lang.translate("command.create.tags"));
|
||||
|
||||
ArrayList<DataTag> destiArgs = destination.getArgs();
|
||||
@ -57,19 +62,21 @@ public class CreateDestiSubCommand extends CreateTaggedSubCommand {
|
||||
else {
|
||||
for (DataTag tag : destiArgs) {
|
||||
if(tag.VALUES.length == 1) {
|
||||
sender.sendMessage("\u00A7a" + tag.NAME + "\u00A77:\u00A7e" + tag.VALUES[0]);
|
||||
sender.sendMessage(" \u00A7a" + tag.NAME + "\u00A77:\u00A7e" + tag.VALUES[0]);
|
||||
} else {
|
||||
sender.sendMessage("\u00A7a" + tag.NAME + "\u00A77:\u00A7e" + tag.VALUES[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("command.createdesti.complete"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("command.createdesti.error"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("command.error.noname"));
|
||||
sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("command.error.noname"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class Destination implements TagTarget {
|
||||
private PlayerLocation loc;
|
||||
|
||||
@SerializedName("a")
|
||||
private HashMap<String, String[]> args = new HashMap<>();
|
||||
transient private HashMap<String, String[]> args = new HashMap<>();
|
||||
|
||||
private transient Set<String> argsCol;
|
||||
|
||||
|
@ -66,16 +66,16 @@ public class DestinationServices {
|
||||
|
||||
// If the name is null, send an error saying that the name is required.
|
||||
if(nameTag == null) {
|
||||
player.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("desti.error.noname"));
|
||||
player.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("desti.error.noname"));
|
||||
return null;
|
||||
}
|
||||
|
||||
if(name == null || name.equals("")) {
|
||||
player.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("desti.error.noname"));
|
||||
player.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("command.error.noname"));
|
||||
return null;
|
||||
}
|
||||
else if(this.destinationRepository.containsKey(name)) {
|
||||
player.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("desti.error.takenname"));
|
||||
player.sendMessage(Lang.translate("messageprefix.negative") + Lang.translateInsertVariables("command.error.nametaken", name));
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -92,8 +92,9 @@ public class DestinationServices {
|
||||
}
|
||||
try {
|
||||
this.destinationRepository.addDestination(name, desti);
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
player.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("desti.error.save"));
|
||||
}
|
||||
this.saveDestinations();
|
||||
return desti;
|
||||
|
@ -67,7 +67,7 @@ command.createdesti.console= You cannot create a destination using the console.
|
||||
command.createdesti.detailedhelp=Format is /desti create (name) [tag:tagvalue] List tags after create in the format tag:value, if your value needs spaces use the format tag:"value with spaces"
|
||||
command.createdesti.complete= The destination has been successfully created.
|
||||
|
||||
command.create.tags=&aTags:
|
||||
command.create.tags=&aTags&e:
|
||||
|
||||
command.playeronly= Sorry but that command can only be run by a player.
|
||||
|
||||
@ -97,11 +97,11 @@ portal.error.selection.differentworlds=Both the selected points need to be in th
|
||||
|
||||
desti.info.noargs=&cNo tags were given
|
||||
|
||||
command.error.noname= No name has been given.
|
||||
command.error.noname= You must specify a name. (name:someNameHere)
|
||||
command.error.notags= No tags have been given. You need to include at least &ename:(name)&c.
|
||||
command.error.nametaken= The name &e%1$s &cis already taken.
|
||||
|
||||
desti.error.takenname=The name given for the portal is already taken.
|
||||
desti.error.noname=You must specify a name for the destination. (name:destinationname)
|
||||
desti.error.save= There was a problem saving the destination:
|
||||
|
||||
error.notplayer=Only players can do that.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user