- Moved Maven repository to automatic jenkin-build-repo by cloudbees (free hosting)
 - Removed Unsafe storage item serialization as it is now more complex than i'd like to manage manually
   * (restoring should still work, so no inventory loss)
This commit is contained in:
Jascha Starke 2012-12-22 23:14:14 +01:00
parent 7a471ea05e
commit 4bbc6a38c4
8 changed files with 52 additions and 127 deletions

View file

@ -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.

View file

@ -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:

33
pom.xml
View file

@ -3,7 +3,7 @@
<groupId>de.jaschastarke</groupId>
<artifactId>LimitedCreative</artifactId>
<name>LimitedCreative</name>
<version>1.4.5a</version>
<version>1.4.6a</version>
<url>https://github.com/possi/LimitedCreative</url>
<scm>
<connection>scm:git:git://github.com/possi/LimitedCreative.git</connection>
@ -11,17 +11,14 @@
<url>https://github.com/possi/LimitedCreative/tree/master</url>
</scm>
<repositories>
<!-- The result with cloudbees SHOULD be stored here for public
<!-- Possible public Maven Repository, containing LimitedCreative builds and other dependencies without own rep.
like AuthMe, etc.
Supports http & https -->
<repository>
<id>de-jaschastarke</id>
<id>de-jas-mvn</id>
<url>https://repository-possi.forge.cloudbees.com/release</url>
</repository>
-->
<!-- Required dependencies for optional integrations, that aren't hosted yet -->
<repository>
<id>opt-dep</id>
<url>http://dl.dropbox.com/u/5023975/mvn-repo</url>
</repository>
<!-- Official (Craft-)Bukkit repository -->
<repository>
<id>bukkit-repo</id>
@ -37,10 +34,16 @@
<id>onarandombox</id>
<url>http://repo.onarandombox.com/content/groups/public</url>
</repository>
<!-- Official Vault repository -->
<repository>
<id>vault-repo</id>
<url>http://ci.herocraftonline.com/plugin/repository/everything</url>
</repository>
<!-- Official xAuth repository; it is no good! we keep our own dep-files of it - ->
<repository>
<id>luricos.de-repo</id>
<url>http://repo.luricos.de/bukkit-plugins/</url>
</repository><!- - -->
</repositories>
<build>
<sourceDirectory>${basedir}/src</sourceDirectory>
@ -78,28 +81,28 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.4.5-R0.2</version>
<version>1.4.6-R0.1</version>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.4.5-R0.2</version>
<version>1.4.6-R0.1</version>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
<version>5.4.4</version>
<version>5.4.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<version>5.6.3</version>
<version>5.6.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>uk.org.whoami</groupId>
<artifactId>authme</artifactId>
<version>2.6.7b5</version>
<version>2.7.0b2</version>
</dependency>
<dependency>
<groupId>com.onarandombox.multiversecore</groupId>
@ -109,7 +112,7 @@
<dependency>
<groupId>com.cypherx</groupId>
<artifactId>xauth</artifactId>
<version>2.0.20</version>
<version>2.0.26</version>
</dependency>
</dependencies>
<properties>

View file

@ -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");
}

View file

@ -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"));
//}
}
}

View file

@ -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<String, Object> 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)) {

View file

@ -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<String, Object> serialized = is.serialize();
Map<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> getRecursiveSerialized(ConfigurationSerializable conf) {
Map<String, Object> serialized = new HashMap<String, Object>(conf.serialize()); // de-immutable
for (Map.Entry<String, Object> 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;
}*/
}

View file

@ -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<String, Object> serializeTags(ItemStack cis) {
Map<String, Object> 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<String, Object>();
map.put("name", display.getString("Name"));
}
}
return map;
}
public static ItemStack unserializeTags(ItemStack cis, Map<String, Object> 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();
}
}