diff --git a/build.gradle b/build.gradle index a80a77c6..decc730d 100644 --- a/build.gradle +++ b/build.gradle @@ -29,12 +29,10 @@ repositories { maven {url = 'https://dl.bintray.com/ichbinjoe/public/'} maven {url = 'https://repo.codemc.org/repository/maven-public/'} maven {url = 'https://repo.minebench.de/'} - maven {url = "https://repo.aikar.co/content/groups/aikar/"} maven {url = "https://raw.githubusercontent.com/JorelAli/CommandAPI/mvn-repo/"} } dependencies { - compile 'co.aikar:acf-bukkit:0.5.0-SNAPSHOT' compile 'net.kyori:adventure-api:4.0.0-SNAPSHOT' compile 'net.kyori:adventure-nbt:4.0.0-SNAPSHOT' compile 'net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT' diff --git a/src/main/java/net/draycia/carbon/commands/SpyChannelCommand.java b/src/main/java/net/draycia/carbon/commands/SpyChannelCommand.java index 0eb82867..00b702fb 100644 --- a/src/main/java/net/draycia/carbon/commands/SpyChannelCommand.java +++ b/src/main/java/net/draycia/carbon/commands/SpyChannelCommand.java @@ -3,6 +3,7 @@ package net.draycia.carbon.commands; import dev.jorel.commandapi.CommandAPICommand; import dev.jorel.commandapi.CommandPermission; import dev.jorel.commandapi.arguments.Argument; +import dev.jorel.commandapi.arguments.BooleanArgument; import dev.jorel.commandapi.arguments.LiteralArgument; import net.draycia.carbon.CarbonChat; import net.draycia.carbon.channels.ChatChannel; @@ -43,6 +44,17 @@ public class SpyChannelCommand { .withPermission(CommandPermission.fromString("carbonchat.spy")) .executesPlayer(this::executeWhispers) .register(); + + LinkedHashMap everythingArguments = new LinkedHashMap<>(); + everythingArguments.put("channel", new LiteralArgument("*")); + everythingArguments.put("should-spy", new BooleanArgument()); + + new CommandAPICommand(commandName) + .withArguments(everythingArguments) + .withAliases(commandAliases.toArray(new String[0])) + .withPermission(CommandPermission.fromString("carbonchat.spy")) + .executesPlayer(this::executeEverything) // lul + .register(); } private void execute(Player player, Object[] args) { @@ -81,4 +93,32 @@ public class SpyChannelCommand { user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n")); } + private void executeEverything(Player player, Object[] args) { + Boolean shouldSpy = (Boolean) args[0]; + + ChatUser user = carbonChat.getUserService().wrap(player); + + String message; + + if (shouldSpy) { + user.setSpyingWhispers(true); + + for (ChatChannel channel : carbonChat.getChannelManager().getRegistry().values()) { + user.getChannelSettings(channel).setSpying(true); + } + + message = carbonChat.getLanguage().getString("spy-everything-off"); + } else { + user.setSpyingWhispers(false); + + for (ChatChannel channel : carbonChat.getChannelManager().getRegistry().values()) { + user.getChannelSettings(channel).setSpying(false); + } + + message = carbonChat.getLanguage().getString("spy-everything-on"); + } + + user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n")); + } + } diff --git a/src/main/java/net/draycia/carbon/util/ThisOrThat.java b/src/main/java/net/draycia/carbon/util/ThisOrThat.java new file mode 100644 index 00000000..e3b66bf4 --- /dev/null +++ b/src/main/java/net/draycia/carbon/util/ThisOrThat.java @@ -0,0 +1,31 @@ +package net.draycia.carbon.util; + +import org.jetbrains.annotations.Nullable; + +public class ThisOrThat { + + @Nullable A objectA; + @Nullable B objectB; + + public ThisOrThat(@Nullable A objectA, @Nullable B objectB) { + this.objectA = objectA; + this.objectB = objectB; + } + + public boolean isThis() { + return objectA != null; + } + + public boolean isThat() { + return objectB != null; + } + + public @Nullable A getThis() { + return objectA; + } + + public @Nullable B getThat() { + return objectB; + } + +}