mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 22:15:45 +00:00
Add spy-everything
This commit is contained in:
1 parent
d9ab3b3bdd
commit
e95d0eeae8
3 files changed
+71
-2
No files matched your search
@@ -29,12 +29,10 @@ repositories {
|
|||||||
maven {url = 'https://dl.bintray.com/ichbinjoe/public/'}
|
maven {url = 'https://dl.bintray.com/ichbinjoe/public/'}
|
||||||
maven {url = 'https://repo.codemc.org/repository/maven-public/'}
|
maven {url = 'https://repo.codemc.org/repository/maven-public/'}
|
||||||
maven {url = 'https://repo.minebench.de/'}
|
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/"}
|
maven {url = "https://raw.githubusercontent.com/JorelAli/CommandAPI/mvn-repo/"}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'co.aikar:acf-bukkit:0.5.0-SNAPSHOT'
|
|
||||||
compile 'net.kyori:adventure-api:4.0.0-SNAPSHOT'
|
compile 'net.kyori:adventure-api:4.0.0-SNAPSHOT'
|
||||||
compile 'net.kyori:adventure-nbt:4.0.0-SNAPSHOT'
|
compile 'net.kyori:adventure-nbt:4.0.0-SNAPSHOT'
|
||||||
compile 'net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT'
|
compile 'net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT'
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package net.draycia.carbon.commands;
|
|||||||
import dev.jorel.commandapi.CommandAPICommand;
|
import dev.jorel.commandapi.CommandAPICommand;
|
||||||
import dev.jorel.commandapi.CommandPermission;
|
import dev.jorel.commandapi.CommandPermission;
|
||||||
import dev.jorel.commandapi.arguments.Argument;
|
import dev.jorel.commandapi.arguments.Argument;
|
||||||
|
import dev.jorel.commandapi.arguments.BooleanArgument;
|
||||||
import dev.jorel.commandapi.arguments.LiteralArgument;
|
import dev.jorel.commandapi.arguments.LiteralArgument;
|
||||||
import net.draycia.carbon.CarbonChat;
|
import net.draycia.carbon.CarbonChat;
|
||||||
import net.draycia.carbon.channels.ChatChannel;
|
import net.draycia.carbon.channels.ChatChannel;
|
||||||
@@ -43,6 +44,17 @@ public class SpyChannelCommand {
|
|||||||
.withPermission(CommandPermission.fromString("carbonchat.spy"))
|
.withPermission(CommandPermission.fromString("carbonchat.spy"))
|
||||||
.executesPlayer(this::executeWhispers)
|
.executesPlayer(this::executeWhispers)
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
|
LinkedHashMap<String, Argument> 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) {
|
private void execute(Player player, Object[] args) {
|
||||||
@@ -81,4 +93,32 @@ public class SpyChannelCommand {
|
|||||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n"));
|
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"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package net.draycia.carbon.util;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class ThisOrThat<A, B> {
|
||||||
|
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in new issue
Block a user