Features
- bStats Metrics - Update checking with GitHub - Dynamic config.yml
This commit is contained in:
parent
d71087c3d8
commit
5efa4cd5be
9 changed files with 410 additions and 53 deletions
|
|
@ -6,45 +6,56 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Messenger {
|
||||
|
||||
private static final Defaults DEFAULT_MESSAGES;
|
||||
static {
|
||||
DEFAULT_MESSAGES = Defaults.of(
|
||||
"serverutils", Defaults.of(
|
||||
"success", "&3Successfully %action%ed &b%what%&3!",
|
||||
"warning", "&3Successfully %action%ed &b%what%&3, but with warnings.",
|
||||
"error", "&cAn error occurred while %action%ing &4%what%&c, please check the console!",
|
||||
"not_exists", "&cAn error occurred while %action%ing &4%what%&c, plugin does not exist!",
|
||||
"not_enabled", "&cAn error occurred while %action%ing &4%what%&c, plugin is not enabled!",
|
||||
"already_enabled", "&cAn error occurred while %action%ing &4%what%&c, plugin is already enabled!",
|
||||
"file_changed", "&cAccessing the jar file while %action%ing &4%what%&c went wrong, please load the plugin manually!",
|
||||
"help", Defaults.of(
|
||||
"header", "&8&m-------------=&r&8[ &b&lServerUtils Help&r &8]&m=---------------",
|
||||
"format", "&8/&3%command%&b%subcommand% &f(&7%help%&f)",
|
||||
"footer", "&8&m-------------------------------------------------"
|
||||
),
|
||||
"plugins", Defaults.of(
|
||||
"header", "&8&m------------=&r&8[ &b&lServerUtils Plugins&r &8]&m=-------------",
|
||||
"format", "&3%plugin%",
|
||||
"seperator", "&b, ",
|
||||
"last_seperator", " &band ",
|
||||
"version", " &8(&a%version%&8)",
|
||||
"footer", "&8&m-------------------------------------------------"
|
||||
),
|
||||
"plugininfo", Defaults.of(
|
||||
"header", "&8&m-----------=&r&8[ &b&lServerUtils PluginInfo&r &8]&m=-----------",
|
||||
"format", " &3%key%&8: &b%value%",
|
||||
"list_format", "&b%value%",
|
||||
"seperator", "&8, ",
|
||||
"last_seperator", " &8and ",
|
||||
"footer", "&8&m-------------------------------------------------"
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
private static final Defaults DEFAULT_MESSAGES = Defaults.of(
|
||||
"serverutils", Defaults.of(
|
||||
"success", "&3Successfully %action%ed &b%what%&3!",
|
||||
"warning", "&3Successfully %action%ed &b%what%&3, but with warnings.",
|
||||
"error", "&cAn error occurred while %action%ing &4%what%&c, please check the console!",
|
||||
"not_exists", "&cAn error occurred while %action%ing &4%what%&c, plugin does not exist!",
|
||||
"not_enabled", "&cAn error occurred while %action%ing &4%what%&c, plugin is not enabled!",
|
||||
"already_enabled", "&cAn error occurred while %action%ing &4%what%&c, plugin is already enabled!",
|
||||
"file_changed", "&cAccessing the jar file while %action%ing &4%what%&c went wrong, please load the plugin manually!",
|
||||
"update", Defaults.of(
|
||||
"available", "&8&m------------=&r&8[ &b&lServerUtils Update&r &8]&m=--------------\n"
|
||||
+ " &3Current version: &b%old%\n"
|
||||
+ " &3New version: &b%new%\n"
|
||||
+ " &3Release info: &b%info%\n"
|
||||
+ "&8&m-------------------------------------------------",
|
||||
"downloading", "&8&m------------=&r&8[ &b&lServerUtils Update&r &8]&m=--------------\n"
|
||||
+ " &3A new version of ServerUtils will be downloaded and installed after a restart!\n"
|
||||
+ " &3Current version: &b%old%\n"
|
||||
+ " &3New version: &b%new%\n"
|
||||
+ " &3Release info: &b%info%\n"
|
||||
+ "&8&m-------------------------------------------------",
|
||||
"download_failed", "&cFailed to download version %new% of ServerUtils. Please update manually.",
|
||||
"download_success", "&3ServerUtils has been downloaded and will be installed on the next restart."
|
||||
),
|
||||
"help", Defaults.of(
|
||||
"header", "&8&m-------------=&r&8[ &b&lServerUtils Help&r &8]&m=---------------",
|
||||
"format", "&8/&3%command%&b%subcommand% &f(&7%help%&f)",
|
||||
"footer", "&8&m-------------------------------------------------"
|
||||
),
|
||||
"plugins", Defaults.of(
|
||||
"header", "&8&m------------=&r&8[ &b&lServerUtils Plugins&r &8]&m=-------------",
|
||||
"format", "&3%plugin%",
|
||||
"seperator", "&b, ",
|
||||
"last_seperator", " &band ",
|
||||
"version", " &8(&a%version%&8)",
|
||||
"footer", "&8&m-------------------------------------------------"
|
||||
),
|
||||
"plugininfo", Defaults.of(
|
||||
"header", "&8&m-----------=&r&8[ &b&lServerUtils PluginInfo&r &8]&m=-----------",
|
||||
"format", " &3%key%&8: &b%value%",
|
||||
"list_format", "&b%value%",
|
||||
"seperator", "&8, ",
|
||||
"last_seperator", " &8and ",
|
||||
"footer", "&8&m-------------------------------------------------"
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
private static final ServerUtils plugin = ServerUtils.getInstance();
|
||||
private static Messenger instance;
|
||||
|
|
@ -52,19 +63,7 @@ public class Messenger {
|
|||
|
||||
public Messenger(File file) {
|
||||
instance = this;
|
||||
messages = YamlConfiguration.loadConfiguration(file);
|
||||
Defaults.addDefaults(DEFAULT_MESSAGES, messages);
|
||||
|
||||
try {
|
||||
// Idk somehow the order messes up
|
||||
// of the messages if we don't do this
|
||||
file.delete();
|
||||
file.createNewFile();
|
||||
|
||||
messages.save(file);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
messages = Defaults.init(file, DEFAULT_MESSAGES);
|
||||
}
|
||||
|
||||
public static String getMessage(String path, String... replacements) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue