Correction de bug avec les messages de login / logout

This commit is contained in:
Marc Baloup 2014-11-28 22:08:10 +01:00
parent a03a3f373a
commit f5f899b771
2 changed files with 27 additions and 2 deletions

View File

@ -55,7 +55,7 @@ public class ConfigManager {
/* /*
* Insultes * Insultes
*/ */
ChatAnalysis_badWords.add("putes?"); ChatAnalysis_badWords.add("pu+tes?");
ChatAnalysis_badWords.add("conn?a(rd?|ss?e?)"); ChatAnalysis_badWords.add("conn?a(rd?|ss?e?)");
ChatAnalysis_badWords.add("sal(o|au)pe?s?"); ChatAnalysis_badWords.add("sal(o|au)pe?s?");
ChatAnalysis_badWords.add("[ea]ncul(é|e|er|ai(s|t|))"); ChatAnalysis_badWords.add("[ea]ncul(é|e|er|ai(s|t|))");

View File

@ -1,8 +1,13 @@
package net.mc_pandacraft.java.plugin.pandacraftutils.login_message; package net.mc_pandacraft.java.plugin.pandacraftutils.login_message;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
@ -14,6 +19,8 @@ public class LoginLogoutManager implements Listener {
private PandacraftUtils plugin; private PandacraftUtils plugin;
private List<Player> loggedInPlayer = new ArrayList<Player>();
public LoginLogoutManager(PandacraftUtils pl) { public LoginLogoutManager(PandacraftUtils pl) {
plugin = pl; plugin = pl;
@ -31,12 +38,30 @@ public class LoginLogoutManager implements Listener {
@EventHandler @EventHandler
public void onxAuthLogin(xAuthLoginEvent event) { public void onxAuthLogin(xAuthLoginEvent event) {
plugin.getServer().broadcastMessage(ChatColor.YELLOW+event.getPlayer().getDisplayName()+ChatColor.YELLOW+" vient de se connecter"); plugin.getServer().broadcastMessage(ChatColor.YELLOW+event.getPlayer().getDisplayName()+ChatColor.YELLOW+" vient de se connecter");
loggedInPlayer.add(event.getPlayer());
} }
@EventHandler @EventHandler
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
event.setQuitMessage(null);
if (!isPlayerLoggedIn(event.getPlayer()))
return;
loggedInPlayer.remove(event.getPlayer());
event.setQuitMessage(ChatColor.YELLOW+event.getPlayer().getDisplayName()+ChatColor.YELLOW+" a quitté le jeu"); event.setQuitMessage(ChatColor.YELLOW+event.getPlayer().getDisplayName()+ChatColor.YELLOW+" a quitté le jeu");
} }
public List<Player> getLoggedInPlayer() { return loggedInPlayer; }
public List<Player> getLoggedOutPlayer() {
List<Player> players = new ArrayList<Player>(Arrays.asList(plugin.getServer().getOnlinePlayers()));
players.removeAll(loggedInPlayer);
return players;
}
public boolean isPlayerLoggedIn(Player p) {
return loggedInPlayer.contains(p);
}
} }