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