diff --git a/src/main/java/com/hackclub/hccore/HCCorePlugin.java b/src/main/java/com/hackclub/hccore/HCCorePlugin.java index f28fec6c..51b66bb2 100644 --- a/src/main/java/com/hackclub/hccore/HCCorePlugin.java +++ b/src/main/java/com/hackclub/hccore/HCCorePlugin.java @@ -8,6 +8,7 @@ import com.comphenix.protocol.events.ListenerPriority; import com.hackclub.hccore.commands.AFKCommand; import com.hackclub.hccore.commands.ColorCommand; +import com.hackclub.hccore.commands.DownvoteCommand; import com.hackclub.hccore.commands.LocCommand; import com.hackclub.hccore.commands.NickCommand; import com.hackclub.hccore.commands.PingCommand; @@ -15,6 +16,7 @@ import com.hackclub.hccore.commands.SpawnCommand; import com.hackclub.hccore.commands.StatsCommand; import com.hackclub.hccore.commands.TableflipCommand; +import com.hackclub.hccore.commands.UpvoteCommand; import com.hackclub.hccore.listeners.AFKListener; import com.hackclub.hccore.listeners.AdvancementListener; import com.hackclub.hccore.listeners.BeehiveInteractionListener; @@ -56,6 +58,7 @@ public void onEnable() { // Register commands this.getCommand("afk").setExecutor(new AFKCommand(this)); this.getCommand("color").setExecutor(new ColorCommand(this)); + this.getCommand("downvote").setExecutor(new DownvoteCommand(this)); this.getCommand("loc").setExecutor(new LocCommand(this)); this.getCommand("nick").setExecutor(new NickCommand(this)); this.getCommand("ping").setExecutor(new PingCommand(this)); @@ -63,6 +66,7 @@ public void onEnable() { this.getCommand("spawn").setExecutor(new SpawnCommand(this)); this.getCommand("stats").setExecutor(new StatsCommand(this)); this.getCommand("tableflip").setExecutor(new TableflipCommand(this)); + this.getCommand("upvote").setExecutor(new UpvoteCommand(this)); // Register event listeners this.getServer().getPluginManager().registerEvents(new AdvancementListener(this), this); diff --git a/src/main/java/com/hackclub/hccore/commands/DownvoteCommand.java b/src/main/java/com/hackclub/hccore/commands/DownvoteCommand.java new file mode 100644 index 00000000..30805708 --- /dev/null +++ b/src/main/java/com/hackclub/hccore/commands/DownvoteCommand.java @@ -0,0 +1,35 @@ +package com.hackclub.hccore.commands; + +import com.hackclub.hccore.HCCorePlugin; +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 DownvoteCommand implements CommandExecutor { + private static final String DOWNVOTE = ChatColor.AQUA + ChatColor.BOLD.toString() + "↓"; + + private final HCCorePlugin plugin; + + public DownvoteCommand(HCCorePlugin plugin) { + this.plugin = plugin; + } + + @Override + public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) { + if (!(sender instanceof Player)) { + sender.sendMessage(ChatColor.RED + "You must be a player to use this"); + return true; + } + + Player player = (Player) sender; + if (args.length == 0) { + player.chat(DownvoteCommand.DOWNVOTE); + } else { + player.chat(String.join(" ", args) + " " + DownvoteCommand.DOWNVOTE); + } + + return true; + } +} diff --git a/src/main/java/com/hackclub/hccore/commands/UpvoteCommand.java b/src/main/java/com/hackclub/hccore/commands/UpvoteCommand.java new file mode 100644 index 00000000..9b47c61a --- /dev/null +++ b/src/main/java/com/hackclub/hccore/commands/UpvoteCommand.java @@ -0,0 +1,35 @@ +package com.hackclub.hccore.commands; + +import com.hackclub.hccore.HCCorePlugin; +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 UpvoteCommand implements CommandExecutor { + private static final String UPVOTE = ChatColor.RED + ChatColor.BOLD.toString() + "↑"; + + private final HCCorePlugin plugin; + + public UpvoteCommand(HCCorePlugin plugin) { + this.plugin = plugin; + } + + @Override + public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) { + if (!(sender instanceof Player)) { + sender.sendMessage(ChatColor.RED + "You must be a player to use this"); + return true; + } + + Player player = (Player) sender; + if (args.length == 0) { + player.chat(UpvoteCommand.UPVOTE); + } else { + player.chat(String.join(" ", args) + " " + UpvoteCommand.UPVOTE); + } + + return true; + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 739b5312..2533e95a 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -11,6 +11,9 @@ commands: color: description: Sets your chat or name color usage: /color [color] + downvote: + description: Appends a downvote to your message + usage: /downvote [message] loc: description: Manage your saved locations usage: /loc [...args] @@ -32,3 +35,6 @@ commands: tableflip: description: Appends a tableflip to your message usage: /tableflip [message] + upvote: + description: Appends an upvote to your message + usage: /upvote [message]