Fix Lang.yml bugs and cleanup
This commit is contained in:
@@ -57,7 +57,7 @@ public class EconomyOperations {
|
||||
double cost = bukkitConfig.getDouble("economy.cost-to-create", 100);
|
||||
EconomyResponse resp = Main.econ.withdrawPlayer(player.getName(), cost);
|
||||
if(resp.transactionSuccess()) {
|
||||
player.sendMessage(Lang.TITLE.toString() + Lang.COST_TO_OPEN.toString().replaceAll("%price", "" + cost));
|
||||
player.sendMessage(Lang.TITLE.toString() + Lang.COST_TO_CREATE.toString().replaceAll("%price", "" + cost));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,26 +4,30 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
public enum Lang {
|
||||
TITLE("title-name"),
|
||||
OPEN_VAULT("open-vault"),
|
||||
OPEN_OTHER_VAULT("open-other-vault"),
|
||||
INVALID_ARGS("invalid-args"),
|
||||
DELETE_VAULT("delete-vault"),
|
||||
DELETE_OTHER_VAULT("delete-other-vault"),
|
||||
PLAYER_ONLY("player-only"),
|
||||
MUST_BE_NUMBER("must-be-number"),
|
||||
DELETE_VAULT_ERROR("delete-vault-error"),
|
||||
NO_PERMS("no-permissions"),
|
||||
INSUFFICIENT_FUNDS("insufficient-funds"),
|
||||
REFUND_AMOUNT("refund-amount"),
|
||||
COST_TO_OPEN("cost-to-open"),
|
||||
VAULT_DOES_NOT_EXIST("vault-does-not-exist");
|
||||
TITLE("title-name", "&4[&fPlayerVaults&4]:"),
|
||||
OPEN_VAULT("open-vault", "&fOpening vault &a%v"),
|
||||
OPEN_OTHER_VAULT("open-other-vault", "&fOpening vault &a%v &fof &a%p"),
|
||||
OPEN_WORKBENCH("open-workbench", "&fOpening workbench"),
|
||||
INVALID_ARGS("invalid-args", "&cInvalid args!"),
|
||||
DELETE_VAULT("delete-vault", "&fDeleted vault &a%v"),
|
||||
DELETE_OTHER_VAULT("delete-other-vault", "&fDeleted vault &a%v &fof &a%p"),
|
||||
PLAYER_ONLY("player-only", "Sorry but that can only be run by a player!"),
|
||||
MUST_BE_NUMBER("must-be-number", "&cYou need to specify a number between 1-99"),
|
||||
DELETE_VAULT_ERROR("delete-vault-error", "&cError deleting vault :("),
|
||||
NO_PERMS("no-permissions", "&cYou don''t have permission for that!"),
|
||||
INSUFFICIENT_FUNDS("insufficient-funds", "&cYou don''t have enough money for that!"),
|
||||
REFUND_AMOUNT("refund-amount", "&fYou were refunded &a%price &ffor deleting that vault."),
|
||||
COST_TO_CREATE("cost-to-create", "&fYou were charged &c%price &ffor creating a vault."),
|
||||
COST_TO_OPEN("cost-to-open", "&fYou were charged &c%price &ffor opening that vault."),
|
||||
VAULT_DOES_NOT_EXIST("vault-does-not-exist", "&cThat vault does not exist!");
|
||||
|
||||
private String path;
|
||||
private String def; // Default string
|
||||
private static YamlConfiguration lang;
|
||||
|
||||
Lang(String path) {
|
||||
Lang(String path, String start) {
|
||||
this.path = path;
|
||||
this.def = start;
|
||||
}
|
||||
|
||||
public static void setFile(YamlConfiguration yc) {
|
||||
@@ -33,7 +37,15 @@ public enum Lang {
|
||||
@Override
|
||||
public String toString() {
|
||||
if(this == TITLE)
|
||||
return ChatColor.translateAlternateColorCodes('&', lang.getString(this.path)) + " ";
|
||||
return ChatColor.translateAlternateColorCodes('&', lang.getString(this.path));
|
||||
return ChatColor.translateAlternateColorCodes('&', lang.getString(this.path, def)) + " ";
|
||||
return ChatColor.translateAlternateColorCodes('&', lang.getString(this.path, def));
|
||||
}
|
||||
|
||||
public String getDefault() {
|
||||
return this.def;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ 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 java.util.logging.Level;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@@ -20,29 +20,17 @@ public class Updater extends Main {
|
||||
|
||||
public Updater(String version) {
|
||||
this.version = version;
|
||||
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());
|
||||
for(Lang item:Lang.values()) {
|
||||
if(langConf.getString(item.getPath()) == null) {
|
||||
langConf.set(item.getPath(), item.getDefault());
|
||||
}
|
||||
}
|
||||
try {
|
||||
langConf.save(super.getLangFile());
|
||||
} catch (IOException e) {
|
||||
log.log(Level.WARNING, "PlayerVaults: Failed to save lang.yml.");
|
||||
log.log(Level.WARNING, "PlayerVaults: Report this stack trace to drtshock and gomeow.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user