Add config updater.
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>PlayerVaults</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,5 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -71,7 +71,7 @@ public class Main extends JavaPlugin {
|
||||
dropOnDeath = true;
|
||||
inventoriesToDrop = getConfig().getInt("drop-on-death.inventories");
|
||||
}
|
||||
|
||||
|
||||
new File(directory + File.separator + "backups").mkdirs();
|
||||
config = getConfig();
|
||||
|
||||
@@ -112,19 +112,56 @@ public class Main extends JavaPlugin {
|
||||
if (getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
||||
if (rsp == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
econ = rsp.getProvider();
|
||||
useVault = true;
|
||||
|
||||
return econ != null;
|
||||
}
|
||||
|
||||
public void updateConfig() {
|
||||
if(getConfig().get("check-update") == null) {
|
||||
getConfig().set("check-update", true);
|
||||
}
|
||||
|
||||
if(getConfig().get("economy.enabled") == null) {
|
||||
getConfig().set("economy.enabled", false);
|
||||
}
|
||||
|
||||
if(getConfig().get("economy.cost-to-create") == null) {
|
||||
getConfig().set("economy.cost-to-create", 100);
|
||||
}
|
||||
|
||||
if(getConfig().get("economy.cost-to-open") == null) {
|
||||
getConfig().set("economy.cost-to-create", 10);
|
||||
}
|
||||
|
||||
if(getConfig().get("economy.refund-on-delete") == null) {
|
||||
getConfig().set("economy.refund-on-delete", 50);
|
||||
}
|
||||
|
||||
if(getConfig().get("drop-on-death.enabled") == null) {
|
||||
getConfig().set("drop-on-death.enabled", false);
|
||||
}
|
||||
|
||||
if(getConfig().get("drop-on-death.inventories") == null) {
|
||||
getConfig().set("drop-on-death.inventories", 1);
|
||||
}
|
||||
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
public void loadConfig() {
|
||||
File config = new File(getDataFolder() + File.separator + "config.yml");
|
||||
if(!config.exists()) {
|
||||
saveDefaultConfig();
|
||||
} else {
|
||||
updateConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +195,7 @@ public class Main extends JavaPlugin {
|
||||
public YamlConfiguration getLang() {
|
||||
return lang;
|
||||
}
|
||||
|
||||
|
||||
public File getLangFile() {
|
||||
return langFile;
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ 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;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
# PlayerVaults by drsthock and gomeow!
|
||||
# http://dev.bukkit.org/server-mods/playervaults
|
||||
# Made with love :3
|
||||
|
||||
# Whether or not you want to check for updates.
|
||||
# Will not download an update, that is your job :)
|
||||
check-update: true
|
||||
|
||||
# Settings here are for economy integration. playervaults.free bypasses it.
|
||||
economy:
|
||||
enabled: false
|
||||
|
||||
# Cost to create a vault. You can give players playervaults.free to bypass this.
|
||||
cost-to-create: 100
|
||||
cost-to-open: 10
|
||||
refund-on-delete: 50
|
||||
|
||||
# Configuration for dropping inventories on death.
|
||||
# Bypass with playervaults.ignore.drop
|
||||
drop-on-death:
|
||||
enabled: false
|
||||
|
||||
# Max amount of inventories you want to be dropped.
|
||||
# Set to 99 (or highest amount you give people) if you want all inventories to be dropped.
|
||||
# WARNING: This can cause a lot of items to be dropped on the ground. Use caution :3
|
||||
inventories: 1
|
||||
@@ -0,0 +1,19 @@
|
||||
# Use & for color codes.
|
||||
# %p is where the player name will get inserted.
|
||||
# %v is where the vault number will get inserted.
|
||||
# %price is the price.
|
||||
# Made with love :)
|
||||
title-name: "&4[&fPlayerVaults&4]:"
|
||||
open-vault: "&fOpening vault &a%v"
|
||||
open-other-vault: "&fOpening vault &a%v &fof &a%p"
|
||||
delete-vault: "&fDeleted vault &a%v"
|
||||
delete-other-vault: "&fDeleted vault &a%v &fof &a%p"
|
||||
player-only: "Sorry but that can only be run by a player!"
|
||||
must-be-number: "&cYou need to specify a number between 1-99"
|
||||
invalid-args: "&cInvalid args!"
|
||||
delete-vault-error: "&cError deleting vault :("
|
||||
no-permissions: "&cYou don't have permission for that!"
|
||||
insufficient-funds: "&cYou don't have enough money for that!"
|
||||
refund-amount: "&fYou were refunded &a%price &ffor deleting that vault."
|
||||
cost-to-create: "&fYou were charged &c%price &ffor creating that vault."
|
||||
cost-to-open: "&fYou were charged &c%price &ffor opening that vault."
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
name: PlayerVaults
|
||||
main: com.drtshock.playervaults.Main
|
||||
authors: [drtshock, gomeow, Chester]
|
||||
version: 3.0.0
|
||||
website: http://dev.bukkit.org/server-mods/PlayerVaults
|
||||
softdepend: [Vault]
|
||||
commands:
|
||||
pv:
|
||||
description: Open a vault with /vault <number>
|
||||
aliases: [vault]
|
||||
pvdel:
|
||||
description: Delete a vault.
|
||||
aliases: [vaultdel]
|
||||
Reference in New Issue
Block a user