mirror of
https://github.com/songoda/UltimateModeration.git
synced 2025-01-31 11:41:27 +01:00
Added CommandSpy
This commit is contained in:
parent
89212cdaba
commit
322d9b371f
@ -35,6 +35,7 @@ public class CommandManager implements CommandExecutor {
|
|||||||
instance.getCommand("Freeze").setExecutor(this);
|
instance.getCommand("Freeze").setExecutor(this);
|
||||||
instance.getCommand("Revive").setExecutor(this);
|
instance.getCommand("Revive").setExecutor(this);
|
||||||
instance.getCommand("Spy").setExecutor(this);
|
instance.getCommand("Spy").setExecutor(this);
|
||||||
|
instance.getCommand("CommandSpy").setExecutor(this);
|
||||||
|
|
||||||
AbstractCommand commandUltimateModeration = addCommand(new CommandUltimateModeration());
|
AbstractCommand commandUltimateModeration = addCommand(new CommandUltimateModeration());
|
||||||
addCommand(new CommandClearChat());
|
addCommand(new CommandClearChat());
|
||||||
@ -46,6 +47,7 @@ public class CommandManager implements CommandExecutor {
|
|||||||
addCommand(new CommandFreeze());
|
addCommand(new CommandFreeze());
|
||||||
addCommand(new CommandRevive());
|
addCommand(new CommandRevive());
|
||||||
addCommand(new CommandSpy());
|
addCommand(new CommandSpy());
|
||||||
|
addCommand(new CommandCommandSpy());
|
||||||
|
|
||||||
addCommand(new CommandSettings(commandUltimateModeration));
|
addCommand(new CommandSettings(commandUltimateModeration));
|
||||||
addCommand(new CommandReload(commandUltimateModeration));
|
addCommand(new CommandReload(commandUltimateModeration));
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
package com.songoda.ultimatemoderation.command.commands;
|
||||||
|
|
||||||
|
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||||
|
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class CommandCommandSpy extends AbstractCommand {
|
||||||
|
|
||||||
|
private static List<UUID> inSpy = new ArrayList<>();
|
||||||
|
|
||||||
|
public CommandCommandSpy() {
|
||||||
|
super(true, false,"CommandSpy");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||||
|
Player player = ((Player)sender);
|
||||||
|
|
||||||
|
if (inSpy.contains(player.getUniqueId())) {
|
||||||
|
inSpy.remove(player.getUniqueId());
|
||||||
|
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.commandspy.toggleOn"));
|
||||||
|
} else {
|
||||||
|
inSpy.add(player.getUniqueId());
|
||||||
|
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.commandspy.toggleOff"));
|
||||||
|
}
|
||||||
|
return ReturnType.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSpying(Player player) {
|
||||||
|
return !inSpy.contains(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermissionNode() {
|
||||||
|
return "Um.commandspy";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSyntax() {
|
||||||
|
return "/Commandspy";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "Allows you to see inside of a players enderchest.";
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.songoda.ultimatemoderation.listeners;
|
package com.songoda.ultimatemoderation.listeners;
|
||||||
|
|
||||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||||
|
import com.songoda.ultimatemoderation.command.commands.CommandCommandSpy;
|
||||||
import com.songoda.ultimatemoderation.utils.Methods;
|
import com.songoda.ultimatemoderation.utils.Methods;
|
||||||
import com.songoda.ultimatemoderation.utils.SettingsManager;
|
import com.songoda.ultimatemoderation.utils.SettingsManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -25,14 +26,24 @@ public class CommandListener implements Listener {
|
|||||||
public void onCommand(PlayerCommandPreprocessEvent event) {
|
public void onCommand(PlayerCommandPreprocessEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
String command = event.getMessage();
|
||||||
|
|
||||||
List<String> blockedCommands = SettingsManager.Setting.BLOCKED_COMMANDS.getStringList();
|
List<String> blockedCommands = SettingsManager.Setting.BLOCKED_COMMANDS.getStringList();
|
||||||
|
|
||||||
for (String cmd : blockedCommands) {
|
for (String cmd : blockedCommands) {
|
||||||
if (event.getMessage().toUpperCase().startsWith("/" + cmd.toUpperCase())
|
if (command.toUpperCase().startsWith("/" + cmd.toUpperCase())
|
||||||
|
&& (command.toUpperCase().endsWith(cmd.toUpperCase()) || (command.contains(" ") && command.split(" ")[0].toUpperCase().endsWith(cmd.toUpperCase())))
|
||||||
&& !player.hasPermission("um.commandblock.bypass")) {
|
&& !player.hasPermission("um.commandblock.bypass")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.setMessage("-");
|
event.setMessage("-");
|
||||||
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.blocked"));
|
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("event.command.blocked"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!player.hasPermission("um.commandspy.immune")) {
|
||||||
|
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (pl.hasPermission("um.commandspy") && CommandCommandSpy.isSpying(pl))
|
||||||
|
pl.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.commandspy.deny", player.getName(), command));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,4 +26,11 @@ command.revive.revived = "&7You have been revived."
|
|||||||
command.spy.returned = "&7You were returned to your previous location"
|
command.spy.returned = "&7You were returned to your previous location"
|
||||||
command.spy.success = "&7You are now spying on &6%player%&7. Use the command &6/spy &7to return to your previous location&7"
|
command.spy.success = "&7You are now spying on &6%player%&7. Use the command &6/spy &7to return to your previous location&7"
|
||||||
|
|
||||||
command.blocked = "&cYou cannot use that command..."
|
command.commandspy.deny = "&6%player%&7: %command%&7."
|
||||||
|
command.commandspy.toggleOn = "&7Command spy on";
|
||||||
|
command.commandspy.toggleOff = "&7Command spy off";
|
||||||
|
|
||||||
|
#Event Messages
|
||||||
|
|
||||||
|
event.general.nopermission = "&cYou do not have permission to do that."
|
||||||
|
event.command.blocked = "&cYou cannot use that command..."
|
@ -52,3 +52,7 @@ commands:
|
|||||||
description: Spy
|
description: Spy
|
||||||
default: false
|
default: false
|
||||||
usage: /spy
|
usage: /spy
|
||||||
|
CommandSpy:
|
||||||
|
description: CommandSpy
|
||||||
|
default: false
|
||||||
|
usage: /commandspy
|
Loading…
Reference in New Issue
Block a user