Jump to content

Recommended Posts

Posted (edited)

http://www.4shared.com/img/PnpeKHRNce/s25/157e7930310/image

http://www.4shared.com/rar/WiimsNndba/antibot.html Download data files

 

ACIS:

### Eclipse Workspace Patch 1.0
#P aCis_gameserver
Index: java/net/sf/l2j/gameserver/datatables/AntiBotTable.java
===================================================================
--- java/net/sf/l2j/gameserver/datatables/AntiBotTable.java	(revision 0)
+++ java/net/sf/l2j/gameserver/datatables/AntiBotTable.java	(revision 0)
@@ -0,0 +1,183 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.datatables;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import net.sf.l2j.gameserver.ThreadPoolManager;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.network.serverpackets.PledgeImage;
+import net.sf.l2j.util.Rnd;
+
+/**
+ * 
+ * @author Fissban
+ *
+ */
+public class AntiBotTable
+{
+	public static Logger _log = Logger.getLogger(AntiBotTable.class.getName());
+	
+	public static Map<Integer, antiBotData> _imageAntiBotOri = new HashMap<>();
+	public static Map<Integer, antiBotData> _imageAntiBotClient = new HashMap<>();
+	
+	public final static int[] img_antibot_id =
+	{
+		7000, 7001, 7002, 7003, 7004, 7005, 7006, 7007, 7008, 7009
+	};
+	
+	public void loadImage()
+	{
+		LoadImgAntiBot();
+		_log.log(Level.INFO, "loading " + _imageAntiBotOri.size() + " images of AntiBot");
+	}
+	
+	private static void LoadImgAntiBot()
+	{
+		_imageAntiBotOri.clear();
+		int cont = 0;
+		
+		for (int imgId : img_antibot_id)
+		{
+			File image = new File("data/images/antibot/" + imgId + ".dds");
+			_imageAntiBotOri.put(cont, new antiBotData(cont, ConverterImgBytes(image)));
+			cont++;
+		}
+		
+		ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new startEncriptCaptcha(), 100, 600000); // 10 Minutes
+	}
+	
+	public void sendImage(L2PcInstance player, int imgId)
+	{
+		PledgeImage packet = null;
+		
+		if ((imgId >= 50000) && (imgId <= 800000))
+		{
+			for (Entry<Integer, antiBotData> entrySet : _imageAntiBotClient.entrySet())
+			{
+				antiBotData imgCoding = entrySet.getValue();
+				
+				if (imgId == imgCoding.getCodificacion())
+				{
+					packet = new PledgeImage(imgId, imgCoding.getImagen());
+				}
+			}
+		}
+		
+		player.sendPacket(packet);
+	}
+	
+	public static class startEncriptCaptcha implements Runnable
+	{
+		public startEncriptCaptcha()
+		{
+			
+		}
+		
+		@Override
+		public void run()
+		{
+			_imageAntiBotClient.clear();
+			
+			for (Entry<Integer, antiBotData> entrySet : _imageAntiBotOri.entrySet())
+			{
+				entrySet.getValue().getImagen();
+				_imageAntiBotClient.put(entrySet.getKey(), new antiBotData(Rnd.get(50000, 800000), entrySet.getValue().getImagen()));
+			}
+		}
+	}
+	
+	public int getAntiBotClientID(int pos)
+	{
+		int returnCoding = 0;
+		
+		for (Entry<Integer, antiBotData> entrySet : _imageAntiBotClient.entrySet())
+		{
+			int numeroImage = entrySet.getKey().intValue(); 
+			
+			if (pos == numeroImage)
+			{
+				antiBotData imgCoding = entrySet.getValue();
+				returnCoding = imgCoding.getCodificacion();
+			}
+			
+			if (pos > 9)
+			{
+				_log.log(Level.SEVERE, "error in getAntiBotClientID...number dont exist");
+			}
+		}
+		return returnCoding;
+	}
+	
+	public static class antiBotData
+	{
+		int _codificacion;
+		byte[] _data;
+		
+		public antiBotData(int codificacion, byte[] data)
+		{
+			_codificacion = codificacion;
+			_data = data;
+		}
+		
+		public int getCodificacion()
+		{
+			return _codificacion;
+		}
+		
+		public byte[] getImagen()
+		{
+			return _data;
+		}
+	}
+	
+	private static byte[] ConverterImgBytes(File imagen)
+	{
+		ByteArrayOutputStream bos = new ByteArrayOutputStream();
+		
+		byte[] buffer = new byte[1024];
+		try (FileInputStream fis = new FileInputStream(imagen))
+		{
+			for (int readNum; (readNum = fis.read(buffer)) != -1;)
+			{
+				bos.write(buffer, 0, readNum);
+			}
+		}
+		catch (IOException e)
+		{
+			_log.log(Level.SEVERE, "Error when converter image to byte[]");
+		}
+		
+		return bos.toByteArray();
+	}
+	
+	public static AntiBotTable getInstance()
+	{
+		return SingletonHolder._instance;
+	}
+	
+	private static class SingletonHolder
+	{
+		protected static final AntiBotTable _instance = new AntiBotTable();
+	}
+}
Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java	(revision 13)
+++ java/net/sf/l2j/gameserver/GameServer.java	(working copy)
@@ -35,6 +35,7 @@
 import net.sf.l2j.gameserver.communitybbs.Manager.ForumsBBSManager;
 import net.sf.l2j.gameserver.datatables.AccessLevels;
 import net.sf.l2j.gameserver.datatables.AdminCommandAccessRights;
+import net.sf.l2j.gameserver.datatables.AntiBotTable;
 import net.sf.l2j.gameserver.datatables.ArmorSetsTable;
 import net.sf.l2j.gameserver.datatables.AugmentationData;
 import net.sf.l2j.gameserver.datatables.BookmarkTable;
@@ -309,6 +310,8 @@
 		
 		MovieMakerManager.getInstance();
 		
+		AntiBotTable.getInstance().loadImage();
+		
 		if (Config.DEADLOCK_DETECTOR)
 		{
 			_log.info("Deadlock detector is enabled. Timer: " + Config.DEADLOCK_CHECK_INTERVAL + "s.");
Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java	(revision 13)
+++ java/net/sf/l2j/Config.java	(working copy)
@@ -513,6 +513,13 @@
 	public static boolean STORE_SKILL_COOLTIME;
 	public static int BUFFS_MAX_AMOUNT;
 	
+	/** AntiBot */
+	public static boolean ANTIBOT_ENABLE;
+	public static int ANTIBOT_TIME_JAIL;
+	public static int ANTIBOT_TIME_VOTE;
+	public static int ANTIBOT_KILL_MOBS;
+	public static int ANTIBOT_MIN_LEVEL;
+	
 	// --------------------------------------------------
 	// Server
 	// --------------------------------------------------
@@ -1110,6 +1117,12 @@
 			BUFFS_MAX_AMOUNT = players.getProperty("MaxBuffsAmount", 20);
 			STORE_SKILL_COOLTIME = players.getProperty("StoreSkillCooltime", true);
 			
+			ANTIBOT_ENABLE = players.getProperty("AntiBotEnable", true);
+			ANTIBOT_TIME_JAIL = players.getProperty("AntiBotTimeJail", 1);
+			ANTIBOT_TIME_VOTE = players.getProperty("AntiBotTimeVote", 30);
+			ANTIBOT_KILL_MOBS = players.getProperty("AntiBotKillMobs", 1);
+			ANTIBOT_MIN_LEVEL = players.getProperty("AntiBotMinLevel", 1);				
+			
 			// server
 			ExProperties server = load(SERVER_FILE);
 			
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java	(revision 13)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java	(working copy)
@@ -179,6 +179,18 @@
 				final int arenaId = Integer.parseInt(_command.substring(12).trim());
 				activeChar.enterOlympiadObserverMode(arenaId);
 			}
+			else if (_command.startsWith("antibot"))
+			{
+				StringTokenizer st = new StringTokenizer(_command);
+				st.nextToken();
+				
+				if (st.hasMoreTokens())
+				{
+					activeChar.checkCode(st.nextToken());
+					return;
+				}
+				activeChar.checkCode("Fail");
+			}
 		}
 		catch (Exception e)
 		{
Index: java/net/sf/l2j/gameserver/network/clientpackets/Say2.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/Say2.java	(revision 13)
+++ java/net/sf/l2j/gameserver/network/clientpackets/Say2.java	(working copy)
@@ -49,6 +49,7 @@
 	public final static int PARTYROOM_COMMANDER = 15; // (Yellow)
 	public final static int PARTYROOM_ALL = 16; // (Red)
 	public final static int HERO_VOICE = 17;
+	public final static int CRITICAL_ANNOUNCE = 18;
 	
 	private final static String[] CHAT_NAMES =
 	{
@@ -69,7 +70,8 @@
 		"PARTYMATCH_ROOM",
 		"PARTYROOM_COMMANDER",
 		"PARTYROOM_ALL",
-		"HERO_VOICE"
+		"HERO_VOICE",
+		"CRITICAL_ANNOUNCE"
 	};
 	
 	private static final String[] WALKER_COMMAND_LIST =
Index: java/net/sf/l2j/gameserver/network/serverpackets/PledgeImage.java
===================================================================
--- java/net/sf/l2j/gameserver/network/serverpackets/PledgeImage.java	(revision 0)
+++ java/net/sf/l2j/gameserver/network/serverpackets/PledgeImage.java	(revision 0)
@@ -0,0 +1,44 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.network.serverpackets;
+
+public class PledgeImage extends L2GameServerPacket
+{
+	private final int _crestId;
+	private final byte[] _data;
+	
+	public PledgeImage(int crestId, byte[] data)
+	{
+		_crestId = crestId;
+		_data = data;
+	}
+	
+	@Override
+	protected final void writeImpl()
+	{
+		writeC(0x6c);
+		writeD(_crestId);
+		
+		if (_data != null)
+		{
+			writeD(_data.length);
+			writeB(_data);
+		}
+		else
+		{
+			writeD(0);
+		}
+	}
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 13)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -48,6 +48,7 @@
 import net.sf.l2j.gameserver.communitybbs.BB.Forum;
 import net.sf.l2j.gameserver.communitybbs.Manager.ForumsBBSManager;
 import net.sf.l2j.gameserver.datatables.AccessLevels;
+import net.sf.l2j.gameserver.datatables.AntiBotTable;
 import net.sf.l2j.gameserver.datatables.CharNameTable;
 import net.sf.l2j.gameserver.datatables.CharTemplateTable;
 import net.sf.l2j.gameserver.datatables.ClanTable;
@@ -157,12 +158,14 @@
 import net.sf.l2j.gameserver.model.zone.type.L2BossZone;
 import net.sf.l2j.gameserver.network.L2GameClient;
 import net.sf.l2j.gameserver.network.SystemMessageId;
+import net.sf.l2j.gameserver.network.clientpackets.Say2;
 import net.sf.l2j.gameserver.network.serverpackets.AbstractNpcInfo;
 import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
 import net.sf.l2j.gameserver.network.serverpackets.ChairSit;
 import net.sf.l2j.gameserver.network.serverpackets.ChangeWaitType;
 import net.sf.l2j.gameserver.network.serverpackets.CharInfo;
 import net.sf.l2j.gameserver.network.serverpackets.ConfirmDlg;
+import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
 import net.sf.l2j.gameserver.network.serverpackets.EtcStatusUpdate;
 import net.sf.l2j.gameserver.network.serverpackets.ExAutoSoulShot;
 import net.sf.l2j.gameserver.network.serverpackets.ExDuelUpdateUserInfo;
@@ -170,6 +173,7 @@
 import net.sf.l2j.gameserver.network.serverpackets.ExFishingStart;
 import net.sf.l2j.gameserver.network.serverpackets.ExOlympiadMode;
 import net.sf.l2j.gameserver.network.serverpackets.ExSetCompassZoneCode;
+import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
 import net.sf.l2j.gameserver.network.serverpackets.ExStorageMaxCount;
 import net.sf.l2j.gameserver.network.serverpackets.FriendList;
 import net.sf.l2j.gameserver.network.serverpackets.GetOnVehicle;
@@ -219,6 +223,7 @@
 import net.sf.l2j.gameserver.network.serverpackets.TradePressOwnOk;
 import net.sf.l2j.gameserver.network.serverpackets.TradeStart;
 import net.sf.l2j.gameserver.network.serverpackets.UserInfo;
+import net.sf.l2j.gameserver.skills.AbnormalEffect;
 import net.sf.l2j.gameserver.skills.Env;
 import net.sf.l2j.gameserver.skills.Formulas;
 import net.sf.l2j.gameserver.skills.Stats;
@@ -364,6 +369,11 @@
 		}
 	}
 	
+	private String _code = "";
+	private int _attempt = 0;
+	private int _mobs_dead = 0;
+	public static ScheduledFuture<?> _antiBotTask;
+	
 	private L2GameClient _client;
 	
 	private String _accountName;
@@ -10647,4 +10657,183 @@
 			}
 		}
 	}
+	
+	// AntiBoot
+	public void antibot()
+	{
+		increaseMobsDead();
+		
+		if (getMobsDead() >= Config.ANTIBOT_KILL_MOBS)
+		{
+			resetMobsDead();
+			_antiBotTask = ThreadPoolManager.getInstance().scheduleGeneral(new startAntiBotTask(), Config.ANTIBOT_TIME_VOTE * 1000);
+		}
+	}
+	
+	private static void stopAntiBotTask()
+	{
+		if (_antiBotTask != null)
+		{
+			_antiBotTask.cancel(false);
+			_antiBotTask = null;
+		}
+	}
+	
+	private class startAntiBotTask implements Runnable
+	{
+		public startAntiBotTask()
+		{
+			setIsParalyzed(true);
+			setIsInvul(true);
+			startAbnormalEffect(AbnormalEffect.FLOATING_ROOT);
+			sendPacket(new ExShowScreenMessage("[AntiBot]: You have " + Config.ANTIBOT_TIME_VOTE + " to confirm the Captcha!", 10000));
+			getActingPlayer().sendPacket(new CreatureSay(0, Say2.CRITICAL_ANNOUNCE, "[AntiBot]:", "You have " + Config.ANTIBOT_TIME_VOTE + " to confirm the Catpcha."));
+			showHtml_Start();
+		}
+		
+		@Override
+		public void run()
+		{
+			if (!isInJail())
+			{
+				sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "[AntiBot]:", "Your time limit has elapsed."));
+				increaseAttempt();
+				
+				if (getAttempt() >= 3)
+				{
+					setIsParalyzed(false);
+					setIsInvul(false);
+					startAbnormalEffect(AbnormalEffect.FLOATING_ROOT);
+					getActingPlayer().setPunishLevel(L2PcInstance.PunishLevel.JAIL, Config.ANTIBOT_TIME_JAIL);
+					getActingPlayer().sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "[AntiBot]:", "Character " + getName() + " jailed for " + Config.ANTIBOT_TIME_JAIL + " minutes."));
+					_log.warning("[AntiBot]: Character " + getName() + " jailed for " + Config.ANTIBOT_TIME_JAIL + " minutes.");
+				}
+				else
+				{
+					_antiBotTask = ThreadPoolManager.getInstance().scheduleGeneral(new startAntiBotTask(), Config.ANTIBOT_TIME_VOTE * 1000);
+				}
+			}
+		}
+	}
+	
+	public String num2img(int numero) 
+	{
+		String num = Integer.toString(numero);
+		char[] digitos = num.toCharArray();
+		
+		String tmp = "";
+		for(int x=0;x<num.length();x++) 
+		{
+			int dig = Integer.parseInt(Character.toString(digitos[x]));
+			final int it = AntiBotTable.getInstance().getAntiBotClientID(dig);
+			AntiBotTable.getInstance().sendImage(this, it);
+			tmp += "<img src=Crest.crest_" + Config.SERVER_ID + "_" + it + " width=38 height=33 align=left>";
+		}
+		
+		return tmp;
+	}
+	
+	public void showHtml_Start()
+	{
+		NpcHtmlMessage html = new NpcHtmlMessage(0);
+		html.setFile("data/html/antiBot/start.htm");
+		
+		html.replace("%playerName%", getName());
+		html.replace("%attemp%", String.valueOf(3 - getAttempt()));
+		int maxR = 3;
+		
+		String random = new String();
+		
+		for(int x = 0; x<maxR; x++)
+			random += Integer.toString(Rnd.get(0,9));
+		
+		html.replace("%code1%",num2img(Integer.parseInt(random)));
+				
+		this.sendPacket(html);
+		setCode(String.valueOf(Integer.parseInt(random)));
+	}
+	
+	public void showHtml_End()
+	{
+		NpcHtmlMessage html = new NpcHtmlMessage(0);
+		html.setFile("data/html/antiBot/end.htm");
+		html.replace("%playerName%", getName());
+		
+		this.sendPacket(html);
+	}
+	
+	public void checkCode(String code)
+	{
+		if (code.equals(getCode()))
+		{
+			stopAntiBotTask();
+			resetAttempt();
+			
+			sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "[AntiBot]:", "Congratulations, has passed control."));
+			setIsParalyzed(false);
+			setIsInvul(false);
+			stopAbnormalEffect(AbnormalEffect.FLOATING_ROOT);
+		}
+		else
+		{
+			stopAntiBotTask();
+			increaseAttempt();
+			
+			_antiBotTask = ThreadPoolManager.getInstance().scheduleGeneral(new startAntiBotTask(), Config.ANTIBOT_TIME_VOTE * 1000);
+		}
+		
+		if (getAttempt() >= 3)
+		{
+			stopAntiBotTask();
+			resetAttempt();
+			
+			setIsParalyzed(false);
+			setIsInvul(false);
+			startAbnormalEffect(AbnormalEffect.FLOATING_ROOT);
+			
+			setPunishLevel(PunishLevel.JAIL, Config.ANTIBOT_TIME_JAIL);
+			sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "[AntiBot]:", "Character " + getName() + " jailed for " + Config.ANTIBOT_TIME_JAIL + " minutes."));
+			_log.warning("[AntiBot]: Character " + getName() + " jailed for " + Config.ANTIBOT_TIME_JAIL + " minutes.");
+		}
+	}
+	
+	private int getMobsDead()
+	{
+		return _mobs_dead;
+	}
+	
+	private void increaseMobsDead()
+	{
+		_mobs_dead++;
+	}
+	
+	private void resetMobsDead()
+	{
+		_mobs_dead = 0;
+	}
+	
+	private void setCode(String code)
+	{
+		_code = code;
+	}
+	
+	private String getCode()
+	{
+		return _code;
+	}
+	
+	public void increaseAttempt()
+	{
+		_attempt += 1;
+	}
+	
+	public int getAttempt()
+	{
+		return _attempt;
+	}
+	
+	public void resetAttempt()
+	{
+		_attempt = 0;
+	}	
 }
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/model/actor/L2Attackable.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/L2Attackable.java	(revision 13)
+++ java/net/sf/l2j/gameserver/model/actor/L2Attackable.java	(working copy)
@@ -450,6 +450,12 @@
 		if (!super.doDie(killer))
 			return false;
 		
+		// AntiBot
+		if (Config.ANTIBOT_ENABLE && (killer != null) && killer instanceof L2PcInstance && (killer.getLevel() >= Config.ANTIBOT_MIN_LEVEL))
+		{
+			killer.getActingPlayer().antibot();
+		}
+		
 		// Notify the Quest Engine of the L2Attackable death if necessary
 		try
 		{
Index: config/players.properties
===================================================================
--- config/players.properties	(revision 13)
+++ config/players.properties	(working copy)
@@ -294,4 +294,23 @@
 MaxBuffsAmount = 20
 
 # Store buffs/debuffs on user logout?
-StoreSkillCooltime = True
\ No newline at end of file
+StoreSkillCooltime = True
+
+#=============================================================
+#                        AntiBot 
+#=============================================================
+
+# AntiBot. True to enable, False to disable.
+AntiBotEnable = True
+
+# Time the user will be in jail in minutes.
+AntiBotTimeJail = 10
+
+# Time that the user will have to control captcha in seconds.
+AntiBotTimeVote = 40
+
+# Dead mobs needed for captcha.
+AntiBotKillMobs = 100
+
+# Level min need for captcha.
+AntiBotMinLevel = 1
\ No newline at end of file

Frozen:

### Eclipse Workspace Patch 1.0
#P L2jFrozen_GameServer
Index: head-src/com/l2jfrozen/gameserver/model/L2Attackable.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/model/L2Attackable.java	(revision 1118)
+++ head-src/com/l2jfrozen/gameserver/model/L2Attackable.java	(working copy)
@@ -542,6 +542,12 @@
 			LOGGER.error("", e);
 		}
 		
+		// AntiBot
+		if (Config.ANTIBOT_ENABLE && (killer != null) && killer instanceof L2PcInstance && (killer.getLevel() >= Config.ANTIBOT_MIN_LEVEL))
+		{
+			killer.getActingPlayer().antibot();
+		}
+		
 		// Notify the Quest Engine of the L2Attackable death if necessary
 		try
 		{
Index: head-src/com/l2jfrozen/gameserver/datatables/AntiBotTable.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/datatables/AntiBotTable.java	(revision 0)
+++ head-src/com/l2jfrozen/gameserver/datatables/AntiBotTable.java	(revision 0)
@@ -0,0 +1,183 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jfrozen.gameserver.datatables;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jfrozen.gameserver.network.serverpackets.PledgeImage;
+import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
+import com.l2jfrozen.util.random.Rnd;
+
+/**
+ * 
+ * @author Fissban
+ *
+ */
+public class AntiBotTable
+{
+	public static Logger _log = Logger.getLogger(AntiBotTable.class.getName());
+	
+	public static Map<Integer, antiBotData> _imageAntiBotOri = new HashMap<>();
+	public static Map<Integer, antiBotData> _imageAntiBotClient = new HashMap<>();
+	
+	public final static int[] img_antibot_id =
+	{
+		7000, 7001, 7002, 7003, 7004, 7005, 7006, 7007, 7008, 7009
+	};
+	
+	public void loadImage()
+	{
+		LoadImgAntiBot();
+		_log.log(Level.INFO, "loading " + _imageAntiBotOri.size() + " images of AntiBot");
+	}
+	
+	private static void LoadImgAntiBot()
+	{
+		_imageAntiBotOri.clear();
+		int cont = 0;
+		
+		for (int imgId : img_antibot_id)
+		{
+			File image = new File("data/images/antibot/" + imgId + ".dds");
+			_imageAntiBotOri.put(cont, new antiBotData(cont, ConverterImgBytes(image)));
+			cont++;
+		}
+		
+		ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new startEncriptCaptcha(), 100, 600000); // 10 Minutes
+	}
+	
+	public void sendImage(L2PcInstance player, int imgId)
+	{
+		PledgeImage packet = null;
+		
+		if ((imgId >= 50000) && (imgId <= 800000))
+		{
+			for (Entry<Integer, antiBotData> entrySet : _imageAntiBotClient.entrySet())
+			{
+				antiBotData imgCoding = entrySet.getValue();
+				
+				if (imgId == imgCoding.getCodificacion())
+				{
+					packet = new PledgeImage(imgId, imgCoding.getImagen());
+				}
+			}
+		}
+		
+		player.sendPacket(packet);
+	}
+	
+	public static class startEncriptCaptcha implements Runnable
+	{
+		public startEncriptCaptcha()
+		{
+			
+		}
+		
+		@Override
+		public void run()
+		{
+			_imageAntiBotClient.clear();
+			
+			for (Entry<Integer, antiBotData> entrySet : _imageAntiBotOri.entrySet())
+			{
+				entrySet.getValue().getImagen();
+				_imageAntiBotClient.put(entrySet.getKey(), new antiBotData(Rnd.get(50000, 800000), entrySet.getValue().getImagen()));
+			}
+		}
+	}
+	
+	public int getAntiBotClientID(int pos)
+	{
+		int returnCoding = 0;
+		
+		for (Entry<Integer, antiBotData> entrySet : _imageAntiBotClient.entrySet())
+		{
+			int numeroImage = entrySet.getKey().intValue(); 
+			
+			if (pos == numeroImage)
+			{
+				antiBotData imgCoding = entrySet.getValue();
+				returnCoding = imgCoding.getCodificacion();
+			}
+			
+			if (pos > 9)
+			{
+				_log.log(Level.SEVERE, "error in getAntiBotClientID...number dont exist");
+			}
+		}
+		return returnCoding;
+	}
+	
+	public static class antiBotData
+	{
+		int _codificacion;
+		byte[] _data;
+		
+		public antiBotData(int codificacion, byte[] data)
+		{
+			_codificacion = codificacion;
+			_data = data;
+		}
+		
+		public int getCodificacion()
+		{
+			return _codificacion;
+		}
+		
+		public byte[] getImagen()
+		{
+			return _data;
+		}
+	}
+	
+	private static byte[] ConverterImgBytes(File imagen)
+	{
+		ByteArrayOutputStream bos = new ByteArrayOutputStream();
+		
+		byte[] buffer = new byte[1024];
+		try (FileInputStream fis = new FileInputStream(imagen))
+		{
+			for (int readNum; (readNum = fis.read(buffer)) != -1;)
+			{
+				bos.write(buffer, 0, readNum);
+			}
+		}
+		catch (IOException e)
+		{
+			_log.log(Level.SEVERE, "Error when converter image to byte[]");
+		}
+		
+		return bos.toByteArray();
+	}
+	
+	public static AntiBotTable getInstance()
+	{
+		return SingletonHolder._instance;
+	}
+	
+	private static class SingletonHolder
+	{
+		protected static final AntiBotTable _instance = new AntiBotTable();
+	}
+}
\ No newline at end of file
Index: head-src/com/l2jfrozen/gameserver/network/serverpackets/PledgeImage.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/network/serverpackets/PledgeImage.java	(revision 0)
+++ head-src/com/l2jfrozen/gameserver/network/serverpackets/PledgeImage.java	(revision 0)
@@ -0,0 +1,50 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jfrozen.gameserver.network.serverpackets;
+
+public class PledgeImage extends L2GameServerPacket
+{
+	private final int _crestId;
+	private final byte[] _data;
+	
+	public PledgeImage(int crestId, byte[] data)
+	{
+		_crestId = crestId;
+		_data = data;
+	}
+	
+	@Override
+	protected final void writeImpl()
+	{
+		writeC(0x6c);
+		writeD(_crestId);
+		
+		if (_data != null)
+		{
+			writeD(_data.length);
+			writeB(_data);
+		}
+		else
+		{
+			writeD(0);
+		}
+	}
+
+	@Override
+	public String getType()
+	{
+		return null;
+	}
+}
Index: head-src/com/l2jfrozen/gameserver/GameServer.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/GameServer.java	(revision 1118)
+++ head-src/com/l2jfrozen/gameserver/GameServer.java	(working copy)
@@ -44,6 +44,7 @@
 import com.l2jfrozen.gameserver.controllers.GameTimeController;
 import com.l2jfrozen.gameserver.controllers.RecipeController;
 import com.l2jfrozen.gameserver.controllers.TradeController;
+import com.l2jfrozen.gameserver.datatables.AntiBotTable;
 import com.l2jfrozen.gameserver.datatables.GmListTable;
 import com.l2jfrozen.gameserver.datatables.HeroSkillTable;
 import com.l2jfrozen.gameserver.datatables.NobleSkillTable;
@@ -423,6 +424,9 @@
 		AdminCommandAccessRights.getInstance();
 		GmListTable.getInstance();
 		
+		Util.printSection("AntiBot");
+		AntiBotTable.getInstance().loadImage();
+		
 		Util.printSection("Handlers");
 		ItemHandler.getInstance();
 		SkillHandler.getInstance();
Index: config/head/other.properties
===================================================================
--- config/head/other.properties	(revision 1118)
+++ config/head/other.properties	(working copy)
@@ -239,4 +239,23 @@
 ClickTask = 50
 
 # Crit announce
-GMShowCritAnnouncerName = False
\ No newline at end of file
+GMShowCritAnnouncerName = False
+
+#=============================================================
+#                        AntiBot 
+#=============================================================
+
+# AntiBot. True to enable, False to disable.
+AntiBotEnable = True
+
+# Time the user will be in jail in minutes.
+AntiBotTimeJail = 10
+
+# Time that the user will have to control captcha in seconds.
+AntiBotTimeVote = 40
+
+# Dead mobs needed for captcha.
+AntiBotKillMobs = 100
+
+# Level min need for captcha.
+AntiBotMinLevel = 1
\ No newline at end of file
Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java	(revision 1118)
+++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -61,6 +61,7 @@
 import com.l2jfrozen.gameserver.controllers.GameTimeController;
 import com.l2jfrozen.gameserver.controllers.RecipeController;
 import com.l2jfrozen.gameserver.datatables.AccessLevel;
+import com.l2jfrozen.gameserver.datatables.AntiBotTable;
 import com.l2jfrozen.gameserver.datatables.GmListTable;
 import com.l2jfrozen.gameserver.datatables.HeroSkillTable;
 import com.l2jfrozen.gameserver.datatables.NobleSkillTable;
@@ -175,6 +176,7 @@
 import com.l2jfrozen.gameserver.network.serverpackets.ExOlympiadUserInfo;
 import com.l2jfrozen.gameserver.network.serverpackets.ExPCCafePointInfo;
 import com.l2jfrozen.gameserver.network.serverpackets.ExSetCompassZoneCode;
+import com.l2jfrozen.gameserver.network.serverpackets.ExShowScreenMessage;
 import com.l2jfrozen.gameserver.network.serverpackets.FriendList;
 import com.l2jfrozen.gameserver.network.serverpackets.HennaInfo;
 import com.l2jfrozen.gameserver.network.serverpackets.InventoryUpdate;
@@ -712,6 +714,12 @@
 		}
 	}
 	
+	/** AntiBot. */
+	private String _code = "";
+	private int _attempt = 0;
+	private int _mobs_dead = 0;
+	public static ScheduledFuture<?> _antiBotTask;
+	
 	/** The _client. */
 	private L2GameClient _client;
 	
@@ -18740,6 +18748,8 @@
 	// during fall validations will be disabled for 10 ms.
 	/** The Constant FALLING_VALIDATION_DELAY. */
 	private static final int FALLING_VALIDATION_DELAY = 10000;
+
+	public static final String Say2 = null;
 	
 	/** The _falling timestamp. */
 	private long _fallingTimestamp = 0;
@@ -19644,4 +19654,182 @@
 		_currentPetSkill = new SkillDat(currentSkill, ctrlPressed, shiftPressed);
 	}
 	
+	// AntiBot
+	public void antibot()
+	{
+		increaseMobsDead();
+		
+		if (getMobsDead() >= Config.ANTIBOT_KILL_MOBS)
+		{
+			resetMobsDead();
+			_antiBotTask = ThreadPoolManager.getInstance().scheduleGeneral(new startAntiBotTask(), Config.ANTIBOT_TIME_VOTE * 1000);
+		}
+	}
+	
+	private static void stopAntiBotTask()
+	{
+		if (_antiBotTask != null)
+		{
+			_antiBotTask.cancel(false);
+			_antiBotTask = null;
+		}
+	}
+	
+	private class startAntiBotTask implements Runnable
+	{
+		public startAntiBotTask()
+		{
+			setIsParalyzed(true);
+			setIsInvul(true);
+			startAbnormalEffect(L2Character.ABNORMAL_EFFECT_FLOATING_ROOT);
+			sendPacket(new ExShowScreenMessage("[AntiBot]: You have " + Config.ANTIBOT_TIME_VOTE + " to confirm the Captcha!", 10000));
+			getActingPlayer().sendPacket(new CreatureSay(0, Say2.CRITICAL_ANNOUNCE, "[AntiBot]:", "You have " + Config.ANTIBOT_TIME_VOTE + " to confirm the Catpcha."));
+			showHtml_Start();			
+		}
+		
+		@Override
+		public void run()
+		{
+			if (!isInJail())
+			{
+				sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "[AntiBot]:", "Your time limit has elapsed."));
+				increaseAttempt();
+				
+				if (getAttempt() >= 3)
+				{
+					setIsParalyzed(false);
+					setIsInvul(false);
+					startAbnormalEffect(L2Character.ABNORMAL_EFFECT_FLOATING_ROOT);
+					getActingPlayer().setPunishLevel(L2PcInstance.PunishLevel.JAIL, Config.ANTIBOT_TIME_JAIL);
+					getActingPlayer().sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "[AntiBot]:", "Character " + getName() + " jailed for " + Config.ANTIBOT_TIME_JAIL + " minutes."));
+					LOGGER.warn("[AntiBot]: Character " + getName() + " jailed for " + Config.ANTIBOT_TIME_JAIL + " minutes.");					
+				}
+				else
+				{
+					_antiBotTask = ThreadPoolManager.getInstance().scheduleGeneral(new startAntiBotTask(), Config.ANTIBOT_TIME_VOTE * 1000);
+				}
+			}
+		}
+	}
+	
+	public String num2img(int numero) 
+	{
+		String num = Integer.toString(numero);
+		char[] digitos = num.toCharArray();
+		
+		String tmp = "";
+		for(int x=0;x<num.length();x++) 
+		{
+			int dig = Integer.parseInt(Character.toString(digitos[x]));
+			final int it = AntiBotTable.getInstance().getAntiBotClientID(dig);
+			AntiBotTable.getInstance().sendImage(this, it);
+			tmp += "<img src=Crest.crest_" + Config.SERVER_ID + "_" + it + " width=38 height=33 align=left>";
+		}
+		
+		return tmp;
+	}
+	
+	public void showHtml_Start()
+	{
+		NpcHtmlMessage html = new NpcHtmlMessage(0);
+		html.setFile("data/html/antiBot/start.htm");
+		
+		html.replace("%playerName%", getName());
+		html.replace("%attemp%", String.valueOf(3 - getAttempt()));
+		int maxR = 3;
+		
+		String random = new String();
+		
+		for(int x = 0; x<maxR; x++)
+			random += Integer.toString(Rnd.get(0,9));
+		
+		html.replace("%code1%",num2img(Integer.parseInt(random)));
+		
+		this.sendPacket(html);
+		setCode(String.valueOf(Integer.parseInt(random)));
+	}
+	
+	public void showHtml_End()
+	{
+		NpcHtmlMessage html = new NpcHtmlMessage(0);
+		html.setFile("data/html/antiBot/end.htm");
+		html.replace("%playerName%", getName());
+		
+		this.sendPacket(html);
+	}
+	
+	public void checkCode(String code)
+	{
+		if (code.equals(getCode()))
+		{
+			stopAntiBotTask();
+			resetAttempt();
+			
+			sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "[AntiBot]:", "Congratulations, has passed control."));
+			setIsParalyzed(false);
+			setIsInvul(false);
+			stopAbnormalEffect(L2Character.ABNORMAL_EFFECT_FLOATING_ROOT);
+		}
+		else
+		{
+			stopAntiBotTask();
+			increaseAttempt();
+			
+			_antiBotTask = ThreadPoolManager.getInstance().scheduleGeneral(new startAntiBotTask(), Config.ANTIBOT_TIME_VOTE * 1000);
+		}
+		
+		if (getAttempt() >= 3)
+		{
+			stopAntiBotTask();
+			resetAttempt();
+			
+			setIsParalyzed(false);
+			setIsInvul(false);
+			startAbnormalEffect(L2Character.ABNORMAL_EFFECT_FLOATING_ROOT);
+			
+			setPunishLevel(PunishLevel.JAIL, Config.ANTIBOT_TIME_JAIL);
+			sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "[AntiBot]:", "Character " + getName() + " jailed for " + Config.ANTIBOT_TIME_JAIL + " minutes."));
+			LOGGER.warn("[AntiBot]: Character " + getName() + " jailed for " + Config.ANTIBOT_TIME_JAIL + " minutes.");
+		}
+	}
+	
+	private int getMobsDead()
+	{
+		return _mobs_dead;
+	}
+	
+	private void increaseMobsDead()
+	{
+		_mobs_dead++;
+	}
+	
+	private void resetMobsDead()
+	{
+		_mobs_dead = 0;
+	}
+	
+	private void setCode(String code)
+	{
+		_code = code;
+	}
+	
+	private String getCode()
+	{
+		return _code;
+	}
+	
+	public void increaseAttempt()
+	{
+		_attempt += 1;
+	}
+	
+	public int getAttempt()
+	{
+		return _attempt;
+	}
+	
+	public void resetAttempt()
+	{
+		_attempt = 0;
+	}		
 }
\ No newline at end of file
Index: head-src/com/l2jfrozen/Config.java
===================================================================
--- head-src/com/l2jfrozen/Config.java	(revision 1118)
+++ head-src/com/l2jfrozen/Config.java	(working copy)
@@ -579,6 +579,13 @@
 	public static boolean ALLOW_AIO_IN_EVENTS;
 	public static boolean ANNOUNCE_CASTLE_LORDS;
 	
+	/** AntiBot */
+	public static boolean ANTIBOT_ENABLE;
+	public static int ANTIBOT_TIME_JAIL;
+	public static int ANTIBOT_TIME_VOTE;
+	public static int ANTIBOT_KILL_MOBS;
+	public static int ANTIBOT_MIN_LEVEL;
+	
 	/** Configuration to allow custom items to be given on character creation */
 	public static boolean CUSTOM_STARTER_ITEMS_ENABLED;
 	public static List<int[]> STARTING_CUSTOM_ITEMS_F = new ArrayList<>();
@@ -683,6 +690,11 @@
 			ALLOW_AIO_USE_CM = Boolean.parseBoolean(otherSettings.getProperty("AllowAioUseClassMaster", "False"));
 			ALLOW_AIO_IN_EVENTS = Boolean.parseBoolean(otherSettings.getProperty("AllowAioInEvents", "False"));
 			ANNOUNCE_CASTLE_LORDS = Boolean.parseBoolean(otherSettings.getProperty("AnnounceCastleLords", "False"));
+			ANTIBOT_ENABLE = Boolean.parseBoolean(otherSettings.getProperty("AntiBotEnable", "true"));
+			ANTIBOT_TIME_JAIL = Integer.parseInt(otherSettings.getProperty("AntiBotTimeJail", "1"));
+			ANTIBOT_TIME_VOTE = Integer.parseInt(otherSettings.getProperty("AntiBotTimeVote", "30"));
+			ANTIBOT_KILL_MOBS = Integer.parseInt(otherSettings.getProperty("AntiBotKillMobs", "1"));
+			ANTIBOT_MIN_LEVEL = Integer.parseInt(otherSettings.getProperty("AntiBotMinLevel", "1"));				
 			if (ENABLE_AIO_SYSTEM) // create map if system is enabled
 			{
 				final String[] AioSkillsSplit = otherSettings.getProperty("AioSkills", "").split(";");
Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java	(revision 1118)
+++ head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java	(working copy)
@@ -20,6 +20,8 @@
  */
 package com.l2jfrozen.gameserver.network.clientpackets;
 
+import java.util.StringTokenizer;
+
 import org.apache.log4j.Logger;
 
 import com.l2jfrozen.Config;
@@ -317,6 +319,18 @@
 			else if (_command.startsWith("OlympiadArenaChange"))
 			{
 				Olympiad.bypassChangeArena(_command, activeChar);
+			}			
+			else if (_command.startsWith("antibot"))
+			{
+				StringTokenizer st = new StringTokenizer(_command);
+				st.nextToken();
+				
+				if (st.hasMoreTokens())
+				{
+					activeChar.checkCode(st.nextToken());
+					return;
+				}
+				activeChar.checkCode("Fail");
 			}
 		}
 		catch (final Exception e)
Edited by Inthedash6
Posted

i get 1 error..

 

sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "[AntiBot]:", "Congratulations, has passed control."));

 

what should i replace HERO_VOICE with?

 

i'm using l2jfrozen

Posted (edited)

it doesnt work...maybe u can help me by typing here the correct code??

 

check those images to see the errors i get..

1--> https://postimg.org/image/u0hq3nip9/

 

2--> https://postimg.org/image/fsfx56sbf/

Edited by protoftw
Posted (edited)

Then your "frozen" is not frozen. Normally you can't get error as it's correct. You can always remove that Say2.HERO_VOICE and put 17 and 18 instead of Say2.CRITICAL_ANNOUNCE.

Edited by SweeTs
Posted (edited)

U mean sth like that?

 

getActingPlayer().sendPacket(new CreatureSay(0, 17, "[AntiBot]:",

 

instead of 

 

getActingPlayer().sendPacket(new CreatureSay(0, Say2.HERO VOICE, "[AntiBot]:",

 

edit:

 

thank you man ..it works perfect now ..i have just tested it :) hope u have a great night ..

 

dont forget to be nice to ppl

Edited by protoftw
  • 3 months later...
Posted

look this error

 

com\l2jfrozen\gameserver\datatables\AntiBotTable.java:160: error: try-with-resources is not supported in -source

 

try (FileInputStream fis = new FileInputStream(imagen))

     ^
1 error

Posted

 

Where neeed to add images? And where need to add end.html and start.html ?

 

data/images/antibot

data/html/antiBot/start.htm

data/html/antiBot/end.htm
Posted (edited)

data/images/antibot

 

data/html/antiBot/start.htm

 

data/html/antiBot/end.htm

 

where do I put them ???

com\l2jfrozen\gameserver\datatables

It's not core side...Add them to your pack.

Edited by protoftw
Posted

i have problem eclipse

no pack

 

com\l2jfrozen\gameserver\datatables\AntiBotTable.java:160: error: try-with-resources is not supported in -source

 

try (FileInputStream fis = new FileInputStream(imagen))

     ^
1 error

  • 1 year later...
  • 4 weeks later...
Posted
On 10/21/2016 at 7:45 PM, protoftw said:

U mean sth like that?

 

getActingPlayer().sendPacket(new CreatureSay(0, 17, "[AntiBot]:",

 

instead of 

 

getActingPlayer().sendPacket(new CreatureSay(0, Say2.HERO VOICE, "[AntiBot]:",

 

edit:

 

thank you man ..it works perfect now ..i have just tested it :) hope u have a great night ..

 

dont forget to be nice to ppl

 

and 18 for Say2.CRITICAL_ANNOUNCE (THANKS FOR ASK THAT :)

 

the code is working but i need the htmls  the links dont work

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • [Release] Solo PvP Zone System 🔹 Compatible with: aCis 401+ 📜 Features: ✅ Automatic Exit on Restart: Players are removed from the zone if a restart occurs or logout. ✅ Custom Exit Command: Players can exit the Solo Zone with the voice command .exit. ✅ Teleport NPC Command: new bypass solopvp for gatekeeper. ✅ Random Name Generator: Generates random names. ✅ PvP Flag: The players are flagged within this zone.   xml preview & java code backup code -> https://pastebin.com/974V2p2p   SoloZone.xml <?xml version="1.0" encoding="UTF-8"?> <list> <zone shape="NPoly" minZ="-5200" maxZ="-4680"><!-- Frintezza Solo Zone --> <stat name="name" val="Solo PvP Zone" /> <stat name="locs" val="174244,-89089,-5112;174260,-86881,-5112;173184,-88090,-5112;175309,-88018,-5112;174231,-88019,-5112;175136,-88828,-5104;174962,-87025,-5104;173149,-87142,-5104;173470,-88908,-5112" /> <stat name="restrictedClasses" val="15,16,97" /> <node x="172031" y="-90127"/> <node x="176428" y="-90089"/> <node x="176428" y="-74051"/> <node x="172057" y="-74108"/> </zone> </list> SoloZone Code: diff --git a/java/net/sf/l2j/gameserver/taskmanager/SoloZoneTaskManager.java b/java/net/sf/l2j/gameserver/taskmanager/SoloZoneTaskManager.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/taskmanager/SoloZoneTaskManager.java @@ -0,0 +1,98 @@ +package net.sf.l2j.gameserver.taskmanager; + +import java.security.SecureRandom; +import java.util.ArrayList; +import java.util.logging.Logger; + +import net.sf.l2j.commons.random.Rnd; + +import net.sf.l2j.gameserver.data.manager.ZoneManager; +import net.sf.l2j.gameserver.enums.ZoneId; +import net.sf.l2j.gameserver.handler.voicecommandhandlers.VoiceExitSoloZone; +import net.sf.l2j.gameserver.model.World; +import net.sf.l2j.gameserver.model.actor.Player; +import net.sf.l2j.gameserver.model.location.Location; +import net.sf.l2j.gameserver.model.zone.type.SoloZone; + + +/** + * @author MarGaZeaS + */ +public class SoloZoneTaskManager implements Runnable { + + private static final Location EXIT_LOCATION = VoiceExitSoloZone.getExitLocation(); // Λαμβάνουμε την έξοδο από το VoiceExitSoloZone + + @Override + public void run() + { + // Διασχίζουμε όλους τους παίκτες του κόσμου + for (Player player : World.getInstance().getPlayers()) + { + // Ελέγχουμε αν ο παίκτης είναι στο SoloZone + if (player.isInsideZone(ZoneId.SOLO)) + { + // Μεταφέρουμε τον παίκτη στην έξοδο + player.teleportTo(EXIT_LOCATION.getX(), EXIT_LOCATION.getY(), EXIT_LOCATION.getZ(), 0); + player.sendMessage("The server is restarting, you have been moved out of the Solo Zone."); + } + } + } + + private int _id; + + private static final Logger _log = Logger.getLogger(SoloZoneTaskManager.class.getName()); + private static final ArrayList<String> _rndNames = new ArrayList<>(); + private static final int RANDOM_NAMES = 500; + private static final String CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + private int _playersInSoloZone = 0; + + public int getPlayersInside() { + return _playersInSoloZone; + } + + public void setPlayersInside(int val) { + _playersInSoloZone = val; + } + + public SoloZoneTaskManager() { + _log.info("Solo Zone System: Loading..."); + for (int i = 0; i < RANDOM_NAMES; i++) { + String name = generateName(); + _rndNames.add(name); + _log.info("Generated name: " + name); + } + _log.info("Solo Zone System: Loaded " + _rndNames.size() + " names."); + } + + public String getAName() { + if (_rndNames.isEmpty()) { + _log.warning("SoloZoneManager: No random names available."); + return "Unknown"; + } + return _rndNames.get(Rnd.get(5, RANDOM_NAMES - 5)); + } + + private static String generateName() { + SecureRandom rnd = new SecureRandom(); + StringBuilder sb = new StringBuilder(15); + for (int i = 0; i < 15; i++) { + sb.append(CHARS.charAt(rnd.nextInt(CHARS.length()))); + } + return sb.toString(); + } + + public int getZoneId() + { + return _id; + } + + public final static SoloZone getCurrentZone() { + return ZoneManager.getInstance().getAllZones(SoloZone.class) + .stream() + .findFirst() // Επιστρέφει την πρώτη SoloZone (αν υπάρχει μόνο μία) + .orElse(null); + } + + public static SoloZoneTaskManager getInstance() { + return SingletonHolder._instance; + } + + private static class SingletonHolder { + private static final SoloZoneTaskManager _instance = new SoloZoneTaskManager(); + } +} diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/taskmanager/PvpFlagTaskManager.java b/aCis_gameserver/java/net/sf/l2j/gameserver/taskmanager/PvpFlagTaskManager.java index a707ce5..d247e2e 100644 --- a/aCis_gameserver/java/net/sf/l2j/gameserver/taskmanager/PvpFlagTaskManager.java final Player player = entry.getKey(); final long timeLeft = entry.getValue(); + if(player.isInsideZone(ZoneId.SOLO)) + continue; if(player.isInsideZone(ZoneId.BOSS)) continue; // Time is running out, clear PvP flag and remove from list. if (currentTime > timeLeft) diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/RequestCharacterCreate.java b/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/RequestCharacterCreate.java index a707ce5..d247e2e 100644 +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/RequestCharacterCreate.java if (Config.ALLOW_FISH_CHAMPIONSHIP) FishingChampionshipManager.getInstance(); + if (Config.ENABLE_STARTUP) + StartupManager.getInstance(); diff --git a/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminMaintenance.java b/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminMaintenance.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminMaintenance.java if (!st.hasMoreTokens()) { sendHtmlForm(player); return; } try { switch (st.nextToken()) { case "shutdown": + SoloZoneTaskManager exitTask = new SoloZoneTaskManager(); + ThreadPool.schedule(exitTask, 0); Shutdown.getInstance().startShutdown(player, null, Integer.parseInt(st.nextToken()), false); break; case "restart": + exitTask = new SoloZoneTaskManager(); + ThreadPool.schedule(exitTask, 0); Shutdown.getInstance().startShutdown(player, null, Integer.parseInt(st.nextToken()), true); break; case "abort": Shutdown.getInstance().abort(player); break; diff --git a/java/net/sf/l2j/gameserver/handler/voicecommandhandlers/VoiceExitSoloZone.java b/java/net/sf/l2j/gameserver/handler/voicecommandhandlers/VoiceExitSoloZone.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/handler/voicecommandhandlers/VoiceExitSoloZone.java +package net.sf.l2j.gameserver.handler.voicecommandhandlers; + +import net.sf.l2j.commons.pool.ThreadPool; + +import net.sf.l2j.gameserver.enums.ZoneId; +import net.sf.l2j.gameserver.handler.IVoiceCommandHandler; +import net.sf.l2j.gameserver.model.actor.Player; +import net.sf.l2j.gameserver.model.location.Location; +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse; + +/** + * Handles the voice command for exiting the Solo Zone with delay and effects. + * + * @author MarGaZeaS + */ +public class VoiceExitSoloZone implements IVoiceCommandHandler +{ + private static final String[] VOICE_COMMANDS = + { + "exit" + }; + + // Default location to teleport players when exiting the Solo Zone + private static final Location EXIT_LOCATION = new Location(81318, 148064, -3464); // Replace with your desired coordinates + + // Προσθήκη της μεθόδου για να πάρουμε την τοποθεσία εξόδου + public static Location getExitLocation() { + return EXIT_LOCATION; + } + + @Override + public void useVoiceCommand(Player player, String command) + { + if (command.equalsIgnoreCase("exit")) + { + if (!player.isInsideZone(ZoneId.SOLO)) + { + player.sendMessage("You are not inside the Solo Zone."); + return; + } + + // Notify the player about the delay + player.sendMessage("You will be teleported out of the Solo Zone in 2 seconds."); + + // Cast skill effect (Skill ID: 2100, Level: 1) + player.broadcastPacket(new MagicSkillUse(player, player, 2100, 1, 2000, 0)); + + // Schedule the teleportation after a 2-second delay + ThreadPool.schedule(() -> { + // Teleport the player to the designated exit location + player.teleportTo(EXIT_LOCATION.getX(), EXIT_LOCATION.getY(), EXIT_LOCATION.getZ(), 0); + + // Inform the player + player.sendMessage("You have exited the Solo Zone."); + }, 2000); // Delay in milliseconds (2000ms = 2 seconds) + } + } + + @Override + public String[] getVoiceCommandList() + { + return VOICE_COMMANDS; + } +} diff --git a/java/net/sf/l2j/gameserver/handler/VoiceCommandHandler.java b/java/net/sf/l2j/gameserver/handler/VoiceCommandHandler.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/handler/VoiceCommandHandler.java public class VoiceCommandHandler { private final Map<String, IVoiceCommandHandler> _entries = new HashMap<>(); protected VoiceCommandHandler() { ............ ............ + registerHandler(new VoiceExitSoloZone()); } public void registerHandler(IVoiceCommandHandler handler) { for (String command : handler.getVoiceCommandList()) _entries.put(command, handler); } diff --git a/java/net/sf/l2j/gameserver/model/actor/Npc.java b/java/net/sf/l2j/gameserver/model/actor/Npc.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/model/actor/Npc.java else if (command.startsWith("Chat")) { int val = 0; try { val = Integer.parseInt(command.substring(5)); } catch (final IndexOutOfBoundsException ioobe) { } catch (final NumberFormatException nfe) { } showChatWindow(player, val); + ) + else if (command.startsWith("solopvp")) + { + SoloZoneTaskManager.getInstance(); + player.teleportTo(SoloZoneTaskManager.getCurrentZone().getLoc(), 25); + } else if (command.startsWith("Link")) { final String path = command.substring(5).trim(); if (path.indexOf("..") != -1) return; final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId()); html.setFile("data/html/" + path); html.replace("%objectId%", getObjectId()); player.sendPacket(html); } diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java b/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java // Fixed. - else if (_requestType == 4) - { - if (!player.isGM() && !player.isFestivalParticipant()) - return; - - loc = player.getPosition(); - } + if (_requestType == 4) + { + // Έλεγχος αν ο παίκτης δεν είναι GM, δεν είναι μέρος του φεστιβάλ και δεν είναι στην Solo Zone + if (!player.isGM() && !player.isFestivalParticipant() && !player.isInsideZone(ZoneId.SOLO)) + { + return; + } + + SoloZoneTaskManager.getInstance(); + SoloZone currentZone = SoloZoneTaskManager.getCurrentZone(); + if (currentZone != null && currentZone.getLoc() != null) + { + // Αν υπάρχει ζώνη και οι τοποθεσίες δεν είναι κενές, χρησιμοποιούμε τυχαία τοποθεσία από την ζώνη + loc = currentZone.getLoc(); + } else + { + // Διαφορετικά, κάνουμε respawn στην τρέχουσα θέση του παίκτη + loc = player.getPosition(); + } + } diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java b/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java if (player.isFestivalParticipant() && FestivalOfDarknessManager.getInstance().isFestivalInitialized()) { player.sendPacket(SystemMessageId.NO_RESTART_HERE); sendPacket(RestartResponse.valueOf(false)); return; } + if (player.isInsideZone(ZoneId.SOLO)) + { + player.sendMessage("You cannot restart your character while in Solo Zone. Use .exit to leave"); + player.setFakeName(null); + sendPacket(RestartResponse.valueOf(false)); + return; + } player.removeFromBossZone(); diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/Logout.java b/java/net/sf/l2j/gameserver/network/clientpackets/Logout.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/network/clientpackets/Logout.java player.removeFromBossZone(); player.logout(true); } } + + if (player.isInsideZone(ZoneId.SOLO)) + { + player.sendMessage("You cannot logout or restart your character while in Solo Zone. Use .exit to leave"); + player.setFakeName(null); + player.sendPacket(ActionFailed.STATIC_PACKET); + return; + } + player.removeFromBossZone(); player.logout(true); } } diff --git a/java/net/sf/l2j/gameserver/model/zone/type/SoloZone.java b/java/net/sf/l2j/gameserver/model/zone/type/SoloZone.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/model/zone/type/SoloZone.java +package net.sf.l2j.gameserver.model.zone.type; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import net.sf.l2j.commons.random.Rnd; + +import net.sf.l2j.Config; +import net.sf.l2j.gameserver.enums.MessageType; +import net.sf.l2j.gameserver.enums.ZoneId; +import net.sf.l2j.gameserver.handler.voicecommandhandlers.VoiceExitSoloZone; +import net.sf.l2j.gameserver.model.World; +import net.sf.l2j.gameserver.model.actor.Creature; +import net.sf.l2j.gameserver.model.actor.Player; +import net.sf.l2j.gameserver.model.location.Location; +import net.sf.l2j.gameserver.model.zone.type.subtype.ZoneType; +import net.sf.l2j.gameserver.network.SystemMessageId; +import net.sf.l2j.gameserver.network.serverpackets.EtcStatusUpdate; +import net.sf.l2j.gameserver.taskmanager.PvpFlagTaskManager; +import net.sf.l2j.gameserver.taskmanager.SoloZoneTaskManager; + +/** + * @author MarGaZeaS + * + */ +public class SoloZone extends ZoneType +{ + private String _name; + private List<Location> _locations = new ArrayList<>(); + + public SoloZone(int id) + { + super(id); + } + + @Override + public void setParameter(String name, String value) + { + if (name.equals("name")) + _name = value; + else if (name.equals("locs")) + { + for (String locs : value.split(";")) + { + String[] coordinates = locs.split(","); + if (coordinates.length == 3) + { + int x = Integer.parseInt(coordinates[0]); + int y = Integer.parseInt(coordinates[1]); + int z = Integer.parseInt(coordinates[2]); + _locations.add(new Location(x, y, z)); + } + else + { + LOGGER.warn("Invalid location format: " + locs); + } + } + } + } + + + @Override + protected void onEnter(Creature character) + { + if (character instanceof Player) + { + final Player player = (Player) character; + + if ((player.getClassId().getId() == 15 || player.getClassId().getId() == 16 || player.getClassId().getId() == 97)) + { + Location respawnLocation = VoiceExitSoloZone.getExitLocation(); + player.instantTeleportTo(respawnLocation, 20); + player.sendMessage("Your class is not allowed in this zone."); + return; + } + + String randomName = SoloZoneTaskManager.getInstance().getAName(); + if (randomName == null || randomName.isEmpty() || !isValidName(randomName)) + { + randomName = generateRandomName(); + } + if (isNameAlreadyTaken(randomName)) + { + randomName = generateRandomName(); + } + player.setFakeName(randomName); + player.sendMessage("Welcome to the Solo Zone, your random name is: " + randomName); + player.sendPacket(SystemMessageId.ENTERED_COMBAT_ZONE); + character.setInsideZone(ZoneId.SOLO, true); + character.setInsideZone(ZoneId.NO_STORE, true); + character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, true); + + if (player.getParty() != null) + { + player.getParty().removePartyMember(player, MessageType.DISCONNECTED); + } + + if (player.getPvpFlag() > 0) + PvpFlagTaskManager.getInstance().remove(player, true); + + player.updatePvPStatus(); + player.broadcastUserInfo(); + } + } + + private static boolean isValidName(String name) { + return name.matches("[a-zA-Z0-9_]+"); + } + + private static String generateRandomName() { + Random rand = new Random(); + int nameLength = rand.nextInt(12) + 4; + StringBuilder nameBuilder = new StringBuilder(); + + for (int i = 0; i < nameLength; i++) { + char randomChar = (char) (rand.nextInt(26) + 'a'); + nameBuilder.append(randomChar); + } + + return nameBuilder.toString(); + } + + private static boolean isNameAlreadyTaken(String name) { + return World.getInstance().getPlayers().stream().anyMatch(player -> player.getFakeName().equals(name)); + } + + @Override + protected void onExit(Creature character) + { + character.setInsideZone(ZoneId.SOLO, false); // Solo zone + character.setInsideZone(ZoneId.NO_STORE, false); // Allow making a store + character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, false); // Allow summon + + if (character instanceof Player) + { + final Player player = (Player) character; + + if (player.getFakeName() != null) + { + player.setFakeName(null); + } + + player.sendPacket(SystemMessageId.LEFT_COMBAT_ZONE); + { + if(!player.isInObserverMode() && player.getPvpFlag() > 0) + PvpFlagTaskManager.getInstance().add(player, Config.PVP_NORMAL_TIME); + + player.sendPacket(new EtcStatusUpdate(player)); + player.broadcastUserInfo(); + } + } + } + + public String getName() + { + return _name; + } + + public Location getLoc() + { + if (_locations.isEmpty()) + { + return null; // Αν η λίστα είναι κενή, επιστρέφουμε null + } + return _locations.get(Rnd.get(0, _locations.size() - 1)); // Επιλέγουμε τυχαία τοποθεσία + } +} diff --git a/java/net/sf/l2j/gameserver/GameServer.java b/java/net/sf/l2j/gameserver/GameServer.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/GameServer.java if (Config.ALLOW_FISH_CHAMPIONSHIP) FishingChampionshipManager.getInstance(); + StringUtil.printSection("Custom Features"); + SoloZoneTaskManager.getInstance(); StringUtil.printSection("Handlers"); LOGGER.info("Loaded {} admin command handlers.", AdminCommandHandler.getInstance().size()); diff --git a/java/net/sf/l2j/gameserver/GameServer.java b/java/net/sf/l2j/gameserver/Shutdown.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/Shutdown.java // disconnect players try { disconnectAllPlayers(); LOGGER.info("All players have been disconnected."); } catch (Exception e) { // Silent catch. } + // Restore real names for players in SoloZone + restoreRealNamesInSoloZone(); // stop all threadpolls ThreadPool.shutdown(); try { LoginServerThread.getInstance().interrupt(); } catch (Exception e) { // Silent catch. } // avoids new players from logging in if (_secondsShut <= 60 && LoginServerThread.getInstance().getServerType() != ServerType.DOWN) LoginServerThread.getInstance().setServerType(ServerType.DOWN); _secondsShut--; Thread.sleep(1000); } } catch (InterruptedException e) { } } + // This method restores the real names of players in SoloZone + private static void restoreRealNamesInSoloZone() + { + for (Player player : World.getInstance().getPlayers()) + { + // Check if player is inside the SoloZone + if (player.isInsideZone(ZoneId.SOLO)) + { + // Restore the real name by removing the fake name + if (player.getFakeName() != null) + { + player.setFakeName(null); // Restore the real name + LOGGER.info("Player {}'s fake name has been removed and real name restored.", player.getName()); + } + } + } + } private static void sendServerQuit(int seconds) { World.toAllOnlinePlayers(SystemMessage.getSystemMessage(SystemMessageId.THE_SERVER_WILL_BE_COMING_DOWN_IN_S1_SECONDS).addNumber(seconds)); } diff --git a/java/net/sf/l2j/gameserver/enums/ZoneId.java b/java/net/sf/l2j/gameserver/enums/ZoneId.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/enums/ZoneId.java public enum ZoneId { PVP(0), PEACE(1), SIEGE(2), MOTHER_TREE(3), CLAN_HALL(4), NO_LANDING(5), WATER(6), JAIL(7), MONSTER_TRACK(8), CASTLE(9), SWAMP(10), NO_SUMMON_FRIEND(11), NO_STORE(12), TOWN(13), HQ(14), DANGER_AREA(15), CAST_ON_ARTIFACT(16), NO_RESTART(17), SCRIPT(18), - BOSS(19), + BOSS(19), + SOLO(20); private final int _id; private ZoneId(int id) { _id = id; } diff --git a/java/net/sf/l2j/gameserver/network/serverpackets/Die.java b/java/net/sf/l2j/gameserver/network/serverpackets/Die.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/network/serverpackets/Die.java if (creature instanceof Player) { Player player = (Player) creature; - _allowFixedRes = player.getAccessLevel().allowFixedRes(); + _allowFixedRes = player.getAccessLevel().allowFixedRes() || player.isInsideZone(ZoneId.SOLO); _clan = player.getClan(); } diff --git a/java/net/sf/l2j/gameserver/model/actor/Player.java b/java/net/sf/l2j/gameserver//model/actor/Player.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java // Attacker or spectator logging into a siege zone will be ported at town. if (player.isInsideZone(ZoneId.SIEGE) && player.getSiegeState() < 2) player.teleportTo(TeleportType.TOWN); + if (player.isInsideZone(ZoneId.SOLO)) + { + ThreadPool.schedule(() -> { + Location exitLocation = VoiceExitSoloZone.getExitLocation(); + + if (exitLocation != null) + { + player.teleportTo(exitLocation.getX(), exitLocation.getY(), exitLocation.getZ(), 0); + player.sendMessage("You have been moved to the exit of the SoloZone."); + } + }, 5000); // 5000 milliseconds (5sec) + } diff --git a/java/net/sf/l2j/gameserver/model/actor/Player.java b/java/net/sf/l2j/gameserver/model/actor/Player.java new file mode 100644 index 0000000..6b7ef6f --- /dev/null +++ a/java/net/sf/l2j/gameserver/model/actor/Player.java @Override public void doRevive() { super.doRevive(); stopEffects(EffectType.CHARM_OF_COURAGE); sendPacket(new EtcStatusUpdate(this)); getStatus().setCpHpMp(getStatus().getMaxCp(), getStatus().getMaxHp(), getStatus().getMaxMp()); _reviveRequested = 0; _revivePower = 0; if (isMounted()) startFeed(_mountNpcId); + if (isInsideZone(ZoneId.SOLO)) + { + // Give Nobless (1323 ID) + L2Skill no = SkillTable.getInstance().getInfo(1323, 1); + no.getEffects(this, this); + sendMessage("You have received the Nobless status in the Solo Zone."); + } + }   If anyone thinks the code is wrong, please make an update and upload it here so I can update the post. A part was edited with chatgpt
    • Always remember, when you buy files, just compare with my files that I publish for free. and you will know that you are being ripped off. Greetings to all community!!! 🙂
    • Thank you for sharing. You are a capable and skilled person. Thank you again for your selfless dedication, Guytis🫡
    • he kept his promise! i think it's a good idea to unban his old account. he shares files with the community and could help both new and veteran l2off users! good job, Guytis!
  • Topics

×
×
  • Create New...