CommandSpy now works with permissions

This commit is contained in:
Telesphoreo 2022-05-25 22:16:31 -05:00
parent 97117c0e97
commit d785ef31c8

View File

@ -24,7 +24,7 @@ public class CommandListener extends PlexListener
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{ {
Bukkit.getOnlinePlayers().stream().filter(pl -> plugin.getPlayerCache().getPlexPlayer(pl.getUniqueId()).isCommandSpy() && plugin.getPlayerCache().getPlexPlayer(pl.getUniqueId()).isAdminActive()).forEach(pl -> Bukkit.getOnlinePlayers().stream().filter(pl -> plugin.getPlayerCache().getPlexPlayer(pl.getUniqueId()).isCommandSpy() && hasCommandSpy(plugin.getPlayerCache().getPlexPlayer(pl.getUniqueId()))).forEach(pl ->
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
String command = event.getMessage(); String command = event.getMessage();
@ -127,6 +127,18 @@ public class CommandListener extends PlexListener
} }
} }
} }
}
private boolean hasCommandSpy(PlexPlayer plexPlayer)
{
if (plugin.getSystem().equalsIgnoreCase("ranks"))
{
return plexPlayer.isAdminActive();
}
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{
return plexPlayer.getPlayer().hasPermission("plex.commandspy");
}
return false;
} }
} }