Jump to content

Recommended Posts

Posted

Custom start itens for mage and fight

 

Index: /TrunK/L2JBrasil_CORE/java/config/L2JBrasil.properties
===================================================================
--- /TrunK/L2JBrasil_CORE/java/config/L2JBrasil.properties (revision 113)
+++ /TrunK/L2JBrasil_CORE/java/config/L2JBrasil.properties (revision 114)
@@ -3,15 +3,18 @@
+# ---------------------------------------------------------------------------
+# Starting Custom Items System
+# ---------------------------------------------------------------------------
+# Example: StartingCustomItems = itemId,amount;itemId,amount;itemId,amount
+# Enable/Disable Starting Custom Items System
+AllowStartingCustomItems = False
+
+# Starting itens for fighter's classes
+StartingCustomItemsFighter = 57,0
+
+# Starting itens for mage's classes
+StartingCustomItemsMage = 57,0
Index: /TrunK/L2JBrasil_CORE/java/net/sf/l2j/Config.java
===================================================================
--- /TrunK/L2JBrasil_CORE/java/net/sf/l2j/Config.java (revision 113)
+++ /TrunK/L2JBrasil_CORE/java/net/sf/l2j/Config.java (revision 114)
@@ -31,4 +31,5 @@
import javolution.util.FastList;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.util.StringUtil;

/**
@@ -866,4 +867,7 @@
   public static boolean   ALLOW_TRADEOFF_VOICE_COMMAND;
   public static boolean   OVER_ENCHANT_PROTECTION_ENABLED;
+   public static boolean STARTING_CUSTOM_ITEMS;
+   public static List<int[]> STARTING_CUSTOM_ITEMS_F = new FastList<int[]>();
+   public static List<int[]> STARTING_CUSTOM_ITEMS_M = new FastList<int[]>();
   public static FastList<Integer> OLY_RESTRICTED_ITEMS_LIST = new FastList<Integer>(); 
   public static int       RUN_SPD_BOOST; 
@@ -1214,6 +1218,6 @@
            try 
            { 
-              Properties L2JBrasil      = new Properties(); 
- 	          InputStream is              = new FileInputStream(new File(L2JBRASIL)); 
+              Properties L2JBrasil     = new Properties(); 
+ 	          InputStream is           = new FileInputStream(new File(L2JBRASIL)); 
              L2JBrasil.load(is); 
              is.close(); 
@@ -1235,5 +1239,47 @@
              ALLOW_TRADEOFF_VOICE_COMMAND = Boolean.parseBoolean(L2JBrasil.getProperty("TradeOffCommand","False"));
			  OVER_ENCHANT_PROTECTION_ENABLED = Boolean.parseBoolean(L2JBrasil.getProperty("OverEnchantProtection", "True"));
+			  STARTING_CUSTOM_ITEMS    = Boolean.parseBoolean(L2JBrasil.getProperty("AllowStartingCustomItems", "False"));
+			  
+			  String[] propertySplit = L2JBrasil.getProperty("StartingCustomItemsMage", "57,0").split(";");
+			  for (String reward : propertySplit)
+			  {
+				  String[] rewardSplit = reward.split(",");
+				  if (rewardSplit.length != 2)
+					  _log.warning(StringUtil.concat("StartingCustomItemsMage[Config.load()]: invalid config property -> StartingCustomItemsMage \"", reward, "\""));
+				  else
+				  {
+					  try
+					  {
+						  STARTING_CUSTOM_ITEMS_M.add(new int[]{Integer.parseInt(rewardSplit[0]), Integer.parseInt(rewardSplit[1])});
+					  }
+					  catch (NumberFormatException nfe)
+					  {
+						  if (!reward.isEmpty())
+							  _log.warning(StringUtil.concat("StartingCustomItemsMage[Config.load()]: invalid config property -> StartingCustomItemsMage \"", reward, "\""));
+					  }
+				  }
+			  }
+			  
+			  propertySplit = L2JBrasil.getProperty("StartingCustomItemsFighter", "57,0").split(";");
+			  for (String reward : propertySplit)
+			  {
+			      String[] rewardSplit = reward.split(",");
+				  if (rewardSplit.length != 2)
+				      _log.warning(StringUtil.concat("StartingCustomItemsFighter[Config.load()]: invalid config property -> StartingCustomItemsFighter \"", reward, "\""));
+			      else
+			      {
+				      try
+				      {
+					      STARTING_CUSTOM_ITEMS_F.add(new int[]{Integer.parseInt(rewardSplit[0]), Integer.parseInt(rewardSplit[1])});
+    				  }
+	    			  catch (NumberFormatException nfe)
+		    		  {
+			    	  	  if (!reward.isEmpty())
+				    	      _log.warning(StringUtil.concat("StartingCustomItemsFighter[Config.load()]: invalid config property -> StartingCustomItemsFighter \"", reward, "\""));
+			          }
+			      }
+	          }
+              
+			  NOBLE_CUSTOM_ITEM_ID     = Integer.parseInt(L2JBrasil.getProperty("NobleItemId", "6673")); 
              ALLOW_NOBLE_CUSTOM_ITEM  = Boolean.parseBoolean(L2JBrasil.getProperty("AllowNobleCustomItem", "False")); 
              ACTIVE_SUB_NEEDED_TO_USE_NOBLE_ITEM = Boolean.parseBoolean(L2JBrasil.getProperty("ActiveSubNeededToUseNobleItem", "True")); 
Index: /TrunK/L2JBrasil_CORE/java/net/sf/l2j/gameserver/clientpackets/CharacterCreate.java
===================================================================
--- /TrunK/L2JBrasil_CORE/java/net/sf/l2j/gameserver/clientpackets/CharacterCreate.java (revision 101)
+++ /TrunK/L2JBrasil_CORE/java/net/sf/l2j/gameserver/clientpackets/CharacterCreate.java (revision 114)
@@ -175,5 +175,47 @@
		newChar.addAdena("Init", Config.STARTING_ADENA, null, false);

-        if (Config.STARTING_LEVEL > 1)  
+        if (Config.STARTING_CUSTOM_ITEMS)
+		{
+			if (newChar.isMageClass())
+			{			
+				// Iterate over all Starting Custom Items
+				for (int[] reward : Config.STARTING_CUSTOM_ITEMS_M)
+				{
+					// Check for stackable item, non stackabe items need to be added one by one
+					if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
+					{
+						newChar.getInventory().addItem("STARTING_CUSTOM_ITEMS_M", reward[0], reward[1], newChar, null);
+					}
+					else
+					{
+						for (int i = 0; i < reward[1]; ++i)
+						{
+							newChar.getInventory().addItem("STARTING_CUSTOM_ITEMS_M", reward[0], 1, newChar, null);
+						}
+					}
+				}
+			}
+			else
+			{
+				// Iterate over all Starting Custom Items
+				for (int[] reward : Config.STARTING_CUSTOM_ITEMS_F)
+				{
+					// Check for stackable item, non stackabe items need to be added one by one
+					if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
+					{
+						newChar.getInventory().addItem("STARTING_CUSTOM_ITEMS_F", reward[0], reward[1], newChar, null);
+					}
+					else
+					{
+						for (int i = 0; i < reward[1]; ++i)
+						{
+							newChar.getInventory().addItem("STARTING_CUSTOM_ITEMS_F", reward[0], 1, newChar, null);
+						}
+					}
+				}
+			}
+		}
+		
+		if (Config.STARTING_LEVEL > 1)  
             {  
                            newChar.getStat().addLevel(--Config.STARTING_LEVEL);  

 

StringUtil.java

Index: /TrunK/L2JBrasil_CORE/java/net/sf/l2j/gameserver/util/StringUtil.java
===================================================================
--- /TrunK/L2JBrasil_CORE/java/net/sf/l2j/gameserver/util/StringUtil.java (revision 114)
+++ /TrunK/L2JBrasil_CORE/java/net/sf/l2j/gameserver/util/StringUtil.java (revision 114)
@@ -0,0 +1,297 @@
+/*
+ * $Header$
+ * 
+ * $Author: fordfrog $ $Date$ $Revision$ $Log$
+ * 
+ * 
+ * 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.util;
+
+/**
+ * String utilities optimized for the best performance.
+ * 
+ * <h1>How to Use It</h1> <h2>concat() or append()</h2> If concatenating strings
+ * in single call, use StringUtil.concat(), otherwise use StringUtil.append()
+ * and its variants. <h2>Minimum Calls</h2> Bad:
+ * 
+ * <pre>
+ * final StringBuilder sbString = new StringBuilder();
+ * StringUtil.append(sbString, "text 1", String.valueOf(npcId));
+ * StringUtil.append("text 2");
+ * </pre>
+ * 
+ * Good:
+ * 
+ * <pre>
+ * final StringBuilder sbString = new StringBuilder();
+ * StringUtil.append(sbString, "text 1", String.valueOf(npcId), "text 2");
+ * </pre>
+ * 
+ * Why?<br/>
+ * Because the less calls you do, the less memory re-allocations have to be done
+ * so the whole text fits into the memory and less array copy tasks has to be
+ * performed. So if using less calls, less memory is used and string
+ * concatenation is faster. <h2>Size Hints for Loops</h2> Bad:
+ * 
+ * <pre>
+ * final StringBuilder sbString = new StringBuilder();
+ * StringUtil.append(sbString, "header start", someText, "header end");
+ * for (int i = 0; i < 50; i++)
+ * {
+ * 	StringUtil.append(sbString, "text 1", stringArray[i], "text 2");
+ * }
+ * </pre>
+ * 
+ * Good:
+ * 
+ * <pre>
+ * final StringBuilder sbString = StringUtil.startAppend(1300, "header start", someText, "header end");
+ * for (int i = 0; i < 50; i++)
+ * {
+ * 	StringUtil.append(sbString, "text 1", stringArray[i], "text 2");
+ * }
+ * </pre>
+ * 
+ * Why?<br/>
+ * When using StringUtil.append(), memory is only allocated to fit in the
+ * strings in method argument. So on each loop new memory for the string has to
+ * be allocated and old string has to be copied to the new string. With size
+ * hint, even if the size hint is above the needed memory, memory is saved
+ * because new memory has not to be allocated on each cycle. Also it is much
+ * faster if no string copy tasks has to be performed. So if concatenating
+ * strings in a loop, count approximately the size and set it as the hint for
+ * the string builder size. It's better to make the size hint little bit larger
+ * rather than smaller.<br/>
+ * In case there is no text appended before the cycle, just use <code>new
+ * StringBuilder(1300)</code>. <h2>Concatenation and Constants</h2> Bad:
+ * 
+ * <pre>
+ * StringUtil.concat("text 1 ", "text 2", String.valueOf(npcId));
+ * </pre>
+ * 
+ * Good:
+ * 
+ * <pre>
+ * StringUtil.concat("text 1 " + "text 2", String.valueOf(npcId));
+ * </pre>
+ * 
+ * or
+ * 
+ * <pre>
+ * StringUtil.concat("text 1 text 2", String.valueOf(npcId));
+ * </pre>
+ * 
+ * Why?<br/>
+ * It saves some cycles when determining size of memory that needs to be
+ * allocated because less strings are passed to concat() method. But do not use
+ * + for concatenation of non-constant strings, that degrades performance and
+ * makes extra memory allocations needed. <h2>Concatenation and Constant
+ * Variables</h2> Bad:
+ * 
+ * <pre>
+ * String glue = "some glue";
+ * StringUtil.concat("text 1", glue, "text 2", glue, String.valueOf(npcId));
+ * </pre>
+ * 
+ * Good:
+ * 
+ * <pre>
+ * final String glue = "some glue";
+ * StringUtil.concat("text 1" + glue + "text2" + glue, String.valueOf(npcId));
+ * </pre>
+ * 
+ * Why? Because when using <code>final</code> keyword, the <code>glue</code> is
+ * marked as constant string and compiler treats it as a constant string so it
+ * is able to create string "text1some gluetext2some glue" during the
+ * compilation. But this only works in case the value is known at compilation
+ * time, so this cannot be used for cases like
+ * <code>final String objectIdString =
+ * String.valueOf(getObjectId)</code>. <h2>StringBuilder Reuse</h2> Bad:
+ * 
+ * <pre>
+ * final StringBuilder sbString1 = new StringBuilder();
+ * StringUtil.append(sbString1, "text 1", String.valueOf(npcId), "text 2");
+ * ... // output of sbString1, it is no more needed
+ * final StringBuilder sbString2 = new StringBuilder();
+ * StringUtil.append(sbString2, "text 3", String.valueOf(npcId), "text 4");
+ * </pre>
+ * 
+ * Good:
+ * 
+ * <pre>
+ * final StringBuilder sbString = new StringBuilder();
+ * StringUtil.append(sbString, "text 1", String.valueOf(npcId), "text 2");
+ * ... // output of sbString, it is no more needed
+ * sbString.setLength(0);
+ * StringUtil.append(sbString, "text 3", String.valueOf(npcId), "text 4");
+ * </pre>
+ * 
+ * Why?</br> In first case, new memory has to be allocated for the second
+ * string. In second case already allocated memory is reused, but only in case
+ * the new string is not longer than the previously allocated string. Anyway,
+ * the second way is better because the string either fits in the memory and
+ * some memory is saved, or it does not fit in the memory, and in that case it
+ * works as in the first case. <h2>Primitives to Strings</h2> To convert
+ * primitives to string, use String.valueOf(). <h2>How much faster is it?</h2>
+ * Here are some results of my tests. Count is number of strings concatenated.
+ * Don't take the numbers as 100% true as the numbers are affected by other
+ * programs running on my computer at the same time. Anyway, from the results it
+ * is obvious that using StringBuilder with predefined size is the fastest (and
+ * also most memory efficient) solution. It is about 5 times faster when
+ * concatenating 7 strings, compared to TextBuilder. Also, with more strings
+ * concatenated, the difference between StringBuilder and TextBuilder gets
+ * larger. In code, there are many cases, where there are concatenated 50+
+ * strings so the time saving is even greater.
+ * 
+ * <pre>
+ * Count: 2
+ * TextBuilder: 1893
+ * TextBuilder with size: 1703
+ * String: 1033
+ * StringBuilder: 993
+ * StringBuilder with size: 1024
+ * Count: 3
+ * TextBuilder: 1973
+ * TextBuilder with size: 1872
+ * String: 2583
+ * StringBuilder: 1633
+ * StringBuilder with size: 1156
+ * Count: 4
+ * TextBuilder: 2188
+ * TextBuilder with size: 2229
+ * String: 4207
+ * StringBuilder: 1816
+ * StringBuilder with size: 1444
+ * Count: 5
+ * TextBuilder: 9185
+ * TextBuilder with size: 9464
+ * String: 6937
+ * StringBuilder: 2745
+ * StringBuilder with size: 1882
+ * Count: 6
+ * TextBuilder: 9785
+ * TextBuilder with size: 10082
+ * String: 9471
+ * StringBuilder: 2889
+ * StringBuilder with size: 1857
+ * Count: 7
+ * TextBuilder: 10169
+ * TextBuilder with size: 10528
+ * String: 12746
+ * StringBuilder: 3081
+ * StringBuilder with size: 2139
+ * </pre>
+ * 
+ * @author fordfrog
+ */
+public final class StringUtil
+{
+	
+	private StringUtil()
+	{
+	}
+	
+	/**
+	 * Concatenates strings.
+	 * 
+	 * @param strings
+	 *            strings to be concatenated
+	 * 
+	 * @return concatenated string
+	 * 
+	 * @see StringUtil
+	 */
+	public static String concat(final String... strings)
+	{
+		final StringBuilder sbString = new StringBuilder(getLength(strings));
+		
+		for (final String string : strings)
+		{
+			sbString.append(string);
+		}
+		
+		return sbString.toString();
+	}
+	
+	/**
+	 * Creates new string builder with size initializated to
+	 * <code>sizeHint</code>, unless total length of strings is greater than
+	 * <code>sizeHint</code>.
+	 * 
+	 * @param sizeHint
+	 *            hint for string builder size allocation
+	 * @param strings
+	 *            strings to be appended
+	 * 
+	 * @return created string builder
+	 * 
+	 * @see StringUtil
+	 */
+	public static StringBuilder startAppend(final int sizeHint, final String... strings)
+	{
+		final int length = getLength(strings);
+		final StringBuilder sbString = new StringBuilder(sizeHint > length ? sizeHint : length);
+		
+		for (final String string : strings)
+		{
+			sbString.append(string);
+		}
+		
+		return sbString;
+	}
+	
+	/**
+	 * Appends strings to existing string builder.
+	 * 
+	 * @param sbString
+	 *            string builder
+	 * @param strings
+	 *            strings to be appended
+	 * 
+	 * @see StringUtil
+	 */
+	public static void append(final StringBuilder sbString, final String... strings)
+	{
+		sbString.ensureCapacity(sbString.length() + getLength(strings));
+		
+		for (final String string : strings)
+		{
+			sbString.append(string);
+		}
+	}
+	
+	/**
+	 * Counts total length of all the strings.
+	 * 
+	 * @param strings
+	 *            array of strings
+	 * 
+	 * @return total length of all the strings
+	 */
+	private static int getLength(final String[] strings)
+	{
+		int length = 0;
+		
+		for (final String string : strings)
+		{
+			if (string == null)
+				length += 4;
+			else
+				length += string.length();
+		}
+		
+		return length;
+	}
+}

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

    • Do you want stability? Lagless and bugless game? Instant support? Daily PVP? Long-Term playing? You are in the right place, time to start! Lineage2 X70 Interlude NEW Season 2025 February 8th 13:00 UTC+2 Greece/Lithuania: 13:00 UTC+2 Poland/Norway: 12:00 UTC+1 United Kingdom: 11:00 UTC+0 Brazil/Argentina: 8:00 UTC-3 Opening Bonus First 100 players after third class changing will automaticly get Premium Coin award in their inventory. All new players spawn in town of Gludio! All players start from 25 LvL with starter pack (adenas and equipment)! RATES XP: x70 | SP: x70 Party XP/ SP: x1.2 Adenas drop rate: x30 Drop Items: x25 | Spoil: x25 Drop SealStones rate: x1.2 Drop Manor rate: x1 Drop Quest rate: x5 | Reward rates: x2 (NOT FOR ALL) Raid Boss Drop: x10 Raid Boss Adenas Drop: x3 Grand Boss Drop: x1 Grand Boss Adenas Drop: x2 Information NPC Buffer 32 Buffs | 4 Debuffs PET Buffer for all classes [Except Necromancer] Scheme buffer: 3 Profiles. Buffs time: 2 Hours | Summons buffs - 60min. Global Gatekeeper. GM SHOP till weapon / armor / jewel B grade. Caradine letter 3rd part in GM Shop. Offline shop: SELL , PRIVATE CREATION , PACKAGE SALE from 35 LvL ! Mana potions: 500MP/2s. Spawn Protection: 20 Seconds. EVENTS Manager [TVT/DM]. Max Clients for one PC: 5 Rift | 4S Players: 3 Maximum inventory slots: 240 Maximum inventory slots for Dwarf: 250 Custom drop list: - Raid Boss Horus, Ember, Brakki, Nakondas: 1 VIP COIN (25%) | Korim (50%). - Raid Boss Apepi, Shacram, Atraiban, Korim: 1 BEWS (25%). - Raid Boss Glaki, Olkuth: 1-2 BEAS (40%). - Raid Boss Golkonda, Galaxia: 1-3 BEAS (60%). - Raid Boss Shyeed: 1-3 BEWS (30%) | 1-7 BEAS (40%) | 1-5 TOP LS 76 (50%). - Raid Boss Shuriel: 1-7 TOP LS 76 (50%) | 1-4 BEAS (60%). - Raid Boss Ashakiel: 1-2 BEWS (30%) | 1-7 TOP LS 76 (50%) | 1-4 BEAS (75%). - Raid Boss Antharas Priest Cloe: 1-3 BEWS (30%) | 1-7 TOP LS 76 (70%). ------------------------------------------------ - Hestia: Demon Splinters / Forgotten Blande (10%). - Ember: Arcana Mace / Draconic Bow (10%). - Galaxia: Angel Slayer / Heaven's Divider (10%). 1. Baium Lair and TOI 13/14 are PVP zones. 2. Valakas PVP zone near NPC "Klein" and inside Valakas room. 3. Antharas Lair and near "Heart Of Warding" are PVP zones. 4. Frintezza PVP zone is in first Imperial Tomb room. 5. Queen Ant PVP zone after the bridge and near Boss. 6. Zaken ship deck and rooms - PVP area. How to connect STEP BY STEP: 1. Install clear Lineage2 Interlude client 2. Download our patch, delete old system folder and add our 3. Delete, turn off anti virus or add our system folder to anti virus exceptions 4. Run l2.exe from Lineage2/system 5. Enter data on login window and enjoy the game! * You have to remove, turn off or use exceptions of antivirus because of our security protection. It is not a virus. * If you have connection issues with Windows 8 or 10, press right mouse button on l2.exe icon, press Properties, choose compatibility and unmark compatibility mode. Take your friends, clan, alliance, enemys, sharp your swords, clean your armors and meet your destiny at 2025 February 8th 13:00 UTC+2! WWW.L2BLAZE.NET INTERLUDE Empire X70 New Season: 2025 February 8th 13:00 UTC+2! WEBSITE: http://WWW.L2BLAZE.NET
    • Hello all,  i use L2jAcis 409 and i have problem with oly cycle, everyday is a different oly cycle and oly won't finish at the end of the month...almost 50 cycles and no end. I see oly matches in db but no points and after a day pass with /olympiadstat no points... Any help welcome, thank you.
    • Bump NEW USER IN TELEGRAM AND DISCORD IS "mileanum"  NEW USER IN TELEGRAM AND DISCORD IS "mileanum"  NEW USER IN TELEGRAM AND DISCORD IS "mileanum" NEW USER IN TELEGRAM AND DISCORD IS "mileanum" 
  • Topics

×
×
  • Create New...