From c01a81daae494d5076d89ef9ae2f0abc6d287f9b Mon Sep 17 00:00:00 2001 From: eccentric devotion Date: Fri, 3 Oct 2014 00:30:22 +1300 Subject: [PATCH 1/2] Don't rename the map if the album name returns an empty string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Other plugins may use renamed maps, which shouldn’t be renamed. --- src/fromgate/obscura/COCamera.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fromgate/obscura/COCamera.java b/src/fromgate/obscura/COCamera.java index c787097..3c4bcc4 100644 --- a/src/fromgate/obscura/COCamera.java +++ b/src/fromgate/obscura/COCamera.java @@ -153,6 +153,8 @@ public static void updateMapName (ItemStack item){ if ((item==null)||(item.getType()!=Material.MAP)) return; short id = item.getDurability(); String name_album = plg().album.getPictureName(id); + // don't rename the item as the map may be used by another plugin + if (name_album.isEmpty()) return; String name_item = getName (item); if (!name_album.equals(name_item)) setName (item, name_album); } From d74425c457905487e75151af5996114412e50149 Mon Sep 17 00:00:00 2001 From: eccentric devotion Date: Fri, 3 Oct 2014 00:32:58 +1300 Subject: [PATCH 2/2] Add a config list option to reserve map ids Some plugins may use specific maps in recipes and/or so that they can be retextured using Custom Item Textures. --- src/fromgate/obscura/COAlbum.java | 4 +++- src/fromgate/obscura/Obscura.java | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/fromgate/obscura/COAlbum.java b/src/fromgate/obscura/COAlbum.java index 92dbfd2..3979882 100644 --- a/src/fromgate/obscura/COAlbum.java +++ b/src/fromgate/obscura/COAlbum.java @@ -96,7 +96,9 @@ public short createMap (BufferedImage image, boolean reusedeleted, String name, if ((!reusedeleted)||deletedmaps.isEmpty()||(deletedmaps.size()==0)) return createNewMap (image); short id = deletedmaps.get(0); deletedmaps.remove(0); - return updateMap (id, image); + // don't use reserved map ids - servers can set map ids in the config + if (plg.reserved_maps.contains(id)) return createNewMap(image); + return updateMap (id, image); } public boolean isObscuraMap (short id){ diff --git a/src/fromgate/obscura/Obscura.java b/src/fromgate/obscura/Obscura.java index f388707..75a17db 100644 --- a/src/fromgate/obscura/Obscura.java +++ b/src/fromgate/obscura/Obscura.java @@ -23,6 +23,8 @@ import java.io.File; import java.io.IOException; +import java.util.Arrays; +import java.util.List; import net.milkbowl.vault.economy.Economy; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; @@ -137,6 +139,7 @@ public class Obscura extends JavaPlugin { boolean stroke = true; String name_color = "#000000"; String stroke_color = "#FFFFFF"; + List reserved_maps = Arrays.asList((short)1963, (short)1964);; int name_x = 1; int name_y = 122; @@ -262,6 +265,7 @@ public void loadCfg(){ name_color = getConfig().getString("picture-name.font-color","#000000"); stroke =getConfig().getBoolean("picture-name.stroke",true); stroke_color = getConfig().getString("picture-name.stroke-color","#FFFFFF"); + reserved_maps = getConfig().getShortList("reserved-maps"); } }