diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java index 2f1da065..57270c81 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java @@ -52,11 +52,9 @@ public void onCommand(CommandSenderContainer sender, String[] args) { sender.sendMessage(""); sender.sendMessage(Lang.translate("command.create.tags")); - if(destinationTags.isEmpty()) { - sender.sendMessage(Lang.translate("desti.info.noargs")); - } - else { - this.printTags(sender, destinationTags, Tag.TagType.DESTINATION); + if(!destinationTags.isEmpty()) { + this.filterAndProcessTags(destinationTags); + this.printTags(sender, destinationTags); } sender.sendMessage(""); Destination destination = destinationServices.createDesti(player, player.getLoc(), destinationTags); diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java index 9caa6e01..cd24becb 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java @@ -45,7 +45,7 @@ public void onCommand(CommandSenderContainer sender, String[] args) { sender.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("command.create.complete")); sender.sendMessage(Lang.translate("command.create.tags")); sender.sendMessage("\u00A7a" + "triggerBlock\u00A77:\u00A7e" + Arrays.toString(portal.getTriggerBlocks())); - this.printTags(sender, portal.getArgs(), Tag.TagType.PORTAL); + this.printTags(sender, portal.getArgs()); } sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("command.create.error")); } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/reusable/CreateTaggedSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/reusable/CreateTaggedSubCommand.java index de802ae6..559e259d 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/reusable/CreateTaggedSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/reusable/CreateTaggedSubCommand.java @@ -102,7 +102,41 @@ public List onTabComplete(CommandSenderContainer sender, String[] args) return suggestions; } - protected void printTags(CommandSenderContainer sender, List dataTags, Tag.TagType tagType) { + protected void filterAndProcessTags(List dataTags) { + List relatedTags = this.getRelatedTags(); + List processedTags = new ArrayList<>(); + + for (DataTag dataTag : dataTags) { + for (Tag tag : relatedTags) { + if (dataTag.NAME.equals(tag.getName())) { + // DataTag name matches the tag's main name, add as is + processedTags.add(dataTag); + break; + } else if (tag.getAliases() != null && Arrays.asList(tag.getAliases()).contains(dataTag.NAME)) { + // DataTag name matches an alias, create a new DataTag with the main name + processedTags.add(new DataTag(tag.getName(), dataTag.VALUES)); + break; + } + } + } + + // Replace the original dataTags list with the processed tags + dataTags.clear(); + dataTags.addAll(processedTags); + // Sort the tags by name however make sure name is first + dataTags.sort((o1, o2) -> { + if(o1.NAME.equals("name")) { + return -1; + } + if(o2.NAME.equals("name")) { + return 1; + } + return o1.NAME.compareTo(o2.NAME); + }); + } + + + protected void printTags(CommandSenderContainer sender, List dataTags) { for (DataTag tag : dataTags) { if(tag.VALUES.length == 1) { sender.sendMessage(" \u00A7a" + tag.NAME + "\u00A77:\u00A7e" + tag.VALUES[0]); @@ -112,6 +146,5 @@ protected void printTags(CommandSenderContainer sender, List dataTags, } } } - // TODO add a note saying if tags were ignored due to not being valid for the type } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/destination/Destination.java b/core/src/main/java/com/sekwah/advancedportals/core/destination/Destination.java index 0058a72a..cd84d8bd 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/destination/Destination.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/destination/Destination.java @@ -33,7 +33,7 @@ public class Destination implements TagTarget { private PlayerLocation loc; @SerializedName("a") - transient private HashMap args = new HashMap<>(); + private HashMap args = new HashMap<>(); private transient Set argsCol; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/NameTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/NameTag.java index c21225b4..6bed6a64 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/NameTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/NameTag.java @@ -15,7 +15,7 @@ *

* Most tags shouldn't be like this unless they are to be paired with another tag. */ -public class NameTag implements Tag.Activation, Tag.AutoComplete { +public class NameTag implements Tag.AutoComplete { private final TagType[] tagTypes = new TagType[]{ TagType.PORTAL, TagType.DESTINATION }; @@ -39,21 +39,6 @@ public String description() { return Lang.translate("tag.name.description"); } - @Override - public boolean preActivated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) { - return false; - } - - @Override - public void postActivated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) { - - } - - @Override - public boolean activated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) { - return false; - } - @Override public List autoComplete(String argData) { return null; diff --git a/lang/src/main/resources/lang/en_GB.lang b/lang/src/main/resources/lang/en_GB.lang index bb7ce56e..cf28667a 100644 --- a/lang/src/main/resources/lang/en_GB.lang +++ b/lang/src/main/resources/lang/en_GB.lang @@ -109,7 +109,7 @@ desti.error.noname= You must specify a name. (name:someNameHere) error.notplayer=Only players can do that. -portal.selector.poschange=&eYou have selected pos%1$s X:%2$s Y:%3$s Z:%4$s +portal.selector.poschange=&aYou have selected &epos%1$s &aX&7:&e%2$s &aY&7:&e%3$s &aZ&7:&e%4$s command.lang.help=Update the translation file