Refactoring des classes de gestion de spam car elle vont servir pour le système de censure
This commit is contained in:
parent
b2e47d1e2e
commit
22916afa05
@ -2,7 +2,7 @@ package net.mc_pandacraft.java.plugin.pandacraftutils;
|
||||
|
||||
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.afk.CommandAfk;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.antispam.AntispamManager;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.chat_analyzer.ChatAnalysisManager;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.creativ_cheat.CreativCheatManager;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.list.CommandList;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.me.CommandMe;
|
||||
@ -30,7 +30,7 @@ public class PandacraftUtils extends JavaPlugin {
|
||||
|
||||
|
||||
public SpawnTimeManager spawnTimeManager;
|
||||
public AntispamManager antispamManager;
|
||||
public ChatAnalysisManager chatAnalysisManager;
|
||||
public CreativCheatManager creativCheatManager;
|
||||
public NoPvpProtectManager noPvpProtectManager;
|
||||
|
||||
@ -53,7 +53,7 @@ public class PandacraftUtils extends JavaPlugin {
|
||||
commandWandSelection = new CommandWandSelection(this);
|
||||
|
||||
spawnTimeManager = new SpawnTimeManager(this);
|
||||
antispamManager = new AntispamManager(this);
|
||||
chatAnalysisManager = new ChatAnalysisManager(this);
|
||||
creativCheatManager = new CreativCheatManager(this);
|
||||
noPvpProtectManager = new NoPvpProtectManager(this);
|
||||
|
||||
@ -72,7 +72,7 @@ public class PandacraftUtils extends JavaPlugin {
|
||||
commandSpeedMessage = null;
|
||||
|
||||
spawnTimeManager = null;
|
||||
antispamManager = null;
|
||||
chatAnalysisManager = null;
|
||||
creativCheatManager = null;
|
||||
noPvpProtectManager = null;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.mc_pandacraft.java.plugin.pandacraftutils.antispam;
|
||||
package net.mc_pandacraft.java.plugin.pandacraftutils.chat_analyzer;
|
||||
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||
|
||||
@ -11,19 +11,19 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class AntispamManager implements Listener {
|
||||
public class ChatAnalysisManager implements Listener {
|
||||
|
||||
private AntispamPlayer[] aPlayers;
|
||||
private ChatAnalysisPlayer[] aPlayers;
|
||||
|
||||
private PandacraftUtils plugin;
|
||||
|
||||
public AntispamManager(PandacraftUtils pl)
|
||||
public ChatAnalysisManager(PandacraftUtils pl)
|
||||
{
|
||||
plugin = pl;
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
|
||||
aPlayers = new AntispamPlayer[plugin.getServer().getMaxPlayers()];
|
||||
aPlayers = new ChatAnalysisPlayer[plugin.getServer().getMaxPlayers()];
|
||||
|
||||
|
||||
// analyse des joueurs déjà en ligne (/reload)
|
||||
@ -50,11 +50,11 @@ public class AntispamManager implements Listener {
|
||||
|
||||
|
||||
|
||||
public AntispamPlayer getAPlayer(Player p)
|
||||
public ChatAnalysisPlayer getAPlayer(Player p)
|
||||
{
|
||||
if (p == null || !p.isOnline())
|
||||
return null;
|
||||
for (AntispamPlayer ap : aPlayers)
|
||||
for (ChatAnalysisPlayer ap : aPlayers)
|
||||
{
|
||||
if (ap != null && ap.getPlayer() == p)
|
||||
return ap;
|
||||
@ -69,7 +69,7 @@ public class AntispamManager implements Listener {
|
||||
{
|
||||
int i=0;
|
||||
while (i<aPlayers.length && aPlayers[i] != null) i++;
|
||||
if (aPlayers[i] == null) aPlayers[i] = new AntispamPlayer(plugin, event.getPlayer());
|
||||
if (aPlayers[i] == null) aPlayers[i] = new ChatAnalysisPlayer(plugin, event.getPlayer());
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.mc_pandacraft.java.plugin.pandacraftutils.antispam;
|
||||
package net.mc_pandacraft.java.plugin.pandacraftutils.chat_analyzer;
|
||||
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||
@ -10,7 +10,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
|
||||
public class AntispamPlayer {
|
||||
public class ChatAnalysisPlayer {
|
||||
private long time_before_resend_same_message = ConfigManager.getInstance().AntiSpam_timeBeforeResendSameMessage;// 30 sec
|
||||
private long time_before_resend_same_command = ConfigManager.getInstance().AntiSpam_timeBeforeResendSameCommand;// 30 sec
|
||||
|
||||
@ -41,7 +41,7 @@ public class AntispamPlayer {
|
||||
private int violation_level = 0;
|
||||
|
||||
|
||||
public AntispamPlayer(PandacraftUtils pl, Player p)
|
||||
public ChatAnalysisPlayer(PandacraftUtils pl, Player p)
|
||||
{
|
||||
player = p;
|
||||
plugin = pl;
|
@ -147,8 +147,8 @@ public class CommandList implements CommandExecutor {
|
||||
{
|
||||
try
|
||||
{
|
||||
int vl = plugin.antispamManager.getAPlayer(p).getVL();
|
||||
int max_vl = plugin.antispamManager.getAPlayer(p).getMaxVL();
|
||||
int vl = plugin.chatAnalysisManager.getAPlayer(p).getVL();
|
||||
int max_vl = plugin.chatAnalysisManager.getAPlayer(p).getMaxVL();
|
||||
aff_list.add("§f"+name+"§r - §7"+vl+"/"+max_vl);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user