Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.sf.l2j.gameserver.custom.events.luckychest;
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.List;
- import java.util.concurrent.Future;
- import java.util.logging.Logger;
- import net.sf.l2j.commons.random.Rnd;
- import net.sf.l2j.gameserver.custom.events.Event;
- import net.sf.l2j.gameserver.data.NpcTable;
- import net.sf.l2j.gameserver.model.L2Spawn;
- import net.sf.l2j.gameserver.model.WorldObject;
- import net.sf.l2j.gameserver.model.actor.Npc;
- import net.sf.l2j.gameserver.model.actor.instance.Player;
- import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- import net.sf.l2j.gameserver.model.location.SpawnLocation;
- import net.sf.l2j.gameserver.util.Broadcast;
- /**
- * @author LordPanic
- *
- */
- public class LuckyChests
- {
- private static final Logger _log = Logger.getLogger(WorldObject.class.getName());
- private final List<Npc> _boxList = new ArrayList<>();
- private final static int boxID = 50062;
- //add the item to give for reward
- private final static int rewardItemID = 0;
- //add the quantity of reward items
- private final static int itemQuantity = 0;
- //lucky chests spawn locs currently 4, add as many as u want.
- private static final SpawnLocation[] BOX_SPAWNS =
- {
- new SpawnLocation(82648 + Rnd.get(-30, 30), 148344 + Rnd.get(-30, 30), -3464, 0),
- new SpawnLocation(82648 + Rnd.get(-30, 30), 148344 + Rnd.get(-30, 30), -3464, 0),
- new SpawnLocation(82648 + Rnd.get(-30, 30), 148344 + Rnd.get(-30, 30), -3464, 0),
- new SpawnLocation(82648 + Rnd.get(-30, 30), 148344 + Rnd.get(-30, 30), -3464, 0)
- };
- public static LuckyChests getInstance()
- {
- return SingletonHolder._instance;
- }
- public void start()
- {
- startSpawns();
- }
- public void stop()
- {
- deleteSpawns();
- }
- public void soloRewards(Player player)
- {
- player.getInventory().addItem("Lucky Chest", rewardItemID, itemQuantity, player, player);
- }
- public void startSpawns()
- {
- for (SpawnLocation loc : BOX_SPAWNS)
- {
- try {
- final NpcTemplate template = NpcTable.getInstance().getTemplate(boxID);
- final L2Spawn spawn = new L2Spawn(template);
- spawn.setLoc(loc.getX(),loc.getY(),loc.getZ(), 0);
- final Npc mob = spawn.doSpawn(true);
- mob.setIsInvul(true);
- _boxList.add(mob);
- }catch(Exception e) {
- _log.info("[Lucky Chest]: Couldn't spawn Lucky Box's.");
- }
- }
- Broadcast.announceToOnlinePlayers("[Lucky Chest]: Spawned ["+_boxList.size()+"].", true);
- }
- public void deleteSpawns()
- {
- for (Npc chest : _boxList) {
- chest.deleteMe();
- }
- _boxList.clear();
- }
- public void removeluckyBox(int boxid) {
- for(Iterator<Npc> iterator = _boxList.iterator(); iterator.hasNext();) {
- Npc mob = iterator.next();
- if(mob.getObjectId() == boxid) {
- iterator.remove();
- Broadcast.announceToOnlinePlayers("[Lucky Chest]: ["+_boxList.size()+"] left.", true);
- }
- //TODO if(_boxList.isEmpty()){ teleport players back and end the event }
- }
- }
- private static class SingletonHolder
- {
- protected static final LuckyChests _instance = new LuckyChests();
- }
- }
Add Comment
Please, Sign In to add comment