Advertisement
Guest User

Advanced PvP/Pk Name/Title color system.

a guest
Apr 21st, 2011
2,547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.74 KB | None | 0 0
  1. Index: java/net/sf/l2j/Config.java
  2. ===================================================================
  3. --- java/net/sf/l2j/Config.java (revision 82)
  4. +++ java/net/sf/l2j/Config.java (working copy)
  5. @@ -34,6 +34,7 @@
  6. import java.util.logging.Logger;
  7.  
  8. import javolution.util.FastList;
  9. +import javolution.util.FastMap;
  10. import net.sf.l2j.util.StringUtil;
  11.  
  12. /**
  13. @@ -60,6 +61,7 @@
  14. public static final String SERVER_FILE = "./config/server.properties";
  15. public static final String SIEGE_FILE = "./config/siege.properties";
  16. public static final String TELNET_FILE = "./config/telnet.properties";
  17. + private static final String PVP_COLOR_SYSTEM_CONFIG_FILE = "./config/pvpcolorsystem.properties";
  18.  
  19. /**--------------------------------------------------
  20. // Variable Definitions
  21. @@ -642,6 +644,11 @@
  22. public static int CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN = 5; // default 5
  23.  
  24. //--------------------------------------------------
  25. +
  26. + public static String PVPS_COLORS;
  27. + public static FastMap<Integer, Integer> PVPS_COLORS_LIST;
  28. + public static String PKS_COLORS;
  29. + public static FastMap<Integer, Integer> PKS_COLORS_LIST;
  30.  
  31. /**
  32. * This class initializes all global variables for configuration.<br>
  33. @@ -653,6 +660,60 @@
  34. {
  35. _log.info("Loading gameserver configuration files.");
  36.  
  37. + try
  38. + {
  39. + Properties pvpcolor = new Properties();
  40. + InputStream is = new FileInputStream(new File(PVP_COLOR_SYSTEM_CONFIG_FILE));
  41. + pvpcolor.load(is);
  42. + is.close();
  43. +
  44. + PVPS_COLORS = pvpcolor.getProperty("PvpsColors", "");
  45. + PVPS_COLORS_LIST = new FastMap<Integer, Integer>();
  46. +
  47. + String[] splitted_pvps_colors = PVPS_COLORS.split(";");
  48. +
  49. + for(String iii:splitted_pvps_colors)
  50. + {
  51. +
  52. + String[] pvps_colors = iii.split(",");
  53. +
  54. + if(pvps_colors.length != 2)
  55. + {
  56. + System.out.println("Invalid properties.");
  57. + }
  58. + else
  59. + {
  60. + PVPS_COLORS_LIST.put(Integer.parseInt(pvps_colors[0]), Integer.decode("0x" + pvps_colors[1]));
  61. + }
  62. +
  63. + }
  64. +
  65. + PKS_COLORS = pvpcolor.getProperty("PksColors", "");
  66. + PKS_COLORS_LIST = new FastMap<Integer, Integer>();
  67. +
  68. + String[] splitted_pks_colors = PKS_COLORS.split(";");
  69. +
  70. + for(String iii:splitted_pks_colors)
  71. + {
  72. +
  73. + String[] pks_colors = iii.split(",");
  74. +
  75. + if(pks_colors.length != 2)
  76. + {
  77. + System.out.println("Invalid properties.");
  78. + }
  79. + else
  80. + {
  81. + PKS_COLORS_LIST.put(Integer.parseInt(pks_colors[0]), Integer.decode("0x" + pks_colors[1]));
  82. + }
  83. +
  84. + }
  85. + }
  86. + catch (Exception e)
  87. + {
  88. + e.printStackTrace();
  89. + throw new Error("Server failed to load "+PVP_COLOR_SYSTEM_CONFIG_FILE+" file.");
  90. + }
  91. // Clans settings
  92. try
  93. {
  94. Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminEditChar.java
  95. ===================================================================
  96. --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminEditChar.java (revision 82)
  97. +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminEditChar.java (working copy)
  98. @@ -33,6 +33,7 @@
  99. import net.sf.l2j.L2DatabaseFactory;
  100. import net.sf.l2j.gameserver.GmListTable;
  101. import net.sf.l2j.gameserver.ai.CtrlIntention;
  102. +import net.sf.l2j.gameserver.anarchy.PvPColorSystem;
  103. import net.sf.l2j.gameserver.datatables.ClanTable;
  104. import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  105. import net.sf.l2j.gameserver.model.L2Object;
  106. @@ -638,7 +639,10 @@
  107. player.setCurrentCp(cpval);
  108. player.setPvpFlag(pvpflagval);
  109. player.setPvpKills(pvpkillsval);
  110. + PvPColorSystem pvpcolor = new PvPColorSystem();
  111. + pvpcolor.updateNameColor(player);
  112. player.setPkKills(pkkillsval);
  113. + pvpcolor.updateTitleColor(player);
  114.  
  115. // Save the changed parameters to the database.
  116. player.store();
  117. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  118. ===================================================================
  119. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 82)
  120. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
  121. @@ -50,6 +50,7 @@
  122. import net.sf.l2j.gameserver.ai.CtrlIntention;
  123. import net.sf.l2j.gameserver.ai.L2CharacterAI;
  124. import net.sf.l2j.gameserver.ai.L2PlayerAI;
  125. +import net.sf.l2j.gameserver.anarchy.PvPColorSystem;
  126. import net.sf.l2j.gameserver.cache.HtmCache;
  127. import net.sf.l2j.gameserver.communitybbs.BB.Forum;
  128. import net.sf.l2j.gameserver.communitybbs.Manager.ForumsBBSManager;
  129. @@ -4640,6 +4641,10 @@
  130. {
  131. // Add karma to attacker and increase its PK counter
  132. setPvpKills(getPvpKills() + 1);
  133. +
  134. + PvPColorSystem pvpcolor = new PvPColorSystem();
  135. + pvpcolor.updateNameColor(this);
  136. + pvpcolor.updateTitleColor(this);
  137.  
  138. // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
  139. sendPacket(new UserInfo(this));
  140. Index: java/net/sf/l2j/gameserver/anarchy/PvPColorSystem.java
  141. ===================================================================
  142. --- java/net/sf/l2j/gameserver/anarchy/PvPColorSystem.java (revision 0)
  143. +++ java/net/sf/l2j/gameserver/anarchy/PvPColorSystem.java (revision 0)
  144. @@ -0,0 +1,53 @@
  145. +/* This program is free software; you can redistribute it and/or modify
  146. + * it under the terms of the GNU General Public License as published by
  147. + * the Free Software Foundation; either version 2, or (at your option)
  148. + * any later version.
  149. + *
  150. + * This program is distributed in the hope that it will be useful,
  151. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  152. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  153. + * GNU General Public License for more details.
  154. + *
  155. + * You should have received a copy of the GNU General Public License
  156. + * along with this program; if not, write to the Free Software
  157. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  158. + * 02111-1307, USA.
  159. + *
  160. + * http://www.gnu.org/copyleft/gpl.html
  161. + */
  162. +package net.sf.l2j.gameserver.anarchy;
  163. +
  164. +import java.util.Set;
  165. +
  166. +import net.sf.l2j.Config;
  167. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  168. +
  169. +/**
  170. + *
  171. + * @author Anarchy
  172. + */
  173. +public class PvPColorSystem
  174. +{
  175. + public void updateNameColor(L2PcInstance player)
  176. + {
  177. + Set<Integer> pvpscolors = Config.PVPS_COLORS_LIST.keySet();
  178. + for (Integer i : pvpscolors)
  179. + {
  180. + if (player.getPvpKills() >= i)
  181. + {
  182. + player.getAppearance().setNameColor(Config.PVPS_COLORS_LIST.get(i));
  183. + }
  184. + }
  185. + }
  186. + public void updateTitleColor(L2PcInstance player)
  187. + {
  188. + Set<Integer> pkscolors = Config.PKS_COLORS_LIST.keySet();
  189. + for (Integer i : pkscolors)
  190. + {
  191. + if (player.getPkKills() >= i)
  192. + {
  193. + player.getAppearance().setTitleColor(Config.PKS_COLORS_LIST.get(i));
  194. + }
  195. + }
  196. + }
  197. +}
  198. Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  199. ===================================================================
  200. --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 82)
  201. +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
  202. @@ -27,6 +27,7 @@
  203. import net.sf.l2j.gameserver.Olympiad;
  204. import net.sf.l2j.gameserver.SevenSigns;
  205. import net.sf.l2j.gameserver.TaskPriority;
  206. +import net.sf.l2j.gameserver.anarchy.PvPColorSystem;
  207. import net.sf.l2j.gameserver.cache.HtmCache;
  208. import net.sf.l2j.gameserver.datatables.AdminCommandAccessRights;
  209. import net.sf.l2j.gameserver.datatables.MapRegionTable;
  210. @@ -85,6 +86,10 @@
  211. {
  212. L2PcInstance activeChar = getClient().getActiveChar();
  213.  
  214. + PvPColorSystem pvpcolor = new PvPColorSystem();
  215. + pvpcolor.updateNameColor(activeChar);
  216. + pvpcolor.updateTitleColor(activeChar);
  217. +
  218. if (activeChar == null)
  219. {
  220. _log.warning("EnterWorld failed! activeChar is null...");
  221. Index: config/pvpcolorsystem.properties
  222. ===================================================================
  223. --- config/pvpcolorsystem.properties (revision 0)
  224. +++ config/pvpcolorsystem.properties (revision 0)
  225. @@ -0,0 +1,9 @@
  226. +# Advanced pvp/pk color system, by Anarchy.
  227. +
  228. +# PvP Name color System.
  229. +# It works like: pvps,color;pvps,color, eg. 100,00FF00;200,FF0000;300,0000FF;.
  230. +PvpsColors = 100,00FF00;
  231. +
  232. +# Pk Title color System.
  233. +# It works like: pks,color;pks,color, eg. 100,00FF00;200,FF0000;300,0000FF;.
  234. +PksColors = 100,00FF00;
  235. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement