From b9259280dd75b7edbef6ba191a10b493e912717e Mon Sep 17 00:00:00 2001 From: Amaury Carrade Date: Sun, 12 Mar 2017 20:05:32 +0100 Subject: [PATCH] Improved help files and used flags instead of double commands. * NEW: improved help files, by adding missing helps and fixing display of others. * NEW: there is now only one deletion command with a --confirm flag, leading to a less-confusing help for players. * BUG: removed a very old Workers API test (from before zLib!). I feel a little sorry for him but eh, that's the rules. * BUG: fixed untranlated title in the map details GUI. --- .../fr/moribus/imageonmap/ImageOnMap.java | 6 +- ...ConfirmCommand.java => DeleteCommand.java} | 46 ++++++++--- .../maptool/DeleteConfirmCommand.java | 61 --------------- .../moribus/imageonmap/gui/MapDetailGui.java | 4 +- .../image/ImageRendererExecutor.java | 15 +--- src/main/resources/help/maptool.txt | 2 + .../help/maptool/delete-noconfirm.txt | 4 - src/main/resources/help/maptool/delete.txt | 11 ++- src/main/resources/help/maptool/explore.txt | 8 ++ src/main/resources/help/maptool/get.txt | 2 +- .../resources/help/maptool/getremaining.txt | 10 ++- src/main/resources/help/maptool/migrate.txt | 78 +++++++++++-------- src/main/resources/help/maptool/new.txt | 7 +- src/main/resources/i18n/fr_FR.po | 6 +- 14 files changed, 120 insertions(+), 140 deletions(-) rename src/main/java/fr/moribus/imageonmap/commands/maptool/{DeleteNoConfirmCommand.java => DeleteCommand.java} (54%) delete mode 100644 src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteConfirmCommand.java delete mode 100644 src/main/resources/help/maptool/delete-noconfirm.txt create mode 100644 src/main/resources/help/maptool/explore.txt diff --git a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java index 428b00d..f16aa90 100644 --- a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java +++ b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java @@ -18,8 +18,7 @@ package fr.moribus.imageonmap; -import fr.moribus.imageonmap.commands.maptool.DeleteConfirmCommand; -import fr.moribus.imageonmap.commands.maptool.DeleteNoConfirmCommand; +import fr.moribus.imageonmap.commands.maptool.DeleteCommand; import fr.moribus.imageonmap.commands.maptool.ExploreCommand; import fr.moribus.imageonmap.commands.maptool.GetCommand; import fr.moribus.imageonmap.commands.maptool.GetRemainingCommand; @@ -104,8 +103,7 @@ public final class ImageOnMap extends ZPlugin NewCommand.class, ListCommand.class, GetCommand.class, - DeleteConfirmCommand.class, - DeleteNoConfirmCommand.class, + DeleteCommand.class, GetRemainingCommand.class, ExploreCommand.class, MigrateCommand.class diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteNoConfirmCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteCommand.java similarity index 54% rename from src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteNoConfirmCommand.java rename to src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteCommand.java index 6c21183..9b3e1b0 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteNoConfirmCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteCommand.java @@ -24,31 +24,54 @@ import fr.moribus.imageonmap.map.MapManager; import fr.moribus.imageonmap.map.MapManagerException; import fr.zcraft.zlib.components.commands.CommandException; import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.commands.WithFlags; import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.components.rawtext.RawText; import fr.zcraft.zlib.tools.PluginLogger; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; import java.util.List; - -@CommandInfo (name = "delete-noconfirm", usageParameters = "[map name]") -public class DeleteNoConfirmCommand extends IoMCommand +@CommandInfo (name = "delete", usageParameters = " [--confirm]") +@WithFlags ({"confirm"}) +public class DeleteCommand extends IoMCommand { @Override protected void run() throws CommandException { - Player player = playerSender(); ImageMap map = getMapFromArgs(); - MapManager.clear(player.getInventory(), map); - try + + if (!hasFlag("confirm")) { - MapManager.deleteMap(map); - info(I.t("Map successfully deleted.")); + RawText msg = new RawText(I.t("You are going to delete") + " ") + .then(map.getId()) + .color(ChatColor.GOLD) + .then(". " + I.t("Are you sure ? ")) + .color(ChatColor.WHITE) + .then(I.t("[Confirm]")) + .color(ChatColor.GREEN) + .hover(new RawText(I.t("{red}This map will be deleted {bold}forever{red}!"))) + .command(getClass(), map.getId(), "--confirm") + .build(); + + send(msg); } - catch (MapManagerException ex) + else { - PluginLogger.warning("A non-existent map was requested to be deleted", ex); - warning(I.t("This map does not exist.")); + Player player = playerSender(); + MapManager.clear(player.getInventory(), map); + + try + { + MapManager.deleteMap(map); + info(I.t("Map successfully deleted.")); + } + catch (MapManagerException ex) + { + PluginLogger.warning("A non-existent map was requested to be deleted", ex); + warning(I.t("This map does not exist.")); + } } } @@ -57,6 +80,7 @@ public class DeleteNoConfirmCommand extends IoMCommand { if(args.length == 1) return getMatchingMapNames(playerSender(), args[0]); + return null; } } diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteConfirmCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteConfirmCommand.java deleted file mode 100644 index d7c169b..0000000 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteConfirmCommand.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2013 Moribus - * Copyright (C) 2015 ProkopyL - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package fr.moribus.imageonmap.commands.maptool; - -import fr.moribus.imageonmap.commands.IoMCommand; -import fr.moribus.imageonmap.map.ImageMap; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.rawtext.RawText; -import org.bukkit.ChatColor; - -import java.util.List; - -@CommandInfo (name = "delete", usageParameters = "[tool name]") -public class DeleteConfirmCommand extends IoMCommand -{ - @Override - protected void run() throws CommandException - { - ImageMap map = getMapFromArgs(); - - RawText msg = new RawText(I.t("You are going to delete") + " ") - .then(map.getId()) - .color(ChatColor.GOLD) - .then(". " + I.t("Are you sure ? ")) - .color(ChatColor.WHITE) - .then(I.t("[Confirm]")) - .color(ChatColor.GREEN) - .hover(new RawText(I.t("{red}This map will be deleted {bold}forever{red}!"))) - .command(DeleteNoConfirmCommand.class, map.getId()) - .build(); - - send(msg); - } - - @Override - protected List complete() throws CommandException - { - if(args.length == 1) - return getMatchingMapNames(playerSender(), args[0]); - - return null; - } -} diff --git a/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java b/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java index 10e4454..ecbadaf 100644 --- a/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java +++ b/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java @@ -102,7 +102,7 @@ public class MapDetailGui extends ExplorerGui ); action("delete", getSize() - 6, new ItemStackBuilder(Material.BARRIER) - .title("{red}Delete this image") + .title(I.t("{red}Delete this image")) .longLore(I.t("{gray}Deletes this map {white}forever{gray}. This action cannot be undone!")) .loreLine() .longLore(I.t("{gray}You will be asked to confirm your choice if you click here.")) @@ -118,7 +118,7 @@ public class MapDetailGui extends ExplorerGui action("back", backSlot, new ItemStackBuilder(Material.EMERALD) .title(I.t("{green}« Back")) - .lore(I.t("{gray}Go back to the list.")) + .lore(I.t("{gray}Go back to the list.")) ); } diff --git a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java index a4bb967..390ccdd 100644 --- a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java +++ b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java @@ -42,19 +42,6 @@ import java.util.concurrent.Future; @WorkerAttributes (name = "Image Renderer", queriesMainThread = true) public class ImageRendererExecutor extends Worker { - static public void Test(WorkerCallback callback) - { - submitQuery(new WorkerRunnable() - { - @Override - public Void run() throws Throwable - { - Thread.sleep(5000); - return null; - } - }, callback); - } - static public void Render(final URL url, final boolean scaling, final UUID playerUUID, WorkerCallback callback) { submitQuery(new WorkerRunnable() @@ -70,7 +57,7 @@ public class ImageRendererExecutor extends Worker final int httpCode = httpConnection.getResponseCode(); if((httpCode / 100) != 2) { - throw new IOException(I.t("HTTP error : {0} {1}", httpCode, httpConnection.getResponseMessage())); + throw new IOException(I.t("HTTP error: {0} {1}", httpCode, httpConnection.getResponseMessage())); } } final InputStream stream = connection.getInputStream(); diff --git a/src/main/resources/help/maptool.txt b/src/main/resources/help/maptool.txt index aa87291..8859d51 100644 --- a/src/main/resources/help/maptool.txt +++ b/src/main/resources/help/maptool.txt @@ -5,4 +5,6 @@ delete-noconfirm: Deletes a map. Deletion is permanent and made without confirma get: Gives you a map. getremaining: Gives you the remaining maps that could not fit in your inventory list: Lists all the map you currently have. +explore: Opens a GUI to see and manage your maps. +migrate: Lauches the migration process from V2.7 to V3.x. help : Use help for more information about a command. \ No newline at end of file diff --git a/src/main/resources/help/maptool/delete-noconfirm.txt b/src/main/resources/help/maptool/delete-noconfirm.txt deleted file mode 100644 index 1b3212d..0000000 --- a/src/main/resources/help/maptool/delete-noconfirm.txt +++ /dev/null @@ -1,4 +0,0 @@ -Deletes a map, and removes all parts and copies from your inventory. -§cWARNING: §r THERE WILL BE NO CONFIRMATION. MAP DELETION IS §lPERMANENT§r. - -[map name] : The name of the map you want to delete. \ No newline at end of file diff --git a/src/main/resources/help/maptool/delete.txt b/src/main/resources/help/maptool/delete.txt index 81848b1..e720b88 100644 --- a/src/main/resources/help/maptool/delete.txt +++ b/src/main/resources/help/maptool/delete.txt @@ -1,5 +1,8 @@ -Deletes a map, and removes all parts and copies from your inventory. -As deletion is permanent, a confirmation message will be shown -to the sending player. +Deletes a map, and removes all parts and copies +from your inventory. As deletion is permanent, +a confirmation message will be shown to the player. -[map name] : The name of the map you want to delete. \ No newline at end of file +§6 §rThe name of the map you want to delete. + +§6--confirm §rDeletes directly. §cWARNING§r - THERE WILL BE +NO CONFIRMATION. MAP DELETION IS §lPERMANENT§r. \ No newline at end of file diff --git a/src/main/resources/help/maptool/explore.txt b/src/main/resources/help/maptool/explore.txt new file mode 100644 index 0000000..164884d --- /dev/null +++ b/src/main/resources/help/maptool/explore.txt @@ -0,0 +1,8 @@ +Opens a GUI to list and manage your maps. + +From there, you can: +- list all the maps you rendered on this server; +- get copies of maps you rendered; +- get parts of posters in case of need; +- delete or rename your maps (organization!); +- see your statistics (maps rendered, left...). \ No newline at end of file diff --git a/src/main/resources/help/maptool/get.txt b/src/main/resources/help/maptool/get.txt index 455d44d..c9299a3 100644 --- a/src/main/resources/help/maptool/get.txt +++ b/src/main/resources/help/maptool/get.txt @@ -1,3 +1,3 @@ Gives you a map, by putting it directly in your inventory. - : The name of the map you want to get. \ No newline at end of file +§6 §rThe name of the map you want to get. \ No newline at end of file diff --git a/src/main/resources/help/maptool/getremaining.txt b/src/main/resources/help/maptool/getremaining.txt index 349a233..2a6611d 100644 --- a/src/main/resources/help/maptool/getremaining.txt +++ b/src/main/resources/help/maptool/getremaining.txt @@ -1,5 +1,7 @@ -Gives you the remaining maps that could not fit in your inventory. +Gives you the remaining maps that could not fit in +your inventory. -If you requested a multi-part (poster) map, and all the parts can't fit in -your inventory, then only first ones are given to you, and the remaining -ones are saved. You can then use this command to retreive them. \ No newline at end of file +If you requested a multi-part (poster) map, and all +the parts can't fit in your inventory, then only first +ones are given to you, and the remaining ones are saved. +You can then use this command to retrieve them. \ No newline at end of file diff --git a/src/main/resources/help/maptool/migrate.txt b/src/main/resources/help/maptool/migrate.txt index 6d14df3..6711709 100644 --- a/src/main/resources/help/maptool/migrate.txt +++ b/src/main/resources/help/maptool/migrate.txt @@ -1,36 +1,48 @@ -Migrates the Map database to the new V3.x format, that uses UUIDs -instead of player names to designate players (among other improvements). -Migration runs in a separate thread, therefore its progress can only be +Migrates the Map database to the new V3.x format, +that uses UUIDs instead of player names to designate +players (among other improvements). Migration runs in +a separate thread, therefore its progress can only be watched from the server console. -The migration will run the following steps : - - Checking if there are files to migrate. If not, the migration stops. - - Checking if there are backups from a previous migration. - If there are, the migration stops. - - Loading the old map and poster data to memory. - - Backing up old files and new files, to the backups_pre-v3 and - backups_post-v3 subdirectories respectively. - Backup's integrity are chacked using file size and SHA1 checksum. - If integrity could not be proved, the migration stops. - - Retreiving the UUIDs of the players from Mojang's servers. - - Checking if some UUIDs could not be retreived. - If there are, this means some of your players may have changed names - before the migration started. The plugin will therefore try to retreive - them specifying a time, back when usernames could not be changed. - If some names could still not be matched to their UUIDs, then these are - probably non-paid accounts. - If no UUID has been retreived at all, the migration stops. - §c--- From this step, changes to disk will be made, and you will have to use§r - §c--- backups if you want to revert back from before the migration started.§r - - Merging the old map data with the new one, if there is any - (which can be the case if your player started to use newer - versions of ImageOnMap before the migration started). - - Saving all this merged map data to disk. - - Removing the old map data from their former files, leaving only the data - that could not be migrated due to usernames that could not be matched to - their UUIDs. - Original data is still present in the appropriate backup directory, - just in case. +The migration will run the following steps. -Note that this plugin will NEVER delete nor overwrite any backup directory. -Moving or deleting these backups is left to the administrator's responsibility. \ No newline at end of file +- Checking if there are files to migrate. If not, the + migration stops. +- Checking if there are backups from a previous + migration. If there are, the migration stops. +- Loading the old map and poster data to memory. +- Backing up old files and new files, to the + §7backups_pre-v3§r and §7backups_post-v3§r sub- + directories respectively. Backup's integrity are + checked using file size and SHA1 checksum. If + integrity could not be proved, the migration stops. +- Retrieving the UUIDs of the players from Mojang's + servers. +- Checking if some UUIDs could not be retrieved. + If there are, this means some of your players may + have changed names before the migration started. + The plugin will therefore try to retrieve them + specifying a time, back when usernames could not + be changed. If some names could still not be matched + to their UUIDs, then these are probably non-paid + accounts. If no UUID has been retrieved at all, + the migration stops. + +§c--- From this step, changes to disk will be made,§r +§c--- and you will have to use backups if you want to§r +§c--- revert back from before the migration started.§r + +- Merging the old map data with the new one, if there + is any (which can be the case if your player started + to use newer versions of ImageOnMap before the + migration started). +- Saving all this merged map data to disk. +- Removing the old map data from their former files, + leaving only the data that could not be migrated + due to usernames that could not be matched to their + UUIDs. Original data is still present in the + appropriate backup directory, just in case. + +Note that this plugin will NEVER delete nor overwrite +any backup directory. Moving or deleting these backups +is left to the administrator's responsibility. \ No newline at end of file diff --git a/src/main/resources/help/maptool/new.txt b/src/main/resources/help/maptool/new.txt index 431757e..16e05ba 100644 --- a/src/main/resources/help/maptool/new.txt +++ b/src/main/resources/help/maptool/new.txt @@ -1 +1,6 @@ -Creates a new ImageOnMap. \ No newline at end of file +Creates a new ImageOnMap. + +The URL must point to an image. +If resize is appended, the image will be fit into +one map only. Else, multiple maps will be used as +needed. \ No newline at end of file diff --git a/src/main/resources/i18n/fr_FR.po b/src/main/resources/i18n/fr_FR.po index 7dd9019..643ae82 100644 --- a/src/main/resources/i18n/fr_FR.po +++ b/src/main/resources/i18n/fr_FR.po @@ -188,6 +188,10 @@ msgstr "" "{gray}Cliquez ici pour renommer cette image ; ceci ne sert qu'à votre " "organisation personnelle." +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:105 +msgid "{red}Delete this image" +msgstr "{red}Supprimer cette image" + #: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:106 msgid "" "{gray}Deletes this map {white}forever{gray}. This action cannot be undone!" @@ -308,7 +312,7 @@ msgstr[1] "{white}{0}{gray} cartes restantes" #: src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java:73 #, java-format -msgid "HTTP error : {0} {1}" +msgid "HTTP error: {0} {1}" msgstr "Erreur HTTP : {0} {1}" #: src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java:79