Implemented HWID punishment affect.

This commit is contained in:
MobiusDevelopment
2021-08-06 17:20:31 +00:00
parent 9130a64259
commit d5387bb853
238 changed files with 3875 additions and 287 deletions

View File

@@ -12,6 +12,7 @@
<a action="bypass -h admin_punishment info %acc% ACCOUNT">Punishments for account: %acc%</a><br1>
<a action="bypass -h admin_punishment info %char% CHARACTER">Punishments for character: %char%</a><br1>
<a action="bypass -h admin_punishment info %ip% IP">Punishments for IP: %ip%</a><br1>
<a action="bypass -h admin_punishment info %hwid% HWID">Punishments for HWID: %hwid%</a><br1>
<br>
<table width=280 bgcolor="666666" cellspacing="0" cellpadding="6">
<tr>
@@ -41,6 +42,11 @@
<td>%ip%</td>
<td><a action="bypass -h admin_punishment_add %ip% IP $punishmentType $expiration $reason">Ban</a></td>
</tr>
<tr>
<td>HWID:</td>
<td>%hwid%</td>
<td><a action="bypass -h admin_punishment_add %hwid% HWID $punishmentType $expiration $reason">Ban</a></td>
</tr>
</table>
</center>
<br>

View File

@@ -51,6 +51,11 @@
<td><edit var="ip" width="130" height="12"></td>
<td><a action="bypass -h admin_punishment_add $ip IP $punishmentType $expiration $reason">Ban</a></td>
</tr>
<tr>
<td>HWID:</td>
<td><edit var="hwid" width="130" height="12"></td>
<td><a action="bypass -h admin_punishment_add $hwid HWID $punishmentType $expiration $reason">Ban</a></td>
</tr>
</table>
</center>
<br>

View File

@@ -54,6 +54,8 @@ public class AdminPunishment implements IAdminCommandHandler
"admin_punishment_remove",
"admin_ban_acc",
"admin_unban_acc",
"admin_ban_hwid",
"admin_unban_hwid",
"admin_ban_chat",
"admin_unban_chat",
"admin_ban_char",
@@ -182,6 +184,7 @@ public class AdminPunishment implements IAdminCommandHandler
content = content.replace("%acc%", target.getAccountName());
content = content.replace("%char%", target.getName());
content = content.replace("%ip%", target.getIPAddress());
content = content.replace("%hwid%", (target.getClient() == null) || (target.getClient().getHardwareInfo() == null) ? "Unknown" : target.getClient().getHardwareInfo().getMacAddress());
activeChar.sendPacket(new NpcHtmlMessage(0, 1, content));
}
else
@@ -355,6 +358,22 @@ public class AdminPunishment implements IAdminCommandHandler
}
break;
}
case "admin_ban_hwid":
{
if (st.hasMoreTokens())
{
return useAdminCommand(String.format("admin_punishment_add %s %s %s %s %s", st.nextToken(), PunishmentAffect.HWID, PunishmentType.BAN, 0, "Banned by admin"), activeChar);
}
break;
}
case "admin_unban_hwid":
{
if (st.hasMoreTokens())
{
return useAdminCommand(String.format("admin_punishment_remove %s %s %s", st.nextToken(), PunishmentAffect.HWID, PunishmentType.BAN), activeChar);
}
break;
}
case "admin_ban_chat":
{
if (st.hasMoreTokens())

View File

@@ -76,6 +76,19 @@ public class BanHandler implements IPunishmentHandler
}
break;
}
case HWID:
{
final String hwid = String.valueOf(task.getKey());
for (PlayerInstance player : World.getInstance().getPlayers())
{
final GameClient client = player.getClient();
if ((client != null) && client.getHardwareInfo().getMacAddress().equals(hwid))
{
applyToPlayer(player);
}
}
break;
}
}
}

View File

@@ -73,6 +73,19 @@ public class ChatBanHandler implements IPunishmentHandler
}
break;
}
case HWID:
{
final String hwid = String.valueOf(task.getKey());
for (PlayerInstance player : World.getInstance().getPlayers())
{
final GameClient client = player.getClient();
if ((client != null) && client.getHardwareInfo().getMacAddress().equals(hwid))
{
applyToPlayer(task, player);
}
}
break;
}
}
}
@@ -117,6 +130,19 @@ public class ChatBanHandler implements IPunishmentHandler
}
break;
}
case HWID:
{
final String hwid = String.valueOf(task.getKey());
for (PlayerInstance player : World.getInstance().getPlayers())
{
final GameClient client = player.getClient();
if ((client != null) && client.getHardwareInfo().getMacAddress().equals(hwid))
{
removeFromPlayer(player);
}
}
break;
}
}
}
@@ -127,7 +153,7 @@ public class ChatBanHandler implements IPunishmentHandler
*/
private void applyToPlayer(PunishmentTask task, PlayerInstance player)
{
final long delay = ((task.getExpirationTime() - Chronos.currentTimeMillis()) / 1000);
final long delay = (task.getExpirationTime() - Chronos.currentTimeMillis()) / 1000;
if (delay > 0)
{
player.sendMessage("You've been chat banned for " + (delay > 60 ? ((delay / 60) + " minutes.") : delay + " seconds."));

View File

@@ -102,6 +102,19 @@ public class JailHandler implements IPunishmentHandler
}
break;
}
case HWID:
{
final String hwid = String.valueOf(task.getKey());
for (PlayerInstance player : World.getInstance().getPlayers())
{
final GameClient client = player.getClient();
if ((client != null) && client.getHardwareInfo().getMacAddress().equals(hwid))
{
applyToPlayer(task, player);
}
}
break;
}
}
}
@@ -146,6 +159,19 @@ public class JailHandler implements IPunishmentHandler
}
break;
}
case HWID:
{
final String hwid = String.valueOf(task.getKey());
for (PlayerInstance player : World.getInstance().getPlayers())
{
final GameClient client = player.getClient();
if ((client != null) && client.getHardwareInfo().getMacAddress().equals(hwid))
{
removeFromPlayer(player);
}
}
break;
}
}
}
@@ -181,7 +207,7 @@ public class JailHandler implements IPunishmentHandler
player.sendPacket(msg);
if (task != null)
{
final long delay = ((task.getExpirationTime() - Chronos.currentTimeMillis()) / 1000);
final long delay = (task.getExpirationTime() - Chronos.currentTimeMillis()) / 1000;
if (delay > 0)
{
player.sendMessage("You've been jailed for " + (delay > 60 ? ((delay / 60) + " minutes.") : delay + " seconds."));

View File

@@ -11222,7 +11222,10 @@ public class PlayerInstance extends Playable
*/
public boolean isJailed()
{
return PunishmentManager.getInstance().hasPunishment(getObjectId(), PunishmentAffect.CHARACTER, PunishmentType.JAIL) || PunishmentManager.getInstance().hasPunishment(getAccountName(), PunishmentAffect.ACCOUNT, PunishmentType.JAIL) || PunishmentManager.getInstance().hasPunishment(getIPAddress(), PunishmentAffect.IP, PunishmentType.JAIL);
return PunishmentManager.getInstance().hasPunishment(getObjectId(), PunishmentAffect.CHARACTER, PunishmentType.JAIL) //
|| PunishmentManager.getInstance().hasPunishment(getAccountName(), PunishmentAffect.ACCOUNT, PunishmentType.JAIL) //
|| PunishmentManager.getInstance().hasPunishment(getIPAddress(), PunishmentAffect.IP, PunishmentType.JAIL) //
|| ((_client.getHardwareInfo() != null) && PunishmentManager.getInstance().hasPunishment(_client.getHardwareInfo().getMacAddress(), PunishmentAffect.HWID, PunishmentType.JAIL));
}
/**
@@ -11230,7 +11233,10 @@ public class PlayerInstance extends Playable
*/
public boolean isChatBanned()
{
return PunishmentManager.getInstance().hasPunishment(getObjectId(), PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN) || PunishmentManager.getInstance().hasPunishment(getAccountName(), PunishmentAffect.ACCOUNT, PunishmentType.CHAT_BAN) || PunishmentManager.getInstance().hasPunishment(getIPAddress(), PunishmentAffect.IP, PunishmentType.CHAT_BAN);
return PunishmentManager.getInstance().hasPunishment(getObjectId(), PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN) //
|| PunishmentManager.getInstance().hasPunishment(getAccountName(), PunishmentAffect.ACCOUNT, PunishmentType.CHAT_BAN) //
|| PunishmentManager.getInstance().hasPunishment(getIPAddress(), PunishmentAffect.IP, PunishmentType.CHAT_BAN) //
|| ((_client.getHardwareInfo() != null) && PunishmentManager.getInstance().hasPunishment(_client.getHardwareInfo().getMacAddress(), PunishmentAffect.HWID, PunishmentType.CHAT_BAN));
}
public void startFameTask(long delay, int fameFixRate)

View File

@@ -23,8 +23,8 @@ public enum PunishmentAffect
{
ACCOUNT,
CHARACTER,
IP;
// HWID; Not implemented yet.
IP,
HWID;
public static PunishmentAffect getByName(String name)
{

View File

@@ -101,7 +101,9 @@ public class CharacterSelect implements IClientIncomingPacket
}
// Banned?
if (PunishmentManager.getInstance().hasPunishment(info.getObjectId(), PunishmentAffect.CHARACTER, PunishmentType.BAN) || PunishmentManager.getInstance().hasPunishment(client.getAccountName(), PunishmentAffect.ACCOUNT, PunishmentType.BAN) || PunishmentManager.getInstance().hasPunishment(client.getConnectionAddress().getHostAddress(), PunishmentAffect.IP, PunishmentType.BAN))
if (PunishmentManager.getInstance().hasPunishment(info.getObjectId(), PunishmentAffect.CHARACTER, PunishmentType.BAN) //
|| PunishmentManager.getInstance().hasPunishment(client.getAccountName(), PunishmentAffect.ACCOUNT, PunishmentType.BAN) //
|| PunishmentManager.getInstance().hasPunishment(client.getConnectionAddress().getHostAddress(), PunishmentAffect.IP, PunishmentType.BAN))
{
client.close(ServerClose.STATIC_PACKET);
return;

View File

@@ -41,6 +41,7 @@ import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
import org.l2jmobius.gameserver.instancemanager.MailManager;
import org.l2jmobius.gameserver.instancemanager.PetitionManager;
import org.l2jmobius.gameserver.instancemanager.PunishmentManager;
import org.l2jmobius.gameserver.instancemanager.ServerRestartManager;
import org.l2jmobius.gameserver.instancemanager.SiegeManager;
import org.l2jmobius.gameserver.instancemanager.events.GameEvent;
@@ -53,6 +54,8 @@ import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.residences.ClanHall;
import org.l2jmobius.gameserver.model.siege.Fort;
@@ -239,12 +242,6 @@ public class EnterWorld implements IClientIncomingPacket
}
}
// Chat banned icon.
if (player.isChatBanned())
{
player.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
}
// Set dead status if applies
if (player.getCurrentHp() < 0.5)
{
@@ -660,6 +657,7 @@ public class EnterWorld implements IClientIncomingPacket
}
}
// Delayed HWID checks.
if (Config.HARDWARE_INFO_ENABLED)
{
ThreadPool.schedule(() ->
@@ -705,6 +703,13 @@ public class EnterWorld implements IClientIncomingPacket
}
}
// Banned?
if ((hwInfo != null) && PunishmentManager.getInstance().hasPunishment(hwInfo.getMacAddress(), PunishmentAffect.HWID, PunishmentType.BAN))
{
Disconnection.of(client).defaultSequence(false);
return;
}
// Check max players.
if (Config.KICK_MISSING_HWID && (hwInfo == null))
{
@@ -727,6 +732,15 @@ public class EnterWorld implements IClientIncomingPacket
}
}, 5000);
}
// Chat banned icon.
ThreadPool.schedule(() ->
{
if (player.isChatBanned())
{
player.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.NO_CHAT);
}
}, 5500);
}
/**