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
  • Like 1
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!

  • Like 1

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

    • "I recently purchased the account panel from this developer and wanted to leave a positive review.   The transaction was smooth, and the developer demonstrated exceptional professionalism throughout the process.   What truly sets them apart is their outstanding post-sale support. They are responsive, patient, and genuinely helpful when addressing questions or issues. It's clear they care about their customers' experience beyond just the initial sale.   I am thoroughly satisfied and grateful for the service. This is a trustworthy seller who provides real value through both a quality product and reliable support. 100% recommended."
    • Server owners, Top.MaxCheaters.com is now live and accepting Lineage 2 server listings. There is no voting, no rankings manipulation, and no paid advantages. Visibility is clean and equal, and early listings naturally appear at the top while the platform grows. If your server is active, it should already be listed. Submit here https://Top.MaxCheaters.com This platform is part of the MaxCheaters.com network and is being built as a long-term reference point for the Lineage 2 community. — MaxCheaters.com Team
    • ⚙️ General Changed “No Carrier” title to “Disconnected” to avoid confusion after abnormal DC. On-screen Clan War kill notifications will no longer appear during Sieges, Epics, or Events. Bladedancer or SwordSinger classes can now log in even when Max Clients (2) is reached, you cannot have both at the same time. The max is 3 clients. Duels will now be aborted if a monster aggros players during a duel (retail-like behavior). Players can no longer send party requests to blocked players (retail-like). Fixed Researcher Euclie NPC dialogue HTML error. Changed Clan leave/kick penalty from 12 hours to 3 hours. 🧙 Skills Adjusted Decrease Atk. Spd. & Decrease Speed land rates in Varka & FoG. Fixed augmented weapons not getting cooldown when entering Olympiad. 🎉 Events New Team vs Team map added. New Save the King map added (old TvT map). Mounts disabled during Events. Letter Collector Event enabled Monsters drop letters until Feb. 13th Louie the Cat in Giran until Feb. 16th Inventory slots +10 during event period 📜 Quests Fixed “Possessor of a Precious Soul Part 1” rare stuck issue when exceeding max quest items. Fixed Seven Signs applying Strife buff/debuff every Monday until restart. 🏆 Milestones New milestone: “Defeat 700 Monsters in Varka” 🎁 Rewards: 200 Varka’s Mane + Daily Coin 🌍 NEW EXP Bonus Zones Hot Springs added Varka Silenos added (hidden spots excluded) As always, thank you for your support! L2Elixir keeps evolving, improving, and growing every day 💙   Website: https://l2elixir.org/ Discord: https://discord.gg/5ydPHvhbxs
    • https://sms.pro/ — we are an SMS activation platform  seeking partners  mobile number providers  mobile number owners  owners of GSM modems  SIM card owners We process 1,000,000 activations every day.  寻找合作伙伴  手机号码提供商  手机号码持有者  GSM调制解调器持有者  SIM卡持有者 我们每天处理1,000,000次激活。  Ищем партнеров  Владельцы сим карт  провайдеров  владельцев мобильных номеров  владельцев модемов  Обрабатываем от 1 000 000 активаций в день ⚡️ Fast. Reliable.   https://sms.pro/ Support: https://t.me/alismsorg_bot
  • 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..