Noticias:

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

Menú Principal

New Name Color PvP

Iniciado por Swarlog, Jul 26, 2025, 11:30 PM

Tema anterior - Siguiente tema

Swarlog

Index: config/players.properties
===================================================================
--- config/players.properties	(revision 127)
+++ config/players.properties	(working copy)
@@ -298,4 +298,8 @@
 MaxBuffsAmount = 99
 
 # Store buffs/debuffs on user logout?
-StoreSkillCooltime = True
\ No newline at end of file
+StoreSkillCooltime = True
+
+# Cow - shit:
+NameColorSwapsPvp = 100_00FF00,FFFF00;200_F34342,000000,54673F
+NameColorSwapTime = 1
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/ExtremeColoring.java
===================================================================
--- java/net/sf/l2j/gameserver/ExtremeColoring.java	(revision 0)
+++ java/net/sf/l2j/gameserver/ExtremeColoring.java	(revision 0)
@@ -0,0 +1,111 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author Anarchy
+ *
+ */
+public class ExtremeColoring
+{
+	public static void checkUpdate(L2PcInstance p)
+	{
+		int lastI = 0;
+		for (int i : Config.PLAYER_COLORS.keySet())
+		{
+			if (p.getPvpKills() >= i)
+			{
+				lastI = i;
+			}
+		}
+		
+		if (lastI == 0)
+			return;
+		
+		String s = "";
+		for (int i : Config.PLAYER_COLORS.get(lastI))
+		{
+			s += i;
+		}
+		
+		if (!s.equals(p.getColoring().getColors()))
+		{
+			p.getColorTask().cancel(true);
+			p.setColorTask(null);
+			p.setColoring(null);
+			
+			p.setColorTask(ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Coloring(Config.PLAYER_COLORS.get(lastI), p), Config.PLAYER_COLORS_TIME*1000, Config.PLAYER_COLORS_TIME*1000));
+		}
+	}
+	
+	public static void begin(L2PcInstance p)
+	{
+		int lastI = 0;
+		
+		for (int i : Config.PLAYER_COLORS.keySet())
+		{
+			if (p.getPvpKills() >= i)
+			{
+				lastI = i;
+			}
+		}
+		
+		if (lastI == 0)
+			return;
+		
+		p.setColorTask(ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Coloring(Config.PLAYER_COLORS.get(lastI), p), Config.PLAYER_COLORS_TIME*1000, Config.PLAYER_COLORS_TIME*1000));
+	}
+	
+	public static class Coloring implements Runnable
+	{
+		private int[] color;
+		private L2PcInstance p;
+		private int last = 0;
+		
+		public Coloring(ArrayList<Integer> colors, L2PcInstance p)
+		{
+			for (int i = 0; i < colors.size(); i++)
+			{
+				color[i] = colors.get(i);
+			}
+			this.p = p;
+		}
+		
+		@Override
+		public void run()
+		{
+			last++;
+			p.getAppearance().setNameColor(color[last]);
+			p.broadcastUserInfo();
+		}
+		
+		public String getColors()
+		{
+			String s = "";
+			
+			for (int i : color)
+			{
+				s += i;
+			}
+			
+			return s;
+		}
+	}
+}
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 127)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -36,6 +36,8 @@
 
 import net.sf.l2j.Config;
 import net.sf.l2j.L2DatabaseFactory;
+import net.sf.l2j.gameserver.ExtremeColoring;
+import net.sf.l2j.gameserver.ExtremeColoring.Coloring;
 import net.sf.l2j.gameserver.GameTimeController;
 import net.sf.l2j.gameserver.GeoData;
 import net.sf.l2j.gameserver.ItemsAutoDestroy;
@@ -251,6 +253,30 @@
  */
 public final class L2PcInstance extends L2Playable
 {
+	private Coloring coloring = null;
+	
+	public Coloring getColoring()
+	{
+		return coloring;
+	}
+	
+	public void setColoring(Coloring val)
+	{
+		coloring = val;
+	}
+	
+	private Future<?> colorTask = null;
+	
+	public Future<?> getColorTask()
+	{
+		return colorTask;
+	}
+	
+	public void setColorTask(Future<?> val)
+	{
+		colorTask = val;
+	}
+	
 	private int mobsKilled = 0;
 	
 	public void setMobsKilled(int val)
@@ -4541,6 +4567,15 @@
 			return;
 		}
 		
+		if (getColorTask() == null)
+		{
+			ExtremeColoring.begin(this);
+		}
+		else
+		{
+			ExtremeColoring.checkUpdate(this);
+		}
+		
 		getAppearance().setNameColor(0xFFFFFF);
 		broadcastUserInfo();
 	}
Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java	(revision 127)
+++ java/net/sf/l2j/Config.java	(working copy)
@@ -488,6 +488,10 @@
 	public static boolean STORE_SKILL_COOLTIME;
 	public static int BUFFS_MAX_AMOUNT;
 	
+	/** Crap */
+	public static Map<Integer, ArrayList<Integer>> PLAYER_COLORS = new HashMap<>();
+	public static int PLAYER_COLORS_TIME;
+	
 	// --------------------------------------------------
 	// Server
 	// --------------------------------------------------
@@ -1175,6 +1179,20 @@
 			BUFFS_MAX_AMOUNT = players.getProperty("MaxBuffsAmount", 20);
 			STORE_SKILL_COOLTIME = players.getProperty("StoreSkillCooltime", true);
 			
+			PLAYER_COLORS_TIME = players.getProperty("NameColorSwapTime", 1);
+			String player_colors = players.getProperty("NameColorSwapsPvp", "100_00FF00,FFFF00;200_F34342,000000,54673F");
+			String[] pc1 = player_colors.split(";");
+			for (String s : pc1)
+			{
+				String[] pc2 = s.split("_");
+				ArrayList<Integer> temp = new ArrayList<>();
+				for (String ss : pc2[1].split(","))
+				{
+					temp.add(Integer.decode("0x"+ss));
+				}
+				PLAYER_COLORS.put(Integer.parseInt(pc2[0]), temp);
+			}
+			
 			// server
 			ExProperties server = load(SERVER_FILE);
 			
Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java	(revision 127)
+++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java	(working copy)
@@ -16,6 +16,7 @@
 
 import net.sf.l2j.Config;
 import net.sf.l2j.gameserver.Announcements;
+import net.sf.l2j.gameserver.ExtremeColoring;
 import net.sf.l2j.gameserver.GameTimeController;
 import net.sf.l2j.gameserver.SevenSigns;
 import net.sf.l2j.gameserver.customs.events.SoloEventManager;
@@ -251,6 +252,8 @@
 		//{
 			//ServerPreview.getInstance().createNew(activeChar);
 		//}
+		
+		ExtremeColoring.begin(activeChar);
 	}
 	
 	private static void engage(L2PcInstance cha)

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