Make set-greet-message require operator perms, remove System.out prints

This commit is contained in:
2026-01-17 12:18:22 +08:00
parent 6635b7aff4
commit 033e751c9a
12 changed files with 48 additions and 45 deletions
+2 -6
View File
@@ -9,8 +9,6 @@ import moe.sob.events.player.*;
import moe.sob.events.server.ServerLoad;
import moe.sob.events.world.WorldLoad;
import moe.sob.events.world.WorldUnload;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -21,8 +19,6 @@ import java.awt.*;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Date;
import java.util.Objects;
@@ -33,7 +29,7 @@ public class Main extends JavaPlugin {
public static File config;
public static FileConfiguration configR;
public static void main(String... args) {
System.out.printf("Initializing using server address: %s...%n", ServerUtils.address);
mainSmall.getLogger().info(String.format("Initializing using server address: %s...%n", ServerUtils.address));
}
@Override
public void onDisable() {
@@ -122,7 +118,7 @@ public class Main extends JavaPlugin {
}
} catch (Exception e) {
mainSmall.getLogger().warning("Invalid webhook URL provide for your public messages. Please provide the correct webhook and check for any typos. (Caught exception)");
System.out.printf("Exception: %s%n", e);
mainSmall.getLogger().severe(String.format("Exception: %s%n", e));
return false;
}
}
+3 -3
View File
@@ -19,7 +19,7 @@ public class ServerUtils {
Socket s = new Socket();
s.connect(new InetSocketAddress(serverAddress, Integer.parseInt(serverPort.toString())), 15);
s.close();
System.out.println("Server is online. Test notifying by sending a message to your webhook... (Pinged " + serverAddress + ":" + server.getPort() + ")");
Bukkit.getConsoleSender().sendMessage("Server is online. Test notifying by sending a message to your webhook... (Pinged " + serverAddress + ":" + server.getPort() + ")");
return true;
} catch (Exception e) {
System.out.println("Server is inactive. Pinging fallback address...");
@@ -28,10 +28,10 @@ public class ServerUtils {
Socket s = new Socket();
s.connect(new InetSocketAddress(address_fallback, Integer.parseInt(serverPort.toString())), 15);
s.close();
System.out.println("Server is online. Sending message to webhook_notify... (Pinged " + Utils.getServerHostPublicIP() + ":" + server.getPort() + ")");
Bukkit.getConsoleSender().sendMessage("Server is online. Sending message to webhook_notify... (Pinged " + Utils.getServerHostPublicIP() + ":" + server.getPort() + ")");
return true;
} catch (Exception err) {
System.out.println("Fallback address is inactive. No longer pinging...");
Bukkit.getConsoleSender().sendMessage("Fallback address is inactive. No longer pinging...");
}
return false;
}
@@ -7,9 +7,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import java.awt.*;
import java.io.IOException;
import java.util.Date;
public class SendMessageCommand implements CommandExecutor {
@Override
@@ -1,7 +1,6 @@
package moe.sob.commands;
import moe.sob.Main;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -1,7 +1,6 @@
package moe.sob.commands;
import moe.sob.Main;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
+3 -1
View File
@@ -17,13 +17,15 @@ commands:
description: Enables or disables event logging. Server performance is enhanced while logs are disabled. (Depending on server speed)
usage: /set-logging <true|false>
permission: op
permission-message: Only operators can use this command.
permission-message: Only server operators can use this command.
aliases: [sl]
ping-server:
description: Gets the server ping.
usage: /ping-server
aliases: [ping]
set-greet-message:
permission: op
permission-message: Only server operators can use this command.
description: Change the message sent to players whenever they join the server.
usage: /set-greet-message <msg>
aliases: [sgm]