Work on updating lang file on new downloads
This commit is contained in:
@@ -31,6 +31,8 @@ public class Main extends JavaPlugin {
|
||||
public static int inventoriesToDrop = 0;
|
||||
public static boolean useVault = false;
|
||||
public static FileConfiguration config;
|
||||
public static YamlConfiguration lang;
|
||||
public static File langFile;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@@ -134,6 +136,16 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
YamlConfiguration conf = YamlConfiguration.loadConfiguration(lang);
|
||||
Lang.setFile(conf);
|
||||
Main.lang = conf;
|
||||
Main.langFile = lang;
|
||||
return conf;
|
||||
}
|
||||
|
||||
public YamlConfiguration getLang() {
|
||||
return lang;
|
||||
}
|
||||
|
||||
public File getLangFile() {
|
||||
return langFile;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@ public enum Lang {
|
||||
NO_PERMS("no-permissions"),
|
||||
INSUFFICIENT_FUNDS("insufficient-funds"),
|
||||
REFUND_AMOUNT("refund-amount"),
|
||||
COST_TO_OPEN("cost-to-open");
|
||||
COST_TO_OPEN("cost-to-open"),
|
||||
VAULT_DOES_NOT_EXIST("vault-does-not-exist");
|
||||
|
||||
private String path = "";
|
||||
private String path;
|
||||
private static YamlConfiguration lang;
|
||||
|
||||
Lang(String path) {
|
||||
|
||||
@@ -1,16 +1,50 @@
|
||||
package com.drtshock.playervaults.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
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");
|
||||
lang.put("open-other-vault", "&fOpening vault &a%v &fof &a%p");
|
||||
lang.put("delete-other-vault", "&fDeleted vault &a%v &fof &a%p");
|
||||
lang.put("player-only", "Sorry but that can only be run by a player!");
|
||||
lang.put("must-be-number", "&cYou need to specify a number between 1-99");
|
||||
lang.put("invalid-args", "&cInvalid args!");
|
||||
lang.put("delete-vault-error", "&cError deleting vault :(");
|
||||
lang.put("no-permissions", "&cYou don't have permission for that!");
|
||||
lang.put("insufficient-funds", "&cYou don't have enough money for that");
|
||||
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) {
|
||||
langConf.set(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
try {
|
||||
langConf.save(super.getLangFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
String newVersion = "";
|
||||
|
||||
public String getNewVersion() {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# %v is where the vault number will get inserted.
|
||||
# %price is the price.
|
||||
# Made with love :)
|
||||
title-name: "&4[&fPlayerVaults&4]: "
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user