Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 65)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
- @@ -33,6 +33,7 @@
- import net.sf.l2j.gameserver.model.L2Clan;
- import net.sf.l2j.gameserver.model.L2World;
- import net.sf.l2j.gameserver.model.actor.L2Character;
- +import net.sf.l2j.gameserver.model.actor.ipCatcher;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- import net.sf.l2j.gameserver.model.entity.ClanHall;
- import net.sf.l2j.gameserver.model.entity.Couple;
- @@ -175,6 +176,10 @@
- if (Config.ALLOW_WEDDING)
- engage(activeChar);
- + final ipCatcher ipc = new ipCatcher();
- + if(ipc.isCatched(activeChar))
- + activeChar.logout();
- +
- // Announcements, welcome & Seven signs period messages
- activeChar.sendPacket(SystemMessageId.WELCOME_TO_LINEAGE);
- SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
- Index: java/net/sf/l2j/gameserver/model/actor/ipCatcher.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/ipCatcher.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/actor/ipCatcher.java (revision 0)
- @@ -0,0 +1,192 @@
- +package net.sf.l2j.gameserver.model.actor;
- +
- +import java.io.File;
- +import java.io.FileReader;
- +import java.io.FileWriter;
- +import java.io.IOException;
- +import java.io.LineNumberReader;
- +import java.net.InetAddress;
- +import java.net.NetworkInterface;
- +import java.net.SocketException;
- +import java.net.UnknownHostException;
- +import java.util.StringTokenizer;
- +
- +import javolution.util.FastList;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +/**
- + * @author AbsolutePower
- + */
- +public class ipCatcher
- +{
- + public static FastList<String> ips = new FastList<>();
- + static File file = new File("data/ips.txt");
- +
- + public String getMacAddr(L2PcInstance p)
- + {
- + StringBuilder sb = new StringBuilder();
- + byte[] mac = null;
- +
- + if(p != null)
- + try
- + {
- +
- + @SuppressWarnings("static-access")
- + final InetAddress ip = p.getClient().getConnection().getInetAddress().getLocalHost();
- + NetworkInterface network = NetworkInterface.getByInetAddress(ip);
- +
- + if(network !=null)
- + {
- + mac = network.getHardwareAddress();
- + }
- +
- + if(mac!=null)
- + {
- + for (int i = 0; i < mac.length; i++)
- + {
- + sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
- + }
- + }
- + else
- + sb.append("No mac found");
- +
- + }
- + catch (SocketException e)
- + {
- +
- + e.printStackTrace();
- +
- + }
- + catch (UnknownHostException e)
- + {
- + e.printStackTrace();
- + }
- +
- + return sb.toString();
- + }
- +
- + public String getIp(L2PcInstance p)
- + {
- + return p.getClient().getConnection().getInetAddress().getHostAddress();
- + }
- +
- + //return true if catched :D
- + public boolean isCatched(L2PcInstance p)
- + {
- + if(ips.contains(getMacAddr(p)) || ips.contains(getIp(p)))
- + return true;
- +
- + return false;
- + }
- +
- + //make textfile if not exist
- + public static void MkTiNe()
- + {
- + if(file == null)
- + file.mkdirs();
- + }
- +
- + public void addIp(L2PcInstance p)
- + {
- + MkTiNe();
- + final String ip = getIp(p);
- + final String name = p.getName();
- +
- + if(ip != null && name != null)
- + ips.add("Name");
- + ips.add(name);
- + ips.add("Ip");
- + ips.add(ip);
- + ips.add("Mac Addres");
- + ips.add(getMacAddr(p));
- + ips.add("-");
- +
- + FileWriter s = null;
- + try
- + {
- + s = new FileWriter(file);
- + for (int i = 0; i < ips.size(); i ++)
- + {
- + s.write(ips.get(i));
- + s.write("\r\n");
- + }
- + s.flush();
- + s.close();
- + s = null;
- + }
- + catch (IOException e)
- + {
- + e.printStackTrace();
- + }
- + ipsLoad();
- + }
- +
- + public void removeIp(L2PcInstance p)
- + {
- + final String ip = getIp(p);
- + final String name = p.getName();
- +
- + if(ip != null && name != null)
- + ips.remove("Name");
- + ips.remove(name);
- + ips.remove("Ip");
- + ips.remove(ip);
- + ips.remove("Mac Addres");
- + ips.remove(getMacAddr(p));
- + ips.remove("-");
- +
- + FileWriter s = null;
- + try
- + {
- + s = new FileWriter(file);
- + for (int i = 0; i < ips.size(); i ++)
- + {
- + s.write(ips.get(i));
- + s.write("\r\n");
- + }
- + s.flush();
- + s.close();
- + s = null;
- + }
- + catch (IOException e)
- + {
- + e.printStackTrace();
- + }
- + ipsLoad();
- + }
- +
- + public static void ipsLoad()
- + {
- + MkTiNe();
- + LineNumberReader l = null;
- + try
- + {
- + String line = null;
- + l = new LineNumberReader(new FileReader(file));
- + while ( (line = l.readLine()) != null)
- + {
- + StringTokenizer st = new StringTokenizer(line,"\n\r");
- + if (st.hasMoreTokens())
- + {
- + String n = st.nextToken();
- + ips.add(n);
- + }
- + }
- + }
- + catch(Exception e){
- + e.printStackTrace();
- + }
- + finally
- + {
- + try
- + {
- + if(l != null)
- + l.close();
- + }
- + catch (Exception e)
- + {
- + }
- + }
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 65)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -95,6 +95,7 @@
- import net.sf.l2j.gameserver.model.L2World;
- import net.sf.l2j.gameserver.model.PartyMatchRoomList;
- import net.sf.l2j.gameserver.model.PartyMatchWaitingList;
- +import net.sf.l2j.gameserver.model.actor.ipCatcher;
- import net.sf.l2j.gameserver.model.entity.AutoAnnouncement;
- import net.sf.l2j.gameserver.model.entity.Castle;
- import net.sf.l2j.gameserver.model.entity.Hero;
- @@ -293,7 +294,8 @@
- AutoAnnouncement.getInstance();
- if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS)
- OfflineTradersTable.restoreOfflineTraders();
- -
- + ipCatcher.ipsLoad();
- +
- Util.printSection("System");
- TaskManager.getInstance();
- Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminBan.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminBan.java (revision 65)
- +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminBan.java (working copy)
- @@ -24,6 +24,7 @@
- import net.sf.l2j.gameserver.LoginServerThread;
- import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
- import net.sf.l2j.gameserver.model.L2World;
- +import net.sf.l2j.gameserver.model.actor.ipCatcher;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.util.GMAudit;
- @@ -49,7 +50,9 @@
- "admin_unban_chat",
- "admin_jail",
- - "admin_unjail"
- + "admin_unjail",
- + "admin_permaban",
- + "admin_removeperma"
- };
- @Override
- @@ -131,6 +134,36 @@
- auditAction(command, activeChar, (targetPlayer == null ? player : targetPlayer.getName()));
- return changeCharAccessLevel(targetPlayer, player, activeChar, -100);
- }
- + else if (command.startsWith("admin_permaban"))
- + { if (targetPlayer == null && player.equals("")) {
- + activeChar.sendMessage("Usage: //permaban <char_name> (if none, target char is banned)");
- + return false;
- + }
- + final ipCatcher ipc = new ipCatcher();
- + if(targetPlayer!=null && !targetPlayer.isGM())
- + {
- + ipc.addIp(targetPlayer);
- + activeChar.sendMessage(targetPlayer.getName()+" banned permanently");
- + targetPlayer.sendMessage("You are banned permanently from " +activeChar.getName()+"!");
- + targetPlayer.sendMessage("if you will log out you won't be able to log in again!server gave you a opportunity to stay and ask for forgiveness!");
- + //targetPlayer.logout();
- + }
- + }
- + else if (command.startsWith("admin_removeperma"))
- + {
- + if (targetPlayer == null && player.equals(""))
- + {
- + activeChar.sendMessage("Usage: //removeperma <char_name> (if none, target char is unbanned)");
- + return false;
- + }
- + final ipCatcher ipc = new ipCatcher();
- + if(targetPlayer!=null)
- + {
- + ipc.removeIp(targetPlayer);
- + activeChar.sendMessage(targetPlayer.getName()+" permanently ban has been removed!");
- + targetPlayer.sendMessage("Your permanently ban has been removed from " +activeChar.getName()+"!");
- + }
- + }
- else if (command.startsWith("admin_ban_chat"))
- {
- if (targetPlayer == null && player.equals(""))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement