Initial commit

This commit is contained in:
mangorifo
2023-03-28 19:24:11 +08:00
commit a6af8fdae2
46 changed files with 2228 additions and 0 deletions
@@ -0,0 +1,41 @@
package cf.sobrooms.commands;
import cf.sobrooms.DiscordWebhook;
import cf.sobrooms.ServerUtils;
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
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) {
sender.sendMessage("Please input a message to send...");
return false;
} else {
sender.sendMessage("Sending public message to discord server...");
DiscordWebhook discordWebhook = new DiscordWebhook(ServerUtils.webhook_messages);
discordWebhook.setUsername("Public Messages");
String message = String.join(" ", args);
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject()
.setTitle("New public message")
.setDescription(message)
.setAuthor(sender.getName(), "", "")
.setFooter(new Date().toString(), "")
.setColor(Color.darkGray);
discordWebhook.addEmbed(embedObject);
try {
discordWebhook.execute();
sender.sendMessage("Sent public message.");
return true;
} catch (IOException e) {
sender.sendMessage("An error occurred while sending your message...");
throw new RuntimeException(e);
}
}
}
}