Noticias:

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

Menú Principal

Character Killing Monuments - Acis (Top PvP/PK 24 hours)

Iniciado por Swarlog, Jul 27, 2025, 12:14 AM

Tema anterior - Siguiente tema

Swarlog



CitarCORE:

### Eclipse Workspace Patch 1.0
#P aCis_gameserver
Index: java/net/sf/l2j/gameserver/network/serverpackets/NpcInfoPolymorph.java
===================================================================
--- java/net/sf/l2j/gameserver/network/serverpackets/NpcInfoPolymorph.java    (revision 0)
+++ java/net/sf/l2j/gameserver/network/serverpackets/NpcInfoPolymorph.java    (working copy)
@@ -0,0 +1,203 @@
+/*
+ * 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.network.serverpackets;
+
+import net.sf.l2j.gameserver.datatables.CharTemplateTable;
+import net.sf.l2j.gameserver.datatables.ClanTable;
+import net.sf.l2j.gameserver.model.CharSelectInfoPackage;
+import net.sf.l2j.gameserver.model.L2Clan;
+import net.sf.l2j.gameserver.model.actor.L2PcPolymorph;
+import net.sf.l2j.gameserver.model.actor.template.PcTemplate;
+import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
+
+/**
+ * @author paytaly
+ */
+public final class NpcInfoPolymorph extends L2GameServerPacket
+{
+    private final L2PcPolymorph _activeChar;
+    private final CharSelectInfoPackage _morph;
+    private final PcTemplate _template;
+    private final L2Clan _clan;
+    private final int _x, _y, _z, _heading;
+    private final int _mAtkSpd, _pAtkSpd;
+    private final int _runSpd, _walkSpd;
+    private final float _moveMultiplier;
+    
+    public NpcInfoPolymorph(L2PcPolymorph cha)
+    {
+        _activeChar = cha;
+        _morph = cha.getPolymorphInfo();
+        _template = CharTemplateTable.getInstance().getTemplate(_morph.getBaseClassId());
+        _clan = ClanTable.getInstance().getClan(_morph.getClanId());
+        
+        _x = _activeChar.getX();
+        _y = _activeChar.getY();
+        _z = _activeChar.getZ();
+        _heading = _activeChar.getHeading();
+        
+        _mAtkSpd = _activeChar.getMAtkSpd();
+        _pAtkSpd = _activeChar.getPAtkSpd();
+        
+        _moveMultiplier = _activeChar.getMovementSpeedMultiplier();
+        _runSpd = (int) (_activeChar.getRunSpeed() / _moveMultiplier);
+        _walkSpd = (int) (_activeChar.getWalkSpeed() / _moveMultiplier);
+    }
+    
+    @Override
+    protected final void writeImpl()
+    {
+        writeC(0x03);
+        writeD(_x);
+        writeD(_y);
+        writeD(_z);
+        writeD(_heading);
+        writeD(_activeChar.getObjectId());
+        writeS(_morph.getName());
+        writeD(_morph.getRace());
+        writeD(_morph.getSex());
+        
+        writeD(_morph.getBaseClassId());
+        
+        writeD(_morph.getPaperdollItemId(Inventory.PAPERDOLL_HAIRALL));
+        writeD(_morph.getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
+        writeD(_morph.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
+        writeD(_morph.getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
+        writeD(_morph.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
+        writeD(_morph.getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
+        writeD(_morph.getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
+        writeD(_morph.getPaperdollItemId(Inventory.PAPERDOLL_FEET));
+        writeD(_morph.getPaperdollItemId(Inventory.PAPERDOLL_BACK));
+        writeD(_morph.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
+        writeD(_morph.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
+        writeD(_morph.getPaperdollItemId(Inventory.PAPERDOLL_FACE));
+        
+        // c6 new h's
+        writeH(0x00);
+        writeH(0x00);
+        writeH(0x00);
+        writeH(0x00);
+        writeD(_morph.getAugmentationId());
+        writeH(0x00);
+        writeH(0x00);
+        writeH(0x00);
+        writeH(0x00);
+        writeH(0x00);
+        writeH(0x00);
+        writeH(0x00);
+        writeH(0x00);
+        writeH(0x00);
+        writeH(0x00);
+        writeH(0x00);
+        writeH(0x00);
+        writeD(0x00);
+        writeH(0x00);
+        writeH(0x00);
+        writeH(0x00);
+        writeH(0x00);
+        
+        writeD(0);
+        writeD(0);
+        
+        writeD(_mAtkSpd);
+        writeD(_pAtkSpd);
+        
+        writeD(0);
+        writeD(0);
+        
+        writeD(_runSpd);
+        writeD(_walkSpd);
+        writeD(_runSpd); // swim run speed
+        writeD(_walkSpd); // swim walk speed
+        writeD(_runSpd); // fl run speed
+        writeD(_walkSpd); // fl walk speed
+        writeD(_runSpd); // fly run speed
+        writeD(_walkSpd); // fly walk speed
+        writeF(_activeChar.getMovementSpeedMultiplier());
+        writeF(_activeChar.getAttackSpeedMultiplier());
+        
+        writeF(_template.getCollisionRadius());
+        writeF(_template.getCollisionHeight());
+        
+        writeD(_morph.getHairStyle());
+        writeD(_morph.getHairColor());
+        writeD(_morph.getFace());
+        
+        writeS(_activeChar.getVisibleTitle());
+        
+        if (_clan != null)
+        {
+            writeD(_clan.getClanId());
+            writeD(_clan.getCrestId());
+            writeD(_clan.getAllyId());
+            writeD(_clan.getAllyCrestId());
+        }
+        else
+        {
+            writeD(0);
+            writeD(0);
+            writeD(0);
+            writeD(0);
+        }
+        
+        writeD(0);
+        
+        writeC(1); // standing = 1 sitting = 0
+        writeC(_activeChar.isRunning() ? 1 : 0); // running = 1 walking = 0
+        writeC(_activeChar.isInCombat() ? 1 : 0);
+        writeC(_activeChar.isAlikeDead() ? 1 : 0);
+        
+        writeC(0); // invisible = 1 visible =0
+            
+        writeC(0); // 1 on strider 2 on wyvern 0 no mount
+        writeC(0); // 1 - sellshop
+        
+        writeH(0);
+        
+        writeC(0);
+        
+        writeD(_activeChar.getAbnormalEffect());
+
+        writeC(0);
+        writeH(0); // Blue value for name (0 = white, 255 = pure blue)
+        writeD(_morph.getClassId());
+        
+        writeD(_activeChar.getMaxCp());
+        writeD((int) _activeChar.getCurrentCp());
+        writeC((_morph.getEnchantEffect() > 127) ? 127 : _morph.getEnchantEffect());
+        
+        writeC(0x00); // team circle around feet 1= Blue, 2 = red
+            
+        writeD(_clan != null ? _clan.getCrestLargeId() : 0);
+        writeC(0); // Symbol on char menu ctrl+I
+        writeC(0); // Hero Aura
+        
+        writeC(0); // 0x01: Fishing Mode (Cant be undone by setting back to 0)
+        writeD(0);
+        writeD(0);
+        writeD(0);
+        
+        writeD(_activeChar.getNameColor());
+        
+        writeD(0x00); // isRunning() as in UserInfo?
+        
+        writeD(0);
+        writeD(0);
+        
+        writeD(_activeChar.getTitleColor());
+        
+        writeD(0x00);
+    }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java    (revision 3)
+++ java/net/sf/l2j/gameserver/GameServer.java    (working copy)
@@ -78,6 +78,7 @@
 import net.sf.l2j.gameserver.instancemanager.BoatManager;
 import net.sf.l2j.gameserver.instancemanager.CastleManager;
 import net.sf.l2j.gameserver.instancemanager.CastleManorManager;
+import net.sf.l2j.gameserver.instancemanager.CharacterKillingManager;
 import net.sf.l2j.gameserver.instancemanager.ClanHallManager;
 import net.sf.l2j.gameserver.instancemanager.CoupleManager;
 import net.sf.l2j.gameserver.instancemanager.CursedWeaponsManager;
@@ -301,6 +302,11 @@
         if (Config.ALT_FISH_CHAMPIONSHIP_ENABLED)
             FishingChampionshipManager.getInstance();
         
+        if (Config.CKM_ENABLED)
+        {
+            CharacterKillingManager.getInstance().init();
+        }
+        
         Util.printSection("System");
         TaskManager.getInstance();
         Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
Index: java/net/sf/l2j/gameserver/model/actor/L2PcPolymorph.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/L2PcPolymorph.java    (revision 0)
+++ java/net/sf/l2j/gameserver/model/actor/L2PcPolymorph.java    (working copy)
@@ -0,0 +1,191 @@
+/*
+ * 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.model.actor;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.logging.Level;
+
+import net.sf.l2j.L2DatabaseFactory;
+import net.sf.l2j.gameserver.model.CharSelectInfoPackage;
+import net.sf.l2j.gameserver.model.L2Object;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
+import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
+import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
+import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
+import net.sf.l2j.gameserver.network.serverpackets.NpcInfoPolymorph;
+
+/**
+ * @author paytaly
+ */
+public class L2PcPolymorph extends L2Npc
+{
+    private CharSelectInfoPackage _polymorphInfo;
+    private int _nameColor = 0xFFFFFF;
+    private int _titleColor = 0xFFFF77;
+    private String _visibleTitle = "";
+    
+    public L2PcPolymorph(int objectId, NpcTemplate template)
+    {
+        super(objectId, template);
+        setIsInvul(true);
+    }
+    
+    @Override
+    public boolean hasRandomAnimation()
+    {
+        return false;
+    }
+    
+    public CharSelectInfoPackage getPolymorphInfo()
+    {
+        return _polymorphInfo;
+    }
+    
+    public void setPolymorphInfo(CharSelectInfoPackage polymorphInfo)
+    {
+        _polymorphInfo = polymorphInfo;
+        
+        for (L2Object object : getKnownList().getKnownObjects())
+        {
+            if (object instanceof L2PcInstance)
+            {
+                sendInfo(object.getActingPlayer());
+            }
+        }
+    }
+    
+    public int getNameColor()
+    {
+        return _nameColor;
+    }
+    
+    public void setNameColor(int nameColor)
+    {
+        _nameColor = nameColor;
+    }
+    
+    public int getTitleColor()
+    {
+        return _titleColor;
+    }
+    
+    public void setTitleColor(int titleColor)
+    {
+        _titleColor = titleColor;
+    }
+    
+    public String getVisibleTitle()
+    {
+        return _visibleTitle;
+    }
+    
+    public void setVisibleTitle(String title)
+    {
+        _visibleTitle = title == null ? "" : title;
+    }
+
+    @Override
+    public void sendInfo(L2PcInstance activeChar)
+    {
+        if (getPolymorphInfo() == null)
+        {
+            super.sendInfo(activeChar);
+            return;
+        }
+        
+        activeChar.sendPacket(new NpcInfoPolymorph(this));
+    }
+    
+    @Override
+    public String getHtmlPath(int npcId, int val)
+    {
+        String pom = "" + npcId;
+        if (val != 0)
+        {
+            pom += "-" + val;
+        }
+        return "data/html/polymorph/" + pom + ".htm";
+    }
+    
+    @Override
+    public void showChatWindow(L2PcInstance player, int val)
+    {
+        String filename = getHtmlPath(getNpcId(), val);
+        
+        // Send a Server->Client NpcHtmlMessage containing the text of the L2Npc to the L2PcInstance
+        final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
+        html.setFile(filename);
+        html.replace("%objectId%", getObjectId());
+        html.replace("%ownername%", getPolymorphInfo() != null ? getPolymorphInfo().getName() : "");
+        player.sendPacket(html);
+        
+        // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
+        player.sendPacket(ActionFailed.STATIC_PACKET);
+    }
+    
+    public static CharSelectInfoPackage loadCharInfo(int objectId)
+    {
+        try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+            PreparedStatement statement = con.prepareStatement("SELECT char_name, race, base_class, classid, sex, face, hairStyle, hairColor, clanid FROM characters WHERE obj_Id = ?"))
+        {
+            statement.setInt(1, objectId);
+            
+            try (ResultSet rs = statement.executeQuery())
+            {
+                if (rs.next())
+                {
+                    final CharSelectInfoPackage charInfo = new CharSelectInfoPackage(objectId, rs.getString("char_name"));
+                    charInfo.setRace(rs.getInt("race"));
+                    charInfo.setBaseClassId(rs.getInt("base_class"));
+                    charInfo.setClassId(rs.getInt("classid"));
+                    charInfo.setSex(rs.getInt("sex"));
+                    charInfo.setFace(rs.getInt("face"));
+                    charInfo.setHairStyle(rs.getInt("hairStyle"));
+                    charInfo.setHairColor(rs.getInt("hairColor"));
+                    charInfo.setClanId(rs.getInt("clanid"));
+                    
+                    // Get the augmentation id for equipped weapon
+                    int weaponObjId = charInfo.getPaperdollObjectId(Inventory.PAPERDOLL_RHAND);
+                    if (weaponObjId > 0)
+                    {
+                        try (PreparedStatement statementAugment = con.prepareStatement("SELECT attributes FROM augmentations WHERE item_id = ?"))
+                        {
+                            statementAugment.setInt(1, weaponObjId);
+                            try (ResultSet rsAugment = statementAugment.executeQuery())
+                            {
+                                if (rsAugment.next())
+                                {
+                                    int augment = rsAugment.getInt("attributes");
+                                    charInfo.setAugmentationId(augment == -1 ? 0 : augment);
+                                }
+                            }
+                        }
+                    }
+                    
+                    return charInfo;
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            _log.log(Level.WARNING, "Could not restore char info: " + e.getMessage(), e);
+        }
+        
+        return null;
+    }
+}
Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java    (revision 3)
+++ java/net/sf/l2j/Config.java    (working copy)
@@ -54,6 +54,7 @@
     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";
     
     // --------------------------------------------------
     // Clans settings
@@ -679,6 +680,16 @@
     public static int CLIENT_PACKET_QUEUE_MAX_UNDERFLOWS_PER_MIN = 1; // default 1
     public static int CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN = 5; // default 5
     
+    /** Character Killing Monument settings */
+    public static boolean CKM_ENABLED;
+    public static long CKM_CYCLE_LENGTH;
+    public static String CKM_PVP_NPC_TITLE;
+    public static int CKM_PVP_NPC_TITLE_COLOR;
+    public static int CKM_PVP_NPC_NAME_COLOR;
+    public static String CKM_PK_NPC_TITLE;
+    public static int CKM_PK_NPC_TITLE_COLOR;
+    public static int CKM_PK_NPC_NAME_COLOR;
+    
     // --------------------------------------------------
     
     /**
@@ -1240,6 +1251,17 @@
             ZONE_TOWN = server.getProperty("ZoneTown", 0);
             SERVER_NEWS = server.getProperty("ShowServerNews", false);
             DISABLE_TUTORIAL = server.getProperty("DisableTutorial", false);
+            
+            // Custom
+            final ExProperties custom = load(CUSTOM_FILE);
+            CKM_ENABLED = custom.getProperty("CKMEnabled", false);
+            CKM_CYCLE_LENGTH = custom.getProperty("CKMCycleLength", 86400000);
+            CKM_PVP_NPC_TITLE = custom.getProperty("CKMPvPNpcTitle", "%kills% PvPs in the last 24h");
+            CKM_PVP_NPC_TITLE_COLOR = Integer.decode(StringUtil.concat("0x", custom.getProperty("CKMPvPNpcTitleColor", "00CCFF")));
+            CKM_PVP_NPC_NAME_COLOR = Integer.decode(StringUtil.concat("0x", custom.getProperty("CKMPvPNpcNameColor", "FFFFFF")));
+            CKM_PK_NPC_TITLE = custom.getProperty("CKMPKNpcTitle", "%kills% PKs in the last 24h");
+            CKM_PK_NPC_TITLE_COLOR = Integer.decode(StringUtil.concat("0x", custom.getProperty("CKMPKNpcTitleColor", "00CCFF")));
+            CKM_PK_NPC_NAME_COLOR = Integer.decode(StringUtil.concat("0x", custom.getProperty("CKMPKNpcNameColor", "FFFFFF")));
         }
         else if (Server.serverMode == Server.MODE_LOGINSERVER)
         {
Index: java/net/sf/l2j/gameserver/instancemanager/CharacterKillingManager.java
===================================================================
--- java/net/sf/l2j/gameserver/instancemanager/CharacterKillingManager.java    (revision 0)
+++ java/net/sf/l2j/gameserver/instancemanager/CharacterKillingManager.java    (working copy)
@@ -0,0 +1,321 @@
+/*
+ * 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.instancemanager;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.L2DatabaseFactory;
+import net.sf.l2j.gameserver.ThreadPoolManager;
+import net.sf.l2j.gameserver.model.CharSelectInfoPackage;
+import net.sf.l2j.gameserver.model.actor.L2PcPolymorph;
+import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
+
+/**
+ * @author paytaly
+ */
+public final class CharacterKillingManager
+{
+    private static final Logger _log = Logger.getLogger(CharacterKillingManager.class.getName());
+    
+    private int _cycle = 0;
+    private long _cycleStart = 0L;
+    private int _winnerPvPKills;
+    private int _winnerPvPKillsCount;
+    private int _winnerPKKills;
+    private int _winnerPKKillsCount;
+    
+    private volatile CharSelectInfoPackage _winnerPvPKillsInfo;
+    private volatile CharSelectInfoPackage _winnerPKKillsInfo;
+    
+    private ScheduledFuture<?> _scheduledKillingCycleTask = null;
+    
+    private List<L2PcPolymorph> pvpMorphListeners = new CopyOnWriteArrayList<>();
+    private List<L2PcPolymorph> pkMorphListeners = new CopyOnWriteArrayList<>();
+    
+    protected CharacterKillingManager()
+    {
+    }
+    
+    public synchronized void init()
+    {
+        try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+            PreparedStatement st = con.prepareStatement("SELECT cycle, cycle_start, winner_pvpkills, winner_pvpkills_count, winner_pkkills, winner_pkkills_count FROM character_kills_info ORDER BY cycle_start DESC LIMIT 1");
+            ResultSet rs = st.executeQuery())
+        {
+            if (rs.next())
+            {
+                _cycle = rs.getInt("cycle");
+                _cycleStart = rs.getLong("cycle_start");
+                _winnerPvPKills = rs.getInt("winner_pvpkills");
+                _winnerPvPKillsCount = rs.getInt("winner_pvpkills_count");
+                _winnerPKKills = rs.getInt("winner_pkkills");
+                _winnerPKKillsCount = rs.getInt("winner_pkkills_count");
+            }
+        }
+        catch (Exception e)
+        {
+            _log.log(Level.WARNING, "Could not load characters killing cycle: " + e.getMessage(), e);
+        }
+        
+        broadcastMorphUpdate();
+        
+        if (_scheduledKillingCycleTask != null)
+        {
+            _scheduledKillingCycleTask.cancel(true);
+        }
+        long millisToNextCycle = (_cycleStart + Config.CKM_CYCLE_LENGTH) - System.currentTimeMillis();
+        _scheduledKillingCycleTask = ThreadPoolManager.getInstance().scheduleGeneral(new CharacterKillingCycleTask(), millisToNextCycle);
+        
+        _log.info(getClass().getSimpleName() + ": Started! Cycle: " + _cycle + " - Next cycle in: " + _scheduledKillingCycleTask.getDelay(TimeUnit.SECONDS) + "s");
+    }
+    
+    public synchronized void newKillingCycle()
+    {
+        _cycleStart = System.currentTimeMillis();
+        computateCyclePvPWinner();
+        computateCyclePKWinner();
+        refreshKillingSnapshot();
+        
+        try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+            PreparedStatement st = con.prepareStatement("INSERT INTO character_kills_info (cycle_start, winner_pvpkills, winner_pvpkills_count, winner_pkkills, winner_pkkills_count) VALUES (?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS))
+        {
+            st.setLong(1, _cycleStart);
+            st.setInt(2, _winnerPvPKills);
+            st.setInt(3, _winnerPvPKillsCount);
+            st.setInt(4, _winnerPKKills);
+            st.setInt(5, _winnerPKKillsCount);
+            st.execute();
+            
+            try (ResultSet rs = st.getGeneratedKeys())
+            {
+                if (rs.next())
+                {
+                    _cycle = rs.getInt(1);
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            _log.log(Level.WARNING, "Could not create characters killing cycle: " + e.getMessage(), e);
+        }
+        
+        broadcastMorphUpdate();
+        
+        if (_scheduledKillingCycleTask != null)
+        {
+            _scheduledKillingCycleTask.cancel(true);
+        }
+        _scheduledKillingCycleTask = ThreadPoolManager.getInstance().scheduleGeneral(new CharacterKillingCycleTask(), Config.CKM_CYCLE_LENGTH);
+    }
+    
+    private void computateCyclePvPWinner()
+    {
+        _winnerPvPKills = 0;
+        _winnerPvPKillsCount = 0;
+        _winnerPvPKillsInfo = null;
+        
+        try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+            PreparedStatement st = con.prepareStatement("SELECT c.obj_Id, (c.pvpkills - COALESCE(ck.pvpkills, 0)) pvpkills FROM characters c LEFT JOIN character_kills_snapshot ck ON ck.charId = c.obj_Id WHERE accesslevel = 0 ORDER BY pvpkills DESC LIMIT 1");
+            ResultSet rs = st.executeQuery();)
+        {
+            if (rs.next())
+            {
+                int kills = rs.getInt(2);
+                if (kills > 0)
+                {
+                    _winnerPvPKills = rs.getInt(1);
+                    _winnerPvPKillsCount = kills;
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            _log.log(Level.WARNING, "Could not computate characters killing cycle winners: " + e.getMessage(), e);
+        }
+    }
+    
+    private void computateCyclePKWinner()
+    {
+        _winnerPKKills = 0;
+        _winnerPKKillsCount = 0;
+        _winnerPKKillsInfo = null;
+        
+        try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+            PreparedStatement st = con.prepareStatement("SELECT c.obj_Id, (c.pkkills - COALESCE(ck.pkkills, 0)) pkkills FROM characters c LEFT JOIN character_kills_snapshot ck ON ck.charId = c.obj_Id WHERE accesslevel = 0 ORDER BY pkkills DESC LIMIT 1");
+            ResultSet rs = st.executeQuery();)
+        {
+            if (rs.next())
+            {
+                int kills = rs.getInt(2);
+                if (kills > 0)
+                {
+                    _winnerPKKills = rs.getInt(1);
+                    _winnerPKKillsCount = kills;
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            _log.log(Level.WARNING, "Could not computate characters killing cycle winners: " + e.getMessage(), e);
+        }
+    }
+    
+    private static void refreshKillingSnapshot()
+    {
+        try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+            PreparedStatement stTruncate = con.prepareStatement("TRUNCATE TABLE character_kills_snapshot");
+            PreparedStatement stRefresh = con.prepareStatement("INSERT INTO character_kills_snapshot (charId, pvpkills, pkkills) SELECT obj_Id, pvpkills, pkkills FROM characters WHERE (pvpkills > 0 OR pkkills > 0) AND accesslevel = 0"))
+        {
+            stTruncate.executeUpdate();
+            stRefresh.executeUpdate();
+        }
+        catch (Exception e)
+        {
+            _log.log(Level.WARNING, "Could not refresh characters killing snapshot: " + e.getMessage(), e);
+        }
+    }
+    
+    public void broadcastMorphUpdate()
+    {
+        final CharSelectInfoPackage winnerPvPKillsInfo = getWinnerPvPKillsInfo();
+        for (L2PcPolymorph npc : pvpMorphListeners)
+        {
+            broadcastPvPMorphUpdate(npc, winnerPvPKillsInfo);
+        }
+        
+        final CharSelectInfoPackage winnerPKKillsInfo = getWinnerPKKillsInfo();
+        for (L2PcPolymorph npc : pkMorphListeners)
+        {
+            broadcastPKMorphUpdate(npc, winnerPKKillsInfo);
+        }
+    }
+    
+    private void broadcastPvPMorphUpdate(L2PcPolymorph npc, CharSelectInfoPackage winnerPvPKillsInfo)
+    {
+        if (winnerPvPKillsInfo == null)
+        {
+            npc.setPolymorphInfo(null);
+            return;
+        }
+        npc.setVisibleTitle(Config.CKM_PVP_NPC_TITLE.replaceAll("%kills%", String.valueOf(_winnerPvPKillsCount)));
+        npc.setTitleColor(Config.CKM_PVP_NPC_TITLE_COLOR);
+        npc.setNameColor(Config.CKM_PVP_NPC_NAME_COLOR);
+        npc.setPolymorphInfo(winnerPvPKillsInfo);
+        npc.broadcastPacket(new SocialAction(npc, 16));
+    }
+    
+    private void broadcastPKMorphUpdate(L2PcPolymorph npc, CharSelectInfoPackage winnerPKKillsInfo)
+    {
+        if (winnerPKKillsInfo == null)
+        {
+            npc.setPolymorphInfo(null);
+            return;
+        }
+        npc.setVisibleTitle(Config.CKM_PK_NPC_TITLE.replaceAll("%kills%", String.valueOf(_winnerPKKillsCount)));
+        npc.setTitleColor(Config.CKM_PK_NPC_TITLE_COLOR);
+        npc.setNameColor(Config.CKM_PK_NPC_NAME_COLOR);
+        npc.setPolymorphInfo(winnerPKKillsInfo);
+        npc.broadcastPacket(new SocialAction(npc, 16));
+    }
+    
+    public boolean addPvPMorphListener(L2PcPolymorph npc)
+    {
+        if (npc == null)
+        {
+            return false;
+        }
+        broadcastPvPMorphUpdate(npc, getWinnerPvPKillsInfo());
+        return pvpMorphListeners.add(npc);
+    }
+    
+    public boolean removePvPMorphListener(L2PcPolymorph npc)
+    {
+        return pvpMorphListeners.remove(npc);
+    }
+    
+    public boolean addPKMorphListener(L2PcPolymorph npc)
+    {
+        if (npc == null)
+        {
+            return false;
+        }
+        broadcastPKMorphUpdate(npc, getWinnerPKKillsInfo());
+        return pkMorphListeners.add(npc);
+    }
+    
+    public boolean removePKMorphListener(L2PcPolymorph npc)
+    {
+        return pkMorphListeners.remove(npc);
+    }
+    
+    private CharSelectInfoPackage getWinnerPvPKillsInfo()
+    {
+        if (_winnerPvPKills != 0 && _winnerPvPKillsInfo == null)
+        {
+            synchronized (this)
+            {
+                if (_winnerPvPKillsInfo == null)
+                {
+                    _winnerPvPKillsInfo = L2PcPolymorph.loadCharInfo(_winnerPvPKills);
+                }
+            }
+        }
+        return _winnerPvPKillsInfo;
+    }
+    
+    private CharSelectInfoPackage getWinnerPKKillsInfo()
+    {
+        if (_winnerPKKills != 0 && _winnerPKKillsInfo == null)
+        {
+            synchronized (this)
+            {
+                if (_winnerPKKillsInfo == null)
+                {
+                    _winnerPKKillsInfo = L2PcPolymorph.loadCharInfo(_winnerPKKills);
+                }
+            }
+        }
+        return _winnerPKKillsInfo;
+    }
+    
+    protected static class CharacterKillingCycleTask implements Runnable
+    {
+        @Override
+        public void run()
+        {
+            CharacterKillingManager.getInstance().newKillingCycle();
+        }
+    }
+    
+    public static CharacterKillingManager getInstance()
+    {
+        return SingletonHolder._instance;
+    }
+    
+    private static class SingletonHolder
+    {
+        protected static final CharacterKillingManager _instance = new CharacterKillingManager();
+    }
+}
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2TopPKMonumentInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2TopPKMonumentInstance.java    (revision 0)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2TopPKMonumentInstance.java    (working copy)
@@ -0,0 +1,51 @@
+/*
+ * 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.model.actor.instance;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.instancemanager.CharacterKillingManager;
+import net.sf.l2j.gameserver.model.actor.L2PcPolymorph;
+import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
+
+/**
+ * @author paytaly
+ */
+public class L2TopPKMonumentInstance extends L2PcPolymorph
+{
+    public L2TopPKMonumentInstance(int objectId, NpcTemplate template)
+    {
+        super(objectId, template);
+    }
+    
+    @Override
+    public void onSpawn()
+    {
+        super.onSpawn();
+        if (Config.CKM_ENABLED)
+        {
+            CharacterKillingManager.getInstance().addPKMorphListener(this);
+        }
+    }
+    
+    @Override
+    public void deleteMe()
+    {
+        super.deleteMe();
+        if (Config.CKM_ENABLED)
+        {
+            CharacterKillingManager.getInstance().removePKMorphListener(this);
+        }
+    }
+}
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2TopPvPMonumentInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2TopPvPMonumentInstance.java    (revision 0)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2TopPvPMonumentInstance.java    (working copy)
@@ -0,0 +1,51 @@
+/*
+ * 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.model.actor.instance;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.instancemanager.CharacterKillingManager;
+import net.sf.l2j.gameserver.model.actor.L2PcPolymorph;
+import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
+
+/**
+ * @author paytaly
+ */
+public class L2TopPvPMonumentInstance extends L2PcPolymorph
+{
+    public L2TopPvPMonumentInstance(int objectId, NpcTemplate template)
+    {
+        super(objectId, template);
+    }
+    
+    @Override
+    public void onSpawn()
+    {
+        super.onSpawn();
+        if (Config.CKM_ENABLED)
+        {
+            CharacterKillingManager.getInstance().addPvPMorphListener(this);
+        }
+    }
+    
+    @Override
+    public void deleteMe()
+    {
+        super.deleteMe();
+        if (Config.CKM_ENABLED)
+        {
+            CharacterKillingManager.getInstance().removePvPMorphListener(this);
+        }
+    }
+}
Index: config/custom.properties
===================================================================
--- config/custom.properties    (revision 0)
+++ config/custom.properties    (working copy)
@@ -0,0 +1,36 @@
+#=============================================================
+#          Character Killing Monuments (by paytaly)
+#=============================================================
+# Enable the Character Killing Monuments
+# Default: False
+CKMEnabled = False
+
+# The killing cycle length
+# Default: 86400000 (24h)
+CKMCycleLength = 86400000
+
+# The title of the Monument for the PvP winner
+# Note: %kills% will be replaced with the winner's PvP count in the cycle
+# Default: %kills% PvPs in the last 24h
+CKMPvPNpcTitle = %kills% PvPs in the last 24h
+
+# The title color of the Monument for the PvP winner
+# Default: 00CCFF (yellow)
+CKMPvPNpcTitleColor = 00CCFF
+
+# The name color of the Monument for the PvP winner
+# Default: FFFFFF (white)
+CKMPvPNpcNameColor = FFFFFF
+
+# The title of the Monument for the PK winner
+# Note: %kills% will be replaced with the winner's PK count in the cycle
+# Default: %kills% PvPs in the last 24h
+CKMPKNpcTitle = %kills% PKs in the last 24h
+
+# The title color of the Monument for the PK winner
+# Default: 00CCFF (yellow)
+CKMPKNpcTitleColor = 00CCFF
+
+# The name color of the Monument for the PK winner
+# Default: FFFFFF (white)
+CKMPKNpcNameColor = FFFFFF
\ No newline at end of file

CitarDATA:

### Eclipse Workspace Patch 1.0
#P aCis_datapack
Index: data/html/polymorph/10000.htm
===================================================================
--- data/html/polymorph/10000.htm    (revision 0)
+++ data/html/polymorph/10000.htm    (working copy)
@@ -0,0 +1,6 @@
+<html>
+<title>Top PvP Monument - By paytaly</title>
+<body>
+All hail <font color="LEVEL">%ownername%</font> for the most PvPs in the last 24h!
+</body>
+</html>
\ No newline at end of file
Index: data/html/polymorph/10001.htm
===================================================================
--- data/html/polymorph/10001.htm    (revision 0)
+++ data/html/polymorph/10001.htm    (working copy)
@@ -0,0 +1,6 @@
+<html>
+<title>Top PK Monument - By paytaly</title>
+<body>
+All hail <font color="LEVEL">%ownername%</font> for the most PKs in the last 24h!
+</body>
+</html>
\ No newline at end of file
Index: sql/character_kills_snapshot.sql
===================================================================
--- sql/character_kills_snapshot.sql    (revision 0)
+++ sql/character_kills_snapshot.sql    (working copy)
@@ -0,0 +1,6 @@
+CREATE TABLE IF NOT EXISTS character_kills_snapshot (
+  charId INT UNSIGNED NOT NULL DEFAULT 0,
+  pvpkills INT UNSIGNED NOT NULL DEFAULT 0,
+  pkkills INT UNSIGNED NOT NULL DEFAULT 0,
+  PRIMARY KEY (charId)
+);
Index: data/html/polymorph/10001.htm
===================================================================
--- data/html/polymorph/10001.htm    (revision 0)
+++ data/html/polymorph/10001.htm    (working copy)
@@ -0,0 +1,6 @@
+<html>
+<title>Top PK Monument - By paytaly</title>
+<body>
+All hail <font color="LEVEL">%ownername%</font> for the most PKs in the last 24h!
+</body>
+</html>
\ No newline at end of file
Index: data/html/polymorph/10000.htm
===================================================================
--- data/html/polymorph/10000.htm    (revision 0)
+++ data/html/polymorph/10000.htm    (working copy)
@@ -0,0 +1,6 @@
+<html>
+<title>Top PvP Monument - By paytaly</title>
+<body>
+All hail <font color="LEVEL">%ownername%</font> for the most PvPs in the last 24h!
+</body>
+</html>
\ No newline at end of file
Index: data/xml/npcs/custom.xml
===================================================================
--- data/xml/npcs/custom.xml    (revision 0)
+++ data/xml/npcs/custom.xml    (working copy)
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<list>
+    <npc id="10000" idTemplate="31646" name="Top PvP Monument" title="By paytaly">
+        <set name="level" val="80"/>
+        <set name="radius" val="7"/>
+        <set name="height" val="24"/>
+        <set name="rHand" val="0"/>
+        <set name="lHand" val="0"/>
+        <set name="type" val="L2TopPvPMonument"/>
+        <set name="exp" val="0"/>
+        <set name="sp" val="0"/>
+        <set name="hp" val="2444.46819"/>
+        <set name="mp" val="1345.8"/>
+        <set name="hpRegen" val="7.5"/>
+        <set name="mpRegen" val="2.7"/>
+        <set name="pAtk" val="688.86373"/>
+        <set name="pDef" val="295.91597"/>
+        <set name="mAtk" val="470.40463"/>
+        <set name="mDef" val="216.53847"/>
+        <set name="crit" val="4"/>
+        <set name="atkSpd" val="253"/>
+        <set name="str" val="40"/>
+        <set name="int" val="21"/>
+        <set name="dex" val="30"/>
+        <set name="wit" val="20"/>
+        <set name="con" val="43"/>
+        <set name="men" val="20"/>
+        <set name="corpseTime" val="7"/>
+        <set name="walkSpd" val="50"/>
+        <set name="runSpd" val="120"/>
+        <set name="dropHerbGroup" val="0"/>
+        <set name="attackRange" val="40"/>
+        <ai type="default" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="true" seedable="false"/>
+    </npc>
+    <npc id="10001" idTemplate="31646" name="Top PK Monument" title="By paytaly">
+        <set name="level" val="80"/>
+        <set name="radius" val="7"/>
+        <set name="height" val="24"/>
+        <set name="rHand" val="0"/>
+        <set name="lHand" val="0"/>
+        <set name="type" val="L2TopPKMonument"/>
+        <set name="exp" val="0"/>
+        <set name="sp" val="0"/>
+        <set name="hp" val="2444.46819"/>
+        <set name="mp" val="1345.8"/>
+        <set name="hpRegen" val="7.5"/>
+        <set name="mpRegen" val="2.7"/>
+        <set name="pAtk" val="688.86373"/>
+        <set name="pDef" val="295.91597"/>
+        <set name="mAtk" val="470.40463"/>
+        <set name="mDef" val="216.53847"/>
+        <set name="crit" val="4"/>
+        <set name="atkSpd" val="253"/>
+        <set name="str" val="40"/>
+        <set name="int" val="21"/>
+        <set name="dex" val="30"/>
+        <set name="wit" val="20"/>
+        <set name="con" val="43"/>
+        <set name="men" val="20"/>
+        <set name="corpseTime" val="7"/>
+        <set name="walkSpd" val="50"/>
+        <set name="runSpd" val="120"/>
+        <set name="dropHerbGroup" val="0"/>
+        <set name="attackRange" val="40"/>
+        <ai type="default" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="true" seedable="false"/>
+    </npc>
+</list>
\ No newline at end of file
Index: sql/character_kills_info.sql
===================================================================
--- sql/character_kills_info.sql    (revision 0)
+++ sql/character_kills_info.sql    (working copy)
@@ -0,0 +1,9 @@
+CREATE TABLE IF NOT EXISTS character_kills_info (
+  cycle INT NOT NULL AUTO_INCREMENT,
+  cycle_start BIGINT UNSIGNED NOT NULL,
+  winner_pvpkills INT UNSIGNED NOT NULL DEFAULT 0,
+  winner_pvpkills_count INT UNSIGNED NOT NULL DEFAULT 0,
+  winner_pkkills INT UNSIGNED NOT NULL DEFAULT 0,
+  winner_pkkills_count INT UNSIGNED NOT NULL DEFAULT 0,
+  PRIMARY KEY (cycle)
+);

CORE: http://pastebin.com/BpzMsznc
DP: http://pastebin.com/4LwcSN4n