mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-23 02:42:31 +00:00
Hide messages in the console on auto reload
This commit is contained in:
parent
f75e07aad0
commit
8452fad8a3
@ -240,7 +240,7 @@ public class ShopChest extends JavaPlugin {
|
|||||||
ShopReloadEvent event = new ShopReloadEvent(Bukkit.getConsoleSender());
|
ShopReloadEvent event = new ShopReloadEvent(Bukkit.getConsoleSender());
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) getLogger().info("Successfully reloaded " + String.valueOf(shopUtils.reloadShops(true)) + " shops.");
|
if (!event.isCancelled()) shopUtils.reloadShops(true, false);
|
||||||
}
|
}
|
||||||
}, config.auto_reload_time * 20, config.auto_reload_time * 20);
|
}, config.auto_reload_time * 20, config.auto_reload_time * 20);
|
||||||
}
|
}
|
||||||
@ -364,7 +364,7 @@ public class ShopChest extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
private void initializeShops() {
|
private void initializeShops() {
|
||||||
debug("Initializing Shops...");
|
debug("Initializing Shops...");
|
||||||
int count = shopUtils.reloadShops(false);
|
int count = shopUtils.reloadShops(false, false);
|
||||||
getLogger().info("Initialized " + count + " Shops");
|
getLogger().info("Initialized " + count + " Shops");
|
||||||
debug("Initialized " + count + " Shops");
|
debug("Initialized " + count + " Shops");
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ class ShopCommand extends BukkitCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = shopUtils.reloadShops(true);
|
int count = shopUtils.reloadShops(true, true);
|
||||||
plugin.debug(player.getName() + " has reloaded " + count + " shops");
|
plugin.debug(player.getName() + " has reloaded " + count + " shops");
|
||||||
player.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.RELOADED_SHOPS, new LocalizedMessage.ReplacedRegex(Regex.AMOUNT, String.valueOf(count))));
|
player.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.RELOADED_SHOPS, new LocalizedMessage.ReplacedRegex(Regex.AMOUNT, String.valueOf(count))));
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ public class Config {
|
|||||||
plugin.saveDefaultConfig();
|
plugin.saveDefaultConfig();
|
||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
|
|
||||||
reload(true, true);
|
reload(true, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,7 +161,7 @@ public class Config {
|
|||||||
|
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
reload(false, langChange);
|
reload(false, langChange, false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (NumberFormatException e) { /* Value not an integer */ }
|
} catch (NumberFormatException e) { /* Value not an integer */ }
|
||||||
@ -172,7 +172,7 @@ public class Config {
|
|||||||
|
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
reload(false, langChange);
|
reload(false, langChange, false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (NumberFormatException e) { /* Value not a double */ }
|
} catch (NumberFormatException e) { /* Value not a double */ }
|
||||||
@ -187,7 +187,7 @@ public class Config {
|
|||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
|
|
||||||
reload(false, langChange);
|
reload(false, langChange, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -205,7 +205,7 @@ public class Config {
|
|||||||
|
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
reload(false, false);
|
reload(false, false, false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (NumberFormatException e) { /* Value not an integer */ }
|
} catch (NumberFormatException e) { /* Value not an integer */ }
|
||||||
@ -216,7 +216,7 @@ public class Config {
|
|||||||
|
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
reload(false, false);
|
reload(false, false, false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (NumberFormatException e) { /* Value not a double */ }
|
} catch (NumberFormatException e) { /* Value not a double */ }
|
||||||
@ -231,7 +231,7 @@ public class Config {
|
|||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
|
|
||||||
reload(false, false);
|
reload(false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(String property, String value) {
|
public void remove(String property, String value) {
|
||||||
@ -243,7 +243,7 @@ public class Config {
|
|||||||
|
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
reload(false, false);
|
reload(false, false, false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (NumberFormatException e) { /* Value not an integer */ }
|
} catch (NumberFormatException e) { /* Value not an integer */ }
|
||||||
@ -254,7 +254,7 @@ public class Config {
|
|||||||
|
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
reload(false, false);
|
reload(false, false, false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (NumberFormatException e) { /* Value not a double */ }
|
} catch (NumberFormatException e) { /* Value not a double */ }
|
||||||
@ -269,13 +269,13 @@ public class Config {
|
|||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
|
|
||||||
reload(false, false);
|
reload(false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reload the configuration values from config.yml
|
* Reload the configuration values from config.yml
|
||||||
*/
|
*/
|
||||||
public void reload(boolean firstLoad, boolean langReload) {
|
public void reload(boolean firstLoad, boolean langReload, boolean showMessages) {
|
||||||
database_mysql_ping_interval = plugin.getConfig().getInt("database.mysql.ping-interval");
|
database_mysql_ping_interval = plugin.getConfig().getInt("database.mysql.ping-interval");
|
||||||
database_mysql_host = plugin.getConfig().getString("database.mysql.hostname");
|
database_mysql_host = plugin.getConfig().getString("database.mysql.hostname");
|
||||||
database_mysql_port = plugin.getConfig().getInt("database.mysql.port");
|
database_mysql_port = plugin.getConfig().getInt("database.mysql.port");
|
||||||
@ -309,7 +309,7 @@ public class Config {
|
|||||||
main_command_name = plugin.getConfig().getString("main-command-name");
|
main_command_name = plugin.getConfig().getString("main-command-name");
|
||||||
language_file = plugin.getConfig().getString("language-file");
|
language_file = plugin.getConfig().getString("language-file");
|
||||||
|
|
||||||
if (firstLoad || langReload) loadLanguageConfig();
|
if (firstLoad || langReload) loadLanguageConfig(showMessages);
|
||||||
if (!firstLoad && langReload) LanguageUtils.load();
|
if (!firstLoad && langReload) LanguageUtils.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ public class Config {
|
|||||||
return langConfig;
|
return langConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadLanguageConfig() {
|
private void loadLanguageConfig(boolean showMessages) {
|
||||||
langConfig = new LanguageConfiguration(plugin);
|
langConfig = new LanguageConfiguration(plugin);
|
||||||
File langFolder = new File(plugin.getDataFolder(), "lang");
|
File langFolder = new File(plugin.getDataFolder(), "lang");
|
||||||
|
|
||||||
@ -340,9 +340,9 @@ public class Config {
|
|||||||
|
|
||||||
if (r == null) {
|
if (r == null) {
|
||||||
r = plugin._getTextResource("lang/en_US.lang");
|
r = plugin._getTextResource("lang/en_US.lang");
|
||||||
plugin.getLogger().info("Using locale \"en_US\" (Streamed from jar file)");
|
if (showMessages) plugin.getLogger().info("Using locale \"en_US\" (Streamed from jar file)");
|
||||||
} else {
|
} else {
|
||||||
plugin.getLogger().info("Using locale \"" + langConfigFile.getName().substring(0, langConfigFile.getName().length() - 5) + "\" (Streamed from jar file)");
|
if (showMessages) plugin.getLogger().info("Using locale \"" + langConfigFile.getName().substring(0, langConfigFile.getName().length() - 5) + "\" (Streamed from jar file)");
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferedReader br = new BufferedReader(r);
|
BufferedReader br = new BufferedReader(r);
|
||||||
@ -358,25 +358,31 @@ public class Config {
|
|||||||
|
|
||||||
langConfig.loadFromString(sb.toString());
|
langConfig.loadFromString(sb.toString());
|
||||||
} catch (IOException | InvalidConfigurationException ex) {
|
} catch (IOException | InvalidConfigurationException ex) {
|
||||||
plugin.debug(ex);
|
if (showMessages) {
|
||||||
plugin.getLogger().warning("Using default language values");
|
plugin.getLogger().warning("Using default language values");
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
langConfig.load(langDefaultFile);
|
langConfig.load(langDefaultFile);
|
||||||
plugin.getLogger().info("Using locale \"en_US\"");
|
if (showMessages) plugin.getLogger().info("Using locale \"en_US\"");
|
||||||
} catch (IOException | InvalidConfigurationException e) {
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
plugin.debug(e);
|
if (showMessages) {
|
||||||
plugin.getLogger().warning("Using default language values");
|
plugin.getLogger().warning("Using default language values");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
plugin.getLogger().info("Using locale \"" + langConfigFile.getName().substring(0, langConfigFile.getName().length() - 5) + "\"");
|
if (showMessages) plugin.getLogger().info("Using locale \"" + langConfigFile.getName().substring(0, langConfigFile.getName().length() - 5) + "\"");
|
||||||
langConfig.load(langConfigFile);
|
langConfig.load(langConfigFile);
|
||||||
} catch (IOException | InvalidConfigurationException ex) {
|
} catch (IOException | InvalidConfigurationException ex) {
|
||||||
plugin.debug(ex);
|
if (showMessages) {
|
||||||
plugin.getLogger().warning("Using default language values");
|
plugin.getLogger().warning("Using default language values");
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,14 +201,15 @@ public class ShopUtils {
|
|||||||
/**
|
/**
|
||||||
* Reload the shops
|
* Reload the shops
|
||||||
* @param reloadConfig Whether the configuration should also be reloaded
|
* @param reloadConfig Whether the configuration should also be reloaded
|
||||||
|
* @param showConsoleMessages Whether messages about the language file should be shown in the console
|
||||||
* @return Amount of shops, which were reloaded
|
* @return Amount of shops, which were reloaded
|
||||||
*/
|
*/
|
||||||
public int reloadShops(boolean reloadConfig) {
|
public int reloadShops(boolean reloadConfig, boolean showConsoleMessages) {
|
||||||
plugin.debug("Reloading shops...");
|
plugin.debug("Reloading shops...");
|
||||||
|
|
||||||
plugin.getShopDatabase().connect();
|
plugin.getShopDatabase().connect();
|
||||||
|
|
||||||
if (reloadConfig) plugin.getShopChestConfig().reload(false, true);
|
if (reloadConfig) plugin.getShopChestConfig().reload(false, true, showConsoleMessages);
|
||||||
|
|
||||||
int highestId = plugin.getShopDatabase().getHighestID();
|
int highestId = plugin.getShopDatabase().getHighestID();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user