Jump to content

Recommended Posts

Posted (edited)

Hello,i just create this code for my server & i am sharing cause i didn't found a share similar to this!

This is for l2jfrozen ,but it work in every project with  few changes.

Ass the tittle says,these are configs to disable healers from events or specific classes you wish.


Code:

Spoiler

head-src/gameserver/Config.java
----------------------------------------------------------------------------------------------------
+/** Event restricted classes*/
+public static boolean TVT_ALLOW_HEALER_CLASSES;
+public static String DISABLE_ID_CLASSES_TVT;
+public static FastList <Integer> DISABLE_CLASSES_TVT = new FastList <> ();

+
+public static boolean CTF_ALLOW_HEALER_CLASSES;
+public static String DISABLE_ID_CLASSES_CTF;
+public static FastList <Integer> DISABLE_CLASSES_CTF = new FastList <> ();

+
+public static String DISABLE_ID_CLASSES_DM;
+public static FastList <Integer> DISABLE_CLASSES_DM = new FastList <> ();

 +   // ============================================================

 

            TVT_TOP_KILLER_QTY = Integer.parseInt(TVTSettings.getProperty("TvTTopKillerRewardQty", "2000000"));
            TVT_AURA = Boolean.parseBoolean(TVTSettings.getProperty("TvTAura", "False"));
            TVT_STATS_LOGGER = Boolean.parseBoolean(TVTSettings.getProperty("TvTStatsLogger", "true"));
+TVT_ALLOW_HEALER_CLASSES = Boolean.parseBoolean (TVTSettings.getProperty ("TvTAllowedHealerClasses", "true"));
+DISABLE_ID_CLASSES_TVT = TVTSettings.getProperty ("DisableTvtClassesID", "");
+DISABLE_CLASSES_TVT = new FastList <> ();
+for (String class_id: DISABLE_ID_CLASSES_TVT.split (","))
+{
+if (! class_id.equals (""))
+DISABLE_CLASSES_TVT.add (Integer.parseInt (class_id));}

 

 

CTF_REVIVE_RECOVERY = Boolean.parseBoolean(CTFSettings.getProperty("CTFReviveRecovery", "False"));
            CTF_COMMAND = Boolean.parseBoolean(CTFSettings.getProperty("CTFCommand", "True"));
            CTF_AURA = Boolean.parseBoolean(CTFSettings.getProperty("CTFAura", "True"));
        
+CTF_ALLOW_HEALER_CLASSES = Boolean.parseBoolean (CTFSettings.getProperty ("CtfAllowedHealerClasses", "true"));
+DISABLE_ID_CLASSES_CTF = CTFSettings.getProperty ("DisableCtfClassesID", "");
+DISABLE_CLASSES_CTF = new FastList <> ();
+for (String class_id: DISABLE_ID_CLASSES_CTF.split (","))
+{
+if (! class_id.equals (""))
+DISABLE_CLASSES_CTF.add (Integer.parseInt (class_id));}

 

 

DM_STATS_LOGGER = Boolean.parseBoolean(DMSettings.getProperty("DMStatsLogger", "true"));         
            DM_ALLOW_HEALER_CLASSES = Boolean.parseBoolean(DMSettings.getProperty("DMAllowedHealerClasses", "true"));         
            DM_REMOVE_BUFFS_ON_DIE = Boolean.parseBoolean(DMSettings.getProperty("DMRemoveBuffsOnPlayerDie", "false"));    
+DISABLE_ID_CLASSES_DM = DMSettings.getProperty ("DisableDmClassesID", "");
+DISABLE_CLASSES_DM = new FastList <> ();
+for (String class_id: DISABLE_ID_CLASSES_DM.split (","))
+{
+if (! class_id.equals (""))
+DISABLE_CLASSES_DM.add (Integer.parseInt (class_id));}

 

 

 

config/frozen/tvt.Properties:
----------------------------------------------

+# ======================================================== #
+#      Restrict Classes for events   #

+#            By: Irrelevant
+# ======================================================== #
+
+TvTAllowedHealerClasses = False
+#Add restriction for extra Classes Id:
+#example: 97.92
+DisableTvtClassesID = 

 

config/frozen/ctf.Properties:
---------------------------------------------------------

+# ======================================================== #
+#      Restrict Classes for events   #

+#            By: Irrelevant
+# ======================================================== #

+CtfAllowedHealerClasses = False
+#Add restriction for extra Classes Id:
+#example: 97.92
+DisableCtfClassesID = 

 

config/frozen/dm.Properties:
--------------------------------------------------

+# ======================================================== #
+#      Restrict Classes for events   #

+#            By: Irrelevant
+# ======================================================== #

+#Disabled Healer classes for DM are already in configs
+#Add extra restrictions below
+#Add restriction for extra Classes Id:
+#example: 97.92
+DisableDmClassesID = 


com.l2jfrozen.gameserver.model.entity.event. TvT.java
-------------------------------------------------------------------------

    eventPlayer.sendMessage("You already participated in event with another char!");
                        return false;
                    }
                }

+if (! Config.TVT_ALLOW_HEALER_CLASSES && (eventPlayer.getClassId() == ClassId.cardinal || eventPlayer.getClassId() == ClassId.bishop || eventPlayer.getClassId() == ClassId.elder || eventPlayer.getClassId() == ClassId.evaSaint || eventPlayer.getClassId() == ClassId.shillenElder|| eventPlayer.getClassId() == ClassId.shillienSaint))
+{
+    eventPlayer.sendMessage("You can't join with Healer Class!");
+    return false;
+        }
+    {
+    if (Config.DISABLE_CLASSES_TVT.contains (eventPlayer.getClassId (). getId ())) {
+    eventPlayer.sendMessage ("Your Class has disabled for TvT Event");
+    return false;
+    }
+    }

 

com.l2jfrozen.gameserver.model.entity.event. CTF.java
-------------------------------------------------------------------------

eventPlayer.sendMessage("You already participated in event with another char!");
                        return false;
                    }
                }

+if (! Config.TVT_ALLOW_HEALER_CLASSES && (eventPlayer.getClassId() == ClassId.cardinal || eventPlayer.getClassId() == ClassId.bishop || eventPlayer.getClassId() == ClassId.elder || eventPlayer.getClassId() == ClassId.evaSaint || eventPlayer.getClassId() == ClassId.shillenElder|| eventPlayer.getClassId() == ClassId.shillienSaint))
+{
+    eventPlayer.sendMessage("You cant join with Healer Class!");
+    return false;
+        }
+    {
+    if (Config.DISABLE_CLASSES_CTF.contains (eventPlayer.getClassId (). getId ())) {
+    eventPlayer.sendMessage ("Your Class has disabled for TvT Event");
+    return false;
+    }
+    }

 

 

com.l2jfrozen.gameserver.model.entity.event. DM.java
---------------------------------------------------------------------------

eventPlayer.sendMessage("You already participated in event with another char!");
                        return false;
                    }
                }

+if (Config.DISABLE_CLASSES_DM.contains (eventPlayer.getClassId (). getId ())) {
+eventPlayer.sendMessage ("Your Class has disabled for DM Event");
+return false;
+}

 





Special Thanks to " Melron "!
for code improving help(actually he gave the entire code XD).

 

Updated code: 

Spoiler

Config.java
--------------------
+/** Event prohibit classes*/
+     public static Map<Class<?>, List<Integer>> EVENT_RESTRICTED_CLASSES = new HashMap<>();

//=========================//
 

@3032,34

PVP1_CUSTOM_MESSAGE = L2JFrozenSettings.getProperty("PvP1CustomMeesage", "You have been teleported to PvP Zone 1!");
            PVP2_CUSTOM_MESSAGE = L2JFrozenSettings.getProperty("PvP2CustomMeesage", "You have been teleported to PvP Zone 2!");

+//Disable classes in events
+Arrays.asList("CTF", "TvT", "DM").forEach(ev -> 
+      {
+          try
+          {
+             EVENT_RESTRICTED_CLASSES.put(Class.forName("com.l2jfrozen.gameserver.model.entity.event." + ev), Stream.of(l2jfrozenSettings.getProperty(ev + +"RestrictedClasses").split(",")).map(Integer::parseInt).collect(Collectors.toList()));
+         }
+         catch (ClassNotFoundException ex)
+         {
+             ex.printStackTrace();
+          }
+      });

         }
                    catch(Exception e)
                    {
                        e.printStackTrace();
                        throw new Error("Failed to Load " + L2JFROZEN + " File.");

 

 

config/functions/l2jfrozen.Properties:
-----------------------------------------------

+# ======================================================== #
+#      Restrict Classes for events   #
+# ======================================================== #
+TvTRestrictedClasses=92,97
+CTFRestrictedClasses=92,97
+DMRestrictedClasses=92,97 


com.l2jfrozen.gameserver.model.entity.event. TvT.java
-------------------------------------------------------------------------
eventPlayer.sendMessage("You already participated in event with another char!");
                        return false;
                    }
                }

 

+    if (Config.EVENT_RESTRICTED_CLASSES.getOrDefault(TvT.class, Collections.emptyList()).contains(eventPlayer.getClassId().getId()))
+                {
+                eventPlayer.sendMessage("Your class is prohibited.");
+                return false;
+            }

 

com.l2jfrozen.gameserver.model.entity.event. CTF.java
------------------------------------------------------------------------

eventPlayer.sendMessage("You already participated in event with another char!");
                        return false;
                    }
                }

 

+    if (Config.EVENT_RESTRICTED_CLASSES.getOrDefault(CTF.class, Collections.emptyList()).contains(eventPlayer.getClassId().getId()))
+                {
+                eventPlayer.sendMessage("Your class is prohibited.");
+                return false;
+            }


com.l2jfrozen.gameserver.model.entity.event. DM.java
------------------------------------------------------------------------

eventPlayer.sendMessage("You already participated in event with another char!");
                        return false;
                    }
                }

 

+    if (Config.EVENT_RESTRICTED_CLASSES.getOrDefault(DM.class, Collections.emptyList()).contains(eventPlayer.getClassId().getId()))
+                {
+                eventPlayer.sendMessage("Your class is prohibited.");
+                return false;
+            }

 

 

Edited by Irrelevant
Posted (edited)

1. Convert the following into Set or even better a single HashMap that uses as a key a String which refer to the case "CTF", "TVT", "OLYMPIAD" and the value is a Set. 

 

You can retrieve this like:

CLASS_ID_RESTRICTION.getOrDefault("OLYMPIAD", Collections.emptySet()).contains(ClassId.cardinal.getId());

 

2. You don't need to write By: Irrelevant on each single config's line.

 

3. Replace this with a switch

 

+if (! Config.TVT_ALLOW_HEALER_CLASSES && (eventPlayer.getClassId() == ClassId.cardinal || eventPlayer.getClassId() == ClassId.bishop || eventPlayer.getClassId() == ClassId.elder || eventPlayer.getClassId() == ClassId.evaSaint || eventPlayer.getClassId() == ClassId.shillenElder|| eventPlayer.getClassId() == ClassId.shillienSaint))

 

Edited by Kara
Posted (edited)
18 hours ago, Kara said:

1. Convert the following into Set or even better a single HashMap that uses as a key a String which refer to the case "CTF", "TVT", "OLYMPIAD" and the value is a Set. 

 

You can retrieve this like:



CLASS_ID_RESTRICTION.getOrDefault("OLYMPIAD", Collections.emptySet()).contains(ClassId.cardinal.getId());

 

2. You don't need to write By: Irrelevant on each single config's line.

 

3. Replace this

 



+if (! Config.TVT_ALLOW_HEALER_CLASSES && (eventPlayer.getClassId() == ClassId.cardinal || eventPlayer.getClassId() == ClassId.bishop || eventPlayer.getClassId() == ClassId.elder || eventPlayer.getClassId() == ClassId.evaSaint || eventPlayer.getClassId() == ClassId.shillenElder|| eventPlayer.getClassId() == ClassId.shillienSaint))

 

thanks.
oh hahaha noo , i just have them all in custom config and i change the location for this share so i copy/paste 3 time above each one of them XD

Edited by Irrelevant
Posted
1 hour ago, Irrelevant said:

thanks.
oh hahaha noo , i just have them all in custom config and i change the location for others by copy/paste 3 time above each one of them XD

 

Sit down and improve your code. When i come back in 24 hours this must be in such perfect shape that i'll be speechless. Go !

Posted
57 minutes ago, Kara said:

 

Sit down and improve your code. When i come back in 24 hours this must be in such perfect shape that i'll be speechless. Go !

haha ok , i will try tommorow :)

Posted (edited)

Create a local svn . It will help you to see your changes and export your diff files instead of adding + at every line.

 

@onCode

 

Your config should looks like

TvTRestrictedClasses=1,2,3,4,5
CtFRestrictedClasses=10,20,30,40,50
DMRestrictedClasses=20,30,40,50

 

 

Lets parse it... Since we have in common the "RestrictedClasses" ...

Arrays.asList("CTF", "TvT", "DM").forEach(ev -> 
{
	try
	{
		EVENT_RESTRICTED_CLASSES.put(Class.forName("com.l2jfrozen.gameserver.model.entity.event." + ev), Stream.of(MyEventSettings.getProperty(ev + "RestrictedClasses").split(",")).map(Integer::parseInt).collect(Collectors.toList()));
	}
	catch (ClassNotFoundException ex)
	{
		ex.printStackTrace();
	}
});

 

Your config should looks like:

public static Map<Class<?>, List<Integer>> EVENT_RESTRICTED_CLASSES = new HashMap<>();

 

And as mentioned before...

This check can be used everywhere at all your events

if (Config.EVENT_RESTRICTED_CLASSES.getOrDefault(getClass(), Collections.emptyList()).contains(eventPlayer.getClassId().getId()))
{
	eventPlayer.sendMessage("Your class is prohibited.");
	return false;
}

 

if you use this check inside of a static method, you have to use the name of the class directly.

Config.EVENT_RESTRICTED_CLASSES.getOrDefault(TvT.class, Collections.emptyList()).contains(eventPlayer.getClassId().getId())

 

Edited by melron
Posted
6 minutes ago, melron said:

Create a local svn . It will help you to see your changes and export your diff files instead of adding + at every line.

 

@onCode

 

Your config should looks like


TvTRestrictedClasses=1,2,3,4,5
CtFRestrictedClasses=10,20,30,40,50
DMRestrictedClasses=20,30,40,50

 

 

Lets parse it... Since we have in common the "RestrictedClasses" ...


Arrays.asList("CTF", "TvT", "DM").forEach(ev -> 
{
	try
	{
		EVENT_RESTRICTED_CLASSES.put(Class.forName("com.l2jfrozen.gameserver.model.entity.event." + ev), Stream.of(MyEventSettings.getProperty(ev + "RestrictedClasses").split(",")).map(Integer::parseInt).collect(Collectors.toList()));
	}
	catch (ClassNotFoundException ex)
	{
		ex.printStackTrace();
	}
});

 

Your config should looks like:


public static Map<Class<?>, List<Integer>> EVENT_RESTRICTED_CLASSES = new HashMap<>();

 

And as mentioned before...

This check can be used everywhere at all your events


if (Config.EVENT_RESTRICTED_CLASSES.getOrDefault(getClass(), Collections.emptyList()).contains(eventPlayer.getClassId().getId()))
{
	eventPlayer.sendMessage("Your class is prohibited.");
	return false;
}

 

if you use this check inside of a static method, you have to use the name of the class directly.


Config.EVENT_RESTRICTED_CLASSES.getOrDefault(TvT.class, Collections.emptyList()).contains(eventPlayer.getClassId().getId())

 

WOW ,that was really nice of you! THANKS!!!!!!!!! i will change them tommorow!

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

    • Migrating a legacy Interlude server to PostgreSQL while adding real observability is basically forcing 2006 MMO engineering to attend a 2026 infrastructure conference at gunpoint. PS: which revision of aCis? PS: 🧻what was broken during this whatever you call it.    AAC Guard beign asked to adapt to this be like: - Creating bugs since early 2018
    • OH MY LORDDDDDDDDDDDDDDDDDDDDD   FINALLY
    • TG Support: https://t.me/buyingproxysup | Channel: https://t.me/buyingproxycom Discord support: #buyingproxy | Server: Join the BuyingProxy Discord Server!  Create your free account here
    • I came out of my cave as I do once every 5 years. By now, I know nobody really cares about L2, but I still find it fun to experiment. Everything you see here will be free and open source. I have no interest in selling anything.   Long story short, I like to revisit Interlude and apply what I've learned to see how far I can push it. Here's Outerlude, a public fork of aCis for the modern age.   Video demo:   Work that has been done:   Redone the netcode from scratch to be async The NPC AI was completely redone based on Finite State Machines Moved to PostgreSQL and using some of its cool features Lots of config that should be hot reloadable has moved to the database OpenTelemetry instrumentation, where it makes sense, and a Grafana dashboard A built-in REST API for server management A built-in MCP Server for LLMs Nidrah AI, an AI Agent to make managing the server easier Real-time server map view Chat auditing and live snooping A new Fake Players Engine with a Node logic system and a new LLM planner for any behavior Just watch the video   If there is interest in this and I'm happy with it, or I get bored (which I always do), I will open-source it. Let me know what you think and if there is some feature you'd like me to implement.
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..