Noticias:

No tienes permiso para ver los enlaces. Para poder verlos Registrate o Conectate.

Menú Principal

Modificar color PK/PvP

Iniciado por Swarlog, Jul 25, 2025, 12:11 AM

Tema anterior - Siguiente tema

Swarlog

net.sf.l2j.config.java

	public static final String PLAYERS_FILE = "./config/players.properties";
	public static final String SERVER_FILE = "./config/server.properties";
	public static final String SIEGE_FILE = "./config/siege.properties";
+	public static final String CUSTOM_FILE = "./config/custom.properties";
-------------------------------------------------------------------------------------------------
+    // --------------------------------------------------
+    // Custom settings
+    // --------------------------------------------------
+	public static boolean ALLOW_PVP_NAME_COLOR_SYSTEM;
+	public static Map<Integer, Integer> PVP_COLORS = new HashMap<>();
+	public static boolean ALLOW_PK_TITLE_COLOR_SYSTEM;
+	public static Map<Integer, Integer> PK_COLORS = new HashMap<>();
+	
	// --------------------------------------------------
	// Clans settings
	// --------------------------------------------------
-------------------------------------------------------------------------------------------------
			FLOOD_PROTECTOR_MANOR = new FloodProtectorConfig("ManorFloodProtector");
			FLOOD_PROTECTOR_SENDMAIL = new FloodProtectorConfig("SendMailFloodProtector");
			FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector");
			
			_log.info("Loading gameserver configuration files.");
+			
+            try
+            {
+                               Properties custom = new Properties();
+                               InputStream is = new FileInputStream(new File(CUSTOM_FILE));
+                               custom.load(is);
+                               is.close();
+                               
+                                                      ALLOW_PVP_NAME_COLOR_SYSTEM = Boolean.parseBoolean(custom.getProperty("AllowPvpNameColorSystem", "false"));
+                                                      String pvp_colors = custom.getProperty("PvpColors", "100,FFFF00");
+                                                      String pvp_colors_splitted_1[] = pvp_colors.split(";");
+                                                  for (String s : pvp_colors_splitted_1)
+                                                  {
+                                                      String pvp_colors_splitted_2[] = s.split(",");
+                                                      PVP_COLORS.put(Integer.parseInt(pvp_colors_splitted_2[0]), Integer.decode("0x"+pvp_colors_splitted_2[1]));
+                                                  }
+                                                      ALLOW_PK_TITLE_COLOR_SYSTEM = Boolean.parseBoolean(custom.getProperty("AllowPkTitleColorSystem", "false"));
+                                                      String pk_colors = custom.getProperty("PkColors", "100,FFFF00");
+                                                      String pk_colors_splitted_1[] = pk_colors.split(";");
+                                                  for (String s : pk_colors_splitted_1)
+                                                  {
+                                                      String pk_colors_splitted_2[] = s.split(",");
+                                                      PK_COLORS.put(Integer.parseInt(pk_colors_splitted_2[0]), Integer.decode("0x"+pk_colors_splitted_2[1]));
+                                                  }
+                                                      }
+                                   catch (Exception e)
+                                   {
+                                           e.printStackTrace();
+                                           throw new Error("Server failed to load " + CUSTOM_FILE + " file.");
+                                   }
                            
			// Clans settings
			ExProperties clans = load(CLANS_FILE);
			ALT_CLAN_JOIN_DAYS = clans.getProperty("DaysBeforeJoinAClan", 5);
			ALT_CLAN_CREATE_DAYS = clans.getProperty("DaysBeforeCreateAClan", 10);
			ALT_MAX_NUM_OF_CLANS_IN_ALLY = clans.getProperty("AltMaxNumOfClansInAlly", 3);
			ALT_CLAN_MEMBERS_FOR_WAR = clans.getProperty("AltClanMembersForWar", 15);

---------------------------------------------------------------------------------------------------------------------------------------
CONFIG//custom.properties

+#=============================================================
+#         Config Color PvP & Pk System
+#=============================================================
+# PvP name color system.
+AllowPvpNameColorSystem = True
+# PvP name colors, works like: pvps,color;pvps,color;
+PvpColors = 100,FF00FF;200,FF00FF
+
+# PvP title color system.
+AllowPkTitleColorSystem = True
+# Pk title colors, works like: pks,color;pks,color;
+PkColors = 100,FF00FF;200,FF00FF
+
---------------------------------------------------------------------------------------------------------------------------------------
net.sf.l2j.gameserver.network.clientpackets.EnterWorld.java

		// Attacker or spectator logging into a siege zone will be ported at town.
		if (!activeChar.isGM() && (!activeChar.isInSiege() || activeChar.getSiegeState() < 2) && activeChar.isInsideZone(ZoneId.SIEGE))
			activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
		
+		if (Config.ALLOW_PVP_NAME_COLOR_SYSTEM || Config.ALLOW_PK_TITLE_COLOR_SYSTEM)
+        {
+                activeChar.colorsCheck();
+        }
	}

---------------------------------------------------------------------------------------------------------------------------------------
net.sf.l2j.gameserver.model.actor.instances.L2PcInstance.java

	/**
	 * @return PvP Kills of the L2PcInstance (number of player killed during a PvP).
	 */
	public int getPvpKills()
	{
		return _pvpKills;
	}
+	       public void colorsCheck()
+	       {
+	               if (Config.ALLOW_PVP_NAME_COLOR_SYSTEM)
+	               {
+	                       for (int i : Config.PVP_COLORS.keySet())
+	                       {
+	                               if (getPvpKills() >= i)
+	                               {
+	                                       getAppearance().setNameColor(Config.PVP_COLORS.get(i));
+	                                       broadcastUserInfo();
+	                               }
+	                       }
+	               }
+	              
+	               if (Config.ALLOW_PK_TITLE_COLOR_SYSTEM)
+	               {
+	                       for (int i : Config.PK_COLORS.keySet())
+	                       {
+	                               if (getPkKills() >= i)
+	                               {
+	                                       getAppearance().setTitleColor(Config.PK_COLORS.get(i));
+	                                       broadcastUserInfo();
+	                               }
+	                       }
+	               }
+	       }
	    
	/**
	 * Set PvP Kills of the L2PcInstance (number of player killed during a PvP).
	 * @param pvpKills A value.
	 */
-------------------------------------------------------------------------------------------------
				// Add PvP point to attacker.
				setPvpKills(getPvpKills() + 1);
				
+				               if (Config.ALLOW_PVP_NAME_COLOR_SYSTEM || Config.ALLOW_PK_TITLE_COLOR_SYSTEM)
+					               {
+					                       colorsCheck();
+					               }
				               
				// Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
				sendPacket(new UserInfo(this));
			}
		}

---------------------------------------------------------------------------------------------------------------------------------------