mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 08:25:31 +00:00
Add new debug options to plugin config
This commit is contained in:
parent
9ea8dc7eee
commit
f7ea81cb51
@ -31,8 +31,6 @@ public interface TerraPlugin extends LoaderRegistrar {
|
||||
|
||||
File getDataFolder();
|
||||
|
||||
boolean isDebug();
|
||||
|
||||
Language getLanguage();
|
||||
|
||||
CheckedRegistry<ConfigPack> getConfigRegistry();
|
||||
|
@ -55,8 +55,8 @@ public class TerraCommandManager implements CommandManager {
|
||||
private void execute(CommandHolder commandHolder, CommandSender sender, List<String> args) throws CommandException {
|
||||
Class<? extends CommandTemplate> commandClass = commandHolder.clazz;
|
||||
|
||||
if(commandClass.isAnnotationPresent(DebugCommand.class) && !main.isDebug()) {
|
||||
sender.sendMessage("Command must be executed with debug mode enabled.");
|
||||
if(commandClass.isAnnotationPresent(DebugCommand.class) && !main.getTerraConfig().isDebugCommands()) {
|
||||
sender.sendMessage("Command must be executed with debug commands enabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,21 @@ import java.util.jar.JarFile;
|
||||
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
public class PluginConfig implements ConfigTemplate {
|
||||
@Value("debug")
|
||||
@Value("debug.commands")
|
||||
@Default
|
||||
private boolean debug = false;
|
||||
private boolean debugCommands = false;
|
||||
|
||||
@Value("debug.log")
|
||||
@Default
|
||||
private boolean debugLog = false;
|
||||
|
||||
@Value("debug.profiler")
|
||||
@Default
|
||||
private boolean debugProfiler = false;
|
||||
|
||||
@Value("debug.script")
|
||||
@Default
|
||||
private boolean debugScript = false;
|
||||
|
||||
@Value("language")
|
||||
@Default
|
||||
@ -80,15 +92,31 @@ public class PluginConfig implements ConfigTemplate {
|
||||
} catch(ConfigException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.info("DebugLogger: " + isDebug());
|
||||
|
||||
if(isDebugCommands()) logger.info("Debug commands enabled.");
|
||||
if(isDebugLogging()) logger.info("Debug logging enabled.");
|
||||
if(isDebugProfiler()) logger.info("Debug profiler enabled.");
|
||||
if(isDebugScript()) logger.info("Script debug blocks enabled.");
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
public boolean isDebugCommands() {
|
||||
return debugCommands;
|
||||
}
|
||||
|
||||
public boolean isDebugLogging() {
|
||||
return debugLog;
|
||||
}
|
||||
|
||||
public boolean isDebugProfiler() {
|
||||
return debugProfiler;
|
||||
}
|
||||
|
||||
public boolean isDebugScript() {
|
||||
return debugScript;
|
||||
}
|
||||
|
||||
public long getDataSaveInterval() {
|
||||
|
@ -1,4 +1,8 @@
|
||||
debug: false
|
||||
debug:
|
||||
commands: false
|
||||
log: false
|
||||
profiler: false
|
||||
script: false
|
||||
data-save: PT6M
|
||||
language: "en_us"
|
||||
dump-default: true
|
||||
|
@ -171,7 +171,9 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
|
||||
|
||||
config.load(this); // Load master config.yml
|
||||
LangUtil.load(config.getLanguage(), this); // Load language.
|
||||
debugLogger.setDebug(isDebug());
|
||||
|
||||
debugLogger.setDebug(config.isDebugLogging());
|
||||
if(config.isDebugProfiler()) profiler.start();
|
||||
|
||||
if(!addonRegistry.loadAll()) {
|
||||
getLogger().severe("Failed to load addons. Please correct addon installations to continue.");
|
||||
@ -253,12 +255,6 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug() {
|
||||
return config.isDebug();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Language getLanguage() {
|
||||
return LangUtil.getLanguage();
|
||||
|
@ -177,11 +177,6 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
return dataFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Language getLanguage() {
|
||||
return LangUtil.getLanguage();
|
||||
@ -303,6 +298,9 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
LangUtil.load(config.getLanguage(), this);
|
||||
logger.info("Initializing Terra...");
|
||||
|
||||
debugLogger.setDebug(config.isDebugLogging());
|
||||
if(config.isDebugProfiler()) profiler.start();
|
||||
|
||||
if(!addonRegistry.loadAll()) {
|
||||
throw new IllegalStateException("Failed to load addons. Please correct addon installations to continue.");
|
||||
}
|
||||
|
@ -68,11 +68,6 @@ public class StandalonePlugin implements TerraPlugin {
|
||||
return new File(".");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Language getLanguage() {
|
||||
try {
|
||||
|
@ -86,11 +86,6 @@ public class TerraSpongePlugin implements TerraPlugin {
|
||||
return privateConfigDir.toFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Language getLanguage() {
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user