Jump to content

Recommended Posts

Posted

This isnt an event, nor a fantastic npc or voiced command

Its an abstract engine which will allow you to add customize code to many parts of the game where only core mod was the way.

With this, you can modify the most used core parts without touch it (which reduce sync problems)

PD: The code there in the script is just a sample so you can follow it to do whatever you want

PD2: Ofc, the engine can be extended to be called in more placed according to your needs

 

Core patch

Index: java/com/l2jserver/gameserver/handler/IScriptHandler.java
===================================================================
--- java/com/l2jserver/gameserver/handler/IScriptHandler.java	(revision 0)
+++ java/com/l2jserver/gameserver/handler/IScriptHandler.java	(revision 0)
@@ -0,0 +1,29 @@
+/*
+ * 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.l2jserver.gameserver.handler;
+
+import com.l2jserver.gameserver.handler.ScriptHandler.CallSite;
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author BiggBoss
+ *
+ */
+public interface IScriptHandler
+{
+	public CallSite getCallSite();
+	public void execute(L2PcInstance activeChar, L2Character enemy);
+}
Index: java/com/l2jserver/gameserver/handler/ScriptHandler.java
===================================================================
--- java/com/l2jserver/gameserver/handler/ScriptHandler.java	(revision 0)
+++ java/com/l2jserver/gameserver/handler/ScriptHandler.java	(revision 0)
@@ -0,0 +1,77 @@
+/*
+ * 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.l2jserver.gameserver.handler;
+
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+import javolution.util.FastMap;
+
+/**
+ * @author BiggBoss
+ *
+ */
+public class ScriptHandler
+{	
+	public enum CallSite
+	{
+		// Entering to server
+		ON_ENTER,
+		// Killing any L2Character instance
+		ON_KILL,
+		// Dyeing
+		ON_DEATH,
+		// When revive
+		ON_RESS,
+		// Exiting from server
+		ON_EXIT,
+	}
+	
+	private static FastMap<CallSite, IScriptHandler> _handler;
+	
+	private ScriptHandler()
+	{
+		if(_handler == null)
+			_handler = new FastMap<CallSite, IScriptHandler>();
+	}
+	
+	public static ScriptHandler getInstance()
+	{
+		return SingletonHolder._instance;
+	}
+	
+	public void registerHandler(IScriptHandler handler)
+	{
+		CallSite site = handler.getCallSite();
+		_handler.put(site, handler);
+	}
+	
+	public void execute(CallSite site, L2PcInstance activeChar, L2Character enemy)
+	{
+		IScriptHandler handler = _handler.get(site);
+		if(handler != null)
+			handler.execute(activeChar, enemy);
+	}
+	
+	public int size()
+	{
+		return _handler.size();
+	}
+	
+	private static final class SingletonHolder
+	{
+		private static final ScriptHandler _instance = new ScriptHandler();
+	}
+}
Index: java/com/l2jserver/gameserver/model/actor/L2Character.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/L2Character.java	(revision 4330)
+++ java/com/l2jserver/gameserver/model/actor/L2Character.java	(working copy)
@@ -44,7 +44,9 @@
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.datatables.MapRegionTable.TeleportWhereType;
import com.l2jserver.gameserver.handler.ISkillHandler;
+import com.l2jserver.gameserver.handler.ScriptHandler;
import com.l2jserver.gameserver.handler.SkillHandler;
+import com.l2jserver.gameserver.handler.ScriptHandler.CallSite;
import com.l2jserver.gameserver.instancemanager.DimensionalRiftManager;
import com.l2jserver.gameserver.instancemanager.InstanceManager;
import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
@@ -2160,6 +2162,8 @@
		{
			_log.log(Level.SEVERE, "deleteMe()", e);
		}
+		if(killer instanceof L2PcInstance)
+			ScriptHandler.getInstance().execute(CallSite.ON_KILL, (L2PcInstance)killer, this);
		return true;
	}

Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(revision 4330)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -76,6 +76,8 @@
import com.l2jserver.gameserver.datatables.SkillTreeTable;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.handler.ItemHandler;
+import com.l2jserver.gameserver.handler.ScriptHandler;
+import com.l2jserver.gameserver.handler.ScriptHandler.CallSite;
import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.instancemanager.CoupleManager;
@@ -5455,7 +5457,7 @@
			L2PcInstance pk = killer.getActingPlayer();

			TvTEvent.onKill(killer, this);
-			
+			ScriptHandler.getInstance().execute(CallSite.ON_DEATH, this, pk);
			if (atEvent && pk != null)
			{
				pk.kills.add(getName());
@@ -11037,6 +11039,7 @@
			if (!DimensionalRiftManager.getInstance().checkIfInPeaceZone(getX(), getY(), getZ()))
				getParty().getDimensionalRift().memberRessurected(this);
		}
+		ScriptHandler.getInstance().execute(CallSite.ON_RESS, this, null);
	}

	@Override
@@ -11629,6 +11632,15 @@

		try
		{
+			ScriptHandler.getInstance().execute(CallSite.ON_EXIT, this, null);
+		}
+		catch(Exception e)
+		{
+			_log.log(Level.SEVERE, "deleteMe()", e);
+		}
+		
+		try
+		{
			if (isFlying())
			{
				removeSkill(SkillTable.getInstance().getInfo(4289, 1));
Index: java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java	(revision 4330)
+++ java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java	(working copy)
@@ -30,6 +30,8 @@
import com.l2jserver.gameserver.datatables.GMSkillTable;
import com.l2jserver.gameserver.datatables.MapRegionTable;
import com.l2jserver.gameserver.datatables.SkillTable;
+import com.l2jserver.gameserver.handler.ScriptHandler;
+import com.l2jserver.gameserver.handler.ScriptHandler.CallSite;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.instancemanager.ClanHallManager;
import com.l2jserver.gameserver.instancemanager.CoupleManager;
@@ -493,6 +495,8 @@
			sm.addString(Integer.toString(birthday));
			activeChar.sendPacket(sm);
		}
+		
+		ScriptHandler.getInstance().execute(CallSite.ON_ENTER, activeChar, null);
	}

	/**

 

DP Patch

Index: data/scripts/handlers/MasterHandler.java
===================================================================
--- data/scripts/handlers/MasterHandler.java	(revision 7571)
+++ data/scripts/handlers/MasterHandler.java	(working copy)
@@ -19,6 +19,7 @@
import handlers.bypasshandlers.*;
import handlers.chathandlers.*;
import handlers.itemhandlers.*;
+import handlers.scripthandlers.*;
import handlers.skillhandlers.*;
import handlers.usercommandhandlers.*;
import handlers.voicedcommandhandlers.*;
@@ -31,6 +32,7 @@
import com.l2jserver.gameserver.handler.BypassHandler;
import com.l2jserver.gameserver.handler.ChatHandler;
import com.l2jserver.gameserver.handler.ItemHandler;
+import com.l2jserver.gameserver.handler.ScriptHandler;
import com.l2jserver.gameserver.handler.SkillHandler;
import com.l2jserver.gameserver.handler.UserCommandHandler;
import com.l2jserver.gameserver.handler.VoicedCommandHandler;
@@ -314,6 +316,16 @@
		_log.config("Loaded " + VoicedCommandHandler.getInstance().size() + " VoicedHandlers");
	}

+	private static void loadScriptHandlers()
+	{
+		ScriptHandler.getInstance().registerHandler(new EnterWorld());
+		ScriptHandler.getInstance().registerHandler(new OnDeath());
+		ScriptHandler.getInstance().registerHandler(new OnExit());
+		ScriptHandler.getInstance().registerHandler(new OnKill());
+		ScriptHandler.getInstance().registerHandler(new OnRess());
+		_log.config("Loaded " + ScriptHandler.getInstance().size() + " ScriptHandlers");
+	}
+	
	/**
	 * @param args
	 */
@@ -329,6 +341,7 @@
		loadSkillHandlers();
		loadUserHandlers();
		loadVoicedHandlers();
+		loadScriptHandlers();
		_log.config("Handlers Loaded...");
	}
}
\ No newline at end of file
Index: data/scripts/handlers/scripthandlers/EnterWorld.java
===================================================================
--- data/scripts/handlers/scripthandlers/EnterWorld.java	(revision 0)
+++ data/scripts/handlers/scripthandlers/EnterWorld.java	(revision 0)
@@ -0,0 +1,41 @@
+/**
+ * 
+ */
+package handlers.scripthandlers;
+
+import com.l2jserver.gameserver.Announcements;
+import com.l2jserver.gameserver.handler.IScriptHandler;
+import com.l2jserver.gameserver.handler.ScriptHandler.CallSite;
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author BiggBoss
+ *
+ */
+public class EnterWorld implements IScriptHandler
+{
+
+	/* (non-Javadoc)
+	 * @see com.l2jserver.gameserver.handler.IScriptHandler#execute()
+	 */
+	@Override
+	public void execute(L2PcInstance activeChar, L2Character enemy)
+	{
+		activeChar.sendMessage("This is a test and damn it works!");
+		activeChar.setHero(true);
+		
+		if(activeChar.isGM())
+			Announcements.getInstance().announceToAll("GM "+activeChar.getName()+" has logged in!");
+	}
+
+	/* (non-Javadoc)
+	 * @see com.l2jserver.gameserver.handler.IScriptHandler#getCallSite()
+	 */
+	@Override
+	public CallSite getCallSite()
+	{
+		return CallSite.ON_ENTER;
+	}
+	
+}
Index: data/scripts/handlers/scripthandlers/OnDeath.java
===================================================================
--- data/scripts/handlers/scripthandlers/OnDeath.java	(revision 0)
+++ data/scripts/handlers/scripthandlers/OnDeath.java	(revision 0)
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package handlers.scripthandlers;
+
+import com.l2jserver.gameserver.Announcements;
+import com.l2jserver.gameserver.handler.IScriptHandler;
+import com.l2jserver.gameserver.handler.ScriptHandler.CallSite;
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author BiggBoss
+ *
+ */
+public class OnDeath implements IScriptHandler
+{
+
+	/* (non-Javadoc)
+	 * @see com.l2jserver.gameserver.handler.IScriptHandler#execute(com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
+	 */
+	@Override
+	public void execute(L2PcInstance activeChar, L2Character enemy)
+	{
+		activeChar.sendMessage("This is a test and damn, it works!");
+		if(enemy instanceof L2PcInstance)
+		{
+			L2PcInstance enem = (L2PcInstance)enemy;
+			enem.sendMessage("ffs");
+			if(enem.getKarma() > 0)
+				Announcements.getInstance().announceToAll(enem.getName()+" is PK!, Go get his stuff!");
+		}
+		else
+			enemy.doDie(activeChar);
+		activeChar.doRevive();
+	}
+
+	/* (non-Javadoc)
+	 * @see com.l2jserver.gameserver.handler.IScriptHandler#getCallSite()
+	 */
+	@Override
+	public CallSite getCallSite()
+	{
+		return CallSite.ON_DEATH;
+	}
+	
+}
Index: data/scripts/handlers/scripthandlers/OnExit.java
===================================================================
--- data/scripts/handlers/scripthandlers/OnExit.java	(revision 0)
+++ data/scripts/handlers/scripthandlers/OnExit.java	(revision 0)
@@ -0,0 +1,37 @@
+/**
+ * 
+ */
+package handlers.scripthandlers;
+
+import com.l2jserver.gameserver.handler.IScriptHandler;
+import com.l2jserver.gameserver.handler.ScriptHandler.CallSite;
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author BiggBoss
+ *
+ */
+public class OnExit implements IScriptHandler
+{
+
+	/* (non-Javadoc)
+	 * @see com.l2jserver.gameserver.handler.IScriptHandler#execute(com.l2jserver.gameserver.model.actor.instance.L2PcInstance, com.l2jserver.gameserver.model.actor.L2Character)
+	 */
+	@Override
+	public void execute(L2PcInstance activeChar, L2Character enemy)
+	{
+		// TODO Auto-generated method stub
+		activeChar.sendMessage("Thanks for playing our server! You are welcome anytime.");
+	}
+
+	/* (non-Javadoc)
+	 * @see com.l2jserver.gameserver.handler.IScriptHandler#getCallSite()
+	 */
+	@Override
+	public CallSite getCallSite()
+	{
+		// TODO Auto-generated method stub
+		return CallSite.ON_EXIT;
+	}
+}
Index: data/scripts/handlers/scripthandlers/OnKill.java
===================================================================
--- data/scripts/handlers/scripthandlers/OnKill.java	(revision 0)
+++ data/scripts/handlers/scripthandlers/OnKill.java	(revision 0)
@@ -0,0 +1,38 @@
+/**
+ * 
+ */
+package handlers.scripthandlers;
+
+import com.l2jserver.gameserver.handler.IScriptHandler;
+import com.l2jserver.gameserver.handler.ScriptHandler.CallSite;
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author BiggBoss
+ *
+ */
+public class OnKill implements IScriptHandler
+{
+
+	/* (non-Javadoc)
+	 * @see com.l2jserver.gameserver.handler.IScriptHandler#execute(com.l2jserver.gameserver.model.actor.instance.L2PcInstance, com.l2jserver.gameserver.model.actor.L2Character)
+	 */
+	@Override
+	public void execute(L2PcInstance activeChar, L2Character enemy)
+	{
+		// TODO Auto-generated method stub
+		activeChar.sendMessage(activeChar.getName()+ " what did you just do !? You are an assasin!");
+	}
+
+	/* (non-Javadoc)
+	 * @see com.l2jserver.gameserver.handler.IScriptHandler#getCallSite()
+	 */
+	@Override
+	public CallSite getCallSite()
+	{
+		// TODO Auto-generated method stub
+		return CallSite.ON_KILL;
+	}
+	
+}
Index: data/scripts/handlers/scripthandlers/OnRess.java
===================================================================
--- data/scripts/handlers/scripthandlers/OnRess.java	(revision 0)
+++ data/scripts/handlers/scripthandlers/OnRess.java	(revision 0)
@@ -0,0 +1,39 @@
+/**
+ * 
+ */
+package handlers.scripthandlers;
+
+import com.l2jserver.gameserver.handler.IScriptHandler;
+import com.l2jserver.gameserver.handler.ScriptHandler.CallSite;
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author BiggBoss
+ *
+ */
+public class OnRess implements IScriptHandler
+{
+
+	/* (non-Javadoc)
+	 * @see com.l2jserver.gameserver.handler.IScriptHandler#execute(com.l2jserver.gameserver.model.actor.instance.L2PcInstance, com.l2jserver.gameserver.model.actor.L2Character)
+	 */
+	@Override
+	public void execute(L2PcInstance activeChar, L2Character enemy)
+	{
+		activeChar.setCurrentHp(activeChar.getMaxHp());
+		activeChar.setCurrentMp(activeChar.getMaxMp());
+		activeChar.setCurrentCp(activeChar.getMaxCp());
+	}
+
+	/* (non-Javadoc)
+	 * @see com.l2jserver.gameserver.handler.IScriptHandler#getCallSite()
+	 */
+	@Override
+	public CallSite getCallSite()
+	{
+		// TODO Auto-generated method stub
+		return CallSite.ON_RESS;
+	}
+	
+}

 

Posted

AWSOME MANY I LOVE YOU :D

 

now i can unhardcode every costum check i had also every events check can be done in a dp handler pure awsomeness :D

 

PS.: is it tested or still w8 for testing?

Posted

@Gabor:

 

Index: data/scripts/handlers/scripthandlers/OnDeath.java

===================================================================

--- data/scripts/handlers/scripthandlers/OnDeath.java (revision 0)

+++ data/scripts/handlers/scripthandlers/OnDeath.java (revision 0)

@@ -0,0 +1,47 @@

+/**

+ *

+ */

+package handlers.scripthandlers;

+

+import com.l2jserver.gameserver.Announcements;

+import com.l2jserver.gameserver.handler.IScriptHandler;

+import com.l2jserver.gameserver.handler.ScriptHandler.CallSite;

+import com.l2jserver.gameserver.model.actor.L2Character;

+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;

+

+/**

+ * @author BiggBoss

+ *

+ */

+public class OnDeath implements IScriptHandler

+{

+

+ /* (non-Javadoc)

+ * @see com.l2jserver.gameserver.handler.IScriptHandler#execute(com.l2jserver.gameserver.model.actor.instance.L2PcInstance)

+ */

+ @Override

+ public void execute(L2PcInstance activeChar, L2Character enemy)

+ {

+ activeChar.sendMessage("This is a test and damn, it works!");

+ if(enemy instanceof L2PcInstance)

+ {

+ L2PcInstance enem = (L2PcInstance)enemy;

+ enem.sendMessage("ffs");

+ if(enem.getKarma() > 0)

+ Announcements.getInstance().announceToAll(enem.getName()+" is PK!, Go get his stuff!");

+ }

+ else

+ enemy.doDie(activeChar);

+ activeChar.doRevive();

+ }

+

+ /* (non-Javadoc)

+ * @see com.l2jserver.gameserver.handler.IScriptHandler#getCallSite()

+ */

+ @Override

+ public CallSite getCallSite()

+ {

+ return CallSite.ON_DEATH;

+ }

+

+}

Posted

Well Thank you, but i don`t rly got what this code is for could you explain better?

u saw events in thread...now you can use this to create better events

Posted

Well Thank you, but i don`t rly got what this code is for could you explain better?

makes server core a little bit more abstract

btw, thx all  :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • looking for someone who has cache cleaner for h5 
    • I’m looking to buy GeoEngine compatible with L2Scripts (Essence). A test server must be provided so I can verify functionality before purchase. DM here or through Telegram: @nick77737
    • fixed !.. thank you veru much @NevesOma  someone lock it
    • OFFICIAL DEVELOPERS Undetected since : Release Updated for last patch : 29/11/2025 After payment you will receive: Product download link1 Activation key for the selected period. Free support for the duration of the product subscription.   ✅AC - Undetected ▸WINDOWS 10/11 (All versions, even 24H2) ▸INTEL / AMD ▸Our software mainly targets player wanting to cheat legitimately. . Precision. Stealth. Performance.   The external ARC Raiders cheats from stern designed to elevate your gameplay without slowing your system. Fully compatible with Windows 10/11 — Intel & AMD ready.   Our Functions: AIMBOT **Enable Aim requires a mandatory confirmation popup, so there’s zero risk of activating it by accident for users who don’t want to use it. Aimbot Aimbot Drone Fov Aim (Draw fov circle) Target Line (Draw targetline) Arrow Fov (Draw arrow fov) Visible Check (Aim visible) Humanize (Aim randomize) Custom Aim Key Fov Value / Smooth Value / Aim Delay Arrow Size & Spacing VISUALS – PLAYERS Box ESP (2D / Corner) Health / Shield Bar Skeleton ESP Distance ESP Name ESP Tracers / Player Lines Visible & Invisible Check Squad Name ESP Draw Eyes Directions Radar ESP Radar Distance ESP Players Flags (corpse/knocked/exit/alive) VISUALS – ENTITY Pickup Base ESP Drone ESP Probe Crashed ESP Apricot ESP Mullein ESP Agave ESP MossRock ESP Crate ESP Salvage Container ESP Rsr Lockers ESP Raiders Cache Esp Bin Trash Esp Shredder Esp Fruit Basket ESP Ammo Box ESP Computer ESP Backpack ESP Leaper ESP Probe ESP Mushroom ESP Cargo Ship ESP Firewall ESP Assault Rifle ESP Battle Rifle ESP SMG ESP Grenade ESP Medical Bag ESP Turret ESP Sentinel Esp Weapon Case Esp Extraction ESP All Weapons ESP Max Distance & Fade distance MISC FOV Arrow Player Count Display Custom Arrow Size & Distance Streamproof (Invisible in recordings & screenshots) External (No injection) Maximum Privacy & Security 24/7 Support Available: replies within minutes Our prices: Prices must be checked directly on our website, as they may change at any time to control sales — however, we remain among the most competitive in the market.   Discover our website   GET GOOD, GET STERN
    • I paid this guy yesterday (i got screen for the payment for proof), he told me that someone will log to send me my adena. Then he said he had some problems and couldn't send me the adena. Waited and waited and waited until he replied that he can't find the guy and he will return the money i gave him. Today still no money returned and he doesn't reply to the discord messages. If he doesn't return the money i paid or send the adena he promised in game, i will report him in every single website and many more. Stay away. I have all the discussion screenshot on discord with him. He knows who i am so he better keep his promise legit.
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock