Implemented HWID punishment affect.
This commit is contained in:
		@@ -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>
 | 
			
		||||
 
 | 
			
		||||
@@ -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>
 | 
			
		||||
 
 | 
			
		||||
@@ -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())
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -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."));
 | 
			
		||||
 
 | 
			
		||||
@@ -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."));
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user