diff --git a/build.gradle b/build.gradle index ceb89391..38cf0063 100644 --- a/build.gradle +++ b/build.gradle @@ -100,7 +100,7 @@ task copyPlugin() { println "$buildDir/MinecraftServer/plugins/Advanced-Portals-${getVersion()}.jar" try { delete fileTree("$buildDir/MinecraftServer/plugins/") { - include "*.jar" + include "Advanced-Portals*.jar" } } catch (RuntimeException e) { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java index 812e55c1..b02582b8 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java @@ -64,8 +64,9 @@ public void onCommand(CommandSenderContainer sender, String commandExecuted, Str String subCommand = args[1].toLowerCase(); if(this.subCommandRegistry.isArgRegistered(subCommand)) { sender.sendMessage(""); - sender.sendMessage(Lang.translateInsertVariables("command.help.subcommandheader", - command, subCommand)); + var helpTitle = Lang.centeredTitle(Lang.translateInsertVariables("command.help.subcommandheader", + command, helpPage, pages)); + sender.sendMessage(helpTitle); sender.sendMessage("\u00A77" + this.getSubCommand(subCommand).getDetailedHelpText()); } else { @@ -75,8 +76,11 @@ public void onCommand(CommandSenderContainer sender, String commandExecuted, Str } } sender.sendMessage(""); - sender.sendMessage(Lang.translateInsertVariables("command.help.header", + + var helpTitle = Lang.centeredTitle(Lang.translateInsertVariables("command.help.header", command, helpPage, pages)); + + sender.sendMessage(helpTitle); sender.sendMessage("\u00A7a█\u00A77 = Permission \u00A7c█\u00A77 = No Permission"); int subCommandOffset = (helpPage - 1) * this.subCommandsPerPage; int displayEnd = subCommandOffset + this.subCommandsPerPage; 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 47d112bc..eccd3cf6 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 @@ -1,10 +1,13 @@ package com.sekwah.advancedportals.core.commands.subcommands.desti; +import com.google.inject.Inject; import com.sekwah.advancedportals.core.commands.SubCommand; import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; +import com.sekwah.advancedportals.core.destination.Destination; import com.sekwah.advancedportals.core.serializeddata.DataTag; import com.sekwah.advancedportals.core.permissions.PortalPermissions; +import com.sekwah.advancedportals.core.services.DestinationServices; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.TagReader; @@ -13,6 +16,9 @@ public class CreateDestiSubCommand implements SubCommand { + @Inject + DestinationServices destinationServices; + @Override public void onCommand(CommandSenderContainer sender, String[] args) { if(args.length > 1) { @@ -21,25 +27,31 @@ public void onCommand(CommandSenderContainer sender, String[] args) { sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("command.createdesti.console")); return; } - ArrayList destiTags = TagReader.getTagsFromArgs(args); - // TODO sort desti service - /*Destination desti = AdvancedPortalsCore.getDestinationServices().createDesti(args[1], player, player.getLoc(), destiTags); - if(desti != null) { - sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translateColor("command.createdesti.complete")); - sender.sendMessage(Lang.translateColor("command.create.tags")); - ArrayList destiArgs = desti.getArgs(); - if(destiArgs.size() == 0) { - sender.sendMessage(Lang.translateColor("desti.info.noargs")); + ArrayList destinationTags = TagReader.getTagsFromArgs(args); + + Destination destination = destinationServices.createDesti(args[1], player, player.getLoc(), destinationTags); + if(destination != null) { + sender.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("command.createdesti.complete")); + sender.sendMessage(Lang.translate("command.create.tags")); + + ArrayList destiArgs = destination.getArgs(); + + if(destiArgs.isEmpty()) { + sender.sendMessage(Lang.translate("desti.info.noargs")); } else { for (DataTag tag : destiArgs) { - sender.sendMessage("\u00A7a" + tag.NAME + "\u00A77:\u00A7e" + tag.VALUE); + if(tag.VALUES.length == 1) { + sender.sendMessage("\u00A7a" + tag.NAME + "\u00A77:\u00A7e" + tag.VALUES[0]); + } else { + sender.sendMessage("\u00A7a" + tag.NAME + "\u00A77:\u00A7e" + tag.VALUES[0]); + } } } } else { - sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateColor("command.createdesti.error")); - }*/ + sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("command.createdesti.error")); + } } else { sender.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("command.error.noname")); 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 706caeeb..4b0548ca 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 @@ -10,7 +10,7 @@ public class NameTag implements Tag.Activation, Tag.AutoComplete { - private final TagType[] tagTypes = new TagType[]{ TagType.PORTAL }; + private final TagType[] tagTypes = new TagType[]{ TagType.PORTAL, TagType.DESTINATION }; @Override public TagType[] getTagTypes() { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/util/Lang.java b/core/src/main/java/com/sekwah/advancedportals/core/util/Lang.java index 19a0b011..80f349aa 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/util/Lang.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/util/Lang.java @@ -74,6 +74,38 @@ public Map getInternalLanguageMap(String fileName) { return Collections.emptyMap(); } + /** + * Length of text excluding colour codes + * @param text + * @return + */ + public static int textLength(String text) { + int length = 0; + for (int i = 0; i < text.length(); i++) { + char c = text.charAt(i); + if(c == '\u00A7') { + i++; + } + else { + length++; + } + } + return length; + } + + /** + * The default font is not monospaced, so this will likely be a little thinner to be on the safe side + * @param title + * @return + */ + public static String centeredTitle(String title) { + var titleLength = 54 - (Lang.textLength(title)); + + int eachSide = titleLength / 2; + + return "\u00A7e" + "=".repeat(eachSide) + " " + title + " \u00A7e" + "=".repeat(eachSide); + } + private void injectTranslations(String fileName) { try { URL url = Lang.instance.getClass().getClassLoader().getResource("lang/" + fileName + ".lang"); diff --git a/lang/src/main/resources/lang/de_DE.lang b/lang/src/main/resources/lang/de_DE.lang index cd3ec989..533d8786 100644 --- a/lang/src/main/resources/lang/de_DE.lang +++ b/lang/src/main/resources/lang/de_DE.lang @@ -49,8 +49,8 @@ logger.plugincrafterror=Diese Version von Craftbukkit/Spigot wird derzeit nicht command.noargs= Du musst einen Sub-Command angeben. Bitte benutze &e/%1$s help &c. Falls du eine Liste von möglichen Sub_Command willst. command.subcommand.invalid= Das ist ein ungültiger Sub-Command. -command.help.header=&e--------------- &a%1$s Hilfe - Seite %2$s of %3$s&e --------------- -command.help.subcommandheader=&e--------- &a%1$s Hilfe - %2$s&e --------- +command.help.header=&a%1$s Hilfe - Seite %2$s of %3$s +command.help.subcommandheader=&a%1$s Hilfe - %2$s command.help.invalidhelp= &e%1$s&c ist keine gültige Seitennummer oder Sub-Command. command.reload.help=Ladet die Portal-Dateien neu diff --git a/lang/src/main/resources/lang/en_GB.lang b/lang/src/main/resources/lang/en_GB.lang index f24672e3..6e13128f 100644 --- a/lang/src/main/resources/lang/en_GB.lang +++ b/lang/src/main/resources/lang/en_GB.lang @@ -47,8 +47,8 @@ logger.plugincrafterror=This version of craftbukkit is not yet supported or some command.noargs= Sorry but you need to specify a sub command, please use &e/%1$s help &cif you would like a list of possible subcommands. command.subcommand.invalid= Sorry but that is not a valid sub command. -command.help.header=&e--------------- &a%1$s Help - Page %2$s of %3$s&e --------------- -command.help.subcommandheader=&e--------- &a%1$s Help - %2$s&e --------- +command.help.header=&a%1$s Help - Page %2$s of %3$s +command.help.subcommandheader=&a%1$s Help - %2$s command.help.invalidhelp= Sorry but &e%1$s&c is not a valid page number or sub command. command.reload.help=Reloads portal data diff --git a/lang/src/main/resources/lang/fr_FR.lang b/lang/src/main/resources/lang/fr_FR.lang index 66568196..6de96568 100644 --- a/lang/src/main/resources/lang/fr_FR.lang +++ b/lang/src/main/resources/lang/fr_FR.lang @@ -46,8 +46,8 @@ logger.plugincrafterror=Cette version craftbukkit n'est pas supportée, veuillez command.noargs= Vous devez spécifier une sous commande, utilisez &e/%1$s help &cpour avoir la liste des commandes possibles. command.subcommand.invalid= Ce n'est pas une sous commande. -command.help.header=&e--------------- &a%1$s Aide - Page %2$s sur %3$s&e --------------- -command.help.subcommandheader=&e--------- &a%1$s Aide - %2$s&e --------- +command.help.header=&a%1$s Aide - Page %2$s sur %3$s +command.help.subcommandheader=&a%1$s Aide - %2$s command.help.invalidhelp= Désolé mais &e%1$s&c n'est pas une page ou sous commande valide. command.reload.help=Recharge les fichiers diff --git a/lang/src/main/resources/lang/hu_HU.lang b/lang/src/main/resources/lang/hu_HU.lang index f87df5d5..10c43435 100644 --- a/lang/src/main/resources/lang/hu_HU.lang +++ b/lang/src/main/resources/lang/hu_HU.lang @@ -46,8 +46,8 @@ logger.plugincrafterror=A craftbukkit ezen verziója még nem támogatott, vagy command.noargs= Sajnálom, de meg kell adni egy al parancsot, kérlek, használd &e/%1$s help &cha a lehetséges al parancsok listáját szeretnéd látni. command.subcommand.invalid= Sajnáljuk, de ez nem érvényes al parancs. -command.help.header=&e--------------- &a%1$s Segítség - Oldal %2$s %3$s&e-ból/-ből --------------- -command.help.subcommandheader=&e--------- &a%1$s Segítség - %2$s&e --------- +command.help.header=&a%1$s Segítség - Oldal %2$s %3$s&e-ból/-ből +command.help.subcommandheader=&a%1$s Segítség - %2$s command.help.invalidhelp= Sajnálom, de &e%1$s&c nem érvényes oldalszám vagy al parancs. command.reload.help=Portál adat újratöltése