@@ -83,7 +83,6 @@ public class BackwardsCompatibility {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static CraftItemStack getCraftVersion(org.bukkit.inventory.ItemStack stack) {
|
||||
if ((stack instanceof CraftItemStack))
|
||||
return (CraftItemStack) stack;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class EconomyOperations {
|
||||
private static YamlConfiguration bukkitConfig = new YamlConfiguration();
|
||||
|
||||
public static Main plugin;
|
||||
|
||||
|
||||
public EconomyOperations(Main instance) throws FileNotFoundException, IOException, InvalidConfigurationException {
|
||||
plugin = instance;
|
||||
configFile = new File(plugin.getDataFolder(), "config.yml");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,37 +22,37 @@ public class Serialization {
|
||||
/*
|
||||
* All normal functions
|
||||
*/
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<String, Object> toMap(JSONObject object) throws JSONException {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Iterator<String> keys = object.keys();
|
||||
while (keys.hasNext()) {
|
||||
String key = (String) keys.next();
|
||||
map.put(key, fromJson(object.get(key)));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Iterator<String> keys = object.keys();
|
||||
while (keys.hasNext()) {
|
||||
String key = (String) keys.next();
|
||||
map.put(key, fromJson(object.get(key)));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
private static Object fromJson(Object json) throws JSONException {
|
||||
if (json == JSONObject.NULL) {
|
||||
return null;
|
||||
} else if (json instanceof JSONObject) {
|
||||
return toMap((JSONObject) json);
|
||||
} else if (json instanceof JSONArray) {
|
||||
return toList((JSONArray) json);
|
||||
} else {
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
if (json == JSONObject.NULL) {
|
||||
return null;
|
||||
} else if (json instanceof JSONObject) {
|
||||
return toMap((JSONObject) json);
|
||||
} else if (json instanceof JSONArray) {
|
||||
return toList((JSONArray) json);
|
||||
} else {
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Object> toList(JSONArray array) throws JSONException {
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
list.add(fromJson(array.get(i)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
list.add(fromJson(array.get(i)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<String> toString(Inventory inv) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<ConfigurationSerializable> items = new ArrayList<ConfigurationSerializable>();
|
||||
@@ -69,7 +69,7 @@ public class Serialization {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static Inventory toInventory(List<String> stringItems, int number) {
|
||||
Inventory inv = Bukkit.createInventory(null, 54, ChatColor.RED + "Vault #" + number);
|
||||
List<ItemStack> contents = new ArrayList<ItemStack>();
|
||||
@@ -93,37 +93,37 @@ public class Serialization {
|
||||
return inv;
|
||||
}
|
||||
|
||||
public static Map<String, Object> serialize(ConfigurationSerializable cs) {
|
||||
Map<String, Object> serialized = recreateMap(cs.serialize());
|
||||
for (Entry<String, Object> entry : serialized.entrySet()) {
|
||||
if (entry.getValue() instanceof ConfigurationSerializable) {
|
||||
entry.setValue(serialize((ConfigurationSerializable)entry.getValue()));
|
||||
}
|
||||
}
|
||||
serialized.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(cs.getClass()));
|
||||
return serialized;
|
||||
}
|
||||
public static Map<String, Object> recreateMap(Map<String, Object> original) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
for (Entry<String, Object> entry : original.entrySet()) {
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
public static Map<String, Object> serialize(ConfigurationSerializable cs) {
|
||||
Map<String, Object> serialized = recreateMap(cs.serialize());
|
||||
for (Entry<String, Object> entry : serialized.entrySet()) {
|
||||
if (entry.getValue() instanceof ConfigurationSerializable) {
|
||||
entry.setValue(serialize((ConfigurationSerializable)entry.getValue()));
|
||||
}
|
||||
}
|
||||
serialized.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(cs.getClass()));
|
||||
return serialized;
|
||||
}
|
||||
public static Map<String, Object> recreateMap(Map<String, Object> original) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
for (Entry<String, Object> entry : original.entrySet()) {
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static ConfigurationSerializable deserialize(Map<String, Object> map) {
|
||||
for (Entry<String, Object> entry : map.entrySet()) {
|
||||
// Check if any of its sub-maps are ConfigurationSerializable. They need to be done first.
|
||||
if (entry.getValue() instanceof Map && ((Map)entry.getValue()).containsKey(ConfigurationSerialization.SERIALIZED_TYPE_KEY)) {
|
||||
entry.setValue(deserialize((Map)entry.getValue()));
|
||||
}
|
||||
}
|
||||
return ConfigurationSerialization.deserializeObject(map);
|
||||
}
|
||||
|
||||
/*
|
||||
* All old methods for transferring
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static ConfigurationSerializable deserialize(Map<String, Object> map) {
|
||||
for (Entry<String, Object> entry : map.entrySet()) {
|
||||
// Check if any of its sub-maps are ConfigurationSerializable. They need to be done first.
|
||||
if (entry.getValue() instanceof Map && ((Map)entry.getValue()).containsKey(ConfigurationSerialization.SERIALIZED_TYPE_KEY)) {
|
||||
entry.setValue(deserialize((Map)entry.getValue()));
|
||||
}
|
||||
}
|
||||
return ConfigurationSerialization.deserializeObject(map);
|
||||
}
|
||||
|
||||
/*
|
||||
* All old methods for transferring
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import com.drtshock.playervaults.Main;
|
||||
|
||||
public class Updater extends Main {
|
||||
|
||||
|
||||
SortedMap<String, String> lang = new TreeMap<String, String>();
|
||||
|
||||
|
||||
public Updater() {
|
||||
lang.put("title-name", "&4[&fPlayerVaults&4]:");
|
||||
lang.put("open-vault", "&fOpening vault &a%v");
|
||||
@@ -31,7 +31,7 @@ public class Updater extends Main {
|
||||
lang.put("refund-amount", "&fYou were refunded &a%price &ffor deleting that vault.");
|
||||
lang.put("cost-to-create", "&fYou were charged &c%price &ffor creating that vault.");
|
||||
lang.put("cost-to-open", "&fYou were charged &c%price &ffor opening that vault.");
|
||||
|
||||
|
||||
YamlConfiguration langConf = super.getLang();
|
||||
for(Entry<String, String> e:lang.entrySet()) {
|
||||
if(langConf.getString(e.getKey()) == null) {
|
||||
@@ -44,9 +44,9 @@ public class Updater extends Main {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String newVersion = "";
|
||||
|
||||
|
||||
public String getNewVersion() {
|
||||
return this.newVersion;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class Updater extends Main {
|
||||
return false; //They are using a FUTURE version!
|
||||
}
|
||||
else {
|
||||
return false; //They are up to date!
|
||||
return false; //They are up to date!
|
||||
}
|
||||
}
|
||||
lineNum = lineNum + 1;
|
||||
|
||||
Reference in New Issue
Block a user