dunno if it works
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cf.sobrooms.commands;
|
||||
|
||||
import cf.sobrooms.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -12,17 +13,24 @@ import java.io.IOException;
|
||||
public class SetLoggingModeCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args[0].isBlank()) {
|
||||
sender.sendMessage("Please only provide true or false.");
|
||||
sender.sendMessage("Please only provide true or false in the command arguments.");
|
||||
return false;
|
||||
} else {
|
||||
if (args[0].equals("true") || args[0].equals("false")) {
|
||||
try {
|
||||
|
||||
FileWriter writer = new FileWriter(Main.isLoggingConfig);
|
||||
writer.write(args[0]);
|
||||
writer.close();
|
||||
System.out.println("Wrote to config, closing writer...");
|
||||
sender.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Changes will only apply once the server has restarted.");
|
||||
sender.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Restart your server if you would like to apply the changes.");
|
||||
String status = "";
|
||||
if (args[0].equals("true"))
|
||||
status = "enabled";
|
||||
else if (args[0].equals("false"))
|
||||
status = "disabled";
|
||||
Bukkit.broadcastMessage(ChatColor.ITALIC + "%s %s server logging.".formatted(sender.getName(), status));
|
||||
Bukkit.broadcastMessage(ChatColor.ITALIC + "Changes will only apply once the server has restarted.");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user