2025-10-15 21:12:07 +08:00
|
|
|
package moe.sob.commands;
|
2023-03-28 19:24:11 +08:00
|
|
|
|
2025-10-15 21:12:07 +08:00
|
|
|
import moe.sob.Main;
|
2023-03-28 19:24:11 +08:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
|
import org.bukkit.command.CommandExecutor;
|
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
|
|
|
|
|
|
public class SetLoggingModeCommand implements CommandExecutor {
|
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
|
|
|
if (args[0].isBlank()) {
|
2023-11-12 10:40:18 +08:00
|
|
|
sender.sendMessage("Please only provide true or false in the command arguments.");
|
2023-03-28 19:24:11 +08:00
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
if (args[0].equals("true") || args[0].equals("false")) {
|
|
|
|
|
try {
|
2025-10-15 21:12:07 +08:00
|
|
|
Main.configR.set("log", args[0].equals("true"));
|
|
|
|
|
Main.configR.save(Main.config);
|
2023-11-12 10:40:18 +08:00
|
|
|
String status = "";
|
|
|
|
|
if (args[0].equals("true"))
|
|
|
|
|
status = "enabled";
|
|
|
|
|
else if (args[0].equals("false"))
|
|
|
|
|
status = "disabled";
|
2025-10-15 21:12:07 +08:00
|
|
|
sender.sendMessage(ChatColor.ITALIC + "%s %s server logging.".formatted(sender.getName(), status));
|
|
|
|
|
sender.sendMessage(ChatColor.ITALIC + "Changes will only apply once the server has restarted.");
|
|
|
|
|
} catch (Exception e) {
|
2023-03-28 19:24:11 +08:00
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|