notify on /stop
This commit is contained in:
@@ -10,6 +10,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
|
||||
public class PlayerCommandPreprocess implements Listener {
|
||||
@@ -30,5 +31,21 @@ public class PlayerCommandPreprocess implements Listener {
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
// temp: log on /stop
|
||||
if (command[0].equals("/stop")) {
|
||||
DiscordWebhook ntf = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
|
||||
.setTitle("Server stopped")
|
||||
.setDescription("The server was stopped using the `/stop` command.")
|
||||
.addField("Date", "<t:%n:R>".formatted(new Timestamp(System.currentTimeMillis()).getTime()), true)
|
||||
.addField("Player name", player.getName(), true);
|
||||
ntf.addEmbed(embed);
|
||||
try {
|
||||
ntf.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user