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

    • That’s just part of buying and selling; if your service didn't appeal to me at the time, there's no reason for me to force myself to buy it. After all, I regularly buy other interfaces and clients from other users mostly Russians using USDT. But *I'm* the child here, even though *you're* the incredibly arrogant one.   The payment method or the amounts were never the problem you were. But life goes on; you’d rather stay caught up in your delusions, thinking you’re the protagonist of some anime. Princess Alice 😂   I have all the interfaces for the 474/506/509/520/542/563/557. and olds too.  Some were created by me, including the ARENA P140 interface, which will soon be released for free. This includes everything you make available. It will no longer be a monopoly held by just a few people.   Including your clients with system. like  
    • NEW: Ryzen 9 9950X VPS now Available! Our most Powerful VPS plans now available with dedicated Zen 5 cores clocked up to 5.7 GHz, DDR5 ECC, blazing NVMe Gen4 storage (~7 GB/s), 10 Gbit/s uplink with up to 50 TB traffic, and premium Anti-DDoS included on every plan. No KYC, crypto payments accepted, deployed in minutes. ⭐ RYZEN 9 9950X VPS: [ 9.99 ] 2vCore | 6GB DDR5 | 30GB NVMe - DEPLOY [ 19.99 ] 4vCore | 12GB DDR5 | 50GB NVMe - DEPLOY [ 39.99 ] 8vCore | 24GB DDR5 | 80GB NVMe - DEPLOY [ 69.99 ] 12vCore | 48GB DDR5 | 120GB NVMe - DEPLOY - 10 Gbit/s Port included in ALL Plans - Premium Anti-DDoS included in ALL Plans - No-KYC signup, crypto payments accepted ✅ Ryzen 9 9950X VPS ( vpslab.cloud )
    • I thiunk RU Federation having issues now with paypal?
    • 👑 [FOR SALE] Lineage 2 Premium UCP – Modern Web Panel with Progression & Reward Systems. Looking for the ultimate edge to make your server boom and boost revenue? Introducing the L2 Premium UCP—the most comprehensive and modern User Control Panel on the market. Developed with a total focus on player experience (UX) and administrative automation. Say goodbye to outdated, buggy panels. Give your server the look and feel of an official game!  
  • 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..