From 4885198888b5cb09c047823eddba468da4bfce20 Mon Sep 17 00:00:00 2001 From: kirbykirby56 Date: Sat, 24 Mar 2018 20:46:32 -0400 Subject: [PATCH 01/11] 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 02/11] 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 03/11] 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 04/11] 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 05/11] 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 06/11] 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 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 07/11] 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 08/11] 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 09/11] 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 10/11] 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 11/11] 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