Noticias:

Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate

Menú Principal

Evento Lucky Chests

Iniciado por Swarlog, Ago 06, 2022, 02:30 AM

Tema anterior - Siguiente tema

Swarlog

### Eclipse Workspace Patch 1.0
#P aCis_gameserver
Index: java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (revision 0)
+++ java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (revision 0)
@@ -0,0 +1,15 @@
+
+package net.sf.l2j.gameserver.handler;
+
+import java.util.logging.Logger;
+
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+public interface IVoicedCommandHandler
+{
+    public static Logger _log = Logger.getLogger(IVoicedCommandHandler.class.getName());
+
+    public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params);
+
+    public String[] getVoicedCommandList();
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2LuckyChestInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2LuckyChestInstance.java (revision 0)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2LuckyChestInstance.java (revision 0)
@@ -0,0 +1,62 @@
+package net.sf.l2j.gameserver.model.actor.instance;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.ThreadPoolManager;
+import net.sf.l2j.gameserver.model.entity.LuckyChests;
+import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
+import net.sf.l2j.util.Rnd;
+
+/*
+ * @author ponyrider && Thug
+ *
+ */
+public class L2LuckyChestInstance extends L2NpcInstance
+{
+ public L2LuckyChestInstance(int objectId, L2NpcTemplate template)
+ {
+ super(objectId, template);
+ }
+
+ private static int REWARD_RATE = Config.LUCKY_CHEST_REWARD_RATE;
+ private static int[][] REWARDS = Config.LUCKY_CHEST_REWARDS;
+
+ @Override
+ public void onSpawn()
+ {
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ if(this!=null)
+ {
+ getSpawn().stopRespawn();
+ deleteMe();
+ }
+ }
+ }, 150000);
+ }
+
+ @Override
+ public void showChatWindow(L2PcInstance player)
+ {
+ if(player == null)
+ return;
+
+ if(!LuckyChests.getInstance().getPlayers().contains(player))
+ return;
+
+ if(Rnd.get(100) < REWARD_RATE)
+ {
+ for(int[] rewardArray : REWARDS)
+ player.addItem("Lucky Chest", rewardArray[0], rewardArray[1], null, true);
+ }
+ else
+ player.sendMessage("Nothing happened!");
+
+
+ this.deleteMe();
+
+ }
+
+}
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestMagicSkillUse.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestMagicSkillUse.java (revision 1)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestMagicSkillUse.java (working copy)
@@ -16,8 +16,10 @@
 
 import net.sf.l2j.Config;
 import net.sf.l2j.gameserver.datatables.SkillTable;
+import net.sf.l2j.gameserver.model.L2Object;
 import net.sf.l2j.gameserver.model.L2Skill;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.entity.LuckyChests;
 import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
 import net.sf.l2j.gameserver.templates.skills.L2SkillType;
 
@@ -49,6 +51,15 @@
  return;
  }
 
+
+ if(!LuckyChests.getInstance().canAct(activeChar))
+ return;
+
+ L2Object target = activeChar.getTarget();
+ if(target instanceof L2PcInstance)
+ if(LuckyChests.getInstance().getPlayers().contains(target))
+ return;
+
  // Get the level of the used skill
  final int level = activeChar.getSkillLevel(_magicId);
  if (level <= 0)
Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 1)
+++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
@@ -44,6 +44,7 @@
 import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminInvul;
 import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminKick;
 import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminLevel;
+import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminLuckyChest;
 import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminMaintenance;
 import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminMammon;
 import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminManor;
@@ -67,6 +68,7 @@
 import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTeleport;
 import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminUnblockIp;
 import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminZone;
+import net.sf.l2j.gameserver.model.entity.LuckyChests;
 
 public class AdminCommandHandler
 {
@@ -88,6 +90,7 @@
  registerAdminCommandHandler(new AdminBuffs());
  registerAdminCommandHandler(new AdminCache());
  registerAdminCommandHandler(new AdminCamera());
+ registerAdminCommandHandler(new AdminLuckyChest());
  registerAdminCommandHandler(new AdminChangeAccessLevel());
  registerAdminCommandHandler(new AdminCreateItem());
  registerAdminCommandHandler(new AdminCursedWeapons());
Index: java/net/sf/l2j/gameserver/network/clientpackets/Say2.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/Say2.java (revision 1)
+++ java/net/sf/l2j/gameserver/network/clientpackets/Say2.java (working copy)
@@ -22,6 +22,7 @@
 import net.sf.l2j.gameserver.handler.ChatHandler;
 import net.sf.l2j.gameserver.handler.IChatHandler;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.entity.LuckyChests;
 import net.sf.l2j.gameserver.network.SystemMessageId;
 import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
 import net.sf.l2j.gameserver.util.IllegalPlayerAction;
@@ -141,6 +142,7 @@
  return;
  }
 
+
  if (_text.isEmpty())
  {
  _log.warning(activeChar.getName() + ": sending empty text. Possible packet hack.");
Index: config/events.properties
===================================================================
--- config/events.properties (revision 1)
+++ config/events.properties (working copy)
@@ -251,4 +251,12 @@
 AltFishChampionshipReward2 = 500000
 AltFishChampionshipReward3 = 300000
 AltFishChampionshipReward4 = 200000
-AltFishChampionshipReward5 = 100000
\ No newline at end of file
+AltFishChampionshipReward5 = 100000
+
+#Lucky chests event
+#Percent ( % ) rate to reward
+LuckyChestRewardRate = 80
+#Lucky chest rewards id and count
+LuckyChestRewards = 57,100000000;
+#Times
+LuckyInterval = 16:00,17:00,16:45
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/model/L2Spawn.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2Spawn.java (revision 1)
+++ java/net/sf/l2j/gameserver/model/L2Spawn.java (working copy)
@@ -28,6 +28,7 @@
 import net.sf.l2j.gameserver.model.actor.L2Character;
 import net.sf.l2j.gameserver.model.actor.L2Npc;
 import net.sf.l2j.gameserver.model.actor.instance.L2MonsterInstance;
+import net.sf.l2j.gameserver.model.entity.LuckyChests;
 import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
 import net.sf.l2j.util.Rnd;
 
@@ -402,6 +403,8 @@
  // Reset decay info
  mob.setDecayed(false);
 
+
+
  // Set the HP and MP of the L2Npc to the max
  mob.setCurrentHpMp(mob.getMaxHp(), mob.getMaxMp());
 
@@ -422,6 +425,8 @@
  ((L2Attackable) mob).setChampion(Rnd.get(100) < Config.CHAMPION_FREQUENCY);
  }
 
+
+
  // Link the L2Npc to this L2Spawn
  mob.setSpawn(this);
 
Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (revision 0)
+++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (revision 0)
@@ -0,0 +1,61 @@
+
+package net.sf.l2j.gameserver.handler;
+
+import gnu.trove.map.hash.TIntObjectHashMap;
+
+import java.util.logging.Logger;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.handler.voicedcommandhandlers.LuckyChestsCommand;
+
+public class VoicedCommandHandler
+{
+    private static Logger _log = Logger.getLogger(ItemHandler.class.getName());
+   
+    private final TIntObjectHashMap<IVoicedCommandHandler> _datatable;
+   
+    public static VoicedCommandHandler getInstance()
+    {
+        return SingletonHolder._instance;
+    }
+   
+    protected VoicedCommandHandler()
+    {
+        _datatable = new TIntObjectHashMap<>();
+       
+        registerHandler(new LuckyChestsCommand());
+    }
+   
+    public void registerHandler(IVoicedCommandHandler handler)
+    {
+        String[] ids = handler.getVoicedCommandList();
+        for (int i = 0; i < ids.length; i++)
+        {
+            if (Config.DEBUG)
+                _log.fine("Adding handler for command " + ids[i]);
+            _datatable.put(ids[i].hashCode(), handler);
+        }
+    }
+   
+    public IVoicedCommandHandler getHandler(String voicedCommand)
+    {
+        String command = voicedCommand;
+        if (voicedCommand.indexOf(" ") != -1)
+        {
+            command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
+        }
+        if (Config.DEBUG)
+            _log.fine("getting handler for command: " + command + " -> " + (_datatable.get(command.hashCode()) != null));
+        return _datatable.get(command.hashCode());
+    }
+   
+    public int size()
+    {
+        return _datatable.size();
+    }
+   
+    private static class SingletonHolder
+    {
+        protected static final VoicedCommandHandler _instance = new VoicedCommandHandler();
+    }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/model/actor/L2Npc.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/L2Npc.java (revision 1)
+++ java/net/sf/l2j/gameserver/model/actor/L2Npc.java (working copy)
@@ -55,6 +55,7 @@
 import net.sf.l2j.gameserver.model.actor.stat.NpcStat;
 import net.sf.l2j.gameserver.model.actor.status.NpcStatus;
 import net.sf.l2j.gameserver.model.entity.Castle;
+import net.sf.l2j.gameserver.model.entity.LuckyChests;
 import net.sf.l2j.gameserver.model.quest.Quest;
 import net.sf.l2j.gameserver.model.quest.QuestEventType;
 import net.sf.l2j.gameserver.model.quest.QuestState;
@@ -283,6 +284,8 @@
 
  // Set the name of the L2Character
  setName(template.getName());
+
+
  }
 
  @Override
Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminLuckyChest.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminLuckyChest.java (revision 0)
+++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminLuckyChest.java (revision 0)
@@ -0,0 +1,50 @@
+/*
+ * 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.handler.admincommandhandlers;
+
+import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.entity.LuckyChests;
+
+/**
+ * @author ponyrider && Thug
+ *
+ */
+public class AdminLuckyChest implements IAdminCommandHandler
+{
+
+ private static final String[] ADMIN_COMMANDS =
+ {
+ "admin_start_lucky_chest",
+ };
+
+ @Override
+ public boolean useAdminCommand(String command, L2PcInstance activeChar)
+ {
+ if(command.startsWith("admin_start_lucky_chest"))
+ {
+ LuckyChests.getInstance();
+ }
+
+ return true;
+ }
+
+ @Override
+ public String[] getAdminCommandList()
+ {
+ return ADMIN_COMMANDS;
+ }
+
+}
Index: java/net/sf/l2j/gameserver/model/entity/LuckyChests.java
===================================================================
--- java/net/sf/l2j/gameserver/model/entity/LuckyChests.java (revision 0)
+++ java/net/sf/l2j/gameserver/model/entity/LuckyChests.java (revision 0)
@@ -0,0 +1,348 @@
+/*
+ * 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.entity;
+
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.ThreadPoolManager;
+import net.sf.l2j.gameserver.datatables.NpcTable;
+import net.sf.l2j.gameserver.datatables.SpawnTable;
+import net.sf.l2j.gameserver.model.L2Spawn;
+import net.sf.l2j.gameserver.model.TaskScheduler;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
+import net.sf.l2j.gameserver.util.Broadcast;
+
+/**
+ * @author ponyrider && Thug
+ *
+ */
+public class LuckyChests
+{
+ public  int[][] SPAWN_LOCATIONS =
+ {
+ {-91386,150381,-3626},
+ {-91365,149653,-3626},
+ {-91354,149791,-3626},
+ {-91350,149923,-3626},
+ {-91344,150052,-3626},
+ {-91352,150177,-3626},
+ {-91333,150585,-3626},
+ {-91328,150670,-3626},
+ {-91327,150797,-3626},
+ {-91327,150922,-3626},
+ {-91212,150915,-3626},
+ {-91212,150795,-3626},
+ {-91216,150619,-3626},
+ {-91213,150492,-3626},
+ {-91212,150331,-3626},
+ {-91205,150184,-3626},
+ {-91202,150047,-3626},
+ {-91193,149914,-3626},
+ {-91193,149700,-3626},
+ {-91183,149503,-3626},
+ {-91047,149473,-3626},
+ {-91043,149667,-3626},
+ {-91025,149834,-3626},
+ {-91013,150020,-3626},
+ {-90995,150247,-3626},
+ {-90977,150491,-3626},
+ {-90962,150703,-3626},
+ {-90944,150890,-3626},
+ {-90856,150934,-3626},
+ {-90838,150715,-3626},
+ {-90826,150558,-3626},
+ {-90819,150417,-3626},
+ {-90815,150256,-3626},
+ {-90809,150087,-3626},
+ {-90815,149883,-3626},
+ {-90801,149674,-3626},
+ {-90768,149479,-3626},
+ {-90661,149390,-3626},
+ {-90621,149506,-3626},
+ {-90616,149696,-3626},
+ {-90611,149894,-3626},
+ {-90616,150083,-3626},
+ {-90615,150241,-3626},
+ {-90626,150410,-3626},
+ {-90641,150575,-3626},
+ {-90606,150738,-3626},
+ {-90539,150684,-3626},
+ {-90536,150513,-3626},
+ {-90516,150298,-3626},
+ {-90502,150088,-3626},
+ {-90498,149879,-3626},
+ {-90509,149624,-3626},
+
+
+
+ };
+
+ protected static List<L2PcInstance> players = new CopyOnWriteArrayList<>();
+ private static enum State {OFF,REGISTER,WAIT,ACTIVE};
+ public static State state = State.OFF;
+ private int MOB_COUNTER=1;
+
+ public int getMobCounter()
+ {
+ return MOB_COUNTER;
+ }
+
+ public void setMobCounter(int realCounter)
+ {
+ MOB_COUNTER = realCounter;
+ }
+
+ public void increaseMobCounter()
+ {
+ MOB_COUNTER++;
+ }
+
+ public List<L2PcInstance> getPlayers()
+ {
+ return players;
+ }
+
+ public LuckyChests()
+ {
+ TaskScheduler.scheduleTask(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ if(state != State.OFF)
+ return;
+ Broadcast.announceToOnlinePlayers("Lucky Chests event registrations are opened.");
+ Broadcast.announceToOnlinePlayers("Registrations will close in 4 minutes.");
+ Broadcast.announceToOnlinePlayers("Press .join_lucky to register or .leave_lucky to leave the event.");
+ openRegistrations();
+ }
+ }, Config.LUCKY_CHEST_INTERVAL.toString());
+ }
+
+
+
+
+ public void openRegistrations()
+ {
+ state = State.REGISTER;
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ Broadcast.announceToOnlinePlayers("Registrations of Lucky Chests event will close in 3 minutes.");
+ Broadcast.announceToOnlinePlayers("Press .join_lucky to register or .leave_lucky to leave the event.");
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ Broadcast.announceToOnlinePlayers("Registrations of Lucky Chests event will close in 2 minutes.");
+ Broadcast.announceToOnlinePlayers("Press .join_lucky to register or .leave_lucky to leave the event.");
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ Broadcast.announceToOnlinePlayers("Registrations of Lucky Chests event will close in 1 minutes.");
+ Broadcast.announceToOnlinePlayers("Press .join_lucky to register or .leave_lucky to leave the event.");
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ Broadcast.announceToOnlinePlayers("Registrations of Lucky Chests just closed!");
+ Broadcast.announceToOnlinePlayers("Registed players will be teleported in 10 seconds!");
+ closeRegistrations();
+ }
+ }, 60000);
+ }
+ }, 60000);
+ }
+ }, 60000);
+ }
+ }, 60000);
+ }
+
+ public void closeRegistrations()
+ {
+ state = State.WAIT;
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ for(L2PcInstance player : players)
+ {
+ if(player == null) continue;
+
+ player.teleToLocation(-91474, 150512, -3626, 0);
+ player.sendMessage("You are now being teleported in event area!");
+ player.sendMessage("Lucky chests will be spawned in some seconds!");
+ }
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ runEvent();
+ }
+ }, 8000);
+
+ }
+ }, 10000);
+ }
+
+ public boolean registerPlayer(L2PcInstance player)
+ {
+ if(state != State.REGISTER)
+ {
+ if(state == State.OFF)
+ player.sendMessage("Event is not active");
+ else
+ player.sendMessage("Event is already active, registrations are closed");
+
+ return false;
+ }
+ if(players.contains(player))
+ {
+ player.sendMessage("You have been already registed in event");
+ return false;
+ }
+
+ players.add(player);
+ player.sendMessage("You successfully registed to Lucky Crests!");
+ return true;
+ }
+
+ public boolean unregisterPlayer(L2PcInstance player)
+ {
+ if(state != State.REGISTER)
+ {
+ if(state == State.OFF)
+ player.sendMessage("Event is not active");
+ else
+ player.sendMessage("Event is already active, registrations are closed");
+
+ return false;
+ }
+ if(!players.contains(player))
+ {
+ player.sendMessage("You haven't even registed to event");
+ return false;
+ }
+
+ players.remove(player);
+ player.sendMessage("You successfully unregisted from Lucky Crests!");
+ return true;
+ }
+
+ public void runEvent()
+ {
+ state = State.ACTIVE;
+ Broadcast.announceToOnlinePlayers("Lucky Chests event started!");
+ for(int[] spawnLoc : SPAWN_LOCATIONS)
+ {
+ int x = spawnLoc[0];
+ int y = spawnLoc[1];
+ int z = spawnLoc[2];
+ L2NpcTemplate template;
+ template = NpcTable.getInstance().getTemplate(55520);
+ try
+ {
+ final L2Spawn spawn = new L2Spawn(template);
+ spawn.setLocx(x);
+ spawn.setLocy(y);
+ spawn.setLocz(z);
+ spawn.setHeading(0);
+ spawn.setRespawnDelay(8);
+ SpawnTable.getInstance().addNewSpawn(spawn, false);
+ spawn.init();
+
+
+
+ }
+ catch(Exception e)
+ {
+ Broadcast.announceToOnlinePlayers("There was a problem spawning lucky chests , sorry event cancelled.");
+ state = State.OFF;
+ }
+ }
+
+ for(L2PcInstance player : players)
+ {
+ if(player == null) continue;
+ player.sendMessage("Lucky chests spawned! Start talking them!");
+ player.sendMessage("Event will end in 1 minutes!");
+ }
+
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ stopEvent();
+ }
+ }, 120000);
+
+
+ }
+
+ public void stopEvent()
+ {
+ state = State.OFF;
+
+ for(L2PcInstance player : players)
+ {
+ if(player == null) continue;
+
+ player.sendMessage("Event ended!");
+ player.teleToLocation(82840, 148639, -3474, 0);
+ players.remove(player);
+ }
+
+ Broadcast.announceToOnlinePlayers("Lucky Chests event ended!");
+
+
+ }
+
+ public static LuckyChests getInstance()
+ {
+ return SingletonHolder._instance;
+ }
+
+ private static class SingletonHolder
+ {
+ protected static final LuckyChests _instance = new LuckyChests();
+ }
+
+ public void checkIfLogout(L2PcInstance player)
+ {
+ if(players.contains(player))
+ players.remove(player);
+ }
+
+ public boolean canAct(L2PcInstance player)
+ {
+ if(players.contains(player))
+ return false;
+
+ return true;
+ }
+}
Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (revision 1)
+++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (working copy)
@@ -14,7 +14,11 @@
  */
 package net.sf.l2j.gameserver.handler.chathandlers;
 
+import java.util.StringTokenizer;
+
 import net.sf.l2j.gameserver.handler.IChatHandler;
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
 import net.sf.l2j.gameserver.model.BlockList;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
@@ -37,15 +41,43 @@
  @Override
  public void handleChat(int type, L2PcInstance activeChar, String params, String text)
  {
- CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
+ boolean vcd_used = false;
+         if (text.startsWith("."))
+         {
+             StringTokenizer st = new StringTokenizer(text);
+             IVoicedCommandHandler vch;
+             String command = "";
 
- for (L2PcInstance player : activeChar.getKnownList().getKnownTypeInRadius(L2PcInstance.class, 1250))
- {
- if (!BlockList.isBlocked(player, activeChar))
- player.sendPacket(cs);
- }
-
- activeChar.sendPacket(cs);
+             if (st.countTokens() > 1)
+             {
+                 command = st.nextToken().substring(1);
+                 params = text.substring(command.length() + 2);
+                 vch = VoicedCommandHandler.getInstance().getHandler(command);
+             }
+             else
+             {
+                 command = text.substring(1);
+                 vch = VoicedCommandHandler.getInstance().getHandler(command);
+             }
+             
+             if (vch != null)
+             {
+                 vch.useVoicedCommand(command, activeChar, params);
+                 vcd_used = true;
+             }
+         }
+         if (!vcd_used)
+         {
+             CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
+             
+             for (L2PcInstance player : activeChar.getKnownList().getKnownType(L2PcInstance.class))
+             {
+                 if (activeChar.isInsideRadius(player, 1250, false, true) && !BlockList.isBlocked(player, activeChar))
+                     player.sendPacket(cs);
+             }
+             
+             activeChar.sendPacket(cs);
+         }
  }
 
  /**
Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java (revision 1)
+++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
@@ -24,7 +24,8 @@
 import java.util.logging.Level;
 import java.util.logging.LogManager;
 import java.util.logging.Logger;
-
+import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
 import net.sf.l2j.Config;
 import net.sf.l2j.L2DatabaseFactory;
 import net.sf.l2j.Server;
@@ -92,6 +93,7 @@
 import net.sf.l2j.gameserver.model.PartyMatchWaitingList;
 import net.sf.l2j.gameserver.model.entity.Castle;
 import net.sf.l2j.gameserver.model.entity.Hero;
+import net.sf.l2j.gameserver.model.entity.LuckyChests;
 import net.sf.l2j.gameserver.model.olympiad.Olympiad;
 import net.sf.l2j.gameserver.model.olympiad.OlympiadGameManager;
 import net.sf.l2j.gameserver.network.L2GameClient;
@@ -158,6 +160,7 @@
  ArmorSetsTable.getInstance();
  FishTable.getInstance();
  SpellbookTable.getInstance();
+ LuckyChests.getInstance();
 
  Util.printSection("Augments");
  AugmentationData.getInstance();
@@ -275,7 +278,7 @@
  _log.config("ItemHandler: Loaded " + ItemHandler.getInstance().size() + " handlers.");
  _log.config("SkillHandler: Loaded " + SkillHandler.getInstance().size() + " handlers.");
  _log.config("UserCommandHandler: Loaded " + UserCommandHandler.getInstance().size() + " handlers.");
-
+ _log.config("VoicedCommandHandler: Loaded " + VoicedCommandHandler.getInstance().size() + " handlers.");
  if (Config.ALLOW_WEDDING)
  CoupleManager.getInstance();
 
Index: java/net/sf/l2j/gameserver/model/TaskScheduler.java
===================================================================
--- java/net/sf/l2j/gameserver/model/TaskScheduler.java (revision 0)
+++ java/net/sf/l2j/gameserver/model/TaskScheduler.java (revision 0)
@@ -0,0 +1,84 @@
+package net.sf.l2j.gameserver.model;
+
+import java.util.Calendar;
+
+import net.sf.l2j.gameserver.ThreadPoolManager;
+
+
+
+public class TaskScheduler
+
+{
+
+        public static void scheduleTask(final Runnable task, final String times)
+        {     
+
+                Calendar cld = Calendar.getInstance();
+
+               
+
+                String[] times_splitted = times.split(";");
+
+               
+
+                int i = times_splitted.length;
+
+               
+
+                for (String time : times_splitted)
+
+                {
+
+                        String[] time_splitted = time.split(":");
+
+                       
+
+                        int hour = Integer.parseInt(time_splitted[0]), minutes = Integer.parseInt(time_splitted[1]);
+                        cld.set(Calendar.HOUR_OF_DAY, hour);
+
+                        cld.set(Calendar.MINUTE, minutes);
+
+                        cld.set(Calendar.SECOND, 0);
+
+                       
+
+                        if (System.currentTimeMillis() > cld.getTimeInMillis())
+                        {
+                                cld.set(Calendar.DAY_OF_MONTH, cld.get(Calendar.DAY_OF_MONTH)+1);
+                                cld.set(Calendar.HOUR_OF_DAY, hour);
+                                cld.set(Calendar.MINUTE, minutes);
+                                cld.set(Calendar.SECOND, 0);
+                        }
+
+                        ThreadPoolManager.getInstance().scheduleGeneral(task, cld.getTimeInMillis()-System.currentTimeMillis());
+                        i--;
+
+                       
+
+                        if (i == 0)
+
+                        {
+
+                                ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+
+                                {
+
+                                        @Override
+
+                                        public void run()
+
+                                        {
+
+                                                scheduleTask(task, times);
+
+                                        }
+
+                                }, cld.getTimeInMillis()-System.currentTimeMillis());
+
+                        }
+
+                }
+
+        }
+
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/network/clientpackets/AttackRequest.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/AttackRequest.java (revision 1)
+++ java/net/sf/l2j/gameserver/network/clientpackets/AttackRequest.java (working copy)
@@ -17,6 +17,7 @@
 import net.sf.l2j.gameserver.model.L2Object;
 import net.sf.l2j.gameserver.model.L2World;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.entity.LuckyChests;
 import net.sf.l2j.gameserver.network.SystemMessageId;
 import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
 
@@ -53,6 +54,7 @@
  return;
  }
 
+
  // avoid using expensive operations if not needed
  final L2Object target;
  if (activeChar.getTargetId() == _objectId)
@@ -63,6 +65,10 @@
  if (target == null)
  return;
 
+
+ if(!LuckyChests.getInstance().canAct(activeChar) || LuckyChests.getInstance().getPlayers().contains(target))
+ return;
+
  if (activeChar.getTarget() != target)
  target.onAction(activeChar);
  else
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 1)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -126,6 +126,7 @@
 import net.sf.l2j.gameserver.model.entity.Castle;
 import net.sf.l2j.gameserver.model.entity.Duel;
 import net.sf.l2j.gameserver.model.entity.Hero;
+import net.sf.l2j.gameserver.model.entity.LuckyChests;
 import net.sf.l2j.gameserver.model.entity.Siege;
 import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
 import net.sf.l2j.gameserver.model.itemcontainer.ItemContainer;
@@ -9272,6 +9273,7 @@
  @Override
  public void deleteMe()
  {
+ LuckyChests.getInstance().checkIfLogout(this);
  cleanup();
  store();
  super.deleteMe();
Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java (revision 1)
+++ java/net/sf/l2j/Config.java (working copy)
@@ -225,6 +225,10 @@
  public static int ALT_FISH_CHAMPIONSHIP_REWARD_4;
  public static int ALT_FISH_CHAMPIONSHIP_REWARD_5;
 
+ public static int LUCKY_CHEST_REWARD_RATE;
+ public static int[][] LUCKY_CHEST_REWARDS;
+ public static String LUCKY_CHEST_INTERVAL;
+
  // --------------------------------------------------
  // HexID
  // --------------------------------------------------
@@ -870,6 +874,10 @@
  ALT_FISH_CHAMPIONSHIP_REWARD_4 = events.getProperty("AltFishChampionshipReward4", 200000);
  ALT_FISH_CHAMPIONSHIP_REWARD_5 = events.getProperty("AltFishChampionshipReward5", 100000);
 
+ LUCKY_CHEST_REWARD_RATE = events.getProperty("LuckyChestRewardRate",70);
+ LUCKY_CHEST_REWARDS = parseItemsList(events.getProperty("LuckyChestRewards", "57,100000000;"));
+ LUCKY_CHEST_INTERVAL = events.getProperty("LuckyInterval","16:00,17:00,16:45");
+   
  // FloodProtector
  ExProperties security = load(FLOOD_PROTECTOR_FILE);
  loadFloodProtectorConfig(security, FLOOD_PROTECTOR_ROLL_DICE, "RollDice", "42");
Index: java/net/sf/l2j/gameserver/model/actor/knownlist/CharKnownList.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/knownlist/CharKnownList.java (revision 1)
+++ java/net/sf/l2j/gameserver/model/actor/knownlist/CharKnownList.java (working copy)
@@ -14,8 +14,11 @@
  */
 package net.sf.l2j.gameserver.model.actor.knownlist;
 
+import java.util.Collection;
+
 import net.sf.l2j.gameserver.model.L2Object;
 import net.sf.l2j.gameserver.model.actor.L2Character;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 
 public class CharKnownList extends ObjectKnownList
 {
@@ -38,6 +41,7 @@
  getActiveChar().setAI(null);
  }
 
+
  @Override
  public boolean removeKnownObject(L2Object object)
  {
Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/LuckyChestsCommand.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/LuckyChestsCommand.java (revision 0)
+++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/LuckyChestsCommand.java (revision 0)
@@ -0,0 +1,56 @@
+/*
+ * 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.handler.voicedcommandhandlers;
+
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.entity.LuckyChests;
+
+/**
+ * @author ponyrider && Thug
+ *
+ */
+public class LuckyChestsCommand implements IVoicedCommandHandler
+{
+
+ private static final String VOICED_COMMANDS[] =
+ {
+ "join_lucky",
+ "leave_lucky"
+ };
+
+
+ @Override
+ public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
+ {
+ if(command.startsWith(VOICED_COMMANDS[0]))
+ {
+ LuckyChests.getInstance().registerPlayer(activeChar);
+ }
+ else if(command.startsWith(VOICED_COMMANDS[1]))
+ {
+ LuckyChests.getInstance().unregisterPlayer(activeChar);
+ }
+
+ return true;
+ }
+
+ @Override
+ public String[] getVoicedCommandList()
+ {
+ return VOICED_COMMANDS;
+ }
+
+}