Add Spy command to toggle SocialSpy
This commit is contained in:
parent
c1a51dc803
commit
097541e86f
|
|
@ -239,9 +239,10 @@ public final class Config {
|
|||
}
|
||||
|
||||
public static String SERVERMUTEPERMISSION = "command.mute-server";
|
||||
|
||||
public static String SPYPERMISSION = "chat.socialspy";
|
||||
private static void permissions() {
|
||||
SERVERMUTEPERMISSION = getString("permissions.server-mute", SERVERMUTEPERMISSION);
|
||||
SPYPERMISSION = getString("permissions.server-mute", SPYPERMISSION);
|
||||
}
|
||||
|
||||
public static String IP = "0.0.0.0";
|
||||
|
|
|
|||
36
galaxy/src/main/java/com/alttd/chat/commands/Spy.java
Executable file
36
galaxy/src/main/java/com/alttd/chat/commands/Spy.java
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
package com.alttd.chat.commands;
|
||||
|
||||
import com.alttd.chat.ChatPlugin;
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import com.alttd.chat.util.Utility;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Spy implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) { // must be a player
|
||||
return true;
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UUID uuid = ((Player) sender).getUniqueId();
|
||||
Utility.flipPermission(uuid, Config.SPYPERMISSION);
|
||||
//Queries.setGlobalChatState(chatUser.isGcOn(), chatUser.getUuid());
|
||||
sender.sendMessage(MiniMessage.get().parse("You have turned spy " + (!Utility.hasPermission(uuid, Config.GCPERMISSION) ? "<green>on." : "<red>off."))); // TODO load from config and minimessage
|
||||
}
|
||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ public class ChatHandler {
|
|||
sendPrivateMessage(player, target, "privatemessage", component);
|
||||
Component spymessage = miniMessage.parse(Config.MESSAGESPY, templates);
|
||||
for(Player pl : Bukkit.getOnlinePlayers()) {
|
||||
if(pl.hasPermission("chat.social-spy") && !pl.equals(player) && !pl.getName().equalsIgnoreCase(target)) { // todo add a toggle for social spy
|
||||
if(pl.hasPermission(Config.SPYPERMISSION) && !pl.equals(player) && !pl.getName().equalsIgnoreCase(target)) { // todo add a toggle for social spy
|
||||
pl.sendMessage(spymessage);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,4 +24,6 @@ commands:
|
|||
unignore:
|
||||
permission: command.ignore
|
||||
muteserver:
|
||||
permission: command.mute-server
|
||||
permission: command.mute-server
|
||||
spy:
|
||||
permission: command.togglespy
|
||||
Loading…
Reference in New Issue
Block a user