Chat ban command fixed and upgraded.

This commit is contained in:
MobiusDev 2018-05-06 01:38:45 +00:00
parent 2881989633
commit 217c85eedd
26 changed files with 826 additions and 644 deletions

View File

@ -27,6 +27,8 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect; import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentTask; import com.l2jmobius.gameserver.model.punishment.PunishmentTask;
import com.l2jmobius.gameserver.model.punishment.PunishmentType; import com.l2jmobius.gameserver.model.punishment.PunishmentType;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util; import com.l2jmobius.gameserver.util.Util;
public class ChatAdmin implements IVoicedCommandHandler public class ChatAdmin implements IVoicedCommandHandler
@ -34,7 +36,9 @@ public class ChatAdmin implements IVoicedCommandHandler
private static final String[] VOICED_COMMANDS = private static final String[] VOICED_COMMANDS =
{ {
"banchat", "banchat",
"unbanchat" "chatban",
"unbanchat",
"chatunban"
}; };
@Override @Override
@ -45,11 +49,14 @@ public class ChatAdmin implements IVoicedCommandHandler
return false; return false;
} }
if (command.equals(VOICED_COMMANDS[0])) // banchat switch (command)
{
case "banchat":
case "chatban":
{ {
if (params == null) if (params == null)
{ {
activeChar.sendMessage("Usage: .banchat name [minutes]"); BuilderUtil.sendSysMessage(activeChar, "Usage: .banchat name [minutes]");
return true; return true;
} }
final StringTokenizer st = new StringTokenizer(params); final StringTokenizer st = new StringTokenizer(params);
@ -62,7 +69,7 @@ public class ChatAdmin implements IVoicedCommandHandler
final String token = st.nextToken(); final String token = st.nextToken();
if (Util.isDigit(token)) if (Util.isDigit(token))
{ {
expirationTime = System.currentTimeMillis() + (Integer.parseInt(st.nextToken()) * 60 * 1000); expirationTime = Integer.parseInt(token);
} }
} }
@ -72,54 +79,56 @@ public class ChatAdmin implements IVoicedCommandHandler
final L2PcInstance player = L2World.getInstance().getPlayer(objId); final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player == null) || !player.isOnline()) if ((player == null) || !player.isOnline())
{ {
activeChar.sendMessage("Player not online !"); BuilderUtil.sendSysMessage(activeChar, "Player not online!");
return false; return false;
} }
if (player.isChatBanned()) if (player.isChatBanned())
{ {
activeChar.sendMessage("Player is already punished !"); BuilderUtil.sendSysMessage(activeChar, "Player is already punished!");
return false; return false;
} }
if (player == activeChar) if (player == activeChar)
{ {
activeChar.sendMessage("You can't ban yourself !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban yourself!");
return false; return false;
} }
if (player.isGM()) if (player.isGM())
{ {
activeChar.sendMessage("You can't ban GM !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban a GM!");
return false; return false;
} }
if (AdminData.getInstance().hasAccess(command, player.getAccessLevel())) if (AdminData.getInstance().hasAccess(command, player.getAccessLevel()))
{ {
activeChar.sendMessage("You can't ban moderator !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban moderator!");
return false; return false;
} }
PunishmentManager.getInstance().startPunishment(new PunishmentTask(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, expirationTime, "Chat banned by moderator", activeChar.getName())); PunishmentManager.getInstance().startPunishment(new PunishmentTask(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, System.currentTimeMillis() + (expirationTime * 1000 * 60), "Chat banned by moderator", activeChar.getName()));
player.sendMessage("Chat banned by moderator " + activeChar.getName());
if (expirationTime > 0) if (expirationTime > 0)
{ {
activeChar.sendMessage("Player " + player.getName() + " chat banned for " + expirationTime + " minutes."); BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat banned for " + expirationTime + " minutes.");
} }
else else
{ {
activeChar.sendMessage("Player " + player.getName() + " chat banned forever."); BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat banned forever.");
} }
player.sendMessage("Chat banned by moderator " + activeChar.getName());
player.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
} }
else else
{ {
activeChar.sendMessage("Player not found !"); BuilderUtil.sendSysMessage(activeChar, "Player not found!");
return false; return false;
} }
} }
break;
} }
else if (command.equals(VOICED_COMMANDS[1])) // unbanchat case "unbanchat":
case "chatunban":
{ {
if (params == null) if (params == null)
{ {
activeChar.sendMessage("Usage: .unbanchat name"); BuilderUtil.sendSysMessage(activeChar, "Usage: .unbanchat name");
return true; return true;
} }
final StringTokenizer st = new StringTokenizer(params); final StringTokenizer st = new StringTokenizer(params);
@ -133,26 +142,28 @@ public class ChatAdmin implements IVoicedCommandHandler
final L2PcInstance player = L2World.getInstance().getPlayer(objId); final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player == null) || !player.isOnline()) if ((player == null) || !player.isOnline())
{ {
activeChar.sendMessage("Player not online !"); BuilderUtil.sendSysMessage(activeChar, "Player not online!");
return false; return false;
} }
if (!player.isChatBanned()) if (!player.isChatBanned())
{ {
activeChar.sendMessage("Player is not chat banned !"); BuilderUtil.sendSysMessage(activeChar, "Player is not chat banned!");
return false; return false;
} }
PunishmentManager.getInstance().stopPunishment(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN); PunishmentManager.getInstance().stopPunishment(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN);
BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat unbanned.");
activeChar.sendMessage("Player " + player.getName() + " chat unbanned.");
player.sendMessage("Chat unbanned by moderator " + activeChar.getName()); player.sendMessage("Chat unbanned by moderator " + activeChar.getName());
player.getEffectList().stopAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
} }
else else
{ {
activeChar.sendMessage("Player not found !"); BuilderUtil.sendSysMessage(activeChar, "Player not found!");
return false; return false;
} }
} }
break;
}
} }
return true; return true;
} }

View File

@ -2527,7 +2527,7 @@ public final class Config
// Load ChatModeration config file (if exists) // Load ChatModeration config file (if exists)
final PropertiesParser ChatModeration = new PropertiesParser(CUSTOM_CHAT_MODERATION_CONFIG_FILE); final PropertiesParser ChatModeration = new PropertiesParser(CUSTOM_CHAT_MODERATION_CONFIG_FILE);
CHAT_ADMIN = ChatModeration.getBoolean("ChatAdmin", false); CHAT_ADMIN = ChatModeration.getBoolean("ChatAdmin", true);
// Load CommunityBoard config file (if exists) // Load CommunityBoard config file (if exists)
final PropertiesParser CommunityBoard = new PropertiesParser(CUSTOM_COMMUNITY_BOARD_CONFIG_FILE); final PropertiesParser CommunityBoard = new PropertiesParser(CUSTOM_COMMUNITY_BOARD_CONFIG_FILE);

View File

@ -30,6 +30,9 @@ import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.handler.IPunishmentHandler; import com.l2jmobius.gameserver.handler.IPunishmentHandler;
import com.l2jmobius.gameserver.handler.PunishmentHandler; import com.l2jmobius.gameserver.handler.PunishmentHandler;
import com.l2jmobius.gameserver.instancemanager.PunishmentManager; import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
/** /**
* @author UnAfraid * @author UnAfraid
@ -234,6 +237,15 @@ public class PunishmentTask implements Runnable
} }
} }
if (_type.equals(PunishmentType.CHAT_BAN) && _affect.equals(PunishmentAffect.CHARACTER))
{
final L2PcInstance player = L2World.getInstance().getPlayer(Integer.valueOf(_key));
if (player != null)
{
player.getEffectList().stopAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
}
}
final IPunishmentHandler handler = PunishmentHandler.getInstance().getHandler(_type); final IPunishmentHandler handler = PunishmentHandler.getInstance().getHandler(_type);
if (handler != null) if (handler != null)
{ {

View File

@ -263,6 +263,12 @@ public class EnterWorld implements IClientIncomingPacket
} }
} }
// Chat banned icon.
if (activeChar.isChatBanned())
{
activeChar.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
}
// Set dead status if applies // Set dead status if applies
if (activeChar.getCurrentHp() < 0.5) if (activeChar.getCurrentHp() < 0.5)
{ {

View File

@ -27,6 +27,8 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect; import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentTask; import com.l2jmobius.gameserver.model.punishment.PunishmentTask;
import com.l2jmobius.gameserver.model.punishment.PunishmentType; import com.l2jmobius.gameserver.model.punishment.PunishmentType;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util; import com.l2jmobius.gameserver.util.Util;
public class ChatAdmin implements IVoicedCommandHandler public class ChatAdmin implements IVoicedCommandHandler
@ -34,7 +36,9 @@ public class ChatAdmin implements IVoicedCommandHandler
private static final String[] VOICED_COMMANDS = private static final String[] VOICED_COMMANDS =
{ {
"banchat", "banchat",
"unbanchat" "chatban",
"unbanchat",
"chatunban"
}; };
@Override @Override
@ -45,11 +49,14 @@ public class ChatAdmin implements IVoicedCommandHandler
return false; return false;
} }
if (command.equals(VOICED_COMMANDS[0])) // banchat switch (command)
{
case "banchat":
case "chatban":
{ {
if (params == null) if (params == null)
{ {
activeChar.sendMessage("Usage: .banchat name [minutes]"); BuilderUtil.sendSysMessage(activeChar, "Usage: .banchat name [minutes]");
return true; return true;
} }
final StringTokenizer st = new StringTokenizer(params); final StringTokenizer st = new StringTokenizer(params);
@ -62,7 +69,7 @@ public class ChatAdmin implements IVoicedCommandHandler
final String token = st.nextToken(); final String token = st.nextToken();
if (Util.isDigit(token)) if (Util.isDigit(token))
{ {
expirationTime = System.currentTimeMillis() + (Integer.parseInt(st.nextToken()) * 60 * 1000); expirationTime = Integer.parseInt(token);
} }
} }
@ -72,54 +79,56 @@ public class ChatAdmin implements IVoicedCommandHandler
final L2PcInstance player = L2World.getInstance().getPlayer(objId); final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player == null) || !player.isOnline()) if ((player == null) || !player.isOnline())
{ {
activeChar.sendMessage("Player not online !"); BuilderUtil.sendSysMessage(activeChar, "Player not online!");
return false; return false;
} }
if (player.isChatBanned()) if (player.isChatBanned())
{ {
activeChar.sendMessage("Player is already punished !"); BuilderUtil.sendSysMessage(activeChar, "Player is already punished!");
return false; return false;
} }
if (player == activeChar) if (player == activeChar)
{ {
activeChar.sendMessage("You can't ban yourself !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban yourself!");
return false; return false;
} }
if (player.isGM()) if (player.isGM())
{ {
activeChar.sendMessage("You can't ban GM !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban a GM!");
return false; return false;
} }
if (AdminData.getInstance().hasAccess(command, player.getAccessLevel())) if (AdminData.getInstance().hasAccess(command, player.getAccessLevel()))
{ {
activeChar.sendMessage("You can't ban moderator !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban moderator!");
return false; return false;
} }
PunishmentManager.getInstance().startPunishment(new PunishmentTask(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, expirationTime, "Chat banned by moderator", activeChar.getName())); PunishmentManager.getInstance().startPunishment(new PunishmentTask(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, System.currentTimeMillis() + (expirationTime * 1000 * 60), "Chat banned by moderator", activeChar.getName()));
player.sendMessage("Chat banned by moderator " + activeChar.getName());
if (expirationTime > 0) if (expirationTime > 0)
{ {
activeChar.sendMessage("Player " + player.getName() + " chat banned for " + expirationTime + " minutes."); BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat banned for " + expirationTime + " minutes.");
} }
else else
{ {
activeChar.sendMessage("Player " + player.getName() + " chat banned forever."); BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat banned forever.");
} }
player.sendMessage("Chat banned by moderator " + activeChar.getName());
player.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
} }
else else
{ {
activeChar.sendMessage("Player not found !"); BuilderUtil.sendSysMessage(activeChar, "Player not found!");
return false; return false;
} }
} }
break;
} }
else if (command.equals(VOICED_COMMANDS[1])) // unbanchat case "unbanchat":
case "chatunban":
{ {
if (params == null) if (params == null)
{ {
activeChar.sendMessage("Usage: .unbanchat name"); BuilderUtil.sendSysMessage(activeChar, "Usage: .unbanchat name");
return true; return true;
} }
final StringTokenizer st = new StringTokenizer(params); final StringTokenizer st = new StringTokenizer(params);
@ -133,26 +142,28 @@ public class ChatAdmin implements IVoicedCommandHandler
final L2PcInstance player = L2World.getInstance().getPlayer(objId); final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player == null) || !player.isOnline()) if ((player == null) || !player.isOnline())
{ {
activeChar.sendMessage("Player not online !"); BuilderUtil.sendSysMessage(activeChar, "Player not online!");
return false; return false;
} }
if (!player.isChatBanned()) if (!player.isChatBanned())
{ {
activeChar.sendMessage("Player is not chat banned !"); BuilderUtil.sendSysMessage(activeChar, "Player is not chat banned!");
return false; return false;
} }
PunishmentManager.getInstance().stopPunishment(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN); PunishmentManager.getInstance().stopPunishment(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN);
BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat unbanned.");
activeChar.sendMessage("Player " + player.getName() + " chat unbanned.");
player.sendMessage("Chat unbanned by moderator " + activeChar.getName()); player.sendMessage("Chat unbanned by moderator " + activeChar.getName());
player.getEffectList().stopAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
} }
else else
{ {
activeChar.sendMessage("Player not found !"); BuilderUtil.sendSysMessage(activeChar, "Player not found!");
return false; return false;
} }
} }
break;
}
} }
return true; return true;
} }

View File

@ -2543,7 +2543,7 @@ public final class Config
// Load ChatModeration config file (if exists) // Load ChatModeration config file (if exists)
final PropertiesParser ChatModeration = new PropertiesParser(CUSTOM_CHAT_MODERATION_CONFIG_FILE); final PropertiesParser ChatModeration = new PropertiesParser(CUSTOM_CHAT_MODERATION_CONFIG_FILE);
CHAT_ADMIN = ChatModeration.getBoolean("ChatAdmin", false); CHAT_ADMIN = ChatModeration.getBoolean("ChatAdmin", true);
// Load CommunityBoard config file (if exists) // Load CommunityBoard config file (if exists)
final PropertiesParser CommunityBoard = new PropertiesParser(CUSTOM_COMMUNITY_BOARD_CONFIG_FILE); final PropertiesParser CommunityBoard = new PropertiesParser(CUSTOM_COMMUNITY_BOARD_CONFIG_FILE);

View File

@ -30,6 +30,9 @@ import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.handler.IPunishmentHandler; import com.l2jmobius.gameserver.handler.IPunishmentHandler;
import com.l2jmobius.gameserver.handler.PunishmentHandler; import com.l2jmobius.gameserver.handler.PunishmentHandler;
import com.l2jmobius.gameserver.instancemanager.PunishmentManager; import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
/** /**
* @author UnAfraid * @author UnAfraid
@ -234,6 +237,15 @@ public class PunishmentTask implements Runnable
} }
} }
if (_type.equals(PunishmentType.CHAT_BAN) && _affect.equals(PunishmentAffect.CHARACTER))
{
final L2PcInstance player = L2World.getInstance().getPlayer(Integer.valueOf(_key));
if (player != null)
{
player.getEffectList().stopAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
}
}
final IPunishmentHandler handler = PunishmentHandler.getInstance().getHandler(_type); final IPunishmentHandler handler = PunishmentHandler.getInstance().getHandler(_type);
if (handler != null) if (handler != null)
{ {

View File

@ -268,6 +268,12 @@ public class EnterWorld implements IClientIncomingPacket
} }
} }
// Chat banned icon.
if (activeChar.isChatBanned())
{
activeChar.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
}
// Set dead status if applies // Set dead status if applies
if (activeChar.getCurrentHp() < 0.5) if (activeChar.getCurrentHp() < 0.5)
{ {

View File

@ -27,6 +27,8 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect; import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentTask; import com.l2jmobius.gameserver.model.punishment.PunishmentTask;
import com.l2jmobius.gameserver.model.punishment.PunishmentType; import com.l2jmobius.gameserver.model.punishment.PunishmentType;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util; import com.l2jmobius.gameserver.util.Util;
public class ChatAdmin implements IVoicedCommandHandler public class ChatAdmin implements IVoicedCommandHandler
@ -34,7 +36,9 @@ public class ChatAdmin implements IVoicedCommandHandler
private static final String[] VOICED_COMMANDS = private static final String[] VOICED_COMMANDS =
{ {
"banchat", "banchat",
"unbanchat" "chatban",
"unbanchat",
"chatunban"
}; };
@Override @Override
@ -45,11 +49,14 @@ public class ChatAdmin implements IVoicedCommandHandler
return false; return false;
} }
if (command.equals(VOICED_COMMANDS[0])) // banchat switch (command)
{
case "banchat":
case "chatban":
{ {
if (params == null) if (params == null)
{ {
activeChar.sendMessage("Usage: .banchat name [minutes]"); BuilderUtil.sendSysMessage(activeChar, "Usage: .banchat name [minutes]");
return true; return true;
} }
final StringTokenizer st = new StringTokenizer(params); final StringTokenizer st = new StringTokenizer(params);
@ -62,7 +69,7 @@ public class ChatAdmin implements IVoicedCommandHandler
final String token = st.nextToken(); final String token = st.nextToken();
if (Util.isDigit(token)) if (Util.isDigit(token))
{ {
expirationTime = System.currentTimeMillis() + (Integer.parseInt(st.nextToken()) * 60 * 1000); expirationTime = Integer.parseInt(token);
} }
} }
@ -72,54 +79,56 @@ public class ChatAdmin implements IVoicedCommandHandler
final L2PcInstance player = L2World.getInstance().getPlayer(objId); final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player == null) || !player.isOnline()) if ((player == null) || !player.isOnline())
{ {
activeChar.sendMessage("Player not online !"); BuilderUtil.sendSysMessage(activeChar, "Player not online!");
return false; return false;
} }
if (player.isChatBanned()) if (player.isChatBanned())
{ {
activeChar.sendMessage("Player is already punished !"); BuilderUtil.sendSysMessage(activeChar, "Player is already punished!");
return false; return false;
} }
if (player == activeChar) if (player == activeChar)
{ {
activeChar.sendMessage("You can't ban yourself !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban yourself!");
return false; return false;
} }
if (player.isGM()) if (player.isGM())
{ {
activeChar.sendMessage("You can't ban GM !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban a GM!");
return false; return false;
} }
if (AdminData.getInstance().hasAccess(command, player.getAccessLevel())) if (AdminData.getInstance().hasAccess(command, player.getAccessLevel()))
{ {
activeChar.sendMessage("You can't ban moderator !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban moderator!");
return false; return false;
} }
PunishmentManager.getInstance().startPunishment(new PunishmentTask(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, expirationTime, "Chat banned by moderator", activeChar.getName())); PunishmentManager.getInstance().startPunishment(new PunishmentTask(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, System.currentTimeMillis() + (expirationTime * 1000 * 60), "Chat banned by moderator", activeChar.getName()));
player.sendMessage("Chat banned by moderator " + activeChar.getName());
if (expirationTime > 0) if (expirationTime > 0)
{ {
activeChar.sendMessage("Player " + player.getName() + " chat banned for " + expirationTime + " minutes."); BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat banned for " + expirationTime + " minutes.");
} }
else else
{ {
activeChar.sendMessage("Player " + player.getName() + " chat banned forever."); BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat banned forever.");
} }
player.sendMessage("Chat banned by moderator " + activeChar.getName());
player.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
} }
else else
{ {
activeChar.sendMessage("Player not found !"); BuilderUtil.sendSysMessage(activeChar, "Player not found!");
return false; return false;
} }
} }
break;
} }
else if (command.equals(VOICED_COMMANDS[1])) // unbanchat case "unbanchat":
case "chatunban":
{ {
if (params == null) if (params == null)
{ {
activeChar.sendMessage("Usage: .unbanchat name"); BuilderUtil.sendSysMessage(activeChar, "Usage: .unbanchat name");
return true; return true;
} }
final StringTokenizer st = new StringTokenizer(params); final StringTokenizer st = new StringTokenizer(params);
@ -133,26 +142,28 @@ public class ChatAdmin implements IVoicedCommandHandler
final L2PcInstance player = L2World.getInstance().getPlayer(objId); final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player == null) || !player.isOnline()) if ((player == null) || !player.isOnline())
{ {
activeChar.sendMessage("Player not online !"); BuilderUtil.sendSysMessage(activeChar, "Player not online!");
return false; return false;
} }
if (!player.isChatBanned()) if (!player.isChatBanned())
{ {
activeChar.sendMessage("Player is not chat banned !"); BuilderUtil.sendSysMessage(activeChar, "Player is not chat banned!");
return false; return false;
} }
PunishmentManager.getInstance().stopPunishment(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN); PunishmentManager.getInstance().stopPunishment(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN);
BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat unbanned.");
activeChar.sendMessage("Player " + player.getName() + " chat unbanned.");
player.sendMessage("Chat unbanned by moderator " + activeChar.getName()); player.sendMessage("Chat unbanned by moderator " + activeChar.getName());
player.getEffectList().stopAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
} }
else else
{ {
activeChar.sendMessage("Player not found !"); BuilderUtil.sendSysMessage(activeChar, "Player not found!");
return false; return false;
} }
} }
break;
}
} }
return true; return true;
} }

View File

@ -2560,7 +2560,7 @@ public final class Config
// Load ChatModeration config file (if exists) // Load ChatModeration config file (if exists)
final PropertiesParser ChatModeration = new PropertiesParser(CUSTOM_CHAT_MODERATION_CONFIG_FILE); final PropertiesParser ChatModeration = new PropertiesParser(CUSTOM_CHAT_MODERATION_CONFIG_FILE);
CHAT_ADMIN = ChatModeration.getBoolean("ChatAdmin", false); CHAT_ADMIN = ChatModeration.getBoolean("ChatAdmin", true);
// Load CommunityBoard config file (if exists) // Load CommunityBoard config file (if exists)
final PropertiesParser CommunityBoard = new PropertiesParser(CUSTOM_COMMUNITY_BOARD_CONFIG_FILE); final PropertiesParser CommunityBoard = new PropertiesParser(CUSTOM_COMMUNITY_BOARD_CONFIG_FILE);

View File

@ -30,6 +30,9 @@ import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.handler.IPunishmentHandler; import com.l2jmobius.gameserver.handler.IPunishmentHandler;
import com.l2jmobius.gameserver.handler.PunishmentHandler; import com.l2jmobius.gameserver.handler.PunishmentHandler;
import com.l2jmobius.gameserver.instancemanager.PunishmentManager; import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
/** /**
* @author UnAfraid * @author UnAfraid
@ -234,6 +237,15 @@ public class PunishmentTask implements Runnable
} }
} }
if (_type.equals(PunishmentType.CHAT_BAN) && _affect.equals(PunishmentAffect.CHARACTER))
{
final L2PcInstance player = L2World.getInstance().getPlayer(Integer.valueOf(_key));
if (player != null)
{
player.getEffectList().stopAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
}
}
final IPunishmentHandler handler = PunishmentHandler.getInstance().getHandler(_type); final IPunishmentHandler handler = PunishmentHandler.getInstance().getHandler(_type);
if (handler != null) if (handler != null)
{ {

View File

@ -268,6 +268,12 @@ public class EnterWorld implements IClientIncomingPacket
} }
} }
// Chat banned icon.
if (activeChar.isChatBanned())
{
activeChar.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
}
// Set dead status if applies // Set dead status if applies
if (activeChar.getCurrentHp() < 0.5) if (activeChar.getCurrentHp() < 0.5)
{ {

View File

@ -27,6 +27,8 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect; import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentTask; import com.l2jmobius.gameserver.model.punishment.PunishmentTask;
import com.l2jmobius.gameserver.model.punishment.PunishmentType; import com.l2jmobius.gameserver.model.punishment.PunishmentType;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util; import com.l2jmobius.gameserver.util.Util;
public class ChatAdmin implements IVoicedCommandHandler public class ChatAdmin implements IVoicedCommandHandler
@ -34,7 +36,9 @@ public class ChatAdmin implements IVoicedCommandHandler
private static final String[] VOICED_COMMANDS = private static final String[] VOICED_COMMANDS =
{ {
"banchat", "banchat",
"unbanchat" "chatban",
"unbanchat",
"chatunban"
}; };
@Override @Override
@ -45,11 +49,14 @@ public class ChatAdmin implements IVoicedCommandHandler
return false; return false;
} }
if (command.equals(VOICED_COMMANDS[0])) // banchat switch (command)
{
case "banchat":
case "chatban":
{ {
if (params == null) if (params == null)
{ {
activeChar.sendMessage("Usage: .banchat name [minutes]"); BuilderUtil.sendSysMessage(activeChar, "Usage: .banchat name [minutes]");
return true; return true;
} }
final StringTokenizer st = new StringTokenizer(params); final StringTokenizer st = new StringTokenizer(params);
@ -62,7 +69,7 @@ public class ChatAdmin implements IVoicedCommandHandler
final String token = st.nextToken(); final String token = st.nextToken();
if (Util.isDigit(token)) if (Util.isDigit(token))
{ {
expirationTime = System.currentTimeMillis() + (Integer.parseInt(st.nextToken()) * 60 * 1000); expirationTime = Integer.parseInt(token);
} }
} }
@ -72,54 +79,56 @@ public class ChatAdmin implements IVoicedCommandHandler
final L2PcInstance player = L2World.getInstance().getPlayer(objId); final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player == null) || !player.isOnline()) if ((player == null) || !player.isOnline())
{ {
activeChar.sendMessage("Player not online !"); BuilderUtil.sendSysMessage(activeChar, "Player not online!");
return false; return false;
} }
if (player.isChatBanned()) if (player.isChatBanned())
{ {
activeChar.sendMessage("Player is already punished !"); BuilderUtil.sendSysMessage(activeChar, "Player is already punished!");
return false; return false;
} }
if (player == activeChar) if (player == activeChar)
{ {
activeChar.sendMessage("You can't ban yourself !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban yourself!");
return false; return false;
} }
if (player.isGM()) if (player.isGM())
{ {
activeChar.sendMessage("You can't ban GM !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban a GM!");
return false; return false;
} }
if (AdminData.getInstance().hasAccess(command, player.getAccessLevel())) if (AdminData.getInstance().hasAccess(command, player.getAccessLevel()))
{ {
activeChar.sendMessage("You can't ban moderator !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban moderator!");
return false; return false;
} }
PunishmentManager.getInstance().startPunishment(new PunishmentTask(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, expirationTime, "Chat banned by moderator", activeChar.getName())); PunishmentManager.getInstance().startPunishment(new PunishmentTask(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, System.currentTimeMillis() + (expirationTime * 1000 * 60), "Chat banned by moderator", activeChar.getName()));
player.sendMessage("Chat banned by moderator " + activeChar.getName());
if (expirationTime > 0) if (expirationTime > 0)
{ {
activeChar.sendMessage("Player " + player.getName() + " chat banned for " + expirationTime + " minutes."); BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat banned for " + expirationTime + " minutes.");
} }
else else
{ {
activeChar.sendMessage("Player " + player.getName() + " chat banned forever."); BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat banned forever.");
} }
player.sendMessage("Chat banned by moderator " + activeChar.getName());
player.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
} }
else else
{ {
activeChar.sendMessage("Player not found !"); BuilderUtil.sendSysMessage(activeChar, "Player not found!");
return false; return false;
} }
} }
break;
} }
else if (command.equals(VOICED_COMMANDS[1])) // unbanchat case "unbanchat":
case "chatunban":
{ {
if (params == null) if (params == null)
{ {
activeChar.sendMessage("Usage: .unbanchat name"); BuilderUtil.sendSysMessage(activeChar, "Usage: .unbanchat name");
return true; return true;
} }
final StringTokenizer st = new StringTokenizer(params); final StringTokenizer st = new StringTokenizer(params);
@ -133,26 +142,28 @@ public class ChatAdmin implements IVoicedCommandHandler
final L2PcInstance player = L2World.getInstance().getPlayer(objId); final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player == null) || !player.isOnline()) if ((player == null) || !player.isOnline())
{ {
activeChar.sendMessage("Player not online !"); BuilderUtil.sendSysMessage(activeChar, "Player not online!");
return false; return false;
} }
if (!player.isChatBanned()) if (!player.isChatBanned())
{ {
activeChar.sendMessage("Player is not chat banned !"); BuilderUtil.sendSysMessage(activeChar, "Player is not chat banned!");
return false; return false;
} }
PunishmentManager.getInstance().stopPunishment(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN); PunishmentManager.getInstance().stopPunishment(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN);
BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat unbanned.");
activeChar.sendMessage("Player " + player.getName() + " chat unbanned.");
player.sendMessage("Chat unbanned by moderator " + activeChar.getName()); player.sendMessage("Chat unbanned by moderator " + activeChar.getName());
player.getEffectList().stopAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
} }
else else
{ {
activeChar.sendMessage("Player not found !"); BuilderUtil.sendSysMessage(activeChar, "Player not found!");
return false; return false;
} }
} }
break;
}
} }
return true; return true;
} }

View File

@ -2558,7 +2558,7 @@ public final class Config
// Load ChatModeration config file (if exists) // Load ChatModeration config file (if exists)
final PropertiesParser ChatModeration = new PropertiesParser(CUSTOM_CHAT_MODERATION_CONFIG_FILE); final PropertiesParser ChatModeration = new PropertiesParser(CUSTOM_CHAT_MODERATION_CONFIG_FILE);
CHAT_ADMIN = ChatModeration.getBoolean("ChatAdmin", false); CHAT_ADMIN = ChatModeration.getBoolean("ChatAdmin", true);
// Load CommunityBoard config file (if exists) // Load CommunityBoard config file (if exists)
final PropertiesParser CommunityBoard = new PropertiesParser(CUSTOM_COMMUNITY_BOARD_CONFIG_FILE); final PropertiesParser CommunityBoard = new PropertiesParser(CUSTOM_COMMUNITY_BOARD_CONFIG_FILE);

View File

@ -30,6 +30,9 @@ import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.handler.IPunishmentHandler; import com.l2jmobius.gameserver.handler.IPunishmentHandler;
import com.l2jmobius.gameserver.handler.PunishmentHandler; import com.l2jmobius.gameserver.handler.PunishmentHandler;
import com.l2jmobius.gameserver.instancemanager.PunishmentManager; import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
/** /**
* @author UnAfraid * @author UnAfraid
@ -234,6 +237,15 @@ public class PunishmentTask implements Runnable
} }
} }
if (_type.equals(PunishmentType.CHAT_BAN) && _affect.equals(PunishmentAffect.CHARACTER))
{
final L2PcInstance player = L2World.getInstance().getPlayer(Integer.valueOf(_key));
if (player != null)
{
player.getEffectList().stopAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
}
}
final IPunishmentHandler handler = PunishmentHandler.getInstance().getHandler(_type); final IPunishmentHandler handler = PunishmentHandler.getInstance().getHandler(_type);
if (handler != null) if (handler != null)
{ {

View File

@ -268,6 +268,12 @@ public class EnterWorld implements IClientIncomingPacket
} }
} }
// Chat banned icon.
if (activeChar.isChatBanned())
{
activeChar.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
}
// Set dead status if applies // Set dead status if applies
if (activeChar.getCurrentHp() < 0.5) if (activeChar.getCurrentHp() < 0.5)
{ {

View File

@ -27,6 +27,7 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect; import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentTask; import com.l2jmobius.gameserver.model.punishment.PunishmentTask;
import com.l2jmobius.gameserver.model.punishment.PunishmentType; import com.l2jmobius.gameserver.model.punishment.PunishmentType;
import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util; import com.l2jmobius.gameserver.util.Util;
public class ChatAdmin implements IVoicedCommandHandler public class ChatAdmin implements IVoicedCommandHandler
@ -34,7 +35,9 @@ public class ChatAdmin implements IVoicedCommandHandler
private static final String[] VOICED_COMMANDS = private static final String[] VOICED_COMMANDS =
{ {
"banchat", "banchat",
"unbanchat" "chatban",
"unbanchat",
"chatunban"
}; };
@Override @Override
@ -45,11 +48,14 @@ public class ChatAdmin implements IVoicedCommandHandler
return false; return false;
} }
if (command.equals(VOICED_COMMANDS[0])) // banchat switch (command)
{
case "banchat":
case "chatban":
{ {
if (params == null) if (params == null)
{ {
activeChar.sendMessage("Usage: .banchat name [minutes]"); BuilderUtil.sendSysMessage(activeChar, "Usage: .banchat name [minutes]");
return true; return true;
} }
final StringTokenizer st = new StringTokenizer(params); final StringTokenizer st = new StringTokenizer(params);
@ -62,7 +68,7 @@ public class ChatAdmin implements IVoicedCommandHandler
final String token = st.nextToken(); final String token = st.nextToken();
if (Util.isDigit(token)) if (Util.isDigit(token))
{ {
expirationTime = System.currentTimeMillis() + (Integer.parseInt(st.nextToken()) * 60 * 1000); expirationTime = Integer.parseInt(token);
} }
} }
@ -72,54 +78,55 @@ public class ChatAdmin implements IVoicedCommandHandler
final L2PcInstance player = L2World.getInstance().getPlayer(objId); final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player == null) || !player.isOnline()) if ((player == null) || !player.isOnline())
{ {
activeChar.sendMessage("Player not online !"); BuilderUtil.sendSysMessage(activeChar, "Player not online!");
return false; return false;
} }
if (player.isChatBanned()) if (player.isChatBanned())
{ {
activeChar.sendMessage("Player is already punished !"); BuilderUtil.sendSysMessage(activeChar, "Player is already punished!");
return false; return false;
} }
if (player == activeChar) if (player == activeChar)
{ {
activeChar.sendMessage("You can't ban yourself !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban yourself!");
return false; return false;
} }
if (player.isGM()) if (player.isGM())
{ {
activeChar.sendMessage("You can't ban GM !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban a GM!");
return false; return false;
} }
if (AdminData.getInstance().hasAccess(command, player.getAccessLevel())) if (AdminData.getInstance().hasAccess(command, player.getAccessLevel()))
{ {
activeChar.sendMessage("You can't ban moderator !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban moderator!");
return false; return false;
} }
PunishmentManager.getInstance().startPunishment(new PunishmentTask(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, expirationTime, "Chat banned by moderator", activeChar.getName())); PunishmentManager.getInstance().startPunishment(new PunishmentTask(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, System.currentTimeMillis() + (expirationTime * 1000 * 60), "Chat banned by moderator", activeChar.getName()));
player.sendMessage("Chat banned by moderator " + activeChar.getName());
if (expirationTime > 0) if (expirationTime > 0)
{ {
activeChar.sendMessage("Player " + player.getName() + " chat banned for " + expirationTime + " minutes."); BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat banned for " + expirationTime + " minutes.");
} }
else else
{ {
activeChar.sendMessage("Player " + player.getName() + " chat banned forever."); BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat banned forever.");
} }
player.sendMessage("Chat banned by moderator " + activeChar.getName());
} }
else else
{ {
activeChar.sendMessage("Player not found !"); BuilderUtil.sendSysMessage(activeChar, "Player not found!");
return false; return false;
} }
} }
break;
} }
else if (command.equals(VOICED_COMMANDS[1])) // unbanchat case "unbanchat":
case "chatunban":
{ {
if (params == null) if (params == null)
{ {
activeChar.sendMessage("Usage: .unbanchat name"); BuilderUtil.sendSysMessage(activeChar, "Usage: .unbanchat name");
return true; return true;
} }
final StringTokenizer st = new StringTokenizer(params); final StringTokenizer st = new StringTokenizer(params);
@ -133,26 +140,27 @@ public class ChatAdmin implements IVoicedCommandHandler
final L2PcInstance player = L2World.getInstance().getPlayer(objId); final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player == null) || !player.isOnline()) if ((player == null) || !player.isOnline())
{ {
activeChar.sendMessage("Player not online !"); BuilderUtil.sendSysMessage(activeChar, "Player not online!");
return false; return false;
} }
if (!player.isChatBanned()) if (!player.isChatBanned())
{ {
activeChar.sendMessage("Player is not chat banned !"); BuilderUtil.sendSysMessage(activeChar, "Player is not chat banned!");
return false; return false;
} }
PunishmentManager.getInstance().stopPunishment(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN); PunishmentManager.getInstance().stopPunishment(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN);
BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat unbanned.");
activeChar.sendMessage("Player " + player.getName() + " chat unbanned.");
player.sendMessage("Chat unbanned by moderator " + activeChar.getName()); player.sendMessage("Chat unbanned by moderator " + activeChar.getName());
} }
else else
{ {
activeChar.sendMessage("Player not found !"); BuilderUtil.sendSysMessage(activeChar, "Player not found!");
return false; return false;
} }
} }
break;
}
} }
return true; return true;
} }

View File

@ -2702,7 +2702,7 @@ public final class Config
// Load ChatModeration config file (if exists) // Load ChatModeration config file (if exists)
final PropertiesParser ChatModeration = new PropertiesParser(CUSTOM_CHAT_MODERATION_CONFIG_FILE); final PropertiesParser ChatModeration = new PropertiesParser(CUSTOM_CHAT_MODERATION_CONFIG_FILE);
CHAT_ADMIN = ChatModeration.getBoolean("ChatAdmin", false); CHAT_ADMIN = ChatModeration.getBoolean("ChatAdmin", true);
// Load CommunityBoard config file (if exists) // Load CommunityBoard config file (if exists)
final PropertiesParser CommunityBoard = new PropertiesParser(CUSTOM_COMMUNITY_BOARD_CONFIG_FILE); final PropertiesParser CommunityBoard = new PropertiesParser(CUSTOM_COMMUNITY_BOARD_CONFIG_FILE);

View File

@ -27,6 +27,8 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect; import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentTask; import com.l2jmobius.gameserver.model.punishment.PunishmentTask;
import com.l2jmobius.gameserver.model.punishment.PunishmentType; import com.l2jmobius.gameserver.model.punishment.PunishmentType;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util; import com.l2jmobius.gameserver.util.Util;
public class ChatAdmin implements IVoicedCommandHandler public class ChatAdmin implements IVoicedCommandHandler
@ -34,7 +36,9 @@ public class ChatAdmin implements IVoicedCommandHandler
private static final String[] VOICED_COMMANDS = private static final String[] VOICED_COMMANDS =
{ {
"banchat", "banchat",
"unbanchat" "chatban",
"unbanchat",
"chatunban"
}; };
@Override @Override
@ -45,11 +49,14 @@ public class ChatAdmin implements IVoicedCommandHandler
return false; return false;
} }
if (command.equals(VOICED_COMMANDS[0])) // banchat switch (command)
{
case "banchat":
case "chatban":
{ {
if (params == null) if (params == null)
{ {
activeChar.sendMessage("Usage: .banchat name [minutes]"); BuilderUtil.sendSysMessage(activeChar, "Usage: .banchat name [minutes]");
return true; return true;
} }
final StringTokenizer st = new StringTokenizer(params); final StringTokenizer st = new StringTokenizer(params);
@ -62,7 +69,7 @@ public class ChatAdmin implements IVoicedCommandHandler
final String token = st.nextToken(); final String token = st.nextToken();
if (Util.isDigit(token)) if (Util.isDigit(token))
{ {
expirationTime = System.currentTimeMillis() + (Integer.parseInt(st.nextToken()) * 60 * 1000); expirationTime = Integer.parseInt(token);
} }
} }
@ -72,54 +79,56 @@ public class ChatAdmin implements IVoicedCommandHandler
final L2PcInstance player = L2World.getInstance().getPlayer(objId); final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player == null) || !player.isOnline()) if ((player == null) || !player.isOnline())
{ {
activeChar.sendMessage("Player not online !"); BuilderUtil.sendSysMessage(activeChar, "Player not online!");
return false; return false;
} }
if (player.isChatBanned()) if (player.isChatBanned())
{ {
activeChar.sendMessage("Player is already punished !"); BuilderUtil.sendSysMessage(activeChar, "Player is already punished!");
return false; return false;
} }
if (player == activeChar) if (player == activeChar)
{ {
activeChar.sendMessage("You can't ban yourself !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban yourself!");
return false; return false;
} }
if (player.isGM()) if (player.isGM())
{ {
activeChar.sendMessage("You can't ban GM !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban a GM!");
return false; return false;
} }
if (AdminData.getInstance().hasAccess(command, player.getAccessLevel())) if (AdminData.getInstance().hasAccess(command, player.getAccessLevel()))
{ {
activeChar.sendMessage("You can't ban moderator !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban moderator!");
return false; return false;
} }
PunishmentManager.getInstance().startPunishment(new PunishmentTask(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, expirationTime, "Chat banned by moderator", activeChar.getName())); PunishmentManager.getInstance().startPunishment(new PunishmentTask(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, System.currentTimeMillis() + (expirationTime * 1000 * 60), "Chat banned by moderator", activeChar.getName()));
player.sendMessage("Chat banned by moderator " + activeChar.getName());
if (expirationTime > 0) if (expirationTime > 0)
{ {
activeChar.sendMessage("Player " + player.getName() + " chat banned for " + expirationTime + " minutes."); BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat banned for " + expirationTime + " minutes.");
} }
else else
{ {
activeChar.sendMessage("Player " + player.getName() + " chat banned forever."); BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat banned forever.");
} }
player.sendMessage("Chat banned by moderator " + activeChar.getName());
player.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
} }
else else
{ {
activeChar.sendMessage("Player not found !"); BuilderUtil.sendSysMessage(activeChar, "Player not found!");
return false; return false;
} }
} }
break;
} }
else if (command.equals(VOICED_COMMANDS[1])) // unbanchat case "unbanchat":
case "chatunban":
{ {
if (params == null) if (params == null)
{ {
activeChar.sendMessage("Usage: .unbanchat name"); BuilderUtil.sendSysMessage(activeChar, "Usage: .unbanchat name");
return true; return true;
} }
final StringTokenizer st = new StringTokenizer(params); final StringTokenizer st = new StringTokenizer(params);
@ -133,26 +142,28 @@ public class ChatAdmin implements IVoicedCommandHandler
final L2PcInstance player = L2World.getInstance().getPlayer(objId); final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player == null) || !player.isOnline()) if ((player == null) || !player.isOnline())
{ {
activeChar.sendMessage("Player not online !"); BuilderUtil.sendSysMessage(activeChar, "Player not online!");
return false; return false;
} }
if (!player.isChatBanned()) if (!player.isChatBanned())
{ {
activeChar.sendMessage("Player is not chat banned !"); BuilderUtil.sendSysMessage(activeChar, "Player is not chat banned!");
return false; return false;
} }
PunishmentManager.getInstance().stopPunishment(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN); PunishmentManager.getInstance().stopPunishment(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN);
BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat unbanned.");
activeChar.sendMessage("Player " + player.getName() + " chat unbanned.");
player.sendMessage("Chat unbanned by moderator " + activeChar.getName()); player.sendMessage("Chat unbanned by moderator " + activeChar.getName());
player.getEffectList().stopAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
} }
else else
{ {
activeChar.sendMessage("Player not found !"); BuilderUtil.sendSysMessage(activeChar, "Player not found!");
return false; return false;
} }
} }
break;
}
} }
return true; return true;
} }

View File

@ -2431,7 +2431,7 @@ public final class Config
// Load ChatModeration config file (if exists) // Load ChatModeration config file (if exists)
final PropertiesParser ChatModeration = new PropertiesParser(CUSTOM_CHAT_MODERATION_CONFIG_FILE); final PropertiesParser ChatModeration = new PropertiesParser(CUSTOM_CHAT_MODERATION_CONFIG_FILE);
CHAT_ADMIN = ChatModeration.getBoolean("ChatAdmin", false); CHAT_ADMIN = ChatModeration.getBoolean("ChatAdmin", true);
// Load CommunityBoard config file (if exists) // Load CommunityBoard config file (if exists)
final PropertiesParser CommunityBoard = new PropertiesParser(CUSTOM_COMMUNITY_BOARD_CONFIG_FILE); final PropertiesParser CommunityBoard = new PropertiesParser(CUSTOM_COMMUNITY_BOARD_CONFIG_FILE);

View File

@ -30,6 +30,9 @@ import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.handler.IPunishmentHandler; import com.l2jmobius.gameserver.handler.IPunishmentHandler;
import com.l2jmobius.gameserver.handler.PunishmentHandler; import com.l2jmobius.gameserver.handler.PunishmentHandler;
import com.l2jmobius.gameserver.instancemanager.PunishmentManager; import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
/** /**
* @author UnAfraid * @author UnAfraid
@ -234,6 +237,15 @@ public class PunishmentTask implements Runnable
} }
} }
if (_type.equals(PunishmentType.CHAT_BAN) && _affect.equals(PunishmentAffect.CHARACTER))
{
final L2PcInstance player = L2World.getInstance().getPlayer(Integer.valueOf(_key));
if (player != null)
{
player.getEffectList().stopAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
}
}
final IPunishmentHandler handler = PunishmentHandler.getInstance().getHandler(_type); final IPunishmentHandler handler = PunishmentHandler.getInstance().getHandler(_type);
if (handler != null) if (handler != null)
{ {

View File

@ -267,6 +267,12 @@ public class EnterWorld implements IClientIncomingPacket
} }
} }
// Chat banned icon.
if (activeChar.isChatBanned())
{
activeChar.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
}
// Set dead status if applies // Set dead status if applies
if (activeChar.getCurrentHp() < 0.5) if (activeChar.getCurrentHp() < 0.5)
{ {

View File

@ -27,6 +27,8 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect; import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentTask; import com.l2jmobius.gameserver.model.punishment.PunishmentTask;
import com.l2jmobius.gameserver.model.punishment.PunishmentType; import com.l2jmobius.gameserver.model.punishment.PunishmentType;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util; import com.l2jmobius.gameserver.util.Util;
public class ChatAdmin implements IVoicedCommandHandler public class ChatAdmin implements IVoicedCommandHandler
@ -34,7 +36,9 @@ public class ChatAdmin implements IVoicedCommandHandler
private static final String[] VOICED_COMMANDS = private static final String[] VOICED_COMMANDS =
{ {
"banchat", "banchat",
"unbanchat" "chatban",
"unbanchat",
"chatunban"
}; };
@Override @Override
@ -45,11 +49,14 @@ public class ChatAdmin implements IVoicedCommandHandler
return false; return false;
} }
if (command.equals(VOICED_COMMANDS[0])) // banchat switch (command)
{
case "banchat":
case "chatban":
{ {
if (params == null) if (params == null)
{ {
activeChar.sendMessage("Usage: .banchat name [minutes]"); BuilderUtil.sendSysMessage(activeChar, "Usage: .banchat name [minutes]");
return true; return true;
} }
final StringTokenizer st = new StringTokenizer(params); final StringTokenizer st = new StringTokenizer(params);
@ -62,7 +69,7 @@ public class ChatAdmin implements IVoicedCommandHandler
final String token = st.nextToken(); final String token = st.nextToken();
if (Util.isDigit(token)) if (Util.isDigit(token))
{ {
expirationTime = System.currentTimeMillis() + (Integer.parseInt(st.nextToken()) * 60 * 1000); expirationTime = Integer.parseInt(token);
} }
} }
@ -72,54 +79,56 @@ public class ChatAdmin implements IVoicedCommandHandler
final L2PcInstance player = L2World.getInstance().getPlayer(objId); final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player == null) || !player.isOnline()) if ((player == null) || !player.isOnline())
{ {
activeChar.sendMessage("Player not online !"); BuilderUtil.sendSysMessage(activeChar, "Player not online!");
return false; return false;
} }
if (player.isChatBanned()) if (player.isChatBanned())
{ {
activeChar.sendMessage("Player is already punished !"); BuilderUtil.sendSysMessage(activeChar, "Player is already punished!");
return false; return false;
} }
if (player == activeChar) if (player == activeChar)
{ {
activeChar.sendMessage("You can't ban yourself !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban yourself!");
return false; return false;
} }
if (player.isGM()) if (player.isGM())
{ {
activeChar.sendMessage("You can't ban GM !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban a GM!");
return false; return false;
} }
if (AdminData.getInstance().hasAccess(command, player.getAccessLevel())) if (AdminData.getInstance().hasAccess(command, player.getAccessLevel()))
{ {
activeChar.sendMessage("You can't ban moderator !"); BuilderUtil.sendSysMessage(activeChar, "You can't ban moderator!");
return false; return false;
} }
PunishmentManager.getInstance().startPunishment(new PunishmentTask(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, expirationTime, "Chat banned by moderator", activeChar.getName())); PunishmentManager.getInstance().startPunishment(new PunishmentTask(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, System.currentTimeMillis() + (expirationTime * 1000 * 60), "Chat banned by moderator", activeChar.getName()));
player.sendMessage("Chat banned by moderator " + activeChar.getName());
if (expirationTime > 0) if (expirationTime > 0)
{ {
activeChar.sendMessage("Player " + player.getName() + " chat banned for " + expirationTime + " minutes."); BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat banned for " + expirationTime + " minutes.");
} }
else else
{ {
activeChar.sendMessage("Player " + player.getName() + " chat banned forever."); BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat banned forever.");
} }
player.sendMessage("Chat banned by moderator " + activeChar.getName());
player.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
} }
else else
{ {
activeChar.sendMessage("Player not found !"); BuilderUtil.sendSysMessage(activeChar, "Player not found!");
return false; return false;
} }
} }
break;
} }
else if (command.equals(VOICED_COMMANDS[1])) // unbanchat case "unbanchat":
case "chatunban":
{ {
if (params == null) if (params == null)
{ {
activeChar.sendMessage("Usage: .unbanchat name"); BuilderUtil.sendSysMessage(activeChar, "Usage: .unbanchat name");
return true; return true;
} }
final StringTokenizer st = new StringTokenizer(params); final StringTokenizer st = new StringTokenizer(params);
@ -133,26 +142,28 @@ public class ChatAdmin implements IVoicedCommandHandler
final L2PcInstance player = L2World.getInstance().getPlayer(objId); final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player == null) || !player.isOnline()) if ((player == null) || !player.isOnline())
{ {
activeChar.sendMessage("Player not online !"); BuilderUtil.sendSysMessage(activeChar, "Player not online!");
return false; return false;
} }
if (!player.isChatBanned()) if (!player.isChatBanned())
{ {
activeChar.sendMessage("Player is not chat banned !"); BuilderUtil.sendSysMessage(activeChar, "Player is not chat banned!");
return false; return false;
} }
PunishmentManager.getInstance().stopPunishment(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN); PunishmentManager.getInstance().stopPunishment(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN);
BuilderUtil.sendSysMessage(activeChar, "Player " + player.getName() + " chat unbanned.");
activeChar.sendMessage("Player " + player.getName() + " chat unbanned.");
player.sendMessage("Chat unbanned by moderator " + activeChar.getName()); player.sendMessage("Chat unbanned by moderator " + activeChar.getName());
player.getEffectList().stopAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
} }
else else
{ {
activeChar.sendMessage("Player not found !"); BuilderUtil.sendSysMessage(activeChar, "Player not found!");
return false; return false;
} }
} }
break;
}
} }
return true; return true;
} }

View File

@ -2438,7 +2438,7 @@ public final class Config
// Load ChatModeration config file (if exists) // Load ChatModeration config file (if exists)
final PropertiesParser ChatModeration = new PropertiesParser(CUSTOM_CHAT_MODERATION_CONFIG_FILE); final PropertiesParser ChatModeration = new PropertiesParser(CUSTOM_CHAT_MODERATION_CONFIG_FILE);
CHAT_ADMIN = ChatModeration.getBoolean("ChatAdmin", false); CHAT_ADMIN = ChatModeration.getBoolean("ChatAdmin", true);
// Load CommunityBoard config file (if exists) // Load CommunityBoard config file (if exists)
final PropertiesParser CommunityBoard = new PropertiesParser(CUSTOM_COMMUNITY_BOARD_CONFIG_FILE); final PropertiesParser CommunityBoard = new PropertiesParser(CUSTOM_COMMUNITY_BOARD_CONFIG_FILE);

View File

@ -30,6 +30,9 @@ import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.handler.IPunishmentHandler; import com.l2jmobius.gameserver.handler.IPunishmentHandler;
import com.l2jmobius.gameserver.handler.PunishmentHandler; import com.l2jmobius.gameserver.handler.PunishmentHandler;
import com.l2jmobius.gameserver.instancemanager.PunishmentManager; import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
/** /**
* @author UnAfraid * @author UnAfraid
@ -234,6 +237,15 @@ public class PunishmentTask implements Runnable
} }
} }
if (_type.equals(PunishmentType.CHAT_BAN) && _affect.equals(PunishmentAffect.CHARACTER))
{
final L2PcInstance player = L2World.getInstance().getPlayer(Integer.valueOf(_key));
if (player != null)
{
player.getEffectList().stopAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
}
}
final IPunishmentHandler handler = PunishmentHandler.getInstance().getHandler(_type); final IPunishmentHandler handler = PunishmentHandler.getInstance().getHandler(_type);
if (handler != null) if (handler != null)
{ {

View File

@ -267,6 +267,12 @@ public class EnterWorld implements IClientIncomingPacket
} }
} }
// Chat banned icon.
if (activeChar.isChatBanned())
{
activeChar.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
}
// Set dead status if applies // Set dead status if applies
if (activeChar.getCurrentHp() < 0.5) if (activeChar.getCurrentHp() < 0.5)
{ {