Add blacklist of commands for muted players. Adds #30.

This commit is contained in:
drtshock 2015-05-12 21:44:36 -05:00
parent 6796d460dc
commit d6eb846488
4 changed files with 37 additions and 0 deletions

View File

@ -356,6 +356,12 @@ public class EssentialsPlayerListener implements Listener {
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
final Player player = event.getPlayer();
final String cmd = event.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "").toLowerCase(Locale.ENGLISH);
if (ess.getUser(player).isMuted() && (ess.getSettings().getMuteCommands().contains(cmd) || ess.getSettings().getMuteCommands().contains("*"))) {
event.setCancelled(true);
player.sendMessage(tl("voiceSilenced"));
LOGGER.info(tl("mutedUserSpeaks", player.getName()));
return;
}
if (ess.getSettings().getSocialSpyCommands().contains(cmd) || ess.getSettings().getSocialSpyCommands().contains("*")) {
for (User spyer : ess.getOnlineUsers()) {
if (spyer.isSocialSpyEnabled() && !player.equals(spyer.getBase())) {

View File

@ -48,6 +48,8 @@ public interface ISettings extends IConf {
Set<String> getSocialSpyCommands();
Set<String> getMuteCommands();
Map<String, Object> getKit(String name);
ConfigurationSection getKits();

View File

@ -254,6 +254,24 @@ public class Settings implements net.ess3.api.ISettings {
return socialSpyCommands;
}
private Set<String> muteCommands = new HashSet<String>();
private Set<String> _getMuteCommands() {
Set<String> muteCommands = new HashSet<String>();
if(config.isList("mute-commands")) {
for(String s : config.getStringList("mute-commands")) {
muteCommands.add(s.toLowerCase(Locale.ENGLISH));
}
}
return muteCommands;
}
@Override
public Set<String> getMuteCommands() {
return muteCommands;
}
private String nicknamePrefix = "~";
private String _getNicknamePrefix() {
@ -489,6 +507,7 @@ public class Settings implements net.ess3.api.ISettings {
isCustomJoinMessage = !customJoinMessage.equals("none");
customQuitMessage = _getCustomQuitMessage();
isCustomQuitMessage = !customQuitMessage.equals("none");
muteCommands = _getMuteCommands();
}
private List<Integer> itemSpawnBl = new ArrayList<Integer>();

View File

@ -138,6 +138,16 @@ socialspy-commands:
- ewhisper
- pm
# Mute Commands
# These commands will be disabled when a player is muted.
# Use '*' to disable every command.
# Essentials already disabled Essentials messaging commands by default.
# It only cars about the root command, not args after that (it sees /f chat the same as /f)
mute-commands:
- f
- kittycannon
# - '*'
# If you do not wish to use a permission system, you can define a list of 'player perms' below.
# This list has no effect if you are using a supported permissions system.
# If you are using an unsupported permissions system, simply delete this section.