From 370113b5241d4aed7ddbcf31a761aecea51c9cb3 Mon Sep 17 00:00:00 2001 From: NoahTheGoodra Date: Fri, 6 Oct 2017 11:39:39 -0500 Subject: [PATCH 01/44] Add Rename Command Signed-off-by: NoahTheGoodra --- .../fr/moribus/imageonmap/ImageOnMap.java | 11 ++--- .../commands/maptool/RenameCommand.java | 48 +++++++++++++++++++ 2 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 src/main/java/fr/moribus/imageonmap/commands/maptool/RenameCommand.java diff --git a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java index f16aa90..92ea105 100644 --- a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java +++ b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java @@ -18,13 +18,7 @@ package fr.moribus.imageonmap; -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; -import fr.moribus.imageonmap.commands.maptool.ListCommand; -import fr.moribus.imageonmap.commands.maptool.MigrateCommand; -import fr.moribus.imageonmap.commands.maptool.NewCommand; +import fr.moribus.imageonmap.commands.maptool.*; import fr.moribus.imageonmap.image.ImageIOExecutor; import fr.moribus.imageonmap.image.ImageRendererExecutor; import fr.moribus.imageonmap.image.MapInitEvent; @@ -106,7 +100,8 @@ public final class ImageOnMap extends ZPlugin DeleteCommand.class, GetRemainingCommand.class, ExploreCommand.class, - MigrateCommand.class + MigrateCommand.class, + RenameCommand.class ); Commands.registerShortcut("maptool", NewCommand.class, "tomap"); diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/RenameCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/RenameCommand.java new file mode 100644 index 0000000..36f8be5 --- /dev/null +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/RenameCommand.java @@ -0,0 +1,48 @@ +/* + * 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 java.util.List; + +@CommandInfo(name = "rename",usageParameters = " ") +public class RenameCommand extends IoMCommand { + @Override + protected void run() throws CommandException + { + if(args.length == 2) + { + ImageMap map = getMapFromArgs(); + map.rename(args[1]); + } else { + info("Not Enough Or To Many Arguments"); + } + } + @Override + protected List complete() throws CommandException + { + if(args.length == 1) + return getMatchingMapNames(playerSender(), args[0]); + return null; + } +} From 4885198888b5cb09c047823eddba468da4bfce20 Mon Sep 17 00:00:00 2001 From: kirbykirby56 Date: Sat, 24 Mar 2018 20:46:32 -0400 Subject: [PATCH 02/44] Add administrative commands --- .../fr/moribus/imageonmap/ImageOnMap.java | 22 +++- .../fr/moribus/imageonmap/Permissions.java | 7 +- .../commands/maptool/DebugCommand.java | 41 ++++++ .../commands/maptool/DeleteOtherCommand.java | 98 ++++++++++++++ .../commands/maptool/GetOtherCommand.java | 80 +++++++++++ .../commands/maptool/ListOtherCommand.java | 124 ++++++++++++++++++ .../fr/moribus/imageonmap/map/ImageMap.java | 8 +- .../fr/moribus/imageonmap/map/MapManager.java | 3 +- .../imageonmap/map/PlayerMapStore.java | 3 +- src/main/resources/config.yml | 9 ++ src/main/resources/help/maptool.txt | 1 + src/main/resources/help/maptool/getother.txt | 4 + src/main/resources/help/maptool/listother.txt | 1 + 13 files changed, 390 insertions(+), 11 deletions(-) create mode 100644 src/main/java/fr/moribus/imageonmap/commands/maptool/DebugCommand.java create mode 100644 src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java create mode 100644 src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java create mode 100644 src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java create mode 100644 src/main/resources/help/maptool/getother.txt create mode 100644 src/main/resources/help/maptool/listother.txt diff --git a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java index f16aa90..cd3f22a 100644 --- a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java +++ b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java @@ -18,13 +18,17 @@ package fr.moribus.imageonmap; +import fr.moribus.imageonmap.commands.maptool.DebugCommand; 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; +import fr.moribus.imageonmap.commands.maptool.DeleteOtherCommand; import fr.moribus.imageonmap.commands.maptool.ListCommand; +import fr.moribus.imageonmap.commands.maptool.ListOtherCommand; import fr.moribus.imageonmap.commands.maptool.MigrateCommand; import fr.moribus.imageonmap.commands.maptool.NewCommand; +import fr.moribus.imageonmap.commands.maptool.GetCommand; +import fr.moribus.imageonmap.commands.maptool.GetRemainingCommand; +import fr.moribus.imageonmap.commands.maptool.GetOtherCommand; +import fr.moribus.imageonmap.commands.maptool.ExploreCommand; import fr.moribus.imageonmap.image.ImageIOExecutor; import fr.moribus.imageonmap.image.ImageRendererExecutor; import fr.moribus.imageonmap.image.MapInitEvent; @@ -41,12 +45,12 @@ import fr.zcraft.zlib.tools.PluginLogger; import java.io.File; import java.io.IOException; + public final class ImageOnMap extends ZPlugin { static private final String IMAGES_DIRECTORY_NAME = "images"; static private final String MAPS_DIRECTORY_NAME = "maps"; static private ImageOnMap plugin; - private File imagesDirectory; private final File mapsDirectory; @@ -69,6 +73,7 @@ public final class ImageOnMap extends ZPlugin return new File(imagesDirectory, "map"+mapID+".png"); } + @SuppressWarnings ("unchecked") @Override public void onEnable() @@ -85,11 +90,12 @@ public final class ImageOnMap extends ZPlugin this.setEnabled(false); return; } - + + saveDefaultConfig(); loadComponents(I18n.class, Gui.class, Commands.class, PluginConfiguration.class, ImageIOExecutor.class, ImageRendererExecutor.class); - + //Init all the things ! MetricsLite.startMetrics(); I18n.setPrimaryLocale(PluginConfiguration.LANG.get()); @@ -101,8 +107,12 @@ public final class ImageOnMap extends ZPlugin Commands.register( "maptool", NewCommand.class, + DebugCommand.class, ListCommand.class, GetCommand.class, + GetOtherCommand.class, + ListOtherCommand.class, + DeleteOtherCommand.class, DeleteCommand.class, GetRemainingCommand.class, ExploreCommand.class, diff --git a/src/main/java/fr/moribus/imageonmap/Permissions.java b/src/main/java/fr/moribus/imageonmap/Permissions.java index abaa110..ba6c552 100644 --- a/src/main/java/fr/moribus/imageonmap/Permissions.java +++ b/src/main/java/fr/moribus/imageonmap/Permissions.java @@ -1,5 +1,5 @@ /* - * Copyright or © or Copr. AmauryCarrade (2015) + * Copyright or or Copr. AmauryCarrade (2015) * * http://amaury.carrade.eu * @@ -38,9 +38,12 @@ public enum Permissions { NEW("imageonmap.new", "imageonmap.userender"), LIST("imageonmap.list"), + LISTOTHER("imageonmap.listother"), GET("imageonmap.get"), + GETOTHER("imageonmap.getother"), RENAME("imageonmap.rename"), DELETE("imageonmap.delete"), + DELETEOTHER("imageonmap.deleteother"), ADMINISTRATIVE("imageonmap.administrative") ; @@ -72,4 +75,4 @@ public enum Permissions return false; } -} +} \ No newline at end of file diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/DebugCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/DebugCommand.java new file mode 100644 index 0000000..9d43270 --- /dev/null +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/DebugCommand.java @@ -0,0 +1,41 @@ +/* + * 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.PluginConfiguration; +import fr.moribus.imageonmap.commands.IoMCommand; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import org.bukkit.entity.Player; + +@CommandInfo (name = "debug") +public class DebugCommand extends IoMCommand +{ + @Override + protected void run() throws CommandException + { + Player p = playerSender(); + p.sendMessage("Limit Map Size X" + PluginConfiguration.LIMIT_SIZE_X.get().toString()); + p.sendMessage("Limit Map Size Y" + PluginConfiguration.LIMIT_SIZE_Y.get().toString()); + p.sendMessage("Global Map Limit" + PluginConfiguration.MAP_GLOBAL_LIMIT.get().toString()); + p.sendMessage("Player Map Limit" + PluginConfiguration.MAP_PLAYER_LIMIT.get().toString()); + p.sendMessage("Collect Data" + PluginConfiguration.COLLECT_DATA.get().toString()); + p.sendMessage("Save Full Image" + PluginConfiguration.SAVE_FULL_IMAGE.get().toString()); + } +} diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java new file mode 100644 index 0000000..7f95328 --- /dev/null +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java @@ -0,0 +1,98 @@ +/* + * 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.Permissions; +import fr.moribus.imageonmap.commands.IoMCommand; +import fr.moribus.imageonmap.map.ImageMap; +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.tools.PluginLogger; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.UUID; + +@CommandInfo (name = "deleteother", usageParameters = " ") +@WithFlags ({"confirm"}) +public class DeleteOtherCommand extends IoMCommand +{ + @Override + protected void run() throws CommandException + { + if(args.length < 2) warning(I.t("Not enough parameters! Usage: /maptool deleteother ")); + if(!playerSender().hasPermission("imageonmap.delete.other")) { + warning(I.t("You do not have permission for this command. (imageonmap.delete.other)")); + return; + } + + Player player = null; + UUID uuid = null; + OfflinePlayer op = null; + player = Bukkit.getPlayer(args[0]); + if(player == null){ + op = Bukkit.getOfflinePlayer(args[0]); + if(op.hasPlayedBefore()) uuid = op.getUniqueId(); + else warning(I.t("We've never seen that player before!")); + } + else uuid = player.getUniqueId(); + String mapName = ""; + mapName = args[1]; + if(args.length > 2) for(int i = 2; i < args.length; i++) mapName += (" " + args[i - 1]); + + ImageMap map = MapManager.getMap(uuid, mapName); + + if(player != null) MapManager.clear(player.getInventory(), map); + //if(player == null) MapManager.clear(op.getPlayer().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.")); + } + } + + + @Override + protected List complete() throws CommandException + { + if(args.length == 1) + return getMatchingMapNames(playerSender(), args[0]); + + return null; + } + @Override + public boolean canExecute(CommandSender sender) + { + return Permissions.DELETEOTHER.grantedTo(sender); + } +} diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java new file mode 100644 index 0000000..d8529d5 --- /dev/null +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java @@ -0,0 +1,80 @@ +/* + * 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 java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import fr.moribus.imageonmap.Permissions; +import fr.moribus.imageonmap.commands.IoMCommand; +import fr.moribus.imageonmap.map.ImageMap; +import fr.moribus.imageonmap.map.MapManager; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; + + +@CommandInfo (name = "getother", usageParameters = " ") +public class GetOtherCommand extends IoMCommand +{ + @SuppressWarnings("deprecation") + @Override + protected void run() throws CommandException + { + if(args.length < 2) warning(I.t("Not enough parameters! Usage: /maptool getother ")); + //Deny those who do not have permission. + if(!playerSender().hasPermission("imageonmap.get.other")) { + warning(I.t("You do not have permission for this command. (imageonmap.get.other)")); + return; + } + + Player player = null; + UUID uuid = null; + player = Bukkit.getPlayer(args[0]); + if(player == null){ + OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]); + if(op.hasPlayedBefore()) uuid = op.getUniqueId(); + else warning(I.t("We've never seen that player before!")); + } + else { + uuid = player.getUniqueId(); + } + ImageMap map = null; + String mapName = ""; + mapName = args[1]; + if(args.length > 2) { + for(int i = 2; i < args.length; i++) { + mapName += (" " + args[i - 1]); + } + } + map = MapManager.getMap(uuid, mapName); + map.give(playerSender()); + return; + } + @Override + public boolean canExecute(CommandSender sender) + { + return Permissions.GETOTHER.grantedTo(sender); + } +} diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java new file mode 100644 index 0000000..292c1ea --- /dev/null +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java @@ -0,0 +1,124 @@ +/* + * 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 java.util.List; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import fr.moribus.imageonmap.Permissions; +import fr.moribus.imageonmap.commands.IoMCommand; +import fr.moribus.imageonmap.map.ImageMap; +import fr.moribus.imageonmap.map.MapManager; +import fr.moribus.imageonmap.map.PosterMap; +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 fr.zcraft.zlib.components.rawtext.RawTextPart; +import fr.zcraft.zlib.tools.items.ItemStackBuilder; +import fr.zcraft.zlib.tools.text.RawMessage; + + +@CommandInfo (name = "listother", usageParameters = "") +public class ListOtherCommand extends IoMCommand +{ + @Override + protected void run() throws CommandException + { + if(args.length < 1) warning(I.t("Not enough parameters! Usage: /maptool listother ")); + if(!playerSender().hasPermission("imageonmap.list.other")) { + warning(I.t("You do not have permission for this command. (imageonmap.list.other)")); + return; + } + + Player player = null; + UUID uuid = null; + player = Bukkit.getPlayer(args[0]); + if(player == null){ + OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]); + if(op.hasPlayedBefore()) { + uuid = op.getUniqueId(); + } + else { + warning(I.t("We've never seen that player before!")); + + } + } + else{ + uuid = player.getUniqueId(); + } + + List mapList = null; + try{ + mapList = MapManager.getMapList(uuid); + } + catch(Exception e){ + + } + if(mapList.isEmpty()) + { + info(I.t("No map found.")); + return; + } + + info(I.tn("{white}{bold}{0} map found.", "{white}{bold}{0} maps found.", mapList.size())); + + RawTextPart rawText = new RawText(""); + rawText = addMap(rawText, mapList.get(0)); + + for(int i = 1, c = mapList.size(); i < c; i++) + { + rawText = rawText.then(", ").color(ChatColor.GRAY); + rawText = addMap(rawText, mapList.get(i)); + } + + RawMessage.send(playerSender(), rawText.build()); + } + + private RawTextPart addMap(RawTextPart rawText, ImageMap map) + { + final String size = map.getType() == ImageMap.Type.SINGLE ? "1 × 1" : ((PosterMap) map).getColumnCount() + " × " + ((PosterMap) map).getRowCount(); + + return rawText + .then(map.getId()) + .color(ChatColor.WHITE) + .command(GetCommand.class, map.getId()) + .hover(new ItemStackBuilder(Material.MAP) + .title(ChatColor.GREEN + "" + ChatColor.BOLD + map.getName()) + .lore(ChatColor.GRAY + map.getId() + ", " + size) + .lore("") + .lore(I.t("{white}Click{gray} to get this map")) + .hideAttributes() + .item() + ); + } + @Override + public boolean canExecute(CommandSender sender) + { + return Permissions.LISTOTHER.grantedTo(sender); + } +} diff --git a/src/main/java/fr/moribus/imageonmap/map/ImageMap.java b/src/main/java/fr/moribus/imageonmap/map/ImageMap.java index bd71fad..4f12ca9 100644 --- a/src/main/java/fr/moribus/imageonmap/map/ImageMap.java +++ b/src/main/java/fr/moribus/imageonmap/map/ImageMap.java @@ -18,6 +18,7 @@ package fr.moribus.imageonmap.map; +import fr.moribus.imageonmap.ImageOnMap; import fr.moribus.imageonmap.ui.MapItemManager; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Material; @@ -26,6 +27,7 @@ import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -47,7 +49,6 @@ public abstract class ImageMap implements ConfigurationSerializable private final UUID userUUID; private final Type mapType; private String name; - protected ImageMap(UUID userUUID, Type mapType) { this(userUUID, mapType, null, null); @@ -84,6 +85,11 @@ public abstract class ImageMap implements ConfigurationSerializable return MapItemManager.give(player, this); } + public static File getFullImageFile(short mapIDstart, short mapIDend) + { + return new File(ImageOnMap.getPlugin().getImagesDirectory(), "_"+mapIDstart+"-"+mapIDend+".png"); + } + /* ====== Serialization methods ====== */ static public ImageMap fromConfig(Map map, UUID userUUID) throws InvalidConfigurationException diff --git a/src/main/java/fr/moribus/imageonmap/map/MapManager.java b/src/main/java/fr/moribus/imageonmap/map/MapManager.java index fa58f99..c4aa7bc 100644 --- a/src/main/java/fr/moribus/imageonmap/map/MapManager.java +++ b/src/main/java/fr/moribus/imageonmap/map/MapManager.java @@ -18,12 +18,13 @@ package fr.moribus.imageonmap.map; -import fr.moribus.imageonmap.ImageOnMap; import fr.moribus.imageonmap.PluginConfiguration; import fr.moribus.imageonmap.image.ImageIOExecutor; import fr.moribus.imageonmap.image.PosterImage; import fr.moribus.imageonmap.map.MapManagerException.Reason; import fr.zcraft.zlib.tools.PluginLogger; +import fr.moribus.imageonmap.ImageOnMap; + import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.inventory.Inventory; diff --git a/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java b/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java index 0c8d531..c052165 100644 --- a/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java +++ b/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java @@ -18,10 +18,11 @@ package fr.moribus.imageonmap.map; -import fr.moribus.imageonmap.ImageOnMap; import fr.moribus.imageonmap.PluginConfiguration; import fr.moribus.imageonmap.map.MapManagerException.Reason; import fr.zcraft.zlib.tools.PluginLogger; +import fr.moribus.imageonmap.ImageOnMap; + import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.InvalidConfigurationException; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 5ffe7d4..ab0ed6f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -16,3 +16,12 @@ collect-data: true # 0 means unlimited. map-global-limit: 0 map-player-limit: 0 + + +#Maximum size in pixels for an image to be. 0 is unlimited. +limit-map-size-x: 0 +limit-map-size-y: 0 + + +#Should the full image be saved when a map is rendered? +save-full-image: false \ No newline at end of file diff --git a/src/main/resources/help/maptool.txt b/src/main/resources/help/maptool.txt index 8859d51..b211c1c 100644 --- a/src/main/resources/help/maptool.txt +++ b/src/main/resources/help/maptool.txt @@ -3,6 +3,7 @@ new: Creates a new ImageOnMap delete: Deletes a map. delete-noconfirm: Deletes a map. Deletion is permanent and made without confirmation get: Gives you a map. +getother: Gets another player's 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. diff --git a/src/main/resources/help/maptool/getother.txt b/src/main/resources/help/maptool/getother.txt new file mode 100644 index 0000000..2c11fd3 --- /dev/null +++ b/src/main/resources/help/maptool/getother.txt @@ -0,0 +1,4 @@ +Gets another player's map. + +§6: §rThe name of the player who owns the map. +§6: §rThe name of the map. Use /maptool listother to get map names. \ No newline at end of file diff --git a/src/main/resources/help/maptool/listother.txt b/src/main/resources/help/maptool/listother.txt new file mode 100644 index 0000000..a24cb0a --- /dev/null +++ b/src/main/resources/help/maptool/listother.txt @@ -0,0 +1 @@ +Lists another player's maps. \ No newline at end of file From f5c3cb2bfd57cfe40b55af159421a50c41d18f19 Mon Sep 17 00:00:00 2001 From: kirbykirby56 Date: Sat, 24 Mar 2018 20:51:47 -0400 Subject: [PATCH 03/44] Removed debug-command --- .../fr/moribus/imageonmap/ImageOnMap.java | 2 - .../commands/maptool/DebugCommand.java | 41 ------------------- 2 files changed, 43 deletions(-) delete mode 100644 src/main/java/fr/moribus/imageonmap/commands/maptool/DebugCommand.java diff --git a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java index cd3f22a..d210ee3 100644 --- a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java +++ b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java @@ -18,7 +18,6 @@ package fr.moribus.imageonmap; -import fr.moribus.imageonmap.commands.maptool.DebugCommand; import fr.moribus.imageonmap.commands.maptool.DeleteCommand; import fr.moribus.imageonmap.commands.maptool.DeleteOtherCommand; import fr.moribus.imageonmap.commands.maptool.ListCommand; @@ -107,7 +106,6 @@ public final class ImageOnMap extends ZPlugin Commands.register( "maptool", NewCommand.class, - DebugCommand.class, ListCommand.class, GetCommand.class, GetOtherCommand.class, diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/DebugCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/DebugCommand.java deleted file mode 100644 index 9d43270..0000000 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/DebugCommand.java +++ /dev/null @@ -1,41 +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.PluginConfiguration; -import fr.moribus.imageonmap.commands.IoMCommand; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import org.bukkit.entity.Player; - -@CommandInfo (name = "debug") -public class DebugCommand extends IoMCommand -{ - @Override - protected void run() throws CommandException - { - Player p = playerSender(); - p.sendMessage("Limit Map Size X" + PluginConfiguration.LIMIT_SIZE_X.get().toString()); - p.sendMessage("Limit Map Size Y" + PluginConfiguration.LIMIT_SIZE_Y.get().toString()); - p.sendMessage("Global Map Limit" + PluginConfiguration.MAP_GLOBAL_LIMIT.get().toString()); - p.sendMessage("Player Map Limit" + PluginConfiguration.MAP_PLAYER_LIMIT.get().toString()); - p.sendMessage("Collect Data" + PluginConfiguration.COLLECT_DATA.get().toString()); - p.sendMessage("Save Full Image" + PluginConfiguration.SAVE_FULL_IMAGE.get().toString()); - } -} From 4e4212e42fce3d7f2e7951d831c4e73afe1bf159 Mon Sep 17 00:00:00 2001 From: kirbykirby56 Date: Sat, 24 Mar 2018 21:05:14 -0400 Subject: [PATCH 04/44] Revert to 3d7d2fd Because I screwed up. --- .../fr/moribus/imageonmap/ImageOnMap.java | 22 ++++++------------- .../fr/moribus/imageonmap/Permissions.java | 7 ++---- .../fr/moribus/imageonmap/map/ImageMap.java | 8 +------ .../fr/moribus/imageonmap/map/MapManager.java | 3 +-- .../imageonmap/map/PlayerMapStore.java | 3 +-- src/main/resources/config.yml | 9 -------- src/main/resources/help/maptool.txt | 1 - 7 files changed, 12 insertions(+), 41 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java index d210ee3..f16aa90 100644 --- a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java +++ b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java @@ -19,15 +19,12 @@ package fr.moribus.imageonmap; import fr.moribus.imageonmap.commands.maptool.DeleteCommand; -import fr.moribus.imageonmap.commands.maptool.DeleteOtherCommand; -import fr.moribus.imageonmap.commands.maptool.ListCommand; -import fr.moribus.imageonmap.commands.maptool.ListOtherCommand; -import fr.moribus.imageonmap.commands.maptool.MigrateCommand; -import fr.moribus.imageonmap.commands.maptool.NewCommand; +import fr.moribus.imageonmap.commands.maptool.ExploreCommand; import fr.moribus.imageonmap.commands.maptool.GetCommand; import fr.moribus.imageonmap.commands.maptool.GetRemainingCommand; -import fr.moribus.imageonmap.commands.maptool.GetOtherCommand; -import fr.moribus.imageonmap.commands.maptool.ExploreCommand; +import fr.moribus.imageonmap.commands.maptool.ListCommand; +import fr.moribus.imageonmap.commands.maptool.MigrateCommand; +import fr.moribus.imageonmap.commands.maptool.NewCommand; import fr.moribus.imageonmap.image.ImageIOExecutor; import fr.moribus.imageonmap.image.ImageRendererExecutor; import fr.moribus.imageonmap.image.MapInitEvent; @@ -44,12 +41,12 @@ import fr.zcraft.zlib.tools.PluginLogger; import java.io.File; import java.io.IOException; - public final class ImageOnMap extends ZPlugin { static private final String IMAGES_DIRECTORY_NAME = "images"; static private final String MAPS_DIRECTORY_NAME = "maps"; static private ImageOnMap plugin; + private File imagesDirectory; private final File mapsDirectory; @@ -72,7 +69,6 @@ public final class ImageOnMap extends ZPlugin return new File(imagesDirectory, "map"+mapID+".png"); } - @SuppressWarnings ("unchecked") @Override public void onEnable() @@ -89,12 +85,11 @@ public final class ImageOnMap extends ZPlugin this.setEnabled(false); return; } - - + saveDefaultConfig(); loadComponents(I18n.class, Gui.class, Commands.class, PluginConfiguration.class, ImageIOExecutor.class, ImageRendererExecutor.class); - + //Init all the things ! MetricsLite.startMetrics(); I18n.setPrimaryLocale(PluginConfiguration.LANG.get()); @@ -108,9 +103,6 @@ public final class ImageOnMap extends ZPlugin NewCommand.class, ListCommand.class, GetCommand.class, - GetOtherCommand.class, - ListOtherCommand.class, - DeleteOtherCommand.class, DeleteCommand.class, GetRemainingCommand.class, ExploreCommand.class, diff --git a/src/main/java/fr/moribus/imageonmap/Permissions.java b/src/main/java/fr/moribus/imageonmap/Permissions.java index ba6c552..abaa110 100644 --- a/src/main/java/fr/moribus/imageonmap/Permissions.java +++ b/src/main/java/fr/moribus/imageonmap/Permissions.java @@ -1,5 +1,5 @@ /* - * Copyright or or Copr. AmauryCarrade (2015) + * Copyright or © or Copr. AmauryCarrade (2015) * * http://amaury.carrade.eu * @@ -38,12 +38,9 @@ public enum Permissions { NEW("imageonmap.new", "imageonmap.userender"), LIST("imageonmap.list"), - LISTOTHER("imageonmap.listother"), GET("imageonmap.get"), - GETOTHER("imageonmap.getother"), RENAME("imageonmap.rename"), DELETE("imageonmap.delete"), - DELETEOTHER("imageonmap.deleteother"), ADMINISTRATIVE("imageonmap.administrative") ; @@ -75,4 +72,4 @@ public enum Permissions return false; } -} \ No newline at end of file +} diff --git a/src/main/java/fr/moribus/imageonmap/map/ImageMap.java b/src/main/java/fr/moribus/imageonmap/map/ImageMap.java index 4f12ca9..bd71fad 100644 --- a/src/main/java/fr/moribus/imageonmap/map/ImageMap.java +++ b/src/main/java/fr/moribus/imageonmap/map/ImageMap.java @@ -18,7 +18,6 @@ package fr.moribus.imageonmap.map; -import fr.moribus.imageonmap.ImageOnMap; import fr.moribus.imageonmap.ui.MapItemManager; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Material; @@ -27,7 +26,6 @@ import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -49,6 +47,7 @@ public abstract class ImageMap implements ConfigurationSerializable private final UUID userUUID; private final Type mapType; private String name; + protected ImageMap(UUID userUUID, Type mapType) { this(userUUID, mapType, null, null); @@ -85,11 +84,6 @@ public abstract class ImageMap implements ConfigurationSerializable return MapItemManager.give(player, this); } - public static File getFullImageFile(short mapIDstart, short mapIDend) - { - return new File(ImageOnMap.getPlugin().getImagesDirectory(), "_"+mapIDstart+"-"+mapIDend+".png"); - } - /* ====== Serialization methods ====== */ static public ImageMap fromConfig(Map map, UUID userUUID) throws InvalidConfigurationException diff --git a/src/main/java/fr/moribus/imageonmap/map/MapManager.java b/src/main/java/fr/moribus/imageonmap/map/MapManager.java index c4aa7bc..fa58f99 100644 --- a/src/main/java/fr/moribus/imageonmap/map/MapManager.java +++ b/src/main/java/fr/moribus/imageonmap/map/MapManager.java @@ -18,13 +18,12 @@ package fr.moribus.imageonmap.map; +import fr.moribus.imageonmap.ImageOnMap; import fr.moribus.imageonmap.PluginConfiguration; import fr.moribus.imageonmap.image.ImageIOExecutor; import fr.moribus.imageonmap.image.PosterImage; import fr.moribus.imageonmap.map.MapManagerException.Reason; import fr.zcraft.zlib.tools.PluginLogger; -import fr.moribus.imageonmap.ImageOnMap; - import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.inventory.Inventory; diff --git a/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java b/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java index c052165..0c8d531 100644 --- a/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java +++ b/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java @@ -18,11 +18,10 @@ package fr.moribus.imageonmap.map; +import fr.moribus.imageonmap.ImageOnMap; import fr.moribus.imageonmap.PluginConfiguration; import fr.moribus.imageonmap.map.MapManagerException.Reason; import fr.zcraft.zlib.tools.PluginLogger; -import fr.moribus.imageonmap.ImageOnMap; - import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.InvalidConfigurationException; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ab0ed6f..5ffe7d4 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -16,12 +16,3 @@ collect-data: true # 0 means unlimited. map-global-limit: 0 map-player-limit: 0 - - -#Maximum size in pixels for an image to be. 0 is unlimited. -limit-map-size-x: 0 -limit-map-size-y: 0 - - -#Should the full image be saved when a map is rendered? -save-full-image: false \ No newline at end of file diff --git a/src/main/resources/help/maptool.txt b/src/main/resources/help/maptool.txt index b211c1c..8859d51 100644 --- a/src/main/resources/help/maptool.txt +++ b/src/main/resources/help/maptool.txt @@ -3,7 +3,6 @@ new: Creates a new ImageOnMap delete: Deletes a map. delete-noconfirm: Deletes a map. Deletion is permanent and made without confirmation get: Gives you a map. -getother: Gets another player's 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. From 2050a113b58846c2586dab4020aa6c0ed79ed411 Mon Sep 17 00:00:00 2001 From: kirbykirby56 Date: Sat, 24 Mar 2018 21:06:49 -0400 Subject: [PATCH 05/44] Add administrative commands --- .../fr/moribus/imageonmap/ImageOnMap.java | 19 +++++++++++++------ .../fr/moribus/imageonmap/Permissions.java | 7 +++++-- .../fr/moribus/imageonmap/map/ImageMap.java | 8 +++++++- .../fr/moribus/imageonmap/map/MapManager.java | 3 ++- .../imageonmap/map/PlayerMapStore.java | 3 ++- src/main/resources/help/maptool.txt | 1 + 6 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java index f16aa90..3341659 100644 --- a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java +++ b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java @@ -19,12 +19,15 @@ package fr.moribus.imageonmap; 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; +import fr.moribus.imageonmap.commands.maptool.DeleteOtherCommand; import fr.moribus.imageonmap.commands.maptool.ListCommand; +import fr.moribus.imageonmap.commands.maptool.ListOtherCommand; import fr.moribus.imageonmap.commands.maptool.MigrateCommand; import fr.moribus.imageonmap.commands.maptool.NewCommand; +import fr.moribus.imageonmap.commands.maptool.GetCommand; +import fr.moribus.imageonmap.commands.maptool.GetRemainingCommand; +import fr.moribus.imageonmap.commands.maptool.GetOtherCommand; +import fr.moribus.imageonmap.commands.maptool.ExploreCommand; import fr.moribus.imageonmap.image.ImageIOExecutor; import fr.moribus.imageonmap.image.ImageRendererExecutor; import fr.moribus.imageonmap.image.MapInitEvent; @@ -46,7 +49,6 @@ public final class ImageOnMap extends ZPlugin static private final String IMAGES_DIRECTORY_NAME = "images"; static private final String MAPS_DIRECTORY_NAME = "maps"; static private ImageOnMap plugin; - private File imagesDirectory; private final File mapsDirectory; @@ -69,6 +71,7 @@ public final class ImageOnMap extends ZPlugin return new File(imagesDirectory, "map"+mapID+".png"); } + @SuppressWarnings ("unchecked") @Override public void onEnable() @@ -85,11 +88,12 @@ public final class ImageOnMap extends ZPlugin this.setEnabled(false); return; } - + + saveDefaultConfig(); loadComponents(I18n.class, Gui.class, Commands.class, PluginConfiguration.class, ImageIOExecutor.class, ImageRendererExecutor.class); - + //Init all the things ! MetricsLite.startMetrics(); I18n.setPrimaryLocale(PluginConfiguration.LANG.get()); @@ -103,6 +107,9 @@ public final class ImageOnMap extends ZPlugin NewCommand.class, ListCommand.class, GetCommand.class, + GetOtherCommand.class, + ListOtherCommand.class, + DeleteOtherCommand.class, DeleteCommand.class, GetRemainingCommand.class, ExploreCommand.class, diff --git a/src/main/java/fr/moribus/imageonmap/Permissions.java b/src/main/java/fr/moribus/imageonmap/Permissions.java index abaa110..ba6c552 100644 --- a/src/main/java/fr/moribus/imageonmap/Permissions.java +++ b/src/main/java/fr/moribus/imageonmap/Permissions.java @@ -1,5 +1,5 @@ /* - * Copyright or © or Copr. AmauryCarrade (2015) + * Copyright or or Copr. AmauryCarrade (2015) * * http://amaury.carrade.eu * @@ -38,9 +38,12 @@ public enum Permissions { NEW("imageonmap.new", "imageonmap.userender"), LIST("imageonmap.list"), + LISTOTHER("imageonmap.listother"), GET("imageonmap.get"), + GETOTHER("imageonmap.getother"), RENAME("imageonmap.rename"), DELETE("imageonmap.delete"), + DELETEOTHER("imageonmap.deleteother"), ADMINISTRATIVE("imageonmap.administrative") ; @@ -72,4 +75,4 @@ public enum Permissions return false; } -} +} \ No newline at end of file diff --git a/src/main/java/fr/moribus/imageonmap/map/ImageMap.java b/src/main/java/fr/moribus/imageonmap/map/ImageMap.java index bd71fad..4f12ca9 100644 --- a/src/main/java/fr/moribus/imageonmap/map/ImageMap.java +++ b/src/main/java/fr/moribus/imageonmap/map/ImageMap.java @@ -18,6 +18,7 @@ package fr.moribus.imageonmap.map; +import fr.moribus.imageonmap.ImageOnMap; import fr.moribus.imageonmap.ui.MapItemManager; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Material; @@ -26,6 +27,7 @@ import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -47,7 +49,6 @@ public abstract class ImageMap implements ConfigurationSerializable private final UUID userUUID; private final Type mapType; private String name; - protected ImageMap(UUID userUUID, Type mapType) { this(userUUID, mapType, null, null); @@ -84,6 +85,11 @@ public abstract class ImageMap implements ConfigurationSerializable return MapItemManager.give(player, this); } + public static File getFullImageFile(short mapIDstart, short mapIDend) + { + return new File(ImageOnMap.getPlugin().getImagesDirectory(), "_"+mapIDstart+"-"+mapIDend+".png"); + } + /* ====== Serialization methods ====== */ static public ImageMap fromConfig(Map map, UUID userUUID) throws InvalidConfigurationException diff --git a/src/main/java/fr/moribus/imageonmap/map/MapManager.java b/src/main/java/fr/moribus/imageonmap/map/MapManager.java index fa58f99..c4aa7bc 100644 --- a/src/main/java/fr/moribus/imageonmap/map/MapManager.java +++ b/src/main/java/fr/moribus/imageonmap/map/MapManager.java @@ -18,12 +18,13 @@ package fr.moribus.imageonmap.map; -import fr.moribus.imageonmap.ImageOnMap; import fr.moribus.imageonmap.PluginConfiguration; import fr.moribus.imageonmap.image.ImageIOExecutor; import fr.moribus.imageonmap.image.PosterImage; import fr.moribus.imageonmap.map.MapManagerException.Reason; import fr.zcraft.zlib.tools.PluginLogger; +import fr.moribus.imageonmap.ImageOnMap; + import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.inventory.Inventory; diff --git a/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java b/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java index 0c8d531..c052165 100644 --- a/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java +++ b/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java @@ -18,10 +18,11 @@ package fr.moribus.imageonmap.map; -import fr.moribus.imageonmap.ImageOnMap; import fr.moribus.imageonmap.PluginConfiguration; import fr.moribus.imageonmap.map.MapManagerException.Reason; import fr.zcraft.zlib.tools.PluginLogger; +import fr.moribus.imageonmap.ImageOnMap; + import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.InvalidConfigurationException; diff --git a/src/main/resources/help/maptool.txt b/src/main/resources/help/maptool.txt index 8859d51..b211c1c 100644 --- a/src/main/resources/help/maptool.txt +++ b/src/main/resources/help/maptool.txt @@ -3,6 +3,7 @@ new: Creates a new ImageOnMap delete: Deletes a map. delete-noconfirm: Deletes a map. Deletion is permanent and made without confirmation get: Gives you a map. +getother: Gets another player's 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. From aeceb0fb63be54e3bf56f4bee055e0779dd6b16e Mon Sep 17 00:00:00 2001 From: kirbykirby56 Date: Sat, 24 Mar 2018 21:09:03 -0400 Subject: [PATCH 06/44] Revert to 3d7d2fd again Because git is really hard for beginners and i keep including ImageMap.java --- .../fr/moribus/imageonmap/ImageOnMap.java | 21 +++++++------------ .../fr/moribus/imageonmap/Permissions.java | 7 ++----- .../fr/moribus/imageonmap/map/ImageMap.java | 8 +------ .../fr/moribus/imageonmap/map/MapManager.java | 3 +-- .../imageonmap/map/PlayerMapStore.java | 3 +-- src/main/resources/help/maptool.txt | 1 - 6 files changed, 12 insertions(+), 31 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java index 3341659..f16aa90 100644 --- a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java +++ b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java @@ -19,15 +19,12 @@ package fr.moribus.imageonmap; import fr.moribus.imageonmap.commands.maptool.DeleteCommand; -import fr.moribus.imageonmap.commands.maptool.DeleteOtherCommand; -import fr.moribus.imageonmap.commands.maptool.ListCommand; -import fr.moribus.imageonmap.commands.maptool.ListOtherCommand; -import fr.moribus.imageonmap.commands.maptool.MigrateCommand; -import fr.moribus.imageonmap.commands.maptool.NewCommand; +import fr.moribus.imageonmap.commands.maptool.ExploreCommand; import fr.moribus.imageonmap.commands.maptool.GetCommand; import fr.moribus.imageonmap.commands.maptool.GetRemainingCommand; -import fr.moribus.imageonmap.commands.maptool.GetOtherCommand; -import fr.moribus.imageonmap.commands.maptool.ExploreCommand; +import fr.moribus.imageonmap.commands.maptool.ListCommand; +import fr.moribus.imageonmap.commands.maptool.MigrateCommand; +import fr.moribus.imageonmap.commands.maptool.NewCommand; import fr.moribus.imageonmap.image.ImageIOExecutor; import fr.moribus.imageonmap.image.ImageRendererExecutor; import fr.moribus.imageonmap.image.MapInitEvent; @@ -49,6 +46,7 @@ public final class ImageOnMap extends ZPlugin static private final String IMAGES_DIRECTORY_NAME = "images"; static private final String MAPS_DIRECTORY_NAME = "maps"; static private ImageOnMap plugin; + private File imagesDirectory; private final File mapsDirectory; @@ -71,7 +69,6 @@ public final class ImageOnMap extends ZPlugin return new File(imagesDirectory, "map"+mapID+".png"); } - @SuppressWarnings ("unchecked") @Override public void onEnable() @@ -88,12 +85,11 @@ public final class ImageOnMap extends ZPlugin this.setEnabled(false); return; } - - + saveDefaultConfig(); loadComponents(I18n.class, Gui.class, Commands.class, PluginConfiguration.class, ImageIOExecutor.class, ImageRendererExecutor.class); - + //Init all the things ! MetricsLite.startMetrics(); I18n.setPrimaryLocale(PluginConfiguration.LANG.get()); @@ -107,9 +103,6 @@ public final class ImageOnMap extends ZPlugin NewCommand.class, ListCommand.class, GetCommand.class, - GetOtherCommand.class, - ListOtherCommand.class, - DeleteOtherCommand.class, DeleteCommand.class, GetRemainingCommand.class, ExploreCommand.class, diff --git a/src/main/java/fr/moribus/imageonmap/Permissions.java b/src/main/java/fr/moribus/imageonmap/Permissions.java index ba6c552..abaa110 100644 --- a/src/main/java/fr/moribus/imageonmap/Permissions.java +++ b/src/main/java/fr/moribus/imageonmap/Permissions.java @@ -1,5 +1,5 @@ /* - * Copyright or or Copr. AmauryCarrade (2015) + * Copyright or © or Copr. AmauryCarrade (2015) * * http://amaury.carrade.eu * @@ -38,12 +38,9 @@ public enum Permissions { NEW("imageonmap.new", "imageonmap.userender"), LIST("imageonmap.list"), - LISTOTHER("imageonmap.listother"), GET("imageonmap.get"), - GETOTHER("imageonmap.getother"), RENAME("imageonmap.rename"), DELETE("imageonmap.delete"), - DELETEOTHER("imageonmap.deleteother"), ADMINISTRATIVE("imageonmap.administrative") ; @@ -75,4 +72,4 @@ public enum Permissions return false; } -} \ No newline at end of file +} diff --git a/src/main/java/fr/moribus/imageonmap/map/ImageMap.java b/src/main/java/fr/moribus/imageonmap/map/ImageMap.java index 4f12ca9..bd71fad 100644 --- a/src/main/java/fr/moribus/imageonmap/map/ImageMap.java +++ b/src/main/java/fr/moribus/imageonmap/map/ImageMap.java @@ -18,7 +18,6 @@ package fr.moribus.imageonmap.map; -import fr.moribus.imageonmap.ImageOnMap; import fr.moribus.imageonmap.ui.MapItemManager; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Material; @@ -27,7 +26,6 @@ import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -49,6 +47,7 @@ public abstract class ImageMap implements ConfigurationSerializable private final UUID userUUID; private final Type mapType; private String name; + protected ImageMap(UUID userUUID, Type mapType) { this(userUUID, mapType, null, null); @@ -85,11 +84,6 @@ public abstract class ImageMap implements ConfigurationSerializable return MapItemManager.give(player, this); } - public static File getFullImageFile(short mapIDstart, short mapIDend) - { - return new File(ImageOnMap.getPlugin().getImagesDirectory(), "_"+mapIDstart+"-"+mapIDend+".png"); - } - /* ====== Serialization methods ====== */ static public ImageMap fromConfig(Map map, UUID userUUID) throws InvalidConfigurationException diff --git a/src/main/java/fr/moribus/imageonmap/map/MapManager.java b/src/main/java/fr/moribus/imageonmap/map/MapManager.java index c4aa7bc..fa58f99 100644 --- a/src/main/java/fr/moribus/imageonmap/map/MapManager.java +++ b/src/main/java/fr/moribus/imageonmap/map/MapManager.java @@ -18,13 +18,12 @@ package fr.moribus.imageonmap.map; +import fr.moribus.imageonmap.ImageOnMap; import fr.moribus.imageonmap.PluginConfiguration; import fr.moribus.imageonmap.image.ImageIOExecutor; import fr.moribus.imageonmap.image.PosterImage; import fr.moribus.imageonmap.map.MapManagerException.Reason; import fr.zcraft.zlib.tools.PluginLogger; -import fr.moribus.imageonmap.ImageOnMap; - import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.inventory.Inventory; diff --git a/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java b/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java index c052165..0c8d531 100644 --- a/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java +++ b/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java @@ -18,11 +18,10 @@ package fr.moribus.imageonmap.map; +import fr.moribus.imageonmap.ImageOnMap; import fr.moribus.imageonmap.PluginConfiguration; import fr.moribus.imageonmap.map.MapManagerException.Reason; import fr.zcraft.zlib.tools.PluginLogger; -import fr.moribus.imageonmap.ImageOnMap; - import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.InvalidConfigurationException; diff --git a/src/main/resources/help/maptool.txt b/src/main/resources/help/maptool.txt index b211c1c..8859d51 100644 --- a/src/main/resources/help/maptool.txt +++ b/src/main/resources/help/maptool.txt @@ -3,7 +3,6 @@ new: Creates a new ImageOnMap delete: Deletes a map. delete-noconfirm: Deletes a map. Deletion is permanent and made without confirmation get: Gives you a map. -getother: Gets another player's 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. From f0889b8cf1fc4122e5350ff3f403a89ae067d56a Mon Sep 17 00:00:00 2001 From: kirbykirby56 Date: Sat, 24 Mar 2018 21:17:44 -0400 Subject: [PATCH 07/44] Add administrative commands --- .../fr/moribus/imageonmap/ImageOnMap.java | 20 +++++++++++++------ .../fr/moribus/imageonmap/Permissions.java | 7 +++++-- src/main/resources/help/maptool.txt | 1 + 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java index f16aa90..d210ee3 100644 --- a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java +++ b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java @@ -19,12 +19,15 @@ package fr.moribus.imageonmap; 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; +import fr.moribus.imageonmap.commands.maptool.DeleteOtherCommand; import fr.moribus.imageonmap.commands.maptool.ListCommand; +import fr.moribus.imageonmap.commands.maptool.ListOtherCommand; import fr.moribus.imageonmap.commands.maptool.MigrateCommand; import fr.moribus.imageonmap.commands.maptool.NewCommand; +import fr.moribus.imageonmap.commands.maptool.GetCommand; +import fr.moribus.imageonmap.commands.maptool.GetRemainingCommand; +import fr.moribus.imageonmap.commands.maptool.GetOtherCommand; +import fr.moribus.imageonmap.commands.maptool.ExploreCommand; import fr.moribus.imageonmap.image.ImageIOExecutor; import fr.moribus.imageonmap.image.ImageRendererExecutor; import fr.moribus.imageonmap.image.MapInitEvent; @@ -41,12 +44,12 @@ import fr.zcraft.zlib.tools.PluginLogger; import java.io.File; import java.io.IOException; + public final class ImageOnMap extends ZPlugin { static private final String IMAGES_DIRECTORY_NAME = "images"; static private final String MAPS_DIRECTORY_NAME = "maps"; static private ImageOnMap plugin; - private File imagesDirectory; private final File mapsDirectory; @@ -69,6 +72,7 @@ public final class ImageOnMap extends ZPlugin return new File(imagesDirectory, "map"+mapID+".png"); } + @SuppressWarnings ("unchecked") @Override public void onEnable() @@ -85,11 +89,12 @@ public final class ImageOnMap extends ZPlugin this.setEnabled(false); return; } - + + saveDefaultConfig(); loadComponents(I18n.class, Gui.class, Commands.class, PluginConfiguration.class, ImageIOExecutor.class, ImageRendererExecutor.class); - + //Init all the things ! MetricsLite.startMetrics(); I18n.setPrimaryLocale(PluginConfiguration.LANG.get()); @@ -103,6 +108,9 @@ public final class ImageOnMap extends ZPlugin NewCommand.class, ListCommand.class, GetCommand.class, + GetOtherCommand.class, + ListOtherCommand.class, + DeleteOtherCommand.class, DeleteCommand.class, GetRemainingCommand.class, ExploreCommand.class, diff --git a/src/main/java/fr/moribus/imageonmap/Permissions.java b/src/main/java/fr/moribus/imageonmap/Permissions.java index abaa110..ba6c552 100644 --- a/src/main/java/fr/moribus/imageonmap/Permissions.java +++ b/src/main/java/fr/moribus/imageonmap/Permissions.java @@ -1,5 +1,5 @@ /* - * Copyright or © or Copr. AmauryCarrade (2015) + * Copyright or or Copr. AmauryCarrade (2015) * * http://amaury.carrade.eu * @@ -38,9 +38,12 @@ public enum Permissions { NEW("imageonmap.new", "imageonmap.userender"), LIST("imageonmap.list"), + LISTOTHER("imageonmap.listother"), GET("imageonmap.get"), + GETOTHER("imageonmap.getother"), RENAME("imageonmap.rename"), DELETE("imageonmap.delete"), + DELETEOTHER("imageonmap.deleteother"), ADMINISTRATIVE("imageonmap.administrative") ; @@ -72,4 +75,4 @@ public enum Permissions return false; } -} +} \ No newline at end of file diff --git a/src/main/resources/help/maptool.txt b/src/main/resources/help/maptool.txt index 8859d51..b211c1c 100644 --- a/src/main/resources/help/maptool.txt +++ b/src/main/resources/help/maptool.txt @@ -3,6 +3,7 @@ new: Creates a new ImageOnMap delete: Deletes a map. delete-noconfirm: Deletes a map. Deletion is permanent and made without confirmation get: Gives you a map. +getother: Gets another player's 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. From c8955f18828659c5b6362550f7f618ec77287e0c Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Tue, 30 Jun 2020 00:59:37 +0200 Subject: [PATCH 08/44] Delete testforwebhook.test useless --- testforwebhook.test | 1 - 1 file changed, 1 deletion(-) delete mode 100644 testforwebhook.test diff --git a/testforwebhook.test b/testforwebhook.test deleted file mode 100644 index 9daeafb..0000000 --- a/testforwebhook.test +++ /dev/null @@ -1 +0,0 @@ -test From 98b952471bc071ae9e67013c94870179e9cd12b1 Mon Sep 17 00:00:00 2001 From: valentin Date: Fri, 3 Jul 2020 10:49:07 +0200 Subject: [PATCH 09/44] PR #38, fixed comment --- src/main/java/fr/moribus/imageonmap/ImageOnMap.java | 8 +++++++- .../imageonmap/commands/maptool/RenameCommand.java | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java index 92ea105..3441c71 100644 --- a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java +++ b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java @@ -18,7 +18,13 @@ package fr.moribus.imageonmap; -import fr.moribus.imageonmap.commands.maptool.*; +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; +import fr.moribus.imageonmap.commands.maptool.ListCommand; +import fr.moribus.imageonmap.commands.maptool.MigrateCommand; +import fr.moribus.imageonmap.commands.maptool.NewCommand; import fr.moribus.imageonmap.image.ImageIOExecutor; import fr.moribus.imageonmap.image.ImageRendererExecutor; import fr.moribus.imageonmap.image.MapInitEvent; diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/RenameCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/RenameCommand.java index 36f8be5..d3d654f 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/RenameCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/RenameCommand.java @@ -35,14 +35,20 @@ public class RenameCommand extends IoMCommand { ImageMap map = getMapFromArgs(); map.rename(args[1]); } else { - info("Not Enough Or To Many Arguments"); + info(I.t("Not enough or too many arguments")); } } @Override protected List complete() throws CommandException { + if(args.length == 1) return getMatchingMapNames(playerSender(), args[0]); return null; } + @Override + public boolean canExecute(CommandSender sender) + { + return Permissions.RENAME.grantedTo(sender); + } } From 13881f751ee1811d3ac4be026975549573f51af9 Mon Sep 17 00:00:00 2001 From: Pugabyte Date: Fri, 3 Jul 2020 16:20:58 -0400 Subject: [PATCH 10/44] Add permission to remove splattermap off wall --- .../fr/moribus/imageonmap/Permissions.java | 1 + .../moribus/imageonmap/ui/MapItemManager.java | 18 +++++++++++------- src/main/resources/plugin.yml | 11 ++++++++--- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/Permissions.java b/src/main/java/fr/moribus/imageonmap/Permissions.java index 6667243..e561eb3 100644 --- a/src/main/java/fr/moribus/imageonmap/Permissions.java +++ b/src/main/java/fr/moribus/imageonmap/Permissions.java @@ -44,6 +44,7 @@ public enum Permissions LIST("imageonmap.list"), GET("imageonmap.get"), RENAME("imageonmap.rename"), + REMOVE_SPLATTER_MAP("imageonmap.removesplattermap"), DELETE("imageonmap.delete"), ADMINISTRATIVE("imageonmap.administrative"), BYPASS_SIZE("imageonmap.bypasssize") diff --git a/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java b/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java index e16aad7..b8e14c5 100644 --- a/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java +++ b/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java @@ -36,6 +36,7 @@ package fr.moribus.imageonmap.ui; +import fr.moribus.imageonmap.Permissions; import fr.moribus.imageonmap.map.ImageMap; import fr.moribus.imageonmap.map.MapManager; import fr.moribus.imageonmap.map.PosterMap; @@ -285,17 +286,20 @@ public class MapItemManager implements Listener ItemStack item = frame.getItem(); if (frame.getItem().getType() != Material.FILLED_MAP) return; - if (player.isSneaking()) + if (Permissions.REMOVE_SPLATTER_MAP.grantedTo(player)) { - PosterMap poster = SplatterMapManager.removeSplatterMap(frame,player); - if (poster != null) + if (player.isSneaking()) { - event.setCancelled(true); + PosterMap poster = SplatterMapManager.removeSplatterMap(frame,player); + if (poster != null) + { + event.setCancelled(true); - if (player.getGameMode() != GameMode.CREATIVE || !SplatterMapManager.hasSplatterMap(player, poster)) - poster.give(player); + if (player.getGameMode() != GameMode.CREATIVE || !SplatterMapManager.hasSplatterMap(player, poster)) + poster.give(player); - return; + return; + } } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index ef82c43..f92a42c 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -23,15 +23,16 @@ permissions: imageonmap.get: true imageonmap.explore: true imageonmap.rename: true + imageonmap.removesplattermap: true imageonmap.delete: true imageonmap.bypasssize: false imageonmap.userender: - description: "Allows you to use /tomap and related commands (/maptool getremaing). Alias of imageonmap.new." + description: "Allows you to use /tomap and related commands (/maptool getremaining). Alias of imageonmap.new." default: true imageonmap.new: - description: "Allows you to use /tomap and related commands (/maptool getremaing)." + description: "Allows you to use /tomap and related commands (/maptool getremaining)." default: true imageonmap.list: @@ -39,7 +40,7 @@ permissions: default: true imageonmap.get: - description: "Allows you to get a new map among the ones you already rendered, and related commands (/maptool getremaing)." + description: "Allows you to get a new map among the ones you already rendered, and related commands (/maptool getremaining)." default: true imageonmap.explore: @@ -54,6 +55,10 @@ permissions: description: "Allows you to delete a map you rendered in the past." default: true + imageonmap.removesplattermap: + description: "Allows you to remove a splatter map from a wall by sneaking and breaking a map." + default: true + imageonmap.administrative: description: "Allows you to perform administrative tasks (like /maptool migrate)." default: op From b8c1494f584340c0f226dcd03d53117298899db7 Mon Sep 17 00:00:00 2001 From: Griffin Kubesa Date: Wed, 8 Jul 2020 18:13:18 -0400 Subject: [PATCH 11/44] Fix saving images (#112) --- .../imageonmap/image/ImageRendererExecutor.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java index b49f57e..0ed4908 100644 --- a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java +++ b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java @@ -151,7 +151,7 @@ public class ImageRendererExecutor extends Worker return renderSingle(scaling.resize(image, ImageMap.WIDTH, ImageMap.HEIGHT), playerUUID); } final BufferedImage resizedImage = scaling.resize(image, ImageMap.WIDTH * width, ImageMap.HEIGHT * height); - //image.flush(); + image.flush(); return renderPoster(resizedImage, playerUUID); } }, callback); @@ -171,7 +171,7 @@ public class ImageRendererExecutor extends Worker }); final int mapID = futureMapID.get(); - //ImageIOExecutor.saveImage(mapID, image); + ImageIOExecutor.saveImage(mapID, image); submitToMainThread(new Callable() { @@ -179,11 +179,11 @@ public class ImageRendererExecutor extends Worker public Void call() throws Exception { Renderer.installRenderer(image, mapID); - //image.flush(); + image.flush(); return null; } }); - //image.flush(); + image.flush(); return MapManager.createMap(playerUUID, mapID); } @@ -202,7 +202,7 @@ public class ImageRendererExecutor extends Worker }); poster.splitImages(); final int[] mapsIDs = futureMapsIds.get(); - // ImageIOExecutor.saveImage(mapsIDs, poster); + ImageIOExecutor.saveImage(mapsIDs, poster); if (PluginConfiguration.SAVE_FULL_IMAGE.get()) @@ -221,7 +221,7 @@ public class ImageRendererExecutor extends Worker }); - // image.flush(); + image.flush(); return MapManager.createMap(poster, playerUUID, mapsIDs); } From b01f133639ce34255ca6eb2ecde25b19aee88594 Mon Sep 17 00:00:00 2001 From: Vlammar Date: Thu, 16 Jul 2020 02:50:17 +0200 Subject: [PATCH 12/44] Update working --- .../fr/moribus/imageonmap/ImageOnMap.java | 3 +- .../fr/moribus/imageonmap/Permissions.java | 1 + .../imageonmap/commands/IoMCommand.java | 1 - .../commands/maptool/UpdateCommand.java | 234 ++++++++++++++++++ .../image/ImageRendererExecutor.java | 123 +++++++-- .../fr/moribus/imageonmap/map/ImageMap.java | 32 ++- .../fr/moribus/imageonmap/map/MapManager.java | 8 +- .../imageonmap/map/PlayerMapStore.java | 8 +- 8 files changed, 376 insertions(+), 34 deletions(-) create mode 100644 src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java diff --git a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java index 2c1361d..f545743 100644 --- a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java +++ b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java @@ -119,7 +119,8 @@ public final class ImageOnMap extends ZPlugin DeleteCommand.class, GetRemainingCommand.class, ExploreCommand.class, - MigrateCommand.class + MigrateCommand.class, + UpdateCommand.class ); Commands.registerShortcut("maptool", NewCommand.class, "tomap"); diff --git a/src/main/java/fr/moribus/imageonmap/Permissions.java b/src/main/java/fr/moribus/imageonmap/Permissions.java index 6667243..4ca6a8d 100644 --- a/src/main/java/fr/moribus/imageonmap/Permissions.java +++ b/src/main/java/fr/moribus/imageonmap/Permissions.java @@ -45,6 +45,7 @@ public enum Permissions GET("imageonmap.get"), RENAME("imageonmap.rename"), DELETE("imageonmap.delete"), + UPDATE("imageonmap.update"), ADMINISTRATIVE("imageonmap.administrative"), BYPASS_SIZE("imageonmap.bypasssize") diff --git a/src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java b/src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java index b3203b4..25efd58 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java @@ -69,7 +69,6 @@ public abstract class IoMCommand extends Command } mapName = mapName.trim(); - map = MapManager.getMap(player.getUniqueId(), mapName); if(map == null) error(I.t("This map does not exist.")); diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java new file mode 100644 index 0000000..1be5743 --- /dev/null +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java @@ -0,0 +1,234 @@ +/* + * Copyright or © or Copr. Moribus (2013) + * Copyright or © or Copr. ProkopyL (2015) + * Copyright or © or Copr. Amaury Carrade (2016 – 2020) + * Copyright or © or Copr. Vlammar (2019 – 2020) + * + * This software is a computer program whose purpose is to allow insertion of + * custom images in a Minecraft world. + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ + +package fr.moribus.imageonmap.commands.maptool; + +import fr.moribus.imageonmap.Permissions; +import fr.moribus.imageonmap.commands.IoMCommand; +import fr.moribus.imageonmap.image.ImageRendererExecutor; +import fr.moribus.imageonmap.image.ImageUtils; +import fr.moribus.imageonmap.map.ImageMap; +import fr.moribus.imageonmap.map.MapManager; +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.worker.WorkerCallback; +import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.zlib.tools.text.ActionBar; +import fr.zcraft.zlib.tools.text.MessageSender; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; + +@CommandInfo (name = "update", usageParameters = " [--confirm]") +@WithFlags ({"confirm"}) +public class UpdateCommand extends IoMCommand +{ + @Override + protected void run() throws CommandException + { + final Player player = playerSender(); + ImageUtils.ScalingType scaling = ImageUtils.ScalingType.NONE; + URL url; + + + if(args.length < 1) throwInvalidArgument(I.t("You must give an URL and a map name to update.")); + if(args.length < 2) throwInvalidArgument(I.t("You must give a map name to update.")); + + ImageMap map=getMapFromArgs(player,1,true); + + try + { + url = new URL(args[0]); + MapManager.load(); + Integer[] size={1,1}; + if(map.getType()== ImageMap.Type.POSTER) + size=map.getSize( new HashMap(),map.getUserUUID(),map.getId()); + + int width=size[0],height=size[1]; + + try { + + + ActionBar.sendPermanentMessage(player, ChatColor.DARK_GREEN + I.t("Updating...")); + ImageRendererExecutor.update(url, scaling, player.getUniqueId(), map, width, height, new WorkerCallback() { + @Override + public void finished(ImageMap result) { + ActionBar.removeMessage(player); + MessageSender.sendActionBarMessage(player, ChatColor.DARK_GREEN + I.t("Updating finished!")); + + + } + + @Override + public void errored(Throwable exception) { + player.sendMessage(I.t("{ce}Map rendering failed: {0}", exception.getMessage())); + + PluginLogger.warning("Rendering from {0} failed: {1}: {2}", + player.getName(), + exception.getClass().getCanonicalName(), + exception.getMessage()); + } + }); + } + //Added to fix bug with rendering displaying after error + finally { + ActionBar.removeMessage(player); + } + + } + catch(MalformedURLException ex) + { + throwInvalidArgument(I.t("Invalid URL.")); + return; + } + /*catch (MapManagerException ex){ + throwInvalidArgument(I.t("Update failed.")); + return; + }*/ + + + + + + /* if(args.length >= 2) + { + if(args.length >= 4) { + width = Integer.parseInt(args[2]); + height = Integer.parseInt(args[3]); + } + + switch(args[1]) { + case "resize": scaling = ImageUtils.ScalingType.CONTAINED; break; + case "resize-stretched": scaling = ImageUtils.ScalingType.STRETCHED; break; + case "resize-covered": scaling = ImageUtils.ScalingType.COVERED; break; + default: throwInvalidArgument(I.t("Invalid Stretching mode.")); break; + } + }*/ + /* try { + + + ActionBar.sendPermanentMessage(player, ChatColor.DARK_GREEN + I.t("Updating map...")); + //ImageRendererExecutor.render(url, scaling, player.getUniqueId(), width, height, new WorkerCallback() { + @Override + public void finished(ImageMap result) { + ActionBar.removeMessage(player); + MessageSender.sendActionBarMessage(player, ChatColor.DARK_GREEN + I.t("Rendering finished!")); + + if (result.give(player) && (result instanceof PosterMap && !((PosterMap) result).hasColumnData())) { + info(I.t("The rendered map was too big to fit in your inventory.")); + info(I.t("Use '/maptool getremaining' to get the remaining maps.")); + } + } + + @Override + public void errored(Throwable exception) { + player.sendMessage(I.t("{ce}Map rendering failed: {0}", exception.getMessage())); + + PluginLogger.warning("Rendering from {0} failed: {1}: {2}", + player.getName(), + exception.getClass().getCanonicalName(), + exception.getMessage()); + } + }); + } + //Added to fix bug with rendering displaying after error + finally { + ActionBar.removeMessage(player); + }*/ + } + + +/* + + @Override + protected void run() throws CommandException + { + ImageMap map = getMapFromArgs(); + + if (!hasFlag("confirm")) + { + RawText msg = new RawText(I.t("You are going to update") + " ") + .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 updated {bold}forever{red}!"))) + .command(getClass(), map.getId(), "--confirm") + .build(); + + send(msg); + } + else + { + Player player = playerSender(); + MapManager.clear(player.getInventory(), map); + + try + { + MapManager.updateMap(map); + info(I.t("Map successfully updated.")); + } + catch (MapManagerException ex) + { + PluginLogger.warning("A non-existent map was requested to be updated", ex); + warning(I.t("This map does not exist.")); + } + } + } + + @Override + protected List complete() throws CommandException + { + if(args.length == 1) + return getMatchingMapNames(playerSender(), args[0]); + + return null; + } +*/ + @Override + public boolean canExecute(CommandSender sender) + { + return Permissions.UPDATE.grantedTo(sender); + } +} diff --git a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java index 3811c8f..b52da7b 100644 --- a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java +++ b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java @@ -61,6 +61,39 @@ import java.util.concurrent.Future; @WorkerAttributes(name = "Image Renderer", queriesMainThread = true) public class ImageRendererExecutor extends Worker { + static private URLConnection HTTPconnection(final URL url) throws IOException { + final URLConnection connection = url.openConnection(); + connection.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0"); + connection.connect(); + + if (connection instanceof HttpURLConnection) + { + final HttpURLConnection httpConnection = (HttpURLConnection) connection; + final int httpCode = httpConnection.getResponseCode(); + if ((httpCode / 100) != 2) + { + throw new IOException(I.t("HTTP error: {0} {1}", httpCode, httpConnection.getResponseMessage())); + } + } + return connection; + } + + static private void checkSizeLimit(final UUID playerUUID, final BufferedImage image ) throws IOException { + if ((PluginConfiguration.LIMIT_SIZE_X.get() > 0 || PluginConfiguration.LIMIT_SIZE_Y.get() > 0) && !Permissions.BYPASS_SIZE.grantedTo(Bukkit.getPlayer(playerUUID))) + { + if (PluginConfiguration.LIMIT_SIZE_X.get() > 0) + { + if (image.getWidth() > PluginConfiguration.LIMIT_SIZE_X.get()) + throw new IOException(I.t("The image is too wide!")); + } + if (PluginConfiguration.LIMIT_SIZE_Y.get() > 0) + { + if (image.getHeight() > PluginConfiguration.LIMIT_SIZE_Y.get()) + throw new IOException(I.t("The image is too tall!")); + } + } + } + static public void render(final URL url, final ImageUtils.ScalingType scaling, final UUID playerUUID, final int width, final int height, WorkerCallback callback) { submitQuery(new WorkerRunnable() @@ -68,39 +101,17 @@ public class ImageRendererExecutor extends Worker @Override public ImageMap run() throws Throwable { - final URLConnection connection = url.openConnection(); - connection.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0"); - connection.connect(); - if (connection instanceof HttpURLConnection) - { - final HttpURLConnection httpConnection = (HttpURLConnection) connection; - final int httpCode = httpConnection.getResponseCode(); - if ((httpCode / 100) != 2) - { - throw new IOException(I.t("HTTP error: {0} {1}", httpCode, httpConnection.getResponseMessage())); - } - } + final URLConnection connection = HTTPconnection(url); final InputStream stream = connection.getInputStream(); final BufferedImage image = ImageIO.read(stream); + stream.close(); if (image == null) throw new IOException(I.t("The given URL is not a valid image")); // Limits are in place and the player does NOT have rights to avoid them. - if ((PluginConfiguration.LIMIT_SIZE_X.get() > 0 || PluginConfiguration.LIMIT_SIZE_Y.get() > 0) && !Permissions.BYPASS_SIZE.grantedTo(Bukkit.getPlayer(playerUUID))) - { - if (PluginConfiguration.LIMIT_SIZE_X.get() > 0) - { - if (image.getWidth() > PluginConfiguration.LIMIT_SIZE_X.get()) - throw new IOException(I.t("The image is too wide!")); - } - if (PluginConfiguration.LIMIT_SIZE_Y.get() > 0) - { - if (image.getHeight() > PluginConfiguration.LIMIT_SIZE_Y.get()) - throw new IOException(I.t("The image is too tall!")); - } - } + checkSizeLimit(playerUUID, image ); if (scaling != ImageUtils.ScalingType.NONE && height <= 1 && width <= 1) { @@ -113,6 +124,66 @@ public class ImageRendererExecutor extends Worker }, callback); } + public static void update(final URL url, final ImageUtils.ScalingType scaling, final UUID playerUUID, final ImageMap map, final int width, final int height, WorkerCallback callback) { + submitQuery(new WorkerRunnable() + { + @Override + public ImageMap run() throws Throwable + { + + final URLConnection connection = HTTPconnection(url); + + final InputStream stream = connection.getInputStream(); + final BufferedImage image = ImageIO.read(stream); + stream.close(); + + if (image == null) throw new IOException(I.t("The given URL is not a valid image")); + + // Limits are in place and the player does NOT have rights to avoid them. + checkSizeLimit(playerUUID, image ); + + + updateMap(ImageUtils.ScalingType.CONTAINED.resize(image, width*128, height*128),playerUUID,map.getMapsIDs()); + return map; + /*if (scaling != ImageUtils.ScalingType.NONE && height <= 1 && width <= 1) + { + return updateSingle(scaling.resize(image, ImageMap.WIDTH, ImageMap.HEIGHT), playerUUID); + } + + final BufferedImage resizedImage = scaling.resize(image, ImageMap.WIDTH * width, ImageMap.HEIGHT * height); + return updatePoster(resizedImage, playerUUID);*/ + } + }, callback); + + } + static private void updateMap(final BufferedImage image, final UUID playerUUID,int[] mapsIDs) throws Throwable + { + + final PosterImage poster = new PosterImage(image); + poster.splitImages(); + + + + ImageIOExecutor.saveImage(mapsIDs, poster); + + if (PluginConfiguration.SAVE_FULL_IMAGE.get()) + { + ImageIOExecutor.saveImage(ImageMap.getFullImageFile(mapsIDs[0], mapsIDs[mapsIDs.length - 1]), image); + } + + submitToMainThread(new Callable() + { + @Override + public Void call() throws Exception + { + Renderer.installRenderer(poster, mapsIDs); + return null; + } + + }); + + + } static private ImageMap renderSingle(final BufferedImage image, final UUID playerUUID) throws Throwable { MapManager.checkMapLimit(1, playerUUID); @@ -180,4 +251,6 @@ public class ImageRendererExecutor extends Worker return MapManager.createMap(poster, playerUUID, mapsIDs); } + + } diff --git a/src/main/java/fr/moribus/imageonmap/map/ImageMap.java b/src/main/java/fr/moribus/imageonmap/map/ImageMap.java index 0c0bf9e..27c0a88 100644 --- a/src/main/java/fr/moribus/imageonmap/map/ImageMap.java +++ b/src/main/java/fr/moribus/imageonmap/map/ImageMap.java @@ -39,7 +39,9 @@ package fr.moribus.imageonmap.map; import fr.moribus.imageonmap.ImageOnMap; import fr.moribus.imageonmap.ui.MapItemManager; import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.PluginLogger; import org.bukkit.Material; +import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.entity.Player; @@ -47,6 +49,7 @@ import org.bukkit.inventory.ItemStack; import java.io.File; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.UUID; @@ -150,7 +153,34 @@ public abstract class ImageMap implements ConfigurationSerializable this.postSerialize(map); return map; } - + + static public Integer[] getSize(Map map, UUID playerUUID, String id){ + + ConfigurationSection section=MapManager.getPlayerMapStore(playerUUID).getToolConfig().getConfigurationSection("PlayerMapStore"); + + if(section == null) return null; + List> list = (List>) section.getList("mapList"); + if(list == null) return null; + + PluginLogger.info("list "); + for(Map tMap : list) + { + PluginLogger.info(" "+tMap.toString()); + if(tMap.get("id").equals(id)) { + + return new Integer[]{(Integer)tMap.get("columns"), (Integer)tMap.get("rows")}; + + } + } + + + + + + + + return null; + } static protected T getFieldValue(Map map, String fieldName) throws InvalidConfigurationException { T value = getNullableFieldValue(map, fieldName); diff --git a/src/main/java/fr/moribus/imageonmap/map/MapManager.java b/src/main/java/fr/moribus/imageonmap/map/MapManager.java index d06cf8c..fd7281d 100644 --- a/src/main/java/fr/moribus/imageonmap/map/MapManager.java +++ b/src/main/java/fr/moribus/imageonmap/map/MapManager.java @@ -106,7 +106,7 @@ abstract public class MapManager addMap(newMap); return newMap; } - + static public ImageMap createMap(PosterImage image, UUID playerUUID, int[] mapsIDs) throws MapManagerException { ImageMap newMap; @@ -122,7 +122,7 @@ abstract public class MapManager addMap(newMap); return newMap; } - + static public int[] getNewMapsIds(int amount) { int[] mapsIds = new int[amount]; @@ -161,7 +161,7 @@ abstract public class MapManager getPlayerMapStore(map.getUserUUID()).deleteMap(map); ImageIOExecutor.deleteImage(map); } - + static public void notifyModification(UUID playerUUID) { getPlayerMapStore(playerUUID).notifyModification(); @@ -376,7 +376,7 @@ abstract public class MapManager } } - static private PlayerMapStore getPlayerMapStore(UUID playerUUID) + static public PlayerMapStore getPlayerMapStore(UUID playerUUID) { PlayerMapStore store; synchronized(playerMaps) diff --git a/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java b/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java index 057c9e0..de4ee96 100644 --- a/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java +++ b/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java @@ -149,7 +149,11 @@ public class PlayerMapStore implements ConfigurationSerializable { return new ArrayList(mapList); } - + + /*public synchronized ArrayList getMapList() + { + return mapList; + }*/ public synchronized ImageMap[] getMaps() { return mapList.toArray(new ImageMap[mapList.size()]); @@ -256,7 +260,7 @@ public class PlayerMapStore implements ConfigurationSerializable private FileConfiguration mapConfig = null; private File mapsFile = null; - private FileConfiguration getToolConfig() + public FileConfiguration getToolConfig() { if(mapConfig == null) load(); From f007e8e0b9de52f8e827d86828a50ca9df6dd343 Mon Sep 17 00:00:00 2001 From: Vlammar Date: Thu, 16 Jul 2020 02:59:22 +0200 Subject: [PATCH 13/44] Code cleanup --- .../commands/maptool/UpdateCommand.java | 114 ------------------ .../image/ImageRendererExecutor.java | 12 -- .../fr/moribus/imageonmap/map/ImageMap.java | 9 -- 3 files changed, 135 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java index 1be5743..d1baf8c 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java @@ -69,7 +69,6 @@ public class UpdateCommand extends IoMCommand ImageUtils.ScalingType scaling = ImageUtils.ScalingType.NONE; URL url; - if(args.length < 1) throwInvalidArgument(I.t("You must give an URL and a map name to update.")); if(args.length < 2) throwInvalidArgument(I.t("You must give a map name to update.")); @@ -82,22 +81,15 @@ public class UpdateCommand extends IoMCommand Integer[] size={1,1}; if(map.getType()== ImageMap.Type.POSTER) size=map.getSize( new HashMap(),map.getUserUUID(),map.getId()); - int width=size[0],height=size[1]; - try { - - ActionBar.sendPermanentMessage(player, ChatColor.DARK_GREEN + I.t("Updating...")); ImageRendererExecutor.update(url, scaling, player.getUniqueId(), map, width, height, new WorkerCallback() { @Override public void finished(ImageMap result) { ActionBar.removeMessage(player); MessageSender.sendActionBarMessage(player, ChatColor.DARK_GREEN + I.t("Updating finished!")); - - } - @Override public void errored(Throwable exception) { player.sendMessage(I.t("{ce}Map rendering failed: {0}", exception.getMessage())); @@ -109,123 +101,17 @@ public class UpdateCommand extends IoMCommand } }); } - //Added to fix bug with rendering displaying after error finally { ActionBar.removeMessage(player); } - } catch(MalformedURLException ex) { throwInvalidArgument(I.t("Invalid URL.")); return; } - /*catch (MapManagerException ex){ - throwInvalidArgument(I.t("Update failed.")); - return; - }*/ - - - - - - /* if(args.length >= 2) - { - if(args.length >= 4) { - width = Integer.parseInt(args[2]); - height = Integer.parseInt(args[3]); - } - - switch(args[1]) { - case "resize": scaling = ImageUtils.ScalingType.CONTAINED; break; - case "resize-stretched": scaling = ImageUtils.ScalingType.STRETCHED; break; - case "resize-covered": scaling = ImageUtils.ScalingType.COVERED; break; - default: throwInvalidArgument(I.t("Invalid Stretching mode.")); break; - } - }*/ - /* try { - - - ActionBar.sendPermanentMessage(player, ChatColor.DARK_GREEN + I.t("Updating map...")); - //ImageRendererExecutor.render(url, scaling, player.getUniqueId(), width, height, new WorkerCallback() { - @Override - public void finished(ImageMap result) { - ActionBar.removeMessage(player); - MessageSender.sendActionBarMessage(player, ChatColor.DARK_GREEN + I.t("Rendering finished!")); - - if (result.give(player) && (result instanceof PosterMap && !((PosterMap) result).hasColumnData())) { - info(I.t("The rendered map was too big to fit in your inventory.")); - info(I.t("Use '/maptool getremaining' to get the remaining maps.")); - } - } - - @Override - public void errored(Throwable exception) { - player.sendMessage(I.t("{ce}Map rendering failed: {0}", exception.getMessage())); - - PluginLogger.warning("Rendering from {0} failed: {1}: {2}", - player.getName(), - exception.getClass().getCanonicalName(), - exception.getMessage()); - } - }); - } - //Added to fix bug with rendering displaying after error - finally { - ActionBar.removeMessage(player); - }*/ } - -/* - - @Override - protected void run() throws CommandException - { - ImageMap map = getMapFromArgs(); - - if (!hasFlag("confirm")) - { - RawText msg = new RawText(I.t("You are going to update") + " ") - .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 updated {bold}forever{red}!"))) - .command(getClass(), map.getId(), "--confirm") - .build(); - - send(msg); - } - else - { - Player player = playerSender(); - MapManager.clear(player.getInventory(), map); - - try - { - MapManager.updateMap(map); - info(I.t("Map successfully updated.")); - } - catch (MapManagerException ex) - { - PluginLogger.warning("A non-existent map was requested to be updated", ex); - warning(I.t("This map does not exist.")); - } - } - } - - @Override - protected List complete() throws CommandException - { - if(args.length == 1) - return getMatchingMapNames(playerSender(), args[0]); - - return null; - } -*/ @Override public boolean canExecute(CommandSender sender) { diff --git a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java index b52da7b..f8c1a35 100644 --- a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java +++ b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java @@ -142,16 +142,9 @@ public class ImageRendererExecutor extends Worker // Limits are in place and the player does NOT have rights to avoid them. checkSizeLimit(playerUUID, image ); - updateMap(ImageUtils.ScalingType.CONTAINED.resize(image, width*128, height*128),playerUUID,map.getMapsIDs()); return map; - /*if (scaling != ImageUtils.ScalingType.NONE && height <= 1 && width <= 1) - { - return updateSingle(scaling.resize(image, ImageMap.WIDTH, ImageMap.HEIGHT), playerUUID); - } - final BufferedImage resizedImage = scaling.resize(image, ImageMap.WIDTH * width, ImageMap.HEIGHT * height); - return updatePoster(resizedImage, playerUUID);*/ } }, callback); @@ -162,8 +155,6 @@ public class ImageRendererExecutor extends Worker final PosterImage poster = new PosterImage(image); poster.splitImages(); - - ImageIOExecutor.saveImage(mapsIDs, poster); if (PluginConfiguration.SAVE_FULL_IMAGE.get()) @@ -179,10 +170,7 @@ public class ImageRendererExecutor extends Worker Renderer.installRenderer(poster, mapsIDs); return null; } - }); - - } static private ImageMap renderSingle(final BufferedImage image, final UUID playerUUID) throws Throwable { diff --git a/src/main/java/fr/moribus/imageonmap/map/ImageMap.java b/src/main/java/fr/moribus/imageonmap/map/ImageMap.java index 27c0a88..d1828c0 100644 --- a/src/main/java/fr/moribus/imageonmap/map/ImageMap.java +++ b/src/main/java/fr/moribus/imageonmap/map/ImageMap.java @@ -167,18 +167,9 @@ public abstract class ImageMap implements ConfigurationSerializable { PluginLogger.info(" "+tMap.toString()); if(tMap.get("id").equals(id)) { - return new Integer[]{(Integer)tMap.get("columns"), (Integer)tMap.get("rows")}; - } } - - - - - - - return null; } static protected T getFieldValue(Map map, String fieldName) throws InvalidConfigurationException From 97adcf4aafecfccc8531ca3346c5d21c2c6700a4 Mon Sep 17 00:00:00 2001 From: Vlammar Date: Thu, 16 Jul 2020 03:01:48 +0200 Subject: [PATCH 14/44] Forget a commented code part --- src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java b/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java index de4ee96..184e5e6 100644 --- a/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java +++ b/src/main/java/fr/moribus/imageonmap/map/PlayerMapStore.java @@ -149,11 +149,7 @@ public class PlayerMapStore implements ConfigurationSerializable { return new ArrayList(mapList); } - - /*public synchronized ArrayList getMapList() - { - return mapList; - }*/ + public synchronized ImageMap[] getMaps() { return mapList.toArray(new ImageMap[mapList.size()]); From bef12a235a0bb19c8f6d47b65a40802b297ace2b Mon Sep 17 00:00:00 2001 From: Vlammar Date: Thu, 16 Jul 2020 14:07:08 +0200 Subject: [PATCH 15/44] Added scaling support, remove an unused print --- .../commands/maptool/UpdateCommand.java | 22 ++++++++++++++++--- .../image/ImageRendererExecutor.java | 2 +- .../fr/moribus/imageonmap/map/ImageMap.java | 3 --- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java index d1baf8c..9302c8d 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java @@ -58,7 +58,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; -@CommandInfo (name = "update", usageParameters = " [--confirm]") +@CommandInfo (name = "update", usageParameters = " [stretched|covered] \"\" [--confirm]") @WithFlags ({"confirm"}) public class UpdateCommand extends IoMCommand { @@ -66,14 +66,30 @@ public class UpdateCommand extends IoMCommand protected void run() throws CommandException { final Player player = playerSender(); - ImageUtils.ScalingType scaling = ImageUtils.ScalingType.NONE; + ImageUtils.ScalingType scaling; + URL url; if(args.length < 1) throwInvalidArgument(I.t("You must give an URL and a map name to update.")); if(args.length < 2) throwInvalidArgument(I.t("You must give a map name to update.")); - ImageMap map=getMapFromArgs(player,1,true); + switch(args[1]) { + case "stretched": + scaling = ImageUtils.ScalingType.STRETCHED; + break; + case "covered": + scaling = ImageUtils.ScalingType.COVERED; + break; + default: + scaling = ImageUtils.ScalingType.CONTAINED; + break; + } + ImageMap map; + if(scaling.equals(ImageUtils.ScalingType.CONTAINED)) + map=getMapFromArgs(player,1,true); + else + map=getMapFromArgs(player,2,true); try { url = new URL(args[0]); diff --git a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java index f8c1a35..a180448 100644 --- a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java +++ b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java @@ -142,7 +142,7 @@ public class ImageRendererExecutor extends Worker // Limits are in place and the player does NOT have rights to avoid them. checkSizeLimit(playerUUID, image ); - updateMap(ImageUtils.ScalingType.CONTAINED.resize(image, width*128, height*128),playerUUID,map.getMapsIDs()); + updateMap(scaling.resize(image, width*128, height*128),playerUUID,map.getMapsIDs()); return map; } diff --git a/src/main/java/fr/moribus/imageonmap/map/ImageMap.java b/src/main/java/fr/moribus/imageonmap/map/ImageMap.java index d1828c0..1b15290 100644 --- a/src/main/java/fr/moribus/imageonmap/map/ImageMap.java +++ b/src/main/java/fr/moribus/imageonmap/map/ImageMap.java @@ -39,7 +39,6 @@ package fr.moribus.imageonmap.map; import fr.moribus.imageonmap.ImageOnMap; import fr.moribus.imageonmap.ui.MapItemManager; import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.PluginLogger; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.InvalidConfigurationException; @@ -162,10 +161,8 @@ public abstract class ImageMap implements ConfigurationSerializable List> list = (List>) section.getList("mapList"); if(list == null) return null; - PluginLogger.info("list "); for(Map tMap : list) { - PluginLogger.info(" "+tMap.toString()); if(tMap.get("id").equals(id)) { return new Integer[]{(Integer)tMap.get("columns"), (Integer)tMap.get("rows")}; } From c92af51a50cec0f2cb7ab0180524787f8d3f2230 Mon Sep 17 00:00:00 2001 From: Vlammar Date: Thu, 23 Jul 2020 02:02:18 +0200 Subject: [PATCH 16/44] added support for quote --- .../imageonmap/commands/IoMCommand.java | 43 +++++++++++++++++++ .../commands/maptool/UpdateCommand.java | 11 ++--- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java b/src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java index 25efd58..9bcfd20 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java @@ -40,10 +40,13 @@ import fr.moribus.imageonmap.map.MapManager; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.CommandException; import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.PluginLogger; import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public abstract class IoMCommand extends Command @@ -52,7 +55,47 @@ public abstract class IoMCommand extends Command { return getMapFromArgs(playerSender(), 0, true); } +//TODO:Add the quote system to zlib and refactor this + protected ImageMap getMapFromArgs(Player player, int index) throws CommandException + { + if(args.length <= index) throwInvalidArgument(I.t("You need to give a map name.")); + ImageMap map; + String mapName = args[index]; + for (int i = index + 1, c = args.length; i < c; i++) { + mapName += " " + args[i]; + } + String regex="((\"([^\\\"]*(\\\\\\\")*)*([^\\\\\\\"]\"))|([^\\\"\\s\\\\]*(\\\\\\s)*[\\\\]*)*\"?)"; + + Pattern pattern=Pattern.compile(regex); + Matcher matcher=pattern.matcher(mapName); + + StringBuilder result = new StringBuilder(); + + matcher.find(); + result.append(matcher.group(0)); + if(result!=null) + if(result.charAt(0)=='\"') + if(result.length()==1){ + result.deleteCharAt(0); + } + else + if(result.charAt(result.length()-1)=='\"') { + result=result.deleteCharAt(result.length() - 1); + if(result!=null&&!result.equals("")&&result.charAt(0)=='\"') + mapName=result.deleteCharAt(0).toString(); + + } + + + mapName = mapName.trim(); + + map = MapManager.getMap(player.getUniqueId(), mapName); + + if(map == null) error(I.t("This map does not exist.")); + PluginLogger.info(""+map.getName()); + return map; + } protected ImageMap getMapFromArgs(Player player, int index, boolean expand) throws CommandException { if(args.length <= index) throwInvalidArgument(I.t("You need to give a map name.")); diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java index 9302c8d..ba2af51 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java @@ -44,7 +44,6 @@ import fr.moribus.imageonmap.map.ImageMap; import fr.moribus.imageonmap.map.MapManager; 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.worker.WorkerCallback; import fr.zcraft.zlib.tools.PluginLogger; @@ -58,8 +57,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; -@CommandInfo (name = "update", usageParameters = " [stretched|covered] \"\" [--confirm]") -@WithFlags ({"confirm"}) +@CommandInfo (name = "update", usageParameters = " [stretched|covered] \"\"") public class UpdateCommand extends IoMCommand { @Override @@ -86,14 +84,17 @@ public class UpdateCommand extends IoMCommand break; } ImageMap map; + PluginLogger.info("getting mapfromargs"); if(scaling.equals(ImageUtils.ScalingType.CONTAINED)) - map=getMapFromArgs(player,1,true); + map=getMapFromArgs(player,1); else - map=getMapFromArgs(player,2,true); + map=getMapFromArgs(player,2); + PluginLogger.info("getted mapfromargs"); try { url = new URL(args[0]); MapManager.load(); + Integer[] size={1,1}; if(map.getType()== ImageMap.Type.POSTER) size=map.getSize( new HashMap(),map.getUserUUID(),map.getId()); From e4c3c8ddf53adfad0ee8597950d925b529596b76 Mon Sep 17 00:00:00 2001 From: Vlammar Date: Thu, 23 Jul 2020 04:14:39 +0200 Subject: [PATCH 17/44] updated plugin.yml --- src/main/resources/plugin.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index ef82c43..05bcd5a 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -25,6 +25,7 @@ permissions: imageonmap.rename: true imageonmap.delete: true imageonmap.bypasssize: false + imageonmap.update: false imageonmap.userender: description: "Allows you to use /tomap and related commands (/maptool getremaing). Alias of imageonmap.new." @@ -61,3 +62,7 @@ permissions: imageonmap.bypasssize: description: "Allows you to create maps larger than the configured limit." default: op + + imageonmap.update: + description: "Allows you to update a map." + default: op From 71d620b83d9ac8e57110ffa19a35115ea4f6707d Mon Sep 17 00:00:00 2001 From: Vlammar Date: Thu, 23 Jul 2020 15:01:55 +0200 Subject: [PATCH 18/44] Added chinese, thanks to Souir_Tommer --- src/main/resources/config.yml | 2 +- src/main/resources/i18n/zh_CN.po | 595 +++++++++++++++++++++++++++++++ 2 files changed, 596 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/i18n/zh_CN.po diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 7d84e64..e938e6d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -2,7 +2,7 @@ # Plugin language. Empty: system language. -# Available: en-US (default, fallback), fr-FR, ru-RU, de-DE. +# Available: en-US (default, fallback), fr-FR, ru-RU, de-DE, zh-CN. lang: diff --git a/src/main/resources/i18n/zh_CN.po b/src/main/resources/i18n/zh_CN.po new file mode 100644 index 0000000..0bf8933 --- /dev/null +++ b/src/main/resources/i18n/zh_CN.po @@ -0,0 +1,595 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-07-10 03:07+0200\n" +"PO-Revision-Date: 2016-07-10 03:08+0200\n" +"Last-Translator: Souir_Tommer\n" +"Language-Team: \n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n < 1 || n > 1);\n" +"X-Generator: Poedit 1.8.7.1\n" + +#: src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java:40 +msgid "You need to give a map name." +msgstr "你需要提供名称" + +#: src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java:57 +#: src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteNoConfirmCommand.java:51 +msgid "This map does not exist." +msgstr "该地图不存在" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteConfirmCommand.java:39 +msgid "You are going to delete" +msgstr "你将要删除" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteConfirmCommand.java:42 +msgid "Are you sure ? " +msgstr "你确定吗? " + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteConfirmCommand.java:44 +msgid "[Confirm]" +msgstr "[确定]" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteConfirmCommand.java:46 +msgid "{red}This map will be deleted {bold}forever{red}!" +msgstr "{red}这个地图将会永久 {bold}删除{red}!" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteNoConfirmCommand.java:46 +msgid "Map successfully deleted." +msgstr "地图已成功删除" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/GetCommand.java:38 +msgid "The requested map was too big to fit in your inventory." +msgstr "请求的地图太大,无法容纳到您的背包中" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/GetCommand.java:39 +#: src/main/java/fr/moribus/imageonmap/commands/maptool/NewCommand.java:71 +msgid "Use '/maptool getremaining' to get the remaining maps." +msgstr "Use '/maptool getremaining' to get the remaining maps." + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/GetRemainingCommand.java:38 +msgid "You have no remaining map." +msgstr "你没有剩余的地图" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/GetRemainingCommand.java:46 +msgid "" +"Your inventory is full! Make some space before requesting the remaining maps." +msgstr "" +"你的背包已满!" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/GetRemainingCommand.java:50 +#, java-format +msgid "There is {0} map remaining." +msgid_plural "There are {0} maps remaining." +msgstr[0] "剩余 {0} 张地图" +msgstr[1] "剩余 {0} 张地图" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/ListCommand.java:49 +msgid "No map found." +msgstr "找不到地图" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/ListCommand.java:53 +msgid "{white}{bold}{0} map found." +msgid_plural "{white}{bold}{0} maps found." +msgstr[0] "{white}{bold}{0} 地图" +msgstr[1] "{white}{bold}{0} 地图" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/ListCommand.java:79 +msgid "{white}Click{gray} to get this map" +msgstr "{white}点击{gray} 得到这张地图" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/MigrateCommand.java:36 +msgid "A migration process is already running. Check console for details." +msgstr "进程已在运行..请等待" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/MigrateCommand.java:40 +msgid "Migration started. See console for details." +msgstr "开始..." + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/NewCommand.java:44 +msgid "You must give an URL to take the image from." +msgstr "您必须提供URL才能从中获取图像" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/NewCommand.java:52 +msgid "Invalid URL." +msgstr "无效的网址" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/NewCommand.java:61 +msgid "Rendering..." +msgstr "渲染..." + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/NewCommand.java:67 +msgid "Rendering finished!" +msgstr "渲染完成!" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/NewCommand.java:70 +msgid "The rendered map was too big to fit in your inventory." +msgstr "渲染的地图太大" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/NewCommand.java:78 +msgid "{ce}Map rendering failed: {0}" +msgstr "{ce}地图渲染失败: {0}" + +#. The title of the map deletion GUI. {0}: map name. +#: src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java:102 +msgid "{0} » {black}Confirm deletion" +msgstr "{0} » {black}确认删除" + +#. The title of the map deletion item +#: src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java:110 +msgid "{red}You're about to destroy this map..." +msgstr "{red}您将要销毁这张地图..." + +#. The end, in the lore, of a title starting with “You're about to destroy this map...”. +#: src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java:112 +msgid "{red}...{italic}forever{red}." +msgstr "{red}...{italic}永久{red}." + +#: src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java:114 +msgid "{gray}Name: {white}{0}" +msgstr "{gray}名称: {white}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java:115 +msgid "{gray}Map ID: {white}{0}" +msgstr "{gray}地图 ID: {white}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java:116 +msgid "{gray}Maps inside: {white}{0}" +msgstr "{gray}地图: {white}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java:178 +msgid "{gray}Map successfully deleted." +msgstr "{gray}地图已成功删除" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:54 +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:71 +msgid "{green}Map part" +msgstr "{green}地图部分" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:55 +msgid "{gray}Column: {white}{0}" +msgstr "{gray}高: {white}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:56 +msgid "{gray}Row: {white}{0}" +msgstr "{gray}宽: {white}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:58 +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:74 +msgid "{gray}» {white}Click{gray} to get only this part" +msgstr "{gray}» {white}点击{gray} 得到这部分" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:72 +msgid "{gray}Part: {white}{0}" +msgstr "{gray}部分: {white}{0}" + +#. Title of the map details GUI +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:114 +msgid "Your maps » {black}{0}" +msgstr "你的地图 » {black}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:136 +msgid "{blue}Rename this image" +msgstr "{blue}重命名这张图片" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:137 +msgid "" +"{gray}Click here to rename this image; this is used for your own " +"organization." +msgstr "" +"{gray}点击此处重命名该图像; 这只对自己生效" +"" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:141 +msgid "{red}Delete this image" +msgstr "{red}删除这张图片" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:142 +msgid "" +"{gray}Deletes this map {white}forever{gray}. This action cannot be undone!" +msgstr "" +"{white}永久{gray} {gray}删除这张地图,此操作无法撤消!" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:144 +msgid "{gray}You will be asked to confirm your choice if you click here." +msgstr "{gray}You will be asked to confirm your choice if you click here." + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:156 +msgid "{green}« Back" +msgstr "{green}« 返回" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:157 +msgid "{gray}Go back to the list." +msgstr "{gray}返回到列表" + +#. Displayed subtitle description of a single map on the list GUI +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:44 +msgid "{white}Single map" +msgstr "{white}单张地图" + +#. Displayed subtitle description of a poster map on the list GUI (columns × rows in english) +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:52 +msgid "{white}Poster map ({0} × {1})" +msgstr "{white}地图大小 ({0} × {1})" + +#. Displayed subtitle description of a poster map without column data on the list GUI +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:57 +msgid "{white}Poster map ({0} parts)" +msgstr "{white}地图大小 ({0} 部分)" + +#. Displayed title of a map on the list GUI +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:62 +msgid "{green}{bold}{0}" +msgstr "{green}{bold}{0}" + +#. Map ID displayed in the tooltip of a map on the list GUI +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:67 +msgid "{gray}Map ID: {0}" +msgstr "{gray}地图 ID: {0}" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:69 +msgid "{gray}» {white}Left-click{gray} to get this map" +msgstr "{gray}» {white}左击{gray} 获得地图" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:70 +msgid "{gray}» {white}Right-click{gray} for details and options" +msgstr "{gray}» {white}右击{gray} 打开更多设置" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:79 +msgid "{red}You don't have any map." +msgstr "{red}你还没有任何地图" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:80 +msgid "" +"{gray}Get started by creating a new one using {white}/tomap [resize]" +"{gray}!" +msgstr "" +"{gray}使用指令创建地图吧 {white}/tomap [resize]" +"{gray}!" + +#. The maps list GUI title +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:119 +msgid "{black}Your maps {reset}({0})" +msgstr "{black}你的地图 {reset}({0})" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:148 +msgid "{blue}Usage statistics" +msgstr "{blue}使用状态" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:150 +msgid "{white}{0}{gray} image rendered" +msgid_plural "{white}{0}{gray} images rendered" +msgstr[0] "{white}{0}{gray} 渲染地图" +msgstr[1] "{white}{0}{gray} 渲染地图" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:151 +msgid "{white}{0}{gray} Minecraft map used" +msgid_plural "{white}{0}{gray} Minecraft maps used" +msgstr[0] "{white}{0}{gray} 张地图用量" +msgstr[1] "{white}{0}{gray} 张地图用量" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:156 +msgid "{blue}Minecraft maps limits" +msgstr "{blue}minecraft地图限制" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:158 +msgid "{gray}Server-wide limit: {white}unlimited" +msgstr "{gray}Server-wide limit: {white}unlimited" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:159 +msgid "{gray}Server-wide limit: {white}{0}" +msgstr "{gray}Server-wide limit: {white}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:161 +msgid "{gray}Per-player limit: {white}unlimited" +msgstr "{gray}Per-player limit: {white}unlimited" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:162 +msgid "{gray}Per-player limit: {white}{0}" +msgstr "{gray}Per-player limit: {white}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:164 +msgid "{white}{0} %{gray} of your quota used" +msgstr "{white}{0} %{gray} of your quota used" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:165 +msgid "{white}{0}{gray} map left" +msgid_plural "{white}{0}{gray} maps left" +msgstr[0] "{white}{0}{gray} map left" +msgstr[1] "{white}{0}{gray} maps left" + +#: src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java:73 +#, java-format +msgid "HTTP error : {0} {1}" +msgstr "HTTP error : {0} {1}" + +#: src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java:79 +msgid "The given URL is not a valid image" +msgstr "指定的网址不是有效的图片" + +#. The default display name of a map +#: src/main/java/fr/moribus/imageonmap/map/ImageMap.java:44 +msgid "Map" +msgstr "地图" + +#: src/main/java/fr/moribus/imageonmap/map/MapManagerException.java:29 +#, java-format +msgid "You have too many maps (maximum : {0})." +msgstr "You have too many maps (maximum : {0})." + +#: src/main/java/fr/moribus/imageonmap/map/MapManagerException.java:30 +msgid "The server ImageOnMap limit has been reached." +msgstr "The server ImageOnMap limit has been reached." + +#: src/main/java/fr/moribus/imageonmap/map/MapManagerException.java:31 +msgid "The given map does not exist." +msgstr "地图不存在." + +#: src/main/java/fr/moribus/imageonmap/migration/MigratorExecutor.java:34 +msgid "Migration is already running." +msgstr "迁移已在运行" + +#: src/main/java/fr/moribus/imageonmap/migration/MigratorExecutor.java:50 +msgid "Waiting for migration to finish..." +msgstr "等待迁移完成..." + +#: src/main/java/fr/moribus/imageonmap/migration/MigratorExecutor.java:58 +msgid "" +"Migration thread has been interrupted while waiting to finish. It may not " +"have ended correctly." +msgstr "" +"Migration thread has been interrupted while waiting to finish. It may not " +"have ended correctly." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:176 +msgid "Error while preparing migration" +msgstr "Error while preparing migration" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:177 +msgid "Aborting migration. No change has been made." +msgstr "Aborting migration. No change has been made." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:189 +msgid "Error while migrating" +msgstr "Error while migrating" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:190 +msgid "Aborting migration. Some changes may already have been made." +msgstr "Aborting migration. Some changes may already have been made." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:191 +msgid "" +"Before trying to migrate again, you must recover player files from the " +"backups, and then move the backups away from the plugin directory to avoid " +"overwriting them." +msgstr "" +"Before trying to migrate again, you must recover player files from the " +"backups, and then move the backups away from the plugin directory to avoid " +"overwriting them." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:203 +msgid "Looking for configuration files to migrate..." +msgstr "Looking for configuration files to migrate..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:206 +#, java-format +msgid "Detected former posters file {0}" +msgstr "Detected former posters file {0}" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:209 +#, java-format +msgid "Detected former maps file {0}" +msgstr "Detected former maps file {0}" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:213 +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:416 +msgid "There is nothing to migrate. Stopping." +msgstr "There is nothing to migrate. Stopping." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:218 +msgid "Done." +msgstr "Done." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:232 +msgid "Backup directories already exists." +msgstr "Backup directories already exists." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:233 +msgid "" +"This means that a migration has already been done, or may not have ended " +"well." +msgstr "" +"This means that a migration has already been done, or may not have ended " +"well." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:234 +msgid "" +"To start a new migration, you must move away the backup directories so they " +"are not overwritten." +msgstr "" +"To start a new migration, you must move away the backup directories so they " +"are not overwritten." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:247 +msgid "Backing up map data before migrating..." +msgstr "Backing up map data before migrating..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:271 +msgid "Backup complete." +msgstr "Backup complete." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:352 +msgid "Fetching UUIDs from Mojang..." +msgstr "Fetching UUIDs from Mojang..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:359 +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:387 +msgid "An error occurred while fetching the UUIDs from Mojang" +msgstr "An error occurred while fetching the UUIDs from Mojang" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:364 +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:392 +msgid "The migration worker has been interrupted" +msgstr "The migration worker has been interrupted" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:367 +#, java-format +msgid "Fetching done. {0} UUID have been retrieved." +msgid_plural "Fetching done. {0} UUIDs have been retrieved." +msgstr[0] "Fetching done. {0} UUID have been retrieved." +msgstr[1] "Fetching done. {0} UUIDs have been retrieved." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:378 +#, java-format +msgid "Mojang did not find UUIDs for {0} player at the current time." +msgid_plural "Mojang did not find UUIDs for {0} players at the current time." +msgstr[0] "Mojang did not find UUIDs for {0} player at the current time." +msgstr[1] "Mojang did not find UUIDs for {0} players at the current time." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:379 +msgid "" +"The Mojang servers limit requests rate at one per second, this may take some " +"time..." +msgstr "" +"The Mojang servers limit requests rate at one per second, this may take some " +"time..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:398 +#, java-format +msgid "Mojang did not find player data for {0} player" +msgid_plural "Mojang did not find player data for {0} players" +msgstr[0] "Mojang did not find player data for {0} player" +msgstr[1] "Mojang did not find player data for {0} players" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:400 +msgid "The following players do not exist or do not have paid accounts :" +msgstr "The following players do not exist or do not have paid accounts :" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:415 +msgid "Mojang could not find any of the registered players." +msgstr "Mojang could not find any of the registered players." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:425 +msgid "Merging map data..." +msgstr "Merging map data..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:475 +#, java-format +msgid "{0} registered minecraft map is missing from the save." +msgid_plural "{0} registered minecraft maps are missing from the save." +msgstr[0] "{0} registered minecraft map is missing from the save." +msgstr[1] "{0} registered minecraft maps are missing from the save." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:476 +msgid "" +"These maps will not be migrated, but this could mean the save has been " +"altered or corrupted." +msgstr "" +"These maps will not be migrated, but this could mean the save has been " +"altered or corrupted." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:477 +#, java-format +msgid "The following maps are missing : {0} " +msgstr "The following maps are missing : {0} " + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:483 +msgid "Saving changes..." +msgstr "Saving changes..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:489 +msgid "Cleaning up old data files..." +msgstr "Cleaning up old data files..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:496 +msgid "Deleting old map data file..." +msgstr "Deleting old map data file..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:501 +#, java-format +msgid "{0} map could not be migrated." +msgid_plural "{0} maps could not be migrated." +msgstr[0] "{0} map could not be migrated." +msgstr[1] "{0} maps could not be migrated." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:519 +msgid "Deleting old poster data file..." +msgstr "Deleting old poster data file..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:524 +#, java-format +msgid "{0} poster could not be migrated." +msgid_plural "{0} posters could not be migrated." +msgstr[0] "{0} poster could not be migrated." +msgstr[1] "{0} posters could not be migrated." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:537 +msgid "Data that has not been migrated will be kept in the old data files." +msgstr "Data that has not been migrated will be kept in the old data files." + +#. The name of a map item given to a player, if splatter maps are not used. 0 = map name; 1 = index. +#: src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java:139 +#: src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java:215 +#, java-format +msgid "{0} (part {1})" +msgstr "{0} (部分 {1})" + +#. The name of a map item given to a player, if splatter maps are not used. 0 = map name; 1 = row; 2 = column. +#: src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java:145 +#: src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java:213 +#, java-format +msgid "{0} (row {1}, column {2})" +msgstr "{0} (宽 {1}, 高 {2})" + +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:44 +msgid "Splatter Map" +msgstr "扩散地图" + +#. Title in a splatter map tooltip +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:48 +msgid "Item frames needed" +msgstr "展示框空间所需" + +#. Size of a map stored in a splatter map +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:56 +#, java-format +msgid "{0} × {1}" +msgstr "宽: {0} × 高: {1}" + +#. Size of a map stored in a splatter map, including the total frames count +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:62 +#, java-format +msgid "{0} × {1} (total {2} frames)" +msgstr "宽: {0} × 高: {1} (共需要 {2} 展示框)" + +#. Title in a splatter map tooltip +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:53 +msgid "How to use this?" +msgstr "如何使用?" + +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:54 +msgid "" +"Place empty item frames on a wall, enough to host the whole map. Then, right-" +"click on the bottom-left frame with this map." +msgstr "" +"把一样宽高的展示框全部放在墙上,然后手持此地图右键左下角的" +"展示框即可" + +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:56 +msgid "" +"Shift-click one of the placed maps to remove the whole poster in one shot." +msgstr "" +"潜行攻击放置的地图,即可收回整张地图" + +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:101 +msgid "{ce}There is not enough space to place this map ({0} × {1})." +msgstr "{ce}这里没有足够的空间 (宽: {0} × 高: {1})" From 5be7aa2b11b49183117ca6d7d10a0436b6d5d674 Mon Sep 17 00:00:00 2001 From: Kotlia Date: Tue, 28 Jul 2020 10:02:14 -0400 Subject: [PATCH 19/44] Add Japanese --- src/main/resources/i18n/jp_JP.po | 594 +++++++++++++++++++++++++++++++ 1 file changed, 594 insertions(+) create mode 100644 src/main/resources/i18n/jp_JP.po diff --git a/src/main/resources/i18n/jp_JP.po b/src/main/resources/i18n/jp_JP.po new file mode 100644 index 0000000..0d3291d --- /dev/null +++ b/src/main/resources/i18n/jp_JP.po @@ -0,0 +1,594 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-07-27 03:07+0200\n" +"PO-Revision-Date: 2016-07-27 03:08+0200\n" +"Last-Translator: Kotlia\n" +"Language-Team: \n" +"Language: ja_JA\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n < 1 || n > 1);\n" +"X-Generator: Poedit 1.8.7.1\n" + +#: src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java:40 +msgid "You need to give a map name." +msgstr "マップ名が必要です!" + +#: src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java:57 +#: src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteNoConfirmCommand.java:51 +msgid "This map does not exist." +msgstr "このマップは存在しません" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteConfirmCommand.java:39 +msgid "You are going to delete" +msgstr "これを削除します" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteConfirmCommand.java:42 +msgid "Are you sure ? " +msgstr "大丈夫ですか?" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteConfirmCommand.java:44 +msgid "[Confirm]" +msgstr "[確定]" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteConfirmCommand.java:46 +msgid "{red}This map will be deleted {bold}forever{red}!" +msgstr "{red}このマップは {bold}復元不可能になります{red}!" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteNoConfirmCommand.java:46 +msgid "Map successfully deleted." +msgstr "削除に成功しました" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/GetCommand.java:38 +msgid "The requested map was too big to fit in your inventory." +msgstr "マップのサイズがインベントリに対して大きすぎます" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/GetCommand.java:39 +#: src/main/java/fr/moribus/imageonmap/commands/maptool/NewCommand.java:71 +msgid "Use '/maptool getremaining' to get the remaining maps." +msgstr "残りのマップを取得するには '/maptool getremaining' を実行して下さい。" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/GetRemainingCommand.java:38 +msgid "You have no remaining map." +msgstr "残りのマップは存在しません" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/GetRemainingCommand.java:46 +msgid "" +"Your inventory is full! Make some space before requesting the remaining maps." +msgstr "" +"インベントリが一杯です!" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/GetRemainingCommand.java:50 +#, java-format +msgid "There is {0} map remaining." +msgid_plural "There are {0} maps remaining." +msgstr[0] "残り {0} 枚のマップが残っています" +msgstr[1] "残り {0} 枚のマップが残っています" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/ListCommand.java:49 +msgid "No map found." +msgstr "マップが見つかりませんでした" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/ListCommand.java:53 +msgid "{white}{bold}{0} map found." +msgid_plural "{white}{bold}{0} maps found." +msgstr[0] "{white}{bold}{0} 枚のマップを発見しました" +msgstr[1] "{white}{bold}{0} 枚のマップを発見しました" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/ListCommand.java:79 +msgid "{white}Click{gray} to get this map" +msgstr "{gray}マップを取得するには{white}ここをクリック" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/MigrateCommand.java:36 +msgid "A migration process is already running. Check console for details." +msgstr "移行中...コンソールで詳細を確認できます" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/MigrateCommand.java:40 +msgid "Migration started. See console for details." +msgstr "移行開始...コンソールで詳細を確認できます" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/NewCommand.java:44 +msgid "You must give an URL to take the image from." +msgstr "画像URLが必要です!" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/NewCommand.java:52 +msgid "Invalid URL." +msgstr "無効なURLです" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/NewCommand.java:61 +msgid "Rendering..." +msgstr "レンダリング中..." + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/NewCommand.java:67 +msgid "Rendering finished!" +msgstr "レンダリング完了!" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/NewCommand.java:70 +msgid "The rendered map was too big to fit in your inventory." +msgstr "レンダリングされたマップはインベントリに対して大きすぎます!" + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/NewCommand.java:78 +msgid "{ce}Map rendering failed: {0}" +msgstr "{ce}レンダリング失敗: {0}" + +#. The title of the map deletion GUI. {0}: map name. +#: src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java:102 +msgid "{0} » {black}Confirm deletion" +msgstr "{0} » {black}削除確認" + +#. The title of the map deletion item +#: src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java:110 +msgid "{red}You're about to destroy this map..." +msgstr "{red}このマップを破壊しようとしています..." + +#. The end, in the lore, of a title starting with “You're about to destroy this map...”. +#: src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java:112 +msgid "{red}...{italic}forever{red}." +msgstr "{red}...{italic}永遠{red}." + +#: src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java:114 +msgid "{gray}Name: {white}{0}" +msgstr "{gray}名前: {white}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java:115 +msgid "{gray}Map ID: {white}{0}" +msgstr "{gray}マップ ID: {white}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java:116 +msgid "{gray}Maps inside: {white}{0}" +msgstr "{gray}マップ: {white}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java:178 +msgid "{gray}Map successfully deleted." +msgstr "{gray}マップの削除に成功しました" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:54 +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:71 +msgid "{green}Map part" +msgstr "{green}マップ部分" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:55 +msgid "{gray}Column: {white}{0}" +msgstr "{gray}縦: {white}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:56 +msgid "{gray}Row: {white}{0}" +msgstr "{gray}横: {white}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:58 +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:74 +msgid "{gray}» {white}Click{gray} to get only this part" +msgstr "{gray}» {gray} ここだけを入手するには {white}クリック" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:72 +msgid "{gray}Part: {white}{0}" +msgstr "{gray}部分: {white}{0}" + +#. Title of the map details GUI +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:114 +msgid "Your maps » {black}{0}" +msgstr "あなたのマップ » {black}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:136 +msgid "{blue}Rename this image" +msgstr "{blue}このイメージの名前を変更" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:137 +msgid "" +"{gray}Click here to rename this image; this is used for your own " +"organization." +msgstr "" +"{gray}このイメージの名前を変更...自分のみに反映されます" +"" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:141 +msgid "{red}Delete this image" +msgstr "{red}この写真を削除" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:142 +msgid "" +"{gray}Deletes this map {white}forever{gray}. This action cannot be undone!" +msgstr "" +"{white}削除・永久{gray} {gray}に復旧出来ません。" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:144 +msgid "{gray}You will be asked to confirm your choice if you click here." +msgstr "{gray}You will be asked to confirm your choice if you click here." + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:156 +msgid "{green}« Back" +msgstr "{green}« 戻る" + +#: src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java:157 +msgid "{gray}Go back to the list." +msgstr "{gray}表に戻る" + +#. Displayed subtitle description of a single map on the list GUI +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:44 +msgid "{white}Single map" +msgstr "{white}一つのマップ" + +#. Displayed subtitle description of a poster map on the list GUI (columns × rows in english) +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:52 +msgid "{white}Poster map ({0} × {1})" +msgstr "{white}ポスターマップ ({0} × {1})" + +#. Displayed subtitle description of a poster map without column data on the list GUI +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:57 +msgid "{white}Poster map ({0} parts)" +msgstr "{white}ポスターマップ ({0} 部分)" + +#. Displayed title of a map on the list GUI +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:62 +msgid "{green}{bold}{0}" +msgstr "{green}{bold}{0}" + +#. Map ID displayed in the tooltip of a map on the list GUI +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:67 +msgid "{gray}Map ID: {0}" +msgstr "{gray}マップ ID: {0}" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:69 +msgid "{gray}» {white}Left-click{gray} to get this map" +msgstr "{gray}» {white}左クリック{gray} でこのマップを入手" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:70 +msgid "{gray}» {white}Right-click{gray} for details and options" +msgstr "{gray}» {white}右クリック{gray} で詳細を表示" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:79 +msgid "{red}You don't have any map." +msgstr "{red}あなたはマップを持っていません!" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:80 +msgid "" +"{gray}Get started by creating a new one using {white}/tomap [resize]" +"{gray}!" +msgstr "" +"{gray}まずは作ってみましょう!コマンド: {white}/tomap [resize]" +"{gray}!" + +#. The maps list GUI title +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:119 +msgid "{black}Your maps {reset}({0})" +msgstr "{black}あなたのマップ {reset}({0})" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:148 +msgid "{blue}Usage statistics" +msgstr "{blue}あなたの統計情報" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:150 +msgid "{white}{0}{gray} image rendered" +msgid_plural "{white}{0}{gray} images rendered" +msgstr[0] "{white}{0}{gray} 画像レンダリング完了" +msgstr[1] "{white}{0}{gray} 画像レンダリング完了" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:151 +msgid "{white}{0}{gray} Minecraft map used" +msgid_plural "{white}{0}{gray} Minecraft maps used" +msgstr[0] "{white}{0}{gray} 使用したマップ" +msgstr[1] "{white}{0}{gray} 使用したマップ" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:156 +msgid "{blue}Minecraft maps limits" +msgstr "{blue}minecraftマップリミット" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:158 +msgid "{gray}Server-wide limit: {white}unlimited" +msgstr "{gray}Server-wide limit: {white}unlimited" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:159 +msgid "{gray}Server-wide limit: {white}{0}" +msgstr "{gray}Server-wide limit: {white}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:161 +msgid "{gray}Per-player limit: {white}unlimited" +msgstr "{gray}Per-player limit: {white}unlimited" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:162 +msgid "{gray}Per-player limit: {white}{0}" +msgstr "{gray}Per-player limit: {white}{0}" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:164 +msgid "{white}{0} %{gray} of your quota used" +msgstr "{white}{0} %{gray} of your quota used" + +#: src/main/java/fr/moribus/imageonmap/gui/MapListGui.java:165 +msgid "{white}{0}{gray} map left" +msgid_plural "{white}{0}{gray} maps left" +msgstr[0] "{white}{0}{gray} map left" +msgstr[1] "{white}{0}{gray} maps left" + +#: src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java:73 +#, java-format +msgid "HTTP error : {0} {1}" +msgstr "HTTP error : {0} {1}" + +#: src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java:79 +msgid "The given URL is not a valid image" +msgstr "これは有効な画像URLではありません!" + +#. The default display name of a map +#: src/main/java/fr/moribus/imageonmap/map/ImageMap.java:44 +msgid "Map" +msgstr "マップ" + +#: src/main/java/fr/moribus/imageonmap/map/MapManagerException.java:29 +#, java-format +msgid "You have too many maps (maximum : {0})." +msgstr "保有するマップが多すぎます! (maximum : {0})." + +#: src/main/java/fr/moribus/imageonmap/map/MapManagerException.java:30 +msgid "The server ImageOnMap limit has been reached." +msgstr "The server ImageOnMap limit has been reached." + +#: src/main/java/fr/moribus/imageonmap/map/MapManagerException.java:31 +msgid "The given map does not exist." +msgstr "マップが存在しません." + +#: src/main/java/fr/moribus/imageonmap/migration/MigratorExecutor.java:34 +msgid "Migration is already running." +msgstr "移行は実行中です" + +#: src/main/java/fr/moribus/imageonmap/migration/MigratorExecutor.java:50 +msgid "Waiting for migration to finish..." +msgstr "移行終了待ち..." + +#: src/main/java/fr/moribus/imageonmap/migration/MigratorExecutor.java:58 +msgid "" +"Migration thread has been interrupted while waiting to finish. It may not " +"have ended correctly." +msgstr "" +"Migration thread has been interrupted while waiting to finish. It may not " +"have ended correctly." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:176 +msgid "Error while preparing migration" +msgstr "Error while preparing migration" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:177 +msgid "Aborting migration. No change has been made." +msgstr "Aborting migration. No change has been made." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:189 +msgid "Error while migrating" +msgstr "Error while migrating" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:190 +msgid "Aborting migration. Some changes may already have been made." +msgstr "Aborting migration. Some changes may already have been made." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:191 +msgid "" +"Before trying to migrate again, you must recover player files from the " +"backups, and then move the backups away from the plugin directory to avoid " +"overwriting them." +msgstr "" +"Before trying to migrate again, you must recover player files from the " +"backups, and then move the backups away from the plugin directory to avoid " +"overwriting them." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:203 +msgid "Looking for configuration files to migrate..." +msgstr "Looking for configuration files to migrate..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:206 +#, java-format +msgid "Detected former posters file {0}" +msgstr "Detected former posters file {0}" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:209 +#, java-format +msgid "Detected former maps file {0}" +msgstr "Detected former maps file {0}" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:213 +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:416 +msgid "There is nothing to migrate. Stopping." +msgstr "There is nothing to migrate. Stopping." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:218 +msgid "Done." +msgstr "Done." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:232 +msgid "Backup directories already exists." +msgstr "Backup directories already exists." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:233 +msgid "" +"This means that a migration has already been done, or may not have ended " +"well." +msgstr "" +"This means that a migration has already been done, or may not have ended " +"well." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:234 +msgid "" +"To start a new migration, you must move away the backup directories so they " +"are not overwritten." +msgstr "" +"To start a new migration, you must move away the backup directories so they " +"are not overwritten." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:247 +msgid "Backing up map data before migrating..." +msgstr "Backing up map data before migrating..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:271 +msgid "Backup complete." +msgstr "Backup complete." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:352 +msgid "Fetching UUIDs from Mojang..." +msgstr "Fetching UUIDs from Mojang..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:359 +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:387 +msgid "An error occurred while fetching the UUIDs from Mojang" +msgstr "An error occurred while fetching the UUIDs from Mojang" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:364 +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:392 +msgid "The migration worker has been interrupted" +msgstr "The migration worker has been interrupted" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:367 +#, java-format +msgid "Fetching done. {0} UUID have been retrieved." +msgid_plural "Fetching done. {0} UUIDs have been retrieved." +msgstr[0] "Fetching done. {0} UUID have been retrieved." +msgstr[1] "Fetching done. {0} UUIDs have been retrieved." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:378 +#, java-format +msgid "Mojang did not find UUIDs for {0} player at the current time." +msgid_plural "Mojang did not find UUIDs for {0} players at the current time." +msgstr[0] "Mojang did not find UUIDs for {0} player at the current time." +msgstr[1] "Mojang did not find UUIDs for {0} players at the current time." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:379 +msgid "" +"The Mojang servers limit requests rate at one per second, this may take some " +"time..." +msgstr "" +"The Mojang servers limit requests rate at one per second, this may take some " +"time..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:398 +#, java-format +msgid "Mojang did not find player data for {0} player" +msgid_plural "Mojang did not find player data for {0} players" +msgstr[0] "Mojang did not find player data for {0} player" +msgstr[1] "Mojang did not find player data for {0} players" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:400 +msgid "The following players do not exist or do not have paid accounts :" +msgstr "The following players do not exist or do not have paid accounts :" + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:415 +msgid "Mojang could not find any of the registered players." +msgstr "Mojang could not find any of the registered players." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:425 +msgid "Merging map data..." +msgstr "Merging map data..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:475 +#, java-format +msgid "{0} registered minecraft map is missing from the save." +msgid_plural "{0} registered minecraft maps are missing from the save." +msgstr[0] "{0} registered minecraft map is missing from the save." +msgstr[1] "{0} registered minecraft maps are missing from the save." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:476 +msgid "" +"These maps will not be migrated, but this could mean the save has been " +"altered or corrupted." +msgstr "" +"These maps will not be migrated, but this could mean the save has been " +"altered or corrupted." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:477 +#, java-format +msgid "The following maps are missing : {0} " +msgstr "The following maps are missing : {0} " + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:483 +msgid "Saving changes..." +msgstr "Saving changes..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:489 +msgid "Cleaning up old data files..." +msgstr "Cleaning up old data files..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:496 +msgid "Deleting old map data file..." +msgstr "Deleting old map data file..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:501 +#, java-format +msgid "{0} map could not be migrated." +msgid_plural "{0} maps could not be migrated." +msgstr[0] "{0} map could not be migrated." +msgstr[1] "{0} maps could not be migrated." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:519 +msgid "Deleting old poster data file..." +msgstr "Deleting old poster data file..." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:524 +#, java-format +msgid "{0} poster could not be migrated." +msgid_plural "{0} posters could not be migrated." +msgstr[0] "{0} poster could not be migrated." +msgstr[1] "{0} posters could not be migrated." + +#: src/main/java/fr/moribus/imageonmap/migration/V3Migrator.java:537 +msgid "Data that has not been migrated will be kept in the old data files." +msgstr "Data that has not been migrated will be kept in the old data files." + +#. The name of a map item given to a player, if splatter maps are not used. 0 = map name; 1 = index. +#: src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java:139 +#: src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java:215 +#, java-format +msgid "{0} (part {1})" +msgstr "{0} (部分 {1})" + +#. The name of a map item given to a player, if splatter maps are not used. 0 = map name; 1 = row; 2 = column. +#: src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java:145 +#: src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java:213 +#, java-format +msgid "{0} (row {1}, column {2})" +msgstr "{0} (横 {1}, 縦 {2})" + +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:44 +msgid "Splatter Map" +msgstr "拡散マップ" + +#. Title in a splatter map tooltip +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:48 +msgid "Item frames needed" +msgstr "アイテムフレームが必要です" + +#. Size of a map stored in a splatter map +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:56 +#, java-format +msgid "{0} × {1}" +msgstr "横: {0} × 縦: {1}" + +#. Size of a map stored in a splatter map, including the total frames count +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:62 +#, java-format +msgid "{0} × {1} (total {2} frames)" +msgstr "横: {0} × 縦: {1} (合計 {2} フレーム)" + +#. Title in a splatter map tooltip +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:53 +msgid "How to use this?" +msgstr "これをどうやって使いますか?" + +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:54 +msgid "" +"Place empty item frames on a wall, enough to host the whole map. Then, right-" +"click on the bottom-left frame with this map." +msgstr "" +"アイテムフレームを空にしてから、マップが必要な分のフレームを設置してから、左下のフレームを右クリックして下さい。" + +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:56 +msgid "" +"Shift-click one of the placed maps to remove the whole poster in one shot." +msgstr "" +"シフトクリックでマップを一括削除できます" + +#: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:101 +msgid "{ce}There is not enough space to place this map ({0} × {1})." +msgstr "{ce}このマップを設置するのに十分なスペースがありません! (横: {0} × 縦: {1})" From 8fb4ac550c2d22dc7834672d9d2aabf99bf75de4 Mon Sep 17 00:00:00 2001 From: Kotlia Date: Tue, 28 Jul 2020 10:25:17 -0400 Subject: [PATCH 20/44] Add Japanese --- src/main/resources/i18n/jp_JP.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/i18n/jp_JP.po b/src/main/resources/i18n/jp_JP.po index 0d3291d..433c332 100644 --- a/src/main/resources/i18n/jp_JP.po +++ b/src/main/resources/i18n/jp_JP.po @@ -7,11 +7,11 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-07-27 03:07+0200\n" -"PO-Revision-Date: 2016-07-27 03:08+0200\n" +"POT-Creation-Date: 2020-07-27 21:02+0200\n" +"PO-Revision-Date: 2020-07-27 21:38+0200\n" "Last-Translator: Kotlia\n" "Language-Team: \n" -"Language: ja_JA\n" +"Language: ja_JP\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" From 1f16740d804a88b06bb249d2b5bb9265c97a42e0 Mon Sep 17 00:00:00 2001 From: Kotlia Date: Tue, 28 Jul 2020 11:27:30 -0400 Subject: [PATCH 21/44] Add Japanese --- src/main/resources/config.yml | 2 +- src/main/resources/i18n/{jp_JP.po => ja_JP.po} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/main/resources/i18n/{jp_JP.po => ja_JP.po} (100%) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 3f51a2e..d34b848 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -2,7 +2,7 @@ # Plugin language. Empty: system language. -# Available: en-US (default, fallback), fr-FR, ru-RU, de-DE, zh-CN. +# Available: en-US (default, fallback), fr-FR, ru-RU, de-DE, zh-CN, ja_JP. lang: diff --git a/src/main/resources/i18n/jp_JP.po b/src/main/resources/i18n/ja_JP.po similarity index 100% rename from src/main/resources/i18n/jp_JP.po rename to src/main/resources/i18n/ja_JP.po From 2c734d1cb566254884b1b097ac96a954aa94a6fd Mon Sep 17 00:00:00 2001 From: Vlammar Date: Thu, 30 Jul 2020 11:57:19 +0200 Subject: [PATCH 22/44] fixed bugs of #121 --- .../moribus/imageonmap/ui/MapItemManager.java | 43 +++++++++++++------ .../imageonmap/ui/SplatterMapManager.java | 5 +-- src/main/resources/config.yml | 2 +- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java b/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java index b8e14c5..7c60c76 100644 --- a/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java +++ b/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java @@ -43,6 +43,7 @@ import fr.moribus.imageonmap.map.PosterMap; import fr.moribus.imageonmap.map.SingleMap; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.core.ZLib; +import fr.zcraft.zlib.tools.PluginLogger; import fr.zcraft.zlib.tools.items.ItemStackBuilder; import fr.zcraft.zlib.tools.items.ItemUtils; import org.bukkit.*; @@ -88,7 +89,7 @@ public class MapItemManager implements Listener static public boolean give(Player player, SingleMap map) { - return give(player, createMapItem(map)); + return give(player, createMapItem(map,true)); } static public boolean give(Player player, PosterMap map) @@ -138,12 +139,16 @@ public class MapItemManager implements Listener return !given; } - static public ItemStack createMapItem(SingleMap map) { return createMapItem(map.getMapsIDs()[0], map.getName(), false); } + static public ItemStack createMapItem(SingleMap map, boolean goldTitle) + { + return createMapItem(map.getMapsIDs()[0], map.getName(), false, goldTitle); + } + static public ItemStack createMapItem(PosterMap map, int index) { return createMapItem(map.getMapIdAt(index), getMapTitle(map, index), true); @@ -166,20 +171,32 @@ public class MapItemManager implements Listener return I.t("{0} (part {1})", map.getName(), index + 1); } - static public ItemStack createMapItem(int mapID, String text, boolean isMapPart) + static public ItemStack createMapItem(int mapID, String text, boolean isMapPart, boolean goldTitle) { - final ItemStack mapItem = new ItemStackBuilder(Material.FILLED_MAP) - .title(text) - .hideAttributes() - .item(); - + ItemStack mapItem; + if(goldTitle) { + mapItem = new ItemStackBuilder(Material.FILLED_MAP) + .title( ChatColor.GOLD, text) + .hideAttributes() + .item(); + } + else{ + mapItem= new ItemStackBuilder(Material.FILLED_MAP) + .title(text) + .hideAttributes() + .item(); + } final MapMeta meta = (MapMeta) mapItem.getItemMeta(); meta.setMapId(mapID); meta.setColor(isMapPart ? Color.LIME : Color.GREEN); mapItem.setItemMeta(meta); - + PluginLogger.info("color "+meta.getColor()); return mapItem; } + static public ItemStack createMapItem(int mapID, String text, boolean isMapPart) + { + return createMapItem( mapID, text, isMapPart,false); + } /** * Returns the item to place to display the (col;row) part of the given poster. @@ -248,18 +265,20 @@ public class MapItemManager implements Listener if (frame.getItem().getType() != Material.AIR) return; if (!MapManager.managesMap(mapItem)) return; - if (SplatterMapManager.hasSplatterAttributes(mapItem)) { if (!SplatterMapManager.placeSplatterMap(frame, player,event)){ event.setCancelled(true); //In case of an error allow to cancel map placement - return;} + return; + } + frame.setRotation(Rotation.NONE.rotateCounterClockwise()); } else { + frame.setRotation(Rotation.NONE.rotateCounterClockwise()); // If the item has a display name, bot not one from an anvil by the player, we remove it // If it is not displayed on hover on the wall. - if (mapItem.hasItemMeta() && mapItem.getItemMeta().hasDisplayName() && mapItem.getItemMeta().getDisplayName().startsWith("§r")) + if (mapItem.hasItemMeta() && mapItem.getItemMeta().hasDisplayName() && mapItem.getItemMeta().getDisplayName().startsWith("§6")) { final ItemStack frameItem = mapItem.clone(); diff --git a/src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java b/src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java index e0858ab..762c8ca 100644 --- a/src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java +++ b/src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java @@ -298,10 +298,7 @@ abstract public class SplatterMapManager { frame.setItem(new ItemStackBuilder(Material.FILLED_MAP).nbt(ImmutableMap.of("map", id)).craftItem()); //Force reset of rotation - if(i==0){//First map need to be rotate one time Clockwise - frame.setRotation(Rotation.NONE.rotateCounterClockwise()); - } - else{frame.setRotation(Rotation.NONE);} + frame.setRotation(Rotation.NONE); MapInitEvent.initMap(id); ++i; } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index d34b848..07e54e2 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -2,7 +2,7 @@ # Plugin language. Empty: system language. -# Available: en-US (default, fallback), fr-FR, ru-RU, de-DE, zh-CN, ja_JP. +# Available: en-US (default, fallback), fr-FR, ru-RU, de-DE, zh-CN, ja-JP. lang: From a41ffaedee2a3459bc5c4cc4d70216c1837ae4ce Mon Sep 17 00:00:00 2001 From: Vlammar Date: Thu, 30 Jul 2020 13:37:06 +0200 Subject: [PATCH 23/44] fixed other bugs linked to #121 --- .../java/fr/moribus/imageonmap/gui/MapDetailGui.java | 2 +- src/main/java/fr/moribus/imageonmap/gui/MapListGui.java | 2 +- .../java/fr/moribus/imageonmap/ui/MapItemManager.java | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java b/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java index 465508e..9717771 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 if (map instanceof SingleMap) { - return MapItemManager.createMapItem((SingleMap)map); + return MapItemManager.createMapItem((SingleMap)map,true); } else if (map instanceof PosterMap) { diff --git a/src/main/java/fr/moribus/imageonmap/gui/MapListGui.java b/src/main/java/fr/moribus/imageonmap/gui/MapListGui.java index 8d8053d..40f38d9 100644 --- a/src/main/java/fr/moribus/imageonmap/gui/MapListGui.java +++ b/src/main/java/fr/moribus/imageonmap/gui/MapListGui.java @@ -131,7 +131,7 @@ public class MapListGui extends ExplorerGui if (map instanceof SingleMap) { - return MapItemManager.createMapItem(map.getMapsIDs()[0], map.getName(), false); + return MapItemManager.createMapItem(map.getMapsIDs()[0], map.getName(), false,true); } else if (map instanceof PosterMap) { diff --git a/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java b/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java index 7c60c76..3ce3bf5 100644 --- a/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java +++ b/src/main/java/fr/moribus/imageonmap/ui/MapItemManager.java @@ -43,10 +43,10 @@ import fr.moribus.imageonmap.map.PosterMap; import fr.moribus.imageonmap.map.SingleMap; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.core.ZLib; -import fr.zcraft.zlib.tools.PluginLogger; import fr.zcraft.zlib.tools.items.ItemStackBuilder; import fr.zcraft.zlib.tools.items.ItemUtils; import org.bukkit.*; +import org.bukkit.block.BlockFace; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -190,7 +190,6 @@ public class MapItemManager implements Listener meta.setMapId(mapID); meta.setColor(isMapPart ? Color.LIME : Color.GREEN); mapItem.setItemMeta(meta); - PluginLogger.info("color "+meta.getColor()); return mapItem; } static public ItemStack createMapItem(int mapID, String text, boolean isMapPart) @@ -271,11 +270,13 @@ public class MapItemManager implements Listener event.setCancelled(true); //In case of an error allow to cancel map placement return; } - frame.setRotation(Rotation.NONE.rotateCounterClockwise()); + if(frame.getFacing()!= BlockFace.UP&&frame.getFacing()!= BlockFace.DOWN) + frame.setRotation(Rotation.NONE.rotateCounterClockwise()); } else { - frame.setRotation(Rotation.NONE.rotateCounterClockwise()); + if(frame.getFacing()!= BlockFace.UP&&frame.getFacing()!= BlockFace.DOWN) + frame.setRotation(Rotation.NONE.rotateCounterClockwise()); // If the item has a display name, bot not one from an anvil by the player, we remove it // If it is not displayed on hover on the wall. if (mapItem.hasItemMeta() && mapItem.getItemMeta().hasDisplayName() && mapItem.getItemMeta().getDisplayName().startsWith("§6")) From 2be34cb34a0699d78ecd66c20fac187467ff7d61 Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Tue, 18 Aug 2020 00:04:43 +0200 Subject: [PATCH 24/44] Update src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java Co-authored-by: Amaury Carrade --- src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java b/src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java index 9bcfd20..69483ac 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/IoMCommand.java @@ -93,7 +93,6 @@ public abstract class IoMCommand extends Command map = MapManager.getMap(player.getUniqueId(), mapName); if(map == null) error(I.t("This map does not exist.")); - PluginLogger.info(""+map.getName()); return map; } protected ImageMap getMapFromArgs(Player player, int index, boolean expand) throws CommandException From 2b062f451e0b8e207aa1080743f2c72b9e3a297e Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Tue, 18 Aug 2020 00:05:12 +0200 Subject: [PATCH 25/44] Update src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java Co-authored-by: Amaury Carrade --- .../fr/moribus/imageonmap/commands/maptool/UpdateCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java index ba2af51..41cf125 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java @@ -81,7 +81,6 @@ public class UpdateCommand extends IoMCommand break; default: scaling = ImageUtils.ScalingType.CONTAINED; - break; } ImageMap map; PluginLogger.info("getting mapfromargs"); From 76e770a0e3233d01200372bad63c9975c495a557 Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Tue, 18 Aug 2020 00:05:27 +0200 Subject: [PATCH 26/44] Update src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java Co-authored-by: Amaury Carrade --- .../fr/moribus/imageonmap/commands/maptool/UpdateCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java index 41cf125..0986fc1 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java @@ -88,7 +88,6 @@ public class UpdateCommand extends IoMCommand map=getMapFromArgs(player,1); else map=getMapFromArgs(player,2); - PluginLogger.info("getted mapfromargs"); try { url = new URL(args[0]); From dda4d5e76ee516b95f6f08080d48e4ee1ef19f23 Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Tue, 18 Aug 2020 00:08:15 +0200 Subject: [PATCH 27/44] Update src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java Co-authored-by: Amaury Carrade --- .../fr/moribus/imageonmap/commands/maptool/UpdateCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java index 0986fc1..4958beb 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java @@ -103,7 +103,7 @@ public class UpdateCommand extends IoMCommand @Override public void finished(ImageMap result) { ActionBar.removeMessage(player); - MessageSender.sendActionBarMessage(player, ChatColor.DARK_GREEN + I.t("Updating finished!")); + MessageSender.sendActionBarMessage(player, ChatColor.DARK_GREEN + I.t("The map was updated using the new image!")); } @Override public void errored(Throwable exception) { From 66af34920fae2f64f14878d3e3d502441eaced4c Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Tue, 18 Aug 2020 00:08:35 +0200 Subject: [PATCH 28/44] Update src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java Co-authored-by: Amaury Carrade --- .../fr/moribus/imageonmap/commands/maptool/UpdateCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java index 4958beb..f127231 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java @@ -123,7 +123,6 @@ public class UpdateCommand extends IoMCommand catch(MalformedURLException ex) { throwInvalidArgument(I.t("Invalid URL.")); - return; } } From 19d79d2da0332597816dffeb2eb0e8ce0c62a70e Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Tue, 18 Aug 2020 00:12:45 +0200 Subject: [PATCH 29/44] Update src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java Co-authored-by: Amaury Carrade --- .../java/fr/moribus/imageonmap/image/ImageRendererExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java index a180448..1815729 100644 --- a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java +++ b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java @@ -111,7 +111,7 @@ public class ImageRendererExecutor extends Worker if (image == null) throw new IOException(I.t("The given URL is not a valid image")); // Limits are in place and the player does NOT have rights to avoid them. - checkSizeLimit(playerUUID, image ); + checkSizeLimit(playerUUID, image); if (scaling != ImageUtils.ScalingType.NONE && height <= 1 && width <= 1) { From 965ebe6605f9807f22ec7bf85d9b218a4f005190 Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Tue, 18 Aug 2020 00:14:38 +0200 Subject: [PATCH 30/44] Update src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java Co-authored-by: Amaury Carrade --- .../java/fr/moribus/imageonmap/image/ImageRendererExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java index 1815729..f4cb3ec 100644 --- a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java +++ b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java @@ -140,7 +140,7 @@ public class ImageRendererExecutor extends Worker if (image == null) throw new IOException(I.t("The given URL is not a valid image")); // Limits are in place and the player does NOT have rights to avoid them. - checkSizeLimit(playerUUID, image ); + checkSizeLimit(playerUUID, image); updateMap(scaling.resize(image, width*128, height*128),playerUUID,map.getMapsIDs()); return map; From 04dbca95b82a76e7d5dfcb9c95a8eae6abe2b76f Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Tue, 18 Aug 2020 00:15:45 +0200 Subject: [PATCH 31/44] Update src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java Co-authored-by: Amaury Carrade --- .../fr/moribus/imageonmap/commands/maptool/UpdateCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java index f127231..3127465 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java @@ -83,7 +83,6 @@ public class UpdateCommand extends IoMCommand scaling = ImageUtils.ScalingType.CONTAINED; } ImageMap map; - PluginLogger.info("getting mapfromargs"); if(scaling.equals(ImageUtils.ScalingType.CONTAINED)) map=getMapFromArgs(player,1); else From 93dd4bf38c44f7170d36ef2194a9cb141c2ad5df Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Tue, 18 Aug 2020 00:16:24 +0200 Subject: [PATCH 32/44] Update src/main/resources/plugin.yml Co-authored-by: Amaury Carrade --- src/main/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 05bcd5a..0d4d085 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -64,5 +64,5 @@ permissions: default: op imageonmap.update: - description: "Allows you to update a map." + description: "Allows you to update an existing map with a new image." default: op From b11a93634dfaa76514d953b3b7201d5f172671e1 Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Tue, 25 Aug 2020 22:39:10 +0200 Subject: [PATCH 33/44] Update ImageOnMap.java Change order to a more logical one for the command list --- src/main/java/fr/moribus/imageonmap/ImageOnMap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java index 3441c71..0591054 100644 --- a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java +++ b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java @@ -103,11 +103,11 @@ public final class ImageOnMap extends ZPlugin NewCommand.class, ListCommand.class, GetCommand.class, + RenameCommand.class, DeleteCommand.class, GetRemainingCommand.class, ExploreCommand.class, - MigrateCommand.class, - RenameCommand.class + MigrateCommand.class ); Commands.registerShortcut("maptool", NewCommand.class, "tomap"); From edc6f51e2e32665492a282b76649f0a93a024ccf Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Tue, 25 Aug 2020 22:50:24 +0200 Subject: [PATCH 34/44] Update DeleteOtherCommand.java Removed commented code and inverted permission check with arg length check. Changed success and error messages --- .../commands/maptool/DeleteOtherCommand.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java index 7f95328..91d7680 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java @@ -44,12 +44,12 @@ public class DeleteOtherCommand extends IoMCommand @Override protected void run() throws CommandException { - if(args.length < 2) warning(I.t("Not enough parameters! Usage: /maptool deleteother ")); if(!playerSender().hasPermission("imageonmap.delete.other")) { warning(I.t("You do not have permission for this command. (imageonmap.delete.other)")); return; } - + if(args.length < 2) warning(I.t("Not enough parameters! Usage: /maptool deleteother ")); + Player player = null; UUID uuid = null; OfflinePlayer op = null; @@ -67,17 +67,16 @@ public class DeleteOtherCommand extends IoMCommand ImageMap map = MapManager.getMap(uuid, mapName); if(player != null) MapManager.clear(player.getInventory(), map); - //if(player == null) MapManager.clear(op.getPlayer().getInventory(), map); try { MapManager.deleteMap(map); - info(I.t("Map successfully deleted.")); + getPlayer().sendMessage(I.t("{gray}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.")); + PluginLogger.warning(I.t("A non-existent map was requested to be deleted", ex)); + getPlayer().sendMessage(ChatColor.RED+(I.t("This map does not exist."))); } } From 2a2da88f72d2e13f79b80ff926cc2786cf87ce9c Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Tue, 25 Aug 2020 23:59:18 +0200 Subject: [PATCH 35/44] Update maptool.txt --- src/main/resources/help/maptool.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/help/maptool.txt b/src/main/resources/help/maptool.txt index b211c1c..846eb9b 100644 --- a/src/main/resources/help/maptool.txt +++ b/src/main/resources/help/maptool.txt @@ -2,10 +2,11 @@ This command manages and creates ImagesOnMaps. new: Creates a new ImageOnMap delete: Deletes a map. delete-noconfirm: Deletes a map. Deletion is permanent and made without confirmation +deleteother: Deletes another map. get: Gives you a map. getother: Gets another player's 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 +help : Use help for more information about a command. From f524c8ee957224514ae08667a8916d7f2f08d93e Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Wed, 26 Aug 2020 00:00:47 +0200 Subject: [PATCH 36/44] Update maptool.txt --- src/main/resources/help/maptool.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/help/maptool.txt b/src/main/resources/help/maptool.txt index 846eb9b..5110868 100644 --- a/src/main/resources/help/maptool.txt +++ b/src/main/resources/help/maptool.txt @@ -7,6 +7,7 @@ get: Gives you a map. getother: Gets another player's map. getremaining: Gives you the remaining maps that could not fit in your inventory list: Lists all the map you currently have. +listother: list all the map of another player. 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. From 7b3814cd7fbb9dbc73de989a36bd5baf9b162fb3 Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Wed, 26 Aug 2020 00:02:53 +0200 Subject: [PATCH 37/44] Update listother.txt --- src/main/resources/help/maptool/listother.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/resources/help/maptool/listother.txt b/src/main/resources/help/maptool/listother.txt index a24cb0a..7364938 100644 --- a/src/main/resources/help/maptool/listother.txt +++ b/src/main/resources/help/maptool/listother.txt @@ -1 +1,3 @@ -Lists another player's maps. \ No newline at end of file +Lists another player's maps. + +§6: §rThe name of the player you want to list map from. From 16248a9e3b905ba7317d961454d8c1dc9baa56dc Mon Sep 17 00:00:00 2001 From: Vlammar <36545324+Vlammar@users.noreply.github.com> Date: Wed, 26 Aug 2020 00:08:05 +0200 Subject: [PATCH 38/44] Update ListOtherCommand.java --- .../commands/maptool/ListOtherCommand.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java index 292c1ea..89540e4 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java @@ -107,13 +107,11 @@ public class ListOtherCommand extends IoMCommand .then(map.getId()) .color(ChatColor.WHITE) .command(GetCommand.class, map.getId()) - .hover(new ItemStackBuilder(Material.MAP) - .title(ChatColor.GREEN + "" + ChatColor.BOLD + map.getName()) - .lore(ChatColor.GRAY + map.getId() + ", " + size) - .lore("") - .lore(I.t("{white}Click{gray} to get this map")) - .hideAttributes() - .item() + .hover(new RawText() + .then(map.getName()).style(ChatColor.BOLD, ChatColor.GREEN).then("\n") + .then(map.getId() + ", " + size).color(ChatColor.GRAY).then("\n\n") + .then(I.t("{white}Click{gray} to get this map")) + ); } @Override From fcc48cb4024625c11c507982bb20cbbbd2fe53d9 Mon Sep 17 00:00:00 2001 From: Vlammar Date: Thu, 27 Aug 2020 01:32:04 +0200 Subject: [PATCH 39/44] fixed various issues with the admin command, refactored some of the code and added an exploredother command --- .../fr/moribus/imageonmap/ImageOnMap.java | 5 +- .../commands/maptool/DeleteCommand.java | 28 ++++--- .../commands/maptool/DeleteOtherCommand.java | 72 ++++++++++------ .../commands/maptool/ExploreCommand.java | 2 +- .../commands/maptool/ExploreOtherCommand.java | 83 +++++++++++++++++++ .../commands/maptool/GetOtherCommand.java | 74 +++++++++++------ .../commands/maptool/ListOtherCommand.java | 74 ++++++++++------- .../imageonmap/gui/ConfirmDeleteMapGui.java | 3 +- .../moribus/imageonmap/gui/MapDetailGui.java | 21 +++-- .../fr/moribus/imageonmap/gui/MapListGui.java | 46 +++++++--- src/main/resources/help/maptool.txt | 1 + src/main/resources/plugin.yml | 32 +++++-- 12 files changed, 322 insertions(+), 119 deletions(-) create mode 100644 src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java diff --git a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java index 38cf7c7..608e980 100644 --- a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java +++ b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java @@ -118,13 +118,14 @@ public final class ImageOnMap extends ZPlugin "maptool", NewCommand.class, ListCommand.class, + ListOtherCommand.class, GetCommand.class, GetOtherCommand.class, - ListOtherCommand.class, - DeleteOtherCommand.class, DeleteCommand.class, + DeleteOtherCommand.class, GetRemainingCommand.class, ExploreCommand.class, + ExploreOtherCommand.class, MigrateCommand.class ); diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteCommand.java index a2516f1..2041d60 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteCommand.java @@ -57,6 +57,20 @@ import java.util.List; @WithFlags ({"confirm"}) public class DeleteCommand extends IoMCommand { + + private static RawText deleteMsg(Class klass,ImageMap map){ + return 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(klass, map.getId(), "--confirm") + .build(); + } + @Override protected void run() throws CommandException { @@ -64,17 +78,7 @@ public class DeleteCommand extends IoMCommand if (!hasFlag("confirm")) { - 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(); - + RawText msg = deleteMsg(getClass(),map); send(msg); } else @@ -89,7 +93,7 @@ public class DeleteCommand extends IoMCommand } catch (MapManagerException ex) { - PluginLogger.warning("A non-existent map was requested to be deleted", ex); + PluginLogger.warning(I.t("A non-existent map was requested to be deleted", ex)); warning(I.t("This map does not exist.")); } } diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java index 91d7680..dfcf537 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java @@ -1,19 +1,37 @@ /* - * Copyright (C) 2013 Moribus - * Copyright (C) 2015 ProkopyL + * Copyright or © or Copr. Moribus (2013) + * Copyright or © or Copr. ProkopyL (2015) + * Copyright or © or Copr. Amaury Carrade (2016 – 2020) + * Copyright or © or Copr. Vlammar (2019 – 2020) * - * 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 software is a computer program whose purpose is to allow insertion of + * custom images in a Minecraft world. * - * 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. + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. */ package fr.moribus.imageonmap.commands.maptool; @@ -28,8 +46,8 @@ 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.tools.PluginLogger; - import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -44,12 +62,16 @@ public class DeleteOtherCommand extends IoMCommand @Override protected void run() throws CommandException { - if(!playerSender().hasPermission("imageonmap.delete.other")) { + /*if(!playerSender().hasPermission("imageonmap.delete.other")) { warning(I.t("You do not have permission for this command. (imageonmap.delete.other)")); return; - } - if(args.length < 2) warning(I.t("Not enough parameters! Usage: /maptool deleteother ")); - + }*/ + if(args.length < 2) { + warning(I.t("Not enough parameters! Usage: /maptool deleteother ")); + return; + } + + Player player = null; UUID uuid = null; OfflinePlayer op = null; @@ -60,23 +82,24 @@ public class DeleteOtherCommand extends IoMCommand else warning(I.t("We've never seen that player before!")); } else uuid = player.getUniqueId(); - String mapName = ""; - mapName = args[1]; - if(args.length > 2) for(int i = 2; i < args.length; i++) mapName += (" " + args[i - 1]); - - ImageMap map = MapManager.getMap(uuid, mapName); + if(player==null){ + warning(I.t("Player not found")); + return; + } + ImageMap map = getMapFromArgs(player, 1, true); + //ImageMap map = MapManager.getMap(uuid, mapName); if(player != null) MapManager.clear(player.getInventory(), map); try { MapManager.deleteMap(map); - getPlayer().sendMessage(I.t("{gray}Map successfully deleted.")); + info(I.t("{gray}Map successfully deleted.")); } catch (MapManagerException ex) { PluginLogger.warning(I.t("A non-existent map was requested to be deleted", ex)); - getPlayer().sendMessage(ChatColor.RED+(I.t("This map does not exist."))); + warning(ChatColor.RED+(I.t("This map does not exist."))); } } @@ -89,6 +112,7 @@ public class DeleteOtherCommand extends IoMCommand return null; } + @Override public boolean canExecute(CommandSender sender) { diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreCommand.java index d4bac06..cd3f96f 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreCommand.java @@ -52,7 +52,7 @@ public class ExploreCommand extends IoMCommand @Override protected void run() throws CommandException { - Gui.open(playerSender(), new MapListGui()); + Gui.open(playerSender(), new MapListGui(playerSender())); } @Override diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java new file mode 100644 index 0000000..8e8af95 --- /dev/null +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java @@ -0,0 +1,83 @@ +/* + * Copyright or © or Copr. Moribus (2013) + * Copyright or © or Copr. ProkopyL (2015) + * Copyright or © or Copr. Amaury Carrade (2016 – 2020) + * Copyright or © or Copr. Vlammar (2019 – 2020) + * + * This software is a computer program whose purpose is to allow insertion of + * custom images in a Minecraft world. + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ + +package fr.moribus.imageonmap.commands.maptool; + + +import fr.moribus.imageonmap.Permissions; +import fr.moribus.imageonmap.commands.IoMCommand; +import fr.moribus.imageonmap.gui.MapListGui; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.gui.Gui; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; + +import java.io.IOException; + + +@CommandInfo (name = "exploreother") +public class ExploreOtherCommand extends IoMCommand +{ + @Override + protected void run() throws CommandException + { + if(args.length < 1) { + warning(I.t("Not enough parameters! Usage: /maptool exploreother ")); + return; + } + + try{ + OfflinePlayer player=getOfflinePlayerParameter(0); + String name=args[0]; + if(player!=null) + Gui.open(playerSender(), new MapListGui(player,name)); + } + catch (InterruptedException | IOException e){ + warning(I.t("Can't find player")); + return; + } + + + } + + @Override + public boolean canExecute(CommandSender sender) + { + return Permissions.LISTOTHER.grantedTo(sender); + } +} diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java index d8529d5..ba18870 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java @@ -1,31 +1,42 @@ /* - * Copyright (C) 2013 Moribus - * Copyright (C) 2015 ProkopyL + * Copyright or © or Copr. Moribus (2013) + * Copyright or © or Copr. ProkopyL (2015) + * Copyright or © or Copr. Amaury Carrade (2016 – 2020) + * Copyright or © or Copr. Vlammar (2019 – 2020) * - * 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 software is a computer program whose purpose is to allow insertion of + * custom images in a Minecraft world. * - * 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. + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. */ package fr.moribus.imageonmap.commands.maptool; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - import fr.moribus.imageonmap.Permissions; import fr.moribus.imageonmap.commands.IoMCommand; import fr.moribus.imageonmap.map.ImageMap; @@ -33,29 +44,36 @@ import fr.moribus.imageonmap.map.MapManager; import fr.zcraft.zlib.components.commands.CommandException; import fr.zcraft.zlib.components.commands.CommandInfo; import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.UUID; @CommandInfo (name = "getother", usageParameters = " ") public class GetOtherCommand extends IoMCommand { - @SuppressWarnings("deprecation") + @Override protected void run() throws CommandException { - if(args.length < 2) warning(I.t("Not enough parameters! Usage: /maptool getother ")); - //Deny those who do not have permission. - if(!playerSender().hasPermission("imageonmap.get.other")) { - warning(I.t("You do not have permission for this command. (imageonmap.get.other)")); + + if(args.length < 2) { + warning(I.t("Not enough parameters! Usage: /maptool getother ")); return; } - + Player player = null; UUID uuid = null; player = Bukkit.getPlayer(args[0]); + if(player == null){ OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]); if(op.hasPlayedBefore()) uuid = op.getUniqueId(); else warning(I.t("We've never seen that player before!")); + return; } else { uuid = player.getUniqueId(); @@ -69,7 +87,11 @@ public class GetOtherCommand extends IoMCommand } } map = MapManager.getMap(uuid, mapName); - map.give(playerSender()); + if(map!=null) + map.give(playerSender()); + else{ + warning(I.t("Unknown map {0}",mapName)); + } return; } @Override diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java index 89540e4..52f0091 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java @@ -1,34 +1,42 @@ /* - * Copyright (C) 2013 Moribus - * Copyright (C) 2015 ProkopyL + * Copyright or © or Copr. Moribus (2013) + * Copyright or © or Copr. ProkopyL (2015) + * Copyright or © or Copr. Amaury Carrade (2016 – 2020) + * Copyright or © or Copr. Vlammar (2019 – 2020) * - * 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 software is a computer program whose purpose is to allow insertion of + * custom images in a Minecraft world. * - * 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. + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. */ package fr.moribus.imageonmap.commands.maptool; -import java.util.List; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - import fr.moribus.imageonmap.Permissions; import fr.moribus.imageonmap.commands.IoMCommand; import fr.moribus.imageonmap.map.ImageMap; @@ -39,8 +47,15 @@ import fr.zcraft.zlib.components.commands.CommandInfo; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.rawtext.RawText; import fr.zcraft.zlib.components.rawtext.RawTextPart; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; import fr.zcraft.zlib.tools.text.RawMessage; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.UUID; @CommandInfo (name = "listother", usageParameters = "") @@ -49,11 +64,12 @@ public class ListOtherCommand extends IoMCommand @Override protected void run() throws CommandException { - if(args.length < 1) warning(I.t("Not enough parameters! Usage: /maptool listother ")); - if(!playerSender().hasPermission("imageonmap.list.other")) { - warning(I.t("You do not have permission for this command. (imageonmap.list.other)")); - return; + + if(args.length < 1){ + warning(I.t("Not enough parameters! Usage: /maptool listother ")); + return; } + Player player = null; UUID uuid = null; @@ -65,7 +81,6 @@ public class ListOtherCommand extends IoMCommand } else { warning(I.t("We've never seen that player before!")); - } } else{ @@ -77,8 +92,9 @@ public class ListOtherCommand extends IoMCommand mapList = MapManager.getMapList(uuid); } catch(Exception e){ - + return; } + if(mapList.isEmpty()) { info(I.t("No map found.")); diff --git a/src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java b/src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java index b60768d..1f81604 100644 --- a/src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java +++ b/src/main/java/fr/moribus/imageonmap/gui/ConfirmDeleteMapGui.java @@ -168,12 +168,13 @@ public class ConfirmDeleteMapGui extends ActionGui @GuiAction ("cancel") protected void cancel() { - close(); + close(); } @GuiAction ("delete") protected void delete() { + // Does the player still have the permission to delete a map? if (!Permissions.DELETE.grantedTo(getPlayer())) { diff --git a/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java b/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java index 9717771..f08395a 100644 --- a/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java +++ b/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java @@ -47,21 +47,25 @@ import fr.zcraft.zlib.components.gui.GuiAction; import fr.zcraft.zlib.components.gui.PromptGui; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.Callback; +import fr.zcraft.zlib.tools.PluginLogger; import fr.zcraft.zlib.tools.items.ItemStackBuilder; import org.apache.commons.lang.ArrayUtils; import org.bukkit.Material; +import org.bukkit.OfflinePlayer; import org.bukkit.inventory.ItemStack; public class MapDetailGui extends ExplorerGui { private final ImageMap map; + private OfflinePlayer p; + private String name; - public MapDetailGui(ImageMap map) - { - this.map = map; + public MapDetailGui(ImageMap map, OfflinePlayer p, String name){ + this.map=map; + this.p=p; + this.name=name; } - @Override protected ItemStack getViewItem(int x, int y) { @@ -136,7 +140,12 @@ public class MapDetailGui extends ExplorerGui protected void onUpdate() { /// Title of the map details GUI - setTitle(I.t(getPlayerLocale(), "Your maps » {black}{0}", map.getName())); + if(p.getUniqueId().equals(getPlayer().getUniqueId())) { + setTitle(I.t(getPlayerLocale(), "Your maps » {black}{0}", map.getName())); + } + else{ + setTitle(I.t(getPlayerLocale(), "{1}'s maps » {black}{0}", map.getName(),name)); + } setKeepHorizontalScrollingSpace(true); if (map instanceof PosterMap) @@ -236,13 +245,13 @@ public class MapDetailGui extends ExplorerGui @GuiAction ("delete") public void delete() { + PluginLogger.info("delete"); if (!Permissions.DELETE.grantedTo(getPlayer())) { I.sendT(getPlayer(), "{ce}You are no longer allowed to do that."); update(); return; } - Gui.open(getPlayer(), new ConfirmDeleteMapGui(map), this); } diff --git a/src/main/java/fr/moribus/imageonmap/gui/MapListGui.java b/src/main/java/fr/moribus/imageonmap/gui/MapListGui.java index 40f38d9..4bf7644 100644 --- a/src/main/java/fr/moribus/imageonmap/gui/MapListGui.java +++ b/src/main/java/fr/moribus/imageonmap/gui/MapListGui.java @@ -49,12 +49,25 @@ import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.items.ItemStackBuilder; import org.bukkit.Color; import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.MapMeta; public class MapListGui extends ExplorerGui { + private OfflinePlayer p; + private String name; + public MapListGui(Player sender){ + this.p=sender; + this.name=sender.getName(); + } + public MapListGui( OfflinePlayer p,String name){ + this.p=p; + this.name=name; + } + @Override protected ItemStack getViewItem(ImageMap map) { @@ -106,23 +119,29 @@ public class MapListGui extends ExplorerGui @Override protected ItemStack getEmptyViewItem() { - ItemStackBuilder builder = new ItemStackBuilder(Material.BARRIER) - .title(I.tl(getPlayerLocale(), "{red}You don't have any map.")); + ItemStackBuilder builder = new ItemStackBuilder(Material.BARRIER); + if(p.getUniqueId().equals(getPlayer().getUniqueId())) { - if (Permissions.NEW.grantedTo(getPlayer())) - builder.longLore(I.tl(getPlayerLocale(), "{gray}Get started by creating a new one using {white}/tomap [resize]{gray}!")); - else - builder.longLore(I.tl(getPlayerLocale(), "{gray}Unfortunately, you are not allowed to create one.")); + builder.title(I.tl(getPlayerLocale(), "{red}You don't have any map.")); + if (Permissions.NEW.grantedTo(getPlayer())) + builder.longLore(I.tl(getPlayerLocale(), "{gray}Get started by creating a new one using {white}/tomap [resize]{gray}!")); + else + builder.longLore(I.tl(getPlayerLocale(), "{gray}Unfortunately, you are not allowed to create one.")); + } + else{ + builder.title(I.tl(getPlayerLocale(), "{red}{0} doesn't have any map.",name)); + } return builder.item(); } @Override protected void onRightClick(ImageMap data) { - Gui.open(getPlayer(), new MapDetailGui(data), this); + Gui.open(getPlayer(), new MapDetailGui(data,getPlayer(),name), this); } + @Override protected ItemStack getPickedUpItem(ImageMap map) { @@ -151,19 +170,22 @@ public class MapListGui extends ExplorerGui @Override protected void onUpdate() { - ImageMap[] maps = MapManager.getMaps(getPlayer().getUniqueId()); + ImageMap[] maps = MapManager.getMaps(p.getUniqueId()); setData(maps); /// The maps list GUI title - setTitle(I.tl(getPlayerLocale(), "{black}Your maps {reset}({0})", maps.length)); + //Equal if the person who send the command is the owner of the mapList + if(p.getUniqueId().equals(getPlayer().getUniqueId())) + setTitle(I.tl(getPlayerLocale(), "{black}Your maps {reset}({0})", maps.length)); + else + setTitle(I.tl(getPlayerLocale(), "{black}{1}'s maps {reset}({0})", maps.length, name )); setKeepHorizontalScrollingSpace(true); /* ** Statistics ** */ - - int imagesCount = MapManager.getMapList(getPlayer().getUniqueId()).size(); - int mapPartCount = MapManager.getMapPartCount(getPlayer().getUniqueId()); + int imagesCount = MapManager.getMapList(p.getUniqueId()).size(); + int mapPartCount = MapManager.getMapPartCount(p.getUniqueId()); int mapGlobalLimit = PluginConfiguration.MAP_GLOBAL_LIMIT.get(); int mapPersonalLimit = PluginConfiguration.MAP_PLAYER_LIMIT.get(); diff --git a/src/main/resources/help/maptool.txt b/src/main/resources/help/maptool.txt index 5110868..9b83e58 100644 --- a/src/main/resources/help/maptool.txt +++ b/src/main/resources/help/maptool.txt @@ -9,5 +9,6 @@ getremaining: Gives you the remaining maps that could not fit in your inventory list: Lists all the map you currently have. listother: list all the map of another player. explore: Opens a GUI to see and manage your maps. +exploreother: Opens a GUI to see and manage another player maps. migrate: Lauches the migration process from V2.7 to V3.x. help : Use help for more information about a command. diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index f92a42c..490e06d 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -20,11 +20,15 @@ permissions: imageonmap.userender: true imageonmap.new: true imageonmap.list: true + imageonmap.listother: true imageonmap.get: true + imageonmap.getother: true imageonmap.explore: true + imageonmap.exploreother: true imageonmap.rename: true imageonmap.removesplattermap: true imageonmap.delete: true + imageonmap.deleteother: false imageonmap.bypasssize: false imageonmap.userender: @@ -36,16 +40,28 @@ permissions: default: true imageonmap.list: - description: "Allows you to list the images you rendered." - default: true + description: "Allows you to list the images you rendered." + default: true + + imageonmap.listother: + description: "Allows you to list the images a player have rendered." + default: false imageonmap.get: - description: "Allows you to get a new map among the ones you already rendered, and related commands (/maptool getremaining)." - default: true + description: "Allows you to get a new map among the ones you already rendered, and related commands (/maptool getremaining)." + default: true + + imageonmap.getother: + description: "Allows you to get a new map among the ones a player have already rendered." + default: false imageonmap.explore: - description: "Allows you to open a GUI with all your maps." - default: true + description: "Allows you to open a GUI with all your maps." + default: true + + imageonmap.exploreother: + description: "Allows you to open a GUI with all of the player maps." + default: false imageonmap.rename: description: "Allows you to rename a map you rendered in the past." @@ -55,6 +71,10 @@ permissions: description: "Allows you to delete a map you rendered in the past." default: true + imageonmap.deleteother: + description: "Allows you to delete a map a player rendered in the past." + default: false + imageonmap.removesplattermap: description: "Allows you to remove a splatter map from a wall by sneaking and breaking a map." default: true From 166da8dca893362252d607582824c16361b050c1 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 19 Sep 2020 10:53:21 +0200 Subject: [PATCH 40/44] typo --- src/main/java/fr/moribus/imageonmap/ImageOnMap.java | 1 - .../imageonmap/commands/maptool/DeleteOtherCommand.java | 8 +------- .../imageonmap/commands/maptool/ExploreOtherCommand.java | 4 ---- .../imageonmap/commands/maptool/GetOtherCommand.java | 1 - .../imageonmap/commands/maptool/ListOtherCommand.java | 2 -- src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java | 1 - src/main/java/fr/moribus/imageonmap/gui/MapListGui.java | 2 +- 7 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java index 608e980..7ad7669 100644 --- a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java +++ b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java @@ -56,7 +56,6 @@ import org.bstats.bukkit.Metrics; import java.io.File; import java.io.IOException; - public final class ImageOnMap extends ZPlugin { static private final String IMAGES_DIRECTORY_NAME = "images"; diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java index dfcf537..697584d 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java @@ -62,16 +62,11 @@ public class DeleteOtherCommand extends IoMCommand @Override protected void run() throws CommandException { - /*if(!playerSender().hasPermission("imageonmap.delete.other")) { - warning(I.t("You do not have permission for this command. (imageonmap.delete.other)")); - return; - }*/ if(args.length < 2) { warning(I.t("Not enough parameters! Usage: /maptool deleteother ")); return; } - Player player = null; UUID uuid = null; OfflinePlayer op = null; @@ -102,8 +97,7 @@ public class DeleteOtherCommand extends IoMCommand warning(ChatColor.RED+(I.t("This map does not exist."))); } } - - + @Override protected List complete() throws CommandException { diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java index 8e8af95..8df83dc 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java @@ -36,7 +36,6 @@ package fr.moribus.imageonmap.commands.maptool; - import fr.moribus.imageonmap.Permissions; import fr.moribus.imageonmap.commands.IoMCommand; import fr.moribus.imageonmap.gui.MapListGui; @@ -60,7 +59,6 @@ public class ExploreOtherCommand extends IoMCommand warning(I.t("Not enough parameters! Usage: /maptool exploreother ")); return; } - try{ OfflinePlayer player=getOfflinePlayerParameter(0); String name=args[0]; @@ -71,8 +69,6 @@ public class ExploreOtherCommand extends IoMCommand warning(I.t("Can't find player")); return; } - - } @Override diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java index ba18870..a0fd1e0 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java @@ -59,7 +59,6 @@ public class GetOtherCommand extends IoMCommand @Override protected void run() throws CommandException { - if(args.length < 2) { warning(I.t("Not enough parameters! Usage: /maptool getother ")); return; diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java index 52f0091..6e6b5a4 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java @@ -64,7 +64,6 @@ public class ListOtherCommand extends IoMCommand @Override protected void run() throws CommandException { - if(args.length < 1){ warning(I.t("Not enough parameters! Usage: /maptool listother ")); return; @@ -127,7 +126,6 @@ public class ListOtherCommand extends IoMCommand .then(map.getName()).style(ChatColor.BOLD, ChatColor.GREEN).then("\n") .then(map.getId() + ", " + size).color(ChatColor.GRAY).then("\n\n") .then(I.t("{white}Click{gray} to get this map")) - ); } @Override diff --git a/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java b/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java index f08395a..71adf75 100644 --- a/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java +++ b/src/main/java/fr/moribus/imageonmap/gui/MapDetailGui.java @@ -245,7 +245,6 @@ public class MapDetailGui extends ExplorerGui @GuiAction ("delete") public void delete() { - PluginLogger.info("delete"); if (!Permissions.DELETE.grantedTo(getPlayer())) { I.sendT(getPlayer(), "{ce}You are no longer allowed to do that."); diff --git a/src/main/java/fr/moribus/imageonmap/gui/MapListGui.java b/src/main/java/fr/moribus/imageonmap/gui/MapListGui.java index 4bf7644..25a914a 100644 --- a/src/main/java/fr/moribus/imageonmap/gui/MapListGui.java +++ b/src/main/java/fr/moribus/imageonmap/gui/MapListGui.java @@ -63,7 +63,7 @@ public class MapListGui extends ExplorerGui this.p=sender; this.name=sender.getName(); } - public MapListGui( OfflinePlayer p,String name){ + public MapListGui(OfflinePlayer p,String name){ this.p=p; this.name=name; } From 18ac445562cc286a8a266f7701fe2fb6fa384f20 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 21 Sep 2020 15:21:50 +0200 Subject: [PATCH 41/44] updated po for english and french --- src/main/resources/i18n/en_US.po | 9 +++++++++ src/main/resources/i18n/fr_FR.po | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/resources/i18n/en_US.po b/src/main/resources/i18n/en_US.po index 9fee665..e6541be 100644 --- a/src/main/resources/i18n/en_US.po +++ b/src/main/resources/i18n/en_US.po @@ -593,3 +593,12 @@ msgstr "" #: src/main/java/fr/moribus/imageonmap/ui/SplatterMapManager.java:101 msgid "{ce}There is not enough space to place this map ({0} × {1})." msgstr "{ce}There is not enough space to place this map ({0} × {1})." + +#New part, added for update (TODO add to other .po file +#: src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java:71 +msgid "{ce}You must give an URL and a map name to update." +msgstr "{ce}You must give an URL and a map name to update." + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java:72 +msgid "{ce}You must give a map name to update.." +msgstr "{ce}You must give a map name to update.." diff --git a/src/main/resources/i18n/fr_FR.po b/src/main/resources/i18n/fr_FR.po index c1d12c7..a529f25 100644 --- a/src/main/resources/i18n/fr_FR.po +++ b/src/main/resources/i18n/fr_FR.po @@ -568,3 +568,12 @@ msgstr "Carte" #~ msgid_plural "{white}{0}{gray} maps left" #~ msgstr[0] "{white}{0}{gray} carte restante" #~ msgstr[1] "{white}{0}{gray} cartes restantes" + + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java:71 +msgid "{ce}You must give an URL and a map name to update." +msgstr "{ce}Veuillez donner une URL et un nom de carte a update." + +#: src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateCommand.java:72 +msgid "{ce}You must give a map name to update." +msgstr "{ce}Veuillez un nom de carte a update" \ No newline at end of file From 2ff372d20f8f783511e3c4d45ea7727440c65317 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 21 Sep 2020 15:25:20 +0200 Subject: [PATCH 42/44] started to add possibility to update other maps --- .../fr/moribus/imageonmap/Permissions.java | 1 + .../commands/maptool/UpdateOtherCommand.java | 134 ++++++++++++++++++ src/main/resources/plugin.yml | 7 +- testforwebhook.test | 1 - 4 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateOtherCommand.java delete mode 100644 testforwebhook.test diff --git a/src/main/java/fr/moribus/imageonmap/Permissions.java b/src/main/java/fr/moribus/imageonmap/Permissions.java index 4ca6a8d..f0840c2 100644 --- a/src/main/java/fr/moribus/imageonmap/Permissions.java +++ b/src/main/java/fr/moribus/imageonmap/Permissions.java @@ -46,6 +46,7 @@ public enum Permissions RENAME("imageonmap.rename"), DELETE("imageonmap.delete"), UPDATE("imageonmap.update"), + UPDATEOTHER("imageonmap.updateother"), ADMINISTRATIVE("imageonmap.administrative"), BYPASS_SIZE("imageonmap.bypasssize") diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateOtherCommand.java new file mode 100644 index 0000000..8eda873 --- /dev/null +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/UpdateOtherCommand.java @@ -0,0 +1,134 @@ +/* + * Copyright or © or Copr. Moribus (2013) + * Copyright or © or Copr. ProkopyL (2015) + * Copyright or © or Copr. Amaury Carrade (2016 – 2020) + * Copyright or © or Copr. Vlammar (2019 – 2020) + * + * This software is a computer program whose purpose is to allow insertion of + * custom images in a Minecraft world. + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ + +package fr.moribus.imageonmap.commands.maptool; + +import fr.moribus.imageonmap.Permissions; +import fr.moribus.imageonmap.commands.IoMCommand; +import fr.moribus.imageonmap.image.ImageRendererExecutor; +import fr.moribus.imageonmap.image.ImageUtils; +import fr.moribus.imageonmap.map.ImageMap; +import fr.moribus.imageonmap.map.MapManager; +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.worker.WorkerCallback; +import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.zlib.tools.text.ActionBar; +import fr.zcraft.zlib.tools.text.MessageSender; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; + +@CommandInfo (name = "update", usageParameters = " [stretched|covered] \"\"") +public class UpdateOtherCommand extends IoMCommand +{ + @Override + protected void run() throws CommandException + { + //TODO separer les deux update(update et update other) + final Player player = playerSender(); + ImageUtils.ScalingType scaling; + + URL url; + + if(args.length < 1) throwInvalidArgument(I.t("You must give an URL and a map name to update.")); + if(args.length < 2) throwInvalidArgument(I.t("You must give a map name to update.")); + + switch(args[1]) { + + case "stretched": + scaling = ImageUtils.ScalingType.STRETCHED; + break; + case "covered": + scaling = ImageUtils.ScalingType.COVERED; + break; + default: + scaling = ImageUtils.ScalingType.CONTAINED; + } + ImageMap map; + if(scaling.equals(ImageUtils.ScalingType.CONTAINED)) + map=getMapFromArgs(player,1); + else + map=getMapFromArgs(player,2); + try + { + url = new URL(args[0]); + MapManager.load(); + + Integer[] size={1,1}; + if(map.getType()== ImageMap.Type.POSTER) + size=map.getSize( new HashMap(),map.getUserUUID(),map.getId()); + int width=size[0],height=size[1]; + try { + ActionBar.sendPermanentMessage(player, ChatColor.DARK_GREEN + I.t("Updating...")); + ImageRendererExecutor.update(url, scaling, player.getUniqueId(), map, width, height, new WorkerCallback() { + @Override + public void finished(ImageMap result) { + ActionBar.removeMessage(player); + MessageSender.sendActionBarMessage(player, ChatColor.DARK_GREEN + I.t("The map was updated using the new image!")); + } + @Override + public void errored(Throwable exception) { + player.sendMessage(I.t("{ce}Map rendering failed: {0}", exception.getMessage())); + + PluginLogger.warning("Rendering from {0} failed: {1}: {2}", + player.getName(), + exception.getClass().getCanonicalName(), + exception.getMessage()); + } + }); + } + finally { + ActionBar.removeMessage(player); + } + } + catch(MalformedURLException ex) + { + throwInvalidArgument(I.t("Invalid URL.")); + } + } + + @Override + public boolean canExecute(CommandSender sender) + { + return Permissions.UPDATEOTHER.grantedTo(sender); + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 0d4d085..ef23519 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -25,7 +25,8 @@ permissions: imageonmap.rename: true imageonmap.delete: true imageonmap.bypasssize: false - imageonmap.update: false + imageonmap.update: true + imageonmap.updateother: false imageonmap.userender: description: "Allows you to use /tomap and related commands (/maptool getremaing). Alias of imageonmap.new." @@ -65,4 +66,8 @@ permissions: imageonmap.update: description: "Allows you to update an existing map with a new image." + default: true + + imageonmap.updateother: + description: "Allows you to update an existing map of an other player with a new image." default: op diff --git a/testforwebhook.test b/testforwebhook.test deleted file mode 100644 index 9daeafb..0000000 --- a/testforwebhook.test +++ /dev/null @@ -1 +0,0 @@ -test From 6b332d60b6f30d2659bfa12af98a900203cc1c2d Mon Sep 17 00:00:00 2001 From: Vlammar Date: Wed, 4 Nov 2020 17:28:20 +0100 Subject: [PATCH 43/44] code cleanup and fixing issues --- src/main/java/fr/moribus/imageonmap/ImageOnMap.java | 4 +++- .../imageonmap/commands/maptool/DeleteOtherCommand.java | 6 +----- .../imageonmap/commands/maptool/ExploreOtherCommand.java | 7 +++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java index 608e980..0836ad6 100644 --- a/src/main/java/fr/moribus/imageonmap/ImageOnMap.java +++ b/src/main/java/fr/moribus/imageonmap/ImageOnMap.java @@ -45,6 +45,7 @@ import fr.moribus.imageonmap.map.MapManager; import fr.moribus.imageonmap.migration.MigratorExecutor; import fr.moribus.imageonmap.migration.V3Migrator; import fr.moribus.imageonmap.ui.MapItemManager; +import fr.zcraft.zlib.components.commands.CommandWorkers; import fr.zcraft.zlib.components.commands.Commands; import fr.zcraft.zlib.components.gui.Gui; import fr.zcraft.zlib.components.i18n.I18n; @@ -105,7 +106,7 @@ public final class ImageOnMap extends ZPlugin saveDefaultConfig(); - loadComponents(I18n.class, Gui.class, Commands.class, PluginConfiguration.class, ImageIOExecutor.class, ImageRendererExecutor.class); + loadComponents(I18n.class, Gui.class, Commands.class, PluginConfiguration.class, ImageIOExecutor.class, ImageRendererExecutor.class, CommandWorkers.class); //Init all the things ! I18n.setPrimaryLocale(PluginConfiguration.LANG.get()); @@ -114,6 +115,7 @@ public final class ImageOnMap extends ZPlugin MapInitEvent.init(); MapItemManager.init(); + Commands.register( "maptool", NewCommand.class, diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java index dfcf537..87f1712 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java @@ -62,10 +62,7 @@ public class DeleteOtherCommand extends IoMCommand @Override protected void run() throws CommandException { - /*if(!playerSender().hasPermission("imageonmap.delete.other")) { - warning(I.t("You do not have permission for this command. (imageonmap.delete.other)")); - return; - }*/ + if(args.length < 2) { warning(I.t("Not enough parameters! Usage: /maptool deleteother ")); return; @@ -87,7 +84,6 @@ public class DeleteOtherCommand extends IoMCommand return; } ImageMap map = getMapFromArgs(player, 1, true); - //ImageMap map = MapManager.getMap(uuid, mapName); if(player != null) MapManager.clear(player.getInventory(), map); diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java index 8e8af95..5e4896d 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java @@ -47,7 +47,7 @@ import fr.zcraft.zlib.components.i18n.I; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; -import java.io.IOException; +import java.util.concurrent.ExecutionException; @CommandInfo (name = "exploreother") @@ -67,17 +67,16 @@ public class ExploreOtherCommand extends IoMCommand if(player!=null) Gui.open(playerSender(), new MapListGui(player,name)); } - catch (InterruptedException | IOException e){ + catch (InterruptedException | ExecutionException e){ warning(I.t("Can't find player")); return; } - } @Override public boolean canExecute(CommandSender sender) { - return Permissions.LISTOTHER.grantedTo(sender); + return Permissions.LISTOTHER.grantedTo(sender); } } From c769f508357dd20525ed87f0d5ab4452fb888bb1 Mon Sep 17 00:00:00 2001 From: Vlammar Date: Sat, 7 Nov 2020 01:04:24 +0100 Subject: [PATCH 44/44] bug fix and typo --- .../commands/maptool/DeleteOtherCommand.java | 44 +++++++++---------- .../commands/maptool/ExploreOtherCommand.java | 37 ++++++++++------ .../commands/maptool/GetOtherCommand.java | 32 +++++++------- .../commands/maptool/ListOtherCommand.java | 40 ++++++++--------- .../commands/maptool/RenameCommand.java | 19 +++++--- .../image/ImageRendererExecutor.java | 2 +- 6 files changed, 96 insertions(+), 78 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java index c20279e..19e2556 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/DeleteOtherCommand.java @@ -62,19 +62,19 @@ public class DeleteOtherCommand extends IoMCommand @Override protected void run() throws CommandException { - if(args.length < 2) { - warning(I.t("Not enough parameters! Usage: /maptool deleteother ")); - return; + if(args.length < 2) { + warning(I.t("Not enough parameters! Usage: /maptool deleteother ")); + return; } - Player player = null; - UUID uuid = null; - OfflinePlayer op = null; + Player player = null; + UUID uuid = null; + OfflinePlayer op = null; player = Bukkit.getPlayer(args[0]); if(player == null){ - op = Bukkit.getOfflinePlayer(args[0]); - if(op.hasPlayedBefore()) uuid = op.getUniqueId(); - else warning(I.t("We've never seen that player before!")); + op = Bukkit.getOfflinePlayer(args[0]); + if(op.hasPlayedBefore()) uuid = op.getUniqueId(); + else warning(I.t("We've never seen that player before!")); } else uuid = player.getUniqueId(); if(player==null){ @@ -82,25 +82,25 @@ public class DeleteOtherCommand extends IoMCommand return; } ImageMap map = getMapFromArgs(player, 1, true); - + if(player != null) MapManager.clear(player.getInventory(), map); - - try - { - MapManager.deleteMap(map); - info(I.t("{gray}Map successfully deleted.")); - } - catch (MapManagerException ex) - { - PluginLogger.warning(I.t("A non-existent map was requested to be deleted", ex)); - warning(ChatColor.RED+(I.t("This map does not exist."))); - } + + try + { + MapManager.deleteMap(map); + info(I.t("{gray}Map successfully deleted.")); } + catch (MapManagerException ex) + { + PluginLogger.warning(I.t("A non-existent map was requested to be deleted", ex)); + warning(ChatColor.RED+(I.t("This map does not exist."))); + } + } @Override protected List complete() throws CommandException { - if(args.length == 1) + if(args.length == 1) return getMatchingMapNames(playerSender(), args[0]); return null; diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java index 6f30f19..9c33219 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/ExploreOtherCommand.java @@ -43,10 +43,11 @@ import fr.zcraft.zlib.components.commands.CommandException; import fr.zcraft.zlib.components.commands.CommandInfo; import fr.zcraft.zlib.components.gui.Gui; import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.PluginLogger; +import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; - -import java.util.concurrent.ExecutionException; +import org.bukkit.entity.Player; @CommandInfo (name = "exploreother") @@ -59,21 +60,31 @@ public class ExploreOtherCommand extends IoMCommand warning(I.t("Not enough parameters! Usage: /maptool exploreother ")); return; } - try{ - OfflinePlayer player=getOfflinePlayerParameter(0); - String name=args[0]; - if(player!=null) - Gui.open(playerSender(), new MapListGui(player,name)); - } - catch (InterruptedException | ExecutionException e){ - warning(I.t("Can't find player")); - return; - } + String name=args[0]; + Player sender=playerSender(); + offlinePlayerParameter(0, uuid -> { + if(uuid==null){ + try { + throwInvalidArgument(I.t("Player not found.")); + } catch (CommandException e) { + PluginLogger.error("CommandException "+e); + return; + } + } + OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid); + if (offlinePlayer != null) { + Gui.open(sender, new MapListGui(offlinePlayer, name)); + } + else{ + PluginLogger.warning(I.t("Can't find player")); + return; + } + }); } @Override public boolean canExecute(CommandSender sender) { - return Permissions.LISTOTHER.grantedTo(sender); + return Permissions.LISTOTHER.grantedTo(sender); } } diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java index a0fd1e0..f85eaa5 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/GetOtherCommand.java @@ -59,24 +59,24 @@ public class GetOtherCommand extends IoMCommand @Override protected void run() throws CommandException { - if(args.length < 2) { - warning(I.t("Not enough parameters! Usage: /maptool getother ")); - return; - } + if(args.length < 2) { + warning(I.t("Not enough parameters! Usage: /maptool getother ")); + return; + } Player player = null; UUID uuid = null; - player = Bukkit.getPlayer(args[0]); + player = Bukkit.getPlayer(args[0]); - if(player == null){ - OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]); + if(player == null){ + OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]); if(op.hasPlayedBefore()) uuid = op.getUniqueId(); else warning(I.t("We've never seen that player before!")); return; - } - else { - uuid = player.getUniqueId(); - } + } + else { + uuid = player.getUniqueId(); + } ImageMap map = null; String mapName = ""; mapName = args[1]; @@ -93,9 +93,9 @@ public class GetOtherCommand extends IoMCommand } return; } - @Override - public boolean canExecute(CommandSender sender) - { - return Permissions.GETOTHER.grantedTo(sender); - } + @Override + public boolean canExecute(CommandSender sender) + { + return Permissions.GETOTHER.grantedTo(sender); + } } diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java index 6e6b5a4..8d7dd5c 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/ListOtherCommand.java @@ -61,37 +61,37 @@ import java.util.UUID; @CommandInfo (name = "listother", usageParameters = "") public class ListOtherCommand extends IoMCommand { - @Override + @Override protected void run() throws CommandException { - if(args.length < 1){ - warning(I.t("Not enough parameters! Usage: /maptool listother ")); + if(args.length < 1){ + warning(I.t("Not enough parameters! Usage: /maptool listother ")); return; - } + } - - Player player = null; - UUID uuid = null; + + Player player = null; + UUID uuid = null; player = Bukkit.getPlayer(args[0]); if(player == null){ - OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]); - if(op.hasPlayedBefore()) { - uuid = op.getUniqueId(); - } - else { - warning(I.t("We've never seen that player before!")); - } + OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]); + if(op.hasPlayedBefore()) { + uuid = op.getUniqueId(); + } + else { + warning(I.t("We've never seen that player before!")); + } } else{ - uuid = player.getUniqueId(); + uuid = player.getUniqueId(); } - + List mapList = null; try{ - mapList = MapManager.getMapList(uuid); + mapList = MapManager.getMapList(uuid); } catch(Exception e){ - return; + return; } if(mapList.isEmpty()) @@ -99,7 +99,7 @@ public class ListOtherCommand extends IoMCommand info(I.t("No map found.")); return; } - + info(I.tn("{white}{bold}{0} map found.", "{white}{bold}{0} maps found.", mapList.size())); RawTextPart rawText = new RawText(""); @@ -122,7 +122,7 @@ public class ListOtherCommand extends IoMCommand .then(map.getId()) .color(ChatColor.WHITE) .command(GetCommand.class, map.getId()) - .hover(new RawText() + .hover(new RawText() .then(map.getName()).style(ChatColor.BOLD, ChatColor.GREEN).then("\n") .then(map.getId() + ", " + size).color(ChatColor.GRAY).then("\n\n") .then(I.t("{white}Click{gray} to get this map")) diff --git a/src/main/java/fr/moribus/imageonmap/commands/maptool/RenameCommand.java b/src/main/java/fr/moribus/imageonmap/commands/maptool/RenameCommand.java index d3d654f..cbeaa59 100644 --- a/src/main/java/fr/moribus/imageonmap/commands/maptool/RenameCommand.java +++ b/src/main/java/fr/moribus/imageonmap/commands/maptool/RenameCommand.java @@ -18,10 +18,13 @@ package fr.moribus.imageonmap.commands.maptool; +import fr.moribus.imageonmap.Permissions; 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 org.bukkit.command.CommandSender; import java.util.List; @@ -30,13 +33,17 @@ public class RenameCommand extends IoMCommand { @Override protected void run() throws CommandException { - if(args.length == 2) - { - ImageMap map = getMapFromArgs(); - map.rename(args[1]); - } else { - info(I.t("Not enough or too many arguments")); + if(args.length != 4) { + warning(I.t("Not enough or too many arguments! Usage: /maptool rename ")); + return; } + //if(args.length == 2) + //{ + ImageMap map = getMapFromArgs(); + map.rename(args[2]); + // } else { + // info(I.t("Not enough or too many arguments")); + // } } @Override protected List complete() throws CommandException diff --git a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java index 119d977..752f159 100644 --- a/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java +++ b/src/main/java/fr/moribus/imageonmap/image/ImageRendererExecutor.java @@ -165,7 +165,7 @@ public class ImageRendererExecutor extends Worker public ImageMap run() throws Throwable { - final URLConnection connection = HTTPconnection(url); + final URLConnection connection = connecting(url); final InputStream stream = connection.getInputStream(); final BufferedImage image = ImageIO.read(stream);