If the config has prisoners not to get the chats, then let's obey that.

This commit is contained in:
graywolf336 2014-01-03 23:57:10 -06:00
parent 2f36c1f900
commit 369c874add
3 changed files with 25 additions and 0 deletions

View File

@ -16,6 +16,7 @@ public enum Settings {
MAXAFKTIME("jailing.during.maxAFKTime"),
MAXFOODLEVEL("jailing.during.maxFoodLevel"),
MINFOODLEVEL("jailing.during.minFoodLevel"),
RECIEVEMESSAGES("jailing.during.recieveMessages"),
RELEASETOPREVIOUSPOSITION("jailing.release.backToPreviousPosition"),
RESTOREPREVIOUSGAMEMODE("jailing.release.restorePreviousGameMode"),
TELEPORTONRELEASE("jailing.release.teleport"),

View File

@ -1,5 +1,8 @@
package com.graywolf336.jail.listeners;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -13,6 +16,9 @@ import org.bukkit.event.player.PlayerJoinEvent;
import com.graywolf336.jail.JailMain;
import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.Util;
import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.enums.Settings;
public class PlayerListener implements Listener {
private JailMain pl;
@ -50,6 +56,23 @@ public class PlayerListener implements Listener {
event.getPlayer().sendMessage(ChatColor.RED + "Stop talking, you're currently jailed and muted.");
}
}
//If the config has recieve messages set to false, let's remove all the prisoners
//from getting the chat messages.
if(!pl.getConfig().getBoolean(Settings.RECIEVEMESSAGES.getPath())) {
if(pl.inDebug()) pl.getLogger().info("Debug - There are " + event.getRecipients().size() + " players getting the message before.");
Set<Player> rec = new HashSet<Player>(event.getRecipients());
for(Jail j : pl.getJailManager().getJails()) {
for(Prisoner p : j.getAllPrisoners()) {
rec.remove(pl.getServer().getPlayerExact(p.getName()));
}
}
event.getRecipients().clear();
event.getRecipients().addAll(rec);
if(pl.inDebug()) pl.getLogger().info("Debug - There are now " + event.getRecipients().size() + " players getting the message.");
}
}
@EventHandler

View File

@ -19,6 +19,7 @@ jailing:
maxFoodLevel: 20
minFoodLevel: 10
openChest: true
recieveMessages: true
jail:
automaticMute: true
broadcastJailing: false