MineAlert/src/main/java/xyz/etztech/minealert/MineAlert.java

67 lines
1.7 KiB
Java
Raw Normal View History

package xyz.etztech.minealert;
import org.bukkit.plugin.java.JavaPlugin;
import xyz.etztech.minealert.commands.MainCommand;
import xyz.etztech.minealert.listeners.BlockBreakListener;
import java.util.logging.Logger;
public class MineAlert extends JavaPlugin {
private static MineAlert instance;
private final Logger log = Logger.getLogger( "Minecraft" );
public void onEnable() {
instance = this;
saveDefaultConfig();
reloadConfig();
if (isEnabled()) {
new MainCommand(this);
new BlockBreakListener(this);
}
}
public void log(String message) {
log.info( "[MineAlert]: " + message );
}
public static MineAlert getInstance() {
return instance;
}
/**
* @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;
}
}