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