Skip to content

Commit

Permalink
Add quests debug command
Browse files Browse the repository at this point in the history
  • Loading branch information
LMBishop committed Jun 25, 2022
1 parent 4cf5e75 commit 2fa380b
Show file tree
Hide file tree
Showing 7 changed files with 441 additions and 25 deletions.
Expand Up @@ -24,22 +24,15 @@ public void setServerLoggingLevel(LoggingLevel serverLoggingLevel) {

@Override
public void log(String str, LoggingLevel level) {
plugin.getLogHistory().record(level, () -> str);
if (serverLoggingLevel.getNumericVerbosity() < level.getNumericVerbosity()) {
return;
}
switch (level) {
case DEBUG:
plugin.getLogger().info("Debug: " + str);
break;
case INFO:
plugin.getLogger().info(str);
break;
case ERROR:
plugin.getLogger().severe(str);
break;
case WARNING:
plugin.getLogger().warning(str);
break;
case DEBUG -> plugin.getLogger().info("DEBUG: " + str);
case INFO -> plugin.getLogger().info(str);
case ERROR -> plugin.getLogger().severe(str);
case WARNING -> plugin.getLogger().warning(str);
}
}

Expand Down
Expand Up @@ -33,6 +33,7 @@
import com.leonardobishop.quests.bukkit.tasktype.BukkitTaskTypeManager;
import com.leonardobishop.quests.bukkit.tasktype.type.*;
import com.leonardobishop.quests.bukkit.tasktype.type.dependent.*;
import com.leonardobishop.quests.bukkit.util.LogHistory;
import com.leonardobishop.quests.common.config.ConfigProblem;
import com.leonardobishop.quests.common.config.ConfigProblemDescriptions;
import com.leonardobishop.quests.common.config.QuestsConfig;
Expand Down Expand Up @@ -92,6 +93,7 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests {
private Title titleHandle;
private VersionSpecificHandler versionSpecificHandler;

private LogHistory logHistory;
private BukkitTask questAutoSaveTask;
private BukkitTask questQueuePollTask;
private BiFunction<Player, String, String> placeholderAPIProcessor;
Expand Down Expand Up @@ -150,6 +152,7 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests {
public void onEnable() {
// Initial module initialization
this.questsLogger = new BukkitQuestsLogger(this);
this.logHistory = new LogHistory(true);
this.generateConfigurations();
this.questsConfig = new BukkitQuestsConfig(new File(super.getDataFolder() + File.separator + "config.yml"));
this.questManager = new QuestManager(this);
Expand Down Expand Up @@ -602,6 +605,10 @@ public FileConfiguration getConfig() {
return questsConfig.getConfig();
}

public LogHistory getLogHistory() {
return logHistory;
}

@Override
public void reloadConfig() {
this.reloadBaseConfiguration();
Expand Down
Expand Up @@ -24,6 +24,7 @@ public AdminCommandSwitcher(BukkitQuestsPlugin plugin) {
super.subcommands.put("update", new AdminUpdateCommandHandler(plugin));
super.subcommands.put("wiki", new AdminWikiCommandHandler(plugin));
super.subcommands.put("about", new AdminAboutCommandHandler(plugin));
super.subcommands.put("debug", new AdminDebugCommandHandler(plugin));
}

@Override
Expand All @@ -42,6 +43,7 @@ public void showHelp(CommandSender sender) {
sender.sendMessage(ChatColor.DARK_GRAY + " * " + ChatColor.RED + "/quests a update " + ChatColor.DARK_GRAY + ": check for updates");
sender.sendMessage(ChatColor.DARK_GRAY + " * " + ChatColor.RED + "/quests a wiki " + ChatColor.DARK_GRAY + ": get a link to the Quests wiki");
sender.sendMessage(ChatColor.DARK_GRAY + " * " + ChatColor.RED + "/quests a about " + ChatColor.DARK_GRAY + ": get information about Quests");
sender.sendMessage(ChatColor.DARK_GRAY + " * " + ChatColor.RED + "/quests a debug " + ChatColor.DARK_GRAY + ": generate a debug report");
}

@Override
Expand Down

0 comments on commit 2fa380b

Please sign in to comment.