1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-08 09:17:48 +01:00

Now if the localestring is empty or not found then create a default message file

- Now if execute the /jobs reload command then load the furnacebrewinghandling event.
- Fix language double loading when plugin startup
This commit is contained in:
montlikadani 2018-11-01 17:00:29 +01:00
parent b682f1f8c1
commit ac77148230
7 changed files with 39 additions and 38 deletions

View File

@ -600,6 +600,7 @@ public class Jobs extends JavaPlugin {
GconfigManager.reload(); GconfigManager.reload();
lManager.reload(); lManager.reload();
configManager.reload(); configManager.reload();
FurnaceBrewingHandling.load();
usedSlots.clear(); usedSlots.clear();
for (Job job : jobs) { for (Job job : jobs) {
usedSlots.put(job, dao.getSlotsTaken(job)); usedSlots.put(job, dao.getSlotsTaken(job));
@ -838,10 +839,7 @@ public class Jobs extends JavaPlugin {
dao.loadBlockProtection(); dao.loadBlockProtection();
exploreManager.load(); exploreManager.load();
FurnaceBrewingHandling.load();
consoleMsg("&e[Jobs] Plugin has been enabled successfully."); consoleMsg("&e[Jobs] Plugin has been enabled successfully.");
lManager.reload();
cManager.fillCommands(); cManager.fillCommands();

View File

@ -90,27 +90,41 @@ public class LanguageManager {
String ls = Jobs.getGCManager().localeString; String ls = Jobs.getGCManager().localeString;
if (ls == null || ls.equals(""))
return;
YmlMaker langFile = new YmlMaker(plugin, "locale" + File.separator + "messages_" + ls + ".yml");
langFile.saveDefaultConfig();
languages.clear(); languages.clear();
languages.add("en"); languages.add("en");
YmlMaker langFile = null;
if (ls == null || ls.equals("")) {
langFile = new YmlMaker(plugin, "locale" + File.separator + "messages_en.yml");
langFile.saveDefaultConfig();
} else {
langFile = new YmlMaker(plugin, "locale" + File.separator + "messages_" + ls + ".yml");
langFile.saveDefaultConfig();
File customLocaleFile = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + ls + ".yml"); File customLocaleFile = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + ls + ".yml");
if (!customLocaleFile.exists() && !ls.equalsIgnoreCase("en")) if (!customLocaleFile.exists() && !ls.equalsIgnoreCase("en"))
languages.add(ls); languages.add(ls);
}
for (String lang : languages) { for (String lang : languages) {
File f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + lang + ".yml"); File f = null;
if (ls == null || ls.equals("")) {
f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_en.yml");
// Fail safe if file get corrupted and being created with corrupted data, we need to recreate it // Fail safe if file get corrupted and being created with corrupted data, we need to re-create it
if ((f.length() / 1024) > 1024) {
f.delete();
f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_en.yml");
}
} else {
f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + lang + ".yml");
// Fail safe if file get corrupted and being created with corrupted data, we need to re-create it
if ((f.length() / 1024) > 1024) { if ((f.length() / 1024) > 1024) {
f.delete(); f.delete();
f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + lang + ".yml"); f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + lang + ".yml");
} }
}
YamlConfiguration config = YamlConfiguration.loadConfiguration(f); YamlConfiguration config = YamlConfiguration.loadConfiguration(f);
CommentedYamlConfiguration writer = new CommentedYamlConfiguration(); CommentedYamlConfiguration writer = new CommentedYamlConfiguration();

View File

@ -31,7 +31,6 @@ public class JobsConnectionPool {
} }
if (connection == null) { if (connection == null) {
@SuppressWarnings("resource")
Connection conn = DriverManager.getConnection(url, username, password); Connection conn = DriverManager.getConnection(url, username, password);
connection = new JobsConnection(conn); connection = new JobsConnection(conn);
} }

View File

@ -113,7 +113,6 @@ public class JobsMySQL extends JobsDAO {
return prest; return prest;
} }
@SuppressWarnings("resource")
@Override @Override
public boolean createTable(String query) { public boolean createTable(String query) {
Jobs.consoleMsg(query); Jobs.consoleMsg(query);
@ -137,7 +136,6 @@ public class JobsMySQL extends JobsDAO {
return true; return true;
} }
@SuppressWarnings("resource")
@Override @Override
public boolean isTable(String table) { public boolean isTable(String table) {
Statement statement; Statement statement;
@ -158,7 +156,6 @@ public class JobsMySQL extends JobsDAO {
} }
} }
@SuppressWarnings("resource")
@Override @Override
public boolean isCollumn(String table, String collumn) { public boolean isCollumn(String table, String collumn) {
Statement statement; Statement statement;
@ -180,7 +177,6 @@ public class JobsMySQL extends JobsDAO {
} }
} }
@SuppressWarnings("resource")
@Override @Override
public boolean addCollumn(String table, String collumn, String type) { public boolean addCollumn(String table, String collumn, String type) {
Statement statement; Statement statement;
@ -202,7 +198,6 @@ public class JobsMySQL extends JobsDAO {
} }
} }
@SuppressWarnings("resource")
@Override @Override
public boolean truncate(String table) { public boolean truncate(String table) {
Statement statement = null; Statement statement = null;
@ -226,7 +221,6 @@ public class JobsMySQL extends JobsDAO {
} }
} }
@SuppressWarnings("resource")
@Override @Override
public boolean drop(String table) { public boolean drop(String table) {
Statement statement = null; Statement statement = null;

View File

@ -113,7 +113,6 @@ public class JobsSQLite extends JobsDAO {
return prest; return prest;
} }
@SuppressWarnings("resource")
@Override @Override
public boolean createTable(String query) { public boolean createTable(String query) {
Statement statement = null; Statement statement = null;
@ -170,7 +169,6 @@ public class JobsSQLite extends JobsDAO {
} }
} }
@SuppressWarnings("resource")
@Override @Override
public boolean addCollumn(String table, String collumn, String type) { public boolean addCollumn(String table, String collumn, String type) {
Statement statement; Statement statement;
@ -190,7 +188,6 @@ public class JobsSQLite extends JobsDAO {
} }
} }
@SuppressWarnings("resource")
@Override @Override
public boolean truncate(String table) { public boolean truncate(String table) {
Statement statement = null; Statement statement = null;

View File

@ -140,9 +140,8 @@ public class BufferedEconomy {
this.ServerTaxesAccount = Bukkit.getOfflinePlayer(ServerTaxesAccountname); this.ServerTaxesAccount = Bukkit.getOfflinePlayer(ServerTaxesAccountname);
if (Jobs.getGCManager().UseTaxes && Jobs.getGCManager().TransferToServerAccount && ServerTaxesAccount != null) { if (Jobs.getGCManager().UseTaxes && Jobs.getGCManager().TransferToServerAccount && ServerTaxesAccount != null) {
if(TaxesAmount > 0) { if (TaxesAmount > 0)
economy.depositPlayer(ServerTaxesAccount, TaxesAmount); economy.depositPlayer(ServerTaxesAccount, TaxesAmount);
}
if (ServerTaxesAccount.isOnline()) { if (ServerTaxesAccount.isOnline()) {
if (!Jobs.getActionbarToggleList().containsKey(ServerTaxesAccountname) && Jobs.getGCManager().ActionBarsMessageByDefault) if (!Jobs.getActionbarToggleList().containsKey(ServerTaxesAccountname) && Jobs.getGCManager().ActionBarsMessageByDefault)
Jobs.getActionbarToggleList().put(ServerTaxesAccountname, true); Jobs.getActionbarToggleList().put(ServerTaxesAccountname, true);

View File

@ -219,7 +219,7 @@ public class JobsPaymentListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player == null || !player.isOnline()) if (!player.isOnline())
return; return;
if (Jobs.getGCManager().CowMilkingTimer > 0) if (Jobs.getGCManager().CowMilkingTimer > 0)
@ -284,7 +284,7 @@ public class JobsPaymentListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player == null || !player.isOnline()) if (!player.isOnline())
return; return;
// check if in creative // check if in creative
@ -1500,7 +1500,7 @@ public class JobsPaymentListener implements Listener {
Player p = event.getPlayer(); Player p = event.getPlayer();
if (p == null || !p.isOnline()) if (!p.isOnline())
return; return;
// check if in creative // check if in creative
@ -1534,7 +1534,7 @@ public class JobsPaymentListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player == null || !player.isOnline()) if (!player.isOnline())
return; return;
if (!Jobs.getGCManager().payExploringWhenFlying() && player.isFlying()) if (!Jobs.getGCManager().payExploringWhenFlying() && player.isFlying())