From 5b5252382e8730f4cd3536528b15abd8c06261d7 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 11 Mar 2019 12:36:19 +0100 Subject: [PATCH] Converted, moved and deleted some commands Converted & noved: /u opme /yeehaw /u c Deleted: /u admin playerinfo /u admin updateplugin Also made the FunComponent more configurable Also removed old command registration, so some commands will stop working #85 --- .idea/ButtonChat.iml | 28 +++ .../java/buttondevteam/chat/PluginMain.java | 2 - .../chat/commands/ucmds/HelpCommand.java | 167 +++++++++--------- .../chat/commands/ucmds/OpmeCommand.java | 21 --- .../ucmds/admin/PlayerInfoCommand.java | 43 ----- .../commands/ucmds/admin/UpdatePlugin.java | 40 ----- .../ucmds => components/fun}/CCommand.java | 112 ++++++------ .../chat/components/fun/FunComponent.java | 51 ++++-- .../chat/components/fun/OpmeCommand.java | 18 ++ .../fun}/YeehawCommand.java | 58 +++--- 10 files changed, 246 insertions(+), 294 deletions(-) delete mode 100644 src/main/java/buttondevteam/chat/commands/ucmds/OpmeCommand.java delete mode 100644 src/main/java/buttondevteam/chat/commands/ucmds/admin/PlayerInfoCommand.java delete mode 100644 src/main/java/buttondevteam/chat/commands/ucmds/admin/UpdatePlugin.java rename src/main/java/buttondevteam/chat/{commands/ucmds => components/fun}/CCommand.java (61%) create mode 100644 src/main/java/buttondevteam/chat/components/fun/OpmeCommand.java rename src/main/java/buttondevteam/chat/{commands => components/fun}/YeehawCommand.java (61%) diff --git a/.idea/ButtonChat.iml b/.idea/ButtonChat.iml index 3d32cdf..73ae0d4 100644 --- a/.idea/ButtonChat.iml +++ b/.idea/ButtonChat.iml @@ -39,5 +39,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/buttondevteam/chat/PluginMain.java b/src/main/java/buttondevteam/chat/PluginMain.java index b623489..ebb699b 100644 --- a/src/main/java/buttondevteam/chat/PluginMain.java +++ b/src/main/java/buttondevteam/chat/PluginMain.java @@ -1,6 +1,5 @@ package buttondevteam.chat; -import buttondevteam.chat.commands.YeehawCommand; import buttondevteam.chat.components.announce.AnnouncerComponent; import buttondevteam.chat.components.appendext.AppendTextComponent; import buttondevteam.chat.components.flair.FlairComponent; @@ -49,7 +48,6 @@ public class PluginMain extends ButtonPlugin { // Translated to Java: 2015.07.15 TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this); TBMCCoreAPI.RegisterEventsForExceptions(new PlayerJoinLeaveListener(), this); - TBMCChatAPI.AddCommands(this, YeehawCommand.class); MainPlugin.Instance.setChatHandlerEnabled(false); //Disable Core chat handler Console = this.getServer().getConsoleSender(); diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/HelpCommand.java b/src/main/java/buttondevteam/chat/commands/ucmds/HelpCommand.java index 8be549e..a009485 100644 --- a/src/main/java/buttondevteam/chat/commands/ucmds/HelpCommand.java +++ b/src/main/java/buttondevteam/chat/commands/ucmds/HelpCommand.java @@ -1,84 +1,83 @@ -package buttondevteam.chat.commands.ucmds; - -import java.util.ArrayList; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import buttondevteam.chat.PluginMain; -import buttondevteam.lib.chat.CommandClass; -import buttondevteam.lib.chat.TBMCChatAPI; -import buttondevteam.lib.chat.TBMCCommandBase; - -@CommandClass(modOnly = false) -public final class HelpCommand extends UCommandBase { - - @Override - public String[] GetHelpText(String alias) { - return new String[] { "§6---- Help ----", "Prints out help messages for the TBMC plugins" }; - } - - @Override - public boolean OnCommand(CommandSender sender, String alias, String[] args) { - if (args.length == 0) { - sender.sendMessage(new String[] { "§6---- TBMC Help ----", "Do /u help for more info", - "Do /u help [subcommands] for more info about a command", "Topics:", - "commands: See all the commands from this plugin", - "chat: Shows some info about custom chat features", "colors: Shows Minecraft color codes" }); - return true; - } - if (args[0].equalsIgnoreCase("chat")) - sender.sendMessage(new String[] { "§6---- Chat features ----", - "- [g] Channel identifier: Click it to copy message", "-- [g]: Global chat (/g)", - "-- [TC] Town chat (/tc)", "-- [NC] Nation chat (/nc)", - "- Playernames: Hover over them to get some player info", - "-- Respect: This is the number of paid respects divided by eliglble deaths. This is a reference to CoD:AW's \"Press F to pay respects\"" }); - else if (args[0].equalsIgnoreCase("commands")) { - ArrayList text = new ArrayList(); - text.add("§6---- Command list ----"); - for (TBMCCommandBase cmd : TBMCChatAPI.GetCommands().values()) - if (!cmd.getClass().getAnnotation(CommandClass.class).modOnly() || PluginMain.permission.has(sender, "tbmc.admin")) - if (!cmd.isPlayerOnly() || sender instanceof Player) - if (!cmd.GetCommandPath().contains(" ")) - text.add("/" + cmd.GetCommandPath()); - else { - final String topcmd = cmd.GetCommandPath().substring(0, cmd.GetCommandPath().indexOf(' ')); - if (!text.contains("/" + topcmd)) - text.add("/" + topcmd); - } - sender.sendMessage(text.toArray(new String[text.size()])); - } else if (args[0].equalsIgnoreCase("colors")) { - sender.sendMessage(new String[] { "§6---- Chat colors/formats ----", // - "Tellraw name - Code | Tellraw name - Code", // - "§0black - &0 | §1dark_blue - &1", // - "§2dark_green - &2 | §3dark_aqua - &3", // - "§4dark_red - &4 | §5dark_purple - &5", // - "§6gold - &6 | §7gray - &7", // - "§8dark_gray - &8 | §9blue - &9", // - "§agreen - &a | §baqua - &b", // - "§cred - &c | §dlight_purple - &d", // - "§eyellow - &e | §fwhite - &f", // - "§rreset - &r | §kk§robfuscated - &k", // - "§lbold - &l | §mstrikethrough - &m", // - "§nunderline - &n | §oitalic - &o", // - "The format codes in tellraw should be used like \"italic\":\"true\"" }); // - } else { - String path = args[0]; - for (int i = 1; i < args.length; i++) - path += " " + args[i]; - TBMCCommandBase cmd = TBMCChatAPI.GetCommands().get(path); - if (cmd == null) { - String[] subcmds = TBMCChatAPI.GetSubCommands(path, sender); - if (subcmds.length > 0) - sender.sendMessage(subcmds); - else - sender.sendMessage( - new String[] { "§cError: Command not found or you don't have permission for it: " + path, - "Usage example: /u accept --> /u help u accept" }); - } else - sender.sendMessage(cmd.GetHelpText(args[0])); - } - return true; - - } -} +package buttondevteam.chat.commands.ucmds; + +import buttondevteam.chat.PluginMain; +import buttondevteam.lib.chat.CommandClass; +import buttondevteam.lib.chat.TBMCChatAPI; +import buttondevteam.lib.chat.TBMCCommandBase; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.ArrayList; + +@CommandClass(modOnly = false) +public final class HelpCommand extends UCommandBase { + + @Override + public String[] GetHelpText(String alias) { + return new String[] { "§6---- Help ----", "Prints out help messages for the TBMC plugins" }; + } + + @Override + public boolean OnCommand(CommandSender sender, String alias, String[] args) { + if (args.length == 0) { + sender.sendMessage(new String[] { "§6---- TBMC Help ----", "Do /u help for more info", + "Do /u help [subcommands] for more info about a command", "Topics:", + "commands: See all the commands from this plugin", + "chat: Shows some info about custom chat features", "colors: Shows Minecraft color codes" }); + return true; + } + if (args[0].equalsIgnoreCase("chat")) + sender.sendMessage(new String[] { "§6---- Chat features ----", + "- [g] Channel identifier: Click it to copy message", "-- [g]: Global chat (/g)", + "-- [TC] Town chat (/tc)", "-- [NC] Nation chat (/nc)", + "- Playernames: Hover over them to get some player info", + "-- Respect: This is the number of paid respects divided by eliglble deaths. This is a reference to CoD:AW's \"Press F to pay respects\"" }); + else if (args[0].equalsIgnoreCase("commands")) { + ArrayList text = new ArrayList(); + text.add("§6---- Command list ----"); + for (TBMCCommandBase cmd : TBMCChatAPI.GetCommands().values()) + if (!cmd.getClass().getAnnotation(CommandClass.class).modOnly() || PluginMain.permission.has(sender, "tbmc.admin")) + if (!cmd.isPlayerOnly() || sender instanceof Player) + if (!cmd.GetCommandPath().contains(" ")) + text.add("/" + cmd.GetCommandPath()); + else { + final String topcmd = cmd.GetCommandPath().substring(0, cmd.GetCommandPath().indexOf(' ')); + if (!text.contains("/" + topcmd)) + text.add("/" + topcmd); + } + sender.sendMessage(text.toArray(new String[0])); + } else if (args[0].equalsIgnoreCase("colors")) { + sender.sendMessage(new String[] { "§6---- Chat colors/formats ----", // + "Tellraw name - Code | Tellraw name - Code", // + "§0black - &0 | §1dark_blue - &1", // + "§2dark_green - &2 | §3dark_aqua - &3", // + "§4dark_red - &4 | §5dark_purple - &5", // + "§6gold - &6 | §7gray - &7", // + "§8dark_gray - &8 | §9blue - &9", // + "§agreen - &a | §baqua - &b", // + "§cred - &c | §dlight_purple - &d", // + "§eyellow - &e | §fwhite - &f", // + "§rreset - &r | §kk§robfuscated - &k", // + "§lbold - &l | §mstrikethrough - &m", // + "§nunderline - &n | §oitalic - &o", // + "The format codes in tellraw should be used like \"italic\":\"true\"" }); // + } else { + String path = args[0]; + for (int i = 1; i < args.length; i++) + path += " " + args[i]; + TBMCCommandBase cmd = TBMCChatAPI.GetCommands().get(path); + if (cmd == null) { + String[] subcmds = TBMCChatAPI.GetSubCommands(path, sender); + if (subcmds.length > 0) + sender.sendMessage(subcmds); + else + sender.sendMessage( + new String[] { "§cError: Command not found or you don't have permission for it: " + path, + "Usage example: /u accept --> /u help u accept" }); + } else + sender.sendMessage(cmd.GetHelpText(args[0])); + } + return true; + + } +} diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/OpmeCommand.java b/src/main/java/buttondevteam/chat/commands/ucmds/OpmeCommand.java deleted file mode 100644 index adc2096..0000000 --- a/src/main/java/buttondevteam/chat/commands/ucmds/OpmeCommand.java +++ /dev/null @@ -1,21 +0,0 @@ -package buttondevteam.chat.commands.ucmds; - -import org.bukkit.command.CommandSender; - -import buttondevteam.lib.chat.CommandClass; - -@CommandClass(modOnly = false) -public class OpmeCommand extends UCommandBase { - - @Override - public String[] GetHelpText(String alias) { - return new String[] { "§6---- OP me ----", "Totally makes you OP" }; - } - - @Override - public boolean OnCommand(CommandSender sender, String alias, String[] args) { - sender.sendMessage("It would be nice, wouldn't it?"); - return true; - } - -} diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/admin/PlayerInfoCommand.java b/src/main/java/buttondevteam/chat/commands/ucmds/admin/PlayerInfoCommand.java deleted file mode 100644 index 241c0a1..0000000 --- a/src/main/java/buttondevteam/chat/commands/ucmds/admin/PlayerInfoCommand.java +++ /dev/null @@ -1,43 +0,0 @@ -package buttondevteam.chat.commands.ucmds.admin; - -import org.bukkit.command.CommandSender; - -import buttondevteam.chat.ChatPlayer; -import buttondevteam.lib.player.TBMCPlayerBase; - -public class PlayerInfoCommand extends AdminCommandBase { - - @Override - public String[] GetHelpText(String alias) { - return new String[] { "§6---- Player info ----", - "Shows some info about the player's flair, Reddit username(s) and other data known by the plugin", - "Usage: /u admin playerinfo " }; - } - - @Override - public boolean OnCommand(CommandSender sender, String alias, String[] args) { - if (args.length == 0) { - return false; - } - ChatPlayer p = TBMCPlayerBase.getFromName(args[0], ChatPlayer.class); - if (p == null) { - sender.sendMessage("§cPlayer not found: " + args[0] + "§r"); - return true; - } - StringBuilder sb = new StringBuilder(); - sb.append("§6Usernames:"); - for (String username : p.UserNames()) - sb.append(" ").append(username); - sender.sendMessage(new String[] { // - "Player name: " + p.PlayerName(), // - "User flair: " + p.GetFormattedFlair(), // - "Username: " + p.UserName(), // - "Flair state: " + p.FlairState(), // - sb.toString(), // - "FCount: " + p.FCount(), // - "FDeaths: " + p.FDeaths() // - }); - return true; - } - -} diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/admin/UpdatePlugin.java b/src/main/java/buttondevteam/chat/commands/ucmds/admin/UpdatePlugin.java deleted file mode 100644 index d78379d..0000000 --- a/src/main/java/buttondevteam/chat/commands/ucmds/admin/UpdatePlugin.java +++ /dev/null @@ -1,40 +0,0 @@ -package buttondevteam.chat.commands.ucmds.admin; - -import buttondevteam.chat.PluginMain; -import buttondevteam.core.component.updater.PluginUpdater; -import buttondevteam.lib.TBMCCoreAPI; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; - -public class UpdatePlugin extends AdminCommandBase { - - @Override - public String[] GetHelpText(String alias) { - return new String[] { // - "§6---- Update plugin ----", // - "This command downloads the latest version of a TBMC plugin from GitHub", // - "To update a plugin: /" + alias + " ", // - "To list the plugin names: /" + alias // - }; - } - - @Override - public boolean OnCommand(CommandSender sender, String alias, String[] args) { - Bukkit.getScheduler().runTaskAsynchronously(PluginMain.Instance, () -> { - if (args.length == 0) { - sender.sendMessage("Downloading plugin names..."); - boolean first = true; - for (String plugin : PluginUpdater.GetPluginNames()) { - if (first) { - sender.sendMessage("§6---- Plugin names ----"); - first = false; - } - sender.sendMessage("- " + plugin); - } - } else - TBMCCoreAPI.UpdatePlugin(args[0], sender, args.length == 1 ? "master" : args[1]); - }); - return true; - } - -} diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/CCommand.java b/src/main/java/buttondevteam/chat/components/fun/CCommand.java similarity index 61% rename from src/main/java/buttondevteam/chat/commands/ucmds/CCommand.java rename to src/main/java/buttondevteam/chat/components/fun/CCommand.java index 1a61844..0b8c55f 100644 --- a/src/main/java/buttondevteam/chat/commands/ucmds/CCommand.java +++ b/src/main/java/buttondevteam/chat/components/fun/CCommand.java @@ -1,59 +1,53 @@ -package buttondevteam.chat.commands.ucmds; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import buttondevteam.chat.ChatPlayer; -import buttondevteam.chat.PluginMain; -import buttondevteam.lib.chat.*; -import buttondevteam.lib.player.TBMCPlayer; - -@CommandClass(modOnly = false) -@OptionallyPlayerCommandClass(playerOnly = true) -public class CCommand extends UCommandBase { - - @Override - public String[] GetHelpText(String alias) { - return new String[] { "§6---- Rainbow mode ----", "This command allows you to talk in rainbow colors", - "You need to be a donator or a mod to use this command" }; - } - - @Override - public boolean OnCommand(CommandSender sender, String alias, String[] args) { - Player player = (Player) sender; - ChatPlayer p = TBMCPlayer.getPlayer(player.getUniqueId(), ChatPlayer.class); - if (args.length < 1) { - if (PluginMain.permission.has(player, "tbmc.rainbow")) { - p.RainbowPresserColorMode = !p.RainbowPresserColorMode; - p.OtherColorMode = null; - if (p.RainbowPresserColorMode) - player.sendMessage("§eRainbow colors §aenabled."); - else - player.sendMessage("§eRainbow colors §cdisabled."); - } else { - player.sendMessage("§cYou don't have permission for this command. Donate to get it!"); - return true; - } - } else { - if (PluginMain.permission.has(player, "tbmc.admin")) { - p.RainbowPresserColorMode = false; - p.OtherColorMode = null; - try { - p.OtherColorMode = Color.valueOf(args[0].toLowerCase()); - } catch (Exception e) { - player.sendMessage("§cUnknown message color: " + args[0]); - player.sendMessage("§cUse color names, like blue, or dark_aqua"); - } - if (p.OtherColorMode != null) - player.sendMessage(String.format("§eMessage color set to %s", p.OtherColorMode)); - else - player.sendMessage("§eMessage color reset."); - } else { - player.sendMessage("§cYou don't have permission for this command."); - return true; - } - } - return true; - } - -} +package buttondevteam.chat.components.fun; + +import buttondevteam.chat.ChatPlayer; +import buttondevteam.chat.PluginMain; +import buttondevteam.lib.chat.*; +import buttondevteam.lib.player.TBMCPlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandClass(path = "u c", helpText = { + "Rainbow mode", + "This command allows you to talk in rainbow colors" +}) +@OptionallyPlayerCommandClass(playerOnly = true) +public class CCommand extends ICommand2MC { + @Command2.Subcommand + public boolean def(CommandSender sender, @Command2.OptionalArg String color) { + Player player = (Player) sender; + ChatPlayer p = TBMCPlayer.getPlayer(player.getUniqueId(), ChatPlayer.class); + if (color == null) { + if (PluginMain.permission.has(player, "thorpe.color.rainbow")) { + p.RainbowPresserColorMode = !p.RainbowPresserColorMode; + p.OtherColorMode = null; + if (p.RainbowPresserColorMode) + player.sendMessage("§eRainbow colors §aenabled."); + else + player.sendMessage("§eRainbow colors §cdisabled."); + } else { + player.sendMessage("§cYou don't have permission for this command."); + return true; + } + } else { + if (PluginMain.permission.has(player, "thorpe.color.custom")) { + p.RainbowPresserColorMode = false; + p.OtherColorMode = null; + try { + p.OtherColorMode = Color.valueOf(color.toLowerCase()); + } catch (Exception e) { + player.sendMessage("§cUnknown message color: " + color); + player.sendMessage("§cUse color names, like blue, or dark_aqua"); + } + if (p.OtherColorMode != null) + player.sendMessage(String.format("§eMessage color set to %s", p.OtherColorMode)); + else + player.sendMessage("§eMessage color reset."); + } else { + player.sendMessage("§cYou don't have permission for this command."); + return true; + } + } + return true; + } +} diff --git a/src/main/java/buttondevteam/chat/components/fun/FunComponent.java b/src/main/java/buttondevteam/chat/components/fun/FunComponent.java index c11a84a..4b726b8 100644 --- a/src/main/java/buttondevteam/chat/components/fun/FunComponent.java +++ b/src/main/java/buttondevteam/chat/components/fun/FunComponent.java @@ -8,6 +8,7 @@ import buttondevteam.lib.TBMCCommandPreprocessEvent; import buttondevteam.lib.TBMCSystemChatEvent; import buttondevteam.lib.ThorpeUtils; import buttondevteam.lib.architecture.Component; +import buttondevteam.lib.architecture.ConfigData; import buttondevteam.lib.chat.TBMCChatAPI; import buttondevteam.lib.player.ChromaGamerBase; import buttondevteam.lib.player.TBMCPlayer; @@ -29,7 +30,6 @@ import java.util.ArrayList; import java.util.Random; public class FunComponent extends Component implements Listener { - private final static String[] LaughStrings = new String[]{"xd", "lel", "lawl", "kek", "lmao", "hue", "hah", "rofl"}; private boolean ActiveF = false; private ChatPlayer FPlayer = null; private BukkitTask Ftask = null; @@ -37,6 +37,19 @@ public class FunComponent extends Component implements Listener { private UnlolCommand command; private TBMCSystemChatEvent.BroadcastTarget unlolTarget; private TBMCSystemChatEvent.BroadcastTarget fTarget; + + private ConfigData laughStrings() { + return getConfig().getData("laughStrings", () -> new String[]{"xd", "lel", "lawl", "kek", "lmao", "hue", "hah", "rofl"}); + } + + private ConfigData respect() { + return getConfig().getData("respect", true); + } + + private ConfigData unlol() { + return getConfig().getData("unlol", true); + } + @Override protected void enable() { unlolTarget = TBMCSystemChatEvent.BroadcastTarget.add("unlol"); @@ -47,6 +60,9 @@ public class FunComponent extends Component implements Listener { registerCommand(command=new UnlolCommand(unlolTarget)); registerListener(this); registerCommand(new FTopCommand()); + registerCommand(new OpmeCommand()); + registerCommand(new YeehawCommand()); + registerCommand(new CCommand()); } @Override @@ -58,27 +74,30 @@ public class FunComponent extends Component implements Listener { if (ActiveF && !Fs.contains(sender) && message.equalsIgnoreCase("F")) Fs.add(sender); - String msg = message.toLowerCase(); - val lld = new UnlolCommand.LastlolData(sender, event, System.nanoTime()); - boolean add; - if (add = msg.contains("lol")) - lld.setLolornot(true); - else { - for (int i = 0; i < LaughStrings.length; i++) { - if (add = msg.contains(LaughStrings[i])) { - lld.setLolornot(false); - break; + if (unlol().get()) { + String msg = message.toLowerCase(); + val lld = new UnlolCommand.LastlolData(sender, event, System.nanoTime()); + boolean add; + if (add = msg.contains("lol")) + lld.setLolornot(true); + else { + String[] laughs = laughStrings().get(); + for (String laugh : laughs) { + if (add = msg.contains(laugh)) { + lld.setLolornot(false); + break; + } } } + if (add) + command.Lastlol.put(event.getChannel(), lld); } - if (add) - command.Lastlol.put(event.getChannel(), lld); } @EventHandler public void onPlayerDeath(PlayerDeathEvent e) { // MinigamePlayer mgp = Minigames.plugin.pdata.getMinigamePlayer(e.getEntity()); - if (/* (mgp != null && !mgp.isInMinigame()) && */ new Random().nextBoolean()) { // Don't store Fs for NPCs + if (e.getDeathMessage().length() > 0 && respect().get() && new Random().nextBoolean()) { // Don't store Fs for NPCs Runnable tt = () -> { if (ActiveF) { ActiveF = false; @@ -105,12 +124,14 @@ public class FunComponent extends Component implements Listener { } @EventHandler public void onPlayerLeave(PlayerQuitEvent event) { - command.Lastlol.values().removeIf(lld -> lld.getLolowner().equals(event.getPlayer())); + if (unlol().get()) + command.Lastlol.values().removeIf(lld -> lld.getLolowner().equals(event.getPlayer())); } @EventHandler(priority = EventPriority.LOWEST) public void onCommandPreprocess(TBMCCommandPreprocessEvent event) { if (event.isCancelled()) return; + if (!unlol().get()) return; final String cmd = event.getMessage(); // We don't care if we have arguments if (cmd.toLowerCase().startsWith("/un")) { diff --git a/src/main/java/buttondevteam/chat/components/fun/OpmeCommand.java b/src/main/java/buttondevteam/chat/components/fun/OpmeCommand.java new file mode 100644 index 0000000..bbae171 --- /dev/null +++ b/src/main/java/buttondevteam/chat/components/fun/OpmeCommand.java @@ -0,0 +1,18 @@ +package buttondevteam.chat.components.fun; + +import buttondevteam.lib.chat.Command2; +import buttondevteam.lib.chat.CommandClass; +import buttondevteam.lib.chat.ICommand2MC; +import org.bukkit.command.CommandSender; + +@CommandClass(modOnly = false, path = "u opme", helpText = { + "OP me", + "Totally makes you OP" +}) +public class OpmeCommand extends ICommand2MC { + @Command2.Subcommand + public boolean def(CommandSender sender) { + sender.sendMessage("It would be nice, wouldn't it?"); + return true; + } +} diff --git a/src/main/java/buttondevteam/chat/commands/YeehawCommand.java b/src/main/java/buttondevteam/chat/components/fun/YeehawCommand.java similarity index 61% rename from src/main/java/buttondevteam/chat/commands/YeehawCommand.java rename to src/main/java/buttondevteam/chat/components/fun/YeehawCommand.java index ba42373..56ac4e9 100644 --- a/src/main/java/buttondevteam/chat/commands/YeehawCommand.java +++ b/src/main/java/buttondevteam/chat/components/fun/YeehawCommand.java @@ -1,30 +1,28 @@ -package buttondevteam.chat.commands; - -import buttondevteam.lib.chat.CommandClass; -import buttondevteam.lib.chat.TBMCCommandBase; -import buttondevteam.lib.player.TBMCYEEHAWEvent; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -@CommandClass(modOnly = false) -public class YeehawCommand extends TBMCCommandBase { - - @Override - public String[] GetHelpText(String alias) { - return new String[] { "§6---- YEEHAW command ----", "This command makes you YEEHAW." }; - } - - @Override - public boolean OnCommand(CommandSender sender, String alias, String[] args) { - final String message = "§b* " - + (sender instanceof Player ? ((Player) sender).getDisplayName() : sender.getName()) + " §bYEEHAWs."; - for (Player p : Bukkit.getOnlinePlayers()) { - p.playSound(p.getLocation(), "tbmc.yeehaw", 1f, 1f); - p.sendMessage(message); //Not broadcasting, so the Discord plugin can handle the event in a special way - } // Even a cmdblock could yeehaw in theory - // Or anyone from Discord - Bukkit.getPluginManager().callEvent(new TBMCYEEHAWEvent(sender)); - return true; - } -} +package buttondevteam.chat.components.fun; + +import buttondevteam.lib.chat.Command2; +import buttondevteam.lib.chat.CommandClass; +import buttondevteam.lib.chat.ICommand2MC; +import buttondevteam.lib.player.TBMCYEEHAWEvent; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandClass(modOnly = false, helpText = { + "YEEHAW command", + "This command makes you YEEHAW." +}) +public class YeehawCommand extends ICommand2MC { + @Command2.Subcommand + public boolean def(CommandSender sender) { + final String message = "§b* " + + (sender instanceof Player ? ((Player) sender).getDisplayName() : sender.getName()) + " §bYEEHAWs."; + for (Player p : Bukkit.getOnlinePlayers()) { + p.playSound(p.getLocation(), "tbmc.yeehaw", 1f, 1f); + p.sendMessage(message); //Not broadcasting, so the Discord plugin can handle the event in a special way + } // Even a cmdblock could yeehaw in theory + // Or anyone from Discord + Bukkit.getPluginManager().callEvent(new TBMCYEEHAWEvent(sender)); + return true; + } +}