If the config has prisoners not to get the chats, then let's obey that.
This commit is contained in:
parent
2f36c1f900
commit
369c874add
@ -16,6 +16,7 @@ public enum Settings {
|
|||||||
MAXAFKTIME("jailing.during.maxAFKTime"),
|
MAXAFKTIME("jailing.during.maxAFKTime"),
|
||||||
MAXFOODLEVEL("jailing.during.maxFoodLevel"),
|
MAXFOODLEVEL("jailing.during.maxFoodLevel"),
|
||||||
MINFOODLEVEL("jailing.during.minFoodLevel"),
|
MINFOODLEVEL("jailing.during.minFoodLevel"),
|
||||||
|
RECIEVEMESSAGES("jailing.during.recieveMessages"),
|
||||||
RELEASETOPREVIOUSPOSITION("jailing.release.backToPreviousPosition"),
|
RELEASETOPREVIOUSPOSITION("jailing.release.backToPreviousPosition"),
|
||||||
RESTOREPREVIOUSGAMEMODE("jailing.release.restorePreviousGameMode"),
|
RESTOREPREVIOUSGAMEMODE("jailing.release.restorePreviousGameMode"),
|
||||||
TELEPORTONRELEASE("jailing.release.teleport"),
|
TELEPORTONRELEASE("jailing.release.teleport"),
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.graywolf336.jail.listeners;
|
package com.graywolf336.jail.listeners;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -13,6 +16,9 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import com.graywolf336.jail.JailMain;
|
import com.graywolf336.jail.JailMain;
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.Util;
|
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 {
|
public class PlayerListener implements Listener {
|
||||||
private JailMain pl;
|
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.");
|
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
|
@EventHandler
|
||||||
|
@ -19,6 +19,7 @@ jailing:
|
|||||||
maxFoodLevel: 20
|
maxFoodLevel: 20
|
||||||
minFoodLevel: 10
|
minFoodLevel: 10
|
||||||
openChest: true
|
openChest: true
|
||||||
|
recieveMessages: true
|
||||||
jail:
|
jail:
|
||||||
automaticMute: true
|
automaticMute: true
|
||||||
broadcastJailing: false
|
broadcastJailing: false
|
||||||
|
Loading…
Reference in New Issue
Block a user