2020-07-29 17:31:54 +00:00
|
|
|
package xyz.etztech.minealert;
|
|
|
|
|
|
|
|
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
import xyz.etztech.minealert.commands.MainCommand;
|
2020-08-02 15:40:05 +00:00
|
|
|
import xyz.etztech.minealert.listeners.OreAlertListener;
|
2020-07-29 17:31:54 +00:00
|
|
|
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
|
|
public class MineAlert extends JavaPlugin {
|
|
|
|
|
2020-07-29 19:34:28 +00:00
|
|
|
private static MineAlert instance;
|
2020-07-29 17:31:54 +00:00
|
|
|
private final Logger log = Logger.getLogger( "Minecraft" );
|
|
|
|
|
|
|
|
public void onEnable() {
|
2020-07-29 19:34:28 +00:00
|
|
|
instance = this;
|
2020-07-29 17:31:54 +00:00
|
|
|
saveDefaultConfig();
|
|
|
|
reloadConfig();
|
|
|
|
|
|
|
|
if (isEnabled()) {
|
|
|
|
new MainCommand(this);
|
2020-08-02 15:40:05 +00:00
|
|
|
new OreAlertListener(this);
|
2020-07-29 17:31:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void log(String message) {
|
|
|
|
log.info( "[MineAlert]: " + message );
|
|
|
|
}
|
|
|
|
|
2020-07-29 19:34:28 +00:00
|
|
|
public static MineAlert getInstance() {
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
2020-07-29 17:31:54 +00:00
|
|
|
/**
|
|
|
|
* @param def The default if no paths resolve
|
|
|
|
* @param path Config paths to check, from specific -> fallback
|
|
|
|
* @return The resolved String value
|
|
|
|
*/
|
|
|
|
public String getConfigStringFallback(String def, String ...path) {
|
|
|
|
String fallback = "";
|
|
|
|
for (String p : path) {
|
|
|
|
fallback = getConfig().getString(p, fallback);
|
|
|
|
if (!"".equals(fallback)) {
|
|
|
|
return fallback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param def The default if no paths resolve
|
|
|
|
* @param path Config paths to check, from specific -> fallback
|
|
|
|
* @return The resolved Int value
|
|
|
|
*/
|
|
|
|
public int getConfigIntFallback(int def, String ...path) {
|
|
|
|
int fallback = 0;
|
|
|
|
for (String p : path) {
|
|
|
|
fallback = getConfig().getInt(p, fallback);
|
|
|
|
if (fallback != 0) {
|
|
|
|
return fallback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|