Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added /upvote and /downvote #103

Merged
merged 11 commits into from
Jul 16, 2020
4 changes: 4 additions & 0 deletions src/main/java/com/hackclub/hccore/HCCorePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
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;
import com.hackclub.hccore.commands.ShrugCommand;
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;
Expand Down Expand Up @@ -56,13 +58,15 @@ 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));
this.getCommand("shrug").setExecutor(new ShrugCommand(this));
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);
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/com/hackclub/hccore/commands/DownvoteCommand.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
35 changes: 35 additions & 0 deletions src/main/java/com/hackclub/hccore/commands/UpvoteCommand.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
6 changes: 6 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ commands:
color:
description: Sets your chat or name color
usage: /color <chat|name> [color]
downvote:
description: Appends a downvote to your message
usage: /downvote [message]
loc:
description: Manage your saved locations
usage: /loc <del|get|list|rename|save|share> [...args]
Expand All @@ -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]