IndexOF() - Форум администраторов игровых серверов
Форум администраторов игровых серверов StormWall - Защита от DDos атак
Регистрация Мнения Справка Сообщество Календарь
Вернуться   Форум администраторов игровых серверов > MMO > Lineage II > Работа со скриптами

Работа со скриптами Помощь в редактировании и написании квестов к Java серверам, а так же эвентов.

Ответ
Опции темы
Непрочитано 14.03.2011, 14:01   #1
Аватар для krisadr
Пользователь

Автор темы (Топик Стартер) IndexOF()

package instances.ChamberOfDelusionEast;
 
import com.l2world.gameserver.ai.CtrlIntention;
import com.l2world.gameserver.instancemanager.InstanceManager;
import com.l2world.gameserver.instancemanager.InstanceManager.InstanceWorld;
import com.l2world.gameserver.model.L2Party;
import com.l2world.gameserver.model.actor.L2Npc;
import com.l2world.gameserver.model.actor.L2Summon;
import com.l2world.gameserver.model.actor.instance.L2PcInstance;
import com.l2world.gameserver.model.quest.Quest;
import com.l2world.gameserver.model.quest.QuestState;
import com.l2world.gameserver.network.SystemMessageId;
import com.l2world.gameserver.network.serverpackets.SystemMessage;
import com.l2world.gameserver.util.Util;
import com.l2world.util.Rnd;
 
public class ChamberOfDelusionEast extends Quest
{
 
	private class CDWorld extends InstanceWorld
	{
		private L2Npc manager,managera,managerb,managerc,managerd,managere,managerf,managerg,managerh,_aenkinel;
		public CDWorld()
		{
			InstanceManager.getInstance().super();
		}
	}
 
	private static final String qn = "ChamberOfDelusionEast";
	private static final int INSTANCEID = 127; // this is the client number
	//NPCs
	private static final int GKSTART = 32658;
	private static final int GKFINISH = 32664;
	private static final int AENKINEL = 25690;
	private static final int ROOMRB = 4;
	private int rb = 0;
	private int a;
	public int instId = 0;
	private int b;
	private int g = 0;
	private int h = 0;
	private int c;
	private class teleCoord {int instanceId; int x; int y; int z;}
	private static final int[][] TELEPORT =
	{
		{ -122368,-152624,-6752},
		{ -122368,-153504,-6752},
		{ -120496,-154304,-6752},
		{ -120496,-155184,-6752},
		{ -121440,-154688,-6752},
		{ -121440,-151328,-6752},
		{ -120496,-153008,-6752},
		{ -122368,-154800,-6752},
		{ -121440,-153008,-6752}
	};
	private boolean checkConditions(L2PcInstance player)
	{
 
		L2Party party = player.getParty();
		if (party == null)
		{
			player.sendPacket(new SystemMessage(2101));
			return false;
		}
		if (party.getLeader() != player)
		{
			player.sendPacket(new SystemMessage(2185));
			return false;
		}
		for (L2PcInstance partyMember : party.getPartyMembers())
		{
			if (partyMember.getLevel() < 80)
			{
				SystemMessage sm = new SystemMessage(2097);
				sm.addPcName(partyMember);
				party.broadcastToPartyMembers(sm);
				return false;
			}
			if (!Util.checkIfInRange(1000, player, partyMember, true))
			{
				SystemMessage sm = new SystemMessage(2096);
				sm.addPcName(partyMember);
				party.broadcastToPartyMembers(sm);
				return false;
			}
		}
		return true;
 
	}
 
	private void teleportplayer(L2PcInstance player, teleCoord teleto)
	{
		player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
		player.setInstanceId(teleto.instanceId);
		player.teleToLocation(teleto.x, teleto.y, teleto.z);
		return;
	}
 
	private void teleportrnd(L2PcInstance player, CDWorld world)
	{	
		int tp = Rnd.get(TELEPORT.length); 
		if (rb == 1&& tp == ROOMRB)
		{
			tp = Rnd.get(TELEPORT.length);
			for (int i = 0; i < TELEPORT.length; i++)
			{
				if (i == tp)
				{
				for (L2PcInstance partyMember : player.getParty().getPartyMembers())
				{
				partyMember.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
				partyMember.setInstanceId(instId);
				partyMember.teleToLocation(TELEPORT[i][0], TELEPORT[i][1], TELEPORT[i][2]);
				}
				}
			}
			a = player.getX();  
			b = player.getY();
			c = player.getZ();
		}
		else 
		{ 
		for (int i = 0; i < TELEPORT.length; i++)
		{
			if (i == tp)
			{
				for (L2PcInstance partyMember : player.getParty().getPartyMembers())
				{
				partyMember.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
				partyMember.setInstanceId(instId);
				partyMember.teleToLocation(TELEPORT[i][0], TELEPORT[i][1], TELEPORT[i][2]);
				}
			}
		}
		a = player.getX();  
		b = player.getY();
		c = player.getZ();
		}
 
		return;
	}
 
	protected void spawnState(CDWorld world)
        {
                         world._aenkinel = addSpawn(AENKINEL, -121463,-155094,-6752, 0, false, 0, false, world.instanceId);
                         world._aenkinel.setIsNoRndWalk(false);
			 world.manager = addSpawn(32664,-121440,-154688,-6752,0,false,0,false,world.instanceId);
			 world.manager.setIsNoRndWalk(true);
			 world.managerb = addSpawn(32664,-122368,-153504,-6752,0,false,0,false,world.instanceId);
			 world.managerb.setIsNoRndWalk(true);
			 world.managerc = addSpawn(32664,-120496,-154304,-6752,0,false,0,false,world.instanceId);
			 world.managerc.setIsNoRndWalk(true);
			 world.managerd = addSpawn(32664,-120496,-155184,-6752,0,false,0,false,world.instanceId);
			 world.managerd.setIsNoRndWalk(true);
			 world.managere = addSpawn(32664,-121440,-151328,-6752,0,false,0,false,world.instanceId);
			 world.managere.setIsNoRndWalk(true);
			 world.managerf = addSpawn(32664,-120496,-153008,-6752,0,false,0,false,world.instanceId);
			 world.managerf.setIsNoRndWalk(true);
			 world.managerg = addSpawn(32664,-122368,-154800,-6752,0,false,0,false,world.instanceId);
			 world.managerg.setIsNoRndWalk(true);
			 world.managerh = addSpawn(32664,-121440,-153008,-6752,0,false,0,false,world.instanceId);
			 world.managerh.setIsNoRndWalk(true);
			 world.managera = addSpawn(32664,-122368,-152624,-6752,0,false,0,false,world.instanceId);
			 world.managera.setIsNoRndWalk(true);
	}
	protected int enterInstance(L2PcInstance player, String template)
	{
		int instanceId = 0;
		//check for existing instances for this player
		InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
		//existing instance
		if (world != null)
		{
			if (!(world instanceof CDWorld))
			{
				player.sendPacket(new SystemMessage(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER));
				return 0;
			}
			teleCoord tele = new teleCoord();
			tele.x = a;
			tele.y = b;
			tele.z = c;
			tele.instanceId = world.instanceId;
			teleportplayer(player,tele);
			return instanceId;
		}
		//New instance
		else
		{
			if (!checkConditions(player))
				return 0;
			L2Party party = player.getParty();
			instanceId = InstanceManager.getInstance().createDynamicInstance(template);
			world = new CDWorld();
			world.instanceId = instanceId;
			world.templateId = INSTANCEID;
			world.status = 0;
			InstanceManager.getInstance().addWorld(world);
			_log.info("Chamber Of Delusion started " + template + " Instance: " + instanceId + " created by player: " + player.getName());
			spawnState((CDWorld)world);
			instId = world.instanceId;
				for (L2PcInstance partyMember : party.getPartyMembers())
				{
					teleportrnd(partyMember,(CDWorld)world);
					world.allowed.add(partyMember.getObjectId());
				}
 
			return instanceId;
		}
	}
 
	protected void exitInstance(L2PcInstance player, teleCoord tele)
	{
		player.setInstanceId(0);
		player.teleToLocation(tele.x, tele.y, tele.z);
		L2Summon pet = player.getPet();
		if (pet != null)
		{
			pet.setInstanceId(0);
			pet.teleToLocation(tele.x, tele.y, tele.z);
		}
	}
 
	public String onAdvEvent (String event, L2Npc npc, L2PcInstance player)
	{
		InstanceWorld tmpworld = InstanceManager.getInstance().getPlayerWorld(player);
		if (tmpworld instanceof CDWorld)
		{
			CDWorld world = (CDWorld) tmpworld;
			L2Party party = player.getParty();
			instId = player.getInstanceId();
			if (event.equalsIgnoreCase("tproom"))
			{	
 
				for (L2PcInstance partyMember : party.getPartyMembers())
				{
				teleportrnd(partyMember,(CDWorld)world);
				}
 
				startQuestTimer("tproom1",480000,null,player);
				h++;
			}
			else if (event.equalsIgnoreCase("tproom1"))
			{
 
				for (L2PcInstance partyMember : party.getPartyMembers())
				{
				teleportrnd(partyMember,(CDWorld)world);
				}
 
				startQuestTimer("tproom2",480000,null,player);
				h++;
			}
			else if (event.equalsIgnoreCase("tproom2"))
			{
 
				for (L2PcInstance partyMember : party.getPartyMembers())
				{
				teleportrnd(partyMember,(CDWorld)world);
				}
 
				startQuestTimer("tproom3",480000,null,player);
				h++;
			}
			else if (event.equalsIgnoreCase("tproom3"))
			{
 
				for (L2PcInstance partyMember : party.getPartyMembers())
				{
				teleportrnd(partyMember,(CDWorld)world);
				}
 
			}
			else if ("7".equalsIgnoreCase(event))
			{	
				if (g ==0)
				{
				if (h == 0)
				{
				cancelQuestTimers("tproom");
				for (L2PcInstance partyMember : party.getPartyMembers())
				{
				teleportrnd(partyMember,(CDWorld)world);
				}
				startQuestTimer("tproom1",480000,null,player);
				g =1;
				}
				else if (h == 1)
				{
				cancelQuestTimers("tproom1");
				for (L2PcInstance partyMember : party.getPartyMembers())
				{
				teleportrnd(partyMember,(CDWorld)world);
				}
				startQuestTimer("tproom2",480000,null,player);
				g =1;
				}
				else if (h == 2)
				{
				cancelQuestTimers("tproom2");
				for (L2PcInstance partyMember : party.getPartyMembers())
				{
				teleportrnd(partyMember,(CDWorld)world);
				}	
				startQuestTimer("tproom3",480000,null,player);
				g =1;
				}
				else if (h == 3)
				{
				cancelQuestTimers("tproom3");
				for (L2PcInstance partyMember : party.getPartyMembers())
				{
				teleportrnd(partyMember,(CDWorld)world);
				}	
				g =1;				
				}
			}
			}  
 
		}
		return "";
	}
 
	public String onKill( L2Npc npc, L2PcInstance player)
	{
		int npcId = npc.getNpcId();
		if (rb == 0 && npcId == AENKINEL)
		{
			_log.info("kill");
			rb = 1;
 
		}
		return "";
	}
	public final String onFirstTalk (L2Npc npc, L2PcInstance player)
	{
		return npc.getNpcId() + ".htm";
	}		
 
	public String onTalk (L2Npc npc, L2PcInstance player)
	{
		int npcId = npc.getNpcId();
		QuestState st = player.getQuestState(qn);
		if (st == null)
			st = newQuestState(player);
		if (npcId == GKSTART)
		{	
			enterInstance(player,"ChamberofDelusionEast.xml");
			startQuestTimer("tproom",480000,null,player);
			return "";
		}
		else if (npcId == GKFINISH)
		{	InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
			world.allowed.remove(world.allowed.[COLOR="Red"]indexOf[/COLOR](player.getObjectId()));
			teleCoord tele = new teleCoord();
			tele.instanceId = 0;
			tele.x = -114592;
			tele.y = -152509;
			tele.z = -6723;
			cancelQuestTimers("tproom");
			cancelQuestTimers("tproom1");
			cancelQuestTimers("tproom2");
			cancelQuestTimers("tproom3");
			for (L2PcInstance partyMember :  player.getParty().getPartyMembers())
			{
			exitInstance(partyMember,tele);
			}
		}
		return "";
	}
 
	public ChamberOfDelusionEast(int questId, String name, String descr)
	{
		super(questId, name, descr);
 
		addStartNpc(GKSTART);
		addTalkId(GKSTART);
                addStartNpc(GKFINISH);
		addFirstTalkId(GKFINISH);
		addTalkId(GKFINISH);
                addKillId(AENKINEL);  		
	}
 
	public static void main(String[] args)
	{
		new ChamberOfDelusionEast(-1,qn,"instances");
	}
}
Code: Java
вытащил из одной сборки этот скрипт и попытался вставить в свою, но в эклипсе выскачила ошибка, адресованная indexOf что то вроде неправильного синтаксиса, вообщем наскока я понял строка
world.allowed.remove(world.allowed.[COLOR="Red"]indexOf[/COLOR](player.getObjectId()));
Code: Java
удаляет у персонажей этот инстанс... чем можно заменить indexof?
krisadr вне форума Ответить с цитированием
Непрочитано 14.03.2011, 14:41   #2
Аватар для VISTALL
Illussion is real

По умолчанию Re: IndexOF()

  1.  
  2. InstanceWorld
  3.  
Code: Java
дайте код
VISTALL вне форума Ответить с цитированием
Непрочитано 14.03.2011, 14:48   #3
Аватар для krisadr
Пользователь

Автор темы (Топик Стартер) Re: IndexOF()

Код:
/*
 * 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 com.l2dc.gameserver.instancemanager;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;

import javolution.io.UTF8StreamReader;
import javolution.util.FastMap;
import javolution.xml.stream.XMLStreamConstants;
import javolution.xml.stream.XMLStreamException;
import javolution.xml.stream.XMLStreamReaderImpl;
import com.l2dc.Config;
import com.l2dc.database.MiscDbTask;
import com.l2dc.gameserver.model.actor.instance.L2PcInstance;
import com.l2dc.gameserver.model.entity.Instance;
import com.l2dc.util.StringUtil;

/**
 * @author evill33t, GodKratos
 * 
 */
public class InstanceManager
{
	
	/**
	 * Logger.
	 */
	private static final Logger _log = Logger.getLogger(InstanceManager.class.getName());
	/**
	 * Map of instance ids and instances.
	 */
	private Map<Integer, Instance> _instancesMap = new ConcurrentHashMap<Integer, Instance>();
	/**
	 * Map of instance ids and worlds.
	 */
	private Map<Integer, InstanceWorld> _instanceWorldsMap = new ConcurrentHashMap<Integer, InstanceWorld>();
	/**
	 * Counter for creation of dynamic instances.
	 */
	private final AtomicInteger _dynamicInstanceId = new AtomicInteger(300000);
	
	// InstanceId Names
	private final static Map<Integer, String> _instanceIdNames = new FastMap<Integer, String>();
	private Map<Integer, Map<Integer, Long>> _playerInstanceTimes = new FastMap<Integer, Map<Integer, Long>>();
	
	public static final String ADD_INSTANCE_TIME = "INSERT INTO character_instance_time (charId,instanceId,time) values (?,?,?) ON DUPLICATE KEY UPDATE time=?";
	public static final String RESTORE_INSTANCE_TIMES = "SELECT instanceId,time FROM character_instance_time WHERE charId=?";
	public static final String DELETE_INSTANCE_TIME = "DELETE FROM character_instance_time WHERE charId=? AND instanceId=?";
	
	public long getInstanceTime(int playerObjId, int id)
	{
		if (!getPlayerInstanceTimes().containsKey(playerObjId))
			restoreInstanceTimes(playerObjId);
		if (getPlayerInstanceTimes().get(playerObjId).containsKey(id))
			return getPlayerInstanceTimes().get(playerObjId).get(id);
		return -1;
	}
	
	public Map<Integer, Long> getAllInstanceTimes(int playerObjId)
	{
		if (!getPlayerInstanceTimes().containsKey(playerObjId))
			restoreInstanceTimes(playerObjId);
		return getPlayerInstanceTimes().get(playerObjId);
	}
	
	public void setInstanceTime(int playerObjId, int id, long time)
	{
		if (!_playerInstanceTimes.containsKey(playerObjId))
			restoreInstanceTimes(playerObjId);
		MiscDbTask.getInstance().setInstanceTime(this, playerObjId, id, time);
	}
	
	public void deleteInstanceTime(int playerObjId, int id)
	{
		MiscDbTask.getInstance().deleteInstanceTime(this, playerObjId, id);
	}
	
	public void restoreInstanceTimes(int playerObjId)
	{
		if (getPlayerInstanceTimes().containsKey(playerObjId))
			return; // already restored
		getPlayerInstanceTimes().put(playerObjId, new FastMap<Integer, Long>());
		MiscDbTask.getInstance().restoreInstanceTimes(this, playerObjId);
	}
	
	public String getInstanceIdName(int id)
	{
		if (_instanceIdNames.containsKey(id))
			return _instanceIdNames.get(id);
		return ("UnknownInstance");
	}
	
	private void loadInstanceNames()
	{
		InputStream in = null;
		try
		{
			in = new FileInputStream(Config.DATAPACK_ROOT + "/data/instancenames.xml");
			XMLStreamReaderImpl xpp = new XMLStreamReaderImpl();
			xpp.setInput(new UTF8StreamReader().setInput(in));
			for (int e = xpp.getEventType(); e != XMLStreamConstants.END_DOCUMENT; e = xpp.next())
			{
				if (e == XMLStreamConstants.START_ELEMENT)
				{
					if (xpp.getLocalName().toString().equals("instance"))
					{
						Integer id = Integer.valueOf(xpp.getAttributeValue(null, "id").toString());
						String name = xpp.getAttributeValue(null, "name").toString();
						_instanceIdNames.put(id, name);
					}
				}
			}
		}
		catch (FileNotFoundException e)
		{
			_log.log(Level.WARNING, "instancenames.xml could not be loaded: file not found", e);
		}
		catch (XMLStreamException xppe)
		{
			_log.log(Level.WARNING, "cannot read instancenames.xml file", xppe);
		}
		finally
		{
			try
			{
				in.close();
			}
			catch (Exception e)
			{
			}
		}
	}
	
	/**
	 * Creates new instance of InstanceManager.
	 */
	private InstanceManager()
	{
		_log.info("Initializing InstanceManager");
		loadInstanceNames();
		_log.info("Loaded " + _instanceIdNames.size() + " instance names");
		createWorld();
	}
	
	/**
	 * Returns the single instance of InstanceManager.
	 * 
	 * @return the single instance of InstanceManager
	 */
	public static final InstanceManager getInstance()
	{
		return SingletonHolder.INSTANCE;
	}
	
	/**
	 * Adds instance world to the collection of instance worlds.
	 * 
	 * @param world
	 *            instance world
	 */
	public void addWorld(final InstanceWorld world)
	{
		_instanceWorldsMap.put(world.instanceId, world);
	}
	
	/**
	 * Returns instance world for given <code>instanceId</code>.
	 * 
	 * @param instanceId
	 *            instance id
	 * 
	 * @return instance world or null
	 */
	public InstanceWorld getWorld(final int instanceId)
	{
		return _instanceWorldsMap.get(instanceId);
	}
	
	/**
	 * Searches instances to find whether player can enter any of the instances. Returns first
	 * instance world that player can enter.
	 * 
	 * @param player
	 *            player
	 * 
	 * @return instance world or null
	 */
	public InstanceWorld getPlayerWorld(final L2PcInstance player)
	{
		for (final InstanceWorld world : _instanceWorldsMap.values())
		{
			if (world == null)
				continue;
			if (world.allowed.contains(player.getObjectId()))
			{
				return world;
			}
		}
		
		return null;
	}
	
	public void createPlayerWorld(int instanceId, int templateId, int playerId, int status)
	{
		InstanceWorld world = new InstanceWorld();
		world.instanceId = instanceId;
		world.templateId = templateId;
		world.allowed.add(playerId);
		world.status = status;
		InstanceManager.getInstance().addWorld(world);
	}
	
	/**
	 * Creates multiverse and universe for instance manager instance.
	 */
	private void createWorld()
	{
		final Instance themultiverse = new Instance(-1);
		themultiverse.setName("multiverse");
		_instancesMap.put(-1, themultiverse);
		_log.info("Multiverse Instance created");
		
		final Instance universe = new Instance(0);
		universe.setName("universe");
		_instancesMap.put(0, universe);
		_log.info("Universe Instance created");
	}
	
	/**
	 * Destroys instance by <code>instanceId</code>
	 * 
	 * @param instanceid
	 *            id of the instance to destroy
	 */
	public void destroyInstance(final int instanceId)
	{
		if (instanceId <= 0)
		{
			return;
		}
		
		final Instance instance = _instancesMap.get(instanceId);
		
		if (instance == null)
		{
			return;
		}
		
		instance.removeNpcs();
		instance.removePlayers();
		instance.removeDoors();
		instance.cancelTimer();
		_instancesMap.remove(instanceId);
		_instanceWorldsMap.remove(instanceId);
	}
	
	/**
	 * Searches for instance by <code>instanceId</code>. If instance does not exists, then returns
	 * null. This method also logs all attempts for getting non-existant instances so if you just
	 * need to check whether instance exists, use {@link #instanceExist(int)} instead.
	 * 
	 * @param instanceId
	 *            id of instance
	 * 
	 * @return found instance or null
	 */
	public Instance getInstance(final int instanceId)
	{
		final Instance instance = _instancesMap.get(instanceId);
		
		if (instance == null && _log.isLoggable(Level.WARNING))
		{
			_log.log(Level.WARNING, StringUtil.concat("InstanceManager: Instance ", String.valueOf(instanceId), " does not exist in InstanceManager"), new Throwable());
		}
		
		return instance;
	}
	
	/**
	 * Checks whether instance of given <code>instanceId</code> exists.
	 * 
	 * @param instanceId
	 *            instance id
	 * 
	 * @return true if instance exists, otherwise false
	 */
	public boolean instanceExist(final int instanceId)
	{
		return _instancesMap.get(instanceId) != null;
	}
	
	/**
	 * Returns map of instance ids and related instances.
	 * 
	 * @return map of instance ids and related instances
	 */
	public Map<Integer, Instance> getInstances()
	{
		return _instancesMap;
	}
	
	/**
	 * Searches instances to find whether player is specified in any of the instances. Returns first
	 * instance that contains this player.
	 * 
	 * @param objectId
	 *            player object id
	 * 
	 * @return found instance or zero (default instance)
	 */
	public int getPlayerInstance(final int objectId)
	{
		for (final Instance instance : _instancesMap.values())
		{
			if (instance == null)
				continue;
			if (instance.containsPlayer(objectId))
			{
				return instance.getId();
			}
		}
		
		return 0;
	}
	
	/**
	 * Creates new instance with dynamic instance id.
	 * 
	 * @param template
	 *            path to xml template file or null if instance has no template
	 * 
	 * @return id of the newly created instance
	 */
	public int createDynamicInstance(final String template)
	{
		final int newId = _dynamicInstanceId.incrementAndGet();
		
		if (newId == Integer.MAX_VALUE)
		{
			_dynamicInstanceId.set(300000);
			_log.warning(StringUtil.concat("InstanceManager: More then ", String.valueOf(Integer.MAX_VALUE - 300000), " instances created"));
		}
		
		final Instance instance = new Instance(newId);
		_instancesMap.put(newId, instance);
		
		if (template != null)
		{
			try
			{
				instance.loadInstanceTemplate(template);
			}
			catch (final FileNotFoundException e)
			{
				_log.log(Level.WARNING, StringUtil.concat("InstanceManager: Failed creating instance from " + "template ", template), e);
			}
		}
		
		return newId;
	}
	
	/**
	 * Creates new instance using specified instance id. Only values between 1 and 299,999 can be
	 * used.
	 * 
	 * @param instanceId
	 *            instance id
	 * 
	 * @return true if instance was created, otherwise false
	 */
	public boolean createInstance(final int instanceId)
	{
		if (instanceId <= 0 || instanceId >= 300000 || instanceExist(instanceId))
		{
			return false;
		}
		
		final Instance instance = new Instance(instanceId);
		_instancesMap.put(instanceId, instance);
		
		return true;
	}
	
	/**
	 * Creates new instance using specified instance id. Only values between 1 and 299,999 can be
	 * used.
	 * 
	 * @param instanceId
	 *            instance id
	 * @param template
	 *            path to xml template file
	 * 
	 * @return true if instance was created, otherwise false
	 * 
	 * @throws FileNotFoundException
	 *             Thrown if problem occured while trying to read template file.
	 */
	public boolean createInstanceFromTemplate(final int instanceId, final String template) throws FileNotFoundException
	{
		if (instanceId <= 0 || instanceId >= 300000 || instanceExist(instanceId))
		{
			return false;
		}
		
		final Instance instance = new Instance(instanceId);
		_instancesMap.put(instanceId, instance);
		instance.loadInstanceTemplate(template);
		
		return true;
	}
	
	/**
	 * @param playerInstanceTimes the playerInstanceTimes to set
	 */
	public void setPlayerInstanceTimes(Map<Integer, Map<Integer, Long>> playerInstanceTimes)
	{
		_playerInstanceTimes = playerInstanceTimes;
	}
	
	/**
	 * @return the playerInstanceTimes
	 */
	public Map<Integer, Map<Integer, Long>> getPlayerInstanceTimes()
	{
		return _playerInstanceTimes;
	}
	
	/**
	 * Instance world information.
	 */
	public class InstanceWorld
	{
		
		/**
		 * Id of related instance.
		 */
		public int instanceId;
		/**
		 * TemplateId of related instance.
		 */
		public int templateId = -1;
		/**
		 * Collection of players that are allowed to enter the instance.
		 */
		public Set<Integer> allowed = new CopyOnWriteArraySet<Integer>();
		/**
		 * Status of instance world. The meaning of values is specific to each instance.
		 */
		public int status;
	}
	
	/**
	 * Singleton holder for InstanceManager instance.
	 */
	@SuppressWarnings("synthetic-access")
	private static class SingletonHolder
	{
		
		/**
		 * The single instance of InstanceManager.
		 */
		protected static final InstanceManager INSTANCE = new InstanceManager();
	}
}
Добавлено через 1 минуту
не беспокойтесь импорты я заменил правильно, просто скопировал первый пост из сборки

Добавлено через 11 минут
мб нада заменить на valueOf ?)

Последний раз редактировалось krisadr; 14.03.2011 в 15:00. Причина: Добавлено сообщение
krisadr вне форума Ответить с цитированием
Непрочитано 14.03.2011, 16:16   #4
Аватар для VISTALL
Illussion is real

По умолчанию Re: IndexOF()

world.allowed.remove(player.getObjectId())

вот так и все

там поменяли List -> Set в листе нету индексов
VISTALL вне форума Ответить с цитированием
Сказали спасибо:
Ответ


Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.

Быстрый переход


© 2007–2024 «Форум администраторов игровых серверов»
Защита сайта от DDoS атак — StormWall
Работает на Булке неизвестной версии с переводом от zCarot
Текущее время: 07:23. Часовой пояс GMT +3.

Вверх