Guest User

PVP/PK SYSTEM COLOR

a guest
Oct 21st, 2021
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.80 KB | None | 0 0
  1. Index: config/pvpcolorsystem.properties
  2. ===================================================================
  3. --- config/pvpcolorsystem.properties    (revision 0)
  4. +++ config/pvpcolorsystem.properties    (revision 0)
  5. @@ -0,0 +1,9 @@
  6. +# Advanced pvp/pk color system, by Anarchy.
  7. +
  8. +# PvP Name color System.
  9. +# It works like: pvps,color;pvps,color, eg. 100,00FF00;200,FF0000;300,0000FF;.
  10. +PvpsColors = 100,00FF00;
  11. +
  12. +# Pk Title color System.
  13. +# It works like: pks,color;pks,color, eg. 100,00FF00;200,FF0000;300,0000FF;.
  14. +PksColors = 100,00FF00;
  15. \ No newline at end of file
  16. Index: java/net/sf/l2j/Config.java
  17. ===================================================================
  18. --- java/net/sf/l2j/Config.java (revision 2)
  19. +++ java/net/sf/l2j/Config.java (working copy)
  20. @@ -46,6 +46,7 @@
  21.     public static final String RUS_ACIS_FILE = "./config/rus_acis.properties";
  22.     public static final String SERVER_FILE = "./config/server.properties";
  23.     public static final String SIEGE_FILE = "./config/siege.properties";
  24. +   private static final String PVP_COLOR_SYSTEM_CONFIG_FILE = "./config/pvpcolorsystem.properties";
  25.    
  26.     // --------------------------------------------------
  27.     // Clans settings
  28. @@ -776,6 +777,11 @@
  29.     public static boolean CABAL_BUFFER;
  30.     public static int[] NO_DROP_ITEMS;
  31.    
  32. +   /** PVP COLOR SYSTEM */
  33. +   public static String PVPS_COLORS;
  34. +   public static Map<Integer, Integer> PVPS_COLORS_LIST;
  35. +   public static String PKS_COLORS;
  36. +   public static Map<Integer, Integer> PKS_COLORS_LIST;
  37.     /**
  38.      * Initialize {@link ExProperties} from specified configuration file.
  39.      * @param filename : File name to be loaded.
  40. @@ -814,6 +820,46 @@
  41.     }
  42.    
  43.     /**
  44. +    * Loads PvPColor settings.
  45. +    */
  46. +   private static final void loadPvPColors() {
  47. +       final ExProperties pvpcolor = initProperties(PVP_COLOR_SYSTEM_CONFIG_FILE);
  48. +
  49. +       PVPS_COLORS = pvpcolor.getProperty("PvpsColors", "");
  50. +       PVPS_COLORS_LIST = new HashMap <> ();
  51. +
  52. +       String[] splitted_pvps_colors = PVPS_COLORS.split(";");
  53. +
  54. +       for (String iii: splitted_pvps_colors) {
  55. +
  56. +           String[] pvps_colors = iii.split(",");
  57. +
  58. +           if (pvps_colors.length != 2) {
  59. +               System.out.println("Invalid properties.");
  60. +           } else {
  61. +               PVPS_COLORS_LIST.put(Integer.parseInt(pvps_colors[0]), Integer.decode("0x" + pvps_colors[1]));
  62. +           }
  63. +
  64. +       }
  65. +
  66. +       PKS_COLORS = pvpcolor.getProperty("PksColors", "");
  67. +       PKS_COLORS_LIST = new HashMap <> ();
  68. +
  69. +       String[] splitted_pks_colors = PKS_COLORS.split(";");
  70. +
  71. +       for (String iii: splitted_pks_colors) {
  72. +
  73. +           String[] pks_colors = iii.split(",");
  74. +
  75. +           if (pks_colors.length != 2) {
  76. +               System.out.println("Invalid properties.");
  77. +           } else {
  78. +               PKS_COLORS_LIST.put(Integer.parseInt(pks_colors[0]), Integer.decode("0x" + pks_colors[1]));
  79. +           }
  80. +
  81. +       }
  82. +   }
  83. +   /**
  84.      * Loads clan and clan hall settings.
  85.      */
  86.     private static final void loadClans()
  87. @@ -1646,6 +1692,9 @@
  88.        
  89.         // clans settings
  90.         loadClans();
  91. +
  92. +       // pvpcolor settings
  93. +       loadPvPColors();
  94.        
  95.         // events settings
  96.         loadEvents();
  97. Index: java/net/sf/l2j/gameserver/anarchy/PvPColorSystem.java
  98. ===================================================================
  99. --- java/net/sf/l2j/gameserver/anarchy/PvPColorSystem.java  (revision 0)
  100. +++ java/net/sf/l2j/gameserver/anarchy/PvPColorSystem.java  (revision 0)
  101. @@ -0,0 +1,53 @@
  102. +/* This program is free software; you can redistribute it and/or modify
  103. + * it under the terms of the GNU General Public License as published by
  104. + * the Free Software Foundation; either version 2, or (at your option)
  105. + * any later version.
  106. + *
  107. + * This program is distributed in the hope that it will be useful,
  108. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  109. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  110. + * GNU General Public License for more details.
  111. + *
  112. + * You should have received a copy of the GNU General Public License
  113. + * along with this program; if not, write to the Free Software
  114. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  115. + * 02111-1307, USA.
  116. + *
  117. + * http://www.gnu.org/copyleft/gpl.html
  118. + */
  119. +package net.sf.l2j.gameserver.anarchy;
  120. +
  121. +import java.util.Set;
  122. +
  123. +import net.sf.l2j.Config;
  124. +import net.sf.l2j.gameserver.model.actor.Player;
  125. +
  126. +/**
  127. + *
  128. + * @author  Anarchy
  129. + */
  130. +public class PvPColorSystem
  131. +{
  132. +   public void updateNameColor(Player player)
  133. +   {
  134. +       Set<Integer> pvpscolors = Config.PVPS_COLORS_LIST.keySet();
  135. +       for (Integer i : pvpscolors)
  136. +       {
  137. +           if (player.getPvpKills() >= i)
  138. +           {
  139. +               player.getAppearance().setNameColor(Config.PVPS_COLORS_LIST.get(i));
  140. +           }
  141. +       }
  142. +   }
  143. +   public void updateTitleColor(Player player)
  144. +   {
  145. +       Set<Integer> pkscolors = Config.PKS_COLORS_LIST.keySet();
  146. +       for (Integer i : pkscolors)
  147. +       {
  148. +           if (player.getPkKills() >= i)
  149. +           {
  150. +               player.getAppearance().setTitleColor(Config.PKS_COLORS_LIST.get(i));
  151. +           }
  152. +       }
  153. +   }
  154. +}
  155. \ No newline at end of file
  156. Index: java/net/sf/l2j/gameserver/model/actor/Player.java
  157. ===================================================================
  158. --- java/net/sf/l2j/gameserver/model/actor/Player.java  (revision 2)
  159. +++ java/net/sf/l2j/gameserver/model/actor/Player.java  (working copy)
  160. @@ -32,6 +32,7 @@
  161.  
  162.  import net.sf.l2j.Config;
  163.  import net.sf.l2j.gameserver.LoginServerThread;
  164. +import net.sf.l2j.gameserver.anarchy.PvPColorSystem;
  165.  import net.sf.l2j.gameserver.communitybbs.CommunityBoard;
  166.  import net.sf.l2j.gameserver.communitybbs.model.Forum;
  167.  import net.sf.l2j.gameserver.data.SkillTable;
  168. @@ -2971,7 +2972,9 @@
  169.             {
  170.                 // Add PvP point to attacker.
  171.                 setPvpKills(getPvpKills() + 1);
  172. -              
  173. +               PvPColorSystem pvpcolor = new PvPColorSystem();
  174. +               pvpcolor.updateNameColor(this);
  175. +               pvpcolor.updateTitleColor(this);       
  176.                 // Send UserInfo packet to attacker with its Karma and PK Counter
  177.                 sendPacket(new UserInfo(this));
  178.             }
  179. Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  180. ===================================================================
  181. --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (revision 2)
  182. +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (working copy)
  183. @@ -54,6 +54,7 @@
  184.  import net.sf.l2j.gameserver.scripting.QuestState;
  185.  import net.sf.l2j.gameserver.skills.L2Skill;
  186.  import net.sf.l2j.gameserver.taskmanager.GameTimeTaskManager;
  187. +import net.sf.l2j.gameserver.anarchy.PvPColorSystem;
  188.  
  189.  public class EnterWorld extends L2GameClientPacket
  190.  {
  191. @@ -94,6 +95,9 @@
  192.             else
  193.                 AdminData.getInstance().addGm(player, true);
  194.         }
  195. +       PvPColorSystem pvpcolor = new PvPColorSystem();
  196. +       pvpcolor.updateNameColor(player);
  197. +       pvpcolor.updateTitleColor(player);
  198.        
  199.         // Set dead status if applies
  200.         if (player.getStatus().getHp() < 0.5 && player.isMortal())
Advertisement
Add Comment
Please, Sign In to add comment