From 8cd662280c577b83563e96afd6c1cfd3c2d9d319 Mon Sep 17 00:00:00 2001 From: 5vl Date: Tue, 12 Jan 2021 14:44:43 +0100 Subject: [PATCH] Added /discord --- java/coreplugin/coreplugin/Core.java | 4 +++- .../coreplugin/commands/discord.java | 21 +++++++++++++++++++ resources/config.yml | 1 + resources/plugin.yml | 4 +++- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 java/coreplugin/coreplugin/commands/discord.java diff --git a/java/coreplugin/coreplugin/Core.java b/java/coreplugin/coreplugin/Core.java index c3b3a50..cfc52ca 100644 --- a/java/coreplugin/coreplugin/Core.java +++ b/java/coreplugin/coreplugin/Core.java @@ -1,5 +1,6 @@ package coreplugin.coreplugin; +import coreplugin.coreplugin.commands.discord; import coreplugin.coreplugin.commands.fly; import coreplugin.coreplugin.commands.gamemodes.GMA; import coreplugin.coreplugin.commands.gamemodes.GMC; @@ -16,7 +17,7 @@ public final class Core extends JavaPlugin { private static Core instance; @Override public void onEnable() { - System.out.println("Core Plugin has been enabled."); + System.out.println("Enabed Core Plugin 1.0.0"); instance = this; this.getConfig().options().copyDefaults(); saveDefaultConfig(); @@ -36,5 +37,6 @@ public final class Core extends JavaPlugin { getCommand("kick").setExecutor(new kick()); getCommand("ban").setExecutor(new ban()); getCommand("unban").setExecutor(new unban()); + getCommand("discord").setExecutor(new discord()); } } \ No newline at end of file diff --git a/java/coreplugin/coreplugin/commands/discord.java b/java/coreplugin/coreplugin/commands/discord.java new file mode 100644 index 0000000..5463fd4 --- /dev/null +++ b/java/coreplugin/coreplugin/commands/discord.java @@ -0,0 +1,21 @@ +package coreplugin.coreplugin.commands; + +import coreplugin.coreplugin.Core; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class discord implements CommandExecutor { + private String color(String string) { + return ChatColor.translateAlternateColorCodes('&', string); + } + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + String Discord = Core.getInstance().getConfig().getString("Discord"); + Player p = (Player) sender; + p.sendMessage(color(Discord)); + return false; + } +} diff --git a/resources/config.yml b/resources/config.yml index f23a425..35c1e20 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -43,3 +43,4 @@ CannotFindPlayer: '&4Error: Cannot find the specified player.' MissingPermission: '&4&lYou do not have permission to execute this command!' Console: '&cYou can only run this command as a player.' InvalidArgument: '&4Error: Invalid argument.' +Discord: '&bhttps://discord.gg/YourDiscordLinkHere' # Please put in your discord link. \ No newline at end of file diff --git a/resources/plugin.yml b/resources/plugin.yml index e9d5751..15faaaa 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -22,4 +22,6 @@ commands: ban: description: You can ban people with this! unban: - description: You can unban people with this! \ No newline at end of file + description: You can unban people with this! + discord: + description: Send your discord link in chat! \ No newline at end of file