diff --git a/config.yml b/config.yml index dc2bcf1..6dddd84 100644 --- a/config.yml +++ b/config.yml @@ -18,13 +18,6 @@ store: # default: true creative: true - # UnsafeStore (for storing invalid enchants) - # By default the new and upgrade-safe storage method for items is used. This method doesn't allow the use - # of "invalid" enchants, like given by different plugins. Enable it, to allow invalid enchants (not recommended). - # (May be removed with 1.2, as bukkit then allows unsafed enchants by default) - # default: false - unsafe: false - # CreativeArmor # When set, all creative Player automatically wears the given items as Armor. So they are better seen by other # Players. diff --git a/plugin.yml b/plugin.yml index 41fed30..ffdaacb 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: LimitedCreative main: de.jaschastarke.minecraft.limitedcreative.Core -version: 1.4.5a +version: 1.4.6a softdepend: [WorldGuard, WorldEdit, MultiInv] dev-url: http://dev.bukkit.org/server-mods/limited-creative/ commands: diff --git a/pom.xml b/pom.xml index b05cc59..ade8e9c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ de.jaschastarke LimitedCreative LimitedCreative - 1.4.5a + 1.4.6a https://github.com/possi/LimitedCreative scm:git:git://github.com/possi/LimitedCreative.git @@ -11,17 +11,14 @@ https://github.com/possi/LimitedCreative/tree/master - - de-jaschastarke + de-jas-mvn https://repository-possi.forge.cloudbees.com/release - --> - - - opt-dep - http://dl.dropbox.com/u/5023975/mvn-repo - + bukkit-repo @@ -37,10 +34,16 @@ onarandombox http://repo.onarandombox.com/content/groups/public + vault-repo http://ci.herocraftonline.com/plugin/repository/everything + ${basedir}/src @@ -78,28 +81,28 @@ org.bukkit bukkit - 1.4.5-R0.2 + 1.4.6-R0.1 org.bukkit craftbukkit - 1.4.5-R0.2 + 1.4.6-R0.1 com.sk89q worldedit - 5.4.4 + 5.4.5 compile com.sk89q worldguard - 5.6.3 + 5.6.6-SNAPSHOT uk.org.whoami authme - 2.6.7b5 + 2.7.0b2 com.onarandombox.multiversecore @@ -109,7 +112,7 @@ com.cypherx xauth - 2.0.20 + 2.0.26 diff --git a/src/de/jaschastarke/minecraft/limitedcreative/Configuration.java b/src/de/jaschastarke/minecraft/limitedcreative/Configuration.java index 92b901f..2c2ede7 100644 --- a/src/de/jaschastarke/minecraft/limitedcreative/Configuration.java +++ b/src/de/jaschastarke/minecraft/limitedcreative/Configuration.java @@ -122,9 +122,9 @@ public class Configuration { public boolean getStoreCreative() { return this.getBoolean(Option.STORECREATIVE); } - public boolean getUnsafeStorage() { + /*public boolean getUnsafeStorage() { return c.getBoolean("store.unsafe", false); - } + }*/ public String getInventoryFolder() { return c.getString("store.folder", "inventories"); } diff --git a/src/de/jaschastarke/minecraft/limitedcreative/Inventory.java b/src/de/jaschastarke/minecraft/limitedcreative/Inventory.java index cf881f9..702bd60 100644 --- a/src/de/jaschastarke/minecraft/limitedcreative/Inventory.java +++ b/src/de/jaschastarke/minecraft/limitedcreative/Inventory.java @@ -17,9 +17,6 @@ */ package de.jaschastarke.minecraft.limitedcreative; -import static de.jaschastarke.minecraft.utils.Locale.L; - -import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -79,11 +76,11 @@ public class Inventory { try { storage.load(this, Target.getTarget(gm)); } catch (IllegalArgumentException e) { - if (Core.plugin.config.getUnsafeStorage()) { + //if (Core.plugin.config.getUnsafeStorage()) { throw e; - } else { - getPlayer().sendMessage(ChatColor.DARK_RED + L("exception.storage.load")); - } + //} else { + //getPlayer().sendMessage(ChatColor.DARK_RED + L("exception.storage.load")); + //} } } diff --git a/src/de/jaschastarke/minecraft/limitedcreative/store/Fallback.java b/src/de/jaschastarke/minecraft/limitedcreative/store/Fallback.java index 7835c75..b7a545e 100644 --- a/src/de/jaschastarke/minecraft/limitedcreative/store/Fallback.java +++ b/src/de/jaschastarke/minecraft/limitedcreative/store/Fallback.java @@ -26,8 +26,6 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; -import de.jaschastarke.minecraft.limitedcreative.Core; - public class Fallback { public static void loadVersion1(PlayerInventory inv, ConfigurationSection sect) { @@ -64,14 +62,14 @@ public class Fallback { } public static void sectionSetItem(ConfigurationSection section, String path, ItemStack item) { - if (!Core.plugin.config.getUnsafeStorage()) { + //if (!Core.plugin.config.getUnsafeStorage()) { section.set(path, item); - } else { // unsafe enchants fallback + /*} else { // unsafe enchants fallback Map serialize = item.serialize(); if (serialize.containsKey("type") && serialize.get("type") instanceof Material) serialize.put("type", serialize.get("type").toString()); section.createSection(path, serialize); - }; + };*/ } public static ItemStack sectionGetItem(ConfigurationSection section, String path) { if (section.isItemStack(path)) { diff --git a/src/de/jaschastarke/minecraft/limitedcreative/store/InvConfStorage.java b/src/de/jaschastarke/minecraft/limitedcreative/store/InvConfStorage.java index f94318d..0f48b5f 100644 --- a/src/de/jaschastarke/minecraft/limitedcreative/store/InvConfStorage.java +++ b/src/de/jaschastarke/minecraft/limitedcreative/store/InvConfStorage.java @@ -24,6 +24,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.ItemMeta; import de.jaschastarke.minecraft.limitedcreative.Core; import de.jaschastarke.minecraft.limitedcreative.Inventory; @@ -33,9 +34,9 @@ abstract public class InvConfStorage extends PlayerInventoryStorage { public void store(Inventory pinv, ConfigurationSection sect) { PlayerInventory inv = pinv.getPlayer().getInventory(); - sect.set("version", 2); - if (Core.plugin.config.getUnsafeStorage()) - sect.set("unsafe", true); + sect.set("version", 4); + /*if (Core.plugin.config.getUnsafeStorage()) + sect.set("unsafe", true);*/ storeItems(sect.createSection("armor"), inv.getArmorContents()); storeItems(sect.createSection("inv"), inv.getContents()); } @@ -77,15 +78,10 @@ abstract public class InvConfStorage extends PlayerInventoryStorage { return items; } - protected Object serialize(ItemStack is) { + protected Object serialize(ItemStack is) {/* if (Core.plugin.config.getUnsafeStorage()) { - Map serialized = is.serialize(); - Map tagData = NBTagSerializer.serializeTags(is); - if (tagData != null) { - serialized.put("tag", tagData); - } - return serialized; - } + return getRecursiveSerialized(is); + }*/ return is; } @@ -98,7 +94,7 @@ abstract public class InvConfStorage extends PlayerInventoryStorage { int amount = sect.getInt("amount", 1); ItemStack result = new ItemStack(type, amount, damage); - if (sect.contains("enchantments")) { + if (sect.contains("enchantments")) { // conf-version 2 for (Map.Entry entry : sect.getConfigurationSection("enchantments").getValues(false).entrySet()) { Enchantment enchantment = Enchantment.getByName(entry.getKey().toString()); if ((enchantment != null) && (entry.getValue() instanceof Integer)) { @@ -106,9 +102,11 @@ abstract public class InvConfStorage extends PlayerInventoryStorage { } } } - if (sect.contains("tag")) { - Map map = sect.getConfigurationSection("tag").getValues(false); - result = NBTagSerializer.unserializeTags(result, map); + if (sect.contains("tag")) { // Backward compatibility for 1.4.5-R0.2; Was Conf-Version 2, but should be 3 ;) + ConfigurationSection tag = sect.getConfigurationSection("tag"); + ItemMeta meta = result.getItemMeta(); + meta.setDisplayName(tag.getString("name")); + result.setItemMeta(meta); } return result; } else if (is instanceof Map) { @@ -118,4 +116,15 @@ abstract public class InvConfStorage extends PlayerInventoryStorage { return null; } } + + /*protected static Map getRecursiveSerialized(ConfigurationSerializable conf) { + Map serialized = new HashMap(conf.serialize()); // de-immutable + for (Map.Entry entry : serialized.entrySet()) { + if (entry.getValue() instanceof ConfigurationSerializable) { + entry.setValue(getRecursiveSerialized((ConfigurationSerializable) entry.getValue())); // immutable + //serialized.put(entry.getKey(), getRecursiveSerialized((ConfigurationSerializable) entry.getValue())); + } + } + return serialized; + }*/ } diff --git a/src/de/jaschastarke/minecraft/limitedcreative/store/NBTagSerializer.java b/src/de/jaschastarke/minecraft/limitedcreative/store/NBTagSerializer.java deleted file mode 100644 index 51e005d..0000000 --- a/src/de/jaschastarke/minecraft/limitedcreative/store/NBTagSerializer.java +++ /dev/null @@ -1,75 +0,0 @@ -package de.jaschastarke.minecraft.limitedcreative.store; - -import java.util.HashMap; -import java.util.Map; - -import net.minecraft.server.NBTTagCompound; - -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.inventory.ItemStack; - -public class NBTagSerializer { - - public static Map serializeTags(ItemStack cis) { - Map map = null; - NBTTagCompound tag = getTag(cis); - if (tag != null && tag.getCompound("display") != null) { - NBTTagCompound display = tag.getCompound("display"); - if (display.hasKey("Name")) { - map = new HashMap(); - map.put("name", display.getString("Name")); - } - } - return map; - } - - public static ItemStack unserializeTags(ItemStack cis, Map data) { - if (data.size() > 0) { - if (!(cis instanceof CraftItemStack)) { - cis = new CraftItemStack(cis); - } - NBTTagCompound nbt = getTag(cis, true); - - if (data.containsKey("name")) { - NBTTagCompound display; - if (nbt.hasKey("display")) { - display = nbt.getCompound("display"); - } else { - display = new NBTTagCompound("display"); - nbt.setCompound("display", display); - } - display.setString("Name", (String) data.get("name")); - } - } - return cis; - } - - private static NBTTagCompound getTag(ItemStack stack, boolean force) { - NBTTagCompound nbt = getTag(stack); - if (nbt == null && force) { - nbt = new NBTTagCompound(); - getMCItemStack(stack).setTag(nbt); - } - return nbt; - } - - private static NBTTagCompound getTag(ItemStack stack) { - net.minecraft.server.ItemStack is = getMCItemStack(stack); - if (is != null) { - return is.getTag(); - } else { - return null; - } - } - - private static net.minecraft.server.ItemStack getMCItemStack(ItemStack stack) { - if (stack instanceof CraftItemStack) { - return getMCItemStack((CraftItemStack) stack); - } else { - return null; - } - } - private static net.minecraft.server.ItemStack getMCItemStack(CraftItemStack stack) { - return stack.getHandle(); - } -}