Initial commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package cf.sobrooms.commands;
|
||||
|
||||
import cf.sobrooms.Main;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.io.FileWriter;
|
||||
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 provide a boolean and make sure you only provided one argument. (true/false)");
|
||||
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 + "Please restart the server manually.");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user