Advertisement
Evanth3

Untitled

Aug 28th, 2022
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * Copyright (C) 2004-2015 L2J Server
  3.  *
  4.  * This file is part of L2J Server.
  5.  *
  6.  * L2J Server is free software: you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation, either version 3 of the License, or
  9.  * (at your option) any later version.
  10.  *
  11.  * L2J Server is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14.  * General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18.  */
  19. package l2r.gameserver.model.instancezone;
  20.  
  21. import java.util.List;
  22. import java.util.concurrent.CopyOnWriteArrayList;
  23. import java.util.concurrent.atomic.AtomicInteger;
  24.  
  25. import l2r.gameserver.instancemanager.InstanceManager;
  26. import l2r.gameserver.model.actor.L2Character;
  27. import l2r.gameserver.model.entity.Instance;
  28. import l2r.gameserver.network.SystemMessageId;
  29. import l2r.gameserver.network.serverpackets.SystemMessage;
  30.  
  31. /**
  32.  * Basic instance zone data transfer object.
  33.  * @author Zoey76
  34.  */
  35. public class InstanceWorld
  36. {
  37.     private int _instanceId;
  38.     private int _templateId = -1;
  39.     private final List<Integer> _allowed = new CopyOnWriteArrayList<>();
  40.     private final AtomicInteger _status = new AtomicInteger();
  41.     public int tag = -1;
  42.    
  43.     public List<Integer> getAllowed()
  44.     {
  45.         return _allowed;
  46.     }
  47.    
  48.     public void removeAllowed(int id)
  49.     {
  50.         _allowed.remove(_allowed.indexOf(Integer.valueOf(id)));
  51.     }
  52.    
  53.     public void addAllowed(int id)
  54.     {
  55.         _allowed.add(id);
  56.     }
  57.    
  58.     public boolean isAllowed(int id)
  59.     {
  60.         return _allowed.contains(id);
  61.     }
  62.    
  63.     public int getInstanceId()
  64.     {
  65.         return _instanceId;
  66.     }
  67.    
  68.     public void setInstanceId(int instanceId)
  69.     {
  70.         _instanceId = instanceId;
  71.     }
  72.    
  73.     public int getTemplateId()
  74.     {
  75.         return _templateId;
  76.     }
  77.    
  78.     public void setTemplateId(int templateId)
  79.     {
  80.         _templateId = templateId;
  81.     }
  82.    
  83.     public int getStatus()
  84.     {
  85.         return _status.get();
  86.     }
  87.    
  88.     public boolean isStatus(int status)
  89.     {
  90.         return _status.get() == status;
  91.     }
  92.    
  93.     public void setStatus(int status)
  94.     {
  95.         _status.set(status);
  96.     }
  97.    
  98.     public void incStatus()
  99.     {
  100.         _status.incrementAndGet();
  101.     }
  102.    
  103.     /**
  104.      * @param killer
  105.      * @param victim
  106.      */
  107.     public void onDeath(L2Character killer, L2Character victim)
  108.     {
  109.         if ((victim != null) && victim.isPlayer())
  110.         {
  111.             final Instance instance = InstanceManager.getInstance().getInstance(getInstanceId());
  112.             if ((instance != null) && (instance.getEjectTime() > 0))
  113.             {
  114.                 final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_WILL_BE_EXPELLED_IN_S1);
  115.                 sm.addInt(instance.getEjectTime() / 60 / 1000);
  116.                 victim.getActingPlayer().sendPacket(sm);
  117.                 instance.addEjectDeadTask(victim.getActingPlayer());
  118.             }
  119.         }
  120.     }
  121. }
  122.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement