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;
|
dropOnDeath = true;
|
||||||
inventoriesToDrop = getConfig().getInt("drop-on-death.inventories");
|
inventoriesToDrop = getConfig().getInt("drop-on-death.inventories");
|
||||||
}
|
}
|
||||||
|
|
||||||
new File(directory + File.separator + "backups").mkdirs();
|
new File(directory + File.separator + "backups").mkdirs();
|
||||||
config = getConfig();
|
config = getConfig();
|
||||||
|
|
||||||
@@ -112,19 +112,56 @@ public class Main extends JavaPlugin {
|
|||||||
if (getServer().getPluginManager().getPlugin("Vault") == null) {
|
if (getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
if (rsp == null) {
|
if (rsp == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
econ = rsp.getProvider();
|
econ = rsp.getProvider();
|
||||||
useVault = true;
|
useVault = true;
|
||||||
|
|
||||||
return econ != null;
|
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() {
|
public void loadConfig() {
|
||||||
File config = new File(getDataFolder() + File.separator + "config.yml");
|
File config = new File(getDataFolder() + File.separator + "config.yml");
|
||||||
if(!config.exists()) {
|
if(!config.exists()) {
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
|
} else {
|
||||||
|
updateConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +195,7 @@ public class Main extends JavaPlugin {
|
|||||||
public YamlConfiguration getLang() {
|
public YamlConfiguration getLang() {
|
||||||
return lang;
|
return lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getLangFile() {
|
public File getLangFile() {
|
||||||
return langFile;
|
return langFile;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ public class BackwardsCompatibility {
|
|||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static CraftItemStack getCraftVersion(org.bukkit.inventory.ItemStack stack) {
|
private static CraftItemStack getCraftVersion(org.bukkit.inventory.ItemStack stack) {
|
||||||
if ((stack instanceof CraftItemStack))
|
if ((stack instanceof CraftItemStack))
|
||||||
return (CraftItemStack) stack;
|
return (CraftItemStack) stack;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class EconomyOperations {
|
|||||||
private static YamlConfiguration bukkitConfig = new YamlConfiguration();
|
private static YamlConfiguration bukkitConfig = new YamlConfiguration();
|
||||||
|
|
||||||
public static Main plugin;
|
public static Main plugin;
|
||||||
|
|
||||||
public EconomyOperations(Main instance) throws FileNotFoundException, IOException, InvalidConfigurationException {
|
public EconomyOperations(Main instance) throws FileNotFoundException, IOException, InvalidConfigurationException {
|
||||||
plugin = instance;
|
plugin = instance;
|
||||||
configFile = new File(plugin.getDataFolder(), "config.yml");
|
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
|
* All normal functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static Map<String, Object> toMap(JSONObject object) throws JSONException {
|
public static Map<String, Object> toMap(JSONObject object) throws JSONException {
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
Iterator<String> keys = object.keys();
|
Iterator<String> keys = object.keys();
|
||||||
while (keys.hasNext()) {
|
while (keys.hasNext()) {
|
||||||
String key = (String) keys.next();
|
String key = (String) keys.next();
|
||||||
map.put(key, fromJson(object.get(key)));
|
map.put(key, fromJson(object.get(key)));
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
private static Object fromJson(Object json) throws JSONException {
|
private static Object fromJson(Object json) throws JSONException {
|
||||||
if (json == JSONObject.NULL) {
|
if (json == JSONObject.NULL) {
|
||||||
return null;
|
return null;
|
||||||
} else if (json instanceof JSONObject) {
|
} else if (json instanceof JSONObject) {
|
||||||
return toMap((JSONObject) json);
|
return toMap((JSONObject) json);
|
||||||
} else if (json instanceof JSONArray) {
|
} else if (json instanceof JSONArray) {
|
||||||
return toList((JSONArray) json);
|
return toList((JSONArray) json);
|
||||||
} else {
|
} else {
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Object> toList(JSONArray array) throws JSONException {
|
public static List<Object> toList(JSONArray array) throws JSONException {
|
||||||
List<Object> list = new ArrayList<Object>();
|
List<Object> list = new ArrayList<Object>();
|
||||||
for (int i = 0; i < array.length(); i++) {
|
for (int i = 0; i < array.length(); i++) {
|
||||||
list.add(fromJson(array.get(i)));
|
list.add(fromJson(array.get(i)));
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> toString(Inventory inv) {
|
public static List<String> toString(Inventory inv) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<String>();
|
||||||
List<ConfigurationSerializable> items = new ArrayList<ConfigurationSerializable>();
|
List<ConfigurationSerializable> items = new ArrayList<ConfigurationSerializable>();
|
||||||
@@ -69,7 +69,7 @@ public class Serialization {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Inventory toInventory(List<String> stringItems, int number) {
|
public static Inventory toInventory(List<String> stringItems, int number) {
|
||||||
Inventory inv = Bukkit.createInventory(null, 54, ChatColor.RED + "Vault #" + number);
|
Inventory inv = Bukkit.createInventory(null, 54, ChatColor.RED + "Vault #" + number);
|
||||||
List<ItemStack> contents = new ArrayList<ItemStack>();
|
List<ItemStack> contents = new ArrayList<ItemStack>();
|
||||||
@@ -93,37 +93,37 @@ public class Serialization {
|
|||||||
return inv;
|
return inv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Object> serialize(ConfigurationSerializable cs) {
|
public static Map<String, Object> serialize(ConfigurationSerializable cs) {
|
||||||
Map<String, Object> serialized = recreateMap(cs.serialize());
|
Map<String, Object> serialized = recreateMap(cs.serialize());
|
||||||
for (Entry<String, Object> entry : serialized.entrySet()) {
|
for (Entry<String, Object> entry : serialized.entrySet()) {
|
||||||
if (entry.getValue() instanceof ConfigurationSerializable) {
|
if (entry.getValue() instanceof ConfigurationSerializable) {
|
||||||
entry.setValue(serialize((ConfigurationSerializable)entry.getValue()));
|
entry.setValue(serialize((ConfigurationSerializable)entry.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
serialized.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(cs.getClass()));
|
serialized.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(cs.getClass()));
|
||||||
return serialized;
|
return serialized;
|
||||||
}
|
}
|
||||||
public static Map<String, Object> recreateMap(Map<String, Object> original) {
|
public static Map<String, Object> recreateMap(Map<String, Object> original) {
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
for (Entry<String, Object> entry : original.entrySet()) {
|
for (Entry<String, Object> entry : original.entrySet()) {
|
||||||
map.put(entry.getKey(), entry.getValue());
|
map.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public static ConfigurationSerializable deserialize(Map<String, Object> map) {
|
public static ConfigurationSerializable deserialize(Map<String, Object> map) {
|
||||||
for (Entry<String, Object> entry : map.entrySet()) {
|
for (Entry<String, Object> entry : map.entrySet()) {
|
||||||
// Check if any of its sub-maps are ConfigurationSerializable. They need to be done first.
|
// 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)) {
|
if (entry.getValue() instanceof Map && ((Map)entry.getValue()).containsKey(ConfigurationSerialization.SERIALIZED_TYPE_KEY)) {
|
||||||
entry.setValue(deserialize((Map)entry.getValue()));
|
entry.setValue(deserialize((Map)entry.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ConfigurationSerialization.deserializeObject(map);
|
return ConfigurationSerialization.deserializeObject(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* All old methods for transferring
|
* All old methods for transferring
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import com.drtshock.playervaults.Main;
|
import com.drtshock.playervaults.Main;
|
||||||
|
|
||||||
public class Updater extends Main {
|
public class Updater extends Main {
|
||||||
|
|
||||||
SortedMap<String, String> lang = new TreeMap<String, String>();
|
SortedMap<String, String> lang = new TreeMap<String, String>();
|
||||||
|
|
||||||
public Updater() {
|
public Updater() {
|
||||||
lang.put("title-name", "&4[&fPlayerVaults&4]:");
|
lang.put("title-name", "&4[&fPlayerVaults&4]:");
|
||||||
lang.put("open-vault", "&fOpening vault &a%v");
|
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("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-create", "&fYou were charged &c%price &ffor creating that vault.");
|
||||||
lang.put("cost-to-open", "&fYou were charged &c%price &ffor opening that vault.");
|
lang.put("cost-to-open", "&fYou were charged &c%price &ffor opening that vault.");
|
||||||
|
|
||||||
YamlConfiguration langConf = super.getLang();
|
YamlConfiguration langConf = super.getLang();
|
||||||
for(Entry<String, String> e:lang.entrySet()) {
|
for(Entry<String, String> e:lang.entrySet()) {
|
||||||
if(langConf.getString(e.getKey()) == null) {
|
if(langConf.getString(e.getKey()) == null) {
|
||||||
@@ -44,9 +44,9 @@ public class Updater extends Main {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String newVersion = "";
|
String newVersion = "";
|
||||||
|
|
||||||
public String getNewVersion() {
|
public String getNewVersion() {
|
||||||
return this.newVersion;
|
return this.newVersion;
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ public class Updater extends Main {
|
|||||||
return false; //They are using a FUTURE version!
|
return false; //They are using a FUTURE version!
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false; //They are up to date!
|
return false; //They are up to date!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lineNum = lineNum + 1;
|
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