Merged with released L2J-Unity files.
This commit is contained in:
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.interfaces.IUniqueId;
|
||||
|
||||
/**
|
||||
* @author xban1x
|
||||
*/
|
||||
public final class AbsorberInfo implements IUniqueId
|
||||
{
|
||||
private int _objectId;
|
||||
private double _absorbedHp;
|
||||
|
||||
public AbsorberInfo(int objectId, double pAbsorbedHp)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_absorbedHp = pAbsorbedHp;
|
||||
}
|
||||
|
||||
public double getAbsorbedHp()
|
||||
{
|
||||
return _absorbedHp;
|
||||
}
|
||||
|
||||
public void setAbsorbedHp(double absorbedHp)
|
||||
{
|
||||
_absorbedHp = absorbedHp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public void setObjectId(int objectId)
|
||||
{
|
||||
_objectId = objectId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object obj)
|
||||
{
|
||||
return (this == obj) || ((obj instanceof AbsorberInfo) && (((AbsorberInfo) obj).getObjectId() == _objectId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
}
|
||||
@@ -1,194 +1,213 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.Race;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* @author Battlecruiser
|
||||
*/
|
||||
public abstract class AbstractPlayerGroup
|
||||
{
|
||||
/**
|
||||
* @return a list of all members of this group
|
||||
*/
|
||||
public abstract List<L2PcInstance> getMembers();
|
||||
|
||||
/**
|
||||
* @return a list of object IDs of the members of this group
|
||||
*/
|
||||
public List<Integer> getMembersObjectId()
|
||||
{
|
||||
final List<Integer> ids = new ArrayList<>();
|
||||
forEachMember(m ->
|
||||
{
|
||||
ids.add(m.getObjectId());
|
||||
return true;
|
||||
});
|
||||
return ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the leader of this group
|
||||
*/
|
||||
public abstract L2PcInstance getLeader();
|
||||
|
||||
/**
|
||||
* Change the leader of this group to the specified player.
|
||||
* @param leader the player to set as the new leader of this group
|
||||
*/
|
||||
public abstract void setLeader(L2PcInstance leader);
|
||||
|
||||
/**
|
||||
* @return the leader's object ID
|
||||
*/
|
||||
public int getLeaderObjectId()
|
||||
{
|
||||
return getLeader().getObjectId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given player is the leader of this group.
|
||||
* @param player the player to check
|
||||
* @return {@code true} if the specified player is the leader of this group, {@code false} otherwise
|
||||
*/
|
||||
public boolean isLeader(L2PcInstance player)
|
||||
{
|
||||
return getLeaderObjectId() == player.getObjectId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the count of all players in this group
|
||||
*/
|
||||
public int getMemberCount()
|
||||
{
|
||||
return getMembers().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the count of all player races in this group
|
||||
*/
|
||||
public int getRaceCount()
|
||||
{
|
||||
final List<Race> partyRaces = new ArrayList<>();
|
||||
for (L2PcInstance member : getMembers())
|
||||
{
|
||||
if (!partyRaces.contains(member.getRace()))
|
||||
{
|
||||
partyRaces.add(member.getRace());
|
||||
}
|
||||
}
|
||||
return partyRaces.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the level of this group
|
||||
*/
|
||||
public abstract int getLevel();
|
||||
|
||||
/**
|
||||
* Broadcast a packet to every member of this group.
|
||||
* @param packet the packet to broadcast
|
||||
*/
|
||||
public void broadcastPacket(L2GameServerPacket packet)
|
||||
{
|
||||
forEachMember(m ->
|
||||
{
|
||||
if (m != null)
|
||||
{
|
||||
m.sendPacket(packet);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast a system message to this group.
|
||||
* @param message the system message to broadcast
|
||||
*/
|
||||
public void broadcastMessage(SystemMessageId message)
|
||||
{
|
||||
broadcastPacket(SystemMessage.getSystemMessage(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast a text message to this group.
|
||||
* @param text to broadcast
|
||||
*/
|
||||
public void broadcastString(String text)
|
||||
{
|
||||
broadcastPacket(SystemMessage.sendString(text));
|
||||
}
|
||||
|
||||
public void broadcastCreatureSay(CreatureSay msg, L2PcInstance broadcaster)
|
||||
{
|
||||
forEachMember(m ->
|
||||
{
|
||||
if ((m != null) && !BlockList.isBlocked(m, broadcaster))
|
||||
{
|
||||
m.sendPacket(msg);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this group contains a given player.
|
||||
* @param player the player to check
|
||||
* @return {@code true} if this group contains the specified player, {@code false} otherwise
|
||||
*/
|
||||
public boolean containsPlayer(L2PcInstance player)
|
||||
{
|
||||
return getMembers().contains(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a random member of this group
|
||||
*/
|
||||
public L2PcInstance getRandomPlayer()
|
||||
{
|
||||
return getMembers().get(Rnd.get(getMemberCount()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over the group and executes procedure on each member
|
||||
* @param procedure the prodecure to be executed on each member.<br>
|
||||
* If executing the procedure on a member returns {@code true}, the loop continues to the next member, otherwise it breaks the loop
|
||||
* @return {@code true} if the procedure executed correctly, {@code false} if the loop was broken prematurely
|
||||
*/
|
||||
public boolean forEachMember(Function<L2PcInstance, Boolean> procedure)
|
||||
{
|
||||
for (L2PcInstance player : getMembers())
|
||||
{
|
||||
if (!procedure.apply(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.enums.Race;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Battlecruiser
|
||||
*/
|
||||
public abstract class AbstractPlayerGroup
|
||||
{
|
||||
/**
|
||||
* @return a list of all members of this group
|
||||
*/
|
||||
public abstract List<L2PcInstance> getMembers();
|
||||
|
||||
/**
|
||||
* @return a list of object IDs of the members of this group
|
||||
*/
|
||||
public List<Integer> getMembersObjectId()
|
||||
{
|
||||
final List<Integer> ids = new ArrayList<>();
|
||||
forEachMember(m ->
|
||||
{
|
||||
ids.add(m.getObjectId());
|
||||
return true;
|
||||
});
|
||||
return ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the leader of this group
|
||||
*/
|
||||
public abstract L2PcInstance getLeader();
|
||||
|
||||
/**
|
||||
* Change the leader of this group to the specified player.
|
||||
* @param leader the player to set as the new leader of this group
|
||||
*/
|
||||
public abstract void setLeader(L2PcInstance leader);
|
||||
|
||||
/**
|
||||
* @return the leader's object ID
|
||||
*/
|
||||
public int getLeaderObjectId()
|
||||
{
|
||||
return getLeader().getObjectId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given player is the leader of this group.
|
||||
* @param player the player to check
|
||||
* @return {@code true} if the specified player is the leader of this group, {@code false} otherwise
|
||||
*/
|
||||
public boolean isLeader(L2PcInstance player)
|
||||
{
|
||||
return (getLeaderObjectId() == player.getObjectId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the count of all players in this group
|
||||
*/
|
||||
public int getMemberCount()
|
||||
{
|
||||
return getMembers().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the count of all player races in this group
|
||||
*/
|
||||
public int getRaceCount()
|
||||
{
|
||||
final List<Race> partyRaces = new ArrayList<>();
|
||||
for (L2PcInstance member : getMembers())
|
||||
{
|
||||
if (!partyRaces.contains(member.getRace()))
|
||||
{
|
||||
partyRaces.add(member.getRace());
|
||||
}
|
||||
}
|
||||
return partyRaces.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the level of this group
|
||||
*/
|
||||
public abstract int getLevel();
|
||||
|
||||
/**
|
||||
* Broadcast a packet to every member of this group.
|
||||
* @param packet the packet to broadcast
|
||||
*/
|
||||
public void broadcastPacket(IClientOutgoingPacket packet)
|
||||
{
|
||||
forEachMember(m ->
|
||||
{
|
||||
if (m != null)
|
||||
{
|
||||
m.sendPacket(packet);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast a system message to this group.
|
||||
* @param message the system message to broadcast
|
||||
*/
|
||||
public void broadcastMessage(SystemMessageId message)
|
||||
{
|
||||
broadcastPacket(SystemMessage.getSystemMessage(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast a text message to this group.
|
||||
* @param text to broadcast
|
||||
*/
|
||||
public void broadcastString(String text)
|
||||
{
|
||||
broadcastPacket(SystemMessage.sendString(text));
|
||||
}
|
||||
|
||||
public void broadcastCreatureSay(CreatureSay msg, L2PcInstance broadcaster)
|
||||
{
|
||||
forEachMember(m ->
|
||||
{
|
||||
if ((m != null) && !BlockList.isBlocked(m, broadcaster))
|
||||
{
|
||||
m.sendPacket(msg);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this group contains a given player.
|
||||
* @param player the player to check
|
||||
* @return {@code true} if this group contains the specified player, {@code false} otherwise
|
||||
*/
|
||||
public boolean containsPlayer(L2PcInstance player)
|
||||
{
|
||||
return getMembers().contains(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a random member of this group
|
||||
*/
|
||||
public L2PcInstance getRandomPlayer()
|
||||
{
|
||||
return getMembers().get(Rnd.get(getMemberCount()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over the group and executes procedure on each member
|
||||
* @param procedure the prodecure to be executed on each member.<br>
|
||||
* If executing the procedure on a member returns {@code true}, the loop continues to the next member, otherwise it breaks the loop
|
||||
* @return {@code true} if the procedure executed correctly, {@code false} if the loop was broken prematurely
|
||||
*/
|
||||
public boolean forEachMember(Function<L2PcInstance, Boolean> procedure)
|
||||
{
|
||||
for (L2PcInstance player : getMembers())
|
||||
{
|
||||
if (!procedure.apply(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj instanceof AbstractPlayerGroup)
|
||||
{
|
||||
if (getLeaderObjectId() == ((AbstractPlayerGroup) obj).getLeaderObjectId())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +1,49 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model.clientstrings;
|
||||
|
||||
/**
|
||||
* @author Forsaiken
|
||||
*/
|
||||
final class FastStringBuilder
|
||||
{
|
||||
private final char[] _array;
|
||||
private int _len;
|
||||
|
||||
public FastStringBuilder(int capacity)
|
||||
{
|
||||
_array = new char[capacity];
|
||||
}
|
||||
|
||||
public final void append(String text)
|
||||
{
|
||||
text.getChars(0, text.length(), _array, _len);
|
||||
_len += text.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString()
|
||||
{
|
||||
return new String(_array);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class ActionDataHolder
|
||||
{
|
||||
private final int _id;
|
||||
private final String _handler;
|
||||
private final int _optionId;
|
||||
|
||||
public ActionDataHolder(StatsSet set)
|
||||
{
|
||||
_id = set.getInt("id");
|
||||
_handler = set.getString("handler");
|
||||
_optionId = set.getInt("option", 0);
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public String getHandler()
|
||||
{
|
||||
return _handler;
|
||||
}
|
||||
|
||||
public int getOptionId()
|
||||
{
|
||||
return _optionId;
|
||||
}
|
||||
}
|
||||
@@ -1,118 +1,118 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* Action Key DTO.
|
||||
* @author mrTJO, Zoey76
|
||||
*/
|
||||
public class ActionKey
|
||||
{
|
||||
private final int _cat;
|
||||
private int _cmd = 0;
|
||||
private int _key = 0;
|
||||
private int _tgKey1 = 0;
|
||||
private int _tgKey2 = 0;
|
||||
private int _show = 1;
|
||||
|
||||
/**
|
||||
* @param cat category Id
|
||||
*/
|
||||
public ActionKey(int cat)
|
||||
{
|
||||
_cat = cat;
|
||||
}
|
||||
|
||||
/**
|
||||
* L2ActionKey Initialization
|
||||
* @param cat Category ID
|
||||
* @param cmd Command ID
|
||||
* @param key User Defined Primary Key
|
||||
* @param tgKey1 1st Toggled Key (eg. Alt, Ctrl or Shift)
|
||||
* @param tgKey2 2nd Toggled Key (eg. Alt, Ctrl or Shift)
|
||||
* @param show Show Action in UI
|
||||
*/
|
||||
public ActionKey(int cat, int cmd, int key, int tgKey1, int tgKey2, int show)
|
||||
{
|
||||
_cat = cat;
|
||||
_cmd = cmd;
|
||||
_key = key;
|
||||
_tgKey1 = tgKey1;
|
||||
_tgKey2 = tgKey2;
|
||||
_show = show;
|
||||
}
|
||||
|
||||
public int getCategory()
|
||||
{
|
||||
return _cat;
|
||||
}
|
||||
|
||||
public int getCommandId()
|
||||
{
|
||||
return _cmd;
|
||||
}
|
||||
|
||||
public void setCommandId(int cmd)
|
||||
{
|
||||
_cmd = cmd;
|
||||
}
|
||||
|
||||
public int getKeyId()
|
||||
{
|
||||
return _key;
|
||||
}
|
||||
|
||||
public void setKeyId(int key)
|
||||
{
|
||||
_key = key;
|
||||
}
|
||||
|
||||
public int getToogleKey1()
|
||||
{
|
||||
return _tgKey1;
|
||||
}
|
||||
|
||||
public void setToogleKey1(int tKey1)
|
||||
{
|
||||
_tgKey1 = tKey1;
|
||||
}
|
||||
|
||||
public int getToogleKey2()
|
||||
{
|
||||
return _tgKey2;
|
||||
}
|
||||
|
||||
public void setToogleKey2(int tKey2)
|
||||
{
|
||||
_tgKey2 = tKey2;
|
||||
}
|
||||
|
||||
public int getShowStatus()
|
||||
{
|
||||
return _show;
|
||||
}
|
||||
|
||||
public void setShowStatus(int show)
|
||||
{
|
||||
_show = show;
|
||||
}
|
||||
|
||||
public String getSqlSaveString(int playerId, int order)
|
||||
{
|
||||
return "(" + playerId + ", " + _cat + ", " + order + ", " + _cmd + "," + _key + ", " + _tgKey1 + ", " + _tgKey2 + ", " + _show + ")";
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* Action Key DTO.
|
||||
* @author mrTJO, Zoey76
|
||||
*/
|
||||
public class ActionKey
|
||||
{
|
||||
private final int _cat;
|
||||
private int _cmd = 0;
|
||||
private int _key = 0;
|
||||
private int _tgKey1 = 0;
|
||||
private int _tgKey2 = 0;
|
||||
private int _show = 1;
|
||||
|
||||
/**
|
||||
* @param cat category Id
|
||||
*/
|
||||
public ActionKey(int cat)
|
||||
{
|
||||
_cat = cat;
|
||||
}
|
||||
|
||||
/**
|
||||
* L2ActionKey Initialization
|
||||
* @param cat Category ID
|
||||
* @param cmd Command ID
|
||||
* @param key User Defined Primary Key
|
||||
* @param tgKey1 1st Toggled Key (eg. Alt, Ctrl or Shift)
|
||||
* @param tgKey2 2nd Toggled Key (eg. Alt, Ctrl or Shift)
|
||||
* @param show Show Action in UI
|
||||
*/
|
||||
public ActionKey(int cat, int cmd, int key, int tgKey1, int tgKey2, int show)
|
||||
{
|
||||
_cat = cat;
|
||||
_cmd = cmd;
|
||||
_key = key;
|
||||
_tgKey1 = tgKey1;
|
||||
_tgKey2 = tgKey2;
|
||||
_show = show;
|
||||
}
|
||||
|
||||
public int getCategory()
|
||||
{
|
||||
return _cat;
|
||||
}
|
||||
|
||||
public int getCommandId()
|
||||
{
|
||||
return _cmd;
|
||||
}
|
||||
|
||||
public void setCommandId(int cmd)
|
||||
{
|
||||
_cmd = cmd;
|
||||
}
|
||||
|
||||
public int getKeyId()
|
||||
{
|
||||
return _key;
|
||||
}
|
||||
|
||||
public void setKeyId(int key)
|
||||
{
|
||||
_key = key;
|
||||
}
|
||||
|
||||
public int getToogleKey1()
|
||||
{
|
||||
return _tgKey1;
|
||||
}
|
||||
|
||||
public void setToogleKey1(int tKey1)
|
||||
{
|
||||
_tgKey1 = tKey1;
|
||||
}
|
||||
|
||||
public int getToogleKey2()
|
||||
{
|
||||
return _tgKey2;
|
||||
}
|
||||
|
||||
public void setToogleKey2(int tKey2)
|
||||
{
|
||||
_tgKey2 = tKey2;
|
||||
}
|
||||
|
||||
public int getShowStatus()
|
||||
{
|
||||
return _show;
|
||||
}
|
||||
|
||||
public void setShowStatus(int show)
|
||||
{
|
||||
_show = show;
|
||||
}
|
||||
|
||||
public String getSqlSaveString(int playerId, int order)
|
||||
{
|
||||
return "(" + playerId + ", " + _cat + ", " + order + ", " + _cmd + "," + _key + ", " + _tgKey1 + ", " + _tgKey2 + ", " + _show + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,102 +1,96 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
|
||||
/**
|
||||
* @author xban1x
|
||||
*/
|
||||
public final class AggroInfo
|
||||
{
|
||||
private final L2Character _attacker;
|
||||
private int _hate = 0;
|
||||
private int _damage = 0;
|
||||
|
||||
public AggroInfo(L2Character pAttacker)
|
||||
{
|
||||
_attacker = pAttacker;
|
||||
}
|
||||
|
||||
public L2Character getAttacker()
|
||||
{
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public int getHate()
|
||||
{
|
||||
return _hate;
|
||||
}
|
||||
|
||||
public int checkHate(L2Character owner)
|
||||
{
|
||||
if (_attacker.isAlikeDead() || !_attacker.isVisible() || !owner.getKnownList().knowsObject(_attacker))
|
||||
{
|
||||
_hate = 0;
|
||||
}
|
||||
|
||||
return _hate;
|
||||
}
|
||||
|
||||
public void addHate(int value)
|
||||
{
|
||||
_hate = (int) Math.min(_hate + (long) value, 999999999);
|
||||
}
|
||||
|
||||
public void stopHate()
|
||||
{
|
||||
_hate = 0;
|
||||
}
|
||||
|
||||
public int getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public void addDamage(int value)
|
||||
{
|
||||
_damage = (int) Math.min(_damage + (long) value, 999999999);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj instanceof AggroInfo)
|
||||
{
|
||||
return (((AggroInfo) obj).getAttacker() == _attacker);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode()
|
||||
{
|
||||
return _attacker.getObjectId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "AggroInfo [attacker=" + _attacker + ", hate=" + _hate + ", damage=" + _damage + "]";
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
|
||||
/**
|
||||
* @author xban1x
|
||||
*/
|
||||
public final class AggroInfo
|
||||
{
|
||||
private final L2Character _attacker;
|
||||
private int _hate = 0;
|
||||
private int _damage = 0;
|
||||
|
||||
public AggroInfo(L2Character pAttacker)
|
||||
{
|
||||
_attacker = pAttacker;
|
||||
}
|
||||
|
||||
public L2Character getAttacker()
|
||||
{
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public int getHate()
|
||||
{
|
||||
return _hate;
|
||||
}
|
||||
|
||||
public int checkHate(L2Character owner)
|
||||
{
|
||||
if (_attacker.isAlikeDead() || !_attacker.isSpawned() || !owner.isInSurroundingRegion(_attacker))
|
||||
{
|
||||
_hate = 0;
|
||||
}
|
||||
|
||||
return _hate;
|
||||
}
|
||||
|
||||
public void addHate(int value)
|
||||
{
|
||||
_hate = (int) Math.min(_hate + (long) value, 999999999);
|
||||
}
|
||||
|
||||
public void stopHate()
|
||||
{
|
||||
_hate = 0;
|
||||
}
|
||||
|
||||
public int getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public void addDamage(int value)
|
||||
{
|
||||
_damage = (int) Math.min(_damage + (long) value, 999999999);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj instanceof AggroInfo)
|
||||
{
|
||||
return (((AggroInfo) obj).getAttacker() == _attacker);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode()
|
||||
{
|
||||
return _attacker.getObjectId();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +1,50 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* Holds a list of all AirShip teleports.
|
||||
* @author xban1x
|
||||
*/
|
||||
public final class AirShipTeleportList
|
||||
{
|
||||
private final int _location;
|
||||
private final int[] _fuel;
|
||||
private final VehiclePathPoint[][] _routes;
|
||||
|
||||
public AirShipTeleportList(int loc, int[] f, VehiclePathPoint[][] r)
|
||||
{
|
||||
_location = loc;
|
||||
_fuel = f;
|
||||
_routes = r;
|
||||
}
|
||||
|
||||
public int getLocation()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
public int[] getFuel()
|
||||
{
|
||||
return _fuel;
|
||||
}
|
||||
|
||||
public VehiclePathPoint[][] getRoute()
|
||||
{
|
||||
return _routes;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* Holds a list of all AirShip teleports.
|
||||
* @author xban1x
|
||||
*/
|
||||
public final class AirShipTeleportList
|
||||
{
|
||||
private final int _location;
|
||||
private final int[] _fuel;
|
||||
private final VehiclePathPoint[][] _routes;
|
||||
|
||||
public AirShipTeleportList(int loc, int[] f, VehiclePathPoint[][] r)
|
||||
{
|
||||
_location = loc;
|
||||
_fuel = f;
|
||||
_routes = r;
|
||||
}
|
||||
|
||||
public int getLocation()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
public int[] getFuel()
|
||||
{
|
||||
return _fuel;
|
||||
}
|
||||
|
||||
public VehiclePathPoint[][] getRoute()
|
||||
{
|
||||
return _routes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,173 +1,176 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.BlockCheckerEngine;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author xban1x
|
||||
*/
|
||||
public final class ArenaParticipantsHolder
|
||||
{
|
||||
private final int _arena;
|
||||
private final List<L2PcInstance> _redPlayers;
|
||||
private final List<L2PcInstance> _bluePlayers;
|
||||
private final BlockCheckerEngine _engine;
|
||||
|
||||
public ArenaParticipantsHolder(int arena)
|
||||
{
|
||||
_arena = arena;
|
||||
_redPlayers = new ArrayList<>(6);
|
||||
_bluePlayers = new ArrayList<>(6);
|
||||
_engine = new BlockCheckerEngine(this, _arena);
|
||||
}
|
||||
|
||||
public List<L2PcInstance> getRedPlayers()
|
||||
{
|
||||
return _redPlayers;
|
||||
}
|
||||
|
||||
public List<L2PcInstance> getBluePlayers()
|
||||
{
|
||||
return _bluePlayers;
|
||||
}
|
||||
|
||||
public List<L2PcInstance> getAllPlayers()
|
||||
{
|
||||
final List<L2PcInstance> all = new ArrayList<>(_redPlayers);
|
||||
all.addAll(_bluePlayers);
|
||||
return all;
|
||||
}
|
||||
|
||||
public void addPlayer(L2PcInstance player, int team)
|
||||
{
|
||||
if (team == 0)
|
||||
{
|
||||
_redPlayers.add(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
_bluePlayers.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayer(L2PcInstance player, int team)
|
||||
{
|
||||
if (team == 0)
|
||||
{
|
||||
_redPlayers.remove(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
_bluePlayers.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
public int getPlayerTeam(L2PcInstance player)
|
||||
{
|
||||
if (_redPlayers.contains(player))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (_bluePlayers.contains(player))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public int getRedTeamSize()
|
||||
{
|
||||
return _redPlayers.size();
|
||||
}
|
||||
|
||||
public int getBlueTeamSize()
|
||||
{
|
||||
return _bluePlayers.size();
|
||||
}
|
||||
|
||||
public void broadCastPacketToTeam(L2GameServerPacket packet)
|
||||
{
|
||||
for (L2PcInstance p : _redPlayers)
|
||||
{
|
||||
p.sendPacket(packet);
|
||||
}
|
||||
for (L2PcInstance p : _bluePlayers)
|
||||
{
|
||||
p.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearPlayers()
|
||||
{
|
||||
_redPlayers.clear();
|
||||
_bluePlayers.clear();
|
||||
}
|
||||
|
||||
public BlockCheckerEngine getEvent()
|
||||
{
|
||||
return _engine;
|
||||
}
|
||||
|
||||
public void updateEvent()
|
||||
{
|
||||
_engine.updatePlayersOnStart(this);
|
||||
}
|
||||
|
||||
public void checkAndShuffle()
|
||||
{
|
||||
final int redSize = _redPlayers.size();
|
||||
final int blueSize = _bluePlayers.size();
|
||||
if (redSize > (blueSize + 1))
|
||||
{
|
||||
broadCastPacketToTeam(SystemMessage.getSystemMessage(SystemMessageId.TEAM_MEMBERS_WERE_MODIFIED_BECAUSE_THE_TEAMS_WERE_UNBALANCED));
|
||||
for (int i = 0; i < ((redSize - (blueSize + 1)) + 1); i++)
|
||||
{
|
||||
final L2PcInstance plr = _redPlayers.get(i);
|
||||
if (plr == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
HandysBlockCheckerManager.getInstance().changePlayerToTeam(plr, _arena, 1);
|
||||
}
|
||||
}
|
||||
else if (blueSize > (redSize + 1))
|
||||
{
|
||||
broadCastPacketToTeam(SystemMessage.getSystemMessage(SystemMessageId.TEAM_MEMBERS_WERE_MODIFIED_BECAUSE_THE_TEAMS_WERE_UNBALANCED));
|
||||
for (int i = 0; i < ((blueSize - (redSize + 1)) + 1); i++)
|
||||
{
|
||||
final L2PcInstance plr = _bluePlayers.get(i);
|
||||
if (plr == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
HandysBlockCheckerManager.getInstance().changePlayerToTeam(plr, _arena, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.BlockCheckerEngine;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author xban1x
|
||||
*/
|
||||
public final class ArenaParticipantsHolder
|
||||
{
|
||||
private final int _arena;
|
||||
private final List<L2PcInstance> _redPlayers;
|
||||
private final List<L2PcInstance> _bluePlayers;
|
||||
private final BlockCheckerEngine _engine;
|
||||
|
||||
public ArenaParticipantsHolder(int arena)
|
||||
{
|
||||
_arena = arena;
|
||||
_redPlayers = new ArrayList<>(6);
|
||||
_bluePlayers = new ArrayList<>(6);
|
||||
_engine = new BlockCheckerEngine(this, _arena);
|
||||
}
|
||||
|
||||
public List<L2PcInstance> getRedPlayers()
|
||||
{
|
||||
return _redPlayers;
|
||||
}
|
||||
|
||||
public List<L2PcInstance> getBluePlayers()
|
||||
{
|
||||
return _bluePlayers;
|
||||
}
|
||||
|
||||
public List<L2PcInstance> getAllPlayers()
|
||||
{
|
||||
final List<L2PcInstance> all = new ArrayList<>(12);
|
||||
all.addAll(_redPlayers);
|
||||
all.addAll(_bluePlayers);
|
||||
return all;
|
||||
}
|
||||
|
||||
public void addPlayer(L2PcInstance player, int team)
|
||||
{
|
||||
if (team == 0)
|
||||
{
|
||||
_redPlayers.add(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
_bluePlayers.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayer(L2PcInstance player, int team)
|
||||
{
|
||||
if (team == 0)
|
||||
{
|
||||
_redPlayers.remove(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
_bluePlayers.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
public int getPlayerTeam(L2PcInstance player)
|
||||
{
|
||||
if (_redPlayers.contains(player))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (_bluePlayers.contains(player))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public int getRedTeamSize()
|
||||
{
|
||||
return _redPlayers.size();
|
||||
}
|
||||
|
||||
public int getBlueTeamSize()
|
||||
{
|
||||
return _bluePlayers.size();
|
||||
}
|
||||
|
||||
public void broadCastPacketToTeam(IClientOutgoingPacket packet)
|
||||
{
|
||||
for (L2PcInstance p : _redPlayers)
|
||||
{
|
||||
p.sendPacket(packet);
|
||||
}
|
||||
for (L2PcInstance p : _bluePlayers)
|
||||
{
|
||||
p.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearPlayers()
|
||||
{
|
||||
_redPlayers.clear();
|
||||
_bluePlayers.clear();
|
||||
}
|
||||
|
||||
public BlockCheckerEngine getEvent()
|
||||
{
|
||||
return _engine;
|
||||
}
|
||||
|
||||
public void updateEvent()
|
||||
{
|
||||
_engine.updatePlayersOnStart(this);
|
||||
}
|
||||
|
||||
public void checkAndShuffle()
|
||||
{
|
||||
final int redSize = _redPlayers.size();
|
||||
final int blueSize = _bluePlayers.size();
|
||||
if (redSize > (blueSize + 1))
|
||||
{
|
||||
broadCastPacketToTeam(SystemMessage.getSystemMessage(SystemMessageId.TEAM_MEMBERS_WERE_MODIFIED_BECAUSE_THE_TEAMS_WERE_UNBALANCED));
|
||||
final int needed = redSize - (blueSize + 1);
|
||||
for (int i = 0; i < (needed + 1); i++)
|
||||
{
|
||||
final L2PcInstance plr = _redPlayers.get(i);
|
||||
if (plr == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
HandysBlockCheckerManager.getInstance().changePlayerToTeam(plr, _arena, 1);
|
||||
}
|
||||
}
|
||||
else if (blueSize > (redSize + 1))
|
||||
{
|
||||
broadCastPacketToTeam(SystemMessage.getSystemMessage(SystemMessageId.TEAM_MEMBERS_WERE_MODIFIED_BECAUSE_THE_TEAMS_WERE_UNBALANCED));
|
||||
final int needed = blueSize - (redSize + 1);
|
||||
for (int i = 0; i < (needed + 1); i++)
|
||||
{
|
||||
final L2PcInstance plr = _bluePlayers.get(i);
|
||||
if (plr == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
HandysBlockCheckerManager.getInstance().changePlayerToTeam(plr, _arena, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,713 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
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 com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.datatables.SpawnTable;
|
||||
import com.l2jmobius.gameserver.idfactory.IdFactory;
|
||||
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* Auto Spawn handler.<br>
|
||||
* Allows spawning of a NPC object based on a timer.<br>
|
||||
* (From the official idea used for the Merchant and Blacksmith of Mammon)<br>
|
||||
* General Usage: - Call registerSpawn() with the parameters listed below.<br>
|
||||
* int npcId int[][] spawnPoints or specify NULL to add points later.<br>
|
||||
* int initialDelay (If < 0 = default value) int respawnDelay (If < 0 = default value)<br>
|
||||
* int despawnDelay (If < 0 = default value or if = 0, function disabled)<br>
|
||||
* spawnPoints is a standard two-dimensional int array containing X,Y and Z coordinates.<br>
|
||||
* The default respawn/despawn delays are currently every hour (as for Mammon on official servers).<br>
|
||||
* The resulting AutoSpawnInstance object represents the newly added spawn index.<br>
|
||||
* The internal methods of this object can be used to adjust random spawning, for instance a call to setRandomSpawn(1, true); would set the spawn at index 1 to be randomly rather than sequentially-based.<br>
|
||||
* Also they can be used to specify the number of NPC instances to spawn using setSpawnCount(), and broadcast a message to all users using setBroadcast().<br>
|
||||
* Random Spawning = OFF by default Broadcasting = OFF by default
|
||||
* @author Tempy
|
||||
*/
|
||||
public class AutoSpawnHandler
|
||||
{
|
||||
protected static final Logger _log = Logger.getLogger(AutoSpawnHandler.class.getName());
|
||||
|
||||
private static final int DEFAULT_INITIAL_SPAWN = 30000; // 30 seconds after registration
|
||||
private static final int DEFAULT_RESPAWN = 3600000; // 1 hour in millisecs
|
||||
private static final int DEFAULT_DESPAWN = 3600000; // 1 hour in millisecs
|
||||
|
||||
protected Map<Integer, AutoSpawnInstance> _registeredSpawns = new ConcurrentHashMap<>();
|
||||
protected Map<Integer, ScheduledFuture<?>> _runningSpawns = new ConcurrentHashMap<>();
|
||||
|
||||
protected boolean _activeState = true;
|
||||
|
||||
protected AutoSpawnHandler()
|
||||
{
|
||||
restoreSpawnData();
|
||||
}
|
||||
|
||||
public static AutoSpawnHandler getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
public final int size()
|
||||
{
|
||||
return _registeredSpawns.size();
|
||||
}
|
||||
|
||||
public void reload()
|
||||
{
|
||||
// stop all timers
|
||||
for (ScheduledFuture<?> sf : _runningSpawns.values())
|
||||
{
|
||||
if (sf != null)
|
||||
{
|
||||
sf.cancel(true);
|
||||
}
|
||||
}
|
||||
// unregister all registered spawns
|
||||
for (AutoSpawnInstance asi : _registeredSpawns.values())
|
||||
{
|
||||
if (asi != null)
|
||||
{
|
||||
removeSpawn(asi);
|
||||
}
|
||||
}
|
||||
|
||||
// create clean list
|
||||
_registeredSpawns.clear();
|
||||
_runningSpawns.clear();
|
||||
|
||||
// load
|
||||
restoreSpawnData();
|
||||
}
|
||||
|
||||
private void restoreSpawnData()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT * FROM random_spawn ORDER BY groupId ASC");
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM random_spawn_loc WHERE groupId=?"))
|
||||
{
|
||||
// Restore spawn group data, then the location data.
|
||||
while (rs.next())
|
||||
{
|
||||
// Register random spawn group, set various options on the
|
||||
// created spawn instance.
|
||||
final AutoSpawnInstance spawnInst = registerSpawn(rs.getInt("npcId"), rs.getInt("initialDelay"), rs.getInt("respawnDelay"), rs.getInt("despawnDelay"));
|
||||
|
||||
spawnInst.setSpawnCount(rs.getInt("count"));
|
||||
spawnInst.setBroadcast(rs.getBoolean("broadcastSpawn"));
|
||||
spawnInst.setRandomSpawn(rs.getBoolean("randomSpawn"));
|
||||
|
||||
// Restore the spawn locations for this spawn group/instance.
|
||||
ps.setInt(1, rs.getInt("groupId"));
|
||||
try (ResultSet rs2 = ps.executeQuery())
|
||||
{
|
||||
ps.clearParameters();
|
||||
|
||||
while (rs2.next())
|
||||
{
|
||||
// Add each location to the spawn group/instance.
|
||||
spawnInst.addSpawnLocation(rs2.getInt("x"), rs2.getInt("y"), rs2.getInt("z"), rs2.getInt("heading"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "AutoSpawnHandler: Could not restore spawn data: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a spawn with the given parameters with the spawner, and marks it as active.<br>
|
||||
* Returns a AutoSpawnInstance containing info about the spawn.
|
||||
* @param npcId
|
||||
* @param spawnPoints
|
||||
* @param initialDelay (If < 0 = default value)
|
||||
* @param respawnDelay (If < 0 = default value)
|
||||
* @param despawnDelay (If < 0 = default value or if = 0, function disabled)
|
||||
* @return AutoSpawnInstance spawnInst
|
||||
*/
|
||||
public AutoSpawnInstance registerSpawn(int npcId, int[][] spawnPoints, int initialDelay, int respawnDelay, int despawnDelay)
|
||||
{
|
||||
if (initialDelay < 0)
|
||||
{
|
||||
initialDelay = DEFAULT_INITIAL_SPAWN;
|
||||
}
|
||||
|
||||
if (respawnDelay < 0)
|
||||
{
|
||||
respawnDelay = DEFAULT_RESPAWN;
|
||||
}
|
||||
|
||||
if (despawnDelay < 0)
|
||||
{
|
||||
despawnDelay = DEFAULT_DESPAWN;
|
||||
}
|
||||
|
||||
final AutoSpawnInstance newSpawn = new AutoSpawnInstance(npcId, initialDelay, respawnDelay, despawnDelay);
|
||||
|
||||
if (spawnPoints != null)
|
||||
{
|
||||
for (int[] spawnPoint : spawnPoints)
|
||||
{
|
||||
newSpawn.addSpawnLocation(spawnPoint);
|
||||
}
|
||||
}
|
||||
|
||||
final int newId = IdFactory.getInstance().getNextId();
|
||||
newSpawn._objectId = newId;
|
||||
_registeredSpawns.put(newId, newSpawn);
|
||||
|
||||
setSpawnActive(newSpawn, true);
|
||||
return newSpawn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a spawn with the given parameters with the spawner, and marks it as active.<br>
|
||||
* Returns a AutoSpawnInstance containing info about the spawn.<br>
|
||||
* <B>Warning:</B> Spawn locations must be specified separately using addSpawnLocation().
|
||||
* @param npcId
|
||||
* @param initialDelay (If < 0 = default value)
|
||||
* @param respawnDelay (If < 0 = default value)
|
||||
* @param despawnDelay (If < 0 = default value or if = 0, function disabled)
|
||||
* @return AutoSpawnInstance spawnInst
|
||||
*/
|
||||
public AutoSpawnInstance registerSpawn(int npcId, int initialDelay, int respawnDelay, int despawnDelay)
|
||||
{
|
||||
return registerSpawn(npcId, null, initialDelay, respawnDelay, despawnDelay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a registered spawn from the list, specified by the given spawn instance.
|
||||
* @param spawnInst
|
||||
* @return boolean removedSuccessfully
|
||||
*/
|
||||
public boolean removeSpawn(AutoSpawnInstance spawnInst)
|
||||
{
|
||||
if (!isSpawnRegistered(spawnInst))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Try to remove from the list of registered spawns if it exists.
|
||||
_registeredSpawns.remove(spawnInst.getId());
|
||||
|
||||
// Cancel the currently associated running scheduled task.
|
||||
_runningSpawns.remove(spawnInst._objectId).cancel(false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "AutoSpawnHandler: Could not auto spawn for NPC ID " + spawnInst._npcId + " (Object ID = " + spawnInst._objectId + "): " + e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a registered spawn from the list, specified by the given spawn object ID.
|
||||
* @param objectId
|
||||
*/
|
||||
public void removeSpawn(int objectId)
|
||||
{
|
||||
removeSpawn(_registeredSpawns.get(objectId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the active state of the specified spawn.
|
||||
* @param spawnInst
|
||||
* @param isActive
|
||||
*/
|
||||
public void setSpawnActive(AutoSpawnInstance spawnInst, boolean isActive)
|
||||
{
|
||||
if (spawnInst == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final int objectId = spawnInst._objectId;
|
||||
|
||||
if (!isSpawnRegistered(objectId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ScheduledFuture<?> spawnTask = null;
|
||||
if (isActive)
|
||||
{
|
||||
final AutoSpawner rs = new AutoSpawner(objectId);
|
||||
spawnTask = spawnInst._desDelay > 0 ? ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(rs, spawnInst._initDelay, spawnInst._resDelay) : ThreadPoolManager.getInstance().scheduleEffect(rs, spawnInst._initDelay);
|
||||
_runningSpawns.put(objectId, spawnTask);
|
||||
}
|
||||
else
|
||||
{
|
||||
final AutoDespawner rd = new AutoDespawner(objectId);
|
||||
spawnTask = _runningSpawns.remove(objectId);
|
||||
if (spawnTask != null)
|
||||
{
|
||||
spawnTask.cancel(false);
|
||||
}
|
||||
ThreadPoolManager.getInstance().scheduleEffect(rd, 0);
|
||||
}
|
||||
spawnInst.setSpawnActive(isActive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the active state of all auto spawn instances to that specified, and cancels the scheduled spawn task if necessary.
|
||||
* @param isActive
|
||||
*/
|
||||
public void setAllActive(boolean isActive)
|
||||
{
|
||||
if (_activeState == isActive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (AutoSpawnInstance spawnInst : _registeredSpawns.values())
|
||||
{
|
||||
setSpawnActive(spawnInst, isActive);
|
||||
}
|
||||
|
||||
_activeState = isActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of milliseconds until the next occurrence of the given spawn.
|
||||
* @param spawnInst
|
||||
* @return
|
||||
*/
|
||||
public final long getTimeToNextSpawn(AutoSpawnInstance spawnInst)
|
||||
{
|
||||
final int objectId = spawnInst.getObjectId();
|
||||
return !isSpawnRegistered(objectId) ? -1 : _runningSpawns.containsKey(objectId) ? _runningSpawns.get(objectId).getDelay(TimeUnit.MILLISECONDS) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to return the AutoSpawnInstance associated with the given NPC or Object ID type.<br>
|
||||
* Note: If isObjectId == false, returns first instance for the specified NPC ID.
|
||||
* @param id
|
||||
* @param isObjectId
|
||||
* @return AutoSpawnInstance spawnInst
|
||||
*/
|
||||
public final AutoSpawnInstance getAutoSpawnInstance(int id, boolean isObjectId)
|
||||
{
|
||||
if (isObjectId)
|
||||
{
|
||||
if (isSpawnRegistered(id))
|
||||
{
|
||||
return _registeredSpawns.get(id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (AutoSpawnInstance spawnInst : _registeredSpawns.values())
|
||||
{
|
||||
if (spawnInst.getId() == id)
|
||||
{
|
||||
return spawnInst;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<AutoSpawnInstance> getAutoSpawnInstances(int npcId)
|
||||
{
|
||||
final List<AutoSpawnInstance> result = new LinkedList<>();
|
||||
for (AutoSpawnInstance spawnInst : _registeredSpawns.values())
|
||||
{
|
||||
if (spawnInst.getId() == npcId)
|
||||
{
|
||||
result.add(spawnInst);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the specified object ID is assigned to an auto spawn.
|
||||
* @param objectId
|
||||
* @return isAssigned
|
||||
*/
|
||||
public final boolean isSpawnRegistered(int objectId)
|
||||
{
|
||||
return _registeredSpawns.containsKey(objectId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the specified spawn instance is assigned to an auto spawn.
|
||||
* @param spawnInst
|
||||
* @return boolean isAssigned
|
||||
*/
|
||||
public final boolean isSpawnRegistered(AutoSpawnInstance spawnInst)
|
||||
{
|
||||
return _registeredSpawns.containsValue(spawnInst);
|
||||
}
|
||||
|
||||
/**
|
||||
* AutoSpawner class<br>
|
||||
* This handles the main spawn task for an auto spawn instance, and initializes a despawner if required.
|
||||
* @author Tempy
|
||||
*/
|
||||
private class AutoSpawner implements Runnable
|
||||
{
|
||||
private final int _objectId;
|
||||
|
||||
protected AutoSpawner(int objectId)
|
||||
{
|
||||
_objectId = objectId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Retrieve the required spawn instance for this spawn task.
|
||||
final AutoSpawnInstance spawnInst = _registeredSpawns.get(_objectId);
|
||||
|
||||
// If the spawn is not scheduled to be active, cancel the spawn
|
||||
// task.
|
||||
if (!spawnInst.isSpawnActive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Location[] locationList = spawnInst.getLocationList();
|
||||
|
||||
// If there are no set co-ordinates, cancel the spawn task.
|
||||
if (locationList.length == 0)
|
||||
{
|
||||
_log.info("AutoSpawnHandler: No location co-ords specified for spawn instance (Object ID = " + _objectId + ").");
|
||||
return;
|
||||
}
|
||||
|
||||
final int locationCount = locationList.length;
|
||||
int locationIndex = Rnd.nextInt(locationCount);
|
||||
|
||||
// If random spawning is disabled, the spawn at the next set of co-ordinates after the last.
|
||||
// If the index is greater than the number of possible spawns, reset the counter to zero.
|
||||
if (!spawnInst.isRandomSpawn())
|
||||
{
|
||||
locationIndex = spawnInst._lastLocIndex + 1;
|
||||
|
||||
if (locationIndex == locationCount)
|
||||
{
|
||||
locationIndex = 0;
|
||||
}
|
||||
|
||||
spawnInst._lastLocIndex = locationIndex;
|
||||
}
|
||||
|
||||
// Set the X, Y and Z co-ordinates, where this spawn will take place.
|
||||
final int x = locationList[locationIndex].getX();
|
||||
final int y = locationList[locationIndex].getY();
|
||||
final int z = locationList[locationIndex].getZ();
|
||||
final int heading = locationList[locationIndex].getHeading();
|
||||
|
||||
final L2Spawn newSpawn = new L2Spawn(spawnInst.getId());
|
||||
newSpawn.setX(x);
|
||||
newSpawn.setY(y);
|
||||
newSpawn.setZ(z);
|
||||
if (heading != -1)
|
||||
{
|
||||
newSpawn.setHeading(heading);
|
||||
}
|
||||
newSpawn.setAmount(spawnInst.getSpawnCount());
|
||||
if (spawnInst._desDelay == 0)
|
||||
{
|
||||
newSpawn.setRespawnDelay(spawnInst._resDelay);
|
||||
}
|
||||
|
||||
// Add the new spawn information to the spawn table, but do not store it.
|
||||
SpawnTable.getInstance().addNewSpawn(newSpawn, false);
|
||||
L2Npc npcInst = null;
|
||||
|
||||
if (spawnInst._spawnCount == 1)
|
||||
{
|
||||
npcInst = newSpawn.doSpawn();
|
||||
npcInst.setXYZ(npcInst.getX(), npcInst.getY(), npcInst.getZ());
|
||||
spawnInst.addNpcInstance(npcInst);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < spawnInst._spawnCount; i++)
|
||||
{
|
||||
npcInst = newSpawn.doSpawn();
|
||||
|
||||
// To prevent spawning of more than one NPC in the exact same spot, move it slightly by a small random offset.
|
||||
npcInst.setXYZ(npcInst.getX() + Rnd.nextInt(50), npcInst.getY() + Rnd.nextInt(50), npcInst.getZ());
|
||||
|
||||
// Add the NPC instance to the list of managed instances.
|
||||
spawnInst.addNpcInstance(npcInst);
|
||||
}
|
||||
}
|
||||
|
||||
if ((npcInst != null) && spawnInst.isBroadcasting())
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers("The " + npcInst.getName() + " has spawned near " + MapRegionManager.getInstance().getClosestTownName(npcInst) + "!");
|
||||
}
|
||||
|
||||
// If there is no despawn time, do not create a despawn task.
|
||||
if (spawnInst.getDespawnDelay() > 0)
|
||||
{
|
||||
ThreadPoolManager.getInstance().scheduleAi(new AutoDespawner(_objectId), spawnInst.getDespawnDelay() - 1000);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "AutoSpawnHandler: An error occurred while initializing spawn instance (Object ID = " + _objectId + "): " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AutoDespawner Class<br>
|
||||
* Simply used as a secondary class for despawning an auto spawn instance.
|
||||
* @author Tempy
|
||||
*/
|
||||
private class AutoDespawner implements Runnable
|
||||
{
|
||||
private final int _objectId;
|
||||
|
||||
protected AutoDespawner(int objectId)
|
||||
{
|
||||
_objectId = objectId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
final AutoSpawnInstance spawnInst = _registeredSpawns.get(_objectId);
|
||||
|
||||
if (spawnInst == null)
|
||||
{
|
||||
_log.info("AutoSpawnHandler: No spawn registered for object ID = " + _objectId + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
for (L2Npc npcInst : spawnInst.getNPCInstanceList())
|
||||
{
|
||||
if (npcInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
npcInst.deleteMe();
|
||||
SpawnTable.getInstance().deleteSpawn(npcInst.getSpawn(), false);
|
||||
spawnInst.removeNpcInstance(npcInst);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "AutoSpawnHandler: An error occurred while despawning spawn (Object ID = " + _objectId + "): " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AutoSpawnInstance Class<br>
|
||||
* Stores information about a registered auto spawn.
|
||||
* @author Tempy
|
||||
*/
|
||||
public static class AutoSpawnInstance implements IIdentifiable
|
||||
{
|
||||
protected int _objectId;
|
||||
|
||||
protected int _spawnIndex;
|
||||
|
||||
protected int _npcId;
|
||||
|
||||
protected int _initDelay;
|
||||
|
||||
protected int _resDelay;
|
||||
|
||||
protected int _desDelay;
|
||||
|
||||
protected int _spawnCount = 1;
|
||||
|
||||
protected int _lastLocIndex = -1;
|
||||
|
||||
private final List<L2Npc> _npcList = new CopyOnWriteArrayList<>();
|
||||
|
||||
private final List<Location> _locList = new CopyOnWriteArrayList<>();
|
||||
|
||||
private boolean _spawnActive;
|
||||
|
||||
private boolean _randomSpawn = false;
|
||||
|
||||
private boolean _broadcastAnnouncement = false;
|
||||
|
||||
protected AutoSpawnInstance(int npcId, int initDelay, int respawnDelay, int despawnDelay)
|
||||
{
|
||||
_npcId = npcId;
|
||||
_initDelay = initDelay;
|
||||
_resDelay = respawnDelay;
|
||||
_desDelay = despawnDelay;
|
||||
}
|
||||
|
||||
protected void setSpawnActive(boolean activeValue)
|
||||
{
|
||||
_spawnActive = activeValue;
|
||||
}
|
||||
|
||||
protected boolean addNpcInstance(L2Npc npcInst)
|
||||
{
|
||||
return _npcList.add(npcInst);
|
||||
}
|
||||
|
||||
protected boolean removeNpcInstance(L2Npc npcInst)
|
||||
{
|
||||
return _npcList.remove(npcInst);
|
||||
}
|
||||
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public int getInitialDelay()
|
||||
{
|
||||
return _initDelay;
|
||||
}
|
||||
|
||||
public int getRespawnDelay()
|
||||
{
|
||||
return _resDelay;
|
||||
}
|
||||
|
||||
public int getDespawnDelay()
|
||||
{
|
||||
return _desDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the NPC ID.
|
||||
* @return the NPC ID
|
||||
*/
|
||||
@Override
|
||||
public int getId()
|
||||
{
|
||||
return _npcId;
|
||||
}
|
||||
|
||||
public int getSpawnCount()
|
||||
{
|
||||
return _spawnCount;
|
||||
}
|
||||
|
||||
public Location[] getLocationList()
|
||||
{
|
||||
return _locList.toArray(new Location[_locList.size()]);
|
||||
}
|
||||
|
||||
public List<L2Npc> getNPCInstanceList()
|
||||
{
|
||||
return _npcList;
|
||||
}
|
||||
|
||||
public List<L2Spawn> getSpawns()
|
||||
{
|
||||
final List<L2Spawn> npcSpawns = new ArrayList<>();
|
||||
for (L2Npc npcInst : _npcList)
|
||||
{
|
||||
npcSpawns.add(npcInst.getSpawn());
|
||||
}
|
||||
return npcSpawns;
|
||||
}
|
||||
|
||||
public void setSpawnCount(int spawnCount)
|
||||
{
|
||||
_spawnCount = spawnCount;
|
||||
}
|
||||
|
||||
public void setRandomSpawn(boolean randValue)
|
||||
{
|
||||
_randomSpawn = randValue;
|
||||
}
|
||||
|
||||
public void setBroadcast(boolean broadcastValue)
|
||||
{
|
||||
_broadcastAnnouncement = broadcastValue;
|
||||
}
|
||||
|
||||
public boolean isSpawnActive()
|
||||
{
|
||||
return _spawnActive;
|
||||
}
|
||||
|
||||
public boolean isRandomSpawn()
|
||||
{
|
||||
return _randomSpawn;
|
||||
}
|
||||
|
||||
public boolean isBroadcasting()
|
||||
{
|
||||
return _broadcastAnnouncement;
|
||||
}
|
||||
|
||||
public boolean addSpawnLocation(int x, int y, int z, int heading)
|
||||
{
|
||||
return _locList.add(new Location(x, y, z, heading));
|
||||
}
|
||||
|
||||
public boolean addSpawnLocation(int[] spawnLoc)
|
||||
{
|
||||
return (spawnLoc.length == 3) && addSpawnLocation(spawnLoc[0], spawnLoc[1], spawnLoc[2], -1);
|
||||
}
|
||||
|
||||
public Location removeSpawnLocation(int locIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _locList.remove(locIndex);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final AutoSpawnHandler _instance = new AutoSpawnHandler();
|
||||
}
|
||||
}
|
||||
@@ -1,305 +1,272 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.friend.BlockListPacket;
|
||||
|
||||
public class BlockList
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(BlockList.class.getName());
|
||||
private static Map<Integer, HashMap<Integer, String>> OFFLINE_LIST = new HashMap<>();
|
||||
|
||||
private final L2PcInstance _owner;
|
||||
private HashMap<Integer, String> _blockList;
|
||||
private final ArrayList<Integer> _updateMemos = new ArrayList<>();
|
||||
|
||||
public BlockList(L2PcInstance owner)
|
||||
{
|
||||
_owner = owner;
|
||||
_blockList = OFFLINE_LIST.get(owner.getObjectId());
|
||||
if (_blockList == null)
|
||||
{
|
||||
_blockList = loadList(_owner.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
private void addToBlockList(int target)
|
||||
{
|
||||
_blockList.put(target, "");
|
||||
persistInDB(target);
|
||||
}
|
||||
|
||||
private void removeFromBlockList(int target)
|
||||
{
|
||||
_blockList.remove(Integer.valueOf(target));
|
||||
if (_updateMemos.contains(target))
|
||||
{
|
||||
_updateMemos.remove(Integer.valueOf(target));
|
||||
}
|
||||
removeFromDB(target);
|
||||
}
|
||||
|
||||
public void setBlockMemo(int target, String memo)
|
||||
{
|
||||
if (_blockList.containsKey(target))
|
||||
{
|
||||
_blockList.put(target, memo);
|
||||
_updateMemos.add(target);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBlockMemos()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
for (int target : _updateMemos)
|
||||
{
|
||||
try (PreparedStatement ps = con.prepareStatement("UPDATE character_friends SET memo=? WHERE charId=? AND friendId=? AND relation=1"))
|
||||
{
|
||||
ps.setString(1, _blockList.get(target));
|
||||
ps.setInt(2, _owner.getObjectId());
|
||||
ps.setInt(3, target);
|
||||
ps.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
_blockList.clear();
|
||||
}
|
||||
|
||||
public void playerLogout()
|
||||
{
|
||||
OFFLINE_LIST.put(_owner.getObjectId(), _blockList);
|
||||
}
|
||||
|
||||
private static HashMap<Integer, String> loadList(int ObjId)
|
||||
{
|
||||
final HashMap<Integer, String> list = new HashMap<>();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT friendId, memo FROM character_friends WHERE charId=? AND relation=1"))
|
||||
{
|
||||
ps.setInt(1, ObjId);
|
||||
try (ResultSet rs = ps.executeQuery())
|
||||
{
|
||||
int friendId;
|
||||
while (rs.next())
|
||||
{
|
||||
friendId = rs.getInt("friendId");
|
||||
if (friendId == ObjId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list.put(friendId, rs.getString("memo"));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Error found in " + ObjId + " FriendList while loading BlockList: " + e.getMessage(), e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private void removeFromDB(int targetId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM character_friends WHERE charId=? AND friendId=? AND relation=1"))
|
||||
{
|
||||
ps.setInt(1, _owner.getObjectId());
|
||||
ps.setInt(2, targetId);
|
||||
ps.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Could not remove blocked player: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void persistInDB(int targetId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO character_friends (charId, friendId, relation) VALUES (?, ?, 1)"))
|
||||
{
|
||||
ps.setInt(1, _owner.getObjectId());
|
||||
ps.setInt(2, targetId);
|
||||
ps.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Could not add blocked player: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInBlockList(L2PcInstance target)
|
||||
{
|
||||
return _blockList.containsKey(target.getObjectId());
|
||||
}
|
||||
|
||||
public boolean isInBlockList(int targetId)
|
||||
{
|
||||
return _blockList.containsKey(targetId);
|
||||
}
|
||||
|
||||
public boolean isBlockAll()
|
||||
{
|
||||
return _owner.getMessageRefusal();
|
||||
}
|
||||
|
||||
public static boolean isBlocked(L2PcInstance listOwner, L2PcInstance target)
|
||||
{
|
||||
final BlockList blockList = listOwner.getBlockList();
|
||||
return blockList.isBlockAll() || blockList.isInBlockList(target);
|
||||
}
|
||||
|
||||
public static boolean isBlocked(L2PcInstance listOwner, int targetId)
|
||||
{
|
||||
final BlockList blockList = listOwner.getBlockList();
|
||||
return blockList.isBlockAll() || blockList.isInBlockList(targetId);
|
||||
}
|
||||
|
||||
private void setBlockAll(boolean state)
|
||||
{
|
||||
_owner.setMessageRefusal(state);
|
||||
}
|
||||
|
||||
public HashMap<Integer, String> getBlockList()
|
||||
{
|
||||
return _blockList;
|
||||
}
|
||||
|
||||
public static void addToBlockList(L2PcInstance listOwner, int targetId)
|
||||
{
|
||||
if (listOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final String charName = CharNameTable.getInstance().getNameById(targetId);
|
||||
|
||||
if (listOwner.getFriendList().containsKey(targetId))
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THIS_PLAYER_IS_ALREADY_REGISTERED_ON_YOUR_FRIENDS_LIST);
|
||||
sm.addString(charName);
|
||||
listOwner.sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
|
||||
if (listOwner.getBlockList().getBlockList().containsKey(targetId))
|
||||
{
|
||||
listOwner.sendMessage("Already in ignore list.");
|
||||
return;
|
||||
}
|
||||
|
||||
listOwner.getBlockList().addToBlockList(targetId);
|
||||
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_ADDED_TO_YOUR_IGNORE_LIST);
|
||||
sm.addString(charName);
|
||||
listOwner.sendPacket(sm);
|
||||
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(targetId);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_PLACED_YOU_ON_HIS_HER_IGNORE_LIST);
|
||||
sm.addString(listOwner.getName());
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeFromBlockList(L2PcInstance listOwner, int targetId)
|
||||
{
|
||||
if (listOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SystemMessage sm;
|
||||
|
||||
final String charName = CharNameTable.getInstance().getNameById(targetId);
|
||||
|
||||
if (!listOwner.getBlockList().getBlockList().containsKey(targetId))
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
listOwner.sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
|
||||
listOwner.getBlockList().removeFromBlockList(targetId);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_REMOVED_FROM_YOUR_IGNORE_LIST);
|
||||
sm.addString(charName);
|
||||
listOwner.sendPacket(sm);
|
||||
}
|
||||
|
||||
public static boolean isInBlockList(L2PcInstance listOwner, L2PcInstance target)
|
||||
{
|
||||
return listOwner.getBlockList().isInBlockList(target);
|
||||
}
|
||||
|
||||
public boolean isBlockAll(L2PcInstance listOwner)
|
||||
{
|
||||
return listOwner.getBlockList().isBlockAll();
|
||||
}
|
||||
|
||||
public static void setBlockAll(L2PcInstance listOwner, boolean newValue)
|
||||
{
|
||||
listOwner.getBlockList().setBlockAll(newValue);
|
||||
}
|
||||
|
||||
public static void sendListToOwner(L2PcInstance listOwner)
|
||||
{
|
||||
listOwner.sendPacket(new BlockListPacket(listOwner));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ownerId object id of owner block list
|
||||
* @param targetId object id of potential blocked player
|
||||
* @return true if blocked
|
||||
*/
|
||||
public static boolean isInBlockList(int ownerId, int targetId)
|
||||
{
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(ownerId);
|
||||
if (player != null)
|
||||
{
|
||||
return BlockList.isBlocked(player, targetId);
|
||||
}
|
||||
if (!OFFLINE_LIST.containsKey(ownerId))
|
||||
{
|
||||
OFFLINE_LIST.put(ownerId, loadList(ownerId));
|
||||
}
|
||||
return OFFLINE_LIST.get(ownerId).containsKey(targetId);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.BlockListPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
|
||||
*/
|
||||
public class BlockList
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(BlockList.class.getName());
|
||||
private static Map<Integer, List<Integer>> _offlineList = new ConcurrentHashMap<>();
|
||||
|
||||
private final L2PcInstance _owner;
|
||||
private List<Integer> _blockList;
|
||||
|
||||
public BlockList(L2PcInstance owner)
|
||||
{
|
||||
_owner = owner;
|
||||
_blockList = _offlineList.get(owner.getObjectId());
|
||||
if (_blockList == null)
|
||||
{
|
||||
_blockList = loadList(_owner.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
private void addToBlockList(int target)
|
||||
{
|
||||
_blockList.add(target);
|
||||
updateInDB(target, true);
|
||||
}
|
||||
|
||||
private void removeFromBlockList(int target)
|
||||
{
|
||||
_blockList.remove(Integer.valueOf(target));
|
||||
updateInDB(target, false);
|
||||
}
|
||||
|
||||
public void playerLogout()
|
||||
{
|
||||
_offlineList.put(_owner.getObjectId(), _blockList);
|
||||
}
|
||||
|
||||
private static List<Integer> loadList(int ObjId)
|
||||
{
|
||||
final List<Integer> list = new ArrayList<>();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1"))
|
||||
{
|
||||
statement.setInt(1, ObjId);
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
int friendId;
|
||||
while (rset.next())
|
||||
{
|
||||
friendId = rset.getInt("friendId");
|
||||
if (friendId == ObjId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list.add(friendId);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Error found in " + ObjId + " FriendList while loading BlockList: " + e.getMessage(), e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private void updateInDB(int targetId, boolean state)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
if (state) // add
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement("INSERT INTO character_friends (charId, friendId, relation) VALUES (?, ?, 1)"))
|
||||
{
|
||||
statement.setInt(1, _owner.getObjectId());
|
||||
statement.setInt(2, targetId);
|
||||
statement.execute();
|
||||
}
|
||||
}
|
||||
else
|
||||
// remove
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement("DELETE FROM character_friends WHERE charId=? AND friendId=? AND relation=1"))
|
||||
{
|
||||
statement.setInt(1, _owner.getObjectId());
|
||||
statement.setInt(2, targetId);
|
||||
statement.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Could not add block player: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInBlockList(L2PcInstance target)
|
||||
{
|
||||
return _blockList.contains(target.getObjectId());
|
||||
}
|
||||
|
||||
public boolean isInBlockList(int targetId)
|
||||
{
|
||||
return _blockList.contains(targetId);
|
||||
}
|
||||
|
||||
public boolean isBlockAll()
|
||||
{
|
||||
return _owner.getMessageRefusal();
|
||||
}
|
||||
|
||||
public static boolean isBlocked(L2PcInstance listOwner, L2PcInstance target)
|
||||
{
|
||||
final BlockList blockList = listOwner.getBlockList();
|
||||
return blockList.isBlockAll() || blockList.isInBlockList(target);
|
||||
}
|
||||
|
||||
public static boolean isBlocked(L2PcInstance listOwner, int targetId)
|
||||
{
|
||||
final BlockList blockList = listOwner.getBlockList();
|
||||
return blockList.isBlockAll() || blockList.isInBlockList(targetId);
|
||||
}
|
||||
|
||||
private void setBlockAll(boolean state)
|
||||
{
|
||||
_owner.setMessageRefusal(state);
|
||||
}
|
||||
|
||||
private List<Integer> getBlockList()
|
||||
{
|
||||
return _blockList;
|
||||
}
|
||||
|
||||
public static void addToBlockList(L2PcInstance listOwner, int targetId)
|
||||
{
|
||||
if (listOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final String charName = CharNameTable.getInstance().getNameById(targetId);
|
||||
|
||||
if (listOwner.getFriendList().contains(targetId))
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THIS_PLAYER_IS_ALREADY_REGISTERED_ON_YOUR_FRIENDS_LIST);
|
||||
sm.addString(charName);
|
||||
listOwner.sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
|
||||
if (listOwner.getBlockList().getBlockList().contains(targetId))
|
||||
{
|
||||
listOwner.sendMessage("Already in ignore list.");
|
||||
return;
|
||||
}
|
||||
|
||||
listOwner.getBlockList().addToBlockList(targetId);
|
||||
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_ADDED_TO_YOUR_IGNORE_LIST);
|
||||
sm.addString(charName);
|
||||
listOwner.sendPacket(sm);
|
||||
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(targetId);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_PLACED_YOU_ON_HIS_HER_IGNORE_LIST);
|
||||
sm.addString(listOwner.getName());
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeFromBlockList(L2PcInstance listOwner, int targetId)
|
||||
{
|
||||
if (listOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SystemMessage sm;
|
||||
|
||||
final String charName = CharNameTable.getInstance().getNameById(targetId);
|
||||
|
||||
if (!listOwner.getBlockList().getBlockList().contains(targetId))
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
listOwner.sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
|
||||
listOwner.getBlockList().removeFromBlockList(targetId);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_REMOVED_FROM_YOUR_IGNORE_LIST);
|
||||
sm.addString(charName);
|
||||
listOwner.sendPacket(sm);
|
||||
}
|
||||
|
||||
public static boolean isInBlockList(L2PcInstance listOwner, L2PcInstance target)
|
||||
{
|
||||
return listOwner.getBlockList().isInBlockList(target);
|
||||
}
|
||||
|
||||
public boolean isBlockAll(L2PcInstance listOwner)
|
||||
{
|
||||
return listOwner.getBlockList().isBlockAll();
|
||||
}
|
||||
|
||||
public static void setBlockAll(L2PcInstance listOwner, boolean newValue)
|
||||
{
|
||||
listOwner.getBlockList().setBlockAll(newValue);
|
||||
}
|
||||
|
||||
public static void sendListToOwner(L2PcInstance listOwner)
|
||||
{
|
||||
listOwner.sendPacket(new BlockListPacket(listOwner.getBlockList().getBlockList()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ownerId object id of owner block list
|
||||
* @param targetId object id of potential blocked player
|
||||
* @return true if blocked
|
||||
*/
|
||||
public static boolean isInBlockList(int ownerId, int targetId)
|
||||
{
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(ownerId);
|
||||
if (player != null)
|
||||
{
|
||||
return BlockList.isBlocked(player, targetId);
|
||||
}
|
||||
if (!_offlineList.containsKey(ownerId))
|
||||
{
|
||||
_offlineList.put(ownerId, loadList(ownerId));
|
||||
}
|
||||
return _offlineList.get(ownerId).contains(targetId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class ChanceLocation extends Location
|
||||
{
|
||||
private final double _chance;
|
||||
|
||||
public ChanceLocation(int x, int y, int z, int heading, double chance)
|
||||
{
|
||||
super(x, y, z, heading);
|
||||
_chance = chance;
|
||||
}
|
||||
|
||||
public double getChance()
|
||||
{
|
||||
return _chance;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,475 +1,438 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.entity.Hero;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
|
||||
import com.l2jmobius.gameserver.model.variables.PlayerVariables;
|
||||
|
||||
/**
|
||||
* Used to Store data sent to Client for Character.<br>
|
||||
* Selection screen.
|
||||
* @version $Revision: 1.2.2.2.2.4 $ $Date: 2005/03/27 15:29:33 $
|
||||
*/
|
||||
public class CharSelectInfoPackage
|
||||
{
|
||||
private String _name;
|
||||
private int _objectId = 0;
|
||||
private long _exp = 0;
|
||||
private long _sp = 0;
|
||||
private int _clanId = 0;
|
||||
private int _race = 0;
|
||||
private int _classId = 0;
|
||||
private int _baseClassId = 0;
|
||||
private long _deleteTimer = 0L;
|
||||
private long _lastAccess = 0L;
|
||||
private int _face = 0;
|
||||
private int _hairStyle = 0;
|
||||
private int _hairColor = 0;
|
||||
private int _sex = 0;
|
||||
private int _level = 1;
|
||||
private int _maxHp = 0;
|
||||
private double _currentHp = 0;
|
||||
private int _maxMp = 0;
|
||||
private double _currentMp = 0;
|
||||
private final int[][] _paperdoll;
|
||||
private int _reputation = 0;
|
||||
private int _pkKills = 0;
|
||||
private int _pvpKills = 0;
|
||||
private int _augmentationId = 0;
|
||||
private int _x = 0;
|
||||
private int _y = 0;
|
||||
private int _z = 0;
|
||||
private String _htmlPrefix = null;
|
||||
private int _vitalityPoints = 0;
|
||||
private int _accessLevel = 0;
|
||||
private boolean _isGood = false;
|
||||
private boolean _isEvil = false;
|
||||
private final PlayerVariables _vars;
|
||||
|
||||
/**
|
||||
* Constructor for CharSelectInfoPackage.
|
||||
* @param objectId character object Id.
|
||||
* @param name the character's name.
|
||||
*/
|
||||
public CharSelectInfoPackage(int objectId, String name)
|
||||
{
|
||||
setObjectId(objectId);
|
||||
_name = name;
|
||||
_paperdoll = PcInventory.restoreVisibleInventory(objectId);
|
||||
_vars = new PlayerVariables(_objectId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the character object Id.
|
||||
*/
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public void setObjectId(int objectId)
|
||||
{
|
||||
_objectId = objectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the character's access level.
|
||||
*/
|
||||
public int getAccessLevel()
|
||||
{
|
||||
return _accessLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param level the character's access level to be set.
|
||||
*/
|
||||
public void setAccessLevel(int level)
|
||||
{
|
||||
_accessLevel = level;
|
||||
}
|
||||
|
||||
public boolean isGood()
|
||||
{
|
||||
return _isGood;
|
||||
}
|
||||
|
||||
public void setGood()
|
||||
{
|
||||
_isGood = true;
|
||||
_isEvil = false;
|
||||
}
|
||||
|
||||
public boolean isEvil()
|
||||
{
|
||||
return _isEvil;
|
||||
}
|
||||
|
||||
public void setEvil()
|
||||
{
|
||||
_isGood = false;
|
||||
_isEvil = true;
|
||||
}
|
||||
|
||||
public int getClanId()
|
||||
{
|
||||
return _clanId;
|
||||
}
|
||||
|
||||
public void setClanId(int clanId)
|
||||
{
|
||||
_clanId = clanId;
|
||||
}
|
||||
|
||||
public int getClassId()
|
||||
{
|
||||
return _classId;
|
||||
}
|
||||
|
||||
public int getBaseClassId()
|
||||
{
|
||||
return _baseClassId;
|
||||
}
|
||||
|
||||
public void setClassId(int classId)
|
||||
{
|
||||
_classId = classId;
|
||||
}
|
||||
|
||||
public void setBaseClassId(int baseClassId)
|
||||
{
|
||||
_baseClassId = baseClassId;
|
||||
}
|
||||
|
||||
public double getCurrentHp()
|
||||
{
|
||||
return _currentHp;
|
||||
}
|
||||
|
||||
public void setCurrentHp(double currentHp)
|
||||
{
|
||||
_currentHp = currentHp;
|
||||
}
|
||||
|
||||
public double getCurrentMp()
|
||||
{
|
||||
return _currentMp;
|
||||
}
|
||||
|
||||
public void setCurrentMp(double currentMp)
|
||||
{
|
||||
_currentMp = currentMp;
|
||||
}
|
||||
|
||||
public long getDeleteTimer()
|
||||
{
|
||||
return _deleteTimer;
|
||||
}
|
||||
|
||||
public void setDeleteTimer(long deleteTimer)
|
||||
{
|
||||
_deleteTimer = deleteTimer;
|
||||
}
|
||||
|
||||
public long getLastAccess()
|
||||
{
|
||||
return _lastAccess;
|
||||
}
|
||||
|
||||
public void setLastAccess(long lastAccess)
|
||||
{
|
||||
_lastAccess = lastAccess;
|
||||
}
|
||||
|
||||
public long getExp()
|
||||
{
|
||||
return _exp;
|
||||
}
|
||||
|
||||
public void setExp(long exp)
|
||||
{
|
||||
_exp = exp;
|
||||
}
|
||||
|
||||
public int getFace()
|
||||
{
|
||||
return _vars.getInt("visualFaceId", _face);
|
||||
}
|
||||
|
||||
public void setFace(int face)
|
||||
{
|
||||
_face = face;
|
||||
}
|
||||
|
||||
public int getHairColor()
|
||||
{
|
||||
return _vars.getInt("visualHairColorId", _hairColor);
|
||||
}
|
||||
|
||||
public void setHairColor(int hairColor)
|
||||
{
|
||||
_hairColor = hairColor;
|
||||
}
|
||||
|
||||
public int getHairStyle()
|
||||
{
|
||||
return _vars.getInt("visualHairId", _hairStyle);
|
||||
}
|
||||
|
||||
public void setHairStyle(int hairStyle)
|
||||
{
|
||||
_hairStyle = hairStyle;
|
||||
}
|
||||
|
||||
public int getPaperdollObjectId(int slot)
|
||||
{
|
||||
return _paperdoll[slot][0];
|
||||
}
|
||||
|
||||
public int getPaperdollItemId(int slot)
|
||||
{
|
||||
return _paperdoll[slot][1];
|
||||
}
|
||||
|
||||
public int getPaperdollItemVisualId(int slot)
|
||||
{
|
||||
return _paperdoll[slot][3];
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
public void setLevel(int level)
|
||||
{
|
||||
_level = level;
|
||||
}
|
||||
|
||||
public int getMaxHp()
|
||||
{
|
||||
return _maxHp;
|
||||
}
|
||||
|
||||
public void setMaxHp(int maxHp)
|
||||
{
|
||||
_maxHp = maxHp;
|
||||
}
|
||||
|
||||
public int getMaxMp()
|
||||
{
|
||||
return _maxMp;
|
||||
}
|
||||
|
||||
public void setMaxMp(int maxMp)
|
||||
{
|
||||
_maxMp = maxMp;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
public int getRace()
|
||||
{
|
||||
return _race;
|
||||
}
|
||||
|
||||
public void setRace(int race)
|
||||
{
|
||||
_race = race;
|
||||
}
|
||||
|
||||
public int getSex()
|
||||
{
|
||||
return _sex;
|
||||
}
|
||||
|
||||
public void setSex(int sex)
|
||||
{
|
||||
_sex = sex;
|
||||
}
|
||||
|
||||
public long getSp()
|
||||
{
|
||||
return _sp;
|
||||
}
|
||||
|
||||
public void setSp(long sp)
|
||||
{
|
||||
_sp = sp;
|
||||
}
|
||||
|
||||
public int getWeaponEnchantEffect()
|
||||
{
|
||||
return getEnchantEffect(Inventory.PAPERDOLL_RHAND);
|
||||
}
|
||||
|
||||
public int getEnchantEffect(int slot)
|
||||
{
|
||||
return _paperdoll[slot][2];
|
||||
}
|
||||
|
||||
public void setReputation(int reputation)
|
||||
{
|
||||
_reputation = reputation;
|
||||
}
|
||||
|
||||
public int getReputation()
|
||||
{
|
||||
return _reputation;
|
||||
}
|
||||
|
||||
public void setAugmentationId(int augmentationId)
|
||||
{
|
||||
_augmentationId = augmentationId;
|
||||
}
|
||||
|
||||
public int getAugmentationId()
|
||||
{
|
||||
return _augmentationId;
|
||||
}
|
||||
|
||||
public void setPkKills(int PkKills)
|
||||
{
|
||||
_pkKills = PkKills;
|
||||
}
|
||||
|
||||
public int getPkKills()
|
||||
{
|
||||
return _pkKills;
|
||||
}
|
||||
|
||||
public void setPvPKills(int PvPKills)
|
||||
{
|
||||
_pvpKills = PvPKills;
|
||||
}
|
||||
|
||||
public int getPvPKills()
|
||||
{
|
||||
return _pvpKills;
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return _x;
|
||||
}
|
||||
|
||||
public int getY()
|
||||
{
|
||||
return _y;
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return _z;
|
||||
}
|
||||
|
||||
public void setX(int x)
|
||||
{
|
||||
_x = x;
|
||||
}
|
||||
|
||||
public void setY(int y)
|
||||
{
|
||||
_y = y;
|
||||
}
|
||||
|
||||
public void setZ(int z)
|
||||
{
|
||||
_z = z;
|
||||
}
|
||||
|
||||
public String getHtmlPrefix()
|
||||
{
|
||||
return _htmlPrefix;
|
||||
}
|
||||
|
||||
public void setHtmlPrefix(String s)
|
||||
{
|
||||
_htmlPrefix = s;
|
||||
}
|
||||
|
||||
public void setVitalityPoints(int points)
|
||||
{
|
||||
_vitalityPoints = points;
|
||||
}
|
||||
|
||||
public int getVitalityPoints()
|
||||
{
|
||||
return _vitalityPoints;
|
||||
}
|
||||
|
||||
public boolean isHairAccessoryEnabled()
|
||||
{
|
||||
return _vars.getBoolean("hairAccessoryEnabled", true);
|
||||
}
|
||||
|
||||
public int getTransformationId()
|
||||
{
|
||||
final int weaponId = getPaperdollItemId(Inventory.PAPERDOLL_RHAND);
|
||||
switch (weaponId)
|
||||
{
|
||||
case 8190:
|
||||
{
|
||||
return 301;
|
||||
}
|
||||
case 8689:
|
||||
{
|
||||
return 302;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getVitalityPercent()
|
||||
{
|
||||
return 200; // TODO: Implement.
|
||||
}
|
||||
|
||||
public int getVitalityItemCount()
|
||||
{
|
||||
return 5; // TODO: Implement.
|
||||
}
|
||||
|
||||
public boolean isAvailable()
|
||||
{
|
||||
return getAccessLevel() > -100;
|
||||
}
|
||||
|
||||
public boolean isHero()
|
||||
{
|
||||
return Hero.getInstance().isHero(getObjectId());
|
||||
}
|
||||
|
||||
public int get1stAugmentationId()
|
||||
{
|
||||
return 0x0000FFFF & getAugmentationId();
|
||||
}
|
||||
|
||||
public int get2ndAugmentationId()
|
||||
{
|
||||
return getAugmentationId() >> 16;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
|
||||
import com.l2jmobius.gameserver.model.variables.PlayerVariables;
|
||||
|
||||
/**
|
||||
* Used to Store data sent to Client for Character.<br>
|
||||
* Selection screen.
|
||||
* @version $Revision: 1.2.2.2.2.4 $ $Date: 2005/03/27 15:29:33 $
|
||||
*/
|
||||
public class CharSelectInfoPackage
|
||||
{
|
||||
private String _name;
|
||||
private int _objectId = 0;
|
||||
private long _exp = 0;
|
||||
private long _sp = 0;
|
||||
private int _clanId = 0;
|
||||
private int _race = 0;
|
||||
private int _classId = 0;
|
||||
private int _baseClassId = 0;
|
||||
private long _deleteTimer = 0L;
|
||||
private long _lastAccess = 0L;
|
||||
private int _face = 0;
|
||||
private int _hairStyle = 0;
|
||||
private int _hairColor = 0;
|
||||
private int _sex = 0;
|
||||
private int _level = 1;
|
||||
private int _maxHp = 0;
|
||||
private double _currentHp = 0;
|
||||
private int _maxMp = 0;
|
||||
private double _currentMp = 0;
|
||||
private final int[][] _paperdoll;
|
||||
private int _reputation = 0;
|
||||
private int _pkKills = 0;
|
||||
private int _pvpKills = 0;
|
||||
private int _augmentationId = 0;
|
||||
private int _x = 0;
|
||||
private int _y = 0;
|
||||
private int _z = 0;
|
||||
private String _htmlPrefix = null;
|
||||
private boolean _isGood = false;
|
||||
private boolean _isEvil = false;
|
||||
private int _vitalityPoints = 0;
|
||||
private int _accessLevel = 0;
|
||||
private boolean _isNoble;
|
||||
private final PlayerVariables _vars;
|
||||
|
||||
/**
|
||||
* Constructor for CharSelectInfoPackage.
|
||||
* @param objectId character object Id.
|
||||
* @param name the character's name.
|
||||
*/
|
||||
public CharSelectInfoPackage(int objectId, String name)
|
||||
{
|
||||
setObjectId(objectId);
|
||||
_name = name;
|
||||
_paperdoll = PcInventory.restoreVisibleInventory(objectId);
|
||||
_vars = new PlayerVariables(_objectId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the character object Id.
|
||||
*/
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public void setObjectId(int objectId)
|
||||
{
|
||||
_objectId = objectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the character's access level.
|
||||
*/
|
||||
public int getAccessLevel()
|
||||
{
|
||||
return _accessLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param level the character's access level to be set.
|
||||
*/
|
||||
public void setAccessLevel(int level)
|
||||
{
|
||||
_accessLevel = level;
|
||||
}
|
||||
|
||||
public boolean isGood()
|
||||
{
|
||||
return _isGood;
|
||||
}
|
||||
|
||||
public void setGood()
|
||||
{
|
||||
_isGood = true;
|
||||
_isEvil = false;
|
||||
}
|
||||
|
||||
public boolean isEvil()
|
||||
{
|
||||
return _isEvil;
|
||||
}
|
||||
|
||||
public void setEvil()
|
||||
{
|
||||
_isGood = false;
|
||||
_isEvil = true;
|
||||
}
|
||||
|
||||
public int getClanId()
|
||||
{
|
||||
return _clanId;
|
||||
}
|
||||
|
||||
public void setClanId(int clanId)
|
||||
{
|
||||
_clanId = clanId;
|
||||
}
|
||||
|
||||
public int getClassId()
|
||||
{
|
||||
return _classId;
|
||||
}
|
||||
|
||||
public int getBaseClassId()
|
||||
{
|
||||
return _baseClassId;
|
||||
}
|
||||
|
||||
public void setClassId(int classId)
|
||||
{
|
||||
_classId = classId;
|
||||
}
|
||||
|
||||
public void setBaseClassId(int baseClassId)
|
||||
{
|
||||
_baseClassId = baseClassId;
|
||||
}
|
||||
|
||||
public double getCurrentHp()
|
||||
{
|
||||
return _currentHp;
|
||||
}
|
||||
|
||||
public void setCurrentHp(double currentHp)
|
||||
{
|
||||
_currentHp = currentHp;
|
||||
}
|
||||
|
||||
public double getCurrentMp()
|
||||
{
|
||||
return _currentMp;
|
||||
}
|
||||
|
||||
public void setCurrentMp(double currentMp)
|
||||
{
|
||||
_currentMp = currentMp;
|
||||
}
|
||||
|
||||
public long getDeleteTimer()
|
||||
{
|
||||
return _deleteTimer;
|
||||
}
|
||||
|
||||
public void setDeleteTimer(long deleteTimer)
|
||||
{
|
||||
_deleteTimer = deleteTimer;
|
||||
}
|
||||
|
||||
public long getLastAccess()
|
||||
{
|
||||
return _lastAccess;
|
||||
}
|
||||
|
||||
public void setLastAccess(long lastAccess)
|
||||
{
|
||||
_lastAccess = lastAccess;
|
||||
}
|
||||
|
||||
public long getExp()
|
||||
{
|
||||
return _exp;
|
||||
}
|
||||
|
||||
public void setExp(long exp)
|
||||
{
|
||||
_exp = exp;
|
||||
}
|
||||
|
||||
public int getFace()
|
||||
{
|
||||
return _vars.getInt("visualFaceId", _face);
|
||||
}
|
||||
|
||||
public void setFace(int face)
|
||||
{
|
||||
_face = face;
|
||||
}
|
||||
|
||||
public int getHairColor()
|
||||
{
|
||||
return _vars.getInt("visualHairColorId", _hairColor);
|
||||
}
|
||||
|
||||
public void setHairColor(int hairColor)
|
||||
{
|
||||
_hairColor = hairColor;
|
||||
}
|
||||
|
||||
public int getHairStyle()
|
||||
{
|
||||
return _vars.getInt("visualHairId", _hairStyle);
|
||||
}
|
||||
|
||||
public void setHairStyle(int hairStyle)
|
||||
{
|
||||
_hairStyle = hairStyle;
|
||||
}
|
||||
|
||||
public int getPaperdollObjectId(int slot)
|
||||
{
|
||||
return _paperdoll[slot][0];
|
||||
}
|
||||
|
||||
public int getPaperdollItemId(int slot)
|
||||
{
|
||||
return _paperdoll[slot][1];
|
||||
}
|
||||
|
||||
public int getPaperdollItemVisualId(int slot)
|
||||
{
|
||||
return _paperdoll[slot][3];
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
public void setLevel(int level)
|
||||
{
|
||||
_level = level;
|
||||
}
|
||||
|
||||
public int getMaxHp()
|
||||
{
|
||||
return _maxHp;
|
||||
}
|
||||
|
||||
public void setMaxHp(int maxHp)
|
||||
{
|
||||
_maxHp = maxHp;
|
||||
}
|
||||
|
||||
public int getMaxMp()
|
||||
{
|
||||
return _maxMp;
|
||||
}
|
||||
|
||||
public void setMaxMp(int maxMp)
|
||||
{
|
||||
_maxMp = maxMp;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
public int getRace()
|
||||
{
|
||||
return _race;
|
||||
}
|
||||
|
||||
public void setRace(int race)
|
||||
{
|
||||
_race = race;
|
||||
}
|
||||
|
||||
public int getSex()
|
||||
{
|
||||
return _sex;
|
||||
}
|
||||
|
||||
public void setSex(int sex)
|
||||
{
|
||||
_sex = sex;
|
||||
}
|
||||
|
||||
public long getSp()
|
||||
{
|
||||
return _sp;
|
||||
}
|
||||
|
||||
public void setSp(long sp)
|
||||
{
|
||||
_sp = sp;
|
||||
}
|
||||
|
||||
public int getEnchantEffect()
|
||||
{
|
||||
return _paperdoll[Inventory.PAPERDOLL_RHAND][2];
|
||||
}
|
||||
|
||||
public void setReputation(int reputation)
|
||||
{
|
||||
_reputation = reputation;
|
||||
}
|
||||
|
||||
public int getReputation()
|
||||
{
|
||||
return _reputation;
|
||||
}
|
||||
|
||||
public void setAugmentationId(int augmentationId)
|
||||
{
|
||||
_augmentationId = augmentationId;
|
||||
}
|
||||
|
||||
public int getAugmentationId()
|
||||
{
|
||||
return _augmentationId;
|
||||
}
|
||||
|
||||
public void setPkKills(int PkKills)
|
||||
{
|
||||
_pkKills = PkKills;
|
||||
}
|
||||
|
||||
public int getPkKills()
|
||||
{
|
||||
return _pkKills;
|
||||
}
|
||||
|
||||
public void setPvPKills(int PvPKills)
|
||||
{
|
||||
_pvpKills = PvPKills;
|
||||
}
|
||||
|
||||
public int getPvPKills()
|
||||
{
|
||||
return _pvpKills;
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return _x;
|
||||
}
|
||||
|
||||
public int getY()
|
||||
{
|
||||
return _y;
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return _z;
|
||||
}
|
||||
|
||||
public void setX(int x)
|
||||
{
|
||||
_x = x;
|
||||
}
|
||||
|
||||
public void setY(int y)
|
||||
{
|
||||
_y = y;
|
||||
}
|
||||
|
||||
public void setZ(int z)
|
||||
{
|
||||
_z = z;
|
||||
}
|
||||
|
||||
public String getHtmlPrefix()
|
||||
{
|
||||
return _htmlPrefix;
|
||||
}
|
||||
|
||||
public void setHtmlPrefix(String s)
|
||||
{
|
||||
_htmlPrefix = s;
|
||||
}
|
||||
|
||||
public void setVitalityPoints(int points)
|
||||
{
|
||||
_vitalityPoints = points;
|
||||
}
|
||||
|
||||
public int getVitalityPoints()
|
||||
{
|
||||
return _vitalityPoints;
|
||||
}
|
||||
|
||||
public boolean isHairAccessoryEnabled()
|
||||
{
|
||||
return _vars.getBoolean(PlayerVariables.HAIR_ACCESSORY_VARIABLE_NAME, true);
|
||||
}
|
||||
|
||||
public int getVitalityItemsUsed()
|
||||
{
|
||||
return _vars.getInt(PlayerVariables.VITALITY_ITEMS_USED_VARIABLE_NAME, 0);
|
||||
}
|
||||
|
||||
public boolean isNoble()
|
||||
{
|
||||
return _isNoble;
|
||||
}
|
||||
|
||||
public void setNoble(boolean noble)
|
||||
{
|
||||
_isNoble = noble;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class ClanInfo
|
||||
{
|
||||
private final L2Clan _clan;
|
||||
private final int _total;
|
||||
private final int _online;
|
||||
|
||||
public ClanInfo(L2Clan clan)
|
||||
{
|
||||
_clan = clan;
|
||||
_total = clan.getMembersCount();
|
||||
_online = clan.getOnlineMembersCount();
|
||||
}
|
||||
|
||||
public L2Clan getClan()
|
||||
{
|
||||
return _clan;
|
||||
}
|
||||
|
||||
public int getTotal()
|
||||
{
|
||||
return _total;
|
||||
}
|
||||
|
||||
public int getOnline()
|
||||
{
|
||||
return _online;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class ClanInfo
|
||||
{
|
||||
private final L2Clan _clan;
|
||||
private final int _total;
|
||||
private final int _online;
|
||||
|
||||
public ClanInfo(L2Clan clan)
|
||||
{
|
||||
_clan = clan;
|
||||
_total = clan.getMembersCount();
|
||||
_online = clan.getOnlineMembersCount();
|
||||
}
|
||||
|
||||
public L2Clan getClan()
|
||||
{
|
||||
return _clan;
|
||||
}
|
||||
|
||||
public int getTotal()
|
||||
{
|
||||
return _total;
|
||||
}
|
||||
|
||||
public int getOnline()
|
||||
{
|
||||
return _online;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,62 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* This enum is used for clan privileges.<br>
|
||||
* The ordinal of each entry is the bit index in the privilege bitmask.
|
||||
* @author HorridoJoho
|
||||
*/
|
||||
public enum ClanPrivilege
|
||||
{
|
||||
/** dummy entry */
|
||||
DUMMY,
|
||||
/** Privilege to join clan */
|
||||
CL_JOIN_CLAN,
|
||||
/** Privilege to give a title */
|
||||
CL_GIVE_TITLE,
|
||||
/** Privilege to view warehouse content */
|
||||
CL_VIEW_WAREHOUSE,
|
||||
/** Privilege to manage clan ranks */
|
||||
CL_MANAGE_RANKS,
|
||||
CL_PLEDGE_WAR,
|
||||
CL_DISMISS,
|
||||
/** Privilege to register clan crest */
|
||||
CL_REGISTER_CREST,
|
||||
CL_APPRENTICE,
|
||||
CL_TROOPS_FAME,
|
||||
CL_SUMMON_AIRSHIP,
|
||||
/** Privilege to open a door */
|
||||
CH_OPEN_DOOR,
|
||||
CH_OTHER_RIGHTS,
|
||||
CH_AUCTION,
|
||||
CH_DISMISS,
|
||||
CH_SET_FUNCTIONS,
|
||||
CS_OPEN_DOOR,
|
||||
CS_MANOR_ADMIN,
|
||||
CS_MANAGE_SIEGE,
|
||||
CS_USE_FUNCTIONS,
|
||||
CS_DISMISS,
|
||||
CS_TAXES,
|
||||
CS_MERCENARIES,
|
||||
CS_SET_FUNCTIONS;
|
||||
|
||||
public int getBitmask()
|
||||
{
|
||||
return 1 << ordinal();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* This enum is used for clan privileges.<br>
|
||||
* The ordinal of each entry is the bit index in the privilege bitmask.
|
||||
* @author HorridoJoho
|
||||
*/
|
||||
public enum ClanPrivilege
|
||||
{
|
||||
/** dummy entry */
|
||||
DUMMY,
|
||||
/** Privilege to join clan */
|
||||
CL_JOIN_CLAN,
|
||||
/** Privilege to give a title */
|
||||
CL_GIVE_TITLE,
|
||||
/** Privilege to view warehouse content */
|
||||
CL_VIEW_WAREHOUSE,
|
||||
/** Privilege to manage clan ranks */
|
||||
CL_MANAGE_RANKS,
|
||||
CL_PLEDGE_WAR,
|
||||
CL_DISMISS,
|
||||
/** Privilege to register clan crest */
|
||||
CL_REGISTER_CREST,
|
||||
CL_APPRENTICE,
|
||||
CL_TROOPS_FAME,
|
||||
CL_SUMMON_AIRSHIP,
|
||||
/** Privilege to open a door */
|
||||
CH_OPEN_DOOR,
|
||||
CH_OTHER_RIGHTS,
|
||||
CH_AUCTION,
|
||||
CH_DISMISS,
|
||||
CH_SET_FUNCTIONS,
|
||||
CS_OPEN_DOOR,
|
||||
CS_MANOR_ADMIN,
|
||||
CS_MANAGE_SIEGE,
|
||||
CS_USE_FUNCTIONS,
|
||||
CS_DISMISS,
|
||||
CS_TAXES,
|
||||
CS_MERCENARIES,
|
||||
CS_SET_FUNCTIONS;
|
||||
|
||||
public int getBitmask()
|
||||
{
|
||||
return 1 << ordinal();
|
||||
}
|
||||
}
|
||||
|
||||
332
trunk/java/com/l2jmobius/gameserver/model/ClanWar.java
Normal file
332
trunk/java/com/l2jmobius/gameserver/model/ClanWar.java
Normal file
@@ -0,0 +1,332 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.clan.OnClanWarStart;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SurrenderPledgeWar;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public final class ClanWar
|
||||
{
|
||||
public static final long TIME_TO_CANCEL_NON_MUTUAL_CLAN_WAR = TimeUnit.DAYS.toMillis(7);
|
||||
public static final long TIME_TO_DELETION_AFTER_CANCELLATION = TimeUnit.DAYS.toMillis(5);
|
||||
public static final long TIME_TO_DELETION_AFTER_DEFEAT = TimeUnit.DAYS.toMillis(21);
|
||||
private final int _attackerClanId;
|
||||
private final int _attackedClanId;
|
||||
private int _winnerClanId = 0;
|
||||
private ClanWarState _state;
|
||||
private Future<?> _cancelTask;
|
||||
private final long _startTime;
|
||||
private long _endTime = 0;
|
||||
|
||||
private final AtomicInteger _attackerKillCount = new AtomicInteger();
|
||||
private final AtomicInteger _attackedKillCount = new AtomicInteger();
|
||||
|
||||
public ClanWar(L2Clan attacker, L2Clan attacked)
|
||||
{
|
||||
_attackerClanId = attacker.getId();
|
||||
_attackedClanId = attacked.getId();
|
||||
_startTime = System.currentTimeMillis();
|
||||
_state = ClanWarState.BLOOD_DECLARATION;
|
||||
|
||||
_cancelTask = ThreadPoolManager.getInstance().scheduleGeneral(() ->
|
||||
{
|
||||
clanWarTimeout();
|
||||
}, (_startTime + TIME_TO_CANCEL_NON_MUTUAL_CLAN_WAR) - System.currentTimeMillis());
|
||||
|
||||
attacker.addWar(attacked.getId(), this);
|
||||
attacked.addWar(attacker.getId(), this);
|
||||
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnClanWarStart(attacker, attacked));
|
||||
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_DECLARED_A_CLAN_WAR_WITH_S1);
|
||||
sm.addString(attacked.getName());
|
||||
attacker.broadcastToOnlineMembers(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_DECLARED_A_CLAN_WAR_THE_WAR_WILL_AUTOMATICALLY_START_IF_YOU_KILL_S1_CLAN_MEMBERS_5_TIMES_WITHIN_A_WEEK);
|
||||
sm.addString(attacker.getName());
|
||||
attacked.broadcastToOnlineMembers(sm);
|
||||
}
|
||||
|
||||
public ClanWar(L2Clan attacker, L2Clan attacked, int attackerKillCount, int attackedKillCount, int winnerClan, long startTime, long endTime, ClanWarState state)
|
||||
{
|
||||
_attackerClanId = attacker.getId();
|
||||
_attackedClanId = attacked.getId();
|
||||
_startTime = startTime;
|
||||
_endTime = endTime;
|
||||
_state = state;
|
||||
_attackerKillCount.set(attackerKillCount);
|
||||
_attackedKillCount.set(attackedKillCount);
|
||||
_winnerClanId = winnerClan;
|
||||
|
||||
if ((_startTime + TIME_TO_CANCEL_NON_MUTUAL_CLAN_WAR) > System.currentTimeMillis())
|
||||
{
|
||||
_cancelTask = ThreadPoolManager.getInstance().scheduleGeneral(() ->
|
||||
{
|
||||
clanWarTimeout();
|
||||
}, (_startTime + TIME_TO_CANCEL_NON_MUTUAL_CLAN_WAR) - System.currentTimeMillis());
|
||||
}
|
||||
|
||||
if (_endTime > 0)
|
||||
{
|
||||
final long endTimePeriod = _endTime + (_state == ClanWarState.TIE ? TIME_TO_DELETION_AFTER_CANCELLATION : TIME_TO_DELETION_AFTER_DEFEAT);
|
||||
|
||||
if (endTimePeriod > System.currentTimeMillis())
|
||||
{
|
||||
ClanTable.getInstance().deleteclanswars(_attackerClanId, _attackedClanId);
|
||||
}
|
||||
else
|
||||
{
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(() ->
|
||||
{
|
||||
ClanTable.getInstance().deleteclanswars(_attackerClanId, _attackedClanId);
|
||||
}, endTimePeriod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onKill(L2PcInstance killer, L2PcInstance victim)
|
||||
{
|
||||
final L2Clan victimClan = victim.getClan();
|
||||
final L2Clan killerClan = killer.getClan();
|
||||
|
||||
// Reputation increase by killing an enemy (over level 4) in a clan war under the condition of mutual war declaration
|
||||
if ((victim.getLevel() > 4) && (_state == ClanWarState.MUTUAL))
|
||||
{
|
||||
// however, when the other side reputation score is 0 or below, your clan cannot acquire any reputation points from them.
|
||||
if (victimClan.getReputationScore() > 0)
|
||||
{
|
||||
victimClan.takeReputationScore(Config.REPUTATION_SCORE_PER_KILL, false);
|
||||
killerClan.addReputationScore(Config.REPUTATION_SCORE_PER_KILL, false);
|
||||
}
|
||||
|
||||
// System Message notification to clan members
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.BECAUSE_C1_WAS_KILLED_BY_A_CLAN_MEMBER_OF_S2_CLAN_REPUTATION_DECREASED_BY_1);
|
||||
sm.addPcName(victim);
|
||||
sm.addString(killerClan.getName());
|
||||
victimClan.broadcastToOtherOnlineMembers(sm, victim);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.BECAUSE_A_CLAN_MEMBER_OF_S1_WAS_KILLED_BY_C2_CLAN_REPUTATION_INCREASED_BY_1);
|
||||
sm.addString(victimClan.getName());
|
||||
sm.addPcName(killer);
|
||||
killerClan.broadcastToOtherOnlineMembers(sm, killer);
|
||||
|
||||
if (killerClan.getId() == _attackerClanId)
|
||||
{
|
||||
_attackerKillCount.incrementAndGet();
|
||||
}
|
||||
else
|
||||
{
|
||||
_attackedKillCount.incrementAndGet();
|
||||
}
|
||||
}
|
||||
else if ((_state == ClanWarState.BLOOD_DECLARATION) && (victimClan.getId() == _attackerClanId))
|
||||
{
|
||||
final int killCount = _attackedKillCount.incrementAndGet();
|
||||
|
||||
if (killCount >= 5)
|
||||
{
|
||||
_state = ClanWarState.MUTUAL;
|
||||
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.A_CLAN_WAR_WITH_CLAN_S1_HAS_STARTED_THE_CLAN_THAT_CANCELS_THE_WAR_FIRST_WILL_LOSE_5_000_CLAN_REPUTATION_ANY_CLAN_THAT_CANCELS_THE_WAR_WILL_BE_UNABLE_TO_DECLARE_A_WAR_FOR_1_WEEK_IF_YOUR_CLAN_MEMBER_GETS_KILLED_BY_THE_OTHER_CLAN_XP_DECREASES_BY_1_4_OF_THE_AMOUNT_THAT_DECREASES_IN_THE_HUNTING_GROUND);
|
||||
sm.addString(victimClan.getName());
|
||||
killerClan.broadcastToOnlineMembers(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.A_CLAN_WAR_WITH_CLAN_S1_HAS_STARTED_THE_CLAN_THAT_CANCELS_THE_WAR_FIRST_WILL_LOSE_5_000_CLAN_REPUTATION_ANY_CLAN_THAT_CANCELS_THE_WAR_WILL_BE_UNABLE_TO_DECLARE_A_WAR_FOR_1_WEEK_IF_YOUR_CLAN_MEMBER_GETS_KILLED_BY_THE_OTHER_CLAN_XP_DECREASES_BY_1_4_OF_THE_AMOUNT_THAT_DECREASES_IN_THE_HUNTING_GROUND);
|
||||
sm.addString(killerClan.getName());
|
||||
victimClan.broadcastToOnlineMembers(sm);
|
||||
|
||||
if (_cancelTask != null)
|
||||
{
|
||||
_cancelTask.cancel(true);
|
||||
_cancelTask = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.A_CLAN_MEMBER_OF_S1_WAS_KILLED_BY_YOUR_CLAN_MEMBER_IF_YOUR_CLAN_KILLS_S2_MEMBERS_OF_CLAN_S1_A_CLAN_WAR_WITH_CLAN_S1_WILL_START);
|
||||
sm.addString(victimClan.getName());
|
||||
sm.addInt(5 - killCount);
|
||||
killerClan.broadcastToOnlineMembers(sm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel(L2PcInstance player, L2Clan cancelor)
|
||||
{
|
||||
final L2Clan winnerClan = cancelor.getId() == _attackerClanId ? ClanTable.getInstance().getClan(_attackedClanId) : ClanTable.getInstance().getClan(_attackerClanId);
|
||||
|
||||
if (cancelor.getReputationScore() > 5000)
|
||||
{
|
||||
cancelor.takeReputationScore(5000, true);
|
||||
|
||||
player.sendPacket(new SurrenderPledgeWar(cancelor.getName(), player.getName()));
|
||||
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_WAR_ENDED_BY_YOUR_DEFEAT_DECLARATION_WITH_THE_S1_CLAN);
|
||||
sm.addString(winnerClan.getName());
|
||||
cancelor.broadcastToOnlineMembers(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THE_WAR_ENDED_BY_THE_S1_CLAN_S_DEFEAT_DECLARATION_YOU_HAVE_WON_THE_CLAN_WAR_OVER_THE_S1_CLAN);
|
||||
sm.addString(cancelor.getName());
|
||||
winnerClan.broadcastToOnlineMembers(sm);
|
||||
|
||||
_winnerClanId = winnerClan.getId();
|
||||
_endTime = System.currentTimeMillis();
|
||||
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(() ->
|
||||
{
|
||||
ClanTable.getInstance().deleteclanswars(cancelor.getId(), winnerClan.getId());
|
||||
}, (_endTime + TIME_TO_DELETION_AFTER_DEFEAT) - System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
public void clanWarTimeout()
|
||||
{
|
||||
final L2Clan attackerClan = ClanTable.getInstance().getClan(_attackerClanId);
|
||||
final L2Clan attackedClan = ClanTable.getInstance().getClan(_attackedClanId);
|
||||
|
||||
if ((attackerClan != null) && (attackedClan != null))
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.A_CLAN_WAR_DECLARED_BY_CLAN_S1_WAS_CANCELLED);
|
||||
sm.addString(attackerClan.getName());
|
||||
attackedClan.broadcastToOnlineMembers(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.BECAUSE_CLAN_S1_DID_NOT_FIGHT_BACK_FOR_1_WEEK_THE_CLAN_WAR_WAS_CANCELLED);
|
||||
sm.addString(attackedClan.getName());
|
||||
attackerClan.broadcastToOnlineMembers(sm);
|
||||
|
||||
_state = ClanWarState.TIE;
|
||||
_endTime = System.currentTimeMillis();
|
||||
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(() ->
|
||||
{
|
||||
ClanTable.getInstance().deleteclanswars(attackerClan.getId(), attackedClan.getId());
|
||||
}, (_endTime + TIME_TO_DELETION_AFTER_CANCELLATION) - System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
public void mutualClanWarAccepted(L2Clan attacker, L2Clan attacked)
|
||||
{
|
||||
_state = ClanWarState.MUTUAL;
|
||||
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.A_CLAN_WAR_WITH_CLAN_S1_HAS_STARTED_THE_CLAN_THAT_CANCELS_THE_WAR_FIRST_WILL_LOSE_5_000_CLAN_REPUTATION_ANY_CLAN_THAT_CANCELS_THE_WAR_WILL_BE_UNABLE_TO_DECLARE_A_WAR_FOR_1_WEEK_IF_YOUR_CLAN_MEMBER_GETS_KILLED_BY_THE_OTHER_CLAN_XP_DECREASES_BY_1_4_OF_THE_AMOUNT_THAT_DECREASES_IN_THE_HUNTING_GROUND);
|
||||
sm.addString(attacker.getName());
|
||||
attacked.broadcastToOnlineMembers(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.A_CLAN_WAR_WITH_CLAN_S1_HAS_STARTED_THE_CLAN_THAT_CANCELS_THE_WAR_FIRST_WILL_LOSE_5_000_CLAN_REPUTATION_ANY_CLAN_THAT_CANCELS_THE_WAR_WILL_BE_UNABLE_TO_DECLARE_A_WAR_FOR_1_WEEK_IF_YOUR_CLAN_MEMBER_GETS_KILLED_BY_THE_OTHER_CLAN_XP_DECREASES_BY_1_4_OF_THE_AMOUNT_THAT_DECREASES_IN_THE_HUNTING_GROUND);
|
||||
sm.addString(attacked.getName());
|
||||
attacker.broadcastToOnlineMembers(sm);
|
||||
|
||||
if (_cancelTask != null)
|
||||
{
|
||||
_cancelTask.cancel(true);
|
||||
_cancelTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getKillDifference(L2Clan clan)
|
||||
{
|
||||
return _attackerClanId == clan.getId() ? _attackerKillCount.get() - _attackedKillCount.get() : _attackedKillCount.get() - _attackerKillCount.get();
|
||||
}
|
||||
|
||||
public ClanWarState getClanWarState(L2Clan clan)
|
||||
{
|
||||
if (_winnerClanId > 0)
|
||||
{
|
||||
return _winnerClanId == clan.getId() ? ClanWarState.WIN : ClanWarState.LOSS;
|
||||
}
|
||||
return _state;
|
||||
}
|
||||
|
||||
public int getAttackerClanId()
|
||||
{
|
||||
return _attackerClanId;
|
||||
}
|
||||
|
||||
public int getAttackedClanId()
|
||||
{
|
||||
return _attackedClanId;
|
||||
}
|
||||
|
||||
public int getAttackerKillCount()
|
||||
{
|
||||
return _attackerKillCount.get();
|
||||
}
|
||||
|
||||
public int getAttackedKillCount()
|
||||
{
|
||||
return _attackedKillCount.get();
|
||||
}
|
||||
|
||||
public int getWinnerClanId()
|
||||
{
|
||||
return _winnerClanId;
|
||||
}
|
||||
|
||||
public long getStartTime()
|
||||
{
|
||||
return _startTime;
|
||||
}
|
||||
|
||||
public long getEndTime()
|
||||
{
|
||||
return _endTime;
|
||||
}
|
||||
|
||||
public ClanWarState getState()
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
|
||||
public int getKillToStart()
|
||||
{
|
||||
return _state == ClanWarState.BLOOD_DECLARATION ? 5 - _attackedKillCount.get() : 0;
|
||||
}
|
||||
|
||||
public int getRemainingTime()
|
||||
{
|
||||
return (int) TimeUnit.SECONDS.convert(_startTime + TIME_TO_CANCEL_NON_MUTUAL_CLAN_WAR, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public L2Clan getOpposingClan(L2Clan clan)
|
||||
{
|
||||
return _attackerClanId == clan.getId() ? ClanTable.getInstance().getClan(_attackedClanId) : ClanTable.getInstance().getClan(_attackerClanId);
|
||||
}
|
||||
|
||||
public enum ClanWarState
|
||||
{
|
||||
DECLARATION,
|
||||
BLOOD_DECLARATION,
|
||||
MUTUAL,
|
||||
WIN,
|
||||
LOSS,
|
||||
TIE
|
||||
}
|
||||
}
|
||||
@@ -1,126 +1,125 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class CombatFlag
|
||||
{
|
||||
// private static final Logger _log = Logger.getLogger(CombatFlag.class.getName());
|
||||
|
||||
private L2PcInstance _player = null;
|
||||
private int _playerId = 0;
|
||||
private L2ItemInstance _item = null;
|
||||
private L2ItemInstance _itemInstance;
|
||||
private final Location _location;
|
||||
private final int _itemId;
|
||||
@SuppressWarnings("unused")
|
||||
private final int _fortId;
|
||||
|
||||
public CombatFlag(int fort_id, int x, int y, int z, int heading, int item_id)
|
||||
{
|
||||
_fortId = fort_id;
|
||||
_location = new Location(x, y, z, heading);
|
||||
_itemId = item_id;
|
||||
}
|
||||
|
||||
public synchronized void spawnMe()
|
||||
{
|
||||
// Init the dropped L2ItemInstance and add it in the world as a visible object at the position where mob was last
|
||||
_itemInstance = ItemTable.getInstance().createItem("Combat", _itemId, 1, null, null);
|
||||
_itemInstance.dropMe(null, _location.getX(), _location.getY(), _location.getZ());
|
||||
}
|
||||
|
||||
public synchronized void unSpawnMe()
|
||||
{
|
||||
if (_player != null)
|
||||
{
|
||||
dropIt();
|
||||
}
|
||||
if (_itemInstance != null)
|
||||
{
|
||||
_itemInstance.decayMe();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean activate(L2PcInstance player, L2ItemInstance item)
|
||||
{
|
||||
if (player.isMounted())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player holding it data
|
||||
_player = player;
|
||||
_playerId = _player.getObjectId();
|
||||
_itemInstance = null;
|
||||
|
||||
// Equip with the weapon
|
||||
_item = item;
|
||||
_player.getInventory().equipItem(_item);
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EQUIPPED_YOUR_S1);
|
||||
sm.addItemName(_item);
|
||||
_player.sendPacket(sm);
|
||||
|
||||
// Refresh inventory
|
||||
if (!Config.FORCE_INVENTORY_UPDATE)
|
||||
{
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addItem(_item);
|
||||
_player.sendPacket(iu);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.sendPacket(new ItemList(_player, false));
|
||||
}
|
||||
// Refresh player stats
|
||||
_player.broadcastUserInfo();
|
||||
_player.setCombatFlagEquipped(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void dropIt()
|
||||
{
|
||||
// Reset player stats
|
||||
_player.setCombatFlagEquipped(false);
|
||||
final int slot = _player.getInventory().getSlotFromItem(_item);
|
||||
_player.getInventory().unEquipItemInBodySlot(slot);
|
||||
_player.destroyItem("CombatFlag", _item, null, true);
|
||||
_item = null;
|
||||
_player.broadcastUserInfo();
|
||||
_player = null;
|
||||
_playerId = 0;
|
||||
}
|
||||
|
||||
public int getPlayerObjectId()
|
||||
{
|
||||
return _playerId;
|
||||
}
|
||||
|
||||
public L2ItemInstance getCombatFlagInstance()
|
||||
{
|
||||
return _itemInstance;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class CombatFlag
|
||||
{
|
||||
// private static final Logger LOGGER = Logger.getLogger(CombatFlag.class.getName());
|
||||
|
||||
private L2PcInstance _player = null;
|
||||
private int _playerId = 0;
|
||||
private L2ItemInstance _item = null;
|
||||
private L2ItemInstance _itemInstance;
|
||||
private final Location _location;
|
||||
private final int _itemId;
|
||||
@SuppressWarnings("unused")
|
||||
private final int _fortId;
|
||||
|
||||
public CombatFlag(int fort_id, int x, int y, int z, int heading, int item_id)
|
||||
{
|
||||
_fortId = fort_id;
|
||||
_location = new Location(x, y, z, heading);
|
||||
_itemId = item_id;
|
||||
}
|
||||
|
||||
public synchronized void spawnMe()
|
||||
{
|
||||
// Init the dropped L2ItemInstance and add it in the world as a visible object at the position where mob was last
|
||||
_itemInstance = ItemTable.getInstance().createItem("Combat", _itemId, 1, null, null);
|
||||
_itemInstance.dropMe(null, _location.getX(), _location.getY(), _location.getZ());
|
||||
}
|
||||
|
||||
public synchronized void unSpawnMe()
|
||||
{
|
||||
if (_player != null)
|
||||
{
|
||||
dropIt();
|
||||
}
|
||||
if (_itemInstance != null)
|
||||
{
|
||||
_itemInstance.decayMe();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean activate(L2PcInstance player, L2ItemInstance item)
|
||||
{
|
||||
if (player.isMounted())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player holding it data
|
||||
_player = player;
|
||||
_playerId = _player.getObjectId();
|
||||
_itemInstance = null;
|
||||
|
||||
// Equip with the weapon
|
||||
_item = item;
|
||||
_player.getInventory().equipItem(_item);
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EQUIPPED_YOUR_S1);
|
||||
sm.addItemName(_item);
|
||||
_player.sendPacket(sm);
|
||||
|
||||
// Refresh inventory
|
||||
if (!Config.FORCE_INVENTORY_UPDATE)
|
||||
{
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addItem(_item);
|
||||
_player.sendInventoryUpdate(iu);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.sendItemList(false);
|
||||
}
|
||||
// Refresh player stats
|
||||
_player.broadcastUserInfo();
|
||||
_player.setCombatFlagEquipped(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void dropIt()
|
||||
{
|
||||
// Reset player stats
|
||||
_player.setCombatFlagEquipped(false);
|
||||
final int slot = _player.getInventory().getSlotFromItem(_item);
|
||||
_player.getInventory().unEquipItemInBodySlot(slot);
|
||||
_player.destroyItem("CombatFlag", _item, null, true);
|
||||
_item = null;
|
||||
_player.broadcastUserInfo();
|
||||
_player = null;
|
||||
_playerId = 0;
|
||||
}
|
||||
|
||||
public int getPlayerObjectId()
|
||||
{
|
||||
return _playerId;
|
||||
}
|
||||
|
||||
public L2ItemInstance getCombatFlagInstance()
|
||||
{
|
||||
return _itemInstance;
|
||||
}
|
||||
}
|
||||
|
||||
106
trunk/java/com/l2jmobius/gameserver/model/CreatureContainer.java
Normal file
106
trunk/java/com/l2jmobius/gameserver/model/CreatureContainer.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureSee;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class CreatureContainer
|
||||
{
|
||||
private final Set<Integer> _seen = ConcurrentHashMap.newKeySet();
|
||||
private final L2Character _owner;
|
||||
private final int _range;
|
||||
private ScheduledFuture<?> _task;
|
||||
private Predicate<L2Character> _condition = null;
|
||||
|
||||
public CreatureContainer(L2Character owner, int range, Predicate<L2Character> condition)
|
||||
{
|
||||
_owner = owner;
|
||||
_range = range;
|
||||
_condition = condition;
|
||||
start();
|
||||
}
|
||||
|
||||
public L2Character getOwner()
|
||||
{
|
||||
return _owner;
|
||||
}
|
||||
|
||||
public int getRange()
|
||||
{
|
||||
return _range;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the task that scans for new creatures
|
||||
*/
|
||||
public void start()
|
||||
{
|
||||
if ((_task == null) || _task.isDone())
|
||||
{
|
||||
_task = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(this::update, 1000L, 1000L);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code false} if the task could not be cancelled, typically because it has already completed normally; {@code true} otherwise
|
||||
*/
|
||||
public boolean stop()
|
||||
{
|
||||
return (_task != null) && !_task.isDone() && _task.cancel(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the creatures container, all previously seen creature will be discarded and next time update method is called will notify for each creature that owner sees!
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
_seen.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans around the npc and notifies about new creature owner seen
|
||||
*/
|
||||
private void update()
|
||||
{
|
||||
final Set<Integer> verified = new HashSet<>();
|
||||
L2World.getInstance().forEachVisibleObjectInRange(_owner, L2Character.class, _range, creature ->
|
||||
{
|
||||
if ((_condition == null) || _condition.test(creature))
|
||||
{
|
||||
if (_seen.add(creature.getObjectId()))
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee(_owner, creature), _owner);
|
||||
}
|
||||
verified.add(creature.getObjectId());
|
||||
}
|
||||
});
|
||||
|
||||
_seen.retainAll(verified);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,36 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* @author malyelfik
|
||||
*/
|
||||
public final class CropProcure extends SeedProduction
|
||||
{
|
||||
private final int _rewardType;
|
||||
|
||||
public CropProcure(int id, long amount, int type, long startAmount, long price)
|
||||
{
|
||||
super(id, amount, price, startAmount);
|
||||
_rewardType = type;
|
||||
}
|
||||
|
||||
public final int getReward()
|
||||
{
|
||||
return _rewardType;
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* @author malyelfik
|
||||
*/
|
||||
public final class CropProcure extends SeedProduction
|
||||
{
|
||||
private final int _rewardType;
|
||||
|
||||
public CropProcure(int id, long amount, int type, long startAmount, long price)
|
||||
{
|
||||
super(id, amount, price, startAmount);
|
||||
_rewardType = type;
|
||||
}
|
||||
|
||||
public final int getReward()
|
||||
{
|
||||
return _rewardType;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +1,51 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class CrystalizationData
|
||||
{
|
||||
private final int _id;
|
||||
private final List<ItemChanceHolder> _items = new ArrayList<>();
|
||||
|
||||
public CrystalizationData(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public void addItem(ItemChanceHolder item)
|
||||
{
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
public List<ItemChanceHolder> getItems()
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class CrystalizationData
|
||||
{
|
||||
private final int _id;
|
||||
private final List<ItemChanceHolder> _items = new ArrayList<>();
|
||||
|
||||
public CrystalizationData(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public void addItem(ItemChanceHolder item)
|
||||
{
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
public List<ItemChanceHolder> getItems()
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,60 +1,70 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author xban1x
|
||||
*/
|
||||
public final class DamageDoneInfo
|
||||
{
|
||||
private final L2PcInstance _attacker;
|
||||
private int _damage = 0;
|
||||
|
||||
public DamageDoneInfo(L2PcInstance attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public L2PcInstance getAttacker()
|
||||
{
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public void addDamage(int damage)
|
||||
{
|
||||
_damage += damage;
|
||||
}
|
||||
|
||||
public int getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object obj)
|
||||
{
|
||||
return (this == obj) || ((obj instanceof DamageDoneInfo) && (((DamageDoneInfo) obj).getAttacker() == _attacker));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode()
|
||||
{
|
||||
return _attacker.getObjectId();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author xban1x
|
||||
*/
|
||||
public final class DamageDoneInfo
|
||||
{
|
||||
private final L2PcInstance _attacker;
|
||||
private int _damage = 0;
|
||||
|
||||
public DamageDoneInfo(L2PcInstance attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public L2PcInstance getAttacker()
|
||||
{
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public void addDamage(int damage)
|
||||
{
|
||||
_damage += damage;
|
||||
}
|
||||
|
||||
public int getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj instanceof DamageDoneInfo)
|
||||
{
|
||||
return (((DamageDoneInfo) obj).getAttacker() == _attacker);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode()
|
||||
{
|
||||
return _attacker.getObjectId();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +1,108 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
|
||||
|
||||
/**
|
||||
* @author DrHouse
|
||||
*/
|
||||
public class DropProtection implements Runnable
|
||||
{
|
||||
private volatile boolean _isProtected = false;
|
||||
private L2PcInstance _owner = null;
|
||||
private ScheduledFuture<?> _task = null;
|
||||
|
||||
private static final long PROTECTED_MILLIS_TIME = 15000;
|
||||
|
||||
@Override
|
||||
public synchronized void run()
|
||||
{
|
||||
_isProtected = false;
|
||||
_owner = null;
|
||||
_task = null;
|
||||
}
|
||||
|
||||
public boolean isProtected()
|
||||
{
|
||||
return _isProtected;
|
||||
}
|
||||
|
||||
public L2PcInstance getOwner()
|
||||
{
|
||||
return _owner;
|
||||
}
|
||||
|
||||
public synchronized boolean tryPickUp(L2PcInstance actor)
|
||||
{
|
||||
return !_isProtected || (_owner == actor) || ((_owner.getParty() != null) && (_owner.getParty() == actor.getParty()));
|
||||
}
|
||||
|
||||
public boolean tryPickUp(L2PetInstance pet)
|
||||
{
|
||||
return tryPickUp(pet.getOwner());
|
||||
}
|
||||
|
||||
public synchronized void unprotect()
|
||||
{
|
||||
if (_task != null)
|
||||
{
|
||||
_task.cancel(false);
|
||||
}
|
||||
_isProtected = false;
|
||||
_owner = null;
|
||||
_task = null;
|
||||
}
|
||||
|
||||
public synchronized void protect(L2PcInstance player)
|
||||
{
|
||||
unprotect();
|
||||
|
||||
_isProtected = true;
|
||||
_owner = player;
|
||||
|
||||
if (_owner == null)
|
||||
{
|
||||
throw new NullPointerException("Trying to protect dropped item to null owner");
|
||||
}
|
||||
|
||||
_task = ThreadPoolManager.getInstance().scheduleGeneral(this, PROTECTED_MILLIS_TIME);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
|
||||
|
||||
/**
|
||||
* @author DrHouse
|
||||
*/
|
||||
public class DropProtection implements Runnable
|
||||
{
|
||||
private volatile boolean _isProtected = false;
|
||||
private L2PcInstance _owner = null;
|
||||
private ScheduledFuture<?> _task = null;
|
||||
|
||||
private static final long PROTECTED_MILLIS_TIME = 15000;
|
||||
|
||||
@Override
|
||||
public synchronized void run()
|
||||
{
|
||||
_isProtected = false;
|
||||
_owner = null;
|
||||
_task = null;
|
||||
}
|
||||
|
||||
public boolean isProtected()
|
||||
{
|
||||
return _isProtected;
|
||||
}
|
||||
|
||||
public L2PcInstance getOwner()
|
||||
{
|
||||
return _owner;
|
||||
}
|
||||
|
||||
public synchronized boolean tryPickUp(L2PcInstance actor)
|
||||
{
|
||||
if (!_isProtected)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_owner == actor)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((_owner.getParty() != null) && (_owner.getParty() == actor.getParty()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* if (_owner.getClan() != null && _owner.getClan() == actor.getClan()) return true;
|
||||
*/
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean tryPickUp(L2PetInstance pet)
|
||||
{
|
||||
return tryPickUp(pet.getOwner());
|
||||
}
|
||||
|
||||
public synchronized void unprotect()
|
||||
{
|
||||
if (_task != null)
|
||||
{
|
||||
_task.cancel(false);
|
||||
}
|
||||
_isProtected = false;
|
||||
_owner = null;
|
||||
_task = null;
|
||||
}
|
||||
|
||||
public synchronized void protect(L2PcInstance player)
|
||||
{
|
||||
unprotect();
|
||||
|
||||
_isProtected = true;
|
||||
_owner = player;
|
||||
|
||||
if (_owner == null)
|
||||
{
|
||||
throw new NullPointerException("Trying to protect dropped item to null owner");
|
||||
}
|
||||
|
||||
_task = ThreadPoolManager.getInstance().scheduleGeneral(this, PROTECTED_MILLIS_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,485 +1,174 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.FuncAdd;
|
||||
|
||||
public final class Elementals
|
||||
{
|
||||
private static final Map<Integer, ElementalItems> TABLE = new HashMap<>();
|
||||
static
|
||||
{
|
||||
for (ElementalItems item : ElementalItems.values())
|
||||
{
|
||||
TABLE.put(item._itemId, item);
|
||||
}
|
||||
}
|
||||
|
||||
public static final byte NONE = -1;
|
||||
public static final byte FIRE = 0;
|
||||
public static final byte WATER = 1;
|
||||
public static final byte WIND = 2;
|
||||
public static final byte EARTH = 3;
|
||||
public static final byte HOLY = 4;
|
||||
public static final byte DARK = 5;
|
||||
|
||||
public static final int FIRST_WEAPON_BONUS = 20;
|
||||
public static final int NEXT_WEAPON_BONUS = 5;
|
||||
public static final int ARMOR_BONUS = 6;
|
||||
|
||||
public static final int[] WEAPON_VALUES =
|
||||
{
|
||||
0, // Level 1
|
||||
25, // Level 2
|
||||
75, // Level 3
|
||||
150, // Level 4
|
||||
175, // Level 5
|
||||
225, // Level 6
|
||||
300, // Level 7
|
||||
325, // Level 8
|
||||
375, // Level 9
|
||||
450, // Level 10
|
||||
475, // Level 11
|
||||
525, // Level 12
|
||||
600, // Level 13
|
||||
Integer.MAX_VALUE
|
||||
// TODO: Higher stones
|
||||
};
|
||||
|
||||
public static final int[] ARMOR_VALUES =
|
||||
{
|
||||
0, // Level 1
|
||||
12, // Level 2
|
||||
30, // Level 3
|
||||
60, // Level 4
|
||||
72, // Level 5
|
||||
90, // Level 6
|
||||
120, // Level 7
|
||||
132, // Level 8
|
||||
150, // Level 9
|
||||
180, // Level 10
|
||||
192, // Level 11
|
||||
210, // Level 12
|
||||
240, // Level 13
|
||||
Integer.MAX_VALUE
|
||||
// TODO: Higher stones
|
||||
};
|
||||
|
||||
public static enum ElementalItemType
|
||||
{
|
||||
Stone(3),
|
||||
Roughore(3),
|
||||
Stone60(3),
|
||||
Stone150(3),
|
||||
Crystal(6),
|
||||
Crystal300(6),
|
||||
Jewel(9),
|
||||
Energy(12);
|
||||
|
||||
public int _maxLevel;
|
||||
|
||||
private ElementalItemType(int maxLvl)
|
||||
{
|
||||
_maxLevel = maxLvl;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum ElementalItems
|
||||
{
|
||||
fireStone1(FIRE, 9546, ElementalItemType.Stone),
|
||||
fireStone2(FIRE, 22635, ElementalItemType.Stone),
|
||||
fireStone3(FIRE, 34790, ElementalItemType.Stone),
|
||||
fireStone4(FIRE, 37499, ElementalItemType.Stone),
|
||||
fireStone5(FIRE, 22919, ElementalItemType.Stone),
|
||||
fireStone6(FIRE, 34661, ElementalItemType.Stone60),
|
||||
fireStone7(FIRE, 36960, ElementalItemType.Stone60),
|
||||
fireStone8(FIRE, 33863, ElementalItemType.Stone60),
|
||||
fireStone9(FIRE, 35729, ElementalItemType.Stone60),
|
||||
fireStone10(FIRE, 34667, ElementalItemType.Stone150),
|
||||
fireStone11(FIRE, 36966, ElementalItemType.Stone150),
|
||||
fireStone12(FIRE, 33869, ElementalItemType.Stone150),
|
||||
fireStone13(FIRE, 35735, ElementalItemType.Stone150),
|
||||
fireStone14(FIRE, 33481, ElementalItemType.Stone150),
|
||||
waterStone1(WATER, 9547, ElementalItemType.Stone),
|
||||
waterStone2(WATER, 34791, ElementalItemType.Stone),
|
||||
waterStone3(WATER, 22636, ElementalItemType.Stone),
|
||||
waterStone4(WATER, 37500, ElementalItemType.Stone),
|
||||
waterStone5(WATER, 22920, ElementalItemType.Stone),
|
||||
waterStone6(WATER, 34662, ElementalItemType.Stone60),
|
||||
waterStone7(WATER, 36961, ElementalItemType.Stone60),
|
||||
waterStone8(WATER, 33864, ElementalItemType.Stone60),
|
||||
waterStone9(WATER, 35730, ElementalItemType.Stone60),
|
||||
waterStone10(WATER, 34668, ElementalItemType.Stone150),
|
||||
waterStone11(WATER, 36967, ElementalItemType.Stone150),
|
||||
waterStone12(WATER, 33870, ElementalItemType.Stone150),
|
||||
waterStone13(WATER, 35736, ElementalItemType.Stone150),
|
||||
waterStone14(WATER, 33482, ElementalItemType.Stone150),
|
||||
windStone1(WIND, 9549, ElementalItemType.Stone),
|
||||
windStone2(WIND, 34793, ElementalItemType.Stone),
|
||||
windStone3(WIND, 22638, ElementalItemType.Stone),
|
||||
windStone4(WIND, 37502, ElementalItemType.Stone),
|
||||
windStone5(WIND, 22922, ElementalItemType.Stone),
|
||||
windStone6(WIND, 34664, ElementalItemType.Stone60),
|
||||
windStone7(WIND, 36963, ElementalItemType.Stone60),
|
||||
windStone8(WIND, 33866, ElementalItemType.Stone60),
|
||||
windStone9(WIND, 35732, ElementalItemType.Stone60),
|
||||
windStone10(WIND, 34670, ElementalItemType.Stone150),
|
||||
windStone11(WIND, 36969, ElementalItemType.Stone150),
|
||||
windStone12(WIND, 33872, ElementalItemType.Stone150),
|
||||
windStone13(WIND, 35738, ElementalItemType.Stone150),
|
||||
windStone14(WIND, 33484, ElementalItemType.Stone150),
|
||||
earthStone1(EARTH, 9548, ElementalItemType.Stone),
|
||||
earthStone2(EARTH, 34792, ElementalItemType.Stone),
|
||||
earthStone3(EARTH, 22637, ElementalItemType.Stone),
|
||||
earthStone4(EARTH, 37501, ElementalItemType.Stone),
|
||||
earthStone5(EARTH, 22921, ElementalItemType.Stone),
|
||||
earthStone6(EARTH, 34663, ElementalItemType.Stone60),
|
||||
earthStone7(EARTH, 36962, ElementalItemType.Stone60),
|
||||
earthStone8(EARTH, 33865, ElementalItemType.Stone60),
|
||||
earthStone9(EARTH, 35731, ElementalItemType.Stone60),
|
||||
earthStone10(EARTH, 34669, ElementalItemType.Stone150),
|
||||
earthStone11(EARTH, 36968, ElementalItemType.Stone150),
|
||||
earthStone12(EARTH, 33871, ElementalItemType.Stone150),
|
||||
earthStone13(EARTH, 35737, ElementalItemType.Stone150),
|
||||
earthStone14(EARTH, 33483, ElementalItemType.Stone150),
|
||||
divineStone1(HOLY, 9551, ElementalItemType.Stone),
|
||||
divineStone2(HOLY, 34795, ElementalItemType.Stone),
|
||||
divineStone3(HOLY, 22640, ElementalItemType.Stone),
|
||||
divineStone4(HOLY, 37504, ElementalItemType.Stone),
|
||||
divineStone5(HOLY, 22924, ElementalItemType.Stone),
|
||||
divineStone6(HOLY, 34666, ElementalItemType.Stone60),
|
||||
divineStone7(HOLY, 36965, ElementalItemType.Stone60),
|
||||
divineStone8(HOLY, 33868, ElementalItemType.Stone60),
|
||||
divineStone9(HOLY, 35734, ElementalItemType.Stone60),
|
||||
divineStone10(HOLY, 34672, ElementalItemType.Stone150),
|
||||
divineStone11(HOLY, 36971, ElementalItemType.Stone150),
|
||||
divineStone12(HOLY, 33874, ElementalItemType.Stone150),
|
||||
divineStone13(HOLY, 35740, ElementalItemType.Stone150),
|
||||
divineStone14(HOLY, 33486, ElementalItemType.Stone150),
|
||||
darkStone1(DARK, 9550, ElementalItemType.Stone),
|
||||
darkStone2(DARK, 34794, ElementalItemType.Stone),
|
||||
darkStone3(DARK, 22639, ElementalItemType.Stone),
|
||||
darkStone4(DARK, 37503, ElementalItemType.Stone),
|
||||
darkStone5(DARK, 22923, ElementalItemType.Stone),
|
||||
darkStone6(DARK, 34665, ElementalItemType.Stone60),
|
||||
darkStone7(DARK, 36964, ElementalItemType.Stone60),
|
||||
darkStone8(DARK, 33867, ElementalItemType.Stone60),
|
||||
darkStone9(DARK, 35733, ElementalItemType.Stone60),
|
||||
darkStone10(DARK, 34671, ElementalItemType.Stone150),
|
||||
darkStone11(DARK, 36970, ElementalItemType.Stone150),
|
||||
darkStone12(DARK, 33873, ElementalItemType.Stone150),
|
||||
darkStone13(DARK, 35739, ElementalItemType.Stone150),
|
||||
darkStone14(DARK, 33485, ElementalItemType.Stone150),
|
||||
|
||||
fireRoughtore(FIRE, 10521, ElementalItemType.Roughore),
|
||||
waterRoughtore(WATER, 10522, ElementalItemType.Roughore),
|
||||
windRoughtore(WIND, 10524, ElementalItemType.Roughore),
|
||||
earthRoughtore(EARTH, 10523, ElementalItemType.Roughore),
|
||||
divineRoughtore(HOLY, 10526, ElementalItemType.Roughore),
|
||||
darkRoughtore(DARK, 10525, ElementalItemType.Roughore),
|
||||
|
||||
fireCrystal1(FIRE, 9552, ElementalItemType.Crystal),
|
||||
fireCrystal2(FIRE, 34796, ElementalItemType.Crystal),
|
||||
fireCrystal3(FIRE, 22925, ElementalItemType.Crystal),
|
||||
fireCrystal4(FIRE, 22641, ElementalItemType.Crystal),
|
||||
fireCrystal5(FIRE, 36972, ElementalItemType.Crystal300),
|
||||
fireCrystal6(FIRE, 33487, ElementalItemType.Crystal300),
|
||||
waterCrystal1(WATER, 9553, ElementalItemType.Crystal),
|
||||
waterCrystal2(WATER, 34797, ElementalItemType.Crystal),
|
||||
waterCrystal3(WATER, 22926, ElementalItemType.Crystal),
|
||||
waterCrystal4(WATER, 22642, ElementalItemType.Crystal),
|
||||
waterCrystal5(WATER, 36973, ElementalItemType.Crystal300),
|
||||
waterCrystal6(WATER, 33488, ElementalItemType.Crystal300),
|
||||
windCrystal1(WIND, 9555, ElementalItemType.Crystal),
|
||||
windCrystal2(WIND, 34799, ElementalItemType.Crystal),
|
||||
windCrystal3(WIND, 22928, ElementalItemType.Crystal),
|
||||
windCrystal4(WIND, 22644, ElementalItemType.Crystal),
|
||||
windCrystal5(WIND, 36975, ElementalItemType.Crystal300),
|
||||
windCrystal6(WIND, 33490, ElementalItemType.Crystal300),
|
||||
earthCrystal1(EARTH, 9554, ElementalItemType.Crystal),
|
||||
earthCrystal2(EARTH, 34798, ElementalItemType.Crystal),
|
||||
earthCrystal3(EARTH, 22927, ElementalItemType.Crystal),
|
||||
earthCrystal4(EARTH, 22643, ElementalItemType.Crystal),
|
||||
earthCrystal5(EARTH, 36974, ElementalItemType.Crystal300),
|
||||
earthCrystal6(EARTH, 33489, ElementalItemType.Crystal300),
|
||||
divineCrystal1(HOLY, 9557, ElementalItemType.Crystal),
|
||||
divineCrystal2(HOLY, 34801, ElementalItemType.Crystal),
|
||||
divineCrystal3(HOLY, 22930, ElementalItemType.Crystal),
|
||||
divineCrystal4(HOLY, 22646, ElementalItemType.Crystal),
|
||||
divineCrystal5(HOLY, 36977, ElementalItemType.Crystal300),
|
||||
divineCrystal6(HOLY, 33492, ElementalItemType.Crystal300),
|
||||
darkCrystal1(DARK, 9556, ElementalItemType.Crystal),
|
||||
darkCrystal2(DARK, 34800, ElementalItemType.Crystal),
|
||||
darkCrystal3(DARK, 22929, ElementalItemType.Crystal),
|
||||
darkCrystal4(DARK, 22645, ElementalItemType.Crystal),
|
||||
darkCrystal5(DARK, 36796, ElementalItemType.Crystal300),
|
||||
darkCrystal6(DARK, 33491, ElementalItemType.Crystal300),
|
||||
|
||||
fireJewel(FIRE, 9558, ElementalItemType.Jewel),
|
||||
waterJewel(WATER, 9559, ElementalItemType.Jewel),
|
||||
windJewel(WIND, 9561, ElementalItemType.Jewel),
|
||||
earthJewel(EARTH, 9560, ElementalItemType.Jewel),
|
||||
divineJewel(HOLY, 9563, ElementalItemType.Jewel),
|
||||
darkJewel(DARK, 9562, ElementalItemType.Jewel),
|
||||
|
||||
// not yet supported by client (Freya pts)
|
||||
fireEnergy(FIRE, 9564, ElementalItemType.Energy),
|
||||
waterEnergy(WATER, 9565, ElementalItemType.Energy),
|
||||
windEnergy(WIND, 9567, ElementalItemType.Energy),
|
||||
earthEnergy(EARTH, 9566, ElementalItemType.Energy),
|
||||
divineEnergy(HOLY, 9569, ElementalItemType.Energy),
|
||||
darkEnergy(DARK, 9568, ElementalItemType.Energy);
|
||||
|
||||
public byte _element;
|
||||
public int _itemId;
|
||||
public ElementalItemType _type;
|
||||
|
||||
private ElementalItems(byte element, int itemId, ElementalItemType type)
|
||||
{
|
||||
_element = element;
|
||||
_itemId = itemId;
|
||||
_type = type;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte getItemElement(int itemId)
|
||||
{
|
||||
final ElementalItems item = TABLE.get(itemId);
|
||||
return item != null ? item._element : NONE;
|
||||
}
|
||||
|
||||
public static ElementalItems getItemElemental(int itemId)
|
||||
{
|
||||
return TABLE.get(itemId);
|
||||
}
|
||||
|
||||
public static int getMaxElementLevel(int itemId)
|
||||
{
|
||||
final ElementalItems item = TABLE.get(itemId);
|
||||
return item != null ? item._type._maxLevel : -1;
|
||||
}
|
||||
|
||||
public static String getElementName(byte element)
|
||||
{
|
||||
switch (element)
|
||||
{
|
||||
case FIRE:
|
||||
{
|
||||
return "Fire";
|
||||
}
|
||||
case WATER:
|
||||
{
|
||||
return "Water";
|
||||
}
|
||||
case WIND:
|
||||
{
|
||||
return "Wind";
|
||||
}
|
||||
case EARTH:
|
||||
{
|
||||
return "Earth";
|
||||
}
|
||||
case DARK:
|
||||
{
|
||||
return "Dark";
|
||||
}
|
||||
case HOLY:
|
||||
{
|
||||
return "Holy";
|
||||
}
|
||||
}
|
||||
return "None";
|
||||
}
|
||||
|
||||
public static byte getElementId(String name)
|
||||
{
|
||||
final String tmp = name.toLowerCase();
|
||||
if (tmp.equals("fire"))
|
||||
{
|
||||
return FIRE;
|
||||
}
|
||||
if (tmp.equals("water"))
|
||||
{
|
||||
return WATER;
|
||||
}
|
||||
if (tmp.equals("wind"))
|
||||
{
|
||||
return WIND;
|
||||
}
|
||||
if (tmp.equals("earth"))
|
||||
{
|
||||
return EARTH;
|
||||
}
|
||||
if (tmp.equals("dark"))
|
||||
{
|
||||
return DARK;
|
||||
}
|
||||
if (tmp.equals("holy"))
|
||||
{
|
||||
return HOLY;
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
|
||||
public static byte getOppositeElement(byte element)
|
||||
{
|
||||
return (byte) (((element % 2) == 0) ? (element + 1) : (element - 1));
|
||||
}
|
||||
|
||||
public static class ElementalStatBoni
|
||||
{
|
||||
private byte _elementalType;
|
||||
private int _elementalValue;
|
||||
private boolean _active;
|
||||
|
||||
public ElementalStatBoni(byte type, int value)
|
||||
{
|
||||
_elementalType = type;
|
||||
_elementalValue = value;
|
||||
_active = false;
|
||||
}
|
||||
|
||||
public void applyBonus(L2PcInstance player, boolean isArmor)
|
||||
{
|
||||
// make sure the bonuses are not applied twice..
|
||||
if (_active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_elementalType)
|
||||
{
|
||||
case FIRE:
|
||||
{
|
||||
player.addStatFunc(new FuncAdd(isArmor ? Stats.FIRE_RES : Stats.FIRE_POWER, 0x40, this, _elementalValue, null));
|
||||
break;
|
||||
}
|
||||
case WATER:
|
||||
{
|
||||
player.addStatFunc(new FuncAdd(isArmor ? Stats.WATER_RES : Stats.WATER_POWER, 0x40, this, _elementalValue, null));
|
||||
break;
|
||||
}
|
||||
case WIND:
|
||||
{
|
||||
player.addStatFunc(new FuncAdd(isArmor ? Stats.WIND_RES : Stats.WIND_POWER, 0x40, this, _elementalValue, null));
|
||||
break;
|
||||
}
|
||||
case EARTH:
|
||||
{
|
||||
player.addStatFunc(new FuncAdd(isArmor ? Stats.EARTH_RES : Stats.EARTH_POWER, 0x40, this, _elementalValue, null));
|
||||
break;
|
||||
}
|
||||
case DARK:
|
||||
{
|
||||
player.addStatFunc(new FuncAdd(isArmor ? Stats.DARK_RES : Stats.DARK_POWER, 0x40, this, _elementalValue, null));
|
||||
break;
|
||||
}
|
||||
case HOLY:
|
||||
{
|
||||
player.addStatFunc(new FuncAdd(isArmor ? Stats.HOLY_RES : Stats.HOLY_POWER, 0x40, this, _elementalValue, null));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_active = true;
|
||||
}
|
||||
|
||||
public void removeBonus(L2PcInstance player)
|
||||
{
|
||||
// make sure the bonuses are not removed twice
|
||||
if (!_active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.removeStatsOwner(this);
|
||||
|
||||
_active = false;
|
||||
}
|
||||
|
||||
public void setValue(int val)
|
||||
{
|
||||
_elementalValue = val;
|
||||
}
|
||||
|
||||
public void setElement(byte type)
|
||||
{
|
||||
_elementalType = type;
|
||||
}
|
||||
}
|
||||
|
||||
// non static:
|
||||
private ElementalStatBoni _boni = null;
|
||||
private byte _element = NONE;
|
||||
private int _value = 0;
|
||||
|
||||
public byte getElement()
|
||||
{
|
||||
return _element;
|
||||
}
|
||||
|
||||
public void setElement(byte type)
|
||||
{
|
||||
_element = type;
|
||||
_boni.setElement(type);
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
public void setValue(int val)
|
||||
{
|
||||
_value = val;
|
||||
_boni.setValue(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getElementName(_element) + " +" + _value;
|
||||
}
|
||||
|
||||
public Elementals(byte type, int value)
|
||||
{
|
||||
_element = type;
|
||||
_value = value;
|
||||
_boni = new ElementalStatBoni(_element, _value);
|
||||
}
|
||||
|
||||
public void applyBonus(L2PcInstance player, boolean isArmor)
|
||||
{
|
||||
_boni.applyBonus(player, isArmor);
|
||||
}
|
||||
|
||||
public void removeBonus(L2PcInstance player)
|
||||
{
|
||||
_boni.removeBonus(player);
|
||||
}
|
||||
|
||||
public void updateBonus(L2PcInstance player, boolean isArmor)
|
||||
{
|
||||
_boni.removeBonus(player);
|
||||
_boni.applyBonus(player, isArmor);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class Elementals
|
||||
{
|
||||
private static final Map<Integer, ElementalItems> TABLE = new HashMap<>();
|
||||
|
||||
static
|
||||
{
|
||||
for (ElementalItems item : ElementalItems.values())
|
||||
{
|
||||
TABLE.put(item._itemId, item);
|
||||
}
|
||||
}
|
||||
|
||||
protected static final byte NONE = -1;
|
||||
protected static final byte FIRE = 0;
|
||||
protected static final byte WATER = 1;
|
||||
protected static final byte WIND = 2;
|
||||
protected static final byte EARTH = 3;
|
||||
protected static final byte HOLY = 4;
|
||||
protected static final byte DARK = 5;
|
||||
|
||||
public static final int FIRST_WEAPON_BONUS = 20;
|
||||
public static final int NEXT_WEAPON_BONUS = 5;
|
||||
public static final int ARMOR_BONUS = 6;
|
||||
|
||||
public static final int[] WEAPON_VALUES =
|
||||
{
|
||||
0, // Level 1
|
||||
25, // Level 2
|
||||
75, // Level 3
|
||||
150, // Level 4
|
||||
175, // Level 5
|
||||
225, // Level 6
|
||||
300, // Level 7
|
||||
325, // Level 8
|
||||
375, // Level 9
|
||||
450, // Level 10
|
||||
475, // Level 11
|
||||
525, // Level 12
|
||||
600, // Level 13
|
||||
Integer.MAX_VALUE
|
||||
// TODO: Higher stones
|
||||
};
|
||||
|
||||
public static final int[] ARMOR_VALUES =
|
||||
{
|
||||
0, // Level 1
|
||||
12, // Level 2
|
||||
30, // Level 3
|
||||
60, // Level 4
|
||||
72, // Level 5
|
||||
90, // Level 6
|
||||
120, // Level 7
|
||||
132, // Level 8
|
||||
150, // Level 9
|
||||
180, // Level 10
|
||||
192, // Level 11
|
||||
210, // Level 12
|
||||
240, // Level 13
|
||||
Integer.MAX_VALUE
|
||||
// TODO: Higher stones
|
||||
};
|
||||
|
||||
public enum ElementalItemType
|
||||
{
|
||||
Stone(3),
|
||||
Roughore(3),
|
||||
Crystal(6),
|
||||
Jewel(9),
|
||||
Energy(12);
|
||||
|
||||
public int _maxLevel;
|
||||
|
||||
ElementalItemType(int maxLvl)
|
||||
{
|
||||
_maxLevel = maxLvl;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ElementalItems
|
||||
{
|
||||
fireStone(FIRE, 9546, ElementalItemType.Stone),
|
||||
waterStone(WATER, 9547, ElementalItemType.Stone),
|
||||
windStone(WIND, 9549, ElementalItemType.Stone),
|
||||
earthStone(EARTH, 9548, ElementalItemType.Stone),
|
||||
divineStone(HOLY, 9551, ElementalItemType.Stone),
|
||||
darkStone(DARK, 9550, ElementalItemType.Stone),
|
||||
|
||||
fireRoughtore(FIRE, 10521, ElementalItemType.Roughore),
|
||||
waterRoughtore(WATER, 10522, ElementalItemType.Roughore),
|
||||
windRoughtore(WIND, 10524, ElementalItemType.Roughore),
|
||||
earthRoughtore(EARTH, 10523, ElementalItemType.Roughore),
|
||||
divineRoughtore(HOLY, 10526, ElementalItemType.Roughore),
|
||||
darkRoughtore(DARK, 10525, ElementalItemType.Roughore),
|
||||
|
||||
fireCrystal(FIRE, 9552, ElementalItemType.Crystal),
|
||||
waterCrystal(WATER, 9553, ElementalItemType.Crystal),
|
||||
windCrystal(WIND, 9555, ElementalItemType.Crystal),
|
||||
earthCrystal(EARTH, 9554, ElementalItemType.Crystal),
|
||||
divineCrystal(HOLY, 9557, ElementalItemType.Crystal),
|
||||
darkCrystal(DARK, 9556, ElementalItemType.Crystal),
|
||||
|
||||
fireJewel(FIRE, 9558, ElementalItemType.Jewel),
|
||||
waterJewel(WATER, 9559, ElementalItemType.Jewel),
|
||||
windJewel(WIND, 9561, ElementalItemType.Jewel),
|
||||
earthJewel(EARTH, 9560, ElementalItemType.Jewel),
|
||||
divineJewel(HOLY, 9563, ElementalItemType.Jewel),
|
||||
darkJewel(DARK, 9562, ElementalItemType.Jewel),
|
||||
|
||||
// not yet supported by client (Freya pts)
|
||||
fireEnergy(FIRE, 9564, ElementalItemType.Energy),
|
||||
waterEnergy(WATER, 9565, ElementalItemType.Energy),
|
||||
windEnergy(WIND, 9567, ElementalItemType.Energy),
|
||||
earthEnergy(EARTH, 9566, ElementalItemType.Energy),
|
||||
divineEnergy(HOLY, 9569, ElementalItemType.Energy),
|
||||
darkEnergy(DARK, 9568, ElementalItemType.Energy);
|
||||
|
||||
public byte _element;
|
||||
public int _itemId;
|
||||
public ElementalItemType _type;
|
||||
|
||||
ElementalItems(byte element, int itemId, ElementalItemType type)
|
||||
{
|
||||
_element = element;
|
||||
_itemId = itemId;
|
||||
_type = type;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte getItemElement(int itemId)
|
||||
{
|
||||
final ElementalItems item = TABLE.get(itemId);
|
||||
if (item != null)
|
||||
{
|
||||
return item._element;
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
|
||||
public static ElementalItems getItemElemental(int itemId)
|
||||
{
|
||||
return TABLE.get(itemId);
|
||||
}
|
||||
|
||||
public static int getMaxElementLevel(int itemId)
|
||||
{
|
||||
final ElementalItems item = TABLE.get(itemId);
|
||||
if (item != null)
|
||||
{
|
||||
return item._type._maxLevel;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
481
trunk/java/com/l2jmobius/gameserver/model/Fishing.java
Normal file
481
trunk/java/com/l2jmobius/gameserver/model/Fishing.java
Normal file
@@ -0,0 +1,481 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.GeoData;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.FishingData;
|
||||
import com.l2jmobius.gameserver.enums.ShotType;
|
||||
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerFishing;
|
||||
import com.l2jmobius.gameserver.model.interfaces.ILocational;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.items.type.WeaponType;
|
||||
import com.l2jmobius.gameserver.model.zone.L2ZoneType;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2FishingZone;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2WaterZone;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.fishing.ExFishingEnd;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.fishing.ExFishingEnd.FishingEndReason;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.fishing.ExFishingEnd.FishingEndType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.fishing.ExFishingStart;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.fishing.ExUserInfoFishing;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author bit
|
||||
*/
|
||||
public class Fishing
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(Fishing.class.getName());
|
||||
private volatile ILocational _baitLocation = new Location(0, 0, 0);
|
||||
|
||||
private final L2PcInstance _player;
|
||||
private ScheduledFuture<?> _reelInTask;
|
||||
private ScheduledFuture<?> _startFishingTask;
|
||||
private boolean _isFishing = false;
|
||||
|
||||
public Fishing(L2PcInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public synchronized boolean isFishing()
|
||||
{
|
||||
return _isFishing;
|
||||
}
|
||||
|
||||
public boolean isAtValidLocation()
|
||||
{
|
||||
// TODO: implement checking direction
|
||||
return _player.isInsideZone(ZoneId.FISHING);
|
||||
}
|
||||
|
||||
public boolean canFish()
|
||||
{
|
||||
return !_player.isDead() && !_player.isAlikeDead() && !_player.hasBlockActions();
|
||||
}
|
||||
|
||||
private FishingBaitData getCurrentBaitData()
|
||||
{
|
||||
final L2ItemInstance bait = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
|
||||
return bait != null ? FishingData.getInstance().getBaitData(bait.getId()) : null;
|
||||
}
|
||||
|
||||
private void cancelTasks()
|
||||
{
|
||||
if (_reelInTask != null)
|
||||
{
|
||||
_reelInTask.cancel(false);
|
||||
_reelInTask = null;
|
||||
}
|
||||
|
||||
if (_startFishingTask != null)
|
||||
{
|
||||
_startFishingTask.cancel(false);
|
||||
_startFishingTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void startFishing()
|
||||
{
|
||||
if (isFishing())
|
||||
{
|
||||
return;
|
||||
}
|
||||
_isFishing = true;
|
||||
castLine();
|
||||
}
|
||||
|
||||
private void castLine()
|
||||
{
|
||||
if (!Config.ALLOWFISHING && !_player.canOverrideCond(PcCondOverride.ZONE_CONDITIONS))
|
||||
{
|
||||
_player.sendMessage("Fishing is disabled.");
|
||||
_player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
stopFishing(FishingEndType.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
cancelTasks();
|
||||
|
||||
if (!canFish())
|
||||
{
|
||||
if (isFishing())
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.YOUR_ATTEMPT_AT_FISHING_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
stopFishing(FishingEndType.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
final int minPlayerLevel = FishingData.getInstance().getMinPlayerLevel();
|
||||
if (_player.getLevel() < minPlayerLevel)
|
||||
{
|
||||
if (minPlayerLevel == 85)
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.FISHING_IS_AVAILABLE_TO_CHARACTERS_LV_85_OR_ABOVE);
|
||||
}
|
||||
else
|
||||
// In case of custom fishing level requirement set in config.
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.YOU_DO_NOT_MEET_THE_FISHING_LEVEL_REQUIREMENTS);
|
||||
}
|
||||
_player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
stopFishing(FishingEndType.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
final L2ItemInstance rod = _player.getActiveWeaponInstance();
|
||||
if ((rod == null) || (rod.getItemType() != WeaponType.FISHINGROD))
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_A_FISHING_POLE_EQUIPPED);
|
||||
_player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
stopFishing(FishingEndType.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
final FishingBaitData baitData = getCurrentBaitData();
|
||||
if (baitData == null)
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.YOU_MUST_PUT_BAIT_ON_YOUR_HOOK_BEFORE_YOU_CAN_FISH);
|
||||
_player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
stopFishing(FishingEndType.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player.isTransformed() || _player.isInBoat())
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.YOU_CANNOT_FISH_WHEN_TRANSFORMED_OR_WHILE_RIDING_AS_A_PASSENGER_OF_A_BOAT_IT_S_AGAINST_THE_RULES);
|
||||
_player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
stopFishing(FishingEndType.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player.isInCraftMode() || _player.isInStoreMode())
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.YOU_CANNOT_FISH_WHILE_USING_A_RECIPE_BOOK_PRIVATE_WORKSHOP_OR_PRIVATE_STORE);
|
||||
_player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
stopFishing(FishingEndType.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player.isInsideZone(ZoneId.WATER) || _player.isInWater())
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.YOU_CANNOT_FISH_WHILE_UNDER_WATER);
|
||||
_player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
stopFishing(FishingEndType.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
_baitLocation = calculateBaitLocation();
|
||||
if (!isAtValidLocation() || (_baitLocation == null))
|
||||
{
|
||||
if (isFishing())
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.YOUR_ATTEMPT_AT_FISHING_HAS_BEEN_CANCELLED);
|
||||
_player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.YOU_CAN_T_FISH_HERE);
|
||||
_player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
stopFishing(FishingEndType.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_player.isChargedShot(ShotType.FISH_SOULSHOTS))
|
||||
{
|
||||
_player.rechargeShots(false, false, true);
|
||||
}
|
||||
|
||||
_reelInTask = ThreadPoolManager.getInstance().scheduleGeneral(() ->
|
||||
{
|
||||
_player.getFishing().reelInWithReward();
|
||||
_startFishingTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> _player.getFishing().castLine(), Rnd.get(FishingData.getInstance().getFishingTimeWaitMin(), FishingData.getInstance().getFishingTimeWaitMax()));
|
||||
}, Rnd.get(FishingData.getInstance().getFishingTimeMin(), FishingData.getInstance().getFishingTimeMax()));
|
||||
_player.stopMove(null);
|
||||
_player.broadcastPacket(new ExFishingStart(_player, -1, baitData.getLevel(), _baitLocation));
|
||||
_player.sendPacket(new ExUserInfoFishing(_player, true, _baitLocation));
|
||||
_player.sendPacket(new PlaySound("SF_P_01"));
|
||||
_player.sendPacket(SystemMessageId.YOU_CAST_YOUR_LINE_AND_START_TO_FISH);
|
||||
}
|
||||
|
||||
public void reelInWithReward()
|
||||
{
|
||||
// Fish may or may not eat the hook. If it does - it consumes fishing bait and fishing shot.
|
||||
// Then player may or may not catch the fish. Using fishing shots increases chance to win.
|
||||
final FishingBaitData baitData = getCurrentBaitData();
|
||||
if (baitData == null)
|
||||
{
|
||||
reelIn(FishingEndReason.LOSE, false);
|
||||
LOGGER.warning("Player " + _player + " is fishing with unhandled bait: " + _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND));
|
||||
return;
|
||||
}
|
||||
|
||||
double chance = baitData.getChance();
|
||||
if (_player.isChargedShot(ShotType.FISH_SOULSHOTS))
|
||||
{
|
||||
chance *= 1.25; // +25 % chance to win
|
||||
_player.setChargedShot(ShotType.FISH_SOULSHOTS, false);
|
||||
}
|
||||
|
||||
if (Rnd.get(0, 100) <= chance)
|
||||
{
|
||||
reelIn(FishingEndReason.WIN, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
reelIn(FishingEndReason.LOSE, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void reelIn(FishingEndReason reason, boolean consumeBait)
|
||||
{
|
||||
if (!isFishing())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cancelTasks();
|
||||
|
||||
try
|
||||
{
|
||||
final L2ItemInstance bait = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
|
||||
if (consumeBait)
|
||||
{
|
||||
if ((bait == null) || !_player.getInventory().updateItemCount(null, bait, -1, _player, null))
|
||||
{
|
||||
reason = FishingEndReason.LOSE; // no bait - no reward
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((reason == FishingEndReason.WIN) && (bait != null))
|
||||
{
|
||||
final FishingBaitData baitData = FishingData.getInstance().getBaitData(bait.getId());
|
||||
final int numRewards = baitData.getRewards().size();
|
||||
if (numRewards > 0)
|
||||
{
|
||||
// TODO: verify, totally guessed
|
||||
final FishingData fishingData = FishingData.getInstance();
|
||||
final int lvlModifier = _player.getLevel() * _player.getLevel();
|
||||
_player.addExpAndSp(Rnd.get(fishingData.getExpRateMin(), fishingData.getExpRateMax()) * lvlModifier, Rnd.get(fishingData.getSpRateMin(), fishingData.getSpRateMax()) * lvlModifier);
|
||||
final int fishId = baitData.getRewards().get(Rnd.get(0, numRewards - 1));
|
||||
_player.getInventory().addItem("Fishing Reward", fishId, 1, _player, null);
|
||||
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
|
||||
msg.addItemName(fishId);
|
||||
_player.sendPacket(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Could not find fishing rewards for bait ", bait.getId());
|
||||
}
|
||||
}
|
||||
else if (reason == FishingEndReason.LOSE)
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.THE_BAIT_HAS_BEEN_LOST_BECAUSE_THE_FISH_GOT_AWAY);
|
||||
}
|
||||
|
||||
if (consumeBait)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerFishing(_player, reason), _player);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_player.broadcastPacket(new ExFishingEnd(_player, reason));
|
||||
_player.sendPacket(new ExUserInfoFishing(_player, false));
|
||||
}
|
||||
}
|
||||
|
||||
public void stopFishing()
|
||||
{
|
||||
stopFishing(FishingEndType.PLAYER_STOP);
|
||||
}
|
||||
|
||||
public synchronized void stopFishing(FishingEndType endType)
|
||||
{
|
||||
if (isFishing())
|
||||
{
|
||||
reelIn(FishingEndReason.STOP, false);
|
||||
_isFishing = false;
|
||||
switch (endType)
|
||||
{
|
||||
case PLAYER_STOP:
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.YOU_REEL_YOUR_LINE_IN_AND_STOP_FISHING);
|
||||
break;
|
||||
}
|
||||
case PLAYER_CANCEL:
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.YOUR_ATTEMPT_AT_FISHING_HAS_BEEN_CANCELLED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ILocational getBaitLocation()
|
||||
{
|
||||
return _baitLocation;
|
||||
}
|
||||
|
||||
private Location calculateBaitLocation()
|
||||
{
|
||||
// calculate a position in front of the player with a random distance
|
||||
final int distMin = FishingData.getInstance().getBaitDistanceMin();
|
||||
final int distMax = FishingData.getInstance().getBaitDistanceMax();
|
||||
int distance = Rnd.get(distMin, distMax);
|
||||
final double angle = Util.convertHeadingToDegree(_player.getHeading());
|
||||
final double radian = Math.toRadians(angle);
|
||||
final double sin = Math.sin(radian);
|
||||
final double cos = Math.cos(radian);
|
||||
int baitX = (int) (_player.getX() + (cos * distance));
|
||||
int baitY = (int) (_player.getY() + (sin * distance));
|
||||
|
||||
// search for fishing and water zone
|
||||
L2FishingZone fishingZone = null;
|
||||
L2WaterZone waterZone = null;
|
||||
for (L2ZoneType zone : ZoneManager.getInstance().getZones(baitX, baitY))
|
||||
{
|
||||
if (zone instanceof L2FishingZone)
|
||||
{
|
||||
fishingZone = (L2FishingZone) zone;
|
||||
}
|
||||
else if (zone instanceof L2WaterZone)
|
||||
{
|
||||
waterZone = (L2WaterZone) zone;
|
||||
}
|
||||
|
||||
if ((fishingZone != null) && (waterZone != null))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int baitZ = computeBaitZ(_player, baitX, baitY, fishingZone, waterZone);
|
||||
if (baitZ == Integer.MIN_VALUE)
|
||||
{
|
||||
for (distance = distMax; distance >= distMin; --distance)
|
||||
{
|
||||
baitX = (int) (_player.getX() + (cos * distance));
|
||||
baitY = (int) (_player.getY() + (sin * distance));
|
||||
|
||||
// search for fishing and water zone again
|
||||
fishingZone = null;
|
||||
waterZone = null;
|
||||
for (L2ZoneType zone : ZoneManager.getInstance().getZones(baitX, baitY))
|
||||
{
|
||||
if (zone instanceof L2FishingZone)
|
||||
{
|
||||
fishingZone = (L2FishingZone) zone;
|
||||
}
|
||||
else if (zone instanceof L2WaterZone)
|
||||
{
|
||||
waterZone = (L2WaterZone) zone;
|
||||
}
|
||||
|
||||
if ((fishingZone != null) && (waterZone != null))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
baitZ = computeBaitZ(_player, baitX, baitY, fishingZone, waterZone);
|
||||
if (baitZ != Integer.MIN_VALUE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (baitZ == Integer.MIN_VALUE)
|
||||
{
|
||||
if (_player.isGM())
|
||||
{
|
||||
baitZ = _player.getZ();
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.YOU_CAN_T_FISH_HERE);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new Location(baitX, baitY, baitZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the Z of the bait.
|
||||
* @param player the player
|
||||
* @param baitX the bait x
|
||||
* @param baitY the bait y
|
||||
* @param fishingZone the fishing zone
|
||||
* @param waterZone the water zone
|
||||
* @return the bait z or {@link Integer#MIN_VALUE} when you cannot fish here
|
||||
*/
|
||||
private static int computeBaitZ(L2PcInstance player, int baitX, int baitY, L2FishingZone fishingZone, L2WaterZone waterZone)
|
||||
{
|
||||
if ((fishingZone == null))
|
||||
{
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
if ((waterZone == null))
|
||||
{
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
// always use water zone, fishing zone high z is high in the air...
|
||||
final int baitZ = waterZone.getWaterZ();
|
||||
|
||||
if (!GeoData.getInstance().canSeeTarget(player.getX(), player.getY(), player.getZ(), baitX, baitY, baitZ))
|
||||
{
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
if (GeoData.getInstance().hasGeo(baitX, baitY))
|
||||
{
|
||||
if (GeoData.getInstance().getHeight(baitX, baitY, baitZ) > baitZ)
|
||||
{
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
if (GeoData.getInstance().getHeight(baitX, baitY, player.getZ()) > baitZ)
|
||||
{
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
return baitZ;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +1,63 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
|
||||
/**
|
||||
* Alchemy transmute skill DTO.
|
||||
* @author Mobius
|
||||
*/
|
||||
public class L2AlchemySkill
|
||||
{
|
||||
private final List<ItemHolder> _ingredients;
|
||||
private final ItemHolder _product;
|
||||
|
||||
public L2AlchemySkill(List<ItemHolder> ingredients, ItemHolder product)
|
||||
{
|
||||
_ingredients = ingredients;
|
||||
_product = product;
|
||||
}
|
||||
|
||||
public List<ItemHolder> getIngridientItems()
|
||||
{
|
||||
return _ingredients;
|
||||
}
|
||||
|
||||
public ItemHolder getTransmutedItem()
|
||||
{
|
||||
return _product;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author bit
|
||||
*/
|
||||
public class FishingBaitData
|
||||
{
|
||||
private final int _itemId;
|
||||
private final int _level;
|
||||
private final double _chance;
|
||||
private final List<Integer> _rewards = new ArrayList<>();
|
||||
|
||||
public FishingBaitData(int itemId, int level, double chance)
|
||||
{
|
||||
_itemId = itemId;
|
||||
_level = level;
|
||||
_chance = chance;
|
||||
}
|
||||
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
public double getChance()
|
||||
{
|
||||
return _chance;
|
||||
}
|
||||
|
||||
public List<Integer> getRewards()
|
||||
{
|
||||
return _rewards;
|
||||
}
|
||||
|
||||
public void addReward(int itemId)
|
||||
{
|
||||
_rewards.add(itemId);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +1,58 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||
|
||||
/**
|
||||
* Fort Siege Spawn.
|
||||
* @author xban1x
|
||||
*/
|
||||
public final class FortSiegeSpawn extends Location implements IIdentifiable
|
||||
{
|
||||
private final int _npcId;
|
||||
private final int _fortId;
|
||||
private final int _id;
|
||||
|
||||
public FortSiegeSpawn(int fort_id, int x, int y, int z, int heading, int npc_id, int id)
|
||||
{
|
||||
super(x, y, z, heading);
|
||||
_fortId = fort_id;
|
||||
_npcId = npc_id;
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public int getFortId()
|
||||
{
|
||||
return _fortId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the NPC ID.
|
||||
* @return the NPC ID
|
||||
*/
|
||||
@Override
|
||||
public int getId()
|
||||
{
|
||||
return _npcId;
|
||||
}
|
||||
|
||||
public int getMessageId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||
|
||||
/**
|
||||
* Fort Siege Spawn.
|
||||
* @author xban1x
|
||||
*/
|
||||
public final class FortSiegeSpawn extends Location implements IIdentifiable
|
||||
{
|
||||
private final int _npcId;
|
||||
private final int _fortId;
|
||||
private final int _id;
|
||||
|
||||
public FortSiegeSpawn(int fort_id, int x, int y, int z, int heading, int npc_id, int id)
|
||||
{
|
||||
super(x, y, z, heading);
|
||||
_fortId = fort_id;
|
||||
_npcId = npc_id;
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public int getFortId()
|
||||
{
|
||||
return _fortId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the NPC ID.
|
||||
* @return the NPC ID
|
||||
*/
|
||||
@Override
|
||||
public int getId()
|
||||
{
|
||||
return _npcId;
|
||||
}
|
||||
|
||||
public int getMessageId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,83 +1,84 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.AttackType;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class Hit
|
||||
{
|
||||
private final int _targetId;
|
||||
private final int _damage;
|
||||
private final int _ssGrade;
|
||||
private int _flags = 0;
|
||||
|
||||
public Hit(L2Object target, int damage, boolean miss, boolean crit, byte shld, boolean soulshot, int ssGrade)
|
||||
{
|
||||
_targetId = target.getObjectId();
|
||||
_damage = damage;
|
||||
_ssGrade = ssGrade;
|
||||
|
||||
if (miss)
|
||||
{
|
||||
addMask(AttackType.MISSED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (crit)
|
||||
{
|
||||
addMask(AttackType.CRITICAL);
|
||||
}
|
||||
|
||||
if (soulshot)
|
||||
{
|
||||
addMask(AttackType.SHOT_USED);
|
||||
}
|
||||
|
||||
if (target.isInvul() || (shld > 0))
|
||||
{
|
||||
addMask(AttackType.BLOCKED);
|
||||
}
|
||||
}
|
||||
|
||||
private void addMask(AttackType type)
|
||||
{
|
||||
_flags |= type.getMask();
|
||||
}
|
||||
|
||||
public int getTargetId()
|
||||
{
|
||||
return _targetId;
|
||||
}
|
||||
|
||||
public int getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public int getFlags()
|
||||
{
|
||||
return _flags;
|
||||
}
|
||||
|
||||
public int getGrade()
|
||||
{
|
||||
return _ssGrade;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.AttackType;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class Hit
|
||||
{
|
||||
private final int _targetId;
|
||||
private final int _damage;
|
||||
private final int _ssGrade;
|
||||
private int _flags = 0;
|
||||
|
||||
public Hit(L2Object target, int damage, boolean miss, boolean crit, byte shld, boolean soulshot, int ssGrade)
|
||||
{
|
||||
_targetId = target.getObjectId();
|
||||
_damage = damage;
|
||||
_ssGrade = ssGrade;
|
||||
|
||||
if (miss)
|
||||
{
|
||||
addMask(AttackType.MISSED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (crit)
|
||||
{
|
||||
addMask(AttackType.CRITICAL);
|
||||
}
|
||||
|
||||
if (soulshot)
|
||||
{
|
||||
addMask(AttackType.SHOT_USED);
|
||||
}
|
||||
|
||||
if ((target.isCharacter() && ((L2Character) target).isHpBlocked()) || (shld > 0))
|
||||
{
|
||||
addMask(AttackType.BLOCKED);
|
||||
}
|
||||
}
|
||||
|
||||
private void addMask(AttackType type)
|
||||
{
|
||||
_flags |= type.getMask();
|
||||
}
|
||||
|
||||
public int getTargetId()
|
||||
{
|
||||
return _targetId;
|
||||
}
|
||||
|
||||
public int getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public int getFlags()
|
||||
{
|
||||
return _flags;
|
||||
}
|
||||
|
||||
public int getGrade()
|
||||
{
|
||||
return _ssGrade;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,421 +1,419 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.buylist.Product;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.items.L2WarehouseItem;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.ensoul.SoulCrystalOption;
|
||||
|
||||
/**
|
||||
* Get all information from L2ItemInstance to generate ItemInfo.
|
||||
*/
|
||||
public class ItemInfo
|
||||
{
|
||||
/** Identifier of the L2ItemInstance */
|
||||
private int _objectId;
|
||||
|
||||
/** The L2Item template of the L2ItemInstance */
|
||||
private L2Item _item;
|
||||
|
||||
/** The level of enchant on the L2ItemInstance */
|
||||
private int _enchant;
|
||||
|
||||
/** The augmentation of the item */
|
||||
private int _augmentation;
|
||||
|
||||
/** The quantity of L2ItemInstance */
|
||||
private long _count;
|
||||
|
||||
/** The price of the L2ItemInstance */
|
||||
private int _price;
|
||||
|
||||
/** The custom L2ItemInstance types (used loto, race tickets) */
|
||||
private int _type1;
|
||||
private int _type2;
|
||||
|
||||
/** If True the L2ItemInstance is equipped */
|
||||
private int _equipped;
|
||||
|
||||
/** The action to do clientside (1=ADD, 2=MODIFY, 3=REMOVE) */
|
||||
private int _change;
|
||||
|
||||
/** The mana of this item */
|
||||
private int _mana;
|
||||
private int _time;
|
||||
|
||||
private int _location;
|
||||
|
||||
private int _elemAtkType = -2;
|
||||
private int _elemAtkPower = 0;
|
||||
private final int[] _elemDefAttr =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
private int[] _option;
|
||||
private int _visualId;
|
||||
private long _visualExpiration;
|
||||
|
||||
private SoulCrystalOption[] _commonSoulCrystalOptions = new SoulCrystalOption[2];
|
||||
private SoulCrystalOption _specialSoulCrystalOption;
|
||||
|
||||
/**
|
||||
* Get all information from L2ItemInstance to generate ItemInfo.
|
||||
* @param item
|
||||
*/
|
||||
public ItemInfo(L2ItemInstance item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the Identifier of the L2ItemInstance
|
||||
_objectId = item.getObjectId();
|
||||
|
||||
// Get the L2Item of the L2ItemInstance
|
||||
_item = item.getItem();
|
||||
|
||||
// Get the enchant level of the L2ItemInstance
|
||||
_enchant = item.getEnchantLevel();
|
||||
|
||||
// Get the augmentation bonus
|
||||
_augmentation = item.isAugmented() ? item.getAugmentation().getAugmentationId() : 0;
|
||||
|
||||
// Get the quantity of the L2ItemInstance
|
||||
_count = item.getCount();
|
||||
|
||||
// Get custom item types (used loto, race tickets)
|
||||
_type1 = item.getCustomType1();
|
||||
_type2 = item.getCustomType2();
|
||||
|
||||
// Verify if the L2ItemInstance is equipped
|
||||
_equipped = item.isEquipped() ? 1 : 0;
|
||||
|
||||
// Get the action to do clientside
|
||||
switch (item.getLastChange())
|
||||
{
|
||||
case L2ItemInstance.ADDED:
|
||||
{
|
||||
_change = 1;
|
||||
break;
|
||||
}
|
||||
case L2ItemInstance.MODIFIED:
|
||||
{
|
||||
_change = 2;
|
||||
break;
|
||||
}
|
||||
case L2ItemInstance.REMOVED:
|
||||
{
|
||||
_change = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get shadow item mana
|
||||
_mana = item.getMana();
|
||||
_time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999;
|
||||
_location = item.getLocationSlot();
|
||||
|
||||
_elemAtkType = item.getAttackElementType();
|
||||
_elemAtkPower = item.getAttackElementPower();
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
_elemDefAttr[i] = item.getElementDefAttr(i);
|
||||
}
|
||||
_option = item.getEnchantOptions();
|
||||
_visualId = item.getVisualId();
|
||||
|
||||
_commonSoulCrystalOptions = item.getCommonSoulCrystalOptions();
|
||||
_specialSoulCrystalOption = item.getSpecialSoulCrystalOption();
|
||||
}
|
||||
|
||||
public ItemInfo(L2ItemInstance item, int change)
|
||||
{
|
||||
this(item);
|
||||
_change = change;
|
||||
_visualExpiration = item.getVisualLifeTime() > 0 ? (item.getVisualLifeTime() - System.currentTimeMillis()) / 1000 : 0;
|
||||
}
|
||||
|
||||
public ItemInfo(TradeItem item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the Identifier of the L2ItemInstance
|
||||
_objectId = item.getObjectId();
|
||||
|
||||
// Get the L2Item of the L2ItemInstance
|
||||
_item = item.getItem();
|
||||
|
||||
// Get the enchant level of the L2ItemInstance
|
||||
_enchant = item.getEnchant();
|
||||
|
||||
// Get the augmentation boni
|
||||
_augmentation = item.isAugmented() ? item.getAugmentation().getAugmentationId() : 0;
|
||||
|
||||
// Get the quantity of the L2ItemInstance
|
||||
_count = item.getCount();
|
||||
|
||||
// Get custom item types (used loto, race tickets)
|
||||
_type1 = item.getCustomType1();
|
||||
_type2 = item.getCustomType2();
|
||||
|
||||
// Verify if the L2ItemInstance is equipped
|
||||
_equipped = 0;
|
||||
|
||||
// Get the action to do clientside
|
||||
_change = 0;
|
||||
|
||||
// Get shadow item mana
|
||||
_mana = -1;
|
||||
_time = -9999;
|
||||
|
||||
_location = item.getLocationSlot();
|
||||
|
||||
_elemAtkType = item.getAttackElementType();
|
||||
_elemAtkPower = item.getAttackElementPower();
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
_elemDefAttr[i] = item.getElementDefAttr(i);
|
||||
}
|
||||
|
||||
_option = item.getEnchantOptions();
|
||||
_visualId = item.getVisualId();
|
||||
_commonSoulCrystalOptions = item.getCommonSoulCrystalOptions();
|
||||
_specialSoulCrystalOption = item.getSpecialSoulCrystalOption();
|
||||
}
|
||||
|
||||
public ItemInfo(Product item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the Identifier of the L2ItemInstance
|
||||
_objectId = 0;
|
||||
|
||||
// Get the L2Item of the L2ItemInstance
|
||||
_item = item.getItem();
|
||||
|
||||
// Get the enchant level of the L2ItemInstance
|
||||
_enchant = 0;
|
||||
|
||||
// Get the augmentation boni
|
||||
_augmentation = 0;
|
||||
|
||||
// Get the quantity of the L2ItemInstance
|
||||
_count = item.getCount();
|
||||
|
||||
// Get custom item types (used loto, race tickets)
|
||||
_type1 = 0;
|
||||
_type2 = 0;
|
||||
|
||||
// Verify if the L2ItemInstance is equipped
|
||||
_equipped = 0;
|
||||
|
||||
// Get the action to do clientside
|
||||
_change = 0;
|
||||
|
||||
// Get shadow item mana
|
||||
_mana = -1;
|
||||
_time = -9999;
|
||||
|
||||
_location = 0;
|
||||
}
|
||||
|
||||
public ItemInfo(L2WarehouseItem item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the Identifier of the L2ItemInstance
|
||||
_objectId = item.getObjectId();
|
||||
|
||||
// Get the L2Item of the L2ItemInstance
|
||||
_item = item.getItem();
|
||||
|
||||
// Get the enchant level of the L2ItemInstance
|
||||
_enchant = item.getEnchantLevel();
|
||||
|
||||
// Get the augmentation boni
|
||||
_augmentation = item.isAugmented() ? item.getAugmentationId() : 0;
|
||||
|
||||
// Get the quantity of the L2ItemInstance
|
||||
_count = item.getCount();
|
||||
|
||||
// Get custom item types (used loto, race tickets)
|
||||
_type1 = item.getCustomType1();
|
||||
_type2 = item.getCustomType2();
|
||||
|
||||
// Verify if the L2ItemInstance is equipped
|
||||
_equipped = 0;
|
||||
|
||||
// Get shadow item mana
|
||||
_mana = item.getMana();
|
||||
_time = item.getTime();
|
||||
_location = item.getLocationSlot();
|
||||
|
||||
_elemAtkType = item.getAttackElementType();
|
||||
_elemAtkPower = item.getAttackElementPower();
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
_elemDefAttr[i] = item.getElementDefAttr(i);
|
||||
}
|
||||
_option = item.getEnchantOptions();
|
||||
|
||||
_commonSoulCrystalOptions = item.getCommonSoulCrystalOptions();
|
||||
_specialSoulCrystalOption = item.getSpecialSoulCrystalOption();
|
||||
}
|
||||
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public L2Item getItem()
|
||||
{
|
||||
return _item;
|
||||
}
|
||||
|
||||
public int getEnchant()
|
||||
{
|
||||
return _enchant;
|
||||
}
|
||||
|
||||
public int getAugmentationBonus()
|
||||
{
|
||||
return _augmentation;
|
||||
}
|
||||
|
||||
public int get1stAugmentationId()
|
||||
{
|
||||
return 0x0000FFFF & getAugmentationBonus();
|
||||
}
|
||||
|
||||
public int get2ndAugmentationId()
|
||||
{
|
||||
return getAugmentationBonus() >> 16;
|
||||
}
|
||||
|
||||
public long getCount()
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
public int getPrice()
|
||||
{
|
||||
return _price;
|
||||
}
|
||||
|
||||
public int getCustomType1()
|
||||
{
|
||||
return _type1;
|
||||
}
|
||||
|
||||
public int getCustomType2()
|
||||
{
|
||||
return _type2;
|
||||
}
|
||||
|
||||
public int getEquipped()
|
||||
{
|
||||
return _equipped;
|
||||
}
|
||||
|
||||
public int getChange()
|
||||
{
|
||||
return _change;
|
||||
}
|
||||
|
||||
public int getMana()
|
||||
{
|
||||
return _mana;
|
||||
}
|
||||
|
||||
public int getTime()
|
||||
{
|
||||
return _time > 0 ? _time : _visualExpiration > 0 ? (int) _visualExpiration : -9999;
|
||||
}
|
||||
|
||||
public int getLocation()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
public int getAttackElementType()
|
||||
{
|
||||
return _elemAtkType;
|
||||
}
|
||||
|
||||
public int getAttackElementPower()
|
||||
{
|
||||
return _elemAtkPower;
|
||||
}
|
||||
|
||||
public int getElementDefAttr(byte i)
|
||||
{
|
||||
return _elemDefAttr[i];
|
||||
}
|
||||
|
||||
public int[] getEnchantOptions()
|
||||
{
|
||||
return _option;
|
||||
}
|
||||
|
||||
public int getVisualId()
|
||||
{
|
||||
return _visualId;
|
||||
}
|
||||
|
||||
public long getVisualExpiration()
|
||||
{
|
||||
return _visualExpiration;
|
||||
}
|
||||
|
||||
public SoulCrystalOption[] getCommonSoulCrystalOptions()
|
||||
{
|
||||
return _commonSoulCrystalOptions;
|
||||
}
|
||||
|
||||
public void setSoulCrystalOptions(SoulCrystalOption[] options)
|
||||
{
|
||||
_commonSoulCrystalOptions = options;
|
||||
}
|
||||
|
||||
public SoulCrystalOption getSpecialSoulCrystalOption()
|
||||
{
|
||||
return _specialSoulCrystalOption;
|
||||
}
|
||||
|
||||
public void setSpecialSoulCrystalOption(SoulCrystalOption option)
|
||||
{
|
||||
_specialSoulCrystalOption = option;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.AttributeType;
|
||||
import com.l2jmobius.gameserver.model.buylist.Product;
|
||||
import com.l2jmobius.gameserver.model.ensoul.EnsoulOption;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.items.L2WarehouseItem;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
|
||||
/**
|
||||
* Get all information from L2ItemInstance to generate ItemInfo.
|
||||
*/
|
||||
public class ItemInfo
|
||||
{
|
||||
/** Identifier of the L2ItemInstance */
|
||||
private int _objectId;
|
||||
|
||||
/** The L2Item template of the L2ItemInstance */
|
||||
private L2Item _item;
|
||||
|
||||
/** The level of enchant on the L2ItemInstance */
|
||||
private int _enchant;
|
||||
|
||||
/** The augmentation of the item */
|
||||
private int _augmentation;
|
||||
|
||||
/** The quantity of L2ItemInstance */
|
||||
private long _count;
|
||||
|
||||
/** The price of the L2ItemInstance */
|
||||
private int _price;
|
||||
|
||||
/** The custom L2ItemInstance types (used loto, race tickets) */
|
||||
private int _type1;
|
||||
private int _type2;
|
||||
|
||||
/** If True the L2ItemInstance is equipped */
|
||||
private int _equipped;
|
||||
|
||||
/** The action to do clientside (1=ADD, 2=MODIFY, 3=REMOVE) */
|
||||
private int _change;
|
||||
|
||||
/** The mana of this item */
|
||||
private int _mana;
|
||||
private int _time;
|
||||
|
||||
private int _location;
|
||||
|
||||
private byte _elemAtkType = -2;
|
||||
private int _elemAtkPower = 0;
|
||||
private final int[] _elemDefAttr =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
private int[] _option;
|
||||
private Collection<EnsoulOption> _soulCrystalOptions;
|
||||
private Collection<EnsoulOption> _soulCrystalSpecialOptions;
|
||||
private int _visualId;
|
||||
private long _visualExpiration;
|
||||
|
||||
/**
|
||||
* Get all information from L2ItemInstance to generate ItemInfo.
|
||||
* @param item
|
||||
*/
|
||||
public ItemInfo(L2ItemInstance item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the Identifier of the L2ItemInstance
|
||||
_objectId = item.getObjectId();
|
||||
|
||||
// Get the L2Item of the L2ItemInstance
|
||||
_item = item.getItem();
|
||||
|
||||
// Get the enchant level of the L2ItemInstance
|
||||
_enchant = item.getEnchantLevel();
|
||||
|
||||
// Get the augmentation boni
|
||||
if (item.isAugmented())
|
||||
{
|
||||
_augmentation = item.getAugmentation().getId();
|
||||
}
|
||||
else
|
||||
{
|
||||
_augmentation = 0;
|
||||
}
|
||||
|
||||
// Get the quantity of the L2ItemInstance
|
||||
_count = item.getCount();
|
||||
|
||||
// Get custom item types (used loto, race tickets)
|
||||
_type1 = item.getCustomType1();
|
||||
_type2 = item.getCustomType2();
|
||||
|
||||
// Verify if the L2ItemInstance is equipped
|
||||
_equipped = item.isEquipped() ? 1 : 0;
|
||||
|
||||
// Get the action to do clientside
|
||||
switch (item.getLastChange())
|
||||
{
|
||||
case (L2ItemInstance.ADDED):
|
||||
{
|
||||
_change = 1;
|
||||
break;
|
||||
}
|
||||
case (L2ItemInstance.MODIFIED):
|
||||
{
|
||||
_change = 2;
|
||||
break;
|
||||
}
|
||||
case (L2ItemInstance.REMOVED):
|
||||
{
|
||||
_change = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get shadow item mana
|
||||
_mana = item.getMana();
|
||||
_time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999;
|
||||
_location = item.getLocationSlot();
|
||||
|
||||
_elemAtkType = item.getAttackAttributeType().getClientId();
|
||||
_elemAtkPower = item.getAttackAttributePower();
|
||||
for (AttributeType type : AttributeType.ATTRIBUTE_TYPES)
|
||||
{
|
||||
_elemDefAttr[type.getClientId()] = item.getDefenceAttribute(type);
|
||||
}
|
||||
_option = item.getEnchantOptions();
|
||||
_soulCrystalOptions = item.getSpecialAbilities();
|
||||
_soulCrystalSpecialOptions = item.getAdditionalSpecialAbilities();
|
||||
_visualId = item.getVisualId();
|
||||
}
|
||||
|
||||
public ItemInfo(L2ItemInstance item, int change)
|
||||
{
|
||||
this(item);
|
||||
_change = change;
|
||||
_visualExpiration = item.getVisualLifeTime() > 0 ? (item.getVisualLifeTime() - System.currentTimeMillis()) / 1000 : 0;
|
||||
}
|
||||
|
||||
public ItemInfo(TradeItem item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the Identifier of the L2ItemInstance
|
||||
_objectId = item.getObjectId();
|
||||
|
||||
// Get the L2Item of the L2ItemInstance
|
||||
_item = item.getItem();
|
||||
|
||||
// Get the enchant level of the L2ItemInstance
|
||||
_enchant = item.getEnchant();
|
||||
|
||||
// Get the augmentation boni
|
||||
_augmentation = 0;
|
||||
|
||||
// Get the quantity of the L2ItemInstance
|
||||
_count = item.getCount();
|
||||
|
||||
// Get custom item types (used loto, race tickets)
|
||||
_type1 = item.getCustomType1();
|
||||
_type2 = item.getCustomType2();
|
||||
|
||||
// Verify if the L2ItemInstance is equipped
|
||||
_equipped = 0;
|
||||
|
||||
// Get the action to do clientside
|
||||
_change = 0;
|
||||
|
||||
// Get shadow item mana
|
||||
_mana = -1;
|
||||
_time = -9999;
|
||||
|
||||
_location = item.getLocationSlot();
|
||||
|
||||
_elemAtkType = item.getAttackElementType();
|
||||
_elemAtkPower = item.getAttackElementPower();
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
_elemDefAttr[i] = item.getElementDefAttr(i);
|
||||
}
|
||||
|
||||
_option = item.getEnchantOptions();
|
||||
_soulCrystalOptions = item.getSoulCrystalOptions();
|
||||
_soulCrystalOptions = item.getSoulCrystalSpecialOptions();
|
||||
_visualId = item.getVisualId();
|
||||
}
|
||||
|
||||
public ItemInfo(Product item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the Identifier of the L2ItemInstance
|
||||
_objectId = 0;
|
||||
|
||||
// Get the L2Item of the L2ItemInstance
|
||||
_item = item.getItem();
|
||||
|
||||
// Get the enchant level of the L2ItemInstance
|
||||
_enchant = 0;
|
||||
|
||||
// Get the augmentation boni
|
||||
_augmentation = 0;
|
||||
|
||||
// Get the quantity of the L2ItemInstance
|
||||
_count = item.getCount();
|
||||
|
||||
// Get custom item types (used loto, race tickets)
|
||||
_type1 = item.getItem().getType1();
|
||||
_type2 = item.getItem().getType2();
|
||||
|
||||
// Verify if the L2ItemInstance is equipped
|
||||
_equipped = 0;
|
||||
|
||||
// Get the action to do clientside
|
||||
_change = 0;
|
||||
|
||||
// Get shadow item mana
|
||||
_mana = -1;
|
||||
_time = -9999;
|
||||
|
||||
_location = 0;
|
||||
|
||||
_soulCrystalOptions = Collections.emptyList();
|
||||
_soulCrystalSpecialOptions = Collections.emptyList();
|
||||
}
|
||||
|
||||
public ItemInfo(L2WarehouseItem item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the Identifier of the L2ItemInstance
|
||||
_objectId = item.getObjectId();
|
||||
|
||||
// Get the L2Item of the L2ItemInstance
|
||||
_item = item.getItem();
|
||||
|
||||
// Get the enchant level of the L2ItemInstance
|
||||
_enchant = item.getEnchantLevel();
|
||||
|
||||
// Get the augmentation boni
|
||||
if (item.isAugmented())
|
||||
{
|
||||
_augmentation = item.getAugmentationId();
|
||||
}
|
||||
else
|
||||
{
|
||||
_augmentation = 0;
|
||||
}
|
||||
|
||||
// Get the quantity of the L2ItemInstance
|
||||
_count = item.getCount();
|
||||
|
||||
// Get custom item types (used loto, race tickets)
|
||||
_type1 = item.getCustomType1();
|
||||
_type2 = item.getCustomType2();
|
||||
|
||||
// Verify if the L2ItemInstance is equipped
|
||||
_equipped = 0;
|
||||
|
||||
// Get shadow item mana
|
||||
_mana = item.getMana();
|
||||
_time = item.getTime();
|
||||
_location = item.getLocationSlot();
|
||||
|
||||
_elemAtkType = item.getAttackElementType();
|
||||
_elemAtkPower = item.getAttackElementPower();
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
_elemDefAttr[i] = item.getElementDefAttr(i);
|
||||
}
|
||||
_option = item.getEnchantOptions();
|
||||
_soulCrystalOptions = item.getSoulCrystalOptions();
|
||||
_soulCrystalOptions = item.getSoulCrystalSpecialOptions();
|
||||
}
|
||||
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public L2Item getItem()
|
||||
{
|
||||
return _item;
|
||||
}
|
||||
|
||||
public int getEnchant()
|
||||
{
|
||||
return _enchant;
|
||||
}
|
||||
|
||||
public int getAugmentationBonus()
|
||||
{
|
||||
return _augmentation;
|
||||
}
|
||||
|
||||
public long getCount()
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
public int getPrice()
|
||||
{
|
||||
return _price;
|
||||
}
|
||||
|
||||
public int getCustomType1()
|
||||
{
|
||||
return _type1;
|
||||
}
|
||||
|
||||
public int getCustomType2()
|
||||
{
|
||||
return _type2;
|
||||
}
|
||||
|
||||
public int getEquipped()
|
||||
{
|
||||
return _equipped;
|
||||
}
|
||||
|
||||
public int getChange()
|
||||
{
|
||||
return _change;
|
||||
}
|
||||
|
||||
public int getMana()
|
||||
{
|
||||
return _mana;
|
||||
}
|
||||
|
||||
public int getTime()
|
||||
{
|
||||
return _time > 0 ? _time : _visualExpiration > 0 ? (int) _visualExpiration : -9999;
|
||||
}
|
||||
|
||||
public int getLocation()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
public int getAttackElementType()
|
||||
{
|
||||
return _elemAtkType;
|
||||
}
|
||||
|
||||
public int getAttackElementPower()
|
||||
{
|
||||
return _elemAtkPower;
|
||||
}
|
||||
|
||||
public int getElementDefAttr(byte i)
|
||||
{
|
||||
return _elemDefAttr[i];
|
||||
}
|
||||
|
||||
public int[] getEnchantOptions()
|
||||
{
|
||||
return _option;
|
||||
}
|
||||
|
||||
public int getVisualId()
|
||||
{
|
||||
return _visualId;
|
||||
}
|
||||
|
||||
public Collection<EnsoulOption> getSoulCrystalOptions()
|
||||
{
|
||||
return _soulCrystalOptions;
|
||||
}
|
||||
|
||||
public Collection<EnsoulOption> getSoulCrystalSpecialOptions()
|
||||
{
|
||||
return _soulCrystalSpecialOptions;
|
||||
}
|
||||
|
||||
public long getVisualExpiration()
|
||||
{
|
||||
return _visualExpiration;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,80 +1,88 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ItemRequest
|
||||
{
|
||||
int _objectId;
|
||||
int _itemId;
|
||||
long _count;
|
||||
long _price;
|
||||
|
||||
public ItemRequest(int objectId, long count, long price)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_count = count;
|
||||
_price = price;
|
||||
}
|
||||
|
||||
public ItemRequest(int objectId, int itemId, long count, long price)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_itemId = itemId;
|
||||
_count = count;
|
||||
_price = price;
|
||||
}
|
||||
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
public void setCount(long count)
|
||||
{
|
||||
_count = count;
|
||||
}
|
||||
|
||||
public long getCount()
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
public long getPrice()
|
||||
{
|
||||
return _price;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
return (this == obj) || ((obj instanceof ItemRequest) && (_objectId != ((ItemRequest) obj)._objectId));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ItemRequest
|
||||
{
|
||||
int _objectId;
|
||||
int _itemId;
|
||||
long _count;
|
||||
long _price;
|
||||
|
||||
public ItemRequest(int objectId, long count, long price)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_count = count;
|
||||
_price = price;
|
||||
}
|
||||
|
||||
public ItemRequest(int objectId, int itemId, long count, long price)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_itemId = itemId;
|
||||
_count = count;
|
||||
_price = price;
|
||||
}
|
||||
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
public void setCount(long count)
|
||||
{
|
||||
_count = count;
|
||||
}
|
||||
|
||||
public long getCount()
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
public long getPrice()
|
||||
{
|
||||
return _price;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ItemRequest))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (_objectId != ((ItemRequest) obj)._objectId);
|
||||
}
|
||||
}
|
||||
|
||||
44
trunk/java/com/l2jmobius/gameserver/model/KeyValuePair.java
Normal file
44
trunk/java/com/l2jmobius/gameserver/model/KeyValuePair.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
* @param <K>
|
||||
* @param <V>
|
||||
*/
|
||||
public class KeyValuePair<K, V>
|
||||
{
|
||||
private final K _key;
|
||||
private final V _value;
|
||||
|
||||
public KeyValuePair(K key, V value)
|
||||
{
|
||||
_key = key;
|
||||
_value = value;
|
||||
}
|
||||
|
||||
public K getKey()
|
||||
{
|
||||
return _key;
|
||||
}
|
||||
|
||||
public V getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
@@ -1,215 +1,237 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
*/
|
||||
public class L2AccessLevel
|
||||
{
|
||||
/** The access level. */
|
||||
private int _accessLevel = 0;
|
||||
/** The access level name. */
|
||||
private String _name = null;
|
||||
/** Child access levels. */
|
||||
private L2AccessLevel _childsAccessLevel = null;
|
||||
/** Child access levels. */
|
||||
private int _child = 0;
|
||||
/** The name color for the access level. */
|
||||
private int _nameColor = 0;
|
||||
/** The title color for the access level. */
|
||||
private int _titleColor = 0;
|
||||
/** Flag to determine if the access level has GM access. */
|
||||
private boolean _isGm = false;
|
||||
/** Flag for peace zone attack */
|
||||
private boolean _allowPeaceAttack = false;
|
||||
/** Flag for fixed res */
|
||||
private boolean _allowFixedRes = false;
|
||||
/** Flag for transactions */
|
||||
private boolean _allowTransaction = false;
|
||||
/** Flag for AltG commands */
|
||||
private boolean _allowAltG = false;
|
||||
/** Flag to give damage */
|
||||
private boolean _giveDamage = false;
|
||||
/** Flag to take aggro */
|
||||
private boolean _takeAggro = false;
|
||||
/** Flag to gain exp in party */
|
||||
private boolean _gainExp = false;
|
||||
|
||||
public L2AccessLevel(StatsSet set)
|
||||
{
|
||||
_accessLevel = set.getInt("level");
|
||||
_name = set.getString("name");
|
||||
_nameColor = Integer.decode("0x" + set.getString("nameColor", "FFFFFF"));
|
||||
_titleColor = Integer.decode("0x" + set.getString("titleColor", "FFFFFF"));
|
||||
_child = set.getInt("childAccess", 0);
|
||||
_isGm = set.getBoolean("isGM", false);
|
||||
_allowPeaceAttack = set.getBoolean("allowPeaceAttack", false);
|
||||
_allowFixedRes = set.getBoolean("allowFixedRes", false);
|
||||
_allowTransaction = set.getBoolean("allowTransaction", true);
|
||||
_allowAltG = set.getBoolean("allowAltg", false);
|
||||
_giveDamage = set.getBoolean("giveDamage", true);
|
||||
_takeAggro = set.getBoolean("takeAggro", true);
|
||||
_gainExp = set.getBoolean("gainExp", true);
|
||||
}
|
||||
|
||||
public L2AccessLevel()
|
||||
{
|
||||
_accessLevel = 0;
|
||||
_name = "User";
|
||||
_nameColor = Integer.decode("0xFFFFFF");
|
||||
_titleColor = Integer.decode("0xFFFFFF");
|
||||
_child = 0;
|
||||
_isGm = false;
|
||||
_allowPeaceAttack = false;
|
||||
_allowFixedRes = false;
|
||||
_allowTransaction = true;
|
||||
_allowAltG = false;
|
||||
_giveDamage = true;
|
||||
_takeAggro = true;
|
||||
_gainExp = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the access level.
|
||||
* @return the access level
|
||||
*/
|
||||
public int getLevel()
|
||||
{
|
||||
return _accessLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the access level name.
|
||||
* @return the access level name
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name color of the access level.
|
||||
* @return the name color for the access level
|
||||
*/
|
||||
public int getNameColor()
|
||||
{
|
||||
return _nameColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the title color color of the access level.
|
||||
* @return the title color for the access level
|
||||
*/
|
||||
public int getTitleColor()
|
||||
{
|
||||
return _titleColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if the access level has GM access or not.
|
||||
* @return {@code true} if access level have GM access, otherwise {@code false}
|
||||
*/
|
||||
public boolean isGm()
|
||||
{
|
||||
return _isGm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if the access level is allowed to attack in peace zone or not.
|
||||
* @return {@code true} if the access level is allowed to attack in peace zone, otherwise {@code false}
|
||||
*/
|
||||
public boolean allowPeaceAttack()
|
||||
{
|
||||
return _allowPeaceAttack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if the access level is allowed to use fixed resurrection or not.
|
||||
* @return {@ode true} if the access level is allowed to use fixed resurrection, otherwise {@code false}
|
||||
*/
|
||||
public boolean allowFixedRes()
|
||||
{
|
||||
return _allowFixedRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if the access level is allowed to perform transactions or not.
|
||||
* @return {@ode true} if access level is allowed to perform transactions, otherwise {@code false}
|
||||
*/
|
||||
public boolean allowTransaction()
|
||||
{
|
||||
return _allowTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if the access level is allowed to use AltG commands or not.
|
||||
* @return {@ode true} if access level is allowed to use AltG commands, otherwise {@code false}
|
||||
*/
|
||||
public boolean allowAltG()
|
||||
{
|
||||
return _allowAltG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if the access level can give damage or not.
|
||||
* @return {@ode true} if the access level can give damage, otherwise {@code false}
|
||||
*/
|
||||
public boolean canGiveDamage()
|
||||
{
|
||||
return _giveDamage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if the access level can take aggro or not.
|
||||
* @return {@ode true} if the access level can take aggro, otherwise {@code false}
|
||||
*/
|
||||
public boolean canTakeAggro()
|
||||
{
|
||||
return _takeAggro;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if the access level can gain exp or not.
|
||||
* @return {@ode true} if the access level can gain exp, otherwise {@code false}
|
||||
*/
|
||||
public boolean canGainExp()
|
||||
{
|
||||
return _gainExp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the access level contains allowedAccess as child.
|
||||
* @param accessLevel the parent access level
|
||||
* @return {@ode true} if a child access level is equals to allowedAccess, otherwise {@code false}
|
||||
*/
|
||||
public boolean hasChildAccess(L2AccessLevel accessLevel)
|
||||
{
|
||||
if (_childsAccessLevel == null)
|
||||
{
|
||||
if (_child <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_childsAccessLevel = AdminData.getInstance().getAccessLevel(_child);
|
||||
}
|
||||
return (_childsAccessLevel.getLevel() == accessLevel.getLevel()) || _childsAccessLevel.hasChildAccess(accessLevel);
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
*/
|
||||
public class L2AccessLevel
|
||||
{
|
||||
/**
|
||||
* The access level<br>
|
||||
*/
|
||||
private int _accessLevel = 0;
|
||||
/**
|
||||
* The access level name<br>
|
||||
*/
|
||||
private String _name = null;
|
||||
/** Child access levels */
|
||||
L2AccessLevel _childsAccessLevel = null;
|
||||
/** Child access levels */
|
||||
private int _child = 0;
|
||||
/**
|
||||
* The name color for the access level<br>
|
||||
*/
|
||||
private int _nameColor = 0;
|
||||
/**
|
||||
* The title color for the access level<br>
|
||||
*/
|
||||
private int _titleColor = 0;
|
||||
/**
|
||||
* Flag to determine if the access level has gm access<br>
|
||||
*/
|
||||
private boolean _isGm = false;
|
||||
/** Flag for peace zone attack */
|
||||
private boolean _allowPeaceAttack = false;
|
||||
/** Flag for fixed res */
|
||||
private boolean _allowFixedRes = false;
|
||||
/** Flag for transactions */
|
||||
private boolean _allowTransaction = false;
|
||||
/** Flag for AltG commands */
|
||||
private boolean _allowAltG = false;
|
||||
/** Flag to give damage */
|
||||
private boolean _giveDamage = false;
|
||||
/** Flag to take aggro */
|
||||
private boolean _takeAggro = false;
|
||||
/** Flag to gain exp in party */
|
||||
private boolean _gainExp = false;
|
||||
|
||||
public L2AccessLevel(StatsSet set)
|
||||
{
|
||||
_accessLevel = set.getInt("level");
|
||||
_name = set.getString("name");
|
||||
_nameColor = Integer.decode("0x" + set.getString("nameColor", "FFFFFF"));
|
||||
_titleColor = Integer.decode("0x" + set.getString("titleColor", "FFFFFF"));
|
||||
_child = set.getInt("childAccess", 0);
|
||||
_isGm = set.getBoolean("isGM", false);
|
||||
_allowPeaceAttack = set.getBoolean("allowPeaceAttack", false);
|
||||
_allowFixedRes = set.getBoolean("allowFixedRes", false);
|
||||
_allowTransaction = set.getBoolean("allowTransaction", true);
|
||||
_allowAltG = set.getBoolean("allowAltg", false);
|
||||
_giveDamage = set.getBoolean("giveDamage", true);
|
||||
_takeAggro = set.getBoolean("takeAggro", true);
|
||||
_gainExp = set.getBoolean("gainExp", true);
|
||||
}
|
||||
|
||||
public L2AccessLevel()
|
||||
{
|
||||
_accessLevel = 0;
|
||||
_name = "User";
|
||||
_nameColor = Integer.decode("0xFFFFFF");
|
||||
_titleColor = Integer.decode("0xFFFFFF");
|
||||
_child = 0;
|
||||
_isGm = false;
|
||||
_allowPeaceAttack = false;
|
||||
_allowFixedRes = false;
|
||||
_allowTransaction = true;
|
||||
_allowAltG = false;
|
||||
_giveDamage = true;
|
||||
_takeAggro = true;
|
||||
_gainExp = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the access level<br>
|
||||
* <br>
|
||||
* @return int: access level<br>
|
||||
*/
|
||||
public int getLevel()
|
||||
{
|
||||
return _accessLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the access level name<br>
|
||||
* <br>
|
||||
* @return String: access level name<br>
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name color of the access level<br>
|
||||
* <br>
|
||||
* @return int: the name color for the access level<br>
|
||||
*/
|
||||
public int getNameColor()
|
||||
{
|
||||
return _nameColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the title color color of the access level<br>
|
||||
* <br>
|
||||
* @return int: the title color for the access level<br>
|
||||
*/
|
||||
public int getTitleColor()
|
||||
{
|
||||
return _titleColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retuns if the access level has gm access or not<br>
|
||||
* <br>
|
||||
* @return boolean: true if access level have gm access, otherwise false<br>
|
||||
*/
|
||||
public boolean isGm()
|
||||
{
|
||||
return _isGm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the access level is allowed to attack in peace zone or not<br>
|
||||
* <br>
|
||||
* @return boolean: true if the access level is allowed to attack in peace zone, otherwise false<br>
|
||||
*/
|
||||
public boolean allowPeaceAttack()
|
||||
{
|
||||
return _allowPeaceAttack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retruns if the access level is allowed to use fixed res or not<br>
|
||||
* <br>
|
||||
* @return true if the access level is allowed to use fixed res, otherwise false<br>
|
||||
*/
|
||||
public boolean allowFixedRes()
|
||||
{
|
||||
return _allowFixedRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the access level is allowed to perform transactions or not<br>
|
||||
* <br>
|
||||
* @return boolean: true if access level is allowed to perform transactions, otherwise false<br>
|
||||
*/
|
||||
public boolean allowTransaction()
|
||||
{
|
||||
return _allowTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the access level is allowed to use AltG commands or not<br>
|
||||
* <br>
|
||||
* @return boolean: true if access level is allowed to use AltG commands, otherwise false<br>
|
||||
*/
|
||||
public boolean allowAltG()
|
||||
{
|
||||
return _allowAltG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the access level can give damage or not<br>
|
||||
* <br>
|
||||
* @return boolean: true if the access level can give damage, otherwise false<br>
|
||||
*/
|
||||
public boolean canGiveDamage()
|
||||
{
|
||||
return _giveDamage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the access level can take aggro or not<br>
|
||||
* <br>
|
||||
* @return boolean: true if the access level can take aggro, otherwise false<br>
|
||||
*/
|
||||
public boolean canTakeAggro()
|
||||
{
|
||||
return _takeAggro;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the access level can gain exp or not<br>
|
||||
* <br>
|
||||
* @return boolean: true if the access level can gain exp, otherwise false<br>
|
||||
*/
|
||||
public boolean canGainExp()
|
||||
{
|
||||
return _gainExp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the access level contains allowedAccess as child<br>
|
||||
* @param accessLevel as AccessLevel<br>
|
||||
* @return boolean: true if a child access level is equals to allowedAccess, otherwise false<br>
|
||||
*/
|
||||
public boolean hasChildAccess(L2AccessLevel accessLevel)
|
||||
{
|
||||
if (_childsAccessLevel == null)
|
||||
{
|
||||
if (_child <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_childsAccessLevel = AdminData.getInstance().getAccessLevel(_child);
|
||||
}
|
||||
return (_childsAccessLevel != null) && ((_childsAccessLevel.getLevel() == accessLevel.getLevel()) || _childsAccessLevel.hasChildAccess(accessLevel));
|
||||
}
|
||||
}
|
||||
@@ -1,69 +1,69 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
*/
|
||||
public class L2AdminCommandAccessRight
|
||||
{
|
||||
private final String _adminCommand;
|
||||
private final int _accessLevel;
|
||||
private final boolean _requireConfirm;
|
||||
|
||||
public L2AdminCommandAccessRight(StatsSet set)
|
||||
{
|
||||
_adminCommand = set.getString("command");
|
||||
_requireConfirm = set.getBoolean("confirmDlg", false);
|
||||
_accessLevel = set.getInt("accessLevel", 7);
|
||||
}
|
||||
|
||||
public L2AdminCommandAccessRight(String command, boolean confirm, int level)
|
||||
{
|
||||
_adminCommand = command;
|
||||
_requireConfirm = confirm;
|
||||
_accessLevel = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the admin command the access right belongs to
|
||||
*/
|
||||
public String getAdminCommand()
|
||||
{
|
||||
return _adminCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param characterAccessLevel
|
||||
* @return {@code true} if characterAccessLevel is allowed to use the admin command which belongs to this access right, {@code false} otherwise
|
||||
*/
|
||||
public boolean hasAccess(L2AccessLevel characterAccessLevel)
|
||||
{
|
||||
final L2AccessLevel accessLevel = AdminData.getInstance().getAccessLevel(_accessLevel);
|
||||
return (accessLevel.getLevel() == characterAccessLevel.getLevel()) || characterAccessLevel.hasChildAccess(accessLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if admin command requires confirmation before execution, {@code false} otherwise.
|
||||
*/
|
||||
public boolean getRequireConfirm()
|
||||
{
|
||||
return _requireConfirm;
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
*/
|
||||
public class L2AdminCommandAccessRight
|
||||
{
|
||||
private final String _adminCommand;
|
||||
private final int _accessLevel;
|
||||
private final boolean _requireConfirm;
|
||||
|
||||
public L2AdminCommandAccessRight(StatsSet set)
|
||||
{
|
||||
_adminCommand = set.getString("command");
|
||||
_requireConfirm = set.getBoolean("confirmDlg", false);
|
||||
_accessLevel = set.getInt("accessLevel", 7);
|
||||
}
|
||||
|
||||
public L2AdminCommandAccessRight(String command, boolean confirm, int level)
|
||||
{
|
||||
_adminCommand = command;
|
||||
_requireConfirm = confirm;
|
||||
_accessLevel = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the admin command the access right belongs to
|
||||
*/
|
||||
public String getAdminCommand()
|
||||
{
|
||||
return _adminCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param characterAccessLevel
|
||||
* @return {@code true} if characterAccessLevel is allowed to use the admin command which belongs to this access right, {@code false} otherwise
|
||||
*/
|
||||
public boolean hasAccess(L2AccessLevel characterAccessLevel)
|
||||
{
|
||||
final L2AccessLevel accessLevel = AdminData.getInstance().getAccessLevel(_accessLevel);
|
||||
return (accessLevel != null) && ((accessLevel.getLevel() == characterAccessLevel.getLevel()) || characterAccessLevel.hasChildAccess(accessLevel));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if admin command requires confirmation before execution, {@code false} otherwise.
|
||||
*/
|
||||
public boolean getRequireConfirm()
|
||||
{
|
||||
return _requireConfirm;
|
||||
}
|
||||
}
|
||||
@@ -1,416 +1,219 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.ArmorsetSkillHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
|
||||
/**
|
||||
* @author Luno
|
||||
*/
|
||||
public final class L2ArmorSet
|
||||
{
|
||||
private boolean _isVisual;
|
||||
private int _minimumPieces;
|
||||
private final List<Integer> _chests;
|
||||
private final List<Integer> _legs;
|
||||
private final List<Integer> _head;
|
||||
private final List<Integer> _gloves;
|
||||
private final List<Integer> _feet;
|
||||
private final List<Integer> _shield;
|
||||
|
||||
private final List<ArmorsetSkillHolder> _skills;
|
||||
private final List<SkillHolder> _shieldSkills;
|
||||
private final List<ArmorsetSkillHolder> _enchantSkills;
|
||||
|
||||
private int _con;
|
||||
private int _dex;
|
||||
private int _str;
|
||||
private int _men;
|
||||
private int _wit;
|
||||
private int _int;
|
||||
private int _luc;
|
||||
private int _cha;
|
||||
|
||||
private static final int[] ARMORSET_SLOTS = new int[]
|
||||
{
|
||||
Inventory.PAPERDOLL_CHEST,
|
||||
Inventory.PAPERDOLL_LEGS,
|
||||
Inventory.PAPERDOLL_HEAD,
|
||||
Inventory.PAPERDOLL_GLOVES,
|
||||
Inventory.PAPERDOLL_FEET
|
||||
};
|
||||
|
||||
public L2ArmorSet()
|
||||
{
|
||||
_chests = new ArrayList<>();
|
||||
_legs = new ArrayList<>();
|
||||
_head = new ArrayList<>();
|
||||
_gloves = new ArrayList<>();
|
||||
_feet = new ArrayList<>();
|
||||
_shield = new ArrayList<>();
|
||||
|
||||
_skills = new ArrayList<>();
|
||||
_shieldSkills = new ArrayList<>();
|
||||
_enchantSkills = new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean isVisual()
|
||||
{
|
||||
return _isVisual;
|
||||
}
|
||||
|
||||
public void setIsVisual(boolean val)
|
||||
{
|
||||
_isVisual = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the minimum amount of pieces equipped to form a set.
|
||||
*/
|
||||
public int getMinimumPieces()
|
||||
{
|
||||
return _minimumPieces;
|
||||
}
|
||||
|
||||
public void setMinimumPieces(int pieces)
|
||||
{
|
||||
_minimumPieces = pieces;
|
||||
}
|
||||
|
||||
public void addChest(int id)
|
||||
{
|
||||
_chests.add(id);
|
||||
}
|
||||
|
||||
public void addLegs(int id)
|
||||
{
|
||||
_legs.add(id);
|
||||
}
|
||||
|
||||
public void addHead(int id)
|
||||
{
|
||||
_head.add(id);
|
||||
}
|
||||
|
||||
public void addGloves(int id)
|
||||
{
|
||||
_gloves.add(id);
|
||||
}
|
||||
|
||||
public void addFeet(int id)
|
||||
{
|
||||
_feet.add(id);
|
||||
}
|
||||
|
||||
public void addShield(int id)
|
||||
{
|
||||
_shield.add(id);
|
||||
}
|
||||
|
||||
public void addSkill(ArmorsetSkillHolder holder)
|
||||
{
|
||||
_skills.add(holder);
|
||||
}
|
||||
|
||||
public void addShieldSkill(SkillHolder holder)
|
||||
{
|
||||
_shieldSkills.add(holder);
|
||||
}
|
||||
|
||||
public void addEnchantSkill(ArmorsetSkillHolder holder)
|
||||
{
|
||||
_enchantSkills.add(holder);
|
||||
}
|
||||
|
||||
public void addCon(int val)
|
||||
{
|
||||
_con = val;
|
||||
}
|
||||
|
||||
public void addDex(int val)
|
||||
{
|
||||
_dex = val;
|
||||
}
|
||||
|
||||
public void addStr(int val)
|
||||
{
|
||||
_str = val;
|
||||
}
|
||||
|
||||
public void addMen(int val)
|
||||
{
|
||||
_men = val;
|
||||
}
|
||||
|
||||
public void addWit(int val)
|
||||
{
|
||||
_wit = val;
|
||||
}
|
||||
|
||||
public void addInt(int val)
|
||||
{
|
||||
_int = val;
|
||||
}
|
||||
|
||||
public void addLuc(int val)
|
||||
{
|
||||
_luc = val;
|
||||
}
|
||||
|
||||
public void addCha(int val)
|
||||
{
|
||||
_cha = val;
|
||||
}
|
||||
|
||||
public int getPiecesCount(L2PcInstance player)
|
||||
{
|
||||
final Inventory inv = player.getInventory();
|
||||
|
||||
final L2ItemInstance legsItem = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS);
|
||||
final L2ItemInstance headItem = inv.getPaperdollItem(Inventory.PAPERDOLL_HEAD);
|
||||
final L2ItemInstance glovesItem = inv.getPaperdollItem(Inventory.PAPERDOLL_GLOVES);
|
||||
final L2ItemInstance feetItem = inv.getPaperdollItem(Inventory.PAPERDOLL_FEET);
|
||||
|
||||
int legs = 0;
|
||||
int head = 0;
|
||||
int gloves = 0;
|
||||
int feet = 0;
|
||||
|
||||
if (legsItem != null)
|
||||
{
|
||||
legs = legsItem.getId();
|
||||
}
|
||||
if (headItem != null)
|
||||
{
|
||||
head = headItem.getId();
|
||||
}
|
||||
if (glovesItem != null)
|
||||
{
|
||||
gloves = glovesItem.getId();
|
||||
}
|
||||
if (feetItem != null)
|
||||
{
|
||||
feet = feetItem.getId();
|
||||
}
|
||||
|
||||
return getPiecesCount(legs, head, gloves, feet);
|
||||
}
|
||||
|
||||
public int getPiecesCount(int legs, int head, int gloves, int feet)
|
||||
{
|
||||
int pieces = 1;
|
||||
if (_legs.contains(legs))
|
||||
{
|
||||
pieces++;
|
||||
}
|
||||
if (_head.contains(head))
|
||||
{
|
||||
pieces++;
|
||||
}
|
||||
if (_gloves.contains(gloves))
|
||||
{
|
||||
pieces++;
|
||||
}
|
||||
if (_feet.contains(feet))
|
||||
{
|
||||
pieces++;
|
||||
}
|
||||
|
||||
return pieces;
|
||||
}
|
||||
|
||||
public boolean containItem(int slot, int itemId)
|
||||
{
|
||||
switch (slot)
|
||||
{
|
||||
case Inventory.PAPERDOLL_CHEST:
|
||||
{
|
||||
return _chests.contains(itemId);
|
||||
}
|
||||
case Inventory.PAPERDOLL_LEGS:
|
||||
{
|
||||
return _legs.contains(itemId);
|
||||
}
|
||||
case Inventory.PAPERDOLL_HEAD:
|
||||
{
|
||||
return _head.contains(itemId);
|
||||
}
|
||||
case Inventory.PAPERDOLL_GLOVES:
|
||||
{
|
||||
return _gloves.contains(itemId);
|
||||
}
|
||||
case Inventory.PAPERDOLL_FEET:
|
||||
{
|
||||
return _feet.contains(itemId);
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<Integer> getChests()
|
||||
{
|
||||
return _chests;
|
||||
}
|
||||
|
||||
public List<ArmorsetSkillHolder> getSkills()
|
||||
{
|
||||
return _skills;
|
||||
}
|
||||
|
||||
public boolean containShield(L2PcInstance player)
|
||||
{
|
||||
final Inventory inv = player.getInventory();
|
||||
|
||||
final L2ItemInstance shieldItem = inv.getPaperdollItem(Inventory.PAPERDOLL_LHAND);
|
||||
return (shieldItem != null) && _shield.contains(Integer.valueOf(shieldItem.getId()));
|
||||
}
|
||||
|
||||
public boolean containShield(int shield_id)
|
||||
{
|
||||
return !_shield.isEmpty() && _shield.contains(Integer.valueOf(shield_id));
|
||||
}
|
||||
|
||||
public List<SkillHolder> getShieldSkills()
|
||||
{
|
||||
return _shieldSkills;
|
||||
}
|
||||
|
||||
public List<ArmorsetSkillHolder> getEnchantSkills()
|
||||
{
|
||||
return _enchantSkills;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @return true if all parts of set are enchanted to +6 or more
|
||||
*/
|
||||
public int getLowestSetEnchant(L2PcInstance player)
|
||||
{
|
||||
// Player don't have full set
|
||||
if (getPiecesCount(player) < getMinimumPieces())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final PcInventory inv = player.getInventory();
|
||||
|
||||
// No Chest - No Bonus
|
||||
if (inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST) == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int enchantLevel = Byte.MAX_VALUE;
|
||||
for (int armorSlot : ARMORSET_SLOTS)
|
||||
{
|
||||
final L2ItemInstance itemPart = inv.getPaperdollItem(armorSlot);
|
||||
if ((itemPart != null) && (enchantLevel > itemPart.getEnchantLevel()))
|
||||
{
|
||||
enchantLevel = itemPart.getEnchantLevel();
|
||||
}
|
||||
}
|
||||
if (enchantLevel == Byte.MAX_VALUE)
|
||||
{
|
||||
enchantLevel = 0;
|
||||
}
|
||||
return enchantLevel;
|
||||
}
|
||||
|
||||
public int getVisualPiecesCount(L2PcInstance player)
|
||||
{
|
||||
final Inventory inv = player.getInventory();
|
||||
|
||||
final L2ItemInstance legsItem = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS);
|
||||
final L2ItemInstance headItem = inv.getPaperdollItem(Inventory.PAPERDOLL_HEAD);
|
||||
final L2ItemInstance glovesItem = inv.getPaperdollItem(Inventory.PAPERDOLL_GLOVES);
|
||||
final L2ItemInstance feetItem = inv.getPaperdollItem(Inventory.PAPERDOLL_FEET);
|
||||
|
||||
int legs = 0;
|
||||
int head = 0;
|
||||
int gloves = 0;
|
||||
int feet = 0;
|
||||
|
||||
if (legsItem != null)
|
||||
{
|
||||
legs = legsItem.getVisualId();
|
||||
}
|
||||
if (headItem != null)
|
||||
{
|
||||
head = headItem.getVisualId();
|
||||
}
|
||||
if (glovesItem != null)
|
||||
{
|
||||
gloves = glovesItem.getVisualId();
|
||||
}
|
||||
if (feetItem != null)
|
||||
{
|
||||
feet = feetItem.getVisualId();
|
||||
}
|
||||
return getPiecesCount(legs, head, gloves, feet);
|
||||
}
|
||||
|
||||
public int getCON()
|
||||
{
|
||||
return _con;
|
||||
}
|
||||
|
||||
public int getDEX()
|
||||
{
|
||||
return _dex;
|
||||
}
|
||||
|
||||
public int getSTR()
|
||||
{
|
||||
return _str;
|
||||
}
|
||||
|
||||
public int getMEN()
|
||||
{
|
||||
return _men;
|
||||
}
|
||||
|
||||
public int getWIT()
|
||||
{
|
||||
return _wit;
|
||||
}
|
||||
|
||||
public int getINT()
|
||||
{
|
||||
return _int;
|
||||
}
|
||||
|
||||
public int getLUC()
|
||||
{
|
||||
return _luc;
|
||||
}
|
||||
|
||||
public int getCHA()
|
||||
{
|
||||
return _cha;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.ArmorsetSkillHolder;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public final class L2ArmorSet
|
||||
{
|
||||
private final int _id;
|
||||
private final int _minimumPieces;
|
||||
private final boolean _isVisual;
|
||||
|
||||
private final Set<Integer> _requiredItems = new LinkedHashSet<>();
|
||||
private final Set<Integer> _optionalItems = new LinkedHashSet<>();
|
||||
|
||||
private final List<ArmorsetSkillHolder> _skills = new ArrayList<>();
|
||||
private final Map<BaseStats, Double> _stats = new LinkedHashMap<>();
|
||||
|
||||
private static final int[] ARMORSET_SLOTS = new int[]
|
||||
{
|
||||
Inventory.PAPERDOLL_CHEST,
|
||||
Inventory.PAPERDOLL_LEGS,
|
||||
Inventory.PAPERDOLL_HEAD,
|
||||
Inventory.PAPERDOLL_GLOVES,
|
||||
Inventory.PAPERDOLL_FEET
|
||||
};
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param minimumPieces
|
||||
* @param isVisual
|
||||
*/
|
||||
public L2ArmorSet(int id, int minimumPieces, boolean isVisual)
|
||||
{
|
||||
_id = id;
|
||||
_minimumPieces = minimumPieces;
|
||||
_isVisual = isVisual;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the minimum amount of pieces equipped to form a set
|
||||
*/
|
||||
public int getMinimumPieces()
|
||||
{
|
||||
return _minimumPieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the set is visual only, {@code} otherwise
|
||||
*/
|
||||
public boolean isVisual()
|
||||
{
|
||||
return _isVisual;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an item to the set
|
||||
* @param item
|
||||
* @return {@code true} if item was successfully added, {@code false} in case it already exists
|
||||
*/
|
||||
public boolean addRequiredItem(Integer item)
|
||||
{
|
||||
return _requiredItems.add(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the set of items that can form a set
|
||||
*/
|
||||
public Set<Integer> getRequiredItems()
|
||||
{
|
||||
return _requiredItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an shield to the set
|
||||
* @param item
|
||||
* @return {@code true} if shield was successfully added, {@code false} in case it already exists
|
||||
*/
|
||||
public boolean addOptionalItem(Integer item)
|
||||
{
|
||||
return _optionalItems.add(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the set of shields
|
||||
*/
|
||||
public Set<Integer> getOptionalItems()
|
||||
{
|
||||
return _optionalItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an skill to the set
|
||||
* @param holder
|
||||
*/
|
||||
public void addSkill(ArmorsetSkillHolder holder)
|
||||
{
|
||||
_skills.add(holder);
|
||||
}
|
||||
|
||||
/**
|
||||
* The list of skills that are activated when set reaches it's minimal equipped items condition
|
||||
* @return
|
||||
*/
|
||||
public List<ArmorsetSkillHolder> getSkills()
|
||||
{
|
||||
return _skills;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds stats bonus to the set activated when set reaches it's minimal equipped items condition
|
||||
* @param stat
|
||||
* @param value
|
||||
*/
|
||||
public void addStatsBonus(BaseStats stat, double value)
|
||||
{
|
||||
_stats.putIfAbsent(stat, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stat
|
||||
* @return the stats bonus value or 0 if doesn't exists
|
||||
*/
|
||||
public double getStatsBonus(BaseStats stat)
|
||||
{
|
||||
return _stats.getOrDefault(stat, 0d);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param shield_id
|
||||
* @return {@code true} if player has the shield of this set equipped, {@code false} in case set doesn't have a shield or player doesn't
|
||||
*/
|
||||
public boolean containOptionalItem(int shield_id)
|
||||
{
|
||||
return _optionalItems.contains(shield_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @return true if all parts of set are enchanted to +6 or more
|
||||
*/
|
||||
public int getLowestSetEnchant(L2PcInstance player)
|
||||
{
|
||||
// Player don't have full set
|
||||
if (getPiecesCount(player, L2ItemInstance::getId) < getMinimumPieces())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final PcInventory inv = player.getInventory();
|
||||
int enchantLevel = Byte.MAX_VALUE;
|
||||
for (int armorSlot : ARMORSET_SLOTS)
|
||||
{
|
||||
final L2ItemInstance itemPart = inv.getPaperdollItem(armorSlot);
|
||||
if ((itemPart != null) && _requiredItems.contains(itemPart.getId()))
|
||||
{
|
||||
if (enchantLevel > itemPart.getEnchantLevel())
|
||||
{
|
||||
enchantLevel = itemPart.getEnchantLevel();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (enchantLevel == Byte.MAX_VALUE)
|
||||
{
|
||||
enchantLevel = 0;
|
||||
}
|
||||
return enchantLevel;
|
||||
}
|
||||
|
||||
public boolean hasOptionalEquipped(L2PcInstance player, Function<L2ItemInstance, Integer> idProvider)
|
||||
{
|
||||
return player.getInventory().getPaperdollItems().stream().anyMatch(item -> _optionalItems.contains(idProvider.apply(item)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param idProvider
|
||||
* @return the amount of set visual items that player has equipped
|
||||
*/
|
||||
public long getPiecesCount(L2PcInstance player, Function<L2ItemInstance, Integer> idProvider)
|
||||
{
|
||||
return player.getInventory().getPaperdollItems(item -> _requiredItems.contains(idProvider.apply(item))).size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,134 +1,107 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.OptionData;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.options.Options;
|
||||
|
||||
/**
|
||||
* Used to store an augmentation and its bonuses.
|
||||
* @author durgus, UnAfraid
|
||||
*/
|
||||
public final class L2Augmentation
|
||||
{
|
||||
private int _effectsId = 0;
|
||||
private AugmentationStatBoni _boni = null;
|
||||
|
||||
public L2Augmentation(int effects)
|
||||
{
|
||||
_effectsId = effects;
|
||||
_boni = new AugmentationStatBoni(_effectsId);
|
||||
}
|
||||
|
||||
public static class AugmentationStatBoni
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AugmentationStatBoni.class.getName());
|
||||
private final List<Options> _options = new ArrayList<>();
|
||||
private boolean _active;
|
||||
|
||||
public AugmentationStatBoni(int augmentationId)
|
||||
{
|
||||
_active = false;
|
||||
final int[] stats = new int[2];
|
||||
stats[0] = 0x0000FFFF & augmentationId;
|
||||
stats[1] = augmentationId >> 16;
|
||||
|
||||
for (int stat : stats)
|
||||
{
|
||||
final Options op = OptionData.getInstance().getOptions(stat);
|
||||
if (op != null)
|
||||
{
|
||||
_options.add(op);
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't find option: " + stat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void applyBonus(L2PcInstance player)
|
||||
{
|
||||
// make sure the bonuses are not applied twice..
|
||||
if (_active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Options op : _options)
|
||||
{
|
||||
op.apply(player);
|
||||
}
|
||||
|
||||
_active = true;
|
||||
}
|
||||
|
||||
public void removeBonus(L2PcInstance player)
|
||||
{
|
||||
// make sure the bonuses are not removed twice
|
||||
if (!_active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Options op : _options)
|
||||
{
|
||||
op.remove(player);
|
||||
}
|
||||
|
||||
_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
public int getAttributes()
|
||||
{
|
||||
return _effectsId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the augmentation "id" used in serverpackets.
|
||||
* @return augmentationId
|
||||
*/
|
||||
public int getAugmentationId()
|
||||
{
|
||||
return _effectsId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the bonuses to the player.
|
||||
* @param player
|
||||
*/
|
||||
public void applyBonus(L2PcInstance player)
|
||||
{
|
||||
_boni.applyBonus(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the augmentation bonuses from the player.
|
||||
* @param player
|
||||
*/
|
||||
public void removeBonus(L2PcInstance player)
|
||||
{
|
||||
_boni.removeBonus(player);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.OptionData;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.options.Options;
|
||||
|
||||
/**
|
||||
* Used to store an augmentation and its bonuses.
|
||||
* @author durgus, UnAfraid
|
||||
*/
|
||||
public final class L2Augmentation
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(L2Augmentation.class.getName());
|
||||
private final List<Options> _options = new ArrayList<>();
|
||||
private boolean _active;
|
||||
private final int _id;
|
||||
|
||||
public L2Augmentation(int id)
|
||||
{
|
||||
_id = id;
|
||||
_active = false;
|
||||
final int[] stats = new int[2];
|
||||
stats[0] = 0x0000FFFF & id;
|
||||
stats[1] = (id >> 16);
|
||||
|
||||
for (int stat : stats)
|
||||
{
|
||||
final Options op = OptionData.getInstance().getOptions(stat);
|
||||
if (op != null)
|
||||
{
|
||||
_options.add(op);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Couldn't find option: " + stat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the augmentation "id" used in serverpackets.
|
||||
* @return augmentationId
|
||||
*/
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public List<Options> getOptions()
|
||||
{
|
||||
return _options;
|
||||
}
|
||||
|
||||
public void applyBonus(L2PcInstance player)
|
||||
{
|
||||
// make sure the bonuses are not applied twice..
|
||||
if (_active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Options op : _options)
|
||||
{
|
||||
op.apply(player);
|
||||
}
|
||||
|
||||
player.getStat().recalculateStats(true);
|
||||
_active = true;
|
||||
}
|
||||
|
||||
public void removeBonus(L2PcInstance player)
|
||||
{
|
||||
// make sure the bonuses are not removed twice
|
||||
if (!_active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Options op : _options)
|
||||
{
|
||||
op.remove(player);
|
||||
}
|
||||
|
||||
player.getStat().recalculateStats(true);
|
||||
_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,261 +1,253 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExCloseMPCC;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExMPCCPartyInfoUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExOpenMPCC;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* This class serves as a container for command channels.
|
||||
* @author chris_00
|
||||
*/
|
||||
public class L2CommandChannel extends AbstractPlayerGroup
|
||||
{
|
||||
private final List<L2Party> _parties = new CopyOnWriteArrayList<>();
|
||||
private L2PcInstance _commandLeader;
|
||||
private int _channelLvl;
|
||||
|
||||
/**
|
||||
* Create a new command channel and add the leader's party to it.
|
||||
* @param leader the leader of this command channel
|
||||
*/
|
||||
public L2CommandChannel(L2PcInstance leader)
|
||||
{
|
||||
_commandLeader = leader;
|
||||
final L2Party party = leader.getParty();
|
||||
_parties.add(party);
|
||||
_channelLvl = party.getLevel();
|
||||
party.setCommandChannel(this);
|
||||
party.broadcastMessage(SystemMessageId.THE_COMMAND_CHANNEL_HAS_BEEN_FORMED);
|
||||
party.broadcastPacket(ExOpenMPCC.STATIC_PACKET);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a party to this command channel.
|
||||
* @param party the party to add
|
||||
*/
|
||||
public void addParty(L2Party party)
|
||||
{
|
||||
if (party == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Update the CCinfo for existing players
|
||||
broadcastPacket(new ExMPCCPartyInfoUpdate(party, 1));
|
||||
|
||||
_parties.add(party);
|
||||
if (party.getLevel() > _channelLvl)
|
||||
{
|
||||
_channelLvl = party.getLevel();
|
||||
}
|
||||
party.setCommandChannel(this);
|
||||
party.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_JOINED_THE_COMMAND_CHANNEL));
|
||||
party.broadcastPacket(ExOpenMPCC.STATIC_PACKET);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a party from this command channel.
|
||||
* @param party the party to remove
|
||||
*/
|
||||
public void removeParty(L2Party party)
|
||||
{
|
||||
if (party == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_parties.remove(party);
|
||||
_channelLvl = 0;
|
||||
for (L2Party pty : _parties)
|
||||
{
|
||||
if (pty.getLevel() > _channelLvl)
|
||||
{
|
||||
_channelLvl = pty.getLevel();
|
||||
}
|
||||
}
|
||||
party.setCommandChannel(null);
|
||||
party.broadcastPacket(new ExCloseMPCC());
|
||||
if (_parties.size() < 2)
|
||||
{
|
||||
broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_COMMAND_CHANNEL_HAS_BEEN_DISBANDED));
|
||||
disbandChannel();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update the CCinfo for existing players
|
||||
broadcastPacket(new ExMPCCPartyInfoUpdate(party, 0));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disband this command channel.
|
||||
*/
|
||||
public void disbandChannel()
|
||||
{
|
||||
if (_parties == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (L2Party party : _parties)
|
||||
{
|
||||
if (party != null)
|
||||
{
|
||||
removeParty(party);
|
||||
}
|
||||
}
|
||||
_parties.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the total count of all members of this command channel
|
||||
*/
|
||||
@Override
|
||||
public int getMemberCount()
|
||||
{
|
||||
int count = 0;
|
||||
for (L2Party party : _parties)
|
||||
{
|
||||
if (party != null)
|
||||
{
|
||||
count += party.getMemberCount();
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of all parties in this command channel
|
||||
*/
|
||||
public List<L2Party> getPartys()
|
||||
{
|
||||
return _parties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of all members in this command channel
|
||||
*/
|
||||
@Override
|
||||
public List<L2PcInstance> getMembers()
|
||||
{
|
||||
final List<L2PcInstance> members = new LinkedList<>();
|
||||
for (L2Party party : getPartys())
|
||||
{
|
||||
members.addAll(party.getMembers());
|
||||
}
|
||||
return members;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the level of this command channel (equals the level of the highest-leveled character in this command channel)
|
||||
*/
|
||||
@Override
|
||||
public int getLevel()
|
||||
{
|
||||
return _channelLvl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeader(L2PcInstance leader)
|
||||
{
|
||||
_commandLeader = leader;
|
||||
if (leader.getLevel() > _channelLvl)
|
||||
{
|
||||
_channelLvl = leader.getLevel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param obj
|
||||
* @return true if proper condition for RaidWar
|
||||
*/
|
||||
public boolean meetRaidWarCondition(L2Object obj)
|
||||
{
|
||||
return (obj instanceof L2Character) && ((L2Character) obj).isRaid() && (getMemberCount() >= Config.LOOT_RAIDS_PRIVILEGE_CC_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the leader of this command channel
|
||||
*/
|
||||
@Override
|
||||
public L2PcInstance getLeader()
|
||||
{
|
||||
return _commandLeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given player is in this command channel.
|
||||
* @param player the player to check
|
||||
* @return {@code true} if he does, {@code false} otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean containsPlayer(L2PcInstance player)
|
||||
{
|
||||
if ((_parties != null) && !_parties.isEmpty())
|
||||
{
|
||||
for (L2Party party : _parties)
|
||||
{
|
||||
if (party.containsPlayer(player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over all command channel members without the need to allocate a new list
|
||||
* @see com.l2jmobius.gameserver.model.AbstractPlayerGroup#forEachMember(Function)
|
||||
*/
|
||||
@Override
|
||||
public boolean forEachMember(Function<L2PcInstance, Boolean> function)
|
||||
{
|
||||
if ((_parties != null) && !_parties.isEmpty())
|
||||
{
|
||||
for (L2Party party : _parties)
|
||||
{
|
||||
if (!party.forEachMember(function))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the leader of this command channel is the same as the leader of the specified command channel<br>
|
||||
* (which essentially means they're the same group).
|
||||
* @param cc the other command channel to check against
|
||||
* @return {@code true} if this command channel equals the specified command channel, {@code false} otherwise
|
||||
*/
|
||||
public boolean equals(L2CommandChannel cc)
|
||||
{
|
||||
return (cc != null) && (getLeaderObjectId() == cc.getLeaderObjectId());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExCloseMPCC;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExMPCCPartyInfoUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExOpenMPCC;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* This class serves as a container for command channels.
|
||||
* @author chris_00
|
||||
*/
|
||||
public class L2CommandChannel extends AbstractPlayerGroup
|
||||
{
|
||||
private final List<L2Party> _parties = new CopyOnWriteArrayList<>();
|
||||
private L2PcInstance _commandLeader = null;
|
||||
private int _channelLvl;
|
||||
|
||||
/**
|
||||
* Create a new command channel and add the leader's party to it.
|
||||
* @param leader the leader of this command channel
|
||||
*/
|
||||
public L2CommandChannel(L2PcInstance leader)
|
||||
{
|
||||
_commandLeader = leader;
|
||||
final L2Party party = leader.getParty();
|
||||
_parties.add(party);
|
||||
_channelLvl = party.getLevel();
|
||||
party.setCommandChannel(this);
|
||||
party.broadcastMessage(SystemMessageId.THE_COMMAND_CHANNEL_HAS_BEEN_FORMED);
|
||||
party.broadcastPacket(ExOpenMPCC.STATIC_PACKET);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a party to this command channel.
|
||||
* @param party the party to add
|
||||
*/
|
||||
public void addParty(L2Party party)
|
||||
{
|
||||
if (party == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Update the CCinfo for existing players
|
||||
broadcastPacket(new ExMPCCPartyInfoUpdate(party, 1));
|
||||
|
||||
_parties.add(party);
|
||||
if (party.getLevel() > _channelLvl)
|
||||
{
|
||||
_channelLvl = party.getLevel();
|
||||
}
|
||||
party.setCommandChannel(this);
|
||||
party.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_JOINED_THE_COMMAND_CHANNEL));
|
||||
party.broadcastPacket(ExOpenMPCC.STATIC_PACKET);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a party from this command channel.
|
||||
* @param party the party to remove
|
||||
*/
|
||||
public void removeParty(L2Party party)
|
||||
{
|
||||
if (party == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_parties.remove(party);
|
||||
_channelLvl = 0;
|
||||
for (L2Party pty : _parties)
|
||||
{
|
||||
if (pty.getLevel() > _channelLvl)
|
||||
{
|
||||
_channelLvl = pty.getLevel();
|
||||
}
|
||||
}
|
||||
party.setCommandChannel(null);
|
||||
party.broadcastPacket(ExCloseMPCC.STATIC_PACKET);
|
||||
if (_parties.size() < 2)
|
||||
{
|
||||
broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_COMMAND_CHANNEL_HAS_BEEN_DISBANDED));
|
||||
disbandChannel();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update the CCinfo for existing players
|
||||
broadcastPacket(new ExMPCCPartyInfoUpdate(party, 0));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disband this command channel.
|
||||
*/
|
||||
public void disbandChannel()
|
||||
{
|
||||
if (_parties != null)
|
||||
{
|
||||
for (L2Party party : _parties)
|
||||
{
|
||||
if (party != null)
|
||||
{
|
||||
removeParty(party);
|
||||
}
|
||||
}
|
||||
_parties.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the total count of all members of this command channel
|
||||
*/
|
||||
@Override
|
||||
public int getMemberCount()
|
||||
{
|
||||
int count = 0;
|
||||
for (L2Party party : _parties)
|
||||
{
|
||||
if (party != null)
|
||||
{
|
||||
count += party.getMemberCount();
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of all parties in this command channel
|
||||
*/
|
||||
public List<L2Party> getPartys()
|
||||
{
|
||||
return _parties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of all members in this command channel
|
||||
*/
|
||||
@Override
|
||||
public List<L2PcInstance> getMembers()
|
||||
{
|
||||
final List<L2PcInstance> members = new LinkedList<>();
|
||||
for (L2Party party : getPartys())
|
||||
{
|
||||
members.addAll(party.getMembers());
|
||||
}
|
||||
return members;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the level of this command channel (equals the level of the highest-leveled character in this command channel)
|
||||
*/
|
||||
@Override
|
||||
public int getLevel()
|
||||
{
|
||||
return _channelLvl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeader(L2PcInstance leader)
|
||||
{
|
||||
_commandLeader = leader;
|
||||
if (leader.getLevel() > _channelLvl)
|
||||
{
|
||||
_channelLvl = leader.getLevel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param obj
|
||||
* @return true if proper condition for RaidWar
|
||||
*/
|
||||
public boolean meetRaidWarCondition(L2Object obj)
|
||||
{
|
||||
if (!((obj instanceof L2Character) && ((L2Character) obj).isRaid()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (getMemberCount() >= Config.LOOT_RAIDS_PRIVILEGE_CC_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the leader of this command channel
|
||||
*/
|
||||
@Override
|
||||
public L2PcInstance getLeader()
|
||||
{
|
||||
return _commandLeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given player is in this command channel.
|
||||
* @param player the player to check
|
||||
* @return {@code true} if he does, {@code false} otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean containsPlayer(L2PcInstance player)
|
||||
{
|
||||
if ((_parties != null) && !_parties.isEmpty())
|
||||
{
|
||||
for (L2Party party : _parties)
|
||||
{
|
||||
if (party.containsPlayer(player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over all command channel members without the need to allocate a new list
|
||||
* @see com.l2jmobius.gameserver.model.AbstractPlayerGroup#forEachMember(Function)
|
||||
*/
|
||||
@Override
|
||||
public boolean forEachMember(Function<L2PcInstance, Boolean> function)
|
||||
{
|
||||
if ((_parties != null) && !_parties.isEmpty())
|
||||
{
|
||||
for (L2Party party : _parties)
|
||||
{
|
||||
if (!party.forEachMember(function))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,184 +1,185 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* TODO: System messages:<br>
|
||||
* ADD: 3223: The previous name is being registered. Please try again later.<br>
|
||||
* DEL 3219: $s1 was successfully deleted from your Contact List.<br>
|
||||
* DEL 3217: The name is not currently registered.
|
||||
* @author UnAfraid, mrTJO
|
||||
*/
|
||||
public class L2ContactList
|
||||
{
|
||||
private final Logger _log = Logger.getLogger(getClass().getName());
|
||||
private final L2PcInstance activeChar;
|
||||
private final List<String> _contacts = new CopyOnWriteArrayList<>();
|
||||
|
||||
private static final String QUERY_ADD = "INSERT INTO character_contacts (charId, contactId) VALUES (?, ?)";
|
||||
private static final String QUERY_REMOVE = "DELETE FROM character_contacts WHERE charId = ? and contactId = ?";
|
||||
private static final String QUERY_LOAD = "SELECT contactId FROM character_contacts WHERE charId = ?";
|
||||
|
||||
public L2ContactList(L2PcInstance player)
|
||||
{
|
||||
activeChar = player;
|
||||
restore();
|
||||
}
|
||||
|
||||
public void restore()
|
||||
{
|
||||
_contacts.clear();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(QUERY_LOAD))
|
||||
{
|
||||
ps.setInt(1, activeChar.getObjectId());
|
||||
try (ResultSet rs = ps.executeQuery())
|
||||
{
|
||||
int contactId;
|
||||
String contactName;
|
||||
while (rs.next())
|
||||
{
|
||||
contactId = rs.getInt(1);
|
||||
contactName = CharNameTable.getInstance().getNameById(contactId);
|
||||
if ((contactName == null) || contactName.equals(activeChar.getName()) || (contactId == activeChar.getObjectId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_contacts.add(contactName);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Error found in " + activeChar.getName() + "'s ContactsList: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean add(String name)
|
||||
{
|
||||
SystemMessage sm;
|
||||
|
||||
final int contactId = CharNameTable.getInstance().getIdByName(name);
|
||||
if (_contacts.contains(name))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_NAME_ALREADY_EXISTS_ON_THE_ADDED_LIST);
|
||||
return false;
|
||||
}
|
||||
else if (activeChar.getName().equals(name))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_ADD_YOUR_OWN_NAME);
|
||||
return false;
|
||||
}
|
||||
else if (_contacts.size() >= 100)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_MAXIMUM_NUMBER_OF_NAMES_100_HAS_BEEN_REACHED_YOU_CANNOT_REGISTER_ANY_MORE);
|
||||
return false;
|
||||
}
|
||||
else if (contactId < 1)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THE_NAME_S1_DOESN_T_EXIST_PLEASE_TRY_ANOTHER_NAME);
|
||||
sm.addString(name);
|
||||
activeChar.sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (String contactName : _contacts)
|
||||
{
|
||||
if (contactName.equalsIgnoreCase(name))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_NAME_ALREADY_EXISTS_ON_THE_ADDED_LIST);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(QUERY_ADD))
|
||||
{
|
||||
ps.setInt(1, activeChar.getObjectId());
|
||||
ps.setInt(2, contactId);
|
||||
ps.execute();
|
||||
|
||||
_contacts.add(name);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_WAS_SUCCESSFULLY_ADDED_TO_YOUR_CONTACT_LIST);
|
||||
sm.addString(name);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Error found in " + activeChar.getName() + "'s ContactsList: " + e.getMessage(), e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void remove(String name)
|
||||
{
|
||||
final int contactId = CharNameTable.getInstance().getIdByName(name);
|
||||
|
||||
if (!_contacts.contains(name))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_NAME_IS_NOT_CURRENTLY_REGISTERED);
|
||||
return;
|
||||
}
|
||||
else if (contactId < 1)
|
||||
{
|
||||
// TODO: Message?
|
||||
return;
|
||||
}
|
||||
|
||||
_contacts.remove(name);
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(QUERY_REMOVE))
|
||||
{
|
||||
ps.setInt(1, activeChar.getObjectId());
|
||||
ps.setInt(2, contactId);
|
||||
ps.execute();
|
||||
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_WAS_SUCCESSFULLY_DELETED_FROM_YOUR_CONTACT_LIST);
|
||||
sm.addString(name);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Error found in " + activeChar.getName() + "'s ContactsList: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getAllContacts()
|
||||
{
|
||||
return _contacts;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* TODO: System messages:<br>
|
||||
* ADD: 3223: The previous name is being registered. Please try again later.<br>
|
||||
* DEL 3219: $s1 was successfully deleted from your Contact List.<br>
|
||||
* DEL 3217: The name is not currently registered.
|
||||
* @author UnAfraid, mrTJO
|
||||
*/
|
||||
public class L2ContactList
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(L2ContactList.class.getName());
|
||||
|
||||
private final L2PcInstance activeChar;
|
||||
private final Set<String> _contacts = ConcurrentHashMap.newKeySet();
|
||||
|
||||
private static final String QUERY_ADD = "INSERT INTO character_contacts (charId, contactId) VALUES (?, ?)";
|
||||
private static final String QUERY_REMOVE = "DELETE FROM character_contacts WHERE charId = ? and contactId = ?";
|
||||
private static final String QUERY_LOAD = "SELECT contactId FROM character_contacts WHERE charId = ?";
|
||||
|
||||
public L2ContactList(L2PcInstance player)
|
||||
{
|
||||
activeChar = player;
|
||||
restore();
|
||||
}
|
||||
|
||||
public void restore()
|
||||
{
|
||||
_contacts.clear();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(QUERY_LOAD))
|
||||
{
|
||||
statement.setInt(1, activeChar.getObjectId());
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
int contactId;
|
||||
String contactName;
|
||||
while (rset.next())
|
||||
{
|
||||
contactId = rset.getInt(1);
|
||||
contactName = CharNameTable.getInstance().getNameById(contactId);
|
||||
if ((contactName == null) || contactName.equals(activeChar.getName()) || (contactId == activeChar.getObjectId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_contacts.add(contactName);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Error found in " + activeChar.getName() + "'s ContactsList: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean add(String name)
|
||||
{
|
||||
SystemMessage sm;
|
||||
|
||||
final int contactId = CharNameTable.getInstance().getIdByName(name);
|
||||
if (_contacts.contains(name))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_NAME_ALREADY_EXISTS_ON_THE_ADDED_LIST);
|
||||
return false;
|
||||
}
|
||||
else if (activeChar.getName().equals(name))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_ADD_YOUR_OWN_NAME);
|
||||
return false;
|
||||
}
|
||||
else if (_contacts.size() >= 100)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_MAXIMUM_NUMBER_OF_NAMES_100_HAS_BEEN_REACHED_YOU_CANNOT_REGISTER_ANY_MORE);
|
||||
return false;
|
||||
}
|
||||
else if (contactId < 1)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THE_NAME_S1_DOESN_T_EXIST_PLEASE_TRY_ANOTHER_NAME);
|
||||
sm.addString(name);
|
||||
activeChar.sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (String contactName : _contacts)
|
||||
{
|
||||
if (contactName.equalsIgnoreCase(name))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_NAME_ALREADY_EXISTS_ON_THE_ADDED_LIST);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(QUERY_ADD))
|
||||
{
|
||||
statement.setInt(1, activeChar.getObjectId());
|
||||
statement.setInt(2, contactId);
|
||||
statement.execute();
|
||||
|
||||
_contacts.add(name);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_WAS_SUCCESSFULLY_ADDED_TO_YOUR_CONTACT_LIST);
|
||||
sm.addString(name);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Error found in " + activeChar.getName() + "'s ContactsList: " + e.getMessage(), e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void remove(String name)
|
||||
{
|
||||
final int contactId = CharNameTable.getInstance().getIdByName(name);
|
||||
|
||||
if (!_contacts.contains(name))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_NAME_IS_NOT_CURRENTLY_REGISTERED);
|
||||
return;
|
||||
}
|
||||
else if (contactId < 1)
|
||||
{
|
||||
// TODO: Message?
|
||||
return;
|
||||
}
|
||||
|
||||
_contacts.remove(name);
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(QUERY_REMOVE))
|
||||
{
|
||||
statement.setInt(1, activeChar.getObjectId());
|
||||
statement.setInt(2, contactId);
|
||||
statement.execute();
|
||||
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_WAS_SUCCESSFULLY_DELETED_FROM_YOUR_CONTACT_LIST);
|
||||
sm.addString(name);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Error found in " + activeChar.getName() + "'s ContactsList: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public Set<String> getAllContacts()
|
||||
{
|
||||
return _contacts;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,138 +1,138 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.AllyCrest;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPledgeEmblem;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeCrest;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public final class L2Crest implements IIdentifiable
|
||||
{
|
||||
public enum CrestType
|
||||
{
|
||||
PLEDGE(1),
|
||||
PLEDGE_LARGE(2),
|
||||
ALLY(3);
|
||||
|
||||
private final int _id;
|
||||
|
||||
private CrestType(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public static CrestType getById(int id)
|
||||
{
|
||||
for (CrestType crestType : values())
|
||||
{
|
||||
if (crestType.getId() == id)
|
||||
{
|
||||
return crestType;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private final int _id;
|
||||
private final byte[] _data;
|
||||
private final CrestType _type;
|
||||
|
||||
public L2Crest(int id, byte[] data, CrestType type)
|
||||
{
|
||||
_id = id;
|
||||
_data = data;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public byte[] getData()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
public CrestType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the client path to crest for use in html and sends the crest to {@code L2PcInstance}
|
||||
* @param activeChar the @{code L2PcInstance} where html is send to.
|
||||
* @return the client path to crest
|
||||
*/
|
||||
public String getClientPath(L2PcInstance activeChar)
|
||||
{
|
||||
String path = null;
|
||||
switch (getType())
|
||||
{
|
||||
case PLEDGE:
|
||||
{
|
||||
activeChar.sendPacket(new PledgeCrest(getId()));
|
||||
path = "Crest.crest_" + Config.SERVER_ID + "_" + getId();
|
||||
break;
|
||||
}
|
||||
case PLEDGE_LARGE:
|
||||
{
|
||||
final byte[] data = getData();
|
||||
if (data != null)
|
||||
{
|
||||
for (int i = 0; i <= 4; i++)
|
||||
{
|
||||
if (i < 4)
|
||||
{
|
||||
final byte[] fullChunk = new byte[14336];
|
||||
System.arraycopy(data, 14336 * i, fullChunk, 0, 14336);
|
||||
activeChar.sendPacket(new ExPledgeEmblem(getId(), fullChunk, 0, i));
|
||||
}
|
||||
else
|
||||
{
|
||||
final byte[] lastChunk = new byte[8320];
|
||||
System.arraycopy(data, 14336 * i, lastChunk, 0, 8320);
|
||||
activeChar.sendPacket(new ExPledgeEmblem(getId(), lastChunk, 0, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
path = "Crest.crest_" + Config.SERVER_ID + "_" + getId() + "_l";
|
||||
break;
|
||||
}
|
||||
case ALLY:
|
||||
{
|
||||
activeChar.sendPacket(new AllyCrest(getId()));
|
||||
path = "Crest.crest_" + Config.SERVER_ID + "_" + getId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.AllyCrest;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPledgeEmblem;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeCrest;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public final class L2Crest implements IIdentifiable
|
||||
{
|
||||
public enum CrestType
|
||||
{
|
||||
PLEDGE(1),
|
||||
PLEDGE_LARGE(2),
|
||||
ALLY(3);
|
||||
|
||||
private final int _id;
|
||||
|
||||
CrestType(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public static CrestType getById(int id)
|
||||
{
|
||||
for (CrestType crestType : values())
|
||||
{
|
||||
if (crestType.getId() == id)
|
||||
{
|
||||
return crestType;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private final int _id;
|
||||
private final byte[] _data;
|
||||
private final CrestType _type;
|
||||
|
||||
public L2Crest(int id, byte[] data, CrestType type)
|
||||
{
|
||||
_id = id;
|
||||
_data = data;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public byte[] getData()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
public CrestType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the client path to crest for use in html and sends the crest to {@code L2PcInstance}
|
||||
* @param activeChar the @{code L2PcInstance} where html is send to.
|
||||
* @return the client path to crest
|
||||
*/
|
||||
public String getClientPath(L2PcInstance activeChar)
|
||||
{
|
||||
String path = null;
|
||||
switch (getType())
|
||||
{
|
||||
case PLEDGE:
|
||||
{
|
||||
activeChar.sendPacket(new PledgeCrest(getId(), getData()));
|
||||
path = "Crest.crest_" + Config.SERVER_ID + "_" + getId();
|
||||
break;
|
||||
}
|
||||
case PLEDGE_LARGE:
|
||||
{
|
||||
final byte[] data = getData();
|
||||
if (data != null)
|
||||
{
|
||||
for (int i = 0; i <= 4; i++)
|
||||
{
|
||||
if (i < 4)
|
||||
{
|
||||
final byte[] fullChunk = new byte[14336];
|
||||
System.arraycopy(data, (14336 * i), fullChunk, 0, 14336);
|
||||
activeChar.sendPacket(new ExPledgeEmblem(getId(), fullChunk, 0, i));
|
||||
}
|
||||
else
|
||||
{
|
||||
final byte[] lastChunk = new byte[8320];
|
||||
System.arraycopy(data, (14336 * i), lastChunk, 0, 8320);
|
||||
activeChar.sendPacket(new ExPledgeEmblem(getId(), lastChunk, 0, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
path = "Crest.crest_" + Config.SERVER_ID + "_" + getId() + "_l";
|
||||
break;
|
||||
}
|
||||
case ALLY:
|
||||
{
|
||||
activeChar.sendPacket(new AllyCrest(getId(), getData()));
|
||||
path = "Crest.crest_" + Config.SERVER_ID + "_" + getId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@@ -1,101 +1,105 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public final class L2EnchantSkillGroup
|
||||
{
|
||||
private final int _id;
|
||||
private final List<EnchantSkillHolder> _enchantDetails = new ArrayList<>();
|
||||
|
||||
public L2EnchantSkillGroup(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public void addEnchantDetail(EnchantSkillHolder detail)
|
||||
{
|
||||
_enchantDetails.add(detail);
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public List<EnchantSkillHolder> getEnchantGroupDetails()
|
||||
{
|
||||
return _enchantDetails;
|
||||
}
|
||||
|
||||
public static class EnchantSkillHolder
|
||||
{
|
||||
private final int _level;
|
||||
private final int _adenaCost;
|
||||
private final int _expCost;
|
||||
private final int _spCost;
|
||||
private final byte[] _rate;
|
||||
|
||||
public EnchantSkillHolder(StatsSet set)
|
||||
{
|
||||
_level = set.getInt("level");
|
||||
_adenaCost = set.getInt("adena", 0);
|
||||
_expCost = set.getInt("exp", 0);
|
||||
_spCost = set.getInt("sp", 0);
|
||||
_rate = new byte[32];
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
_rate[i] = set.getByte("chance" + (76 + i), (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the level.
|
||||
*/
|
||||
public int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the spCost.
|
||||
*/
|
||||
public int getSpCost()
|
||||
{
|
||||
return _spCost;
|
||||
}
|
||||
|
||||
public int getExpCost()
|
||||
{
|
||||
return _expCost;
|
||||
}
|
||||
|
||||
public int getAdenaCost()
|
||||
{
|
||||
return _adenaCost;
|
||||
}
|
||||
|
||||
public byte getRate(L2PcInstance ply)
|
||||
{
|
||||
return ply.getLevel() < 76 ? 0 : _rate[ply.getLevel() - 76];
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public final class L2EnchantSkillGroup
|
||||
{
|
||||
private final int _id;
|
||||
private final List<EnchantSkillHolder> _enchantDetails = new ArrayList<>();
|
||||
|
||||
public L2EnchantSkillGroup(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public void addEnchantDetail(EnchantSkillHolder detail)
|
||||
{
|
||||
_enchantDetails.add(detail);
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public List<EnchantSkillHolder> getEnchantGroupDetails()
|
||||
{
|
||||
return _enchantDetails;
|
||||
}
|
||||
|
||||
public static class EnchantSkillHolder
|
||||
{
|
||||
private final int _level;
|
||||
private final int _adenaCost;
|
||||
private final int _expCost;
|
||||
private final int _spCost;
|
||||
private final byte[] _rate;
|
||||
|
||||
public EnchantSkillHolder(StatsSet set)
|
||||
{
|
||||
_level = set.getInt("level");
|
||||
_adenaCost = set.getInt("adena", 0);
|
||||
_expCost = set.getInt("exp", 0);
|
||||
_spCost = set.getInt("sp", 0);
|
||||
_rate = new byte[24];
|
||||
for (int i = 0; i < 24; i++)
|
||||
{
|
||||
_rate[i] = set.getByte("chance" + (76 + i), (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the level.
|
||||
*/
|
||||
public int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the spCost.
|
||||
*/
|
||||
public int getSpCost()
|
||||
{
|
||||
return _spCost;
|
||||
}
|
||||
|
||||
public int getExpCost()
|
||||
{
|
||||
return _expCost;
|
||||
}
|
||||
|
||||
public int getAdenaCost()
|
||||
{
|
||||
return _adenaCost;
|
||||
}
|
||||
|
||||
public byte getRate(L2PcInstance ply)
|
||||
{
|
||||
if (ply.getLevel() < 76)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return _rate[ply.getLevel() - 76];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,114 +1,128 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.EnchantSkillGroupsData;
|
||||
import com.l2jmobius.gameserver.model.L2EnchantSkillGroup.EnchantSkillHolder;
|
||||
|
||||
public final class L2EnchantSkillLearn
|
||||
{
|
||||
private final int _id;
|
||||
private final int _baseLvl;
|
||||
private final TreeMap<Integer, Integer> _enchantRoutes = new TreeMap<>();
|
||||
|
||||
public L2EnchantSkillLearn(int id, int baseLvl)
|
||||
{
|
||||
_id = id;
|
||||
_baseLvl = baseLvl;
|
||||
}
|
||||
|
||||
public void addNewEnchantRoute(int route, int group)
|
||||
{
|
||||
_enchantRoutes.put(route, group);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the id.
|
||||
*/
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the minLevel.
|
||||
*/
|
||||
public int getBaseLevel()
|
||||
{
|
||||
return _baseLvl;
|
||||
}
|
||||
|
||||
public static int getEnchantRoute(int level)
|
||||
{
|
||||
return (int) Math.floor(level / 1000);
|
||||
}
|
||||
|
||||
public static int getEnchantIndex(int level)
|
||||
{
|
||||
return (level % 1000) - 1;
|
||||
}
|
||||
|
||||
public static int getEnchantType(int level)
|
||||
{
|
||||
return ((level - 1) / 1000) - 1;
|
||||
}
|
||||
|
||||
public L2EnchantSkillGroup getFirstRouteGroup()
|
||||
{
|
||||
return EnchantSkillGroupsData.getInstance().getEnchantSkillGroupById(_enchantRoutes.firstEntry().getValue());
|
||||
}
|
||||
|
||||
public Set<Integer> getAllRoutes()
|
||||
{
|
||||
return _enchantRoutes.keySet();
|
||||
}
|
||||
|
||||
public int getMinSkillLevel(int level)
|
||||
{
|
||||
return (level % 1000) == 1 ? _baseLvl : level - 1;
|
||||
}
|
||||
|
||||
public boolean isMaxEnchant(int level)
|
||||
{
|
||||
final int enchantType = getEnchantRoute(level);
|
||||
return (enchantType >= 1) && _enchantRoutes.containsKey(enchantType) && ((getEnchantIndex(level) + 1) >= EnchantSkillGroupsData.getInstance().getEnchantSkillGroupById(_enchantRoutes.get(enchantType)).getEnchantGroupDetails().size());
|
||||
}
|
||||
|
||||
public EnchantSkillHolder getEnchantSkillHolder(int level)
|
||||
{
|
||||
final int enchantType = getEnchantRoute(level);
|
||||
if ((enchantType < 1) || !_enchantRoutes.containsKey(enchantType))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final int index = getEnchantIndex(level);
|
||||
final L2EnchantSkillGroup group = EnchantSkillGroupsData.getInstance().getEnchantSkillGroupById(_enchantRoutes.get(enchantType));
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
return group.getEnchantGroupDetails().get(0);
|
||||
}
|
||||
else if (index >= group.getEnchantGroupDetails().size())
|
||||
{
|
||||
return group.getEnchantGroupDetails().get(EnchantSkillGroupsData.getInstance().getEnchantSkillGroupById(_enchantRoutes.get(enchantType)).getEnchantGroupDetails().size() - 1);
|
||||
}
|
||||
return group.getEnchantGroupDetails().get(index);
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.EnchantSkillGroupsData;
|
||||
import com.l2jmobius.gameserver.model.L2EnchantSkillGroup.EnchantSkillHolder;
|
||||
|
||||
public final class L2EnchantSkillLearn
|
||||
{
|
||||
private final int _id;
|
||||
private final int _baseLvl;
|
||||
private final TreeMap<Integer, Integer> _enchantRoutes = new TreeMap<>();
|
||||
|
||||
public L2EnchantSkillLearn(int id, int baseLvl)
|
||||
{
|
||||
_id = id;
|
||||
_baseLvl = baseLvl;
|
||||
}
|
||||
|
||||
public void addNewEnchantRoute(int route, int group)
|
||||
{
|
||||
_enchantRoutes.put(route, group);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the id.
|
||||
*/
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the minLevel.
|
||||
*/
|
||||
public int getBaseLevel()
|
||||
{
|
||||
return _baseLvl;
|
||||
}
|
||||
|
||||
public static int getEnchantRoute(int level)
|
||||
{
|
||||
return (int) Math.floor(level / 100);
|
||||
}
|
||||
|
||||
public static int getEnchantIndex(int level)
|
||||
{
|
||||
return (level % 100) - 1;
|
||||
}
|
||||
|
||||
public static int getEnchantType(int level)
|
||||
{
|
||||
return ((level - 1) / 100) - 1;
|
||||
}
|
||||
|
||||
public L2EnchantSkillGroup getFirstRouteGroup()
|
||||
{
|
||||
return EnchantSkillGroupsData.getInstance().getEnchantSkillGroupById(_enchantRoutes.firstEntry().getValue());
|
||||
}
|
||||
|
||||
public Set<Integer> getAllRoutes()
|
||||
{
|
||||
return _enchantRoutes.keySet();
|
||||
}
|
||||
|
||||
public int getMinSkillLevel(int level)
|
||||
{
|
||||
if ((level % 100) == 1)
|
||||
{
|
||||
return _baseLvl;
|
||||
}
|
||||
return level - 1;
|
||||
}
|
||||
|
||||
public boolean isMaxEnchant(int level)
|
||||
{
|
||||
final int enchantType = getEnchantRoute(level);
|
||||
if ((enchantType < 1) || !_enchantRoutes.containsKey(enchantType))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final int index = getEnchantIndex(level);
|
||||
|
||||
if ((index + 1) >= EnchantSkillGroupsData.getInstance().getEnchantSkillGroupById(_enchantRoutes.get(enchantType)).getEnchantGroupDetails().size())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public EnchantSkillHolder getEnchantSkillHolder(int level)
|
||||
{
|
||||
final int enchantType = getEnchantRoute(level);
|
||||
if ((enchantType < 1) || !_enchantRoutes.containsKey(enchantType))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final int index = getEnchantIndex(level);
|
||||
final L2EnchantSkillGroup group = EnchantSkillGroupsData.getInstance().getEnchantSkillGroupById(_enchantRoutes.get(enchantType));
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
return group.getEnchantGroupDetails().get(0);
|
||||
}
|
||||
else if (index >= group.getEnchantGroupDetails().size())
|
||||
{
|
||||
return group.getEnchantGroupDetails().get(EnchantSkillGroupsData.getInstance().getEnchantSkillGroupById(_enchantRoutes.get(enchantType)).getEnchantGroupDetails().size() - 1);
|
||||
}
|
||||
return group.getEnchantGroupDetails().get(index);
|
||||
}
|
||||
}
|
||||
@@ -1,79 +1,63 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* @author JIV
|
||||
*/
|
||||
public class L2ExtractableProduct
|
||||
{
|
||||
private final int _id;
|
||||
private final int _min;
|
||||
private final int _max;
|
||||
private final int _chance;
|
||||
private final int _minEnchant;
|
||||
private final int _maxEnchant;
|
||||
|
||||
/**
|
||||
* Create Extractable product
|
||||
* @param id create item id
|
||||
* @param min item count max
|
||||
* @param max item count min
|
||||
* @param chance chance for creating
|
||||
* @param minEnchant item min enchant
|
||||
* @param maxEnchant item max enchant
|
||||
*/
|
||||
public L2ExtractableProduct(int id, int min, int max, double chance, int minEnchant, int maxEnchant)
|
||||
{
|
||||
_id = id;
|
||||
_min = min;
|
||||
_max = max;
|
||||
_chance = (int) (chance * 1000);
|
||||
_minEnchant = minEnchant;
|
||||
_maxEnchant = maxEnchant;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getMin()
|
||||
{
|
||||
return _min;
|
||||
}
|
||||
|
||||
public int getMax()
|
||||
{
|
||||
return _max;
|
||||
}
|
||||
|
||||
public int getChance()
|
||||
{
|
||||
return _chance;
|
||||
}
|
||||
|
||||
public int getMinEnchant()
|
||||
{
|
||||
return _minEnchant;
|
||||
}
|
||||
|
||||
public int getMaxEnchant()
|
||||
{
|
||||
return _maxEnchant;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* @author JIV
|
||||
*/
|
||||
public class L2ExtractableProduct
|
||||
{
|
||||
private final int _id;
|
||||
private final int _min;
|
||||
private final int _max;
|
||||
private final int _chance;
|
||||
|
||||
/**
|
||||
* Create Extractable product
|
||||
* @param id crete item id
|
||||
* @param min item count max
|
||||
* @param max item count min
|
||||
* @param chance chance for creating
|
||||
*/
|
||||
public L2ExtractableProduct(int id, int min, int max, double chance)
|
||||
{
|
||||
_id = id;
|
||||
_min = min;
|
||||
_max = max;
|
||||
_chance = (int) (chance * 1000);
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getMin()
|
||||
{
|
||||
return _min;
|
||||
}
|
||||
|
||||
public int getMax()
|
||||
{
|
||||
return _max;
|
||||
}
|
||||
|
||||
public int getChance()
|
||||
{
|
||||
return _chance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +1,52 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
|
||||
/**
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class L2ExtractableProductItem
|
||||
{
|
||||
private final List<ItemHolder> _items;
|
||||
private final double _chance;
|
||||
|
||||
public L2ExtractableProductItem(List<ItemHolder> items, double chance)
|
||||
{
|
||||
_items = items;
|
||||
_chance = chance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the the production list.
|
||||
*/
|
||||
public List<ItemHolder> getItems()
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the chance of the production list.
|
||||
*/
|
||||
public double getChance()
|
||||
{
|
||||
return _chance;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
|
||||
/**
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class L2ExtractableProductItem
|
||||
{
|
||||
private final List<ItemHolder> _items;
|
||||
private final double _chance;
|
||||
|
||||
public L2ExtractableProductItem(List<ItemHolder> items, double chance)
|
||||
{
|
||||
_items = items;
|
||||
_chance = chance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the the production list.
|
||||
*/
|
||||
public List<ItemHolder> getItems()
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the chance of the production list.
|
||||
*/
|
||||
public double getChance()
|
||||
{
|
||||
return _chance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Extractable skill DTO.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class L2ExtractableSkill
|
||||
{
|
||||
private final int _hash;
|
||||
private final List<L2ExtractableProductItem> _product;
|
||||
|
||||
/**
|
||||
* Instantiates a new extractable skill.
|
||||
* @param hash the hash
|
||||
* @param products the products
|
||||
*/
|
||||
public L2ExtractableSkill(int hash, List<L2ExtractableProductItem> products)
|
||||
{
|
||||
_hash = hash;
|
||||
_product = products;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skill hash.
|
||||
* @return the skill hash
|
||||
*/
|
||||
public int getSkillHash()
|
||||
{
|
||||
return _hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the product items.
|
||||
* @return the product items
|
||||
*/
|
||||
public List<L2ExtractableProductItem> getProductItems()
|
||||
{
|
||||
return _product;
|
||||
}
|
||||
}
|
||||
@@ -1,99 +1,91 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.TerritoryTable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* @author littlecrow A special spawn implementation to spawn controllable mob
|
||||
*/
|
||||
public class L2GroupSpawn extends L2Spawn
|
||||
{
|
||||
private final L2NpcTemplate _template;
|
||||
|
||||
public L2GroupSpawn(L2NpcTemplate mobTemplate) throws SecurityException, ClassNotFoundException, NoSuchMethodException
|
||||
{
|
||||
super(mobTemplate);
|
||||
_template = mobTemplate;
|
||||
|
||||
setAmount(1);
|
||||
}
|
||||
|
||||
public L2Npc doGroupSpawn()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_template.isType("L2Pet") || _template.isType("L2Minion"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int newlocx = 0;
|
||||
int newlocy = 0;
|
||||
int newlocz = 0;
|
||||
|
||||
if ((getX() == 0) && (getY() == 0))
|
||||
{
|
||||
if (getLocationId() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final Location location = TerritoryTable.getInstance().getRandomPoint(getLocationId());
|
||||
if (location != null)
|
||||
{
|
||||
newlocx = location.getX();
|
||||
newlocy = location.getY();
|
||||
newlocz = location.getZ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newlocx = getX();
|
||||
newlocy = getY();
|
||||
newlocz = getZ();
|
||||
}
|
||||
|
||||
final L2Npc mob = new L2ControllableMobInstance(_template);
|
||||
mob.setCurrentHpMp(mob.getMaxHp(), mob.getMaxMp());
|
||||
|
||||
mob.setHeading(getHeading() == -1 ? Rnd.nextInt(61794) : getHeading());
|
||||
|
||||
mob.setSpawn(this);
|
||||
mob.spawnMe(newlocx, newlocy, newlocz);
|
||||
mob.onSpawn();
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.finest("Spawned Mob Id: " + _template.getId() + " ,at: X: " + mob.getX() + " Y: " + mob.getY() + " Z: " + mob.getZ());
|
||||
}
|
||||
return mob;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "NPC class not found: " + e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
|
||||
/**
|
||||
* @author littlecrow A special spawn implementation to spawn controllable mob
|
||||
*/
|
||||
public class L2GroupSpawn extends L2Spawn
|
||||
{
|
||||
private final L2NpcTemplate _template;
|
||||
|
||||
public L2GroupSpawn(L2NpcTemplate mobTemplate) throws SecurityException, ClassNotFoundException, NoSuchMethodException
|
||||
{
|
||||
super(mobTemplate);
|
||||
_template = mobTemplate;
|
||||
|
||||
setAmount(1);
|
||||
}
|
||||
|
||||
public L2Npc doGroupSpawn()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_template.isType("L2Pet") || _template.isType("L2Minion"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int newlocx = 0;
|
||||
int newlocy = 0;
|
||||
int newlocz = 0;
|
||||
|
||||
if ((getX() == 0) && (getY() == 0))
|
||||
{
|
||||
if (getLocationId() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
newlocx = getX();
|
||||
newlocy = getY();
|
||||
newlocz = getZ();
|
||||
|
||||
final L2Npc mob = new L2ControllableMobInstance(_template);
|
||||
mob.setCurrentHpMp(mob.getMaxHp(), mob.getMaxMp());
|
||||
|
||||
if (getHeading() == -1)
|
||||
{
|
||||
mob.setHeading(Rnd.nextInt(61794));
|
||||
}
|
||||
else
|
||||
{
|
||||
mob.setHeading(getHeading());
|
||||
}
|
||||
|
||||
mob.setSpawn(this);
|
||||
mob.spawnMe(newlocx, newlocy, newlocz);
|
||||
return mob;
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "NPC class not found: " + e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +1,48 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.RecipeData;
|
||||
|
||||
public class L2ManufactureItem
|
||||
{
|
||||
private final int _recipeId;
|
||||
private final long _cost;
|
||||
private final boolean _isDwarven;
|
||||
|
||||
public L2ManufactureItem(int recipeId, long cost)
|
||||
{
|
||||
_recipeId = recipeId;
|
||||
_cost = cost;
|
||||
_isDwarven = RecipeData.getInstance().getRecipeList(_recipeId).isDwarvenRecipe();
|
||||
}
|
||||
|
||||
public int getRecipeId()
|
||||
{
|
||||
return _recipeId;
|
||||
}
|
||||
|
||||
public long getCost()
|
||||
{
|
||||
return _cost;
|
||||
}
|
||||
|
||||
public boolean isDwarven()
|
||||
{
|
||||
return _isDwarven;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.RecipeData;
|
||||
|
||||
public class L2ManufactureItem
|
||||
{
|
||||
private final int _recipeId;
|
||||
private final long _cost;
|
||||
private final boolean _isDwarven;
|
||||
|
||||
public L2ManufactureItem(int recipeId, long cost)
|
||||
{
|
||||
_recipeId = recipeId;
|
||||
_cost = cost;
|
||||
_isDwarven = RecipeData.getInstance().getRecipeList(_recipeId).isDwarvenRecipe();
|
||||
}
|
||||
|
||||
public int getRecipeId()
|
||||
{
|
||||
return _recipeId;
|
||||
}
|
||||
|
||||
public long getCost()
|
||||
{
|
||||
return _cost;
|
||||
}
|
||||
|
||||
public boolean isDwarven()
|
||||
{
|
||||
return _isDwarven;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,192 +1,220 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.enums.Race;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* @author Nyaran
|
||||
*/
|
||||
public class L2MapRegion
|
||||
{
|
||||
private final String _name;
|
||||
private final String _town;
|
||||
private final int _locId;
|
||||
private final int _castle;
|
||||
private final int _bbs;
|
||||
private List<int[]> _maps = null;
|
||||
|
||||
private List<Location> _spawnLocs = null;
|
||||
private List<Location> _otherSpawnLocs = null;
|
||||
private List<Location> _chaoticSpawnLocs = null;
|
||||
private List<Location> _banishSpawnLocs = null;
|
||||
|
||||
private final Map<Race, String> _bannedRace = new HashMap<>();
|
||||
|
||||
public L2MapRegion(String name, String town, int locId, int castle, int bbs)
|
||||
{
|
||||
_name = name;
|
||||
_town = town;
|
||||
_locId = locId;
|
||||
_castle = castle;
|
||||
_bbs = bbs;
|
||||
}
|
||||
|
||||
public final String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public final String getTown()
|
||||
{
|
||||
return _town;
|
||||
}
|
||||
|
||||
public final int getLocId()
|
||||
{
|
||||
return _locId;
|
||||
}
|
||||
|
||||
public final int getCastle()
|
||||
{
|
||||
return _castle;
|
||||
}
|
||||
|
||||
public final int getBbs()
|
||||
{
|
||||
return _bbs;
|
||||
}
|
||||
|
||||
public final void addMap(int x, int y)
|
||||
{
|
||||
if (_maps == null)
|
||||
{
|
||||
_maps = new ArrayList<>();
|
||||
}
|
||||
|
||||
_maps.add(new int[]
|
||||
{
|
||||
x,
|
||||
y
|
||||
});
|
||||
}
|
||||
|
||||
public final List<int[]> getMaps()
|
||||
{
|
||||
return _maps;
|
||||
}
|
||||
|
||||
public final boolean isZoneInRegion(int x, int y)
|
||||
{
|
||||
if (_maps == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int[] map : _maps)
|
||||
{
|
||||
if ((map[0] == x) && (map[1] == y))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Respawn
|
||||
public final void addSpawn(int x, int y, int z)
|
||||
{
|
||||
if (_spawnLocs == null)
|
||||
{
|
||||
_spawnLocs = new ArrayList<>();
|
||||
}
|
||||
|
||||
_spawnLocs.add(new Location(x, y, z));
|
||||
}
|
||||
|
||||
public final void addOtherSpawn(int x, int y, int z)
|
||||
{
|
||||
if (_otherSpawnLocs == null)
|
||||
{
|
||||
_otherSpawnLocs = new ArrayList<>();
|
||||
}
|
||||
|
||||
_otherSpawnLocs.add(new Location(x, y, z));
|
||||
}
|
||||
|
||||
public final void addChaoticSpawn(int x, int y, int z)
|
||||
{
|
||||
if (_chaoticSpawnLocs == null)
|
||||
{
|
||||
_chaoticSpawnLocs = new ArrayList<>();
|
||||
}
|
||||
|
||||
_chaoticSpawnLocs.add(new Location(x, y, z));
|
||||
}
|
||||
|
||||
public final void addBanishSpawn(int x, int y, int z)
|
||||
{
|
||||
if (_banishSpawnLocs == null)
|
||||
{
|
||||
_banishSpawnLocs = new ArrayList<>();
|
||||
}
|
||||
|
||||
_banishSpawnLocs.add(new Location(x, y, z));
|
||||
}
|
||||
|
||||
public final List<Location> getSpawns()
|
||||
{
|
||||
return _spawnLocs;
|
||||
}
|
||||
|
||||
public final Location getSpawnLoc()
|
||||
{
|
||||
return Config.RANDOM_RESPAWN_IN_TOWN_ENABLED ? _spawnLocs.get(Rnd.get(_spawnLocs.size())) : _spawnLocs.get(0);
|
||||
}
|
||||
|
||||
public final Location getOtherSpawnLoc()
|
||||
{
|
||||
return _otherSpawnLocs != null ? Config.RANDOM_RESPAWN_IN_TOWN_ENABLED ? _otherSpawnLocs.get(Rnd.get(_otherSpawnLocs.size())) : _otherSpawnLocs.get(0) : getSpawnLoc();
|
||||
}
|
||||
|
||||
public final Location getChaoticSpawnLoc()
|
||||
{
|
||||
return _chaoticSpawnLocs != null ? Config.RANDOM_RESPAWN_IN_TOWN_ENABLED ? _chaoticSpawnLocs.get(Rnd.get(_chaoticSpawnLocs.size())) : _chaoticSpawnLocs.get(0) : getSpawnLoc();
|
||||
}
|
||||
|
||||
public final Location getBanishSpawnLoc()
|
||||
{
|
||||
return _banishSpawnLocs != null ? Config.RANDOM_RESPAWN_IN_TOWN_ENABLED ? _banishSpawnLocs.get(Rnd.get(_banishSpawnLocs.size())) : _banishSpawnLocs.get(0) : getSpawnLoc();
|
||||
}
|
||||
|
||||
public final void addBannedRace(String race, String point)
|
||||
{
|
||||
_bannedRace.put(Race.valueOf(race), point);
|
||||
}
|
||||
|
||||
public final Map<Race, String> getBannedRace()
|
||||
{
|
||||
return _bannedRace;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.enums.Race;
|
||||
|
||||
/**
|
||||
* @author Nyaran
|
||||
*/
|
||||
public class L2MapRegion
|
||||
{
|
||||
private final String _name;
|
||||
private final String _town;
|
||||
private final int _locId;
|
||||
private final int _castle;
|
||||
private final int _bbs;
|
||||
private List<int[]> _maps = null;
|
||||
|
||||
private List<Location> _spawnLocs = null;
|
||||
private List<Location> _otherSpawnLocs = null;
|
||||
private List<Location> _chaoticSpawnLocs = null;
|
||||
private List<Location> _banishSpawnLocs = null;
|
||||
|
||||
private final Map<Race, String> _bannedRace = new HashMap<>();
|
||||
|
||||
public L2MapRegion(String name, String town, int locId, int castle, int bbs)
|
||||
{
|
||||
_name = name;
|
||||
_town = town;
|
||||
_locId = locId;
|
||||
_castle = castle;
|
||||
_bbs = bbs;
|
||||
}
|
||||
|
||||
public final String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public final String getTown()
|
||||
{
|
||||
return _town;
|
||||
}
|
||||
|
||||
public final int getLocId()
|
||||
{
|
||||
return _locId;
|
||||
}
|
||||
|
||||
public final int getCastle()
|
||||
{
|
||||
return _castle;
|
||||
}
|
||||
|
||||
public final int getBbs()
|
||||
{
|
||||
return _bbs;
|
||||
}
|
||||
|
||||
public final void addMap(int x, int y)
|
||||
{
|
||||
if (_maps == null)
|
||||
{
|
||||
_maps = new ArrayList<>();
|
||||
}
|
||||
|
||||
_maps.add(new int[]
|
||||
{
|
||||
x,
|
||||
y
|
||||
});
|
||||
}
|
||||
|
||||
public final List<int[]> getMaps()
|
||||
{
|
||||
return _maps;
|
||||
}
|
||||
|
||||
public final boolean isZoneInRegion(int x, int y)
|
||||
{
|
||||
if (_maps == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int[] map : _maps)
|
||||
{
|
||||
if ((map[0] == x) && (map[1] == y))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Respawn
|
||||
public final void addSpawn(int x, int y, int z)
|
||||
{
|
||||
if (_spawnLocs == null)
|
||||
{
|
||||
_spawnLocs = new ArrayList<>();
|
||||
}
|
||||
|
||||
_spawnLocs.add(new Location(x, y, z));
|
||||
}
|
||||
|
||||
public final void addOtherSpawn(int x, int y, int z)
|
||||
{
|
||||
if (_otherSpawnLocs == null)
|
||||
{
|
||||
_otherSpawnLocs = new ArrayList<>();
|
||||
}
|
||||
|
||||
_otherSpawnLocs.add(new Location(x, y, z));
|
||||
}
|
||||
|
||||
public final void addChaoticSpawn(int x, int y, int z)
|
||||
{
|
||||
if (_chaoticSpawnLocs == null)
|
||||
{
|
||||
_chaoticSpawnLocs = new ArrayList<>();
|
||||
}
|
||||
|
||||
_chaoticSpawnLocs.add(new Location(x, y, z));
|
||||
}
|
||||
|
||||
public final void addBanishSpawn(int x, int y, int z)
|
||||
{
|
||||
if (_banishSpawnLocs == null)
|
||||
{
|
||||
_banishSpawnLocs = new ArrayList<>();
|
||||
}
|
||||
|
||||
_banishSpawnLocs.add(new Location(x, y, z));
|
||||
}
|
||||
|
||||
public final List<Location> getSpawns()
|
||||
{
|
||||
return _spawnLocs;
|
||||
}
|
||||
|
||||
public final Location getSpawnLoc()
|
||||
{
|
||||
if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
|
||||
{
|
||||
return _spawnLocs.get(Rnd.get(_spawnLocs.size()));
|
||||
}
|
||||
return _spawnLocs.get(0);
|
||||
}
|
||||
|
||||
public final Location getOtherSpawnLoc()
|
||||
{
|
||||
if (_otherSpawnLocs != null)
|
||||
{
|
||||
if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
|
||||
{
|
||||
return _otherSpawnLocs.get(Rnd.get(_otherSpawnLocs.size()));
|
||||
}
|
||||
return _otherSpawnLocs.get(0);
|
||||
}
|
||||
return getSpawnLoc();
|
||||
}
|
||||
|
||||
public final Location getChaoticSpawnLoc()
|
||||
{
|
||||
if (_chaoticSpawnLocs != null)
|
||||
{
|
||||
if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
|
||||
{
|
||||
return _chaoticSpawnLocs.get(Rnd.get(_chaoticSpawnLocs.size()));
|
||||
}
|
||||
return _chaoticSpawnLocs.get(0);
|
||||
}
|
||||
return getSpawnLoc();
|
||||
}
|
||||
|
||||
public final Location getBanishSpawnLoc()
|
||||
{
|
||||
if (_banishSpawnLocs != null)
|
||||
{
|
||||
if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
|
||||
{
|
||||
return _banishSpawnLocs.get(Rnd.get(_banishSpawnLocs.size()));
|
||||
}
|
||||
return _banishSpawnLocs.get(0);
|
||||
}
|
||||
return getSpawnLoc();
|
||||
}
|
||||
|
||||
public final void addBannedRace(String race, String point)
|
||||
{
|
||||
_bannedRace.put(Race.valueOf(race), point);
|
||||
}
|
||||
|
||||
public final Map<Race, String> getBannedRace()
|
||||
{
|
||||
return _bannedRace;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,129 +1,135 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class L2Mentee
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(L2Mentee.class.getName());
|
||||
|
||||
private final int _objectId;
|
||||
private String _name;
|
||||
private int _classId;
|
||||
private int _currentLevel;
|
||||
|
||||
public L2Mentee(int objectId)
|
||||
{
|
||||
_objectId = objectId;
|
||||
load();
|
||||
}
|
||||
|
||||
public void load()
|
||||
{
|
||||
final L2PcInstance player = getPlayerInstance();
|
||||
if (player == null) // Only if player is offline
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT char_name, level, base_class FROM characters WHERE charId = ?"))
|
||||
{
|
||||
ps.setInt(1, getObjectId());
|
||||
try (ResultSet rs = ps.executeQuery())
|
||||
{
|
||||
if (rs.next())
|
||||
{
|
||||
_name = rs.getString("char_name");
|
||||
_classId = rs.getInt("base_class");
|
||||
_currentLevel = rs.getInt("level");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_name = player.getName();
|
||||
_classId = player.getBaseClassId();
|
||||
_currentLevel = player.getLevel();
|
||||
}
|
||||
}
|
||||
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public int getClassId()
|
||||
{
|
||||
if (isOnline() && (getPlayerInstance().getClassId().getId() != _classId))
|
||||
{
|
||||
_classId = getPlayerInstance().getClassId().getId();
|
||||
}
|
||||
return _classId;
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
if (isOnline() && (getPlayerInstance().getLevel() != _currentLevel))
|
||||
{
|
||||
_currentLevel = getPlayerInstance().getLevel();
|
||||
}
|
||||
return _currentLevel;
|
||||
}
|
||||
|
||||
public L2PcInstance getPlayerInstance()
|
||||
{
|
||||
return L2World.getInstance().getPlayer(_objectId);
|
||||
}
|
||||
|
||||
public boolean isOnline()
|
||||
{
|
||||
return (getPlayerInstance() != null) && (getPlayerInstance().isOnlineInt() > 0);
|
||||
}
|
||||
|
||||
public int isOnlineInt()
|
||||
{
|
||||
return isOnline() ? getPlayerInstance().isOnlineInt() : 0;
|
||||
}
|
||||
|
||||
public void sendPacket(L2GameServerPacket packet)
|
||||
{
|
||||
if (isOnline())
|
||||
{
|
||||
getPlayerInstance().sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class L2Mentee
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(L2Mentee.class.getName());
|
||||
|
||||
private final int _objectId;
|
||||
private String _name;
|
||||
private int _classId;
|
||||
private int _currentLevel;
|
||||
|
||||
public L2Mentee(int objectId)
|
||||
{
|
||||
_objectId = objectId;
|
||||
load();
|
||||
}
|
||||
|
||||
public void load()
|
||||
{
|
||||
final L2PcInstance player = getPlayerInstance();
|
||||
if (player == null) // Only if player is offline
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT char_name, level, base_class FROM characters WHERE charId = ?"))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
if (rset.next())
|
||||
{
|
||||
_name = rset.getString("char_name");
|
||||
_classId = rset.getInt("base_class");
|
||||
_currentLevel = rset.getInt("level");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_name = player.getName();
|
||||
_classId = player.getBaseClass();
|
||||
_currentLevel = player.getLevel();
|
||||
}
|
||||
}
|
||||
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public int getClassId()
|
||||
{
|
||||
if (isOnline())
|
||||
{
|
||||
if (getPlayerInstance().getClassId().getId() != _classId)
|
||||
{
|
||||
_classId = getPlayerInstance().getClassId().getId();
|
||||
}
|
||||
}
|
||||
return _classId;
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
if (isOnline())
|
||||
{
|
||||
if (getPlayerInstance().getLevel() != _currentLevel)
|
||||
{
|
||||
_currentLevel = getPlayerInstance().getLevel();
|
||||
}
|
||||
}
|
||||
return _currentLevel;
|
||||
}
|
||||
|
||||
public L2PcInstance getPlayerInstance()
|
||||
{
|
||||
return L2World.getInstance().getPlayer(_objectId);
|
||||
}
|
||||
|
||||
public boolean isOnline()
|
||||
{
|
||||
return (getPlayerInstance() != null) && (getPlayerInstance().isOnlineInt() > 0);
|
||||
}
|
||||
|
||||
public int isOnlineInt()
|
||||
{
|
||||
return isOnline() ? getPlayerInstance().isOnlineInt() : 0;
|
||||
}
|
||||
|
||||
public void sendPacket(IClientOutgoingPacket packet)
|
||||
{
|
||||
if (isOnline())
|
||||
{
|
||||
getPlayerInstance().sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +1,64 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.network.NpcStringId;
|
||||
|
||||
/**
|
||||
* @author Rayan RPG, JIV
|
||||
* @since 927
|
||||
*/
|
||||
public class L2NpcWalkerNode extends Location
|
||||
{
|
||||
private final String _chatString;
|
||||
private final NpcStringId _npcString;
|
||||
private final int _delay;
|
||||
private final boolean _runToLocation;
|
||||
|
||||
public L2NpcWalkerNode(int moveX, int moveY, int moveZ, int delay, boolean runToLocation, NpcStringId npcString, String chatText)
|
||||
{
|
||||
super(moveX, moveY, moveZ);
|
||||
_delay = delay;
|
||||
_runToLocation = runToLocation;
|
||||
_npcString = npcString;
|
||||
_chatString = (chatText == null) ? "" : chatText;
|
||||
}
|
||||
|
||||
public int getDelay()
|
||||
{
|
||||
return _delay;
|
||||
}
|
||||
|
||||
public boolean runToLocation()
|
||||
{
|
||||
return _runToLocation;
|
||||
}
|
||||
|
||||
public NpcStringId getNpcString()
|
||||
{
|
||||
return _npcString;
|
||||
}
|
||||
|
||||
public String getChatText()
|
||||
{
|
||||
if (_npcString != null)
|
||||
{
|
||||
throw new IllegalStateException("npcString is defined for walker route!");
|
||||
}
|
||||
return _chatString;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.network.NpcStringId;
|
||||
|
||||
/**
|
||||
* @author Rayan RPG, JIV
|
||||
* @since 927
|
||||
*/
|
||||
public class L2NpcWalkerNode extends Location
|
||||
{
|
||||
private final String _chatString;
|
||||
private final NpcStringId _npcString;
|
||||
private final int _delay;
|
||||
private final boolean _runToLocation;
|
||||
|
||||
public L2NpcWalkerNode(int moveX, int moveY, int moveZ, int delay, boolean runToLocation, NpcStringId npcString, String chatText)
|
||||
{
|
||||
super(moveX, moveY, moveZ);
|
||||
_delay = delay;
|
||||
_runToLocation = runToLocation;
|
||||
_npcString = npcString;
|
||||
_chatString = ((chatText == null) ? "" : chatText);
|
||||
}
|
||||
|
||||
public int getDelay()
|
||||
{
|
||||
return _delay;
|
||||
}
|
||||
|
||||
public boolean runToLocation()
|
||||
{
|
||||
return _runToLocation;
|
||||
}
|
||||
|
||||
public NpcStringId getNpcString()
|
||||
{
|
||||
return _npcString;
|
||||
}
|
||||
|
||||
public String getChatText()
|
||||
{
|
||||
if (_npcString != null)
|
||||
{
|
||||
throw new IllegalStateException("npcString is defined for walker route!");
|
||||
}
|
||||
return _chatString;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,249 +1,252 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.l2jmobius.gameserver.datatables.SkillData;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
|
||||
/**
|
||||
* Class hold information about basic pet stats which are same on each level.
|
||||
* @author JIV
|
||||
*/
|
||||
public class L2PetData
|
||||
{
|
||||
private final Map<Integer, L2PetLevelData> _levelStats = new HashMap<>();
|
||||
private final List<L2PetSkillLearn> _skills = new ArrayList<>();
|
||||
|
||||
private final int _npcId;
|
||||
private final int _itemId;
|
||||
private int _load = 20000;
|
||||
private int _hungryLimit = 1;
|
||||
private int _minlvl = Byte.MAX_VALUE;
|
||||
private boolean _syncLevel = false;
|
||||
private final List<Integer> _food = new ArrayList<>();
|
||||
|
||||
public L2PetData(int npcId, int itemId)
|
||||
{
|
||||
_npcId = npcId;
|
||||
_itemId = itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the npc id representing this pet.
|
||||
*/
|
||||
public int getNpcId()
|
||||
{
|
||||
return _npcId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the item id that could summon this pet.
|
||||
*/
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param level the pet's level.
|
||||
* @param data the pet's data.
|
||||
*/
|
||||
public void addNewStat(int level, L2PetLevelData data)
|
||||
{
|
||||
if (_minlvl > level)
|
||||
{
|
||||
_minlvl = level;
|
||||
}
|
||||
_levelStats.put(level, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param petLevel the pet's level.
|
||||
* @return the pet data associated to that pet level.
|
||||
*/
|
||||
public L2PetLevelData getPetLevelData(int petLevel)
|
||||
{
|
||||
return _levelStats.get(petLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's weight load.
|
||||
*/
|
||||
public int getLoad()
|
||||
{
|
||||
return _load;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's hunger limit.
|
||||
*/
|
||||
public int getHungryLimit()
|
||||
{
|
||||
return _hungryLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if pet synchronizes it's level with his master's
|
||||
*/
|
||||
public boolean isSynchLevel()
|
||||
{
|
||||
return _syncLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's minimum level.
|
||||
*/
|
||||
public int getMinLevel()
|
||||
{
|
||||
return _minlvl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's food list.
|
||||
*/
|
||||
public List<Integer> getFood()
|
||||
{
|
||||
return _food;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param foodId the pet's food Id to add.
|
||||
*/
|
||||
public void addFood(Integer foodId)
|
||||
{
|
||||
_food.add(foodId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param load the weight load to set.
|
||||
*/
|
||||
public void setLoad(int load)
|
||||
{
|
||||
_load = load;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param limit the hunger limit to set.
|
||||
*/
|
||||
public void setHungryLimit(int limit)
|
||||
{
|
||||
_hungryLimit = limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val synchronizes level with master or not.
|
||||
*/
|
||||
public void setSyncLevel(boolean val)
|
||||
{
|
||||
_syncLevel = val;
|
||||
}
|
||||
|
||||
// SKILS
|
||||
|
||||
/**
|
||||
* @param skillId the skill Id to add.
|
||||
* @param skillLvl the skill level.
|
||||
* @param petLvl the pet's level when this skill is available.
|
||||
*/
|
||||
public void addNewSkill(int skillId, int skillLvl, int petLvl)
|
||||
{
|
||||
_skills.add(new L2PetSkillLearn(skillId, skillLvl, petLvl));
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Simplify this.
|
||||
* @param skillId the skill Id.
|
||||
* @param petLvl the pet level.
|
||||
* @return the level of the skill for the given skill Id and pet level.
|
||||
*/
|
||||
public int getAvailableLevel(int skillId, int petLvl)
|
||||
{
|
||||
int lvl = 0;
|
||||
for (L2PetSkillLearn temp : _skills)
|
||||
{
|
||||
if (temp.getSkillId() != skillId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (temp.getSkillLvl() == 0)
|
||||
{
|
||||
if (petLvl < 70)
|
||||
{
|
||||
lvl = petLvl / 10;
|
||||
if (lvl <= 0)
|
||||
{
|
||||
lvl = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lvl = 7 + ((petLvl - 70) / 5);
|
||||
}
|
||||
|
||||
// formula usable for skill that have 10 or more skill levels
|
||||
final int maxLvl = SkillData.getInstance().getMaxLevel(temp.getSkillId());
|
||||
if (lvl > maxLvl)
|
||||
{
|
||||
lvl = maxLvl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ((temp.getMinLevel() <= petLvl) && (temp.getSkillLvl() > lvl))
|
||||
{
|
||||
lvl = temp.getSkillLvl();
|
||||
}
|
||||
}
|
||||
return lvl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list with the pet's skill data.
|
||||
*/
|
||||
public List<L2PetSkillLearn> getAvailableSkills()
|
||||
{
|
||||
return _skills;
|
||||
}
|
||||
|
||||
public static final class L2PetSkillLearn extends SkillHolder
|
||||
{
|
||||
private final int _minLevel;
|
||||
|
||||
/**
|
||||
* @param id the skill Id.
|
||||
* @param lvl the skill level.
|
||||
* @param minLvl the minimum level when this skill is available.
|
||||
*/
|
||||
public L2PetSkillLearn(int id, int lvl, int minLvl)
|
||||
{
|
||||
super(id, lvl);
|
||||
_minLevel = minLvl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the minimum level for the pet to get the skill.
|
||||
*/
|
||||
public int getMinLevel()
|
||||
{
|
||||
return _minLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
|
||||
/**
|
||||
* Class hold information about basic pet stats which are same on each level.
|
||||
* @author JIV
|
||||
*/
|
||||
public class L2PetData
|
||||
{
|
||||
private final Map<Integer, L2PetLevelData> _levelStats = new HashMap<>();
|
||||
private final List<L2PetSkillLearn> _skills = new ArrayList<>();
|
||||
|
||||
private final int _npcId;
|
||||
private final int _itemId;
|
||||
private int _load = 20000;
|
||||
private int _hungryLimit = 1;
|
||||
private int _minlvl = Byte.MAX_VALUE;
|
||||
private boolean _syncLevel = false;
|
||||
private final List<Integer> _food = new ArrayList<>();
|
||||
|
||||
public L2PetData(int npcId, int itemId)
|
||||
{
|
||||
_npcId = npcId;
|
||||
_itemId = itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the npc id representing this pet.
|
||||
*/
|
||||
public int getNpcId()
|
||||
{
|
||||
return _npcId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the item id that could summon this pet.
|
||||
*/
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param level the pet's level.
|
||||
* @param data the pet's data.
|
||||
*/
|
||||
public void addNewStat(int level, L2PetLevelData data)
|
||||
{
|
||||
if (_minlvl > level)
|
||||
{
|
||||
_minlvl = level;
|
||||
}
|
||||
_levelStats.put(level, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param petLevel the pet's level.
|
||||
* @return the pet data associated to that pet level.
|
||||
*/
|
||||
public L2PetLevelData getPetLevelData(int petLevel)
|
||||
{
|
||||
return _levelStats.get(petLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's weight load.
|
||||
*/
|
||||
public int getLoad()
|
||||
{
|
||||
return _load;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's hunger limit.
|
||||
*/
|
||||
public int getHungryLimit()
|
||||
{
|
||||
return _hungryLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if pet synchronizes it's level with his master's
|
||||
*/
|
||||
public boolean isSynchLevel()
|
||||
{
|
||||
return _syncLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's minimum level.
|
||||
*/
|
||||
public int getMinLevel()
|
||||
{
|
||||
return _minlvl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's food list.
|
||||
*/
|
||||
public List<Integer> getFood()
|
||||
{
|
||||
return _food;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param foodId the pet's food Id to add.
|
||||
*/
|
||||
public void addFood(Integer foodId)
|
||||
{
|
||||
_food.add(foodId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param load the weight load to set.
|
||||
*/
|
||||
public void setLoad(int load)
|
||||
{
|
||||
_load = load;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param limit the hunger limit to set.
|
||||
*/
|
||||
public void setHungryLimit(int limit)
|
||||
{
|
||||
_hungryLimit = limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val synchronizes level with master or not.
|
||||
*/
|
||||
public void setSyncLevel(boolean val)
|
||||
{
|
||||
_syncLevel = val;
|
||||
}
|
||||
|
||||
// SKILS
|
||||
|
||||
/**
|
||||
* @param skillId the skill Id to add.
|
||||
* @param skillLvl the skill level.
|
||||
* @param petLvl the pet's level when this skill is available.
|
||||
*/
|
||||
public void addNewSkill(int skillId, int skillLvl, int petLvl)
|
||||
{
|
||||
_skills.add(new L2PetSkillLearn(skillId, skillLvl, petLvl));
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Simplify this.
|
||||
* @param skillId the skill Id.
|
||||
* @param petLvl the pet level.
|
||||
* @return the level of the skill for the given skill Id and pet level.
|
||||
*/
|
||||
public int getAvailableLevel(int skillId, int petLvl)
|
||||
{
|
||||
int lvl = 0;
|
||||
for (L2PetSkillLearn temp : _skills)
|
||||
{
|
||||
if (temp.getSkillId() != skillId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (temp.getSkillLvl() == 0)
|
||||
{
|
||||
if (petLvl < 70)
|
||||
{
|
||||
lvl = (petLvl / 10);
|
||||
if (lvl <= 0)
|
||||
{
|
||||
lvl = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lvl = (7 + ((petLvl - 70) / 5));
|
||||
}
|
||||
|
||||
// formula usable for skill that have 10 or more skill levels
|
||||
final int maxLvl = SkillData.getInstance().getMaxLevel(temp.getSkillId());
|
||||
if (lvl > maxLvl)
|
||||
{
|
||||
lvl = maxLvl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (temp.getMinLevel() <= petLvl)
|
||||
{
|
||||
if (temp.getSkillLvl() > lvl)
|
||||
{
|
||||
lvl = temp.getSkillLvl();
|
||||
}
|
||||
}
|
||||
}
|
||||
return lvl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list with the pet's skill data.
|
||||
*/
|
||||
public List<L2PetSkillLearn> getAvailableSkills()
|
||||
{
|
||||
return _skills;
|
||||
}
|
||||
|
||||
public static final class L2PetSkillLearn extends SkillHolder
|
||||
{
|
||||
private final int _minLevel;
|
||||
|
||||
/**
|
||||
* @param id the skill Id.
|
||||
* @param lvl the skill level.
|
||||
* @param minLvl the minimum level when this skill is available.
|
||||
*/
|
||||
public L2PetSkillLearn(int id, int lvl, int minLvl)
|
||||
{
|
||||
super(id, lvl);
|
||||
_minLevel = minLvl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the minimum level for the pet to get the skill.
|
||||
*/
|
||||
public int getMinLevel()
|
||||
{
|
||||
return _minLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,230 +1,218 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.stats.MoveType;
|
||||
|
||||
/**
|
||||
* Stats definition for each pet level.
|
||||
* @author JIV, Zoey76
|
||||
*/
|
||||
public class L2PetLevelData
|
||||
{
|
||||
private final int _ownerExpTaken;
|
||||
private final int _petFeedBattle;
|
||||
private final int _petFeedNormal;
|
||||
private final float _petMAtk;
|
||||
private final long _petMaxExp;
|
||||
private final int _petMaxFeed;
|
||||
private final float _petMaxHP;
|
||||
private final float _petMaxMP;
|
||||
private final float _petMDef;
|
||||
private final float _petPAtk;
|
||||
private final float _petPDef;
|
||||
private final float _petRegenHP;
|
||||
private final float _petRegenMP;
|
||||
private final short _petSoulShot;
|
||||
private final short _petSpiritShot;
|
||||
private final double _walkSpeedOnRide;
|
||||
private final double _runSpeedOnRide;
|
||||
private final double _slowSwimSpeedOnRide;
|
||||
private final double _fastSwimSpeedOnRide;
|
||||
private final double _slowFlySpeedOnRide;
|
||||
private final double _fastFlySpeedOnRide;
|
||||
|
||||
public L2PetLevelData(StatsSet set)
|
||||
{
|
||||
_ownerExpTaken = set.getInt("get_exp_type");
|
||||
_petMaxExp = set.getLong("exp");
|
||||
_petMaxHP = set.getFloat("org_hp");
|
||||
_petMaxMP = set.getFloat("org_mp");
|
||||
_petPAtk = set.getFloat("org_pattack");
|
||||
_petPDef = set.getFloat("org_pdefend");
|
||||
_petMAtk = set.getFloat("org_mattack");
|
||||
_petMDef = set.getFloat("org_mdefend");
|
||||
_petMaxFeed = set.getInt("max_meal");
|
||||
_petFeedBattle = set.getInt("consume_meal_in_battle");
|
||||
_petFeedNormal = set.getInt("consume_meal_in_normal");
|
||||
_petRegenHP = set.getFloat("org_hp_regen");
|
||||
_petRegenMP = set.getFloat("org_mp_regen");
|
||||
_petSoulShot = set.getShort("soulshot_count");
|
||||
_petSpiritShot = set.getShort("spiritshot_count");
|
||||
_walkSpeedOnRide = set.getDouble("walkSpeedOnRide", 0);
|
||||
_runSpeedOnRide = set.getDouble("runSpeedOnRide", 0);
|
||||
_slowSwimSpeedOnRide = set.getDouble("slowSwimSpeedOnRide", 0);
|
||||
_fastSwimSpeedOnRide = set.getDouble("fastSwimSpeedOnRide", 0);
|
||||
_slowFlySpeedOnRide = set.getDouble("slowFlySpeedOnRide", 0);
|
||||
_fastFlySpeedOnRide = set.getDouble("fastFlySpeedOnRide", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the owner's experience points consumed by the pet.
|
||||
*/
|
||||
public int getOwnerExpTaken()
|
||||
{
|
||||
return _ownerExpTaken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's food consume rate at battle state.
|
||||
*/
|
||||
public int getPetFeedBattle()
|
||||
{
|
||||
return _petFeedBattle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's food consume rate at normal state.
|
||||
*/
|
||||
public int getPetFeedNormal()
|
||||
{
|
||||
return _petFeedNormal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's Magical Attack.
|
||||
*/
|
||||
public float getPetMAtk()
|
||||
{
|
||||
return _petMAtk;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's maximum experience points.
|
||||
*/
|
||||
public long getPetMaxExp()
|
||||
{
|
||||
return _petMaxExp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's maximum feed points.
|
||||
*/
|
||||
public int getPetMaxFeed()
|
||||
{
|
||||
return _petMaxFeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's maximum HP.
|
||||
*/
|
||||
public float getPetMaxHP()
|
||||
{
|
||||
return _petMaxHP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's maximum MP.
|
||||
*/
|
||||
public float getPetMaxMP()
|
||||
{
|
||||
return _petMaxMP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's Magical Defense.
|
||||
*/
|
||||
public float getPetMDef()
|
||||
{
|
||||
return _petMDef;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's Physical Attack.
|
||||
*/
|
||||
public float getPetPAtk()
|
||||
{
|
||||
return _petPAtk;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's Physical Defense.
|
||||
*/
|
||||
public float getPetPDef()
|
||||
{
|
||||
return _petPDef;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's HP regeneration rate.
|
||||
*/
|
||||
public float getPetRegenHP()
|
||||
{
|
||||
return _petRegenHP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's MP regeneration rate.
|
||||
*/
|
||||
public float getPetRegenMP()
|
||||
{
|
||||
return _petRegenMP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's soulshot use count.
|
||||
*/
|
||||
public short getPetSoulShot()
|
||||
{
|
||||
return _petSoulShot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's spiritshot use count.
|
||||
*/
|
||||
public short getPetSpiritShot()
|
||||
{
|
||||
return _petSpiritShot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mt movement type
|
||||
* @return the base riding speed of given movement type.
|
||||
*/
|
||||
public double getSpeedOnRide(MoveType mt)
|
||||
{
|
||||
switch (mt)
|
||||
{
|
||||
case WALK:
|
||||
{
|
||||
return _walkSpeedOnRide;
|
||||
}
|
||||
case RUN:
|
||||
{
|
||||
return _runSpeedOnRide;
|
||||
}
|
||||
case SLOW_SWIM:
|
||||
{
|
||||
return _slowSwimSpeedOnRide;
|
||||
}
|
||||
case FAST_SWIM:
|
||||
{
|
||||
return _fastSwimSpeedOnRide;
|
||||
}
|
||||
case SLOW_FLY:
|
||||
{
|
||||
return _slowFlySpeedOnRide;
|
||||
}
|
||||
case FAST_FLY:
|
||||
{
|
||||
return _fastFlySpeedOnRide;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* Stats definition for each pet level.
|
||||
* @author JIV, Zoey76
|
||||
*/
|
||||
public class L2PetLevelData
|
||||
{
|
||||
private final int _ownerExpTaken;
|
||||
private final int _petFeedBattle;
|
||||
private final int _petFeedNormal;
|
||||
private final float _petMAtk;
|
||||
private final long _petMaxExp;
|
||||
private final int _petMaxFeed;
|
||||
private final float _petMaxHP;
|
||||
private final float _petMaxMP;
|
||||
private final float _petMDef;
|
||||
private final float _petPAtk;
|
||||
private final float _petPDef;
|
||||
private final float _petRegenHP;
|
||||
private final float _petRegenMP;
|
||||
private final short _petSoulShot;
|
||||
private final short _petSpiritShot;
|
||||
private final double _walkSpeedOnRide;
|
||||
private final double _runSpeedOnRide;
|
||||
private final double _slowSwimSpeedOnRide;
|
||||
private final double _fastSwimSpeedOnRide;
|
||||
private final double _slowFlySpeedOnRide;
|
||||
private final double _fastFlySpeedOnRide;
|
||||
|
||||
public L2PetLevelData(StatsSet set)
|
||||
{
|
||||
_ownerExpTaken = set.getInt("get_exp_type");
|
||||
_petMaxExp = set.getLong("exp");
|
||||
_petMaxHP = set.getFloat("org_hp");
|
||||
_petMaxMP = set.getFloat("org_mp");
|
||||
_petPAtk = set.getFloat("org_pattack");
|
||||
_petPDef = set.getFloat("org_pdefend");
|
||||
_petMAtk = set.getFloat("org_mattack");
|
||||
_petMDef = set.getFloat("org_mdefend");
|
||||
_petMaxFeed = set.getInt("max_meal");
|
||||
_petFeedBattle = set.getInt("consume_meal_in_battle");
|
||||
_petFeedNormal = set.getInt("consume_meal_in_normal");
|
||||
_petRegenHP = set.getFloat("org_hp_regen");
|
||||
_petRegenMP = set.getFloat("org_mp_regen");
|
||||
_petSoulShot = set.getShort("soulshot_count");
|
||||
_petSpiritShot = set.getShort("spiritshot_count");
|
||||
_walkSpeedOnRide = set.getDouble("walkSpeedOnRide", 0);
|
||||
_runSpeedOnRide = set.getDouble("runSpeedOnRide", 0);
|
||||
_slowSwimSpeedOnRide = set.getDouble("slowSwimSpeedOnRide", 0);
|
||||
_fastSwimSpeedOnRide = set.getDouble("fastSwimSpeedOnRide", 0);
|
||||
_slowFlySpeedOnRide = set.getDouble("slowFlySpeedOnRide", 0);
|
||||
_fastFlySpeedOnRide = set.getDouble("fastFlySpeedOnRide", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the owner's experience points consumed by the pet.
|
||||
*/
|
||||
public int getOwnerExpTaken()
|
||||
{
|
||||
return _ownerExpTaken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's food consume rate at battle state.
|
||||
*/
|
||||
public int getPetFeedBattle()
|
||||
{
|
||||
return _petFeedBattle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's food consume rate at normal state.
|
||||
*/
|
||||
public int getPetFeedNormal()
|
||||
{
|
||||
return _petFeedNormal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's Magical Attack.
|
||||
*/
|
||||
public float getPetMAtk()
|
||||
{
|
||||
return _petMAtk;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's maximum experience points.
|
||||
*/
|
||||
public long getPetMaxExp()
|
||||
{
|
||||
return _petMaxExp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's maximum feed points.
|
||||
*/
|
||||
public int getPetMaxFeed()
|
||||
{
|
||||
return _petMaxFeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's maximum HP.
|
||||
*/
|
||||
public float getPetMaxHP()
|
||||
{
|
||||
return _petMaxHP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's maximum MP.
|
||||
*/
|
||||
public float getPetMaxMP()
|
||||
{
|
||||
return _petMaxMP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's Magical Defense.
|
||||
*/
|
||||
public float getPetMDef()
|
||||
{
|
||||
return _petMDef;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's Physical Attack.
|
||||
*/
|
||||
public float getPetPAtk()
|
||||
{
|
||||
return _petPAtk;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's Physical Defense.
|
||||
*/
|
||||
public float getPetPDef()
|
||||
{
|
||||
return _petPDef;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's HP regeneration rate.
|
||||
*/
|
||||
public float getPetRegenHP()
|
||||
{
|
||||
return _petRegenHP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's MP regeneration rate.
|
||||
*/
|
||||
public float getPetRegenMP()
|
||||
{
|
||||
return _petRegenMP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's soulshot use count.
|
||||
*/
|
||||
public short getPetSoulShot()
|
||||
{
|
||||
return _petSoulShot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet's spiritshot use count.
|
||||
*/
|
||||
public short getPetSpiritShot()
|
||||
{
|
||||
return _petSpiritShot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stat movement type
|
||||
* @return the base riding speed of given movement type.
|
||||
*/
|
||||
public double getSpeedOnRide(Stats stat)
|
||||
{
|
||||
switch (stat)
|
||||
{
|
||||
case WALK_SPEED:
|
||||
return _walkSpeedOnRide;
|
||||
case RUN_SPEED:
|
||||
return _runSpeedOnRide;
|
||||
case SWIM_WALK_SPEED:
|
||||
return _slowSwimSpeedOnRide;
|
||||
case SWIM_RUN_SPEED:
|
||||
return _fastSwimSpeedOnRide;
|
||||
case FLY_RUN_SPEED:
|
||||
return _slowFlySpeedOnRide;
|
||||
case FLY_WALK_SPEED:
|
||||
return _fastFlySpeedOnRide;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
** @author Gnacik
|
||||
*/
|
||||
public class L2PremiumItem
|
||||
{
|
||||
private final int _itemId;
|
||||
private long _count;
|
||||
private final String _sender;
|
||||
|
||||
public L2PremiumItem(int itemid, long count, String sender)
|
||||
{
|
||||
_itemId = itemid;
|
||||
_count = count;
|
||||
_sender = sender;
|
||||
}
|
||||
|
||||
public void updateCount(long newcount)
|
||||
{
|
||||
_count = newcount;
|
||||
}
|
||||
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
public long getCount()
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
public String getSender()
|
||||
{
|
||||
return _sender;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
** @author Gnacik
|
||||
*/
|
||||
public class L2PremiumItem
|
||||
{
|
||||
private final int _itemId;
|
||||
private long _count;
|
||||
private final String _sender;
|
||||
|
||||
public L2PremiumItem(int itemid, long count, String sender)
|
||||
{
|
||||
_itemId = itemid;
|
||||
_count = count;
|
||||
_sender = sender;
|
||||
}
|
||||
|
||||
public void updateCount(long newcount)
|
||||
{
|
||||
_count = newcount;
|
||||
}
|
||||
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
public long getCount()
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
public String getSender()
|
||||
{
|
||||
return _sender;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,123 +1,132 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.RadarControl;
|
||||
|
||||
/**
|
||||
* @author dalrond
|
||||
*/
|
||||
public final class L2Radar
|
||||
{
|
||||
private final L2PcInstance _player;
|
||||
private final List<RadarMarker> _markers = new CopyOnWriteArrayList<>();
|
||||
|
||||
public L2Radar(L2PcInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
// Add a marker to player's radar
|
||||
public void addMarker(int x, int y, int z)
|
||||
{
|
||||
final RadarMarker newMarker = new RadarMarker(x, y, z);
|
||||
|
||||
_markers.add(newMarker);
|
||||
_player.sendPacket(new RadarControl(2, 2, x, y, z));
|
||||
_player.sendPacket(new RadarControl(0, 1, x, y, z));
|
||||
}
|
||||
|
||||
// Remove a marker from player's radar
|
||||
public void removeMarker(int x, int y, int z)
|
||||
{
|
||||
final RadarMarker newMarker = new RadarMarker(x, y, z);
|
||||
|
||||
_markers.remove(newMarker);
|
||||
_player.sendPacket(new RadarControl(1, 1, x, y, z));
|
||||
}
|
||||
|
||||
public void removeAllMarkers()
|
||||
{
|
||||
for (RadarMarker tempMarker : _markers)
|
||||
{
|
||||
_player.sendPacket(new RadarControl(2, 2, tempMarker._x, tempMarker._y, tempMarker._z));
|
||||
}
|
||||
|
||||
_markers.clear();
|
||||
}
|
||||
|
||||
public void loadMarkers()
|
||||
{
|
||||
_player.sendPacket(new RadarControl(2, 2, _player.getX(), _player.getY(), _player.getZ()));
|
||||
for (RadarMarker tempMarker : _markers)
|
||||
{
|
||||
_player.sendPacket(new RadarControl(0, 1, tempMarker._x, tempMarker._y, tempMarker._z));
|
||||
}
|
||||
}
|
||||
|
||||
public static class RadarMarker
|
||||
{
|
||||
// Simple class to model radar points.
|
||||
public int _type, _x, _y, _z;
|
||||
|
||||
public RadarMarker(int type, int x, int y, int z)
|
||||
{
|
||||
_type = type;
|
||||
_x = x;
|
||||
_y = y;
|
||||
_z = z;
|
||||
}
|
||||
|
||||
public RadarMarker(int x, int y, int z)
|
||||
{
|
||||
_type = 1;
|
||||
_x = x;
|
||||
_y = y;
|
||||
_z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = (prime * result) + _type;
|
||||
result = (prime * result) + _x;
|
||||
result = (prime * result) + _y;
|
||||
return result = (prime * result) + _z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof RadarMarker))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final RadarMarker other = (RadarMarker) obj;
|
||||
return (_type == other._type) && (_x == other._x) && (_y == other._y) && (_z == other._z);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.RadarControl;
|
||||
|
||||
/**
|
||||
* @author dalrond
|
||||
*/
|
||||
public final class L2Radar
|
||||
{
|
||||
private final L2PcInstance _player;
|
||||
private final Set<RadarMarker> _markers = ConcurrentHashMap.newKeySet();
|
||||
|
||||
public L2Radar(L2PcInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
// Add a marker to player's radar
|
||||
public void addMarker(int x, int y, int z)
|
||||
{
|
||||
final RadarMarker newMarker = new RadarMarker(x, y, z);
|
||||
|
||||
_markers.add(newMarker);
|
||||
_player.sendPacket(new RadarControl(2, 2, x, y, z));
|
||||
_player.sendPacket(new RadarControl(0, 1, x, y, z));
|
||||
}
|
||||
|
||||
// Remove a marker from player's radar
|
||||
public void removeMarker(int x, int y, int z)
|
||||
{
|
||||
for (RadarMarker rm : _markers)
|
||||
{
|
||||
if ((rm._x == x) && (rm._y == y) && (rm._z == z))
|
||||
{
|
||||
_markers.remove(rm);
|
||||
}
|
||||
}
|
||||
_player.sendPacket(new RadarControl(1, 1, x, y, z));
|
||||
}
|
||||
|
||||
public void removeAllMarkers()
|
||||
{
|
||||
for (RadarMarker tempMarker : _markers)
|
||||
{
|
||||
_player.sendPacket(new RadarControl(2, 2, tempMarker._x, tempMarker._y, tempMarker._z));
|
||||
}
|
||||
|
||||
_markers.clear();
|
||||
}
|
||||
|
||||
public void loadMarkers()
|
||||
{
|
||||
_player.sendPacket(new RadarControl(2, 2, _player.getX(), _player.getY(), _player.getZ()));
|
||||
for (RadarMarker tempMarker : _markers)
|
||||
{
|
||||
_player.sendPacket(new RadarControl(0, 1, tempMarker._x, tempMarker._y, tempMarker._z));
|
||||
}
|
||||
}
|
||||
|
||||
public static class RadarMarker
|
||||
{
|
||||
// Simple class to model radar points.
|
||||
public int _type, _x, _y, _z;
|
||||
|
||||
public RadarMarker(int type, int x, int y, int z)
|
||||
{
|
||||
_type = type;
|
||||
_x = x;
|
||||
_y = y;
|
||||
_z = z;
|
||||
}
|
||||
|
||||
public RadarMarker(int x, int y, int z)
|
||||
{
|
||||
_type = 1;
|
||||
_x = x;
|
||||
_y = y;
|
||||
_z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = (prime * result) + _type;
|
||||
result = (prime * result) + _x;
|
||||
result = (prime * result) + _y;
|
||||
result = (prime * result) + _z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof RadarMarker))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final RadarMarker other = (RadarMarker) obj;
|
||||
if ((_type != other._type) || (_x != other._x) || (_y != other._y) || (_z != other._z))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +1,57 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* This class describes a RecipeList component (1 line of the recipe : Item-Quantity needed).
|
||||
*/
|
||||
public class L2RecipeInstance
|
||||
{
|
||||
/** The Identifier of the item needed in the L2RecipeInstance */
|
||||
private final int _itemId;
|
||||
|
||||
/** The item quantity needed in the L2RecipeInstance */
|
||||
private final int _quantity;
|
||||
|
||||
/**
|
||||
* Constructor of L2RecipeInstance (create a new line in a RecipeList).
|
||||
* @param itemId
|
||||
* @param quantity
|
||||
*/
|
||||
public L2RecipeInstance(int itemId, int quantity)
|
||||
{
|
||||
_itemId = itemId;
|
||||
_quantity = quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Identifier of the L2RecipeInstance Item needed.
|
||||
*/
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Item quantity needed of the L2RecipeInstance.
|
||||
*/
|
||||
public int getQuantity()
|
||||
{
|
||||
return _quantity;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* This class describes a RecipeList component (1 line of the recipe : Item-Quantity needed).
|
||||
*/
|
||||
public class L2RecipeInstance
|
||||
{
|
||||
/** The Identifier of the item needed in the L2RecipeInstance */
|
||||
private final int _itemId;
|
||||
|
||||
/** The item quantity needed in the L2RecipeInstance */
|
||||
private final int _quantity;
|
||||
|
||||
/**
|
||||
* Constructor of L2RecipeInstance (create a new line in a RecipeList).
|
||||
* @param itemId
|
||||
* @param quantity
|
||||
*/
|
||||
public L2RecipeInstance(int itemId, int quantity)
|
||||
{
|
||||
_itemId = itemId;
|
||||
_quantity = quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Identifier of the L2RecipeInstance Item needed.
|
||||
*/
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Item quantity needed of the L2RecipeInstance.
|
||||
*/
|
||||
public int getQuantity()
|
||||
{
|
||||
return _quantity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,242 +1,242 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* This class describes a Recipe used by Dwarf to craft Item. All L2RecipeList are made of L2RecipeInstance (1 line of the recipe : Item-Quantity needed).
|
||||
*/
|
||||
public class L2RecipeList
|
||||
{
|
||||
/** The table containing all L2RecipeInstance (1 line of the recipe : Item-Quantity needed) of the L2RecipeList */
|
||||
private L2RecipeInstance[] _recipes;
|
||||
|
||||
/** The table containing all L2RecipeStatInstance for the statUse parameter of the L2RecipeList */
|
||||
private L2RecipeStatInstance[] _statUse;
|
||||
|
||||
/** The table containing all L2RecipeStatInstance for the altStatChange parameter of the L2RecipeList */
|
||||
private L2RecipeStatInstance[] _altStatChange;
|
||||
|
||||
/** The Identifier of the Instance */
|
||||
private final int _id;
|
||||
|
||||
/** The crafting level needed to use this L2RecipeList */
|
||||
private final int _level;
|
||||
|
||||
/** The Identifier of the L2RecipeList */
|
||||
private final int _recipeId;
|
||||
|
||||
/** The name of the L2RecipeList */
|
||||
private final String _recipeName;
|
||||
|
||||
/** The crafting success rate when using the L2RecipeList */
|
||||
private final int _successRate;
|
||||
|
||||
/** The Identifier of the Item crafted with this L2RecipeList */
|
||||
private final int _itemId;
|
||||
|
||||
/** The quantity of Item crafted when using this L2RecipeList */
|
||||
private final int _count;
|
||||
|
||||
/** The Identifier of the Rare Item crafted with this L2RecipeList */
|
||||
private int _rareItemId;
|
||||
|
||||
/** The quantity of Rare Item crafted when using this L2RecipeList */
|
||||
private int _rareCount;
|
||||
|
||||
/** The chance of Rare Item crafted when using this L2RecipeList */
|
||||
private int _rarity;
|
||||
|
||||
/** If this a common or a dwarven recipe */
|
||||
private final boolean _isDwarvenRecipe;
|
||||
|
||||
/**
|
||||
* Constructor of L2RecipeList (create a new Recipe).
|
||||
* @param set
|
||||
* @param haveRare
|
||||
*/
|
||||
public L2RecipeList(StatsSet set, boolean haveRare)
|
||||
{
|
||||
_recipes = new L2RecipeInstance[0];
|
||||
_statUse = new L2RecipeStatInstance[0];
|
||||
_altStatChange = new L2RecipeStatInstance[0];
|
||||
_id = set.getInt("id");
|
||||
_level = set.getInt("craftLevel");
|
||||
_recipeId = set.getInt("recipeId");
|
||||
_recipeName = set.getString("recipeName");
|
||||
_successRate = set.getInt("successRate");
|
||||
_itemId = set.getInt("itemId");
|
||||
_count = set.getInt("count");
|
||||
if (haveRare)
|
||||
{
|
||||
_rareItemId = set.getInt("rareItemId");
|
||||
_rareCount = set.getInt("rareCount");
|
||||
_rarity = set.getInt("rarity");
|
||||
}
|
||||
_isDwarvenRecipe = set.getBoolean("isDwarvenRecipe");
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a L2RecipeInstance to the L2RecipeList (add a line Item-Quantity needed to the Recipe).
|
||||
* @param recipe
|
||||
*/
|
||||
public void addRecipe(L2RecipeInstance recipe)
|
||||
{
|
||||
final int len = _recipes.length;
|
||||
final L2RecipeInstance[] tmp = new L2RecipeInstance[len + 1];
|
||||
System.arraycopy(_recipes, 0, tmp, 0, len);
|
||||
tmp[len] = recipe;
|
||||
_recipes = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a L2RecipeStatInstance of the statUse parameter to the L2RecipeList.
|
||||
* @param statUse
|
||||
*/
|
||||
public void addStatUse(L2RecipeStatInstance statUse)
|
||||
{
|
||||
final int len = _statUse.length;
|
||||
final L2RecipeStatInstance[] tmp = new L2RecipeStatInstance[len + 1];
|
||||
System.arraycopy(_statUse, 0, tmp, 0, len);
|
||||
tmp[len] = statUse;
|
||||
_statUse = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a L2RecipeStatInstance of the altStatChange parameter to the L2RecipeList.
|
||||
* @param statChange
|
||||
*/
|
||||
public void addAltStatChange(L2RecipeStatInstance statChange)
|
||||
{
|
||||
final int len = _altStatChange.length;
|
||||
final L2RecipeStatInstance[] tmp = new L2RecipeStatInstance[len + 1];
|
||||
System.arraycopy(_altStatChange, 0, tmp, 0, len);
|
||||
tmp[len] = statChange;
|
||||
_altStatChange = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Identifier of the Instance.
|
||||
*/
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the crafting level needed to use this L2RecipeList.
|
||||
*/
|
||||
public int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Identifier of the L2RecipeList.
|
||||
*/
|
||||
public int getRecipeId()
|
||||
{
|
||||
return _recipeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the L2RecipeList.
|
||||
*/
|
||||
public String getRecipeName()
|
||||
{
|
||||
return _recipeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the crafting success rate when using the L2RecipeList.
|
||||
*/
|
||||
public int getSuccessRate()
|
||||
{
|
||||
return _successRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Identifier of the Item crafted with this L2RecipeList.
|
||||
*/
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the quantity of Item crafted when using this L2RecipeList.
|
||||
*/
|
||||
public int getCount()
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Identifier of the Rare Item crafted with this L2RecipeList.
|
||||
*/
|
||||
public int getRareItemId()
|
||||
{
|
||||
return _rareItemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the quantity of Rare Item crafted when using this L2RecipeList.
|
||||
*/
|
||||
public int getRareCount()
|
||||
{
|
||||
return _rareCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the chance of Rare Item crafted when using this L2RecipeList.
|
||||
*/
|
||||
public int getRarity()
|
||||
{
|
||||
return _rarity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if this a Dwarven recipe or {@code false} if its a Common recipe
|
||||
*/
|
||||
public boolean isDwarvenRecipe()
|
||||
{
|
||||
return _isDwarvenRecipe;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the table containing all L2RecipeInstance (1 line of the recipe : Item-Quantity needed) of the L2RecipeList.
|
||||
*/
|
||||
public L2RecipeInstance[] getRecipes()
|
||||
{
|
||||
return _recipes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the table containing all L2RecipeStatInstance of the statUse parameter of the L2RecipeList.
|
||||
*/
|
||||
public L2RecipeStatInstance[] getStatUse()
|
||||
{
|
||||
return _statUse;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the table containing all L2RecipeStatInstance of the AltStatChange parameter of the L2RecipeList.
|
||||
*/
|
||||
public L2RecipeStatInstance[] getAltStatChange()
|
||||
{
|
||||
return _altStatChange;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* This class describes a Recipe used by Dwarf to craft Item. All L2RecipeList are made of L2RecipeInstance (1 line of the recipe : Item-Quantity needed).
|
||||
*/
|
||||
public class L2RecipeList
|
||||
{
|
||||
/** The table containing all L2RecipeInstance (1 line of the recipe : Item-Quantity needed) of the L2RecipeList */
|
||||
private L2RecipeInstance[] _recipes;
|
||||
|
||||
/** The table containing all L2RecipeStatInstance for the statUse parameter of the L2RecipeList */
|
||||
private L2RecipeStatInstance[] _statUse;
|
||||
|
||||
/** The table containing all L2RecipeStatInstance for the altStatChange parameter of the L2RecipeList */
|
||||
private L2RecipeStatInstance[] _altStatChange;
|
||||
|
||||
/** The Identifier of the Instance */
|
||||
private final int _id;
|
||||
|
||||
/** The crafting level needed to use this L2RecipeList */
|
||||
private final int _level;
|
||||
|
||||
/** The Identifier of the L2RecipeList */
|
||||
private final int _recipeId;
|
||||
|
||||
/** The name of the L2RecipeList */
|
||||
private final String _recipeName;
|
||||
|
||||
/** The crafting success rate when using the L2RecipeList */
|
||||
private final int _successRate;
|
||||
|
||||
/** The Identifier of the Item crafted with this L2RecipeList */
|
||||
private final int _itemId;
|
||||
|
||||
/** The quantity of Item crafted when using this L2RecipeList */
|
||||
private final int _count;
|
||||
|
||||
/** The Identifier of the Rare Item crafted with this L2RecipeList */
|
||||
private int _rareItemId;
|
||||
|
||||
/** The quantity of Rare Item crafted when using this L2RecipeList */
|
||||
private int _rareCount;
|
||||
|
||||
/** The chance of Rare Item crafted when using this L2RecipeList */
|
||||
private int _rarity;
|
||||
|
||||
/** If this a common or a dwarven recipe */
|
||||
private final boolean _isDwarvenRecipe;
|
||||
|
||||
/**
|
||||
* Constructor of L2RecipeList (create a new Recipe).
|
||||
* @param set
|
||||
* @param haveRare
|
||||
*/
|
||||
public L2RecipeList(StatsSet set, boolean haveRare)
|
||||
{
|
||||
_recipes = new L2RecipeInstance[0];
|
||||
_statUse = new L2RecipeStatInstance[0];
|
||||
_altStatChange = new L2RecipeStatInstance[0];
|
||||
_id = set.getInt("id");
|
||||
_level = set.getInt("craftLevel");
|
||||
_recipeId = set.getInt("recipeId");
|
||||
_recipeName = set.getString("recipeName");
|
||||
_successRate = set.getInt("successRate");
|
||||
_itemId = set.getInt("itemId");
|
||||
_count = set.getInt("count");
|
||||
if (haveRare)
|
||||
{
|
||||
_rareItemId = set.getInt("rareItemId");
|
||||
_rareCount = set.getInt("rareCount");
|
||||
_rarity = set.getInt("rarity");
|
||||
}
|
||||
_isDwarvenRecipe = set.getBoolean("isDwarvenRecipe");
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a L2RecipeInstance to the L2RecipeList (add a line Item-Quantity needed to the Recipe).
|
||||
* @param recipe
|
||||
*/
|
||||
public void addRecipe(L2RecipeInstance recipe)
|
||||
{
|
||||
final int len = _recipes.length;
|
||||
final L2RecipeInstance[] tmp = new L2RecipeInstance[len + 1];
|
||||
System.arraycopy(_recipes, 0, tmp, 0, len);
|
||||
tmp[len] = recipe;
|
||||
_recipes = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a L2RecipeStatInstance of the statUse parameter to the L2RecipeList.
|
||||
* @param statUse
|
||||
*/
|
||||
public void addStatUse(L2RecipeStatInstance statUse)
|
||||
{
|
||||
final int len = _statUse.length;
|
||||
final L2RecipeStatInstance[] tmp = new L2RecipeStatInstance[len + 1];
|
||||
System.arraycopy(_statUse, 0, tmp, 0, len);
|
||||
tmp[len] = statUse;
|
||||
_statUse = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a L2RecipeStatInstance of the altStatChange parameter to the L2RecipeList.
|
||||
* @param statChange
|
||||
*/
|
||||
public void addAltStatChange(L2RecipeStatInstance statChange)
|
||||
{
|
||||
final int len = _altStatChange.length;
|
||||
final L2RecipeStatInstance[] tmp = new L2RecipeStatInstance[len + 1];
|
||||
System.arraycopy(_altStatChange, 0, tmp, 0, len);
|
||||
tmp[len] = statChange;
|
||||
_altStatChange = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Identifier of the Instance.
|
||||
*/
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the crafting level needed to use this L2RecipeList.
|
||||
*/
|
||||
public int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Identifier of the L2RecipeList.
|
||||
*/
|
||||
public int getRecipeId()
|
||||
{
|
||||
return _recipeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the L2RecipeList.
|
||||
*/
|
||||
public String getRecipeName()
|
||||
{
|
||||
return _recipeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the crafting success rate when using the L2RecipeList.
|
||||
*/
|
||||
public int getSuccessRate()
|
||||
{
|
||||
return _successRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Identifier of the Item crafted with this L2RecipeList.
|
||||
*/
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the quantity of Item crafted when using this L2RecipeList.
|
||||
*/
|
||||
public int getCount()
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Identifier of the Rare Item crafted with this L2RecipeList.
|
||||
*/
|
||||
public int getRareItemId()
|
||||
{
|
||||
return _rareItemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the quantity of Rare Item crafted when using this L2RecipeList.
|
||||
*/
|
||||
public int getRareCount()
|
||||
{
|
||||
return _rareCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the chance of Rare Item crafted when using this L2RecipeList.
|
||||
*/
|
||||
public int getRarity()
|
||||
{
|
||||
return _rarity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if this a Dwarven recipe or {@code false} if its a Common recipe
|
||||
*/
|
||||
public boolean isDwarvenRecipe()
|
||||
{
|
||||
return _isDwarvenRecipe;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the table containing all L2RecipeInstance (1 line of the recipe : Item-Quantity needed) of the L2RecipeList.
|
||||
*/
|
||||
public L2RecipeInstance[] getRecipes()
|
||||
{
|
||||
return _recipes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the table containing all L2RecipeStatInstance of the statUse parameter of the L2RecipeList.
|
||||
*/
|
||||
public L2RecipeStatInstance[] getStatUse()
|
||||
{
|
||||
return _statUse;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the table containing all L2RecipeStatInstance of the AltStatChange parameter of the L2RecipeList.
|
||||
*/
|
||||
public L2RecipeStatInstance[] getAltStatChange()
|
||||
{
|
||||
return _altStatChange;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,58 +1,59 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.StatType;
|
||||
|
||||
/**
|
||||
* This class describes a RecipeList statUse and altStatChange component.
|
||||
*/
|
||||
public class L2RecipeStatInstance
|
||||
{
|
||||
/** The Identifier of the statType */
|
||||
private final StatType _type;
|
||||
|
||||
/** The value of the statType */
|
||||
private final int _value;
|
||||
|
||||
/**
|
||||
* Constructor of L2RecipeStatInstance.
|
||||
* @param type
|
||||
* @param value
|
||||
*/
|
||||
public L2RecipeStatInstance(String type, int value)
|
||||
{
|
||||
_type = Enum.valueOf(StatType.class, type);
|
||||
_value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the the type of the L2RecipeStatInstance.
|
||||
*/
|
||||
public StatType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value of the L2RecipeStatInstance.
|
||||
*/
|
||||
public int getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.StatType;
|
||||
|
||||
/**
|
||||
* This class describes a RecipeList statUse and altStatChange component.
|
||||
*/
|
||||
public class L2RecipeStatInstance
|
||||
{
|
||||
/** The Identifier of the statType */
|
||||
private final StatType _type;
|
||||
|
||||
/** The value of the statType */
|
||||
private final int _value;
|
||||
|
||||
/**
|
||||
* Constructor of L2RecipeStatInstance.
|
||||
* @param type
|
||||
* @param value
|
||||
*/
|
||||
public L2RecipeStatInstance(String type, int value)
|
||||
{
|
||||
_type = Enum.valueOf(StatType.class, type);
|
||||
_value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the the type of the L2RecipeStatInstance.
|
||||
*/
|
||||
public StatType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value of the L2RecipeStatInstance.
|
||||
*/
|
||||
public int getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,148 +1,148 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.L2GameClientPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* This class manages requests (transactions) between two L2PcInstance.
|
||||
* @author kriau
|
||||
*/
|
||||
public class L2Request
|
||||
{
|
||||
private static final int REQUEST_TIMEOUT = 15; // in secs
|
||||
|
||||
protected L2PcInstance _player;
|
||||
protected L2PcInstance _partner;
|
||||
protected boolean _isRequestor;
|
||||
protected boolean _isAnswerer;
|
||||
protected L2GameClientPacket _requestPacket;
|
||||
|
||||
public L2Request(L2PcInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
protected void clear()
|
||||
{
|
||||
_partner = null;
|
||||
_requestPacket = null;
|
||||
_isRequestor = false;
|
||||
_isAnswerer = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the L2PcInstance member of a transaction (ex : FriendInvite, JoinAlly, JoinParty...).
|
||||
* @param partner
|
||||
*/
|
||||
private synchronized void setPartner(L2PcInstance partner)
|
||||
{
|
||||
_partner = partner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the L2PcInstance member of a transaction (ex : FriendInvite, JoinAlly, JoinParty...).
|
||||
*/
|
||||
public L2PcInstance getPartner()
|
||||
{
|
||||
return _partner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the packet incomed from requester.
|
||||
* @param packet
|
||||
*/
|
||||
private synchronized void setRequestPacket(L2GameClientPacket packet)
|
||||
{
|
||||
_requestPacket = packet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the packet originally incomed from requester.
|
||||
* @return
|
||||
*/
|
||||
public L2GameClientPacket getRequestPacket()
|
||||
{
|
||||
return _requestPacket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if request can be made and in success case puts both PC on request state.
|
||||
* @param partner
|
||||
* @param packet
|
||||
* @return
|
||||
*/
|
||||
public synchronized boolean setRequest(L2PcInstance partner, L2GameClientPacket packet)
|
||||
{
|
||||
if (partner == null)
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET);
|
||||
return false;
|
||||
}
|
||||
if (partner.getRequest().isProcessingRequest())
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ON_ANOTHER_TASK_PLEASE_TRY_AGAIN_LATER);
|
||||
sm.addString(partner.getName());
|
||||
_player.sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
if (isProcessingRequest())
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY);
|
||||
return false;
|
||||
}
|
||||
|
||||
_partner = partner;
|
||||
_requestPacket = packet;
|
||||
setOnRequestTimer(true);
|
||||
_partner.getRequest().setPartner(_player);
|
||||
_partner.getRequest().setRequestPacket(packet);
|
||||
_partner.getRequest().setOnRequestTimer(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setOnRequestTimer(boolean isRequestor)
|
||||
{
|
||||
_isRequestor = isRequestor;
|
||||
_isAnswerer = !isRequestor;
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(() -> clear(), REQUEST_TIMEOUT * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears PC request state. Should be called after answer packet receive.
|
||||
*/
|
||||
public void onRequestResponse()
|
||||
{
|
||||
if (_partner != null)
|
||||
{
|
||||
_partner.getRequest().clear();
|
||||
}
|
||||
clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if a transaction is in progress.
|
||||
*/
|
||||
public boolean isProcessingRequest()
|
||||
{
|
||||
return _partner != null;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* This class manages requests (transactions) between two L2PcInstance.
|
||||
* @author kriau
|
||||
*/
|
||||
public class L2Request
|
||||
{
|
||||
private static final int REQUEST_TIMEOUT = 15; // in secs
|
||||
|
||||
protected L2PcInstance _player;
|
||||
protected L2PcInstance _partner;
|
||||
protected boolean _isRequestor;
|
||||
protected boolean _isAnswerer;
|
||||
protected IClientIncomingPacket _requestPacket;
|
||||
|
||||
public L2Request(L2PcInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
protected void clear()
|
||||
{
|
||||
_partner = null;
|
||||
_requestPacket = null;
|
||||
_isRequestor = false;
|
||||
_isAnswerer = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the L2PcInstance member of a transaction (ex : FriendInvite, JoinAlly, JoinParty...).
|
||||
* @param partner
|
||||
*/
|
||||
private synchronized void setPartner(L2PcInstance partner)
|
||||
{
|
||||
_partner = partner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the L2PcInstance member of a transaction (ex : FriendInvite, JoinAlly, JoinParty...).
|
||||
*/
|
||||
public L2PcInstance getPartner()
|
||||
{
|
||||
return _partner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the packet incomed from requester.
|
||||
* @param packet
|
||||
*/
|
||||
private synchronized void setRequestPacket(IClientIncomingPacket packet)
|
||||
{
|
||||
_requestPacket = packet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the packet originally incomed from requester.
|
||||
* @return
|
||||
*/
|
||||
public IClientIncomingPacket getRequestPacket()
|
||||
{
|
||||
return _requestPacket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if request can be made and in success case puts both PC on request state.
|
||||
* @param partner
|
||||
* @param packet
|
||||
* @return
|
||||
*/
|
||||
public synchronized boolean setRequest(L2PcInstance partner, IClientIncomingPacket packet)
|
||||
{
|
||||
if (partner == null)
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET);
|
||||
return false;
|
||||
}
|
||||
if (partner.getRequest().isProcessingRequest())
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ON_ANOTHER_TASK_PLEASE_TRY_AGAIN_LATER);
|
||||
sm.addString(partner.getName());
|
||||
_player.sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
if (isProcessingRequest())
|
||||
{
|
||||
_player.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY);
|
||||
return false;
|
||||
}
|
||||
|
||||
_partner = partner;
|
||||
_requestPacket = packet;
|
||||
setOnRequestTimer(true);
|
||||
_partner.getRequest().setPartner(_player);
|
||||
_partner.getRequest().setRequestPacket(packet);
|
||||
_partner.getRequest().setOnRequestTimer(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setOnRequestTimer(boolean isRequestor)
|
||||
{
|
||||
_isRequestor = isRequestor;
|
||||
_isAnswerer = !isRequestor;
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(() -> clear(), REQUEST_TIMEOUT * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears PC request state. Should be called after answer packet receive.
|
||||
*/
|
||||
public void onRequestResponse()
|
||||
{
|
||||
if (_partner != null)
|
||||
{
|
||||
_partner.getRequest().clear();
|
||||
}
|
||||
clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if a transaction is in progress.
|
||||
*/
|
||||
public boolean isProcessingRequest()
|
||||
{
|
||||
return _partner != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,137 +1,137 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
|
||||
public final class L2Seed
|
||||
{
|
||||
private final int _seedId;
|
||||
private final int _cropId; // crop type
|
||||
private final int _level; // seed level
|
||||
private final int _matureId; // mature crop type
|
||||
private final int _reward1;
|
||||
private final int _reward2;
|
||||
private final int _castleId; // id of manor (castle id) where seed can be farmed
|
||||
private final boolean _isAlternative;
|
||||
private final int _limitSeeds;
|
||||
private final int _limitCrops;
|
||||
private final int _seedReferencePrice;
|
||||
private final int _cropReferencePrice;
|
||||
|
||||
public L2Seed(StatsSet set)
|
||||
{
|
||||
_cropId = set.getInt("id");
|
||||
_seedId = set.getInt("seedId");
|
||||
_level = set.getInt("level");
|
||||
_matureId = set.getInt("mature_Id");
|
||||
_reward1 = set.getInt("reward1");
|
||||
_reward2 = set.getInt("reward2");
|
||||
_castleId = set.getInt("castleId");
|
||||
_isAlternative = set.getBoolean("alternative");
|
||||
_limitCrops = set.getInt("limit_crops");
|
||||
_limitSeeds = set.getInt("limit_seed");
|
||||
// Set prices
|
||||
L2Item item = ItemTable.getInstance().getTemplate(_cropId);
|
||||
_cropReferencePrice = (item != null) ? item.getReferencePrice() : 1;
|
||||
item = ItemTable.getInstance().getTemplate(_seedId);
|
||||
_seedReferencePrice = (item != null) ? item.getReferencePrice() : 1;
|
||||
}
|
||||
|
||||
public final int getCastleId()
|
||||
{
|
||||
return _castleId;
|
||||
}
|
||||
|
||||
public final int getSeedId()
|
||||
{
|
||||
return _seedId;
|
||||
}
|
||||
|
||||
public final int getCropId()
|
||||
{
|
||||
return _cropId;
|
||||
}
|
||||
|
||||
public final int getMatureId()
|
||||
{
|
||||
return _matureId;
|
||||
}
|
||||
|
||||
public final int getReward(int type)
|
||||
{
|
||||
return (type == 1) ? _reward1 : _reward2;
|
||||
}
|
||||
|
||||
public final int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
public final boolean isAlternative()
|
||||
{
|
||||
return _isAlternative;
|
||||
}
|
||||
|
||||
public final int getSeedLimit()
|
||||
{
|
||||
return _limitSeeds * Config.RATE_DROP_MANOR;
|
||||
}
|
||||
|
||||
public final int getCropLimit()
|
||||
{
|
||||
return _limitCrops * Config.RATE_DROP_MANOR;
|
||||
}
|
||||
|
||||
public final int getSeedReferencePrice()
|
||||
{
|
||||
return _seedReferencePrice;
|
||||
}
|
||||
|
||||
public final int getSeedMaxPrice()
|
||||
{
|
||||
return _seedReferencePrice * 10;
|
||||
}
|
||||
|
||||
public final int getSeedMinPrice()
|
||||
{
|
||||
return (int) (_seedReferencePrice * 0.6);
|
||||
}
|
||||
|
||||
public final int getCropReferencePrice()
|
||||
{
|
||||
return _cropReferencePrice;
|
||||
}
|
||||
|
||||
public final int getCropMaxPrice()
|
||||
{
|
||||
return _cropReferencePrice * 10;
|
||||
}
|
||||
|
||||
public final int getCropMinPrice()
|
||||
{
|
||||
return (int) (_cropReferencePrice * 0.6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString()
|
||||
{
|
||||
return "SeedData [_id=" + _seedId + ", _level=" + _level + ", _crop=" + _cropId + ", _mature=" + _matureId + ", _type1=" + _reward1 + ", _type2=" + _reward2 + ", _manorId=" + _castleId + ", _isAlternative=" + _isAlternative + ", _limitSeeds=" + _limitSeeds + ", _limitCrops=" + _limitCrops + "]";
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
|
||||
public final class L2Seed
|
||||
{
|
||||
private final int _seedId;
|
||||
private final int _cropId; // crop type
|
||||
private final int _level; // seed level
|
||||
private final int _matureId; // mature crop type
|
||||
private final int _reward1;
|
||||
private final int _reward2;
|
||||
private final int _castleId; // id of manor (castle id) where seed can be farmed
|
||||
private final boolean _isAlternative;
|
||||
private final int _limitSeeds;
|
||||
private final int _limitCrops;
|
||||
private final int _seedReferencePrice;
|
||||
private final int _cropReferencePrice;
|
||||
|
||||
public L2Seed(StatsSet set)
|
||||
{
|
||||
_cropId = set.getInt("id");
|
||||
_seedId = set.getInt("seedId");
|
||||
_level = set.getInt("level");
|
||||
_matureId = set.getInt("mature_Id");
|
||||
_reward1 = set.getInt("reward1");
|
||||
_reward2 = set.getInt("reward2");
|
||||
_castleId = set.getInt("castleId");
|
||||
_isAlternative = set.getBoolean("alternative");
|
||||
_limitCrops = set.getInt("limit_crops");
|
||||
_limitSeeds = set.getInt("limit_seed");
|
||||
// Set prices
|
||||
L2Item item = ItemTable.getInstance().getTemplate(_cropId);
|
||||
_cropReferencePrice = (item != null) ? item.getReferencePrice() : 1;
|
||||
item = ItemTable.getInstance().getTemplate(_seedId);
|
||||
_seedReferencePrice = (item != null) ? item.getReferencePrice() : 1;
|
||||
}
|
||||
|
||||
public final int getCastleId()
|
||||
{
|
||||
return _castleId;
|
||||
}
|
||||
|
||||
public final int getSeedId()
|
||||
{
|
||||
return _seedId;
|
||||
}
|
||||
|
||||
public final int getCropId()
|
||||
{
|
||||
return _cropId;
|
||||
}
|
||||
|
||||
public final int getMatureId()
|
||||
{
|
||||
return _matureId;
|
||||
}
|
||||
|
||||
public final int getReward(int type)
|
||||
{
|
||||
return (type == 1) ? _reward1 : _reward2;
|
||||
}
|
||||
|
||||
public final int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
public final boolean isAlternative()
|
||||
{
|
||||
return _isAlternative;
|
||||
}
|
||||
|
||||
public final int getSeedLimit()
|
||||
{
|
||||
return _limitSeeds * Config.RATE_DROP_MANOR;
|
||||
}
|
||||
|
||||
public final int getCropLimit()
|
||||
{
|
||||
return _limitCrops * Config.RATE_DROP_MANOR;
|
||||
}
|
||||
|
||||
public final int getSeedReferencePrice()
|
||||
{
|
||||
return _seedReferencePrice;
|
||||
}
|
||||
|
||||
public final int getSeedMaxPrice()
|
||||
{
|
||||
return _seedReferencePrice * 10;
|
||||
}
|
||||
|
||||
public final int getSeedMinPrice()
|
||||
{
|
||||
return (int) (_seedReferencePrice * 0.6);
|
||||
}
|
||||
|
||||
public final int getCropReferencePrice()
|
||||
{
|
||||
return _cropReferencePrice;
|
||||
}
|
||||
|
||||
public final int getCropMaxPrice()
|
||||
{
|
||||
return _cropReferencePrice * 10;
|
||||
}
|
||||
|
||||
public final int getCropMinPrice()
|
||||
{
|
||||
return (int) (_cropReferencePrice * 0.6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString()
|
||||
{
|
||||
return "SeedData [_id=" + _seedId + ", _level=" + _level + ", _crop=" + _cropId + ", _mature=" + _matureId + ", _type1=" + _reward1 + ", _type2=" + _reward2 + ", _manorId=" + _castleId + ", _isAlternative=" + _isAlternative + ", _limitSeeds=" + _limitSeeds + ", _limitCrops=" + _limitCrops + "]";
|
||||
}
|
||||
}
|
||||
@@ -1,79 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.SiegeClanType;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
|
||||
public class L2SiegeClan
|
||||
{
|
||||
private int _clanId = 0;
|
||||
private final List<L2Npc> _flag = new CopyOnWriteArrayList<>();
|
||||
private SiegeClanType _type;
|
||||
|
||||
public L2SiegeClan(int clanId, SiegeClanType type)
|
||||
{
|
||||
_clanId = clanId;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public int getNumFlags()
|
||||
{
|
||||
return _flag.size();
|
||||
}
|
||||
|
||||
public void addFlag(L2Npc flag)
|
||||
{
|
||||
_flag.add(flag);
|
||||
}
|
||||
|
||||
public boolean removeFlag(L2Npc flag)
|
||||
{
|
||||
final boolean ret = _flag.remove(flag);
|
||||
flag.deleteMe();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void removeFlags()
|
||||
{
|
||||
_flag.forEach(f -> f.decayMe());
|
||||
_flag.clear();
|
||||
}
|
||||
|
||||
public final int getClanId()
|
||||
{
|
||||
return _clanId;
|
||||
}
|
||||
|
||||
public final List<L2Npc> getFlag()
|
||||
{
|
||||
return _flag;
|
||||
}
|
||||
|
||||
public SiegeClanType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
public void setType(SiegeClanType setType)
|
||||
{
|
||||
_type = setType;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.SiegeClanType;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
|
||||
public class L2SiegeClan
|
||||
{
|
||||
private int _clanId = 0;
|
||||
private final Set<L2Npc> _flags = ConcurrentHashMap.newKeySet();
|
||||
private SiegeClanType _type;
|
||||
|
||||
public L2SiegeClan(int clanId, SiegeClanType type)
|
||||
{
|
||||
_clanId = clanId;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public int getNumFlags()
|
||||
{
|
||||
return _flags.size();
|
||||
}
|
||||
|
||||
public void addFlag(L2Npc flag)
|
||||
{
|
||||
_flags.add(flag);
|
||||
}
|
||||
|
||||
public boolean removeFlag(L2Npc flag)
|
||||
{
|
||||
if (flag == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
flag.deleteMe();
|
||||
|
||||
return getFlag().remove(flag);
|
||||
}
|
||||
|
||||
public void removeFlags()
|
||||
{
|
||||
for (L2Npc flag : getFlag())
|
||||
{
|
||||
removeFlag(flag);
|
||||
}
|
||||
}
|
||||
|
||||
public final int getClanId()
|
||||
{
|
||||
return _clanId;
|
||||
}
|
||||
|
||||
public final Set<L2Npc> getFlag()
|
||||
{
|
||||
return _flags;
|
||||
}
|
||||
|
||||
public SiegeClanType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
public void setType(SiegeClanType setType)
|
||||
{
|
||||
_type = setType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,280 +1,317 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.enums.Race;
|
||||
import com.l2jmobius.gameserver.model.base.ClassId;
|
||||
import com.l2jmobius.gameserver.model.base.SocialClass;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
|
||||
/**
|
||||
* @author Zoey76
|
||||
*/
|
||||
public final class L2SkillLearn
|
||||
{
|
||||
private final String _skillName;
|
||||
private final int _skillId;
|
||||
private final int _skillLvl;
|
||||
private final int _getLevel;
|
||||
private final int _getDualClassLevel;
|
||||
private final boolean _autoGet;
|
||||
private final int _levelUpSp;
|
||||
private final List<ItemHolder> _requiredItems = new ArrayList<>();
|
||||
private final List<Race> _races = new ArrayList<>();
|
||||
private final List<SkillHolder> _preReqSkills = new ArrayList<>();
|
||||
private SocialClass _socialClass;
|
||||
private final boolean _residenceSkill;
|
||||
private final List<Integer> _residenceIds = new ArrayList<>();
|
||||
private final boolean _learnedByNpc;
|
||||
private final boolean _learnedByFS;
|
||||
private final Set<Integer> _removeSkills = new HashSet<>(1);
|
||||
|
||||
/**
|
||||
* Constructor for L2SkillLearn.
|
||||
* @param set the set with the L2SkillLearn data.
|
||||
*/
|
||||
public L2SkillLearn(StatsSet set)
|
||||
{
|
||||
_skillName = set.getString("skillName");
|
||||
_skillId = set.getInt("skillId");
|
||||
_skillLvl = set.getInt("skillLvl");
|
||||
_getLevel = set.getInt("getLevel");
|
||||
_getDualClassLevel = set.getInt("getDualClassLevel", 0);
|
||||
_autoGet = set.getBoolean("autoGet", false);
|
||||
_levelUpSp = set.getInt("levelUpSp", 0);
|
||||
_residenceSkill = set.getBoolean("residenceSkill", false);
|
||||
_learnedByNpc = set.getBoolean("learnedByNpc", false);
|
||||
_learnedByFS = set.getBoolean("learnedByFS", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of this skill.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return _skillName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of this skill.
|
||||
*/
|
||||
public int getSkillId()
|
||||
{
|
||||
return _skillId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the level of this skill.
|
||||
*/
|
||||
public int getSkillLevel()
|
||||
{
|
||||
return _skillLvl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the minimum level required to acquire this skill.
|
||||
*/
|
||||
public int getGetLevel()
|
||||
{
|
||||
return _getLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the minimum dual class level required to acquire this skill.
|
||||
*/
|
||||
public int getDualClassLevel()
|
||||
{
|
||||
return _getDualClassLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the amount of SP/Clan Reputation to acquire this skill.
|
||||
*/
|
||||
public int getLevelUpSp()
|
||||
{
|
||||
return _levelUpSp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the skill is auto-get, this skill is automatically delivered.
|
||||
*/
|
||||
public boolean isAutoGet()
|
||||
{
|
||||
return _autoGet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list with the item holders required to acquire this skill.
|
||||
*/
|
||||
public List<ItemHolder> getRequiredItems()
|
||||
{
|
||||
return _requiredItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a required item holder to learn this skill.
|
||||
* @param item the required item holder.
|
||||
*/
|
||||
public void addRequiredItem(ItemHolder item)
|
||||
{
|
||||
_requiredItems.add(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list with the races that can acquire this skill.
|
||||
*/
|
||||
public List<Race> getRaces()
|
||||
{
|
||||
return _races;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a required race to learn this skill.
|
||||
* @param race the required race.
|
||||
*/
|
||||
public void addRace(Race race)
|
||||
{
|
||||
_races.add(race);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of skill holders required to acquire this skill.
|
||||
*/
|
||||
public List<SkillHolder> getPreReqSkills()
|
||||
{
|
||||
return _preReqSkills;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a required skill holder to learn this skill.
|
||||
* @param skill the required skill holder.
|
||||
*/
|
||||
public void addPreReqSkill(SkillHolder skill)
|
||||
{
|
||||
_preReqSkills.add(skill);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the social class required to get this skill.
|
||||
*/
|
||||
public SocialClass getSocialClass()
|
||||
{
|
||||
return _socialClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the social class if hasn't been set before.
|
||||
* @param socialClass the social class to set.
|
||||
*/
|
||||
public void setSocialClass(SocialClass socialClass)
|
||||
{
|
||||
if (_socialClass == null)
|
||||
{
|
||||
_socialClass = socialClass;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if this skill is a Residence skill.
|
||||
*/
|
||||
public boolean isResidencialSkill()
|
||||
{
|
||||
return _residenceSkill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list with the Ids where this skill is available.
|
||||
*/
|
||||
public List<Integer> getResidenceIds()
|
||||
{
|
||||
return _residenceIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a required residence Id.
|
||||
* @param id the residence Id to add.
|
||||
*/
|
||||
public void addResidenceId(Integer id)
|
||||
{
|
||||
_residenceIds.add(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if this skill is learned from Npc.
|
||||
*/
|
||||
public boolean isLearnedByNpc()
|
||||
{
|
||||
return _learnedByNpc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if this skill is learned by Forgotten Scroll.
|
||||
*/
|
||||
public boolean isLearnedByFS()
|
||||
{
|
||||
return _learnedByFS;
|
||||
}
|
||||
|
||||
public void addRemoveSkills(int skillId)
|
||||
{
|
||||
_removeSkills.add(skillId);
|
||||
}
|
||||
|
||||
public Set<Integer> getRemoveSkills()
|
||||
{
|
||||
return _removeSkills;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for AltGameSkillLearn mod.<br>
|
||||
* If the alternative skill learn system is enabled and the player is learning a skill from a different class apply a fee.<br>
|
||||
* If the player is learning a skill from other class type (mage learning warrior skills or vice versa) the fee is higher.
|
||||
* @param playerClass the player class Id.
|
||||
* @param learningClass the skill learning player class Id.
|
||||
* @return the amount of SP required to acquire this skill, by calculating the cost for the alternative skill learn system.
|
||||
*/
|
||||
public int getCalculatedLevelUpSp(ClassId playerClass, ClassId learningClass)
|
||||
{
|
||||
if ((playerClass == null) || (learningClass == null))
|
||||
{
|
||||
return _levelUpSp;
|
||||
}
|
||||
|
||||
int levelUpSp = _levelUpSp;
|
||||
// If the alternative skill learn system is enabled and the player is learning a skill from a different class apply a fee.
|
||||
if (Config.ALT_GAME_SKILL_LEARN && (playerClass != learningClass))
|
||||
{
|
||||
// If the player is learning a skill from other class type (mage learning warrior skills or vice versa) the fee is higher.
|
||||
if (playerClass.isMage() != learningClass.isMage())
|
||||
{
|
||||
levelUpSp *= 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
levelUpSp *= 2;
|
||||
}
|
||||
}
|
||||
return levelUpSp;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
import com.l2jmobius.gameserver.enums.Race;
|
||||
import com.l2jmobius.gameserver.model.base.ClassId;
|
||||
import com.l2jmobius.gameserver.model.base.SocialClass;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
|
||||
/**
|
||||
* @author Zoey76
|
||||
*/
|
||||
public final class L2SkillLearn
|
||||
{
|
||||
private final String _skillName;
|
||||
private final int _skillId;
|
||||
private final int _skillLvl;
|
||||
private final int _getLevel;
|
||||
private final int _getDualClassLevel;
|
||||
private final boolean _autoGet;
|
||||
private final int _levelUpSp;
|
||||
private final List<ItemHolder> _requiredItems = new ArrayList<>();
|
||||
private final List<Race> _races = new ArrayList<>();
|
||||
private final List<SkillHolder> _preReqSkills = new ArrayList<>();
|
||||
private SocialClass _socialClass;
|
||||
private final boolean _residenceSkill;
|
||||
private final List<Integer> _residenceIds = new ArrayList<>();
|
||||
private final boolean _learnedByNpc;
|
||||
private final boolean _learnedByFS;
|
||||
private final Set<Integer> _removeSkills = new HashSet<>(1);
|
||||
private final int _treeId;
|
||||
private final int _row;
|
||||
private final int _column;
|
||||
private final int _pointsRequired;
|
||||
|
||||
/**
|
||||
* Constructor for L2SkillLearn.
|
||||
* @param set the set with the L2SkillLearn data.
|
||||
*/
|
||||
public L2SkillLearn(StatsSet set)
|
||||
{
|
||||
_skillName = set.getString("skillName");
|
||||
_skillId = set.getInt("skillId");
|
||||
_skillLvl = set.getInt("skillLvl");
|
||||
_getLevel = set.getInt("getLevel");
|
||||
_getDualClassLevel = set.getInt("getDualClassLevel", 0);
|
||||
_autoGet = set.getBoolean("autoGet", false);
|
||||
_levelUpSp = set.getInt("levelUpSp", 0);
|
||||
_residenceSkill = set.getBoolean("residenceSkill", false);
|
||||
_learnedByNpc = set.getBoolean("learnedByNpc", false);
|
||||
_learnedByFS = set.getBoolean("learnedByFS", false);
|
||||
_treeId = set.getInt("treeId", 0);
|
||||
_row = set.getInt("row", 0);
|
||||
_column = set.getInt("row", 0);
|
||||
_pointsRequired = set.getInt("pointsRequired", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of this skill.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return _skillName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of this skill.
|
||||
*/
|
||||
public int getSkillId()
|
||||
{
|
||||
return _skillId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the level of this skill.
|
||||
*/
|
||||
public int getSkillLevel()
|
||||
{
|
||||
return _skillLvl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the minimum level required to acquire this skill.
|
||||
*/
|
||||
public int getGetLevel()
|
||||
{
|
||||
return _getLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the minimum level of a character dual class required to acquire this skill.
|
||||
*/
|
||||
public int getDualClassLevel()
|
||||
{
|
||||
return _getDualClassLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the amount of SP/Clan Reputation to acquire this skill.
|
||||
*/
|
||||
public int getLevelUpSp()
|
||||
{
|
||||
return _levelUpSp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the skill is auto-get, this skill is automatically delivered.
|
||||
*/
|
||||
public boolean isAutoGet()
|
||||
{
|
||||
return _autoGet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list with the item holders required to acquire this skill.
|
||||
*/
|
||||
public List<ItemHolder> getRequiredItems()
|
||||
{
|
||||
return _requiredItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a required item holder to learn this skill.
|
||||
* @param item the required item holder.
|
||||
*/
|
||||
public void addRequiredItem(ItemHolder item)
|
||||
{
|
||||
_requiredItems.add(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list with the races that can acquire this skill.
|
||||
*/
|
||||
public List<Race> getRaces()
|
||||
{
|
||||
return _races;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a required race to learn this skill.
|
||||
* @param race the required race.
|
||||
*/
|
||||
public void addRace(Race race)
|
||||
{
|
||||
_races.add(race);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of skill holders required to acquire this skill.
|
||||
*/
|
||||
public List<SkillHolder> getPreReqSkills()
|
||||
{
|
||||
return _preReqSkills;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a required skill holder to learn this skill.
|
||||
* @param skill the required skill holder.
|
||||
*/
|
||||
public void addPreReqSkill(SkillHolder skill)
|
||||
{
|
||||
_preReqSkills.add(skill);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the social class required to get this skill.
|
||||
*/
|
||||
public SocialClass getSocialClass()
|
||||
{
|
||||
return _socialClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the social class if hasn't been set before.
|
||||
* @param socialClass the social class to set.
|
||||
*/
|
||||
public void setSocialClass(SocialClass socialClass)
|
||||
{
|
||||
if (_socialClass == null)
|
||||
{
|
||||
_socialClass = socialClass;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if this skill is a Residence skill.
|
||||
*/
|
||||
public boolean isResidencialSkill()
|
||||
{
|
||||
return _residenceSkill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list with the Ids where this skill is available.
|
||||
*/
|
||||
public List<Integer> getResidenceIds()
|
||||
{
|
||||
return _residenceIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a required residence Id.
|
||||
* @param id the residence Id to add.
|
||||
*/
|
||||
public void addResidenceId(Integer id)
|
||||
{
|
||||
_residenceIds.add(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if this skill is learned from Npc.
|
||||
*/
|
||||
public boolean isLearnedByNpc()
|
||||
{
|
||||
return _learnedByNpc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if this skill is learned by Forgotten Scroll.
|
||||
*/
|
||||
public boolean isLearnedByFS()
|
||||
{
|
||||
return _learnedByFS;
|
||||
}
|
||||
|
||||
public void addRemoveSkills(int skillId)
|
||||
{
|
||||
_removeSkills.add(skillId);
|
||||
}
|
||||
|
||||
public Set<Integer> getRemoveSkills()
|
||||
{
|
||||
return _removeSkills;
|
||||
}
|
||||
|
||||
public int getTreeId()
|
||||
{
|
||||
return _treeId;
|
||||
}
|
||||
|
||||
public int getRow()
|
||||
{
|
||||
return _row;
|
||||
}
|
||||
|
||||
public int getColumn()
|
||||
{
|
||||
return _column;
|
||||
}
|
||||
|
||||
public int getPointsRequired()
|
||||
{
|
||||
return _pointsRequired;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for AltGameSkillLearn mod.<br>
|
||||
* If the alternative skill learn system is enabled and the player is learning a skill from a different class apply a fee.<br>
|
||||
* If the player is learning a skill from other class type (mage learning warrior skills or vice versa) the fee is higher.
|
||||
* @param playerClass the player class Id.
|
||||
* @param learningClass the skill learning player class Id.
|
||||
* @return the amount of SP required to acquire this skill, by calculating the cost for the alternative skill learn system.
|
||||
*/
|
||||
public int getCalculatedLevelUpSp(ClassId playerClass, ClassId learningClass)
|
||||
{
|
||||
if ((playerClass == null) || (learningClass == null))
|
||||
{
|
||||
return _levelUpSp;
|
||||
}
|
||||
|
||||
int levelUpSp = _levelUpSp;
|
||||
// If the alternative skill learn system is enabled and the player is learning a skill from a different class apply a fee.
|
||||
if (Config.ALT_GAME_SKILL_LEARN && (playerClass != learningClass))
|
||||
{
|
||||
// If the player is learning a skill from other class type (mage learning warrior skills or vice versa) the fee is higher.
|
||||
if (playerClass.isMage() != learningClass.isMage())
|
||||
{
|
||||
levelUpSp *= 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
levelUpSp *= 2;
|
||||
}
|
||||
}
|
||||
return levelUpSp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
final Skill skill = SkillData.getInstance().getSkill(_skillId, _skillLvl);
|
||||
return "[" + skill.toString() + " treeId: " + _treeId + " row: " + _row + " column: " + _column + " pointsRequired:" + _pointsRequired + "]";
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,144 +1,144 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.2.4.1 $ $Date: 2005/03/27 15:29:32 $
|
||||
*/
|
||||
public class L2TeleportLocation
|
||||
{
|
||||
private int _teleId;
|
||||
private int _locX;
|
||||
private int _locY;
|
||||
private int _locZ;
|
||||
private int _price;
|
||||
private boolean _forNoble;
|
||||
private int _itemId;
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setTeleId(int id)
|
||||
{
|
||||
_teleId = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param locX
|
||||
*/
|
||||
public void setLocX(int locX)
|
||||
{
|
||||
_locX = locX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param locY
|
||||
*/
|
||||
public void setLocY(int locY)
|
||||
{
|
||||
_locY = locY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param locZ
|
||||
*/
|
||||
public void setLocZ(int locZ)
|
||||
{
|
||||
_locZ = locZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param price
|
||||
*/
|
||||
public void setPrice(int price)
|
||||
{
|
||||
_price = price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val
|
||||
*/
|
||||
public void setIsForNoble(boolean val)
|
||||
{
|
||||
_forNoble = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val
|
||||
*/
|
||||
public void setItemId(int val)
|
||||
{
|
||||
_itemId = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getTeleId()
|
||||
{
|
||||
return _teleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getLocX()
|
||||
{
|
||||
return _locX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getLocY()
|
||||
{
|
||||
return _locY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getLocZ()
|
||||
{
|
||||
return _locZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getPrice()
|
||||
{
|
||||
return _price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public boolean getIsForNoble()
|
||||
{
|
||||
return _forNoble;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.2.4.1 $ $Date: 2005/03/27 15:29:32 $
|
||||
*/
|
||||
public class L2TeleportLocation
|
||||
{
|
||||
private int _teleId;
|
||||
private int _locX;
|
||||
private int _locY;
|
||||
private int _locZ;
|
||||
private int _price;
|
||||
private boolean _forNoble;
|
||||
private int _itemId;
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setTeleId(int id)
|
||||
{
|
||||
_teleId = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param locX
|
||||
*/
|
||||
public void setLocX(int locX)
|
||||
{
|
||||
_locX = locX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param locY
|
||||
*/
|
||||
public void setLocY(int locY)
|
||||
{
|
||||
_locY = locY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param locZ
|
||||
*/
|
||||
public void setLocZ(int locZ)
|
||||
{
|
||||
_locZ = locZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param price
|
||||
*/
|
||||
public void setPrice(int price)
|
||||
{
|
||||
_price = price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val
|
||||
*/
|
||||
public void setIsForNoble(boolean val)
|
||||
{
|
||||
_forNoble = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val
|
||||
*/
|
||||
public void setItemId(int val)
|
||||
{
|
||||
_itemId = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getTeleId()
|
||||
{
|
||||
return _teleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getLocX()
|
||||
{
|
||||
return _locX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getLocY()
|
||||
{
|
||||
return _locY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getLocZ()
|
||||
{
|
||||
return _locZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getPrice()
|
||||
{
|
||||
return _price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public boolean getIsForNoble()
|
||||
{
|
||||
return _forNoble;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,172 +1,198 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* @version 0.1, 2005-03-12
|
||||
* @author Balancer
|
||||
*/
|
||||
public class L2Territory
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(L2Territory.class.getName());
|
||||
|
||||
protected static class Point
|
||||
{
|
||||
protected int _x, _y, _zmin, _zmax, _proc;
|
||||
|
||||
Point(int x, int y, int zmin, int zmax, int proc)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
_zmin = zmin;
|
||||
_zmax = zmax;
|
||||
_proc = proc;
|
||||
}
|
||||
}
|
||||
|
||||
private final List<Point> _points = new CopyOnWriteArrayList<>();
|
||||
private final int _terr;
|
||||
private int _xMin;
|
||||
private int _xMax;
|
||||
private int _yMin;
|
||||
private int _yMax;
|
||||
private int _zMin;
|
||||
private int _zMax;
|
||||
private int _procMax;
|
||||
|
||||
public L2Territory(int terr)
|
||||
{
|
||||
_terr = terr;
|
||||
_xMin = 999999;
|
||||
_xMax = -999999;
|
||||
_yMin = 999999;
|
||||
_yMax = -999999;
|
||||
_zMin = 999999;
|
||||
_zMax = -999999;
|
||||
_procMax = 0;
|
||||
}
|
||||
|
||||
public void add(int x, int y, int zmin, int zmax, int proc)
|
||||
{
|
||||
_points.add(new Point(x, y, zmin, zmax, proc));
|
||||
if (x < _xMin)
|
||||
{
|
||||
_xMin = x;
|
||||
}
|
||||
if (y < _yMin)
|
||||
{
|
||||
_yMin = y;
|
||||
}
|
||||
if (x > _xMax)
|
||||
{
|
||||
_xMax = x;
|
||||
}
|
||||
if (y > _yMax)
|
||||
{
|
||||
_yMax = y;
|
||||
}
|
||||
if (zmin < _zMin)
|
||||
{
|
||||
_zMin = zmin;
|
||||
}
|
||||
if (zmax > _zMax)
|
||||
{
|
||||
_zMax = zmax;
|
||||
}
|
||||
_procMax += proc;
|
||||
}
|
||||
|
||||
public boolean isIntersect(int x, int y, Point p1, Point p2)
|
||||
{
|
||||
final double dy1 = p1._y - y;
|
||||
final double dy2 = p2._y - y;
|
||||
|
||||
if (Math.abs(Math.signum(dy1) - Math.signum(dy2)) <= 1e-6)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final double dx1 = p1._x - x;
|
||||
return ((dx1 >= 0) && ((p2._x - x) >= 0)) || (((dx1 >= 0) || ((p2._x - x) >= 0)) && (((dy1 * (p1._x - p2._x)) / (p1._y - p2._y)) <= dx1));
|
||||
}
|
||||
|
||||
public boolean isInside(int x, int y)
|
||||
{
|
||||
int intersect_count = 0;
|
||||
for (int i = 0; i < _points.size(); i++)
|
||||
{
|
||||
if (isIntersect(x, y, _points.get(i > 0 ? i - 1 : _points.size() - 1), _points.get(i)))
|
||||
{
|
||||
intersect_count++;
|
||||
}
|
||||
}
|
||||
|
||||
return (intersect_count % 2) == 1;
|
||||
}
|
||||
|
||||
public Location getRandomPoint()
|
||||
{
|
||||
if (_procMax > 0)
|
||||
{
|
||||
int pos = 0;
|
||||
final int rnd = Rnd.nextInt(_procMax);
|
||||
for (Point p1 : _points)
|
||||
{
|
||||
pos += p1._proc;
|
||||
if (rnd <= pos)
|
||||
{
|
||||
return new Location(p1._x, p1._y, Rnd.get(p1._zmin, p1._zmax));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
final int x = Rnd.get(_xMin, _xMax);
|
||||
final int y = Rnd.get(_yMin, _yMax);
|
||||
if (isInside(x, y))
|
||||
{
|
||||
double curdistance = 0;
|
||||
int zmin = _zMin;
|
||||
for (Point p1 : _points)
|
||||
{
|
||||
final double dx = p1._x - x;
|
||||
final double dy = p1._y - y;
|
||||
final double distance = Math.sqrt((dx * dx) + (dy * dy));
|
||||
if ((curdistance == 0) || (distance < curdistance))
|
||||
{
|
||||
curdistance = distance;
|
||||
zmin = p1._zmin;
|
||||
}
|
||||
}
|
||||
return new Location(x, y, Rnd.get(zmin, _zMax));
|
||||
}
|
||||
}
|
||||
_log.warning("Can't make point for territory " + _terr);
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getProcMax()
|
||||
{
|
||||
return _procMax;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
|
||||
/**
|
||||
* @version 0.1, 2005-03-12
|
||||
* @author Balancer
|
||||
*/
|
||||
public class L2Territory
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(L2Territory.class.getName());
|
||||
|
||||
protected static class Point
|
||||
{
|
||||
protected int _x, _y, _zmin, _zmax, _proc;
|
||||
|
||||
Point(int x, int y, int zmin, int zmax, int proc)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
_zmin = zmin;
|
||||
_zmax = zmax;
|
||||
_proc = proc;
|
||||
}
|
||||
}
|
||||
|
||||
private final List<Point> _points = new ArrayList<>();
|
||||
private final int _terr;
|
||||
private int _xMin;
|
||||
private int _xMax;
|
||||
private int _yMin;
|
||||
private int _yMax;
|
||||
private int _zMin;
|
||||
private int _zMax;
|
||||
private int _procMax;
|
||||
|
||||
public L2Territory(int terr)
|
||||
{
|
||||
_terr = terr;
|
||||
_xMin = 999999;
|
||||
_xMax = -999999;
|
||||
_yMin = 999999;
|
||||
_yMax = -999999;
|
||||
_zMin = 999999;
|
||||
_zMax = -999999;
|
||||
_procMax = 0;
|
||||
}
|
||||
|
||||
public void add(int x, int y, int zmin, int zmax, int proc)
|
||||
{
|
||||
_points.add(new Point(x, y, zmin, zmax, proc));
|
||||
if (x < _xMin)
|
||||
{
|
||||
_xMin = x;
|
||||
}
|
||||
if (y < _yMin)
|
||||
{
|
||||
_yMin = y;
|
||||
}
|
||||
if (x > _xMax)
|
||||
{
|
||||
_xMax = x;
|
||||
}
|
||||
if (y > _yMax)
|
||||
{
|
||||
_yMax = y;
|
||||
}
|
||||
if (zmin < _zMin)
|
||||
{
|
||||
_zMin = zmin;
|
||||
}
|
||||
if (zmax > _zMax)
|
||||
{
|
||||
_zMax = zmax;
|
||||
}
|
||||
_procMax += proc;
|
||||
}
|
||||
|
||||
public void print()
|
||||
{
|
||||
for (Point p : _points)
|
||||
{
|
||||
_log.info("(" + p._x + "," + p._y + ")");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isIntersect(int x, int y, Point p1, Point p2)
|
||||
{
|
||||
final double dy1 = p1._y - y;
|
||||
final double dy2 = p2._y - y;
|
||||
|
||||
if (Math.abs(Math.signum(dy1) - Math.signum(dy2)) <= 1e-6)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final double dx1 = p1._x - x;
|
||||
final double dx2 = p2._x - x;
|
||||
|
||||
if ((dx1 >= 0) && (dx2 >= 0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((dx1 < 0) && (dx2 < 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final double dx0 = (dy1 * (p1._x - p2._x)) / (p1._y - p2._y);
|
||||
|
||||
return dx0 <= dx1;
|
||||
}
|
||||
|
||||
public boolean isInside(int x, int y)
|
||||
{
|
||||
int intersect_count = 0;
|
||||
for (int i = 0; i < _points.size(); i++)
|
||||
{
|
||||
final Point p1 = _points.get(i > 0 ? i - 1 : _points.size() - 1);
|
||||
final Point p2 = _points.get(i);
|
||||
|
||||
if (isIntersect(x, y, p1, p2))
|
||||
{
|
||||
intersect_count++;
|
||||
}
|
||||
}
|
||||
|
||||
return (intersect_count % 2) == 1;
|
||||
}
|
||||
|
||||
public Location getRandomPoint()
|
||||
{
|
||||
if (_procMax > 0)
|
||||
{
|
||||
int pos = 0;
|
||||
final int rnd = Rnd.nextInt(_procMax);
|
||||
for (Point p1 : _points)
|
||||
{
|
||||
pos += p1._proc;
|
||||
if (rnd <= pos)
|
||||
{
|
||||
return new Location(p1._x, p1._y, Rnd.get(p1._zmin, p1._zmax));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
final int x = Rnd.get(_xMin, _xMax);
|
||||
final int y = Rnd.get(_yMin, _yMax);
|
||||
if (isInside(x, y))
|
||||
{
|
||||
double curdistance = 0;
|
||||
int zmin = _zMin;
|
||||
for (Point p1 : _points)
|
||||
{
|
||||
final double dx = p1._x - x;
|
||||
final double dy = p1._y - y;
|
||||
final double distance = Math.sqrt((dx * dx) + (dy * dy));
|
||||
if ((curdistance == 0) || (distance < curdistance))
|
||||
{
|
||||
curdistance = distance;
|
||||
zmin = p1._zmin;
|
||||
}
|
||||
}
|
||||
return new Location(x, y, Rnd.get(zmin, _zMax));
|
||||
}
|
||||
}
|
||||
_log.warning("Can't make point for territory " + _terr);
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getProcMax()
|
||||
{
|
||||
return _procMax;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,74 +1,75 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author GKR
|
||||
*/
|
||||
public class L2WalkRoute
|
||||
{
|
||||
private final String _name;
|
||||
private final List<L2NpcWalkerNode> _nodeList; // List of nodes
|
||||
private final boolean _repeatWalk; // Does repeat walk, after arriving into last point in list, or not
|
||||
private boolean _stopAfterCycle; // Make only one cycle or endlessly
|
||||
private final byte _repeatType; // Repeat style: 0 - go back, 1 - go to first point (circle style), 2 - teleport to first point (conveyor style), 3 - random walking between points
|
||||
|
||||
public L2WalkRoute(String name, List<L2NpcWalkerNode> route, boolean repeat, boolean once, byte repeatType)
|
||||
{
|
||||
_name = name;
|
||||
_nodeList = route;
|
||||
_repeatType = repeatType;
|
||||
_repeatWalk = (_repeatType >= 0) && (_repeatType <= 2) && repeat;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public List<L2NpcWalkerNode> getNodeList()
|
||||
{
|
||||
return _nodeList;
|
||||
}
|
||||
|
||||
public L2NpcWalkerNode getLastNode()
|
||||
{
|
||||
return _nodeList.get(_nodeList.size() - 1);
|
||||
}
|
||||
|
||||
public boolean repeatWalk()
|
||||
{
|
||||
return _repeatWalk;
|
||||
}
|
||||
|
||||
public boolean doOnce()
|
||||
{
|
||||
return _stopAfterCycle;
|
||||
}
|
||||
|
||||
public byte getRepeatType()
|
||||
{
|
||||
return _repeatType;
|
||||
}
|
||||
|
||||
public int getNodesCount()
|
||||
{
|
||||
return _nodeList.size();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author GKR
|
||||
*/
|
||||
public class L2WalkRoute
|
||||
{
|
||||
private final String _name;
|
||||
private final List<L2NpcWalkerNode> _nodeList; // List of nodes
|
||||
private final boolean _repeatWalk; // Does repeat walk, after arriving into last point in list, or not
|
||||
private boolean _stopAfterCycle; // Make only one cycle or endlessly
|
||||
private final byte _repeatType; // Repeat style: 0 - go back, 1 - go to first point (circle style), 2 - teleport to first point (conveyor style), 3 - random walking between points
|
||||
|
||||
public L2WalkRoute(String name, List<L2NpcWalkerNode> route, boolean repeat, boolean once, byte repeatType)
|
||||
{
|
||||
|
||||
_name = name;
|
||||
_nodeList = route;
|
||||
_repeatType = repeatType;
|
||||
_repeatWalk = ((_repeatType >= 0) && (_repeatType <= 2)) && repeat;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public List<L2NpcWalkerNode> getNodeList()
|
||||
{
|
||||
return _nodeList;
|
||||
}
|
||||
|
||||
public L2NpcWalkerNode getLastNode()
|
||||
{
|
||||
return _nodeList.get(_nodeList.size() - 1);
|
||||
}
|
||||
|
||||
public boolean repeatWalk()
|
||||
{
|
||||
return _repeatWalk;
|
||||
}
|
||||
|
||||
public boolean doOnce()
|
||||
{
|
||||
return _stopAfterCycle;
|
||||
}
|
||||
|
||||
public byte getRepeatType()
|
||||
{
|
||||
return _repeatType;
|
||||
}
|
||||
|
||||
public int getNodesCount()
|
||||
{
|
||||
return _nodeList.size();
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,464 +1,388 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.datatables.SpawnTable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Vehicle;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.zone.L2ZoneType;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2PeaceZone;
|
||||
|
||||
public final class L2WorldRegion
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(L2WorldRegion.class.getName());
|
||||
|
||||
/** Map containing all playable characters in game in this world region. */
|
||||
private final Map<Integer, L2Playable> _allPlayable;
|
||||
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, L2Object> _visibleObjects;
|
||||
|
||||
private final List<L2WorldRegion> _surroundingRegions;
|
||||
private final int _tileX, _tileY;
|
||||
private boolean _active = false;
|
||||
private ScheduledFuture<?> _neighborsTask = null;
|
||||
private final List<L2ZoneType> _zones;
|
||||
|
||||
public L2WorldRegion(int pTileX, int pTileY)
|
||||
{
|
||||
_allPlayable = new ConcurrentHashMap<>();
|
||||
_visibleObjects = new ConcurrentHashMap<>();
|
||||
_surroundingRegions = new ArrayList<>();
|
||||
|
||||
_tileX = pTileX;
|
||||
_tileY = pTileY;
|
||||
|
||||
// default a newly initialized region to inactive, unless always on is specified
|
||||
_active = Config.GRIDS_ALWAYS_ON;
|
||||
_zones = new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<L2ZoneType> getZones()
|
||||
{
|
||||
return _zones;
|
||||
}
|
||||
|
||||
public void addZone(L2ZoneType zone)
|
||||
{
|
||||
_zones.add(zone);
|
||||
}
|
||||
|
||||
public void removeZone(L2ZoneType zone)
|
||||
{
|
||||
_zones.remove(zone);
|
||||
}
|
||||
|
||||
public void revalidateZones(L2Character character)
|
||||
{
|
||||
// do NOT update the world region while the character is still in the process of teleporting
|
||||
// Once the teleport is COMPLETED, revalidation occurs safely, at that time.
|
||||
|
||||
if (character.isTeleporting())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (L2ZoneType z : getZones())
|
||||
{
|
||||
if (z != null)
|
||||
{
|
||||
z.revalidateInZone(character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFromZones(L2Character character)
|
||||
{
|
||||
for (L2ZoneType z : getZones())
|
||||
{
|
||||
if (z != null)
|
||||
{
|
||||
z.removeCharacter(character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsZone(int zoneId)
|
||||
{
|
||||
for (L2ZoneType z : getZones())
|
||||
{
|
||||
if (z.getId() == zoneId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkEffectRangeInsidePeaceZone(Skill skill, int x, int y, int z)
|
||||
{
|
||||
final int range = skill.getEffectRange();
|
||||
final int up = y + range;
|
||||
final int down = y - range;
|
||||
final int left = x + range;
|
||||
final int right = x - range;
|
||||
|
||||
for (L2ZoneType e : getZones())
|
||||
{
|
||||
if ((e instanceof L2PeaceZone) && (e.isInsideZone(x, up, z) || e.isInsideZone(x, down, z) || e.isInsideZone(left, y, z) || e.isInsideZone(right, y, z) || e.isInsideZone(x, y, z)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onDeath(L2Character character)
|
||||
{
|
||||
for (L2ZoneType z : getZones())
|
||||
{
|
||||
if (z != null)
|
||||
{
|
||||
z.onDieInside(character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onRevive(L2Character character)
|
||||
{
|
||||
for (L2ZoneType z : getZones())
|
||||
{
|
||||
if (z != null)
|
||||
{
|
||||
z.onReviveInside(character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Task of AI notification */
|
||||
public class NeighborsTask implements Runnable
|
||||
{
|
||||
private final boolean _isActivating;
|
||||
|
||||
public NeighborsTask(boolean isActivating)
|
||||
{
|
||||
_isActivating = isActivating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_isActivating)
|
||||
{
|
||||
// for each neighbor, if it's not active, activate.
|
||||
for (L2WorldRegion neighbor : getSurroundingRegions())
|
||||
{
|
||||
neighbor.setActive(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (areNeighborsEmpty())
|
||||
{
|
||||
setActive(false);
|
||||
}
|
||||
|
||||
// check and deactivate
|
||||
for (L2WorldRegion neighbor : getSurroundingRegions())
|
||||
{
|
||||
if (neighbor.areNeighborsEmpty())
|
||||
{
|
||||
neighbor.setActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void switchAI(boolean isOn)
|
||||
{
|
||||
int c = 0;
|
||||
if (!isOn)
|
||||
{
|
||||
for (L2Object o : _visibleObjects.values())
|
||||
{
|
||||
if (o instanceof L2Attackable)
|
||||
{
|
||||
c++;
|
||||
final L2Attackable mob = (L2Attackable) o;
|
||||
|
||||
// Set target to null and cancel Attack or Cast
|
||||
mob.setTarget(null);
|
||||
|
||||
// Stop movement
|
||||
mob.stopMove(null);
|
||||
|
||||
// Stop all active skills effects in progress on the L2Character
|
||||
mob.stopAllEffects();
|
||||
|
||||
mob.clearAggroList();
|
||||
mob.getAttackByList().clear();
|
||||
mob.getKnownList().removeAllKnownObjects();
|
||||
|
||||
// stop the ai tasks
|
||||
if (mob.hasAI())
|
||||
{
|
||||
mob.getAI().setIntention(com.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE);
|
||||
mob.getAI().stopAITask();
|
||||
}
|
||||
}
|
||||
else if (o instanceof L2Vehicle)
|
||||
{
|
||||
c++;
|
||||
((L2Vehicle) o).getKnownList().removeAllKnownObjects();
|
||||
}
|
||||
}
|
||||
|
||||
_log.fine(c + " mobs were turned off");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (L2Object o : _visibleObjects.values())
|
||||
{
|
||||
if (o instanceof L2Attackable)
|
||||
{
|
||||
c++;
|
||||
// Start HP/MP/CP Regeneration task
|
||||
((L2Attackable) o).getStatus().startHpMpRegeneration();
|
||||
}
|
||||
else if (o instanceof L2Npc)
|
||||
{
|
||||
((L2Npc) o).startRandomAnimationTimer();
|
||||
}
|
||||
}
|
||||
|
||||
_log.fine(c + " mobs were turned on");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
return _active;
|
||||
}
|
||||
|
||||
// check if all 9 neighbors (including self) are inactive or active but with no players.
|
||||
// returns true if the above condition is met.
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
// if this region is occupied, return false.
|
||||
if (isActive() && !_allPlayable.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// if any one of the neighbors is occupied, return false
|
||||
for (L2WorldRegion neighbor : _surroundingRegions)
|
||||
{
|
||||
if (neighbor.isActive() && !neighbor._allPlayable.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// in all other cases, return true.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* this function turns this region's AI and geodata on or off
|
||||
* @param value
|
||||
*/
|
||||
public void setActive(boolean value)
|
||||
{
|
||||
if (_active == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_active = value;
|
||||
|
||||
// turn the AI on or off to match the region's activation.
|
||||
switchAI(value);
|
||||
|
||||
// TODO
|
||||
// turn the geodata on or off to match the region's activation.
|
||||
_log.fine(value ? "Starting Grid " + _tileX + "," + _tileY : "Stoping Grid " + _tileX + "," + _tileY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Immediately sets self as active and starts a timer to set neighbors as active this timer is to avoid turning on neighbors in the case when a person just teleported into a region and then teleported out immediately...there is no reason to activate all the neighbors in that case.
|
||||
*/
|
||||
private void startActivation()
|
||||
{
|
||||
// first set self to active and do self-tasks...
|
||||
setActive(true);
|
||||
|
||||
// if the timer to deactivate neighbors is running, cancel it.
|
||||
synchronized (this)
|
||||
{
|
||||
if (_neighborsTask != null)
|
||||
{
|
||||
_neighborsTask.cancel(true);
|
||||
_neighborsTask = null;
|
||||
}
|
||||
|
||||
// then, set a timer to activate the neighbors
|
||||
_neighborsTask = ThreadPoolManager.getInstance().scheduleGeneral(new NeighborsTask(true), 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* starts a timer to set neighbors (including self) as inactive this timer is to avoid turning off neighbors in the case when a person just moved out of a region that he may very soon return to. There is no reason to turn self & neighbors off in that case.
|
||||
*/
|
||||
private void startDeactivation()
|
||||
{
|
||||
// if the timer to activate neighbors is running, cancel it.
|
||||
synchronized (this)
|
||||
{
|
||||
if (_neighborsTask != null)
|
||||
{
|
||||
_neighborsTask.cancel(true);
|
||||
_neighborsTask = null;
|
||||
}
|
||||
|
||||
// start a timer to "suggest" a deactivate to self and neighbors.
|
||||
// suggest means: first check if a neighbor has L2PcInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPoolManager.getInstance().scheduleGeneral(new NeighborsTask(false), 1000 * Config.GRID_NEIGHBOR_TURNOFF_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the L2Object in the L2ObjectHashSet(L2Object) _visibleObjects containing L2Object visible in this L2WorldRegion <BR>
|
||||
* If L2Object is a L2PcInstance, Add the L2PcInstance in the L2ObjectHashSet(L2PcInstance) _allPlayable containing L2PcInstance of all player in game in this L2WorldRegion <BR>
|
||||
* Assert : object.getCurrentWorldRegion() == this
|
||||
* @param object
|
||||
*/
|
||||
public void addVisibleObject(L2Object object)
|
||||
{
|
||||
if (object == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
assert object.getWorldRegion() == this;
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
|
||||
if (object instanceof L2Playable)
|
||||
{
|
||||
_allPlayable.put(object.getObjectId(), (L2Playable) object);
|
||||
|
||||
// if this is the first player to enter the region, activate self & neighbors
|
||||
if ((_allPlayable.size() == 1) && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startActivation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the L2Object from the L2ObjectHashSet(L2Object) _visibleObjects in this L2WorldRegion. If L2Object is a L2PcInstance, remove it from the L2ObjectHashSet(L2PcInstance) _allPlayable of this L2WorldRegion <BR>
|
||||
* Assert : object.getCurrentWorldRegion() == this || object.getCurrentWorldRegion() == null
|
||||
* @param object
|
||||
*/
|
||||
public void removeVisibleObject(L2Object object)
|
||||
{
|
||||
if (object == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
assert (object.getWorldRegion() == this) || (object.getWorldRegion() == null);
|
||||
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
if (object instanceof L2Playable)
|
||||
{
|
||||
_allPlayable.remove(object.getObjectId());
|
||||
|
||||
if (_allPlayable.isEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addSurroundingRegion(L2WorldRegion region)
|
||||
{
|
||||
_surroundingRegions.add(region);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ArrayList _surroundingRegions containing all L2WorldRegion around the current L2WorldRegion
|
||||
*/
|
||||
public List<L2WorldRegion> getSurroundingRegions()
|
||||
{
|
||||
return _surroundingRegions;
|
||||
}
|
||||
|
||||
public Map<Integer, L2Playable> getVisiblePlayable()
|
||||
{
|
||||
return _allPlayable;
|
||||
}
|
||||
|
||||
public Map<Integer, L2Object> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return "(" + _tileX + ", " + _tileY + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Deleted all spawns in the world.
|
||||
*/
|
||||
public void deleteVisibleNpcSpawns()
|
||||
{
|
||||
_log.fine("Deleting all visible NPC's in Region: " + getName());
|
||||
for (L2Object obj : _visibleObjects.values())
|
||||
{
|
||||
if (obj instanceof L2Npc)
|
||||
{
|
||||
final L2Npc target = (L2Npc) obj;
|
||||
target.deleteMe();
|
||||
final L2Spawn spawn = target.getSpawn();
|
||||
if (spawn != null)
|
||||
{
|
||||
spawn.stopRespawn();
|
||||
SpawnTable.getInstance().deleteSpawn(spawn, false);
|
||||
}
|
||||
_log.finest("Removed NPC " + target.getObjectId());
|
||||
}
|
||||
}
|
||||
_log.info("All visible NPC's deleted in Region: " + getName());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.datatables.SpawnTable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Vehicle;
|
||||
|
||||
public final class L2WorldRegion
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(L2WorldRegion.class.getName());
|
||||
|
||||
/** Map containing visible objects in this world region. */
|
||||
private volatile Map<Integer, L2Object> _visibleObjects;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
private final int _regionZ;
|
||||
private boolean _active = false;
|
||||
private ScheduledFuture<?> _neighborsTask = null;
|
||||
|
||||
public L2WorldRegion(int regionX, int regionY, int regionZ)
|
||||
{
|
||||
_regionX = regionX;
|
||||
_regionY = regionY;
|
||||
_regionZ = regionZ;
|
||||
|
||||
// default a newly initialized region to inactive, unless always on is specified
|
||||
_active = Config.GRIDS_ALWAYS_ON;
|
||||
}
|
||||
|
||||
/** Task of AI notification */
|
||||
public class NeighborsTask implements Runnable
|
||||
{
|
||||
private final boolean _isActivating;
|
||||
|
||||
public NeighborsTask(boolean isActivating)
|
||||
{
|
||||
_isActivating = isActivating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_isActivating)
|
||||
{
|
||||
// for each neighbor, if it's not active, activate.
|
||||
forEachSurroundingRegion(w ->
|
||||
{
|
||||
w.setActive(true);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (areNeighborsEmpty())
|
||||
{
|
||||
setActive(false);
|
||||
}
|
||||
|
||||
// check and deactivate
|
||||
forEachSurroundingRegion(w ->
|
||||
{
|
||||
if (w.areNeighborsEmpty())
|
||||
{
|
||||
w.setActive(false);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void switchAI(boolean isOn)
|
||||
{
|
||||
if (_visibleObjects == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int c = 0;
|
||||
if (!isOn)
|
||||
{
|
||||
final Collection<L2Object> vObj = _visibleObjects.values();
|
||||
for (L2Object o : vObj)
|
||||
{
|
||||
if (o instanceof L2Attackable)
|
||||
{
|
||||
c++;
|
||||
final L2Attackable mob = (L2Attackable) o;
|
||||
|
||||
// Set target to null and cancel Attack or Cast
|
||||
mob.setTarget(null);
|
||||
|
||||
// Stop movement
|
||||
mob.stopMove(null);
|
||||
|
||||
// Stop all active skills effects in progress on the L2Character
|
||||
mob.stopAllEffects();
|
||||
|
||||
mob.clearAggroList();
|
||||
mob.getAttackByList().clear();
|
||||
|
||||
// stop the ai tasks
|
||||
if (mob.hasAI())
|
||||
{
|
||||
mob.getAI().setIntention(com.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE);
|
||||
mob.getAI().stopAITask();
|
||||
}
|
||||
}
|
||||
else if (o instanceof L2Vehicle)
|
||||
{
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
_log.finer(c + " mobs were turned off");
|
||||
}
|
||||
else
|
||||
{
|
||||
final Collection<L2Object> vObj = _visibleObjects.values();
|
||||
|
||||
for (L2Object o : vObj)
|
||||
{
|
||||
if (o instanceof L2Attackable)
|
||||
{
|
||||
c++;
|
||||
// Start HP/MP/CP Regeneration task
|
||||
((L2Attackable) o).getStatus().startHpMpRegeneration();
|
||||
}
|
||||
else if (o instanceof L2Npc)
|
||||
{
|
||||
((L2Npc) o).startRandomAnimationTask();
|
||||
}
|
||||
}
|
||||
|
||||
_log.finer(c + " mobs were turned on");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
return _active;
|
||||
}
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
return !forEachSurroundingRegion(w ->
|
||||
{
|
||||
return !(w.isActive() && w.getVisibleObjects().values().stream().anyMatch(L2Object::isPlayable));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* this function turns this region's AI and geodata on or off
|
||||
* @param value
|
||||
*/
|
||||
public void setActive(boolean value)
|
||||
{
|
||||
if (_active == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_active = value;
|
||||
|
||||
// turn the AI on or off to match the region's activation.
|
||||
switchAI(value);
|
||||
|
||||
_log.finer((value ? "Starting" : "Stoping") + " Grid " + getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Immediately sets self as active and starts a timer to set neighbors as active this timer is to avoid turning on neighbors in the case when a person just teleported into a region and then teleported out immediately...there is no reason to activate all the neighbors in that case.
|
||||
*/
|
||||
private void startActivation()
|
||||
{
|
||||
// first set self to active and do self-tasks...
|
||||
setActive(true);
|
||||
|
||||
// if the timer to deactivate neighbors is running, cancel it.
|
||||
synchronized (this)
|
||||
{
|
||||
if (_neighborsTask != null)
|
||||
{
|
||||
_neighborsTask.cancel(true);
|
||||
_neighborsTask = null;
|
||||
}
|
||||
|
||||
// then, set a timer to activate the neighbors
|
||||
_neighborsTask = ThreadPoolManager.getInstance().scheduleGeneral(new NeighborsTask(true), 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* starts a timer to set neighbors (including self) as inactive this timer is to avoid turning off neighbors in the case when a person just moved out of a region that he may very soon return to. There is no reason to turn self & neighbors off in that case.
|
||||
*/
|
||||
private void startDeactivation()
|
||||
{
|
||||
// if the timer to activate neighbors is running, cancel it.
|
||||
synchronized (this)
|
||||
{
|
||||
if (_neighborsTask != null)
|
||||
{
|
||||
_neighborsTask.cancel(true);
|
||||
_neighborsTask = null;
|
||||
}
|
||||
|
||||
// start a timer to "suggest" a deactivate to self and neighbors.
|
||||
// suggest means: first check if a neighbor has L2PcInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPoolManager.getInstance().scheduleGeneral(new NeighborsTask(false), 1000 * Config.GRID_NEIGHBOR_TURNOFF_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the L2Object in the L2ObjectHashSet(L2Object) _visibleObjects containing L2Object visible in this L2WorldRegion <BR>
|
||||
* If L2Object is a L2PcInstance, Add the L2PcInstance in the L2ObjectHashSet(L2PcInstance) _allPlayable containing L2PcInstance of all player in game in this L2WorldRegion <BR>
|
||||
* Assert : object.getCurrentWorldRegion() == this
|
||||
* @param object
|
||||
*/
|
||||
public void addVisibleObject(L2Object object)
|
||||
{
|
||||
if (object == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
assert object.getWorldRegion() == this;
|
||||
if (_visibleObjects == null)
|
||||
{
|
||||
synchronized (object)
|
||||
{
|
||||
if (_visibleObjects == null)
|
||||
{
|
||||
_visibleObjects = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
|
||||
if (object.isPlayable())
|
||||
{
|
||||
// if this is the first player to enter the region, activate self & neighbors
|
||||
if (!isActive() && (!Config.GRIDS_ALWAYS_ON))
|
||||
{
|
||||
startActivation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the L2Object from the L2ObjectHashSet(L2Object) _visibleObjects in this L2WorldRegion. If L2Object is a L2PcInstance, remove it from the L2ObjectHashSet(L2PcInstance) _allPlayable of this L2WorldRegion <BR>
|
||||
* Assert : object.getCurrentWorldRegion() == this || object.getCurrentWorldRegion() == null
|
||||
* @param object
|
||||
*/
|
||||
public void removeVisibleObject(L2Object object)
|
||||
{
|
||||
if (object == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
assert (object.getWorldRegion() == this) || (object.getWorldRegion() == null);
|
||||
if (_visibleObjects == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
if (object.isPlayable())
|
||||
{
|
||||
if (areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, L2Object> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects != null ? _visibleObjects : Collections.emptyMap();
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return "(" + _regionX + ", " + _regionY + ", " + _regionZ + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Deleted all spawns in the world.
|
||||
*/
|
||||
public void deleteVisibleNpcSpawns()
|
||||
{
|
||||
if (_visibleObjects == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_log.finer("Deleting all visible NPC's in Region: " + getName());
|
||||
|
||||
final Collection<L2Object> vNPC = _visibleObjects.values();
|
||||
for (L2Object obj : vNPC)
|
||||
{
|
||||
if (obj instanceof L2Npc)
|
||||
{
|
||||
final L2Npc target = (L2Npc) obj;
|
||||
target.deleteMe();
|
||||
final L2Spawn spawn = target.getSpawn();
|
||||
if (spawn != null)
|
||||
{
|
||||
spawn.stopRespawn();
|
||||
SpawnTable.getInstance().deleteSpawn(spawn, false);
|
||||
}
|
||||
_log.finest("Removed NPC " + target.getObjectId());
|
||||
}
|
||||
}
|
||||
_log.info("All visible NPC's deleted in Region: " + getName());
|
||||
}
|
||||
|
||||
public boolean forEachSurroundingRegion(Predicate<L2WorldRegion> p)
|
||||
{
|
||||
for (int x = _regionX - 1; x <= (_regionX + 1); x++)
|
||||
{
|
||||
for (int y = _regionY - 1; y <= (_regionY + 1); y++)
|
||||
{
|
||||
for (int z = _regionZ - 1; z <= (_regionZ + 1); z++)
|
||||
{
|
||||
if (L2World.validRegion(x, y, z))
|
||||
{
|
||||
final L2WorldRegion worldRegion = L2World.getInstance().getWorldRegions()[x][y][z];
|
||||
if (!p.test(worldRegion))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getRegionX()
|
||||
{
|
||||
return _regionX;
|
||||
}
|
||||
|
||||
public int getRegionY()
|
||||
{
|
||||
return _regionY;
|
||||
}
|
||||
|
||||
public int getRegionZ()
|
||||
{
|
||||
return _regionZ;
|
||||
}
|
||||
|
||||
public boolean isSurroundingRegion(L2WorldRegion region)
|
||||
{
|
||||
return (region != null) && (getRegionX() >= (region.getRegionX() - 1)) && (getRegionX() <= (region.getRegionX() + 1)) && (getRegionY() >= (region.getRegionY() - 1)) && (getRegionY() <= (region.getRegionY() + 1)) && (getRegionZ() >= (region.getRegionZ() - 1)) && (getRegionZ() <= (region.getRegionZ() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,223 +1,195 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.interfaces.ILocational;
|
||||
import com.l2jmobius.gameserver.model.interfaces.IPositionable;
|
||||
|
||||
/**
|
||||
* Location data transfer object.<br>
|
||||
* Contains coordinates data, heading and instance Id.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class Location implements IPositionable
|
||||
{
|
||||
private int _x;
|
||||
private int _y;
|
||||
private int _z;
|
||||
private int _heading;
|
||||
private int _instanceId;
|
||||
|
||||
public Location(int x, int y, int z)
|
||||
{
|
||||
this(x, y, z, 0, -1);
|
||||
}
|
||||
|
||||
public Location(int x, int y, int z, int heading)
|
||||
{
|
||||
this(x, y, z, heading, -1);
|
||||
}
|
||||
|
||||
public Location(L2Object obj)
|
||||
{
|
||||
this(obj.getX(), obj.getY(), obj.getZ(), obj.getHeading(), obj.getInstanceId());
|
||||
}
|
||||
|
||||
public Location(int x, int y, int z, int heading, int instanceId)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
_z = z;
|
||||
_heading = heading;
|
||||
_instanceId = instanceId;
|
||||
}
|
||||
|
||||
public Location(StatsSet set)
|
||||
{
|
||||
_x = set.getInt("x");
|
||||
_y = set.getInt("y");
|
||||
_z = set.getInt("z");
|
||||
_heading = set.getInt("heading", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the x coordinate.
|
||||
* @return the x coordinate
|
||||
*/
|
||||
@Override
|
||||
public int getX()
|
||||
{
|
||||
return _x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the x coordinate.
|
||||
* @param x the x coordinate
|
||||
*/
|
||||
@Override
|
||||
public void setX(int x)
|
||||
{
|
||||
_x = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the y coordinate.
|
||||
* @return the y coordinate
|
||||
*/
|
||||
@Override
|
||||
public int getY()
|
||||
{
|
||||
return _y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the y coordinate.
|
||||
* @param y the x coordinate
|
||||
*/
|
||||
@Override
|
||||
public void setY(int y)
|
||||
{
|
||||
_y = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the z coordinate.
|
||||
* @return the z coordinate
|
||||
*/
|
||||
@Override
|
||||
public int getZ()
|
||||
{
|
||||
return _z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the z coordinate.
|
||||
* @param z the z coordinate
|
||||
*/
|
||||
@Override
|
||||
public void setZ(int z)
|
||||
{
|
||||
_z = z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the x, y, z coordinates.
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
*/
|
||||
@Override
|
||||
public void setXYZ(int x, int y, int z)
|
||||
{
|
||||
setX(x);
|
||||
setY(y);
|
||||
setZ(z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the x, y, z coordinates.
|
||||
* @param loc The location.
|
||||
*/
|
||||
@Override
|
||||
public void setXYZ(ILocational loc)
|
||||
{
|
||||
setXYZ(loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the heading.
|
||||
* @return the heading
|
||||
*/
|
||||
@Override
|
||||
public int getHeading()
|
||||
{
|
||||
return _heading;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the heading.
|
||||
* @param heading the heading
|
||||
*/
|
||||
@Override
|
||||
public void setHeading(int heading)
|
||||
{
|
||||
_heading = heading;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the instance Id.
|
||||
* @return the instance Id
|
||||
*/
|
||||
@Override
|
||||
public int getInstanceId()
|
||||
{
|
||||
return _instanceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance Id.
|
||||
* @param instanceId the instance Id to set
|
||||
*/
|
||||
@Override
|
||||
public void setInstanceId(int instanceId)
|
||||
{
|
||||
_instanceId = instanceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPositionable getLocation()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(Location loc)
|
||||
{
|
||||
_x = loc.getX();
|
||||
_y = loc.getY();
|
||||
_z = loc.getZ();
|
||||
_heading = loc.getHeading();
|
||||
_instanceId = loc.getInstanceId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if ((obj == null) || !(obj instanceof Location))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final Location loc = (Location) obj;
|
||||
return (getX() == loc.getX()) && (getY() == loc.getY()) && (getZ() == loc.getZ()) && (getHeading() == loc.getHeading()) && (getInstanceId() == loc.getInstanceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "[" + getClass().getSimpleName() + "] X: " + getX() + " Y: " + getY() + " Z: " + getZ() + " Heading: " + _heading + " InstanceId: " + _instanceId;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.interfaces.ILocational;
|
||||
import com.l2jmobius.gameserver.model.interfaces.IPositionable;
|
||||
|
||||
/**
|
||||
* Location data transfer object.<br>
|
||||
* Contains coordinates data, heading and instance Id.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class Location implements IPositionable
|
||||
{
|
||||
private int _x;
|
||||
private int _y;
|
||||
private int _z;
|
||||
private int _heading;
|
||||
|
||||
public Location(int x, int y, int z)
|
||||
{
|
||||
this(x, y, z, 0);
|
||||
}
|
||||
|
||||
public Location(int x, int y, int z, int heading)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
_z = z;
|
||||
_heading = heading;
|
||||
}
|
||||
|
||||
public Location(L2Object obj)
|
||||
{
|
||||
this(obj.getX(), obj.getY(), obj.getZ(), obj.getHeading());
|
||||
}
|
||||
|
||||
public Location(StatsSet set)
|
||||
{
|
||||
_x = set.getInt("x");
|
||||
_y = set.getInt("y");
|
||||
_z = set.getInt("z");
|
||||
_heading = set.getInt("heading", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the x coordinate.
|
||||
* @return the x coordinate
|
||||
*/
|
||||
@Override
|
||||
public int getX()
|
||||
{
|
||||
return _x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the x coordinate.
|
||||
* @param x the x coordinate
|
||||
*/
|
||||
@Override
|
||||
public void setX(int x)
|
||||
{
|
||||
_x = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the y coordinate.
|
||||
* @return the y coordinate
|
||||
*/
|
||||
@Override
|
||||
public int getY()
|
||||
{
|
||||
return _y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the y coordinate.
|
||||
* @param y the x coordinate
|
||||
*/
|
||||
@Override
|
||||
public void setY(int y)
|
||||
{
|
||||
_y = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the z coordinate.
|
||||
* @return the z coordinate
|
||||
*/
|
||||
@Override
|
||||
public int getZ()
|
||||
{
|
||||
return _z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the z coordinate.
|
||||
* @param z the z coordinate
|
||||
*/
|
||||
@Override
|
||||
public void setZ(int z)
|
||||
{
|
||||
_z = z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the x, y, z coordinates.
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
*/
|
||||
@Override
|
||||
public void setXYZ(int x, int y, int z)
|
||||
{
|
||||
setX(x);
|
||||
setY(y);
|
||||
setZ(z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the x, y, z coordinates.
|
||||
* @param loc The location.
|
||||
*/
|
||||
@Override
|
||||
public void setXYZ(ILocational loc)
|
||||
{
|
||||
setXYZ(loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the heading.
|
||||
* @return the heading
|
||||
*/
|
||||
@Override
|
||||
public int getHeading()
|
||||
{
|
||||
return _heading;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the heading.
|
||||
* @param heading the heading
|
||||
*/
|
||||
@Override
|
||||
public void setHeading(int heading)
|
||||
{
|
||||
_heading = heading;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPositionable getLocation()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(Location loc)
|
||||
{
|
||||
_x = loc.getX();
|
||||
_y = loc.getY();
|
||||
_z = loc.getZ();
|
||||
_heading = loc.getHeading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if ((obj != null) && (obj instanceof Location))
|
||||
{
|
||||
final Location loc = (Location) obj;
|
||||
return (getX() == loc.getX()) && (getY() == loc.getY()) && (getZ() == loc.getZ()) && (getHeading() == loc.getHeading());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "[" + getClass().getSimpleName() + "] X: " + getX() + " Y: " + getY() + " Z: " + getZ() + " Heading: " + _heading;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,116 +1,116 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||
import com.l2jmobius.gameserver.model.interfaces.INamable;
|
||||
|
||||
public class Macro implements IIdentifiable, INamable
|
||||
{
|
||||
private int _id;
|
||||
private final int _icon;
|
||||
private final String _name;
|
||||
private final String _descr;
|
||||
private final String _acronym;
|
||||
private final List<MacroCmd> _commands;
|
||||
|
||||
/**
|
||||
* Constructor for macros.
|
||||
* @param id the macro ID
|
||||
* @param icon the icon ID
|
||||
* @param name the macro name
|
||||
* @param descr the macro description
|
||||
* @param acronym the macro acronym
|
||||
* @param list the macro command list
|
||||
*/
|
||||
public Macro(int id, int icon, String name, String descr, String acronym, List<MacroCmd> list)
|
||||
{
|
||||
_id = id;
|
||||
_icon = icon;
|
||||
_name = name;
|
||||
_descr = descr;
|
||||
_acronym = acronym;
|
||||
_commands = list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the marco ID.
|
||||
* @returns the marco ID
|
||||
*/
|
||||
@Override
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the marco ID.
|
||||
* @param id the marco ID
|
||||
*/
|
||||
public void setId(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the macro icon ID.
|
||||
* @return the icon
|
||||
*/
|
||||
public int getIcon()
|
||||
{
|
||||
return _icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the macro name.
|
||||
* @return the name
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the macro description.
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescr()
|
||||
{
|
||||
return _descr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the macro acronym.
|
||||
* @return the acronym
|
||||
*/
|
||||
public String getAcronym()
|
||||
{
|
||||
return _acronym;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the macro command list.
|
||||
* @return the macro command list
|
||||
*/
|
||||
public List<MacroCmd> getCommands()
|
||||
{
|
||||
return _commands;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||
import com.l2jmobius.gameserver.model.interfaces.INamable;
|
||||
|
||||
public class Macro implements IIdentifiable, INamable
|
||||
{
|
||||
private int _id;
|
||||
private final int _icon;
|
||||
private final String _name;
|
||||
private final String _descr;
|
||||
private final String _acronym;
|
||||
private final List<MacroCmd> _commands;
|
||||
|
||||
/**
|
||||
* Constructor for macros.
|
||||
* @param id the macro ID
|
||||
* @param icon the icon ID
|
||||
* @param name the macro name
|
||||
* @param descr the macro description
|
||||
* @param acronym the macro acronym
|
||||
* @param list the macro command list
|
||||
*/
|
||||
public Macro(int id, int icon, String name, String descr, String acronym, List<MacroCmd> list)
|
||||
{
|
||||
_id = id;
|
||||
_icon = icon;
|
||||
_name = name;
|
||||
_descr = descr;
|
||||
_acronym = acronym;
|
||||
_commands = list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the marco ID.
|
||||
* @returns the marco ID
|
||||
*/
|
||||
@Override
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the marco ID.
|
||||
* @param id the marco ID
|
||||
*/
|
||||
public void setId(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the macro icon ID.
|
||||
* @return the icon
|
||||
*/
|
||||
public int getIcon()
|
||||
{
|
||||
return _icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the macro name.
|
||||
* @return the name
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the macro description.
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescr()
|
||||
{
|
||||
return _descr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the macro acronym.
|
||||
* @return the acronym
|
||||
*/
|
||||
public String getAcronym()
|
||||
{
|
||||
return _acronym;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the macro command list.
|
||||
* @return the macro command list
|
||||
*/
|
||||
public List<MacroCmd> getCommands()
|
||||
{
|
||||
return _commands;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.MacroType;
|
||||
|
||||
/**
|
||||
* Macro Cmd DTO.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class MacroCmd
|
||||
{
|
||||
private final int _entry;
|
||||
private final MacroType _type;
|
||||
private final int _d1; // skill_id or page for shortcuts
|
||||
private final int _d2; // shortcut
|
||||
private final String _cmd;
|
||||
|
||||
public MacroCmd(int entry, MacroType type, int d1, int d2, String cmd)
|
||||
{
|
||||
_entry = entry;
|
||||
_type = type;
|
||||
_d1 = d1;
|
||||
_d2 = d2;
|
||||
_cmd = cmd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entry index.
|
||||
* @return the entry index
|
||||
*/
|
||||
public int getEntry()
|
||||
{
|
||||
return _entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the macro type.
|
||||
* @return the macro type
|
||||
*/
|
||||
public MacroType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skill ID, item ID, page ID, depending on the marco use.
|
||||
* @return the first value
|
||||
*/
|
||||
public int getD1()
|
||||
{
|
||||
return _d1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skill level, shortcut ID, depending on the marco use.
|
||||
* @return the second value
|
||||
*/
|
||||
public int getD2()
|
||||
{
|
||||
return _d2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the command.
|
||||
* @return the command
|
||||
*/
|
||||
public String getCmd()
|
||||
{
|
||||
return _cmd;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.MacroType;
|
||||
|
||||
/**
|
||||
* Macro Cmd DTO.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class MacroCmd
|
||||
{
|
||||
private final int _entry;
|
||||
private final MacroType _type;
|
||||
private final int _d1; // skill_id or page for shortcuts
|
||||
private final int _d2; // shortcut
|
||||
private final String _cmd;
|
||||
|
||||
public MacroCmd(int entry, MacroType type, int d1, int d2, String cmd)
|
||||
{
|
||||
_entry = entry;
|
||||
_type = type;
|
||||
_d1 = d1;
|
||||
_d2 = d2;
|
||||
_cmd = cmd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entry index.
|
||||
* @return the entry index
|
||||
*/
|
||||
public int getEntry()
|
||||
{
|
||||
return _entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the macro type.
|
||||
* @return the macro type
|
||||
*/
|
||||
public MacroType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skill ID, item ID, page ID, depending on the marco use.
|
||||
* @return the first value
|
||||
*/
|
||||
public int getD1()
|
||||
{
|
||||
return _d1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skill level, shortcut ID, depending on the marco use.
|
||||
* @return the second value
|
||||
*/
|
||||
public int getD2()
|
||||
{
|
||||
return _d2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the command.
|
||||
* @return the command
|
||||
*/
|
||||
public String getCmd()
|
||||
{
|
||||
return _cmd;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,215 +1,223 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.enums.MacroType;
|
||||
import com.l2jmobius.gameserver.enums.MacroUpdateType;
|
||||
import com.l2jmobius.gameserver.enums.ShortcutType;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.interfaces.IRestorable;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SendMacroList;
|
||||
import com.l2jmobius.util.StringUtil;
|
||||
|
||||
public class MacroList implements IRestorable
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(MacroList.class.getName());
|
||||
|
||||
private final L2PcInstance _owner;
|
||||
private int _macroId;
|
||||
private final Map<Integer, Macro> _macroses = Collections.synchronizedMap(new LinkedHashMap<Integer, Macro>());
|
||||
|
||||
public MacroList(L2PcInstance owner)
|
||||
{
|
||||
_owner = owner;
|
||||
_macroId = 1000;
|
||||
}
|
||||
|
||||
public Map<Integer, Macro> getAllMacroses()
|
||||
{
|
||||
return _macroses;
|
||||
}
|
||||
|
||||
public void registerMacro(Macro macro)
|
||||
{
|
||||
MacroUpdateType updateType = MacroUpdateType.ADD;
|
||||
if (macro.getId() == 0)
|
||||
{
|
||||
macro.setId(_macroId++);
|
||||
while (_macroses.containsKey(macro.getId()))
|
||||
{
|
||||
macro.setId(_macroId++);
|
||||
}
|
||||
_macroses.put(macro.getId(), macro);
|
||||
}
|
||||
else
|
||||
{
|
||||
updateType = MacroUpdateType.MODIFY;
|
||||
final Macro old = _macroses.put(macro.getId(), macro);
|
||||
if (old != null)
|
||||
{
|
||||
deleteMacroFromDb(old);
|
||||
}
|
||||
}
|
||||
registerMacroInDb(macro);
|
||||
_owner.sendPacket(new SendMacroList(1, macro, updateType));
|
||||
}
|
||||
|
||||
public void deleteMacro(int id)
|
||||
{
|
||||
final Macro removed = _macroses.remove(id);
|
||||
if (removed != null)
|
||||
{
|
||||
deleteMacroFromDb(removed);
|
||||
}
|
||||
|
||||
final Shortcut[] allShortCuts = _owner.getAllShortCuts();
|
||||
for (Shortcut sc : allShortCuts)
|
||||
{
|
||||
if ((sc.getId() == id) && (sc.getType() == ShortcutType.MACRO))
|
||||
{
|
||||
_owner.deleteShortCut(sc.getSlot(), sc.getPage());
|
||||
}
|
||||
}
|
||||
_owner.sendPacket(new SendMacroList(0, removed, MacroUpdateType.DELETE));
|
||||
}
|
||||
|
||||
public void sendAllMacros()
|
||||
{
|
||||
final Collection<Macro> allMacros = _macroses.values();
|
||||
final int count = allMacros.size();
|
||||
|
||||
synchronized (_macroses)
|
||||
{
|
||||
if (allMacros.isEmpty())
|
||||
{
|
||||
_owner.sendPacket(new SendMacroList(0, null, MacroUpdateType.LIST));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Macro m : allMacros)
|
||||
{
|
||||
_owner.sendPacket(new SendMacroList(count, m, MacroUpdateType.LIST));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerMacroInDb(Macro macro)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO character_macroses (charId,id,icon,name,descr,acronym,commands) values(?,?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, _owner.getObjectId());
|
||||
ps.setInt(2, macro.getId());
|
||||
ps.setInt(3, macro.getIcon());
|
||||
ps.setString(4, macro.getName());
|
||||
ps.setString(5, macro.getDescr());
|
||||
ps.setString(6, macro.getAcronym());
|
||||
final StringBuilder sb = new StringBuilder(300);
|
||||
for (MacroCmd cmd : macro.getCommands())
|
||||
{
|
||||
StringUtil.append(sb, String.valueOf(cmd.getType().ordinal()), ",", String.valueOf(cmd.getD1()), ",", String.valueOf(cmd.getD2()));
|
||||
if ((cmd.getCmd() != null) && (cmd.getCmd().length() > 0))
|
||||
{
|
||||
StringUtil.append(sb, ",", cmd.getCmd());
|
||||
}
|
||||
sb.append(';');
|
||||
}
|
||||
|
||||
if (sb.length() > 255)
|
||||
{
|
||||
sb.setLength(255);
|
||||
}
|
||||
|
||||
ps.setString(7, sb.toString());
|
||||
ps.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "could not store macro:", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteMacroFromDb(Macro macro)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM character_macroses WHERE charId=? AND id=?"))
|
||||
{
|
||||
ps.setInt(1, _owner.getObjectId());
|
||||
ps.setInt(2, macro.getId());
|
||||
ps.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "could not delete macro:", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restoreMe()
|
||||
{
|
||||
_macroses.clear();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT charId, id, icon, name, descr, acronym, commands FROM character_macroses WHERE charId=?"))
|
||||
{
|
||||
ps.setInt(1, _owner.getObjectId());
|
||||
try (ResultSet rset = ps.executeQuery())
|
||||
{
|
||||
while (rset.next())
|
||||
{
|
||||
final int id = rset.getInt("id");
|
||||
final int icon = rset.getInt("icon");
|
||||
final String name = rset.getString("name");
|
||||
final String descr = rset.getString("descr");
|
||||
final String acronym = rset.getString("acronym");
|
||||
final List<MacroCmd> commands = new ArrayList<>();
|
||||
final StringTokenizer st1 = new StringTokenizer(rset.getString("commands"), ";");
|
||||
while (st1.hasMoreTokens())
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(st1.nextToken(), ",");
|
||||
if (st.countTokens() < 3)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
commands.add(new MacroCmd(commands.size(), MacroType.values()[Integer.parseInt(st.nextToken())], Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()), (st.hasMoreTokens() ? st.nextToken() : "")));
|
||||
}
|
||||
_macroses.put(id, new Macro(id, icon, name, descr, acronym, commands));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "could not store shortcuts:", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.enums.MacroType;
|
||||
import com.l2jmobius.gameserver.enums.MacroUpdateType;
|
||||
import com.l2jmobius.gameserver.enums.ShortcutType;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.interfaces.IRestorable;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SendMacroList;
|
||||
|
||||
public class MacroList implements IRestorable
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(MacroList.class.getName());
|
||||
|
||||
private final L2PcInstance _owner;
|
||||
private int _macroId;
|
||||
private final Map<Integer, Macro> _macroses = Collections.synchronizedMap(new LinkedHashMap<>());
|
||||
|
||||
public MacroList(L2PcInstance owner)
|
||||
{
|
||||
_owner = owner;
|
||||
_macroId = 1000;
|
||||
}
|
||||
|
||||
public Map<Integer, Macro> getAllMacroses()
|
||||
{
|
||||
return _macroses;
|
||||
}
|
||||
|
||||
public void registerMacro(Macro macro)
|
||||
{
|
||||
MacroUpdateType updateType = MacroUpdateType.ADD;
|
||||
if (macro.getId() == 0)
|
||||
{
|
||||
macro.setId(_macroId++);
|
||||
while (_macroses.containsKey(macro.getId()))
|
||||
{
|
||||
macro.setId(_macroId++);
|
||||
}
|
||||
_macroses.put(macro.getId(), macro);
|
||||
registerMacroInDb(macro);
|
||||
}
|
||||
else
|
||||
{
|
||||
updateType = MacroUpdateType.MODIFY;
|
||||
final Macro old = _macroses.put(macro.getId(), macro);
|
||||
if (old != null)
|
||||
{
|
||||
deleteMacroFromDb(old);
|
||||
}
|
||||
registerMacroInDb(macro);
|
||||
}
|
||||
_owner.sendPacket(new SendMacroList(1, macro, updateType));
|
||||
}
|
||||
|
||||
public void deleteMacro(int id)
|
||||
{
|
||||
final Macro removed = _macroses.remove(id);
|
||||
if (removed != null)
|
||||
{
|
||||
deleteMacroFromDb(removed);
|
||||
}
|
||||
|
||||
final Shortcut[] allShortCuts = _owner.getAllShortCuts();
|
||||
for (Shortcut sc : allShortCuts)
|
||||
{
|
||||
if ((sc.getId() == id) && (sc.getType() == ShortcutType.MACRO))
|
||||
{
|
||||
_owner.deleteShortCut(sc.getSlot(), sc.getPage());
|
||||
}
|
||||
}
|
||||
_owner.sendPacket(new SendMacroList(0, removed, MacroUpdateType.DELETE));
|
||||
}
|
||||
|
||||
public void sendAllMacros()
|
||||
{
|
||||
final Collection<Macro> allMacros = _macroses.values();
|
||||
final int count = allMacros.size();
|
||||
|
||||
synchronized (_macroses)
|
||||
{
|
||||
if (allMacros.isEmpty())
|
||||
{
|
||||
_owner.sendPacket(new SendMacroList(0, null, MacroUpdateType.LIST));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Macro m : allMacros)
|
||||
{
|
||||
_owner.sendPacket(new SendMacroList(count, m, MacroUpdateType.LIST));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerMacroInDb(Macro macro)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO character_macroses (charId,id,icon,name,descr,acronym,commands) values(?,?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, _owner.getObjectId());
|
||||
ps.setInt(2, macro.getId());
|
||||
ps.setInt(3, macro.getIcon());
|
||||
ps.setString(4, macro.getName());
|
||||
ps.setString(5, macro.getDescr());
|
||||
ps.setString(6, macro.getAcronym());
|
||||
final StringBuilder sb = new StringBuilder(300);
|
||||
for (MacroCmd cmd : macro.getCommands())
|
||||
{
|
||||
sb.append(cmd.getType().ordinal() + "," + cmd.getD1() + "," + cmd.getD2());
|
||||
if ((cmd.getCmd() != null) && (cmd.getCmd().length() > 0))
|
||||
{
|
||||
sb.append("," + cmd.getCmd());
|
||||
}
|
||||
sb.append(';');
|
||||
}
|
||||
|
||||
if (sb.length() > 255)
|
||||
{
|
||||
sb.setLength(255);
|
||||
}
|
||||
|
||||
ps.setString(7, sb.toString());
|
||||
ps.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "could not store macro:", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteMacroFromDb(Macro macro)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM character_macroses WHERE charId=? AND id=?"))
|
||||
{
|
||||
ps.setInt(1, _owner.getObjectId());
|
||||
ps.setInt(2, macro.getId());
|
||||
ps.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "could not delete macro:", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restoreMe()
|
||||
{
|
||||
_macroses.clear();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT charId, id, icon, name, descr, acronym, commands FROM character_macroses WHERE charId=?"))
|
||||
{
|
||||
ps.setInt(1, _owner.getObjectId());
|
||||
try (ResultSet rset = ps.executeQuery())
|
||||
{
|
||||
while (rset.next())
|
||||
{
|
||||
final int id = rset.getInt("id");
|
||||
final int icon = rset.getInt("icon");
|
||||
final String name = rset.getString("name");
|
||||
final String descr = rset.getString("descr");
|
||||
final String acronym = rset.getString("acronym");
|
||||
final List<MacroCmd> commands = new ArrayList<>();
|
||||
final StringTokenizer st1 = new StringTokenizer(rset.getString("commands"), ";");
|
||||
while (st1.hasMoreTokens())
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(st1.nextToken(), ",");
|
||||
if (st.countTokens() < 3)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final MacroType type = MacroType.values()[Integer.parseInt(st.nextToken())];
|
||||
final int d1 = Integer.parseInt(st.nextToken());
|
||||
final int d2 = Integer.parseInt(st.nextToken());
|
||||
String cmd = "";
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
cmd = st.nextToken();
|
||||
}
|
||||
commands.add(new MacroCmd(commands.size(), type, d1, d2, cmd));
|
||||
}
|
||||
_macroses.put(id, new Macro(id, icon, name, descr, acronym, commands));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "could not store shortcuts:", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,403 +1,409 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.ai.L2ControllableMobAI;
|
||||
import com.l2jmobius.gameserver.datatables.SpawnTable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* @author littlecrow
|
||||
*/
|
||||
public final class MobGroup
|
||||
{
|
||||
private final L2NpcTemplate _npcTemplate;
|
||||
private final int _groupId;
|
||||
private final int _maxMobCount;
|
||||
|
||||
private List<L2ControllableMobInstance> _mobs;
|
||||
|
||||
public MobGroup(int groupId, L2NpcTemplate npcTemplate, int maxMobCount)
|
||||
{
|
||||
_groupId = groupId;
|
||||
_npcTemplate = npcTemplate;
|
||||
_maxMobCount = maxMobCount;
|
||||
}
|
||||
|
||||
public int getActiveMobCount()
|
||||
{
|
||||
return getMobs().size();
|
||||
}
|
||||
|
||||
public int getGroupId()
|
||||
{
|
||||
return _groupId;
|
||||
}
|
||||
|
||||
public int getMaxMobCount()
|
||||
{
|
||||
return _maxMobCount;
|
||||
}
|
||||
|
||||
public List<L2ControllableMobInstance> getMobs()
|
||||
{
|
||||
if (_mobs == null)
|
||||
{
|
||||
_mobs = new CopyOnWriteArrayList<>();
|
||||
}
|
||||
|
||||
return _mobs;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (((L2ControllableMobAI) getMobs().get(0).getAI()).getAlternateAI())
|
||||
{
|
||||
case L2ControllableMobAI.AI_NORMAL:
|
||||
{
|
||||
return "Idle";
|
||||
}
|
||||
case L2ControllableMobAI.AI_FORCEATTACK:
|
||||
{
|
||||
return "Force Attacking";
|
||||
}
|
||||
case L2ControllableMobAI.AI_FOLLOW:
|
||||
{
|
||||
return "Following";
|
||||
}
|
||||
case L2ControllableMobAI.AI_CAST:
|
||||
{
|
||||
return "Casting";
|
||||
}
|
||||
case L2ControllableMobAI.AI_ATTACK_GROUP:
|
||||
{
|
||||
return "Attacking Group";
|
||||
}
|
||||
default:
|
||||
{
|
||||
return "Idle";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return "Unspawned";
|
||||
}
|
||||
}
|
||||
|
||||
public L2NpcTemplate getTemplate()
|
||||
{
|
||||
return _npcTemplate;
|
||||
}
|
||||
|
||||
public boolean isGroupMember(L2ControllableMobInstance mobInst)
|
||||
{
|
||||
for (L2ControllableMobInstance groupMember : getMobs())
|
||||
{
|
||||
if (groupMember == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (groupMember.getObjectId() == mobInst.getObjectId())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void spawnGroup(int x, int y, int z)
|
||||
{
|
||||
if (getActiveMobCount() > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < getMaxMobCount(); i++)
|
||||
{
|
||||
final L2GroupSpawn spawn = new L2GroupSpawn(getTemplate());
|
||||
|
||||
final int signX = (Rnd.nextInt(2) == 0) ? -1 : 1;
|
||||
final int signY = (Rnd.nextInt(2) == 0) ? -1 : 1;
|
||||
final int randX = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
|
||||
final int randY = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
|
||||
|
||||
spawn.setX(x + (signX * randX));
|
||||
spawn.setY(y + (signY * randY));
|
||||
spawn.setZ(z);
|
||||
spawn.stopRespawn();
|
||||
|
||||
SpawnTable.getInstance().addNewSpawn(spawn, false);
|
||||
getMobs().add((L2ControllableMobInstance) spawn.doGroupSpawn());
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
}
|
||||
catch (NoSuchMethodException e2)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void spawnGroup(L2PcInstance activeChar)
|
||||
{
|
||||
spawnGroup(activeChar.getX(), activeChar.getY(), activeChar.getZ());
|
||||
}
|
||||
|
||||
public void teleportGroup(L2PcInstance player)
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!mobInst.isDead())
|
||||
{
|
||||
final int x = player.getX() + Rnd.nextInt(50);
|
||||
final int y = player.getY() + Rnd.nextInt(50);
|
||||
|
||||
mobInst.teleToLocation(new Location(x, y, player.getZ()), true);
|
||||
((L2ControllableMobAI) mobInst.getAI()).follow(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public L2ControllableMobInstance getRandomMob()
|
||||
{
|
||||
removeDead();
|
||||
return getActiveMobCount() == 0 ? null : getMobs().get(Rnd.nextInt(getActiveMobCount()));
|
||||
}
|
||||
|
||||
public void unspawnGroup()
|
||||
{
|
||||
removeDead();
|
||||
|
||||
if (getActiveMobCount() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!mobInst.isDead())
|
||||
{
|
||||
mobInst.deleteMe();
|
||||
}
|
||||
|
||||
SpawnTable.getInstance().deleteSpawn(mobInst.getSpawn(), false);
|
||||
}
|
||||
|
||||
getMobs().clear();
|
||||
}
|
||||
|
||||
public void killGroup(L2PcInstance activeChar)
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!mobInst.isDead())
|
||||
{
|
||||
mobInst.reduceCurrentHp(mobInst.getMaxHp() + 1, activeChar, null);
|
||||
}
|
||||
|
||||
SpawnTable.getInstance().deleteSpawn(mobInst.getSpawn(), false);
|
||||
}
|
||||
|
||||
getMobs().clear();
|
||||
}
|
||||
|
||||
public void setAttackRandom()
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.setAlternateAI(L2ControllableMobAI.AI_NORMAL);
|
||||
ai.setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAttackTarget(L2Character target)
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
((L2ControllableMobAI) mobInst.getAI()).forceAttack(target);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIdleMode()
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
((L2ControllableMobAI) mobInst.getAI()).stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void returnGroup(L2Character activeChar)
|
||||
{
|
||||
setIdleMode();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
((L2ControllableMobAI) mobInst.getAI()).move(activeChar.getX() + (((Rnd.nextInt(2) == 0) ? -1 : 1) * Rnd.nextInt(MobGroupTable.RANDOM_RANGE)), activeChar.getY() + (((Rnd.nextInt(2) == 0) ? -1 : 1) * Rnd.nextInt(MobGroupTable.RANDOM_RANGE)), activeChar.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
public void setFollowMode(L2Character character)
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
((L2ControllableMobAI) mobInst.getAI()).follow(character);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCastMode()
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
((L2ControllableMobAI) mobInst.getAI()).setAlternateAI(L2ControllableMobAI.AI_CAST);
|
||||
}
|
||||
}
|
||||
|
||||
public void setNoMoveMode(boolean enabled)
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
((L2ControllableMobAI) mobInst.getAI()).setNotMoving(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
protected void removeDead()
|
||||
{
|
||||
final List<L2ControllableMobInstance> deadMobs = new LinkedList<>();
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if ((mobInst != null) && mobInst.isDead())
|
||||
{
|
||||
deadMobs.add(mobInst);
|
||||
}
|
||||
}
|
||||
|
||||
getMobs().removeAll(deadMobs);
|
||||
}
|
||||
|
||||
public void setInvul(boolean invulState)
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst != null)
|
||||
{
|
||||
mobInst.setInvul(invulState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setAttackGroup(MobGroup otherGrp)
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.forceAttackGroup(otherGrp);
|
||||
ai.setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.ai.L2ControllableMobAI;
|
||||
import com.l2jmobius.gameserver.datatables.SpawnTable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
|
||||
/**
|
||||
* @author littlecrow
|
||||
*/
|
||||
public final class MobGroup
|
||||
{
|
||||
private final L2NpcTemplate _npcTemplate;
|
||||
private final int _groupId;
|
||||
private final int _maxMobCount;
|
||||
|
||||
private Set<L2ControllableMobInstance> _mobs;
|
||||
|
||||
public MobGroup(int groupId, L2NpcTemplate npcTemplate, int maxMobCount)
|
||||
{
|
||||
_groupId = groupId;
|
||||
_npcTemplate = npcTemplate;
|
||||
_maxMobCount = maxMobCount;
|
||||
}
|
||||
|
||||
public int getActiveMobCount()
|
||||
{
|
||||
return getMobs().size();
|
||||
}
|
||||
|
||||
public int getGroupId()
|
||||
{
|
||||
return _groupId;
|
||||
}
|
||||
|
||||
public int getMaxMobCount()
|
||||
{
|
||||
return _maxMobCount;
|
||||
}
|
||||
|
||||
public Set<L2ControllableMobInstance> getMobs()
|
||||
{
|
||||
if (_mobs == null)
|
||||
{
|
||||
_mobs = ConcurrentHashMap.newKeySet();
|
||||
}
|
||||
|
||||
return _mobs;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
try
|
||||
{
|
||||
final L2ControllableMobAI mobGroupAI = (L2ControllableMobAI) getMobs().stream().findFirst().get().getAI();
|
||||
|
||||
switch (mobGroupAI.getAlternateAI())
|
||||
{
|
||||
case L2ControllableMobAI.AI_NORMAL:
|
||||
return "Idle";
|
||||
case L2ControllableMobAI.AI_FORCEATTACK:
|
||||
return "Force Attacking";
|
||||
case L2ControllableMobAI.AI_FOLLOW:
|
||||
return "Following";
|
||||
case L2ControllableMobAI.AI_CAST:
|
||||
return "Casting";
|
||||
case L2ControllableMobAI.AI_ATTACK_GROUP:
|
||||
return "Attacking Group";
|
||||
default:
|
||||
return "Idle";
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return "Unspawned";
|
||||
}
|
||||
}
|
||||
|
||||
public L2NpcTemplate getTemplate()
|
||||
{
|
||||
return _npcTemplate;
|
||||
}
|
||||
|
||||
public boolean isGroupMember(L2ControllableMobInstance mobInst)
|
||||
{
|
||||
for (L2ControllableMobInstance groupMember : getMobs())
|
||||
{
|
||||
if (groupMember == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (groupMember.getObjectId() == mobInst.getObjectId())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void spawnGroup(int x, int y, int z)
|
||||
{
|
||||
if (getActiveMobCount() > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < getMaxMobCount(); i++)
|
||||
{
|
||||
final L2GroupSpawn spawn = new L2GroupSpawn(getTemplate());
|
||||
|
||||
final int signX = (Rnd.nextInt(2) == 0) ? -1 : 1;
|
||||
final int signY = (Rnd.nextInt(2) == 0) ? -1 : 1;
|
||||
final int randX = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
|
||||
final int randY = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
|
||||
|
||||
spawn.setX(x + (signX * randX));
|
||||
spawn.setY(y + (signY * randY));
|
||||
spawn.setZ(z);
|
||||
spawn.stopRespawn();
|
||||
|
||||
SpawnTable.getInstance().addNewSpawn(spawn, false);
|
||||
getMobs().add((L2ControllableMobInstance) spawn.doGroupSpawn());
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
}
|
||||
catch (NoSuchMethodException e2)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void spawnGroup(L2PcInstance activeChar)
|
||||
{
|
||||
spawnGroup(activeChar.getX(), activeChar.getY(), activeChar.getZ());
|
||||
}
|
||||
|
||||
public void teleportGroup(L2PcInstance player)
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!mobInst.isDead())
|
||||
{
|
||||
final int x = player.getX() + Rnd.nextInt(50);
|
||||
final int y = player.getY() + Rnd.nextInt(50);
|
||||
|
||||
mobInst.teleToLocation(new Location(x, y, player.getZ()), true);
|
||||
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.follow(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public L2ControllableMobInstance getRandomMob()
|
||||
{
|
||||
removeDead();
|
||||
|
||||
if (getActiveMobCount() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int choice = Rnd.nextInt(getActiveMobCount());
|
||||
for (L2ControllableMobInstance mob : getMobs())
|
||||
{
|
||||
if (--choice == 0)
|
||||
{
|
||||
return mob;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void unspawnGroup()
|
||||
{
|
||||
removeDead();
|
||||
|
||||
if (getActiveMobCount() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!mobInst.isDead())
|
||||
{
|
||||
mobInst.deleteMe();
|
||||
}
|
||||
|
||||
SpawnTable.getInstance().deleteSpawn(mobInst.getSpawn(), false);
|
||||
}
|
||||
|
||||
getMobs().clear();
|
||||
}
|
||||
|
||||
public void killGroup(L2PcInstance activeChar)
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!mobInst.isDead())
|
||||
{
|
||||
mobInst.reduceCurrentHp(mobInst.getMaxHp() + 1, activeChar, null);
|
||||
}
|
||||
|
||||
SpawnTable.getInstance().deleteSpawn(mobInst.getSpawn(), false);
|
||||
}
|
||||
|
||||
getMobs().clear();
|
||||
}
|
||||
|
||||
public void setAttackRandom()
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.setAlternateAI(L2ControllableMobAI.AI_NORMAL);
|
||||
ai.setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAttackTarget(L2Character target)
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.forceAttack(target);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIdleMode()
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void returnGroup(L2Character activeChar)
|
||||
{
|
||||
setIdleMode();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final int signX = (Rnd.nextInt(2) == 0) ? -1 : 1;
|
||||
final int signY = (Rnd.nextInt(2) == 0) ? -1 : 1;
|
||||
final int randX = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
|
||||
final int randY = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
|
||||
|
||||
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.move(activeChar.getX() + (signX * randX), activeChar.getY() + (signY * randY), activeChar.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
public void setFollowMode(L2Character character)
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.follow(character);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCastMode()
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.setAlternateAI(L2ControllableMobAI.AI_CAST);
|
||||
}
|
||||
}
|
||||
|
||||
public void setNoMoveMode(boolean enabled)
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.setNotMoving(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
protected void removeDead()
|
||||
{
|
||||
getMobs().removeIf(L2Character::isDead);
|
||||
}
|
||||
|
||||
public void setInvul(boolean invulState)
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst != null)
|
||||
{
|
||||
mobInst.setInvul(invulState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setAttackGroup(MobGroup otherGrp)
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.forceAttackGroup(otherGrp);
|
||||
ai.setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,86 +1,85 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
|
||||
|
||||
/**
|
||||
* @author littlecrow
|
||||
*/
|
||||
public class MobGroupTable
|
||||
{
|
||||
private final Map<Integer, MobGroup> _groupMap;
|
||||
|
||||
public static final int FOLLOW_RANGE = 300;
|
||||
public static final int RANDOM_RANGE = 300;
|
||||
|
||||
protected MobGroupTable()
|
||||
{
|
||||
_groupMap = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
public static MobGroupTable getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
public void addGroup(int groupKey, MobGroup group)
|
||||
{
|
||||
_groupMap.put(groupKey, group);
|
||||
}
|
||||
|
||||
public MobGroup getGroup(int groupKey)
|
||||
{
|
||||
return _groupMap.get(groupKey);
|
||||
}
|
||||
|
||||
public int getGroupCount()
|
||||
{
|
||||
return _groupMap.size();
|
||||
}
|
||||
|
||||
public MobGroup getGroupForMob(L2ControllableMobInstance mobInst)
|
||||
{
|
||||
for (MobGroup mobGroup : _groupMap.values())
|
||||
{
|
||||
if (mobGroup.isGroupMember(mobInst))
|
||||
{
|
||||
return mobGroup;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public MobGroup[] getGroups()
|
||||
{
|
||||
return _groupMap.values().toArray(new MobGroup[getGroupCount()]);
|
||||
}
|
||||
|
||||
public boolean removeGroup(int groupKey)
|
||||
{
|
||||
return _groupMap.remove(groupKey) != null;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final MobGroupTable _instance = new MobGroupTable();
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
|
||||
|
||||
/**
|
||||
* @author littlecrow
|
||||
*/
|
||||
public class MobGroupTable
|
||||
{
|
||||
private final Map<Integer, MobGroup> _groupMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static final int FOLLOW_RANGE = 300;
|
||||
public static final int RANDOM_RANGE = 300;
|
||||
|
||||
protected MobGroupTable()
|
||||
{
|
||||
}
|
||||
|
||||
public static MobGroupTable getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
public void addGroup(int groupKey, MobGroup group)
|
||||
{
|
||||
_groupMap.put(groupKey, group);
|
||||
}
|
||||
|
||||
public MobGroup getGroup(int groupKey)
|
||||
{
|
||||
return _groupMap.get(groupKey);
|
||||
}
|
||||
|
||||
public int getGroupCount()
|
||||
{
|
||||
return _groupMap.size();
|
||||
}
|
||||
|
||||
public MobGroup getGroupForMob(L2ControllableMobInstance mobInst)
|
||||
{
|
||||
for (MobGroup mobGroup : _groupMap.values())
|
||||
{
|
||||
if (mobGroup.isGroupMember(mobInst))
|
||||
{
|
||||
return mobGroup;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public MobGroup[] getGroups()
|
||||
{
|
||||
return _groupMap.values().toArray(new MobGroup[getGroupCount()]);
|
||||
}
|
||||
|
||||
public boolean removeGroup(int groupKey)
|
||||
{
|
||||
return (_groupMap.remove(groupKey) != null);
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final MobGroupTable _instance = new MobGroupTable();
|
||||
}
|
||||
}
|
||||
75
trunk/java/com/l2jmobius/gameserver/model/MpRewardTask.java
Normal file
75
trunk/java/com/l2jmobius/gameserver/model/MpRewardTask.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class MpRewardTask
|
||||
{
|
||||
private final AtomicInteger _count;
|
||||
private final double _value;
|
||||
private final ScheduledFuture<?> _task;
|
||||
private final L2Character _creature;
|
||||
|
||||
public MpRewardTask(L2Character creature, L2Npc npc)
|
||||
{
|
||||
final L2NpcTemplate template = npc.getTemplate();
|
||||
_creature = creature;
|
||||
_count = new AtomicInteger(template.getMpRewardTicks());
|
||||
_value = calculateBaseValue(npc, creature);
|
||||
_task = ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param npc
|
||||
* @param creature
|
||||
* @return
|
||||
*/
|
||||
private double calculateBaseValue(L2Npc npc, L2Character creature)
|
||||
{
|
||||
final L2NpcTemplate template = npc.getTemplate();
|
||||
switch (template.getMpRewardType())
|
||||
{
|
||||
case PER:
|
||||
{
|
||||
return (creature.getMaxMp() * (template.getMpRewardValue() / 100)) / template.getMpRewardTicks();
|
||||
}
|
||||
}
|
||||
return template.getMpRewardValue() / template.getMpRewardTicks();
|
||||
}
|
||||
|
||||
private void run()
|
||||
{
|
||||
if ((_count.decrementAndGet() <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
|
||||
{
|
||||
_task.cancel(false);
|
||||
return;
|
||||
}
|
||||
|
||||
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.OneDayRewardStatus;
|
||||
import com.l2jmobius.gameserver.handler.AbstractOneDayRewardHandler;
|
||||
import com.l2jmobius.gameserver.handler.OneDayRewardHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.base.ClassId;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class OneDayRewardDataHolder
|
||||
{
|
||||
private final int _id;
|
||||
private final int _rewardId;
|
||||
private final List<ItemHolder> _rewardsItems;
|
||||
private final List<ClassId> _classRestriction;
|
||||
private final int _requiredCompletions;
|
||||
private final StatsSet _params;
|
||||
private final boolean _isOneTime;
|
||||
private final AbstractOneDayRewardHandler _handler;
|
||||
|
||||
public OneDayRewardDataHolder(StatsSet set)
|
||||
{
|
||||
final Function<OneDayRewardDataHolder, AbstractOneDayRewardHandler> handler = OneDayRewardHandler.getInstance().getHandler(set.getString("handler"));
|
||||
|
||||
_id = set.getInt("id");
|
||||
_rewardId = set.getInt("reward_id");
|
||||
_requiredCompletions = set.getInt("requiredCompletion", 0);
|
||||
_rewardsItems = set.getList("items", ItemHolder.class);
|
||||
_classRestriction = set.getList("classRestriction", ClassId.class);
|
||||
_params = set.getObject("params", StatsSet.class);
|
||||
_isOneTime = set.getBoolean("isOneTime", true);
|
||||
_handler = handler != null ? handler.apply(this) : null;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getRewardId()
|
||||
{
|
||||
return _rewardId;
|
||||
}
|
||||
|
||||
public List<ClassId> getClassRestriction()
|
||||
{
|
||||
return _classRestriction;
|
||||
}
|
||||
|
||||
public List<ItemHolder> getRewards()
|
||||
{
|
||||
return _rewardsItems;
|
||||
}
|
||||
|
||||
public int getRequiredCompletions()
|
||||
{
|
||||
return _requiredCompletions;
|
||||
}
|
||||
|
||||
public StatsSet getParams()
|
||||
{
|
||||
return _params;
|
||||
}
|
||||
|
||||
public boolean isOneTime()
|
||||
{
|
||||
return _isOneTime;
|
||||
}
|
||||
|
||||
public boolean isDisplayable(L2PcInstance player)
|
||||
{
|
||||
return (!_isOneTime || (getStatus(player) != OneDayRewardStatus.COMPLETED.getClientId())) && (_classRestriction.isEmpty() || _classRestriction.contains(player.getClassId()));
|
||||
}
|
||||
|
||||
public void requestReward(L2PcInstance player)
|
||||
{
|
||||
if ((_handler != null) && isDisplayable(player))
|
||||
{
|
||||
_handler.requestReward(player);
|
||||
}
|
||||
}
|
||||
|
||||
public int getStatus(L2PcInstance player)
|
||||
{
|
||||
return _handler != null ? _handler.getStatus(player) : OneDayRewardStatus.NOT_AVAILABLE.getClientId();
|
||||
}
|
||||
|
||||
public int getProgress(L2PcInstance player)
|
||||
{
|
||||
return _handler != null ? _handler.getProgress(player) : OneDayRewardStatus.NOT_AVAILABLE.getClientId();
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
if (_handler != null)
|
||||
{
|
||||
_handler.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.OneDayRewardStatus;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class OneDayRewardPlayerEntry
|
||||
{
|
||||
private final int _objectId;
|
||||
private final int _rewardId;
|
||||
private OneDayRewardStatus _status = OneDayRewardStatus.NOT_AVAILABLE;
|
||||
private int _progress;
|
||||
private long _lastCompleted;
|
||||
|
||||
public OneDayRewardPlayerEntry(int objectId, int rewardId)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_rewardId = rewardId;
|
||||
}
|
||||
|
||||
public OneDayRewardPlayerEntry(int objectId, int rewardId, int status, int progress, long lastCompleted)
|
||||
{
|
||||
this(objectId, rewardId);
|
||||
_status = OneDayRewardStatus.valueOf(status);
|
||||
_progress = progress;
|
||||
_lastCompleted = lastCompleted;
|
||||
}
|
||||
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public int getRewardId()
|
||||
{
|
||||
return _rewardId;
|
||||
}
|
||||
|
||||
public OneDayRewardStatus getStatus()
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
public void setStatus(OneDayRewardStatus status)
|
||||
{
|
||||
_status = status;
|
||||
}
|
||||
|
||||
public int getProgress()
|
||||
{
|
||||
return _progress;
|
||||
}
|
||||
|
||||
public void setProgress(int progress)
|
||||
{
|
||||
_progress = progress;
|
||||
}
|
||||
|
||||
public int increaseProgress()
|
||||
{
|
||||
_progress++;
|
||||
return _progress;
|
||||
}
|
||||
|
||||
public long getLastCompleted()
|
||||
{
|
||||
return _lastCompleted;
|
||||
}
|
||||
|
||||
public void setLastCompleted(long lastCompleted)
|
||||
{
|
||||
_lastCompleted = lastCompleted;
|
||||
}
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExManagePartyRoomMember;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Gnacik
|
||||
*/
|
||||
public class PartyMatchRoom implements IIdentifiable
|
||||
{
|
||||
private final int _id;
|
||||
private String _title;
|
||||
private int _loot;
|
||||
private int _minlvl;
|
||||
private int _maxlvl;
|
||||
private int _maxmem;
|
||||
private final List<L2PcInstance> _members = new ArrayList<>();
|
||||
|
||||
public PartyMatchRoom(int id, String title, int loot, int minlvl, int maxlvl, int maxmem, L2PcInstance owner)
|
||||
{
|
||||
_id = id;
|
||||
_title = title;
|
||||
_loot = loot;
|
||||
_minlvl = minlvl;
|
||||
_maxlvl = maxlvl;
|
||||
_maxmem = maxmem;
|
||||
_members.add(owner);
|
||||
}
|
||||
|
||||
public List<L2PcInstance> getPartyMembers()
|
||||
{
|
||||
return _members;
|
||||
}
|
||||
|
||||
public void addMember(L2PcInstance player)
|
||||
{
|
||||
_members.add(player);
|
||||
}
|
||||
|
||||
public void deleteMember(L2PcInstance player)
|
||||
{
|
||||
if (player != getOwner())
|
||||
{
|
||||
_members.remove(player);
|
||||
notifyMembersAboutExit(player);
|
||||
}
|
||||
else if (_members.size() == 1)
|
||||
{
|
||||
PartyMatchRoomList.getInstance().deleteRoom(_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
changeLeader(_members.get(1));
|
||||
deleteMember(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyMembersAboutExit(L2PcInstance player)
|
||||
{
|
||||
for (L2PcInstance _member : _members)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_LEFT_THE_PARTY_ROOM);
|
||||
sm.addCharName(player);
|
||||
_member.sendPacket(sm);
|
||||
_member.sendPacket(new ExManagePartyRoomMember(player, this, 2));
|
||||
}
|
||||
}
|
||||
|
||||
public void changeLeader(L2PcInstance newLeader)
|
||||
{
|
||||
// Get current leader
|
||||
final L2PcInstance oldLeader = _members.get(0);
|
||||
// Remove new leader
|
||||
_members.remove(newLeader);
|
||||
// Move him to first position
|
||||
_members.set(0, newLeader);
|
||||
// Add old leader as normal member
|
||||
_members.add(oldLeader);
|
||||
// Broadcast change
|
||||
for (L2PcInstance member : _members)
|
||||
{
|
||||
member.sendPacket(new ExManagePartyRoomMember(newLeader, this, 1));
|
||||
member.sendPacket(new ExManagePartyRoomMember(oldLeader, this, 1));
|
||||
member.sendPacket(SystemMessageId.THE_LEADER_OF_THE_PARTY_ROOM_HAS_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getLootType()
|
||||
{
|
||||
return _loot;
|
||||
}
|
||||
|
||||
public int getMinLvl()
|
||||
{
|
||||
return _minlvl;
|
||||
}
|
||||
|
||||
public int getMaxLvl()
|
||||
{
|
||||
return _maxlvl;
|
||||
}
|
||||
|
||||
/**
|
||||
* <ul>
|
||||
* <li>1 : Talking Island</li>
|
||||
* <li>2 : Gludio</li>
|
||||
* <li>3 : Dark Elven Ter.</li>
|
||||
* <li>4 : Elven Territory</li>
|
||||
* <li>5 : Dion</li>
|
||||
* <li>6 : Giran</li>
|
||||
* <li>7 : Neutral Zone</li>
|
||||
* <li>8 : Lyonn</li>
|
||||
* <li>9 : Schuttgart</li>
|
||||
* <li>10 : Oren</li>
|
||||
* <li>11 : Hunters Village</li>
|
||||
* <li>12 : Innadril</li>
|
||||
* <li>13 : Aden</li>
|
||||
* <li>14 : Rune</li>
|
||||
* <li>15 : Goddard</li>
|
||||
* </ul>
|
||||
* @return the id
|
||||
*/
|
||||
public int getLocation()
|
||||
{
|
||||
return MapRegionManager.getInstance().getMapRegion(_members.get(0)).getBbs();
|
||||
}
|
||||
|
||||
public int getMembers()
|
||||
{
|
||||
return _members.size();
|
||||
}
|
||||
|
||||
public int getMaxMembers()
|
||||
{
|
||||
return _maxmem;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return _title;
|
||||
}
|
||||
|
||||
public L2PcInstance getOwner()
|
||||
{
|
||||
return _members.get(0);
|
||||
}
|
||||
|
||||
/* SET */
|
||||
|
||||
public void setMinLvl(int minlvl)
|
||||
{
|
||||
_minlvl = minlvl;
|
||||
}
|
||||
|
||||
public void setMaxLvl(int maxlvl)
|
||||
{
|
||||
_maxlvl = maxlvl;
|
||||
}
|
||||
|
||||
public void setLootType(int loot)
|
||||
{
|
||||
_loot = loot;
|
||||
}
|
||||
|
||||
public void setMaxMembers(int maxmem)
|
||||
{
|
||||
_maxmem = maxmem;
|
||||
}
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
_title = title;
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExClosePartyRoom;
|
||||
|
||||
/**
|
||||
* @author Gnacik
|
||||
*/
|
||||
public class PartyMatchRoomList
|
||||
{
|
||||
private int _maxid = 1;
|
||||
private final Map<Integer, PartyMatchRoom> _rooms;
|
||||
|
||||
protected PartyMatchRoomList()
|
||||
{
|
||||
_rooms = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
public synchronized void addPartyMatchRoom(int id, PartyMatchRoom room)
|
||||
{
|
||||
_rooms.put(id, room);
|
||||
_maxid++;
|
||||
}
|
||||
|
||||
public void deleteRoom(int id)
|
||||
{
|
||||
for (L2PcInstance _member : getRoom(id).getPartyMembers())
|
||||
{
|
||||
if (_member == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_member.sendPacket(new ExClosePartyRoom());
|
||||
_member.sendPacket(SystemMessageId.THE_PARTY_ROOM_HAS_BEEN_DISBANDED);
|
||||
|
||||
_member.setPartyRoom(0);
|
||||
// _member.setPartyMatching(0);
|
||||
_member.broadcastUserInfo();
|
||||
}
|
||||
_rooms.remove(id);
|
||||
}
|
||||
|
||||
public PartyMatchRoom getRoom(int id)
|
||||
{
|
||||
return _rooms.get(id);
|
||||
}
|
||||
|
||||
public PartyMatchRoom[] getRooms()
|
||||
{
|
||||
return _rooms.values().toArray(new PartyMatchRoom[_rooms.size()]);
|
||||
}
|
||||
|
||||
public int getPartyMatchRoomCount()
|
||||
{
|
||||
return _rooms.size();
|
||||
}
|
||||
|
||||
public int getMaxId()
|
||||
{
|
||||
return _maxid;
|
||||
}
|
||||
|
||||
public PartyMatchRoom getPlayerRoom(L2PcInstance player)
|
||||
{
|
||||
for (PartyMatchRoom _room : _rooms.values())
|
||||
{
|
||||
for (L2PcInstance member : _room.getPartyMembers())
|
||||
{
|
||||
if (member.equals(player))
|
||||
{
|
||||
return _room;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getPlayerRoomId(L2PcInstance player)
|
||||
{
|
||||
for (PartyMatchRoom _room : _rooms.values())
|
||||
{
|
||||
for (L2PcInstance member : _room.getPartyMembers())
|
||||
{
|
||||
if (member.equals(player))
|
||||
{
|
||||
return _room.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static PartyMatchRoomList getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PartyMatchRoomList _instance = new PartyMatchRoomList();
|
||||
}
|
||||
}
|
||||
@@ -1,82 +1,81 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public enum PcCondOverride
|
||||
{
|
||||
MAX_STATS_VALUE(0, "Overrides maximum states conditions"),
|
||||
ITEM_CONDITIONS(1, "Overrides item usage conditions"),
|
||||
SKILL_CONDITIONS(2, "Overrides skill usage conditions"),
|
||||
ZONE_CONDITIONS(3, "Overrides zone conditions"),
|
||||
CASTLE_CONDITIONS(4, "Overrides castle conditions"),
|
||||
FORTRESS_CONDITIONS(5, "Overrides fortress conditions"),
|
||||
CLANHALL_CONDITIONS(6, "Overrides clan hall conditions"),
|
||||
FLOOD_CONDITIONS(7, "Overrides floods conditions"),
|
||||
CHAT_CONDITIONS(8, "Overrides chat conditions"),
|
||||
INSTANCE_CONDITIONS(9, "Overrides instance conditions"),
|
||||
QUEST_CONDITIONS(10, "Overrides quest conditions"),
|
||||
DEATH_PENALTY(11, "Overrides death penalty conditions"),
|
||||
DESTROY_ALL_ITEMS(12, "Overrides item destroy conditions"),
|
||||
SEE_ALL_PLAYERS(13, "Overrides the conditions to see hidden players"),
|
||||
TARGET_ALL(14, "Overrides target conditions"),
|
||||
DROP_ALL_ITEMS(15, "Overrides item drop conditions"),
|
||||
VULNERABLE_ALL_PLAYERS(16, "Overrides the conditions to invulnerable players");
|
||||
|
||||
private final int _mask;
|
||||
private final String _descr;
|
||||
|
||||
private PcCondOverride(int id, String descr)
|
||||
{
|
||||
_mask = 1 << id;
|
||||
_descr = descr;
|
||||
}
|
||||
|
||||
public int getMask()
|
||||
{
|
||||
return _mask;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return _descr;
|
||||
}
|
||||
|
||||
public static PcCondOverride getCondOverride(int ordinal)
|
||||
{
|
||||
try
|
||||
{
|
||||
return values()[ordinal];
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static long getAllExceptionsMask()
|
||||
{
|
||||
long result = 0L;
|
||||
for (PcCondOverride ex : values())
|
||||
{
|
||||
result |= ex.getMask();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public enum PcCondOverride
|
||||
{
|
||||
MAX_STATS_VALUE(0, "Overrides maximum states conditions"),
|
||||
ITEM_CONDITIONS(1, "Overrides item usage conditions"),
|
||||
SKILL_CONDITIONS(2, "Overrides skill usage conditions"),
|
||||
ZONE_CONDITIONS(3, "Overrides zone conditions"),
|
||||
CASTLE_CONDITIONS(4, "Overrides castle conditions"),
|
||||
FORTRESS_CONDITIONS(5, "Overrides fortress conditions"),
|
||||
CLANHALL_CONDITIONS(6, "Overrides clan hall conditions"),
|
||||
FLOOD_CONDITIONS(7, "Overrides floods conditions"),
|
||||
CHAT_CONDITIONS(8, "Overrides chat conditions"),
|
||||
INSTANCE_CONDITIONS(9, "Overrides instance conditions"),
|
||||
QUEST_CONDITIONS(10, "Overrides quest conditions"),
|
||||
DEATH_PENALTY(11, "Overrides death penalty conditions"),
|
||||
DESTROY_ALL_ITEMS(12, "Overrides item destroy conditions"),
|
||||
SEE_ALL_PLAYERS(13, "Overrides the conditions to see hidden players"),
|
||||
TARGET_ALL(14, "Overrides target conditions"),
|
||||
DROP_ALL_ITEMS(15, "Overrides item drop conditions");
|
||||
|
||||
private final int _mask;
|
||||
private final String _descr;
|
||||
|
||||
PcCondOverride(int id, String descr)
|
||||
{
|
||||
_mask = 1 << id;
|
||||
_descr = descr;
|
||||
}
|
||||
|
||||
public int getMask()
|
||||
{
|
||||
return _mask;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return _descr;
|
||||
}
|
||||
|
||||
public static PcCondOverride getCondOverride(int ordinal)
|
||||
{
|
||||
try
|
||||
{
|
||||
return values()[ordinal];
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static long getAllExceptionsMask()
|
||||
{
|
||||
long result = 0L;
|
||||
for (PcCondOverride ex : values())
|
||||
{
|
||||
result |= ex.getMask();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,178 +1,178 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.PetitionState;
|
||||
import com.l2jmobius.gameserver.enums.PetitionType;
|
||||
import com.l2jmobius.gameserver.idfactory.IdFactory;
|
||||
import com.l2jmobius.gameserver.instancemanager.PetitionManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PetitionVotePacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Petition
|
||||
* @author xban1x
|
||||
*/
|
||||
public final class Petition
|
||||
{
|
||||
private final long _submitTime = System.currentTimeMillis();
|
||||
private final int _id;
|
||||
private final PetitionType _type;
|
||||
private PetitionState _state = PetitionState.PENDING;
|
||||
private final String _content;
|
||||
private final List<CreatureSay> _messageLog = new CopyOnWriteArrayList<>();
|
||||
private final L2PcInstance _petitioner;
|
||||
private L2PcInstance _responder;
|
||||
|
||||
public Petition(L2PcInstance petitioner, String petitionText, int petitionType)
|
||||
{
|
||||
_id = IdFactory.getInstance().getNextId();
|
||||
_type = PetitionType.values()[--petitionType];
|
||||
_content = petitionText;
|
||||
_petitioner = petitioner;
|
||||
}
|
||||
|
||||
public boolean addLogMessage(CreatureSay cs)
|
||||
{
|
||||
return _messageLog.add(cs);
|
||||
}
|
||||
|
||||
public List<CreatureSay> getLogMessages()
|
||||
{
|
||||
return _messageLog;
|
||||
}
|
||||
|
||||
public boolean endPetitionConsultation(PetitionState endState)
|
||||
{
|
||||
setState(endState);
|
||||
|
||||
if ((getResponder() != null) && getResponder().isOnline())
|
||||
{
|
||||
if (endState == PetitionState.RESPONDER_REJECT)
|
||||
{
|
||||
getPetitioner().sendMessage("Your petition was rejected. Please try again later.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ending petition consultation with <Player>.
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.PETITION_CONSULTATION_WITH_C1_HAS_ENDED);
|
||||
sm.addString(getPetitioner().getName());
|
||||
getResponder().sendPacket(sm);
|
||||
|
||||
if (endState == PetitionState.PETITIONER_CANCEL)
|
||||
{
|
||||
// Receipt No. <ID> petition cancelled.
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.RECEIPT_NO_S1_PETITION_CANCELLED);
|
||||
sm.addInt(getId());
|
||||
getResponder().sendPacket(sm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// End petition consultation and inform them, if they are still online. And if petitioner is online, enable Evaluation button
|
||||
if ((getPetitioner() != null) && getPetitioner().isOnline())
|
||||
{
|
||||
getPetitioner().sendPacket(SystemMessageId.THIS_ENDS_THE_GM_PETITION_CONSULTATION_NPLEASE_GIVE_US_FEEDBACK_ON_THE_PETITION_SERVICE);
|
||||
getPetitioner().sendPacket(PetitionVotePacket.STATIC_PACKET);
|
||||
}
|
||||
|
||||
PetitionManager.getInstance().getCompletedPetitions().put(getId(), this);
|
||||
return PetitionManager.getInstance().getPendingPetitions().remove(getId()) != null;
|
||||
}
|
||||
|
||||
public String getContent()
|
||||
{
|
||||
return _content;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public L2PcInstance getPetitioner()
|
||||
{
|
||||
return _petitioner;
|
||||
}
|
||||
|
||||
public L2PcInstance getResponder()
|
||||
{
|
||||
return _responder;
|
||||
}
|
||||
|
||||
public long getSubmitTime()
|
||||
{
|
||||
return _submitTime;
|
||||
}
|
||||
|
||||
public PetitionState getState()
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
|
||||
public String getTypeAsString()
|
||||
{
|
||||
return _type.toString().replace("_", " ");
|
||||
}
|
||||
|
||||
public void sendPetitionerPacket(L2GameServerPacket responsePacket)
|
||||
{
|
||||
if ((getPetitioner() == null) || !getPetitioner().isOnline())
|
||||
{
|
||||
// Allows petitioners to see the results of their petition when
|
||||
// they log back into the game.
|
||||
|
||||
// endPetitionConsultation(PetitionState.Petitioner_Missing);
|
||||
return;
|
||||
}
|
||||
|
||||
getPetitioner().sendPacket(responsePacket);
|
||||
}
|
||||
|
||||
public void sendResponderPacket(L2GameServerPacket responsePacket)
|
||||
{
|
||||
if ((getResponder() == null) || !getResponder().isOnline())
|
||||
{
|
||||
endPetitionConsultation(PetitionState.RESPONDER_MISSING);
|
||||
return;
|
||||
}
|
||||
|
||||
getResponder().sendPacket(responsePacket);
|
||||
}
|
||||
|
||||
public void setState(PetitionState state)
|
||||
{
|
||||
_state = state;
|
||||
}
|
||||
|
||||
public void setResponder(L2PcInstance respondingAdmin)
|
||||
{
|
||||
if (getResponder() != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_responder = respondingAdmin;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.PetitionState;
|
||||
import com.l2jmobius.gameserver.enums.PetitionType;
|
||||
import com.l2jmobius.gameserver.idfactory.IdFactory;
|
||||
import com.l2jmobius.gameserver.instancemanager.PetitionManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PetitionVotePacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Petition
|
||||
* @author xban1x
|
||||
*/
|
||||
public final class Petition
|
||||
{
|
||||
private final long _submitTime = System.currentTimeMillis();
|
||||
private final int _id;
|
||||
private final PetitionType _type;
|
||||
private PetitionState _state = PetitionState.PENDING;
|
||||
private final String _content;
|
||||
private final List<CreatureSay> _messageLog = new CopyOnWriteArrayList<>();
|
||||
private final L2PcInstance _petitioner;
|
||||
private L2PcInstance _responder;
|
||||
|
||||
public Petition(L2PcInstance petitioner, String petitionText, int petitionType)
|
||||
{
|
||||
_id = IdFactory.getInstance().getNextId();
|
||||
_type = PetitionType.values()[--petitionType];
|
||||
_content = petitionText;
|
||||
_petitioner = petitioner;
|
||||
}
|
||||
|
||||
public boolean addLogMessage(CreatureSay cs)
|
||||
{
|
||||
return _messageLog.add(cs);
|
||||
}
|
||||
|
||||
public List<CreatureSay> getLogMessages()
|
||||
{
|
||||
return _messageLog;
|
||||
}
|
||||
|
||||
public boolean endPetitionConsultation(PetitionState endState)
|
||||
{
|
||||
setState(endState);
|
||||
|
||||
if ((getResponder() != null) && getResponder().isOnline())
|
||||
{
|
||||
if (endState == PetitionState.RESPONDER_REJECT)
|
||||
{
|
||||
getPetitioner().sendMessage("Your petition was rejected. Please try again later.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ending petition consultation with <Player>.
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.PETITION_CONSULTATION_WITH_C1_HAS_ENDED);
|
||||
sm.addString(getPetitioner().getName());
|
||||
getResponder().sendPacket(sm);
|
||||
|
||||
if (endState == PetitionState.PETITIONER_CANCEL)
|
||||
{
|
||||
// Receipt No. <ID> petition cancelled.
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.RECEIPT_NO_S1_PETITION_CANCELLED);
|
||||
sm.addInt(getId());
|
||||
getResponder().sendPacket(sm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// End petition consultation and inform them, if they are still online. And if petitioner is online, enable Evaluation button
|
||||
if ((getPetitioner() != null) && getPetitioner().isOnline())
|
||||
{
|
||||
getPetitioner().sendPacket(SystemMessageId.THIS_ENDS_THE_GM_PETITION_CONSULTATION_NPLEASE_GIVE_US_FEEDBACK_ON_THE_PETITION_SERVICE);
|
||||
getPetitioner().sendPacket(PetitionVotePacket.STATIC_PACKET);
|
||||
}
|
||||
|
||||
PetitionManager.getInstance().getCompletedPetitions().put(getId(), this);
|
||||
return (PetitionManager.getInstance().getPendingPetitions().remove(getId()) != null);
|
||||
}
|
||||
|
||||
public String getContent()
|
||||
{
|
||||
return _content;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public L2PcInstance getPetitioner()
|
||||
{
|
||||
return _petitioner;
|
||||
}
|
||||
|
||||
public L2PcInstance getResponder()
|
||||
{
|
||||
return _responder;
|
||||
}
|
||||
|
||||
public long getSubmitTime()
|
||||
{
|
||||
return _submitTime;
|
||||
}
|
||||
|
||||
public PetitionState getState()
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
|
||||
public String getTypeAsString()
|
||||
{
|
||||
return _type.toString().replace("_", " ");
|
||||
}
|
||||
|
||||
public void sendPetitionerPacket(IClientOutgoingPacket responsePacket)
|
||||
{
|
||||
if ((getPetitioner() == null) || !getPetitioner().isOnline())
|
||||
{
|
||||
// Allows petitioners to see the results of their petition when
|
||||
// they log back into the game.
|
||||
|
||||
// endPetitionConsultation(PetitionState.Petitioner_Missing);
|
||||
return;
|
||||
}
|
||||
|
||||
getPetitioner().sendPacket(responsePacket);
|
||||
}
|
||||
|
||||
public void sendResponderPacket(IClientOutgoingPacket responsePacket)
|
||||
{
|
||||
if ((getResponder() == null) || !getResponder().isOnline())
|
||||
{
|
||||
endPetitionConsultation(PetitionState.RESPONDER_MISSING);
|
||||
return;
|
||||
}
|
||||
|
||||
getResponder().sendPacket(responsePacket);
|
||||
}
|
||||
|
||||
public void setState(PetitionState state)
|
||||
{
|
||||
_state = state;
|
||||
}
|
||||
|
||||
public void setResponder(L2PcInstance respondingAdmin)
|
||||
{
|
||||
if (getResponder() != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_responder = respondingAdmin;
|
||||
}
|
||||
}
|
||||
|
||||
100
trunk/java/com/l2jmobius/gameserver/model/SayuneEntry.java
Normal file
100
trunk/java/com/l2jmobius/gameserver/model/SayuneEntry.java
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.interfaces.ILocational;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class SayuneEntry implements ILocational
|
||||
{
|
||||
private boolean _isSelector = false;
|
||||
private final int _id;
|
||||
private int _x;
|
||||
private int _y;
|
||||
private int _z;
|
||||
private final List<SayuneEntry> _innerEntries = new LinkedList<>();
|
||||
|
||||
public SayuneEntry(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public SayuneEntry(boolean isSelector, int id, int x, int y, int z)
|
||||
{
|
||||
_isSelector = isSelector;
|
||||
_id = id;
|
||||
_x = x;
|
||||
_y = y;
|
||||
_z = z;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX()
|
||||
{
|
||||
return _x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY()
|
||||
{
|
||||
return _y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ()
|
||||
{
|
||||
return _z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeading()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILocational getLocation()
|
||||
{
|
||||
return new Location(_x, _y, _z);
|
||||
}
|
||||
|
||||
public boolean isSelector()
|
||||
{
|
||||
return _isSelector;
|
||||
}
|
||||
|
||||
public List<SayuneEntry> getInnerEntries()
|
||||
{
|
||||
return _innerEntries;
|
||||
}
|
||||
|
||||
public SayuneEntry addInnerEntry(SayuneEntry innerEntry)
|
||||
{
|
||||
_innerEntries.add(innerEntry);
|
||||
return innerEntry;
|
||||
}
|
||||
}
|
||||
@@ -1,79 +1,79 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
* @author xban1x
|
||||
*/
|
||||
public class SeedProduction
|
||||
{
|
||||
private final int _seedId;
|
||||
private final long _price;
|
||||
private final long _startAmount;
|
||||
private final AtomicLong _amount;
|
||||
|
||||
public SeedProduction(int id, long amount, long price, long startAmount)
|
||||
{
|
||||
_seedId = id;
|
||||
_amount = new AtomicLong(amount);
|
||||
_price = price;
|
||||
_startAmount = startAmount;
|
||||
}
|
||||
|
||||
public final int getId()
|
||||
{
|
||||
return _seedId;
|
||||
}
|
||||
|
||||
public final long getAmount()
|
||||
{
|
||||
return _amount.get();
|
||||
}
|
||||
|
||||
public final long getPrice()
|
||||
{
|
||||
return _price;
|
||||
}
|
||||
|
||||
public final long getStartAmount()
|
||||
{
|
||||
return _startAmount;
|
||||
}
|
||||
|
||||
public final void setAmount(long amount)
|
||||
{
|
||||
_amount.set(amount);
|
||||
}
|
||||
|
||||
public final boolean decreaseAmount(long val)
|
||||
{
|
||||
long current, next;
|
||||
do
|
||||
{
|
||||
current = _amount.get();
|
||||
next = current - val;
|
||||
if (next < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
while (!_amount.compareAndSet(current, next));
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
* @author xban1x
|
||||
*/
|
||||
public class SeedProduction
|
||||
{
|
||||
private final int _seedId;
|
||||
private final long _price;
|
||||
private final long _startAmount;
|
||||
private final AtomicLong _amount;
|
||||
|
||||
public SeedProduction(int id, long amount, long price, long startAmount)
|
||||
{
|
||||
_seedId = id;
|
||||
_amount = new AtomicLong(amount);
|
||||
_price = price;
|
||||
_startAmount = startAmount;
|
||||
}
|
||||
|
||||
public final int getId()
|
||||
{
|
||||
return _seedId;
|
||||
}
|
||||
|
||||
public final long getAmount()
|
||||
{
|
||||
return _amount.get();
|
||||
}
|
||||
|
||||
public final long getPrice()
|
||||
{
|
||||
return _price;
|
||||
}
|
||||
|
||||
public final long getStartAmount()
|
||||
{
|
||||
return _startAmount;
|
||||
}
|
||||
|
||||
public final void setAmount(long amount)
|
||||
{
|
||||
_amount.set(amount);
|
||||
}
|
||||
|
||||
public final boolean decreaseAmount(long val)
|
||||
{
|
||||
long current, next;
|
||||
do
|
||||
{
|
||||
current = _amount.get();
|
||||
next = current - val;
|
||||
if (next < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
while (!_amount.compareAndSet(current, next));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,303 +1,243 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.enums.ShortcutType;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.interfaces.IRestorable;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.items.type.EtcItemType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAutoSoulShot;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ShortCutInit;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
||||
|
||||
public class ShortCuts implements IRestorable
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(ShortCuts.class.getName());
|
||||
private static final int MAX_SHORTCUTS_PER_BAR = 12;
|
||||
private final L2PcInstance _owner;
|
||||
private final Map<Integer, Shortcut> _shortCuts = new TreeMap<>();
|
||||
|
||||
public ShortCuts(L2PcInstance owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
public Shortcut[] getAllShortCuts()
|
||||
{
|
||||
return _shortCuts.values().toArray(new Shortcut[_shortCuts.values().size()]);
|
||||
}
|
||||
|
||||
public Shortcut getShortCut(int slot, int page)
|
||||
{
|
||||
Shortcut sc = _shortCuts.get(slot + (page * MAX_SHORTCUTS_PER_BAR));
|
||||
// Verify shortcut
|
||||
if ((sc != null) && (sc.getType() == ShortcutType.ITEM) && (_owner.getInventory().getItemByObjectId(sc.getId()) == null))
|
||||
{
|
||||
deleteShortCut(sc.getSlot(), sc.getPage());
|
||||
sc = null;
|
||||
}
|
||||
return sc;
|
||||
}
|
||||
|
||||
public synchronized void registerShortCut(Shortcut shortcut)
|
||||
{
|
||||
// Verify shortcut
|
||||
if (shortcut.getType() == ShortcutType.ITEM)
|
||||
{
|
||||
final L2ItemInstance item = _owner.getInventory().getItemByObjectId(shortcut.getId());
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
shortcut.setSharedReuseGroup(item.getSharedReuseGroup());
|
||||
}
|
||||
registerShortCutInDb(shortcut, _shortCuts.put(shortcut.getSlot() + (shortcut.getPage() * MAX_SHORTCUTS_PER_BAR), shortcut));
|
||||
}
|
||||
|
||||
private void registerShortCutInDb(Shortcut shortcut, Shortcut oldShortCut)
|
||||
{
|
||||
if (oldShortCut != null)
|
||||
{
|
||||
deleteShortCutFromDb(oldShortCut);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("REPLACE INTO character_shortcuts (charId,slot,page,type,shortcut_id,level,class_index) values(?,?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, _owner.getObjectId());
|
||||
ps.setInt(2, shortcut.getSlot());
|
||||
ps.setInt(3, shortcut.getPage());
|
||||
ps.setInt(4, shortcut.getType().ordinal());
|
||||
ps.setInt(5, shortcut.getId());
|
||||
ps.setInt(6, shortcut.getLevel());
|
||||
ps.setInt(7, _owner.getClassIndex());
|
||||
ps.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Could not store character shortcut: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @param page
|
||||
*/
|
||||
public synchronized void deleteShortCut(int slot, int page)
|
||||
{
|
||||
final Shortcut old = _shortCuts.remove(slot + (page * MAX_SHORTCUTS_PER_BAR));
|
||||
if ((old == null) || (_owner == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
deleteShortCutFromDb(old);
|
||||
if (old.getType() == ShortcutType.ITEM)
|
||||
{
|
||||
final L2ItemInstance item = _owner.getInventory().getItemByObjectId(old.getId());
|
||||
|
||||
if ((item != null) && (item.getItemType() == EtcItemType.SHOT) && _owner.removeAutoSoulShot(item.getId()))
|
||||
{
|
||||
switch (item.getEtcItem().getDefaultAction())
|
||||
{
|
||||
case SOULSHOT:
|
||||
case FISHINGSHOT:
|
||||
{
|
||||
_owner.sendPacket(new ExAutoSoulShot(item.getId(), 0, 0));
|
||||
break;
|
||||
}
|
||||
case SPIRITSHOT:
|
||||
{
|
||||
_owner.sendPacket(new ExAutoSoulShot(item.getId(), 0, 1));
|
||||
break;
|
||||
}
|
||||
case SUMMON_SOULSHOT:
|
||||
{
|
||||
_owner.sendPacket(new ExAutoSoulShot(item.getId(), 0, 2));
|
||||
break;
|
||||
}
|
||||
case SUMMON_SPIRITSHOT:
|
||||
{
|
||||
_owner.sendPacket(new ExAutoSoulShot(item.getId(), 0, 3));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_owner.sendPacket(new ShortCutInit(_owner));
|
||||
|
||||
for (int shotId : _owner.getAutoSoulShot())
|
||||
{
|
||||
final L2ItemInstance item = _owner.getInventory().getItemByObjectId(shotId);
|
||||
if ((item == null) || (item.getEtcItem() == null) || (item.getEtcItem().getDefaultAction() == null))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (item.getEtcItem().getDefaultAction())
|
||||
{
|
||||
case SOULSHOT:
|
||||
case FISHINGSHOT:
|
||||
{
|
||||
_owner.sendPacket(new ExAutoSoulShot(shotId, 1, 0));
|
||||
break;
|
||||
}
|
||||
case SPIRITSHOT:
|
||||
{
|
||||
_owner.sendPacket(new ExAutoSoulShot(shotId, 1, 1));
|
||||
break;
|
||||
}
|
||||
case SUMMON_SOULSHOT:
|
||||
{
|
||||
_owner.sendPacket(new ExAutoSoulShot(shotId, 1, 2));
|
||||
break;
|
||||
}
|
||||
case SUMMON_SPIRITSHOT:
|
||||
{
|
||||
_owner.sendPacket(new ExAutoSoulShot(shotId, 1, 3));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void deleteShortCutByObjectId(int objectId)
|
||||
{
|
||||
for (Shortcut shortcut : _shortCuts.values())
|
||||
{
|
||||
if ((shortcut.getType() == ShortcutType.ITEM) && (shortcut.getId() == objectId))
|
||||
{
|
||||
deleteShortCut(shortcut.getSlot(), shortcut.getPage());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param shortcut
|
||||
*/
|
||||
private void deleteShortCutFromDb(Shortcut shortcut)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=? AND slot=? AND page=? AND class_index=?"))
|
||||
{
|
||||
ps.setInt(1, _owner.getObjectId());
|
||||
ps.setInt(2, shortcut.getSlot());
|
||||
ps.setInt(3, shortcut.getPage());
|
||||
ps.setInt(4, _owner.getClassIndex());
|
||||
ps.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Could not delete character shortcut: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restoreMe()
|
||||
{
|
||||
_shortCuts.clear();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT charId, slot, page, type, shortcut_id, level FROM character_shortcuts WHERE charId=? AND class_index=?"))
|
||||
{
|
||||
statement.setInt(1, _owner.getObjectId());
|
||||
statement.setInt(2, _owner.getClassIndex());
|
||||
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
while (rset.next())
|
||||
{
|
||||
final int slot = rset.getInt("slot");
|
||||
final int page = rset.getInt("page");
|
||||
_shortCuts.put(slot + (page * MAX_SHORTCUTS_PER_BAR), new Shortcut(slot, page, ShortcutType.values()[rset.getInt("type")], rset.getInt("shortcut_id"), rset.getInt("level"), 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Could not restore character shortcuts: " + e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify shortcuts
|
||||
for (Shortcut sc : getAllShortCuts())
|
||||
{
|
||||
if (sc.getType() == ShortcutType.ITEM)
|
||||
{
|
||||
final L2ItemInstance item = _owner.getInventory().getItemByObjectId(sc.getId());
|
||||
if (item == null)
|
||||
{
|
||||
deleteShortCut(sc.getSlot(), sc.getPage());
|
||||
}
|
||||
else if (item.isEtcItem())
|
||||
{
|
||||
sc.setSharedReuseGroup(item.getEtcItem().getSharedReuseGroup());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the shortcut bars with the new skill.
|
||||
* @param skillId the skill Id to search and update.
|
||||
* @param skillLevel the skill level to update.
|
||||
*/
|
||||
public synchronized void updateShortCuts(int skillId, int skillLevel)
|
||||
{
|
||||
// Update all the shortcuts for this skill
|
||||
for (Shortcut sc : _shortCuts.values())
|
||||
{
|
||||
if ((sc.getId() == skillId) && (sc.getType() == ShortcutType.SKILL))
|
||||
{
|
||||
final Shortcut newsc = new Shortcut(sc.getSlot(), sc.getPage(), sc.getType(), sc.getId(), skillLevel, 1);
|
||||
_owner.sendPacket(new ShortCutRegister(newsc));
|
||||
_owner.registerShortCut(newsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the shortcut icon with the new skill.
|
||||
* @param skillId the skill Id to search.
|
||||
* @param newSkillId the skill Id to replace.
|
||||
*/
|
||||
public void replaceShortCuts(int skillId, int newSkillId)
|
||||
{
|
||||
// Replace all the shortcuts with the new skill
|
||||
for (Shortcut sc : _shortCuts.values())
|
||||
{
|
||||
if ((sc.getId() == skillId) && (sc.getType() == ShortcutType.SKILL))
|
||||
{
|
||||
final Shortcut newsc = new Shortcut(sc.getSlot(), sc.getPage(), sc.getType(), newSkillId, sc.getLevel(), 1);
|
||||
_owner.sendPacket(new ShortCutRegister(newsc));
|
||||
_owner.registerShortCut(newsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.enums.ShortcutType;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.interfaces.IRestorable;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.items.type.EtcItemType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAutoSoulShot;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ShortCutInit;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
||||
|
||||
public class ShortCuts implements IRestorable
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(ShortCuts.class.getName());
|
||||
private static final int MAX_SHORTCUTS_PER_BAR = 12;
|
||||
private final L2PcInstance _owner;
|
||||
private final Map<Integer, Shortcut> _shortCuts = new TreeMap<>();
|
||||
|
||||
public ShortCuts(L2PcInstance owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
public Shortcut[] getAllShortCuts()
|
||||
{
|
||||
return _shortCuts.values().toArray(new Shortcut[_shortCuts.values().size()]);
|
||||
}
|
||||
|
||||
public Shortcut getShortCut(int slot, int page)
|
||||
{
|
||||
Shortcut sc = _shortCuts.get(slot + (page * MAX_SHORTCUTS_PER_BAR));
|
||||
// Verify shortcut
|
||||
if ((sc != null) && (sc.getType() == ShortcutType.ITEM))
|
||||
{
|
||||
if (_owner.getInventory().getItemByObjectId(sc.getId()) == null)
|
||||
{
|
||||
deleteShortCut(sc.getSlot(), sc.getPage());
|
||||
sc = null;
|
||||
}
|
||||
}
|
||||
return sc;
|
||||
}
|
||||
|
||||
public synchronized void registerShortCut(Shortcut shortcut)
|
||||
{
|
||||
// Verify shortcut
|
||||
if (shortcut.getType() == ShortcutType.ITEM)
|
||||
{
|
||||
final L2ItemInstance item = _owner.getInventory().getItemByObjectId(shortcut.getId());
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
shortcut.setSharedReuseGroup(item.getSharedReuseGroup());
|
||||
}
|
||||
final Shortcut oldShortCut = _shortCuts.put(shortcut.getSlot() + (shortcut.getPage() * MAX_SHORTCUTS_PER_BAR), shortcut);
|
||||
registerShortCutInDb(shortcut, oldShortCut);
|
||||
}
|
||||
|
||||
private void registerShortCutInDb(Shortcut shortcut, Shortcut oldShortCut)
|
||||
{
|
||||
if (oldShortCut != null)
|
||||
{
|
||||
deleteShortCutFromDb(oldShortCut);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("REPLACE INTO character_shortcuts (charId,slot,page,type,shortcut_id,level,class_index) values(?,?,?,?,?,?,?)"))
|
||||
{
|
||||
statement.setInt(1, _owner.getObjectId());
|
||||
statement.setInt(2, shortcut.getSlot());
|
||||
statement.setInt(3, shortcut.getPage());
|
||||
statement.setInt(4, shortcut.getType().ordinal());
|
||||
statement.setInt(5, shortcut.getId());
|
||||
statement.setInt(6, shortcut.getLevel());
|
||||
statement.setInt(7, _owner.getClassIndex());
|
||||
statement.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Could not store character shortcut: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @param page
|
||||
*/
|
||||
public synchronized void deleteShortCut(int slot, int page)
|
||||
{
|
||||
final Shortcut old = _shortCuts.remove(slot + (page * MAX_SHORTCUTS_PER_BAR));
|
||||
if ((old == null) || (_owner == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
deleteShortCutFromDb(old);
|
||||
if (old.getType() == ShortcutType.ITEM)
|
||||
{
|
||||
final L2ItemInstance item = _owner.getInventory().getItemByObjectId(old.getId());
|
||||
|
||||
if ((item != null) && (item.getItemType() == EtcItemType.SOULSHOT))
|
||||
{
|
||||
if (_owner.removeAutoSoulShot(item.getId()))
|
||||
{
|
||||
_owner.sendPacket(new ExAutoSoulShot(item.getId(), false, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_owner.sendPacket(new ShortCutInit(_owner));
|
||||
|
||||
for (int shotId : _owner.getAutoSoulShot())
|
||||
{
|
||||
_owner.sendPacket(new ExAutoSoulShot(shotId, true, 0));
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void deleteShortCutByObjectId(int objectId)
|
||||
{
|
||||
for (Shortcut shortcut : _shortCuts.values())
|
||||
{
|
||||
if ((shortcut.getType() == ShortcutType.ITEM) && (shortcut.getId() == objectId))
|
||||
{
|
||||
deleteShortCut(shortcut.getSlot(), shortcut.getPage());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param shortcut
|
||||
*/
|
||||
private void deleteShortCutFromDb(Shortcut shortcut)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=? AND slot=? AND page=? AND class_index=?"))
|
||||
{
|
||||
statement.setInt(1, _owner.getObjectId());
|
||||
statement.setInt(2, shortcut.getSlot());
|
||||
statement.setInt(3, shortcut.getPage());
|
||||
statement.setInt(4, _owner.getClassIndex());
|
||||
statement.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Could not delete character shortcut: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restoreMe()
|
||||
{
|
||||
_shortCuts.clear();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT charId, slot, page, type, shortcut_id, level FROM character_shortcuts WHERE charId=? AND class_index=?"))
|
||||
{
|
||||
statement.setInt(1, _owner.getObjectId());
|
||||
statement.setInt(2, _owner.getClassIndex());
|
||||
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
while (rset.next())
|
||||
{
|
||||
final int slot = rset.getInt("slot");
|
||||
final int page = rset.getInt("page");
|
||||
final int type = rset.getInt("type");
|
||||
final int id = rset.getInt("shortcut_id");
|
||||
final int level = rset.getInt("level");
|
||||
|
||||
_shortCuts.put(slot + (page * MAX_SHORTCUTS_PER_BAR), new Shortcut(slot, page, ShortcutType.values()[type], id, level, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Could not restore character shortcuts: " + e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify shortcuts
|
||||
for (Shortcut sc : getAllShortCuts())
|
||||
{
|
||||
if (sc.getType() == ShortcutType.ITEM)
|
||||
{
|
||||
final L2ItemInstance item = _owner.getInventory().getItemByObjectId(sc.getId());
|
||||
if (item == null)
|
||||
{
|
||||
deleteShortCut(sc.getSlot(), sc.getPage());
|
||||
}
|
||||
else if (item.isEtcItem())
|
||||
{
|
||||
sc.setSharedReuseGroup(item.getEtcItem().getSharedReuseGroup());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the shortcut bars with the new skill.
|
||||
* @param skillId the skill Id to search and update.
|
||||
* @param skillLevel the skill level to update.
|
||||
*/
|
||||
public synchronized void updateShortCuts(int skillId, int skillLevel)
|
||||
{
|
||||
// Update all the shortcuts for this skill
|
||||
for (Shortcut sc : _shortCuts.values())
|
||||
{
|
||||
if ((sc.getId() == skillId) && (sc.getType() == ShortcutType.SKILL))
|
||||
{
|
||||
final Shortcut newsc = new Shortcut(sc.getSlot(), sc.getPage(), sc.getType(), sc.getId(), skillLevel, 1);
|
||||
_owner.sendPacket(new ShortCutRegister(newsc));
|
||||
_owner.registerShortCut(newsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,123 +1,123 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.ShortcutType;
|
||||
|
||||
/**
|
||||
* Shortcut DTO.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class Shortcut
|
||||
{
|
||||
/** Slot from 0 to 11. */
|
||||
private final int _slot;
|
||||
/** Page from 0 to 9. */
|
||||
private final int _page;
|
||||
/** Type: item, skill, action, macro, recipe, bookmark. */
|
||||
private final ShortcutType _type;
|
||||
/** Shortcut ID. */
|
||||
private final int _id;
|
||||
/** Shortcut level (skills). */
|
||||
private final int _level;
|
||||
/** Character type: 1 player, 2 summon. */
|
||||
private final int _characterType;
|
||||
/** Shared reuse group. */
|
||||
private int _sharedReuseGroup = -1;
|
||||
|
||||
public Shortcut(int slot, int page, ShortcutType type, int id, int level, int characterType)
|
||||
{
|
||||
_slot = slot;
|
||||
_page = page;
|
||||
_type = type;
|
||||
_id = id;
|
||||
_level = level;
|
||||
_characterType = characterType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shortcut ID.
|
||||
* @return the ID
|
||||
*/
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shortcut level.
|
||||
* @return the level
|
||||
*/
|
||||
public int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shortcut page.
|
||||
* @return the page
|
||||
*/
|
||||
public int getPage()
|
||||
{
|
||||
return _page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shortcut slot.
|
||||
* @return the slot
|
||||
*/
|
||||
public int getSlot()
|
||||
{
|
||||
return _slot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shortcut type.
|
||||
* @return the type
|
||||
*/
|
||||
public ShortcutType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shortcut character type.
|
||||
* @return the character type
|
||||
*/
|
||||
public int getCharacterType()
|
||||
{
|
||||
return _characterType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shared reuse group.
|
||||
* @return the shared reuse group
|
||||
*/
|
||||
public int getSharedReuseGroup()
|
||||
{
|
||||
return _sharedReuseGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the shared reuse group.
|
||||
* @param sharedReuseGroup the shared reuse group to set
|
||||
*/
|
||||
public void setSharedReuseGroup(int sharedReuseGroup)
|
||||
{
|
||||
_sharedReuseGroup = sharedReuseGroup;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.ShortcutType;
|
||||
|
||||
/**
|
||||
* Shortcut DTO.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class Shortcut
|
||||
{
|
||||
/** Slot from 0 to 11. */
|
||||
private final int _slot;
|
||||
/** Page from 0 to 9. */
|
||||
private final int _page;
|
||||
/** Type: item, skill, action, macro, recipe, bookmark. */
|
||||
private final ShortcutType _type;
|
||||
/** Shortcut ID. */
|
||||
private final int _id;
|
||||
/** Shortcut level (skills). */
|
||||
private final int _level;
|
||||
/** Character type: 1 player, 2 summon. */
|
||||
private final int _characterType;
|
||||
/** Shared reuse group. */
|
||||
private int _sharedReuseGroup = -1;
|
||||
|
||||
public Shortcut(int slot, int page, ShortcutType type, int id, int level, int characterType)
|
||||
{
|
||||
_slot = slot;
|
||||
_page = page;
|
||||
_type = type;
|
||||
_id = id;
|
||||
_level = level;
|
||||
_characterType = characterType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shortcut ID.
|
||||
* @return the ID
|
||||
*/
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shortcut level.
|
||||
* @return the level
|
||||
*/
|
||||
public int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shortcut page.
|
||||
* @return the page
|
||||
*/
|
||||
public int getPage()
|
||||
{
|
||||
return _page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shortcut slot.
|
||||
* @return the slot
|
||||
*/
|
||||
public int getSlot()
|
||||
{
|
||||
return _slot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shortcut type.
|
||||
* @return the type
|
||||
*/
|
||||
public ShortcutType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shortcut character type.
|
||||
* @return the character type
|
||||
*/
|
||||
public int getCharacterType()
|
||||
{
|
||||
return _characterType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shared reuse group.
|
||||
* @return the shared reuse group
|
||||
*/
|
||||
public int getSharedReuseGroup()
|
||||
{
|
||||
return _sharedReuseGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the shared reuse group.
|
||||
* @param sharedReuseGroup the shared reuse group to set
|
||||
*/
|
||||
public void setSharedReuseGroup(int sharedReuseGroup)
|
||||
{
|
||||
_sharedReuseGroup = sharedReuseGroup;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +1,51 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class SiegeScheduleDate
|
||||
{
|
||||
private final int _day;
|
||||
private final int _hour;
|
||||
private final int _maxConcurrent;
|
||||
|
||||
public SiegeScheduleDate(StatsSet set)
|
||||
{
|
||||
_day = set.getInt("day", Calendar.SUNDAY);
|
||||
_hour = set.getInt("hour", 16);
|
||||
_maxConcurrent = set.getInt("maxConcurrent", 5);
|
||||
}
|
||||
|
||||
public int getDay()
|
||||
{
|
||||
return _day;
|
||||
}
|
||||
|
||||
public int getHour()
|
||||
{
|
||||
return _hour;
|
||||
}
|
||||
|
||||
public int getMaxConcurrent()
|
||||
{
|
||||
return _maxConcurrent;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class SiegeScheduleDate
|
||||
{
|
||||
private final int _day;
|
||||
private final int _hour;
|
||||
private final int _maxConcurrent;
|
||||
|
||||
public SiegeScheduleDate(StatsSet set)
|
||||
{
|
||||
_day = set.getInt("day", Calendar.SUNDAY);
|
||||
_hour = set.getInt("hour", 16);
|
||||
_maxConcurrent = set.getInt("maxConcurrent", 5);
|
||||
}
|
||||
|
||||
public int getDay()
|
||||
{
|
||||
return _day;
|
||||
}
|
||||
|
||||
public int getHour()
|
||||
{
|
||||
return _hour;
|
||||
}
|
||||
|
||||
public int getMaxConcurrent()
|
||||
{
|
||||
return _maxConcurrent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
|
||||
*/
|
||||
|
||||
public interface SpawnListener
|
||||
{
|
||||
void npcSpawned(L2Npc npc);
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
|
||||
*/
|
||||
|
||||
public interface SpawnListener
|
||||
{
|
||||
void npcSpawned(L2Npc npc);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,71 +1,71 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class TeleportBookmark extends Location
|
||||
{
|
||||
private final int _id;
|
||||
private int _icon;
|
||||
private String _name, _tag;
|
||||
|
||||
public TeleportBookmark(int id, int x, int y, int z, int icon, String tag, String name)
|
||||
{
|
||||
super(x, y, z);
|
||||
_id = id;
|
||||
_icon = icon;
|
||||
_name = name;
|
||||
_tag = tag;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getIcon()
|
||||
{
|
||||
return _icon;
|
||||
}
|
||||
|
||||
public void setIcon(int icon)
|
||||
{
|
||||
_icon = icon;
|
||||
}
|
||||
|
||||
public String getTag()
|
||||
{
|
||||
return _tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag)
|
||||
{
|
||||
_tag = tag;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class TeleportBookmark extends Location
|
||||
{
|
||||
private final int _id;
|
||||
private int _icon;
|
||||
private String _name, _tag;
|
||||
|
||||
public TeleportBookmark(int id, int x, int y, int z, int icon, String tag, String name)
|
||||
{
|
||||
super(x, y, z);
|
||||
_id = id;
|
||||
_icon = icon;
|
||||
_name = name;
|
||||
_tag = tag;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getIcon()
|
||||
{
|
||||
return _icon;
|
||||
}
|
||||
|
||||
public void setIcon(int icon)
|
||||
{
|
||||
_icon = icon;
|
||||
}
|
||||
|
||||
public String getTag()
|
||||
{
|
||||
return _tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag)
|
||||
{
|
||||
_tag = tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* All teleport types.
|
||||
* @author xban1x
|
||||
*/
|
||||
public enum TeleportWhereType
|
||||
{
|
||||
CASTLE,
|
||||
CLANHALL,
|
||||
SIEGEFLAG,
|
||||
TOWN,
|
||||
FORTRESS
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
/**
|
||||
* All teleport types.
|
||||
* @author xban1x
|
||||
*/
|
||||
public enum TeleportWhereType
|
||||
{
|
||||
CASTLE,
|
||||
CLANHALL,
|
||||
SIEGEFLAG,
|
||||
TOWN,
|
||||
FORTRESS
|
||||
}
|
||||
|
||||
@@ -1,83 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
|
||||
/**
|
||||
* Class explanation:<br>
|
||||
* For item counting or checking purposes. When you don't want to modify inventory<br>
|
||||
* class contains itemId, quantity, ownerId, referencePrice, but not objectId<br>
|
||||
* is stored, this will be only "list" of items with it's owner
|
||||
*/
|
||||
public final class TempItem
|
||||
{
|
||||
private final int _itemId;
|
||||
private int _quantity;
|
||||
private final int _referencePrice;
|
||||
private final String _itemName;
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* @param quantity of that item
|
||||
*/
|
||||
public TempItem(L2ItemInstance item, int quantity)
|
||||
{
|
||||
super();
|
||||
_itemId = item.getId();
|
||||
_quantity = quantity;
|
||||
_itemName = item.getItem().getName();
|
||||
_referencePrice = item.getReferencePrice();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the quantity.
|
||||
*/
|
||||
public int getQuantity()
|
||||
{
|
||||
return _quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param quantity The quantity to set.
|
||||
*/
|
||||
public void setQuantity(int quantity)
|
||||
{
|
||||
_quantity = quantity;
|
||||
}
|
||||
|
||||
public int getReferencePrice()
|
||||
{
|
||||
return _referencePrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the itemId.
|
||||
*/
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the itemName.
|
||||
*/
|
||||
public String getItemName()
|
||||
{
|
||||
return _itemName;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
|
||||
/**
|
||||
* Class explanation:<br>
|
||||
* For item counting or checking purposes. When you don't want to modify inventory<br>
|
||||
* class contains itemId, quantity, ownerId, referencePrice, but not objectId<br>
|
||||
* is stored, this will be only "list" of items with it's owner
|
||||
*/
|
||||
public final class TempItem
|
||||
{
|
||||
private final int _itemId;
|
||||
private int _quantity;
|
||||
private final int _referencePrice;
|
||||
private final String _itemName;
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* @param quantity of that item
|
||||
*/
|
||||
public TempItem(L2ItemInstance item, int quantity)
|
||||
{
|
||||
super();
|
||||
_itemId = item.getId();
|
||||
_quantity = quantity;
|
||||
_itemName = item.getItem().getName();
|
||||
_referencePrice = item.getReferencePrice();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the quantity.
|
||||
*/
|
||||
public int getQuantity()
|
||||
{
|
||||
return _quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param quantity The quantity to set.
|
||||
*/
|
||||
public void setQuantity(int quantity)
|
||||
{
|
||||
_quantity = quantity;
|
||||
}
|
||||
|
||||
public int getReferencePrice()
|
||||
{
|
||||
return _referencePrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the itemId.
|
||||
*/
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the itemName.
|
||||
*/
|
||||
public String getItemName()
|
||||
{
|
||||
return _itemName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,152 +1,152 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
|
||||
/**
|
||||
* Simple class containing all necessary information to maintain<br>
|
||||
* valid time stamps and reuse for skills and items reuse upon re-login.<br>
|
||||
* <b>Filter this carefully as it becomes redundant to store reuse for small delays.</b>
|
||||
* @author Yesod, Zoey76
|
||||
*/
|
||||
public class TimeStamp
|
||||
{
|
||||
/** Item or skill ID. */
|
||||
private final int _id1;
|
||||
/** Item object ID or skill level. */
|
||||
private final int _id2;
|
||||
/** Item or skill reuse time. */
|
||||
private final long _reuse;
|
||||
/** Time stamp. */
|
||||
private final long _stamp;
|
||||
/** Shared reuse group. */
|
||||
private final int _group;
|
||||
|
||||
/**
|
||||
* Skill time stamp constructor.
|
||||
* @param skill the skill upon the stamp will be created.
|
||||
* @param reuse the reuse time for this skill.
|
||||
* @param systime overrides the system time with a customized one.
|
||||
*/
|
||||
public TimeStamp(Skill skill, long reuse, long systime)
|
||||
{
|
||||
_id1 = skill.getId();
|
||||
_id2 = skill.getLevel();
|
||||
_reuse = reuse;
|
||||
_stamp = systime > 0 ? systime : System.currentTimeMillis() + reuse;
|
||||
_group = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Item time stamp constructor.
|
||||
* @param item the item upon the stamp will be created.
|
||||
* @param reuse the reuse time for this item.
|
||||
* @param systime overrides the system time with a customized one.
|
||||
*/
|
||||
public TimeStamp(L2ItemInstance item, long reuse, long systime)
|
||||
{
|
||||
_id1 = item.getId();
|
||||
_id2 = item.getObjectId();
|
||||
_reuse = reuse;
|
||||
_stamp = systime > 0 ? systime : System.currentTimeMillis() + reuse;
|
||||
_group = item.getSharedReuseGroup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the time stamp.
|
||||
* @return the time stamp, either the system time where this time stamp was created or the custom time assigned
|
||||
*/
|
||||
public long getStamp()
|
||||
{
|
||||
return _stamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item ID.
|
||||
* @return the item ID
|
||||
*/
|
||||
public int getItemId()
|
||||
{
|
||||
return _id1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item object ID.
|
||||
* @return the item object ID
|
||||
*/
|
||||
public int getItemObjectId()
|
||||
{
|
||||
return _id2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skill ID.
|
||||
* @return the skill ID
|
||||
*/
|
||||
public int getSkillId()
|
||||
{
|
||||
return _id1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skill level.
|
||||
* @return the skill level
|
||||
*/
|
||||
public int getSkillLvl()
|
||||
{
|
||||
return _id2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the reuse.
|
||||
* @return the reuse
|
||||
*/
|
||||
public long getReuse()
|
||||
{
|
||||
return _reuse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shared reuse group.<br>
|
||||
* Only used on items.
|
||||
* @return the shared reuse group
|
||||
*/
|
||||
public int getSharedReuseGroup()
|
||||
{
|
||||
return _group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the remaining time.
|
||||
* @return the remaining time for this time stamp to expire
|
||||
*/
|
||||
public long getRemaining()
|
||||
{
|
||||
return Math.max(_stamp - System.currentTimeMillis(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if the reuse delay has passed.
|
||||
* @return {@code true} if this time stamp has expired, {@code false} otherwise
|
||||
*/
|
||||
public boolean hasNotPassed()
|
||||
{
|
||||
return System.currentTimeMillis() < _stamp;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
|
||||
/**
|
||||
* Simple class containing all necessary information to maintain<br>
|
||||
* valid time stamps and reuse for skills and items reuse upon re-login.<br>
|
||||
* <b>Filter this carefully as it becomes redundant to store reuse for small delays.</b>
|
||||
* @author Yesod, Zoey76
|
||||
*/
|
||||
public class TimeStamp
|
||||
{
|
||||
/** Item or skill ID. */
|
||||
private final int _id1;
|
||||
/** Item object ID or skill level. */
|
||||
private final int _id2;
|
||||
/** Item or skill reuse time. */
|
||||
private final long _reuse;
|
||||
/** Time stamp. */
|
||||
private final long _stamp;
|
||||
/** Shared reuse group. */
|
||||
private final int _group;
|
||||
|
||||
/**
|
||||
* Skill time stamp constructor.
|
||||
* @param skill the skill upon the stamp will be created.
|
||||
* @param reuse the reuse time for this skill.
|
||||
* @param systime overrides the system time with a customized one.
|
||||
*/
|
||||
public TimeStamp(Skill skill, long reuse, long systime)
|
||||
{
|
||||
_id1 = skill.getId();
|
||||
_id2 = skill.getLevel();
|
||||
_reuse = reuse;
|
||||
_stamp = systime > 0 ? systime : System.currentTimeMillis() + reuse;
|
||||
_group = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Item time stamp constructor.
|
||||
* @param item the item upon the stamp will be created.
|
||||
* @param reuse the reuse time for this item.
|
||||
* @param systime overrides the system time with a customized one.
|
||||
*/
|
||||
public TimeStamp(L2ItemInstance item, long reuse, long systime)
|
||||
{
|
||||
_id1 = item.getId();
|
||||
_id2 = item.getObjectId();
|
||||
_reuse = reuse;
|
||||
_stamp = systime > 0 ? systime : System.currentTimeMillis() + reuse;
|
||||
_group = item.getSharedReuseGroup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the time stamp.
|
||||
* @return the time stamp, either the system time where this time stamp was created or the custom time assigned
|
||||
*/
|
||||
public long getStamp()
|
||||
{
|
||||
return _stamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item ID.
|
||||
* @return the item ID
|
||||
*/
|
||||
public int getItemId()
|
||||
{
|
||||
return _id1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item object ID.
|
||||
* @return the item object ID
|
||||
*/
|
||||
public int getItemObjectId()
|
||||
{
|
||||
return _id2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skill ID.
|
||||
* @return the skill ID
|
||||
*/
|
||||
public int getSkillId()
|
||||
{
|
||||
return _id1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skill level.
|
||||
* @return the skill level
|
||||
*/
|
||||
public int getSkillLvl()
|
||||
{
|
||||
return _id2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the reuse.
|
||||
* @return the reuse
|
||||
*/
|
||||
public long getReuse()
|
||||
{
|
||||
return _reuse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shared reuse group.<br>
|
||||
* Only used on items.
|
||||
* @return the shared reuse group
|
||||
*/
|
||||
public int getSharedReuseGroup()
|
||||
{
|
||||
return _group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the remaining time.
|
||||
* @return the remaining time for this time stamp to expire
|
||||
*/
|
||||
public long getRemaining()
|
||||
{
|
||||
return Math.max(_stamp - System.currentTimeMillis(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if the reuse delay has passed.
|
||||
* @return {@code true} if this time stamp has expired, {@code false} otherwise
|
||||
*/
|
||||
public boolean hasNotPassed()
|
||||
{
|
||||
return System.currentTimeMillis() < _stamp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,75 +1,75 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||
|
||||
/**
|
||||
* @author malyelfik
|
||||
*/
|
||||
public class TowerSpawn implements IIdentifiable
|
||||
{
|
||||
private final int _npcId;
|
||||
private final Location _location;
|
||||
private List<Integer> _zoneList = null;
|
||||
private int _upgradeLevel = 0;
|
||||
|
||||
public TowerSpawn(int npcId, Location location)
|
||||
{
|
||||
_location = location;
|
||||
_npcId = npcId;
|
||||
}
|
||||
|
||||
public TowerSpawn(int npcId, Location location, List<Integer> zoneList)
|
||||
{
|
||||
_location = location;
|
||||
_npcId = npcId;
|
||||
_zoneList = zoneList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the NPC ID.
|
||||
* @return the NPC ID
|
||||
*/
|
||||
@Override
|
||||
public int getId()
|
||||
{
|
||||
return _npcId;
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
public List<Integer> getZoneList()
|
||||
{
|
||||
return _zoneList;
|
||||
}
|
||||
|
||||
public void setUpgradeLevel(int level)
|
||||
{
|
||||
_upgradeLevel = level;
|
||||
}
|
||||
|
||||
public int getUpgradeLevel()
|
||||
{
|
||||
return _upgradeLevel;
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||
|
||||
/**
|
||||
* @author malyelfik
|
||||
*/
|
||||
public class TowerSpawn implements IIdentifiable
|
||||
{
|
||||
private final int _npcId;
|
||||
private final Location _location;
|
||||
private List<Integer> _zoneList = null;
|
||||
private int _upgradeLevel = 0;
|
||||
|
||||
public TowerSpawn(int npcId, Location location)
|
||||
{
|
||||
_location = location;
|
||||
_npcId = npcId;
|
||||
}
|
||||
|
||||
public TowerSpawn(int npcId, Location location, List<Integer> zoneList)
|
||||
{
|
||||
_location = location;
|
||||
_npcId = npcId;
|
||||
_zoneList = zoneList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the NPC ID.
|
||||
* @return the NPC ID
|
||||
*/
|
||||
@Override
|
||||
public int getId()
|
||||
{
|
||||
return _npcId;
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
public List<Integer> getZoneList()
|
||||
{
|
||||
return _zoneList;
|
||||
}
|
||||
|
||||
public void setUpgradeLevel(int level)
|
||||
{
|
||||
_upgradeLevel = level;
|
||||
}
|
||||
|
||||
public int getUpgradeLevel()
|
||||
{
|
||||
return _upgradeLevel;
|
||||
}
|
||||
}
|
||||
@@ -1,295 +1,223 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.ensoul.SoulCrystalOption;
|
||||
|
||||
public class TradeItem
|
||||
{
|
||||
private L2ItemInstance _itemInstance;
|
||||
private int _objectId;
|
||||
private final L2Item _item;
|
||||
private final int _location;
|
||||
private int _enchant;
|
||||
private final int _type1;
|
||||
private final int _type2;
|
||||
private long _count;
|
||||
private long _storeCount;
|
||||
private long _price;
|
||||
private final byte _elemAtkType;
|
||||
private final int _elemAtkPower;
|
||||
private final int[] _elemDefAttr =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
private final int[] _enchantOptions;
|
||||
private final boolean _isAugmented;
|
||||
private final L2Augmentation _augmentation;
|
||||
private final int _mana;
|
||||
private final boolean _isTimeLimited;
|
||||
private final int _time;
|
||||
private final int _visualId;
|
||||
private final long _visualExpiration;
|
||||
private SoulCrystalOption[] _commonSoulCrystalOptions;
|
||||
private SoulCrystalOption _specialSoulCrystalOption;
|
||||
|
||||
public TradeItem(L2ItemInstance item, long count, long price)
|
||||
{
|
||||
_itemInstance = item;
|
||||
_objectId = item.getObjectId();
|
||||
_item = item.getItem();
|
||||
_location = item.getLocationSlot();
|
||||
_enchant = item.getEnchantLevel();
|
||||
_type1 = item.getCustomType1();
|
||||
_type2 = item.getCustomType2();
|
||||
_count = count;
|
||||
_price = price;
|
||||
_elemAtkType = item.getAttackElementType();
|
||||
_elemAtkPower = item.getAttackElementPower();
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
_elemDefAttr[i] = item.getElementDefAttr(i);
|
||||
}
|
||||
_enchantOptions = item.getEnchantOptions();
|
||||
_isAugmented = item.isAugmented();
|
||||
_augmentation = item.getAugmentation();
|
||||
_mana = item.getMana();
|
||||
_isTimeLimited = item.isTimeLimitedItem();
|
||||
_time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999;
|
||||
_visualId = item.getVisualId();
|
||||
_visualExpiration = item.getTime();
|
||||
_commonSoulCrystalOptions = item.getCommonSoulCrystalOptions();
|
||||
_specialSoulCrystalOption = item.getSpecialSoulCrystalOption();
|
||||
}
|
||||
|
||||
public TradeItem(L2Item item, long count, long price, int enchantLevel, int attackAttribute, int attackAttributeValue, int defenseAttributes[], int appearanceId)
|
||||
{
|
||||
_itemInstance = null;
|
||||
_objectId = 0;
|
||||
_item = item;
|
||||
_location = 0;
|
||||
_enchant = 0;
|
||||
_type1 = 0;
|
||||
_type2 = 0;
|
||||
_count = count;
|
||||
_storeCount = count;
|
||||
_price = price;
|
||||
_elemAtkType = (byte) attackAttribute;
|
||||
_elemAtkPower = attackAttributeValue;
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
_elemDefAttr[i] = defenseAttributes[i];
|
||||
}
|
||||
_enchantOptions = L2ItemInstance.DEFAULT_ENCHANT_OPTIONS;
|
||||
_isAugmented = false;
|
||||
_augmentation = null;
|
||||
_mana = -1;
|
||||
_isTimeLimited = false;
|
||||
_time = -9999;
|
||||
_visualId = appearanceId;
|
||||
_visualExpiration = -1;
|
||||
_commonSoulCrystalOptions = new SoulCrystalOption[2];
|
||||
_specialSoulCrystalOption = null;
|
||||
}
|
||||
|
||||
public TradeItem(TradeItem item, long count, long price, int enchantLevel, int attackAttribute, int attackAttributeValue, int defenseAttributes[], int appearanceId)
|
||||
{
|
||||
_itemInstance = item.getItemInstance();
|
||||
_objectId = item.getObjectId();
|
||||
_item = item.getItem();
|
||||
_location = item.getLocationSlot();
|
||||
_enchant = item.getEnchant();
|
||||
_type1 = item.getCustomType1();
|
||||
_type2 = item.getCustomType2();
|
||||
_count = count;
|
||||
_storeCount = count;
|
||||
_price = price;
|
||||
_elemAtkType = item.getAttackElementType();
|
||||
_elemAtkPower = item.getAttackElementPower();
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
_elemDefAttr[i] = item.getElementDefAttr(i);
|
||||
}
|
||||
_enchantOptions = item.getEnchantOptions();
|
||||
_isAugmented = item.isAugmented();
|
||||
_augmentation = item.getAugmentation();
|
||||
_mana = item.getMana();
|
||||
_isTimeLimited = item.isTimeLimitedItem();
|
||||
_time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999;
|
||||
_visualId = item.getVisualId();
|
||||
_visualExpiration = item.getVisualExpiration();
|
||||
_commonSoulCrystalOptions = item.getCommonSoulCrystalOptions();
|
||||
_specialSoulCrystalOption = item.getSpecialSoulCrystalOption();
|
||||
}
|
||||
|
||||
public L2ItemInstance getItemInstance()
|
||||
{
|
||||
return _itemInstance;
|
||||
}
|
||||
|
||||
public void setItemInstance(L2ItemInstance it)
|
||||
{
|
||||
_itemInstance = it;
|
||||
}
|
||||
|
||||
public void setObjectId(int objectId)
|
||||
{
|
||||
_objectId = objectId;
|
||||
}
|
||||
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public L2Item getItem()
|
||||
{
|
||||
return _item;
|
||||
}
|
||||
|
||||
public int getLocationSlot()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
public void setEnchant(int enchant)
|
||||
{
|
||||
_enchant = enchant;
|
||||
}
|
||||
|
||||
public int getEnchant()
|
||||
{
|
||||
return _enchant;
|
||||
}
|
||||
|
||||
public int getCustomType1()
|
||||
{
|
||||
return _type1;
|
||||
}
|
||||
|
||||
public int getCustomType2()
|
||||
{
|
||||
return _type2;
|
||||
}
|
||||
|
||||
public void setCount(long count)
|
||||
{
|
||||
_count = count;
|
||||
}
|
||||
|
||||
public long getCount()
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
public long getStoreCount()
|
||||
{
|
||||
return _storeCount;
|
||||
}
|
||||
|
||||
public void setPrice(long price)
|
||||
{
|
||||
_price = price;
|
||||
}
|
||||
|
||||
public long getPrice()
|
||||
{
|
||||
return _price;
|
||||
}
|
||||
|
||||
public byte getAttackElementType()
|
||||
{
|
||||
return _elemAtkType;
|
||||
}
|
||||
|
||||
public int getAttackElementPower()
|
||||
{
|
||||
return _elemAtkPower;
|
||||
}
|
||||
|
||||
public int getElementDefAttr(byte i)
|
||||
{
|
||||
return _elemDefAttr[i];
|
||||
}
|
||||
|
||||
public int[] getEnchantOptions()
|
||||
{
|
||||
return _enchantOptions;
|
||||
}
|
||||
|
||||
public boolean isAugmented()
|
||||
{
|
||||
return _isAugmented;
|
||||
}
|
||||
|
||||
public L2Augmentation getAugmentation()
|
||||
{
|
||||
return _augmentation;
|
||||
}
|
||||
|
||||
public int getMana()
|
||||
{
|
||||
return _mana;
|
||||
}
|
||||
|
||||
public boolean isTimeLimitedItem()
|
||||
{
|
||||
return _isTimeLimited;
|
||||
}
|
||||
|
||||
public int getVisualId()
|
||||
{
|
||||
return _visualId;
|
||||
}
|
||||
|
||||
public long getVisualExpiration()
|
||||
{
|
||||
return _visualExpiration;
|
||||
}
|
||||
|
||||
public int getRemainingTime()
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
|
||||
public SoulCrystalOption[] getCommonSoulCrystalOptions()
|
||||
{
|
||||
return _commonSoulCrystalOptions;
|
||||
}
|
||||
|
||||
public void setSoulCrystalOptions(SoulCrystalOption[] options)
|
||||
{
|
||||
_commonSoulCrystalOptions = options;
|
||||
}
|
||||
|
||||
public SoulCrystalOption getSpecialSoulCrystalOption()
|
||||
{
|
||||
return _specialSoulCrystalOption;
|
||||
}
|
||||
|
||||
public void setSpecialSoulCrystalOption(SoulCrystalOption option)
|
||||
{
|
||||
_specialSoulCrystalOption = option;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.AttributeType;
|
||||
import com.l2jmobius.gameserver.model.ensoul.EnsoulOption;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
|
||||
public class TradeItem
|
||||
{
|
||||
private int _objectId;
|
||||
private final L2Item _item;
|
||||
private final int _location;
|
||||
private int _enchant;
|
||||
private final int _type1;
|
||||
private final int _type2;
|
||||
private long _count;
|
||||
private long _storeCount;
|
||||
private long _price;
|
||||
private final byte _elemAtkType;
|
||||
private final int _elemAtkPower;
|
||||
private final int[] _elemDefAttr =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
private final int[] _enchantOptions;
|
||||
private final Collection<EnsoulOption> _soulCrystalOptions;
|
||||
private final Collection<EnsoulOption> _soulCrystalSpecialOptions;
|
||||
private int _visualId;
|
||||
private int _augmentId;
|
||||
|
||||
public TradeItem(L2ItemInstance item, long count, long price)
|
||||
{
|
||||
_objectId = item.getObjectId();
|
||||
_item = item.getItem();
|
||||
_location = item.getLocationSlot();
|
||||
_enchant = item.getEnchantLevel();
|
||||
_type1 = item.getCustomType1();
|
||||
_type2 = item.getCustomType2();
|
||||
_count = count;
|
||||
_price = price;
|
||||
_elemAtkType = item.getAttackAttributeType().getClientId();
|
||||
_elemAtkPower = item.getAttackAttributePower();
|
||||
for (AttributeType type : AttributeType.ATTRIBUTE_TYPES)
|
||||
{
|
||||
_elemDefAttr[type.getClientId()] = item.getDefenceAttribute(type);
|
||||
}
|
||||
_enchantOptions = item.getEnchantOptions();
|
||||
_soulCrystalOptions = item.getSpecialAbilities();
|
||||
_soulCrystalSpecialOptions = item.getAdditionalSpecialAbilities();
|
||||
_visualId = item.getVisualId();
|
||||
_augmentId = item.isAugmented() ? item.getAugmentation().getId() : 0;
|
||||
}
|
||||
|
||||
public TradeItem(L2Item item, long count, long price)
|
||||
{
|
||||
_objectId = 0;
|
||||
_item = item;
|
||||
_location = 0;
|
||||
_enchant = 0;
|
||||
_type1 = 0;
|
||||
_type2 = 0;
|
||||
_count = count;
|
||||
_storeCount = count;
|
||||
_price = price;
|
||||
_elemAtkType = Elementals.NONE;
|
||||
_elemAtkPower = 0;
|
||||
_enchantOptions = L2ItemInstance.DEFAULT_ENCHANT_OPTIONS;
|
||||
_soulCrystalOptions = Collections.emptyList();
|
||||
_soulCrystalSpecialOptions = Collections.emptyList();
|
||||
}
|
||||
|
||||
public TradeItem(TradeItem item, long count, long price)
|
||||
{
|
||||
_objectId = item.getObjectId();
|
||||
_item = item.getItem();
|
||||
_location = item.getLocationSlot();
|
||||
_enchant = item.getEnchant();
|
||||
_type1 = item.getCustomType1();
|
||||
_type2 = item.getCustomType2();
|
||||
_count = count;
|
||||
_storeCount = count;
|
||||
_price = price;
|
||||
_elemAtkType = item.getAttackElementType();
|
||||
_elemAtkPower = item.getAttackElementPower();
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
_elemDefAttr[i] = item.getElementDefAttr(i);
|
||||
}
|
||||
_enchantOptions = item.getEnchantOptions();
|
||||
_soulCrystalOptions = item.getSoulCrystalOptions();
|
||||
_soulCrystalSpecialOptions = item.getSoulCrystalSpecialOptions();
|
||||
_visualId = item.getVisualId();
|
||||
}
|
||||
|
||||
public void setObjectId(int objectId)
|
||||
{
|
||||
_objectId = objectId;
|
||||
}
|
||||
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public L2Item getItem()
|
||||
{
|
||||
return _item;
|
||||
}
|
||||
|
||||
public int getLocationSlot()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
public void setEnchant(int enchant)
|
||||
{
|
||||
_enchant = enchant;
|
||||
}
|
||||
|
||||
public int getEnchant()
|
||||
{
|
||||
return _enchant;
|
||||
}
|
||||
|
||||
public int getCustomType1()
|
||||
{
|
||||
return _type1;
|
||||
}
|
||||
|
||||
public int getCustomType2()
|
||||
{
|
||||
return _type2;
|
||||
}
|
||||
|
||||
public void setCount(long count)
|
||||
{
|
||||
_count = count;
|
||||
}
|
||||
|
||||
public long getCount()
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
public long getStoreCount()
|
||||
{
|
||||
return _storeCount;
|
||||
}
|
||||
|
||||
public void setPrice(long price)
|
||||
{
|
||||
_price = price;
|
||||
}
|
||||
|
||||
public long getPrice()
|
||||
{
|
||||
return _price;
|
||||
}
|
||||
|
||||
public byte getAttackElementType()
|
||||
{
|
||||
return _elemAtkType;
|
||||
}
|
||||
|
||||
public int getAttackElementPower()
|
||||
{
|
||||
return _elemAtkPower;
|
||||
}
|
||||
|
||||
public int getElementDefAttr(byte i)
|
||||
{
|
||||
return _elemDefAttr[i];
|
||||
}
|
||||
|
||||
public int[] getEnchantOptions()
|
||||
{
|
||||
return _enchantOptions;
|
||||
}
|
||||
|
||||
public Collection<EnsoulOption> getSoulCrystalOptions()
|
||||
{
|
||||
return _soulCrystalOptions;
|
||||
}
|
||||
|
||||
public Collection<EnsoulOption> getSoulCrystalSpecialOptions()
|
||||
{
|
||||
return _soulCrystalSpecialOptions;
|
||||
}
|
||||
|
||||
public int getAugmentId()
|
||||
{
|
||||
return _augmentId;
|
||||
}
|
||||
|
||||
public int getVisualId()
|
||||
{
|
||||
return _visualId;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,209 +1,213 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.UIData;
|
||||
|
||||
/**
|
||||
* UI Keys Settings class.
|
||||
* @author mrTJO, Zoey76
|
||||
*/
|
||||
public class UIKeysSettings
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(UIKeysSettings.class.getName());
|
||||
|
||||
private final int _playerObjId;
|
||||
private Map<Integer, List<ActionKey>> _storedKeys;
|
||||
private Map<Integer, List<Integer>> _storedCategories;
|
||||
private boolean _saved = true;
|
||||
|
||||
public UIKeysSettings(int playerObjId)
|
||||
{
|
||||
_playerObjId = playerObjId;
|
||||
loadFromDB();
|
||||
}
|
||||
|
||||
public void storeAll(Map<Integer, List<Integer>> catMap, Map<Integer, List<ActionKey>> keyMap)
|
||||
{
|
||||
_saved = false;
|
||||
_storedCategories = catMap;
|
||||
_storedKeys = keyMap;
|
||||
}
|
||||
|
||||
public void storeCategories(Map<Integer, List<Integer>> catMap)
|
||||
{
|
||||
_saved = false;
|
||||
_storedCategories = catMap;
|
||||
}
|
||||
|
||||
public Map<Integer, List<Integer>> getCategories()
|
||||
{
|
||||
return _storedCategories;
|
||||
}
|
||||
|
||||
public void storeKeys(Map<Integer, List<ActionKey>> keyMap)
|
||||
{
|
||||
_saved = false;
|
||||
_storedKeys = keyMap;
|
||||
}
|
||||
|
||||
public Map<Integer, List<ActionKey>> getKeys()
|
||||
{
|
||||
return _storedKeys;
|
||||
}
|
||||
|
||||
public void loadFromDB()
|
||||
{
|
||||
getCatsFromDB();
|
||||
getKeysFromDB();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Categories and Mapped Keys into GameServer DataBase
|
||||
*/
|
||||
public void saveInDB()
|
||||
{
|
||||
String query;
|
||||
if (_saved)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO(Zoey76): Refactor this to use batch.
|
||||
query = "REPLACE INTO character_ui_categories (`charId`, `catId`, `order`, `cmdId`) VALUES ";
|
||||
for (int category : _storedCategories.keySet())
|
||||
{
|
||||
int order = 0;
|
||||
for (int key : _storedCategories.get(category))
|
||||
{
|
||||
query += "(" + _playerObjId + ", " + category + ", " + order++ + ", " + key + "),";
|
||||
}
|
||||
}
|
||||
query = query.substring(0, query.length() - 1) + "; ";
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(query))
|
||||
{
|
||||
statement.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
query = "REPLACE INTO character_ui_actions (`charId`, `cat`, `order`, `cmd`, `key`, `tgKey1`, `tgKey2`, `show`) VALUES";
|
||||
for (List<ActionKey> keyLst : _storedKeys.values())
|
||||
{
|
||||
int order = 0;
|
||||
for (ActionKey key : keyLst)
|
||||
{
|
||||
query += key.getSqlSaveString(_playerObjId, order++) + ",";
|
||||
}
|
||||
}
|
||||
query = query.substring(0, query.length() - 1) + ";";
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(query))
|
||||
{
|
||||
statement.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
|
||||
}
|
||||
_saved = true;
|
||||
}
|
||||
|
||||
public void getCatsFromDB()
|
||||
{
|
||||
if (_storedCategories != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_storedCategories = new HashMap<>();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
|
||||
{
|
||||
ps.setInt(1, _playerObjId);
|
||||
try (ResultSet rs = ps.executeQuery())
|
||||
{
|
||||
while (rs.next())
|
||||
{
|
||||
UIData.addCategory(_storedCategories, rs.getInt("catId"), rs.getInt("cmdId"));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception: getCatsFromDB(): " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (_storedCategories.isEmpty())
|
||||
{
|
||||
_storedCategories = UIData.getInstance().getCategories();
|
||||
}
|
||||
}
|
||||
|
||||
public void getKeysFromDB()
|
||||
{
|
||||
if (_storedKeys != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_storedKeys = new HashMap<>();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
|
||||
{
|
||||
ps.setInt(1, _playerObjId);
|
||||
try (ResultSet rs = ps.executeQuery())
|
||||
{
|
||||
while (rs.next())
|
||||
{
|
||||
final int cat = rs.getInt("cat");
|
||||
UIData.addKey(_storedKeys, cat, new ActionKey(cat, rs.getInt("cmd"), rs.getInt("key"), rs.getInt("tgKey1"), rs.getInt("tgKey2"), rs.getInt("show")));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception: getKeysFromDB(): " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (_storedKeys.isEmpty())
|
||||
{
|
||||
_storedKeys = UIData.getInstance().getKeys();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSaved()
|
||||
{
|
||||
return _saved;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.UIData;
|
||||
|
||||
/**
|
||||
* UI Keys Settings class.
|
||||
* @author mrTJO, Zoey76
|
||||
*/
|
||||
public class UIKeysSettings
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(UIKeysSettings.class.getName());
|
||||
|
||||
private final int _playerObjId;
|
||||
private Map<Integer, List<ActionKey>> _storedKeys;
|
||||
private Map<Integer, List<Integer>> _storedCategories;
|
||||
private boolean _saved = true;
|
||||
|
||||
public UIKeysSettings(int playerObjId)
|
||||
{
|
||||
_playerObjId = playerObjId;
|
||||
loadFromDB();
|
||||
}
|
||||
|
||||
public void storeAll(Map<Integer, List<Integer>> catMap, Map<Integer, List<ActionKey>> keyMap)
|
||||
{
|
||||
_saved = false;
|
||||
_storedCategories = catMap;
|
||||
_storedKeys = keyMap;
|
||||
}
|
||||
|
||||
public void storeCategories(Map<Integer, List<Integer>> catMap)
|
||||
{
|
||||
_saved = false;
|
||||
_storedCategories = catMap;
|
||||
}
|
||||
|
||||
public Map<Integer, List<Integer>> getCategories()
|
||||
{
|
||||
return _storedCategories;
|
||||
}
|
||||
|
||||
public void storeKeys(Map<Integer, List<ActionKey>> keyMap)
|
||||
{
|
||||
_saved = false;
|
||||
_storedKeys = keyMap;
|
||||
}
|
||||
|
||||
public Map<Integer, List<ActionKey>> getKeys()
|
||||
{
|
||||
return _storedKeys;
|
||||
}
|
||||
|
||||
public void loadFromDB()
|
||||
{
|
||||
getCatsFromDB();
|
||||
getKeysFromDB();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Categories and Mapped Keys into GameServer DataBase
|
||||
*/
|
||||
public void saveInDB()
|
||||
{
|
||||
String query;
|
||||
if (_saved)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
query = "REPLACE INTO character_ui_categories (`charId`, `catId`, `order`, `cmdId`) VALUES ";
|
||||
for (int category : _storedCategories.keySet())
|
||||
{
|
||||
int order = 0;
|
||||
for (int key : _storedCategories.get(category))
|
||||
{
|
||||
query += "(" + _playerObjId + ", " + category + ", " + (order++) + ", " + key + "),";
|
||||
}
|
||||
}
|
||||
query = query.substring(0, query.length() - 1) + "; ";
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(query))
|
||||
{
|
||||
statement.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
query = "REPLACE INTO character_ui_actions (`charId`, `cat`, `order`, `cmd`, `key`, `tgKey1`, `tgKey2`, `show`) VALUES";
|
||||
for (List<ActionKey> keyLst : _storedKeys.values())
|
||||
{
|
||||
int order = 0;
|
||||
for (ActionKey key : keyLst)
|
||||
{
|
||||
query += key.getSqlSaveString(_playerObjId, order++) + ",";
|
||||
}
|
||||
}
|
||||
query = query.substring(0, query.length() - 1) + ";";
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(query))
|
||||
{
|
||||
statement.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
|
||||
}
|
||||
_saved = true;
|
||||
}
|
||||
|
||||
public void getCatsFromDB()
|
||||
{
|
||||
if (_storedCategories != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_storedCategories = new HashMap<>();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
|
||||
{
|
||||
stmt.setInt(1, _playerObjId);
|
||||
try (ResultSet rs = stmt.executeQuery())
|
||||
{
|
||||
while (rs.next())
|
||||
{
|
||||
UIData.addCategory(_storedCategories, rs.getInt("catId"), rs.getInt("cmdId"));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception: getCatsFromDB(): " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (_storedCategories.isEmpty())
|
||||
{
|
||||
_storedCategories = UIData.getInstance().getCategories();
|
||||
}
|
||||
}
|
||||
|
||||
public void getKeysFromDB()
|
||||
{
|
||||
if (_storedKeys != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_storedKeys = new HashMap<>();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
|
||||
{
|
||||
stmt.setInt(1, _playerObjId);
|
||||
try (ResultSet rs = stmt.executeQuery())
|
||||
{
|
||||
while (rs.next())
|
||||
{
|
||||
final int cat = rs.getInt("cat");
|
||||
final int cmd = rs.getInt("cmd");
|
||||
final int key = rs.getInt("key");
|
||||
final int tgKey1 = rs.getInt("tgKey1");
|
||||
final int tgKey2 = rs.getInt("tgKey2");
|
||||
final int show = rs.getInt("show");
|
||||
UIData.addKey(_storedKeys, cat, new ActionKey(cat, cmd, key, tgKey1, tgKey2, show));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception: getKeysFromDB(): " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (_storedKeys.isEmpty())
|
||||
{
|
||||
_storedKeys = UIData.getInstance().getKeys();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSaved()
|
||||
{
|
||||
return _saved;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +1,52 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
public final class VehiclePathPoint extends Location
|
||||
{
|
||||
private final int _moveSpeed;
|
||||
private final int _rotationSpeed;
|
||||
|
||||
public VehiclePathPoint(Location loc)
|
||||
{
|
||||
this(loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
public VehiclePathPoint(int x, int y, int z)
|
||||
{
|
||||
super(x, y, z);
|
||||
_moveSpeed = 350;
|
||||
_rotationSpeed = 4000;
|
||||
}
|
||||
|
||||
public VehiclePathPoint(int x, int y, int z, int moveSpeed, int rotationSpeed)
|
||||
{
|
||||
super(x, y, z);
|
||||
_moveSpeed = moveSpeed;
|
||||
_rotationSpeed = rotationSpeed;
|
||||
}
|
||||
|
||||
public int getMoveSpeed()
|
||||
{
|
||||
return _moveSpeed;
|
||||
}
|
||||
|
||||
public int getRotationSpeed()
|
||||
{
|
||||
return _rotationSpeed;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
public final class VehiclePathPoint extends Location
|
||||
{
|
||||
private final int _moveSpeed;
|
||||
private final int _rotationSpeed;
|
||||
|
||||
public VehiclePathPoint(Location loc)
|
||||
{
|
||||
this(loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
public VehiclePathPoint(int x, int y, int z)
|
||||
{
|
||||
super(x, y, z);
|
||||
_moveSpeed = 350;
|
||||
_rotationSpeed = 4000;
|
||||
}
|
||||
|
||||
public VehiclePathPoint(int x, int y, int z, int moveSpeed, int rotationSpeed)
|
||||
{
|
||||
super(x, y, z);
|
||||
_moveSpeed = moveSpeed;
|
||||
_rotationSpeed = rotationSpeed;
|
||||
}
|
||||
|
||||
public int getMoveSpeed()
|
||||
{
|
||||
return _moveSpeed;
|
||||
}
|
||||
|
||||
public int getRotationSpeed()
|
||||
{
|
||||
return _rotationSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,227 +1,225 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import com.l2jmobius.gameserver.instancemanager.WalkingManager;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcMoveRouteFinished;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* Holds info about current walk progress.
|
||||
* @author GKR, UnAfraid
|
||||
*/
|
||||
public class WalkInfo
|
||||
{
|
||||
private final String _routeName;
|
||||
private ScheduledFuture<?> _walkCheckTask;
|
||||
private boolean _blocked = false;
|
||||
private boolean _suspended = false;
|
||||
private boolean _stoppedByAttack = false;
|
||||
private int _currentNode = 0;
|
||||
private boolean _forward = true; // Determines first --> last or first <-- last direction
|
||||
private long _lastActionTime; // Debug field
|
||||
|
||||
public WalkInfo(String routeName)
|
||||
{
|
||||
_routeName = routeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of route of this WalkInfo.
|
||||
*/
|
||||
public L2WalkRoute getRoute()
|
||||
{
|
||||
return WalkingManager.getInstance().getRoute(_routeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current node of this WalkInfo.
|
||||
*/
|
||||
public L2NpcWalkerNode getCurrentNode()
|
||||
{
|
||||
return getRoute().getNodeList().get(_currentNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate next node for this WalkInfo and send debug message from given npc
|
||||
* @param npc NPC to debug message to be sent from
|
||||
*/
|
||||
public synchronized void calculateNextNode(L2Npc npc)
|
||||
{
|
||||
// Check this first, within the bounds of random moving, we have no conception of "first" or "last" node
|
||||
if (getRoute().getRepeatType() == WalkingManager.REPEAT_RANDOM)
|
||||
{
|
||||
int newNode = _currentNode;
|
||||
|
||||
while (newNode == _currentNode)
|
||||
{
|
||||
newNode = Rnd.get(getRoute().getNodesCount());
|
||||
}
|
||||
|
||||
_currentNode = newNode;
|
||||
npc.sendDebugMessage("Route: " + getRoute().getName() + ", next random node is " + _currentNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_forward)
|
||||
{
|
||||
_currentNode++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentNode--;
|
||||
}
|
||||
|
||||
if (_currentNode == getRoute().getNodesCount()) // Last node arrived
|
||||
{
|
||||
// Notify quest
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcMoveRouteFinished(npc), npc);
|
||||
npc.sendDebugMessage("Route: " + getRoute().getName() + ", last node arrived");
|
||||
|
||||
if (!getRoute().repeatWalk())
|
||||
{
|
||||
WalkingManager.getInstance().cancelMoving(npc);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (getRoute().getRepeatType())
|
||||
{
|
||||
case WalkingManager.REPEAT_GO_BACK:
|
||||
{
|
||||
_forward = false;
|
||||
_currentNode -= 2;
|
||||
break;
|
||||
}
|
||||
case WalkingManager.REPEAT_GO_FIRST:
|
||||
{
|
||||
_currentNode = 0;
|
||||
break;
|
||||
}
|
||||
case WalkingManager.REPEAT_TELE_FIRST:
|
||||
{
|
||||
npc.teleToLocation(npc.getSpawn().getLocation());
|
||||
_currentNode = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_currentNode == WalkingManager.NO_REPEAT) // First node arrived, when direction is first <-- last
|
||||
{
|
||||
_currentNode = 1;
|
||||
_forward = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if walking task is blocked, {@code false} otherwise,
|
||||
*/
|
||||
public boolean isBlocked()
|
||||
{
|
||||
return _blocked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val
|
||||
*/
|
||||
public void setBlocked(boolean val)
|
||||
{
|
||||
_blocked = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if walking task is suspended, {@code false} otherwise,
|
||||
*/
|
||||
public boolean isSuspended()
|
||||
{
|
||||
return _suspended;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val
|
||||
*/
|
||||
public void setSuspended(boolean val)
|
||||
{
|
||||
_suspended = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if walking task shall be stopped by attack, {@code false} otherwise,
|
||||
*/
|
||||
public boolean isStoppedByAttack()
|
||||
{
|
||||
return _stoppedByAttack;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val
|
||||
*/
|
||||
public void setStoppedByAttack(boolean val)
|
||||
{
|
||||
_stoppedByAttack = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id of the current node in this walking task.
|
||||
*/
|
||||
public int getCurrentNodeId()
|
||||
{
|
||||
return _currentNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code long} last action time used only for debugging.
|
||||
*/
|
||||
public long getLastAction()
|
||||
{
|
||||
return _lastActionTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val
|
||||
*/
|
||||
public void setLastAction(long val)
|
||||
{
|
||||
_lastActionTime = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return walking check task.
|
||||
*/
|
||||
public ScheduledFuture<?> getWalkCheckTask()
|
||||
{
|
||||
return _walkCheckTask;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val walking check task.
|
||||
*/
|
||||
public void setWalkCheckTask(ScheduledFuture<?> val)
|
||||
{
|
||||
_walkCheckTask = val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "WalkInfo [_routeName=" + _routeName + ", _walkCheckTask=" + _walkCheckTask + ", _blocked=" + _blocked + ", _suspended=" + _suspended + ", _stoppedByAttack=" + _stoppedByAttack + ", _currentNode=" + _currentNode + ", _forward=" + _forward + ", _lastActionTime=" + _lastActionTime + "]";
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.instancemanager.WalkingManager;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcMoveRouteFinished;
|
||||
|
||||
/**
|
||||
* Holds info about current walk progress
|
||||
* @author GKR, UnAfraid
|
||||
*/
|
||||
public class WalkInfo
|
||||
{
|
||||
private final String _routeName;
|
||||
|
||||
private ScheduledFuture<?> _walkCheckTask;
|
||||
private boolean _blocked = false;
|
||||
private boolean _suspended = false;
|
||||
private boolean _stoppedByAttack = false;
|
||||
private int _currentNode = 0;
|
||||
private boolean _forward = true; // Determines first --> last or first <-- last direction
|
||||
private long _lastActionTime; // Debug field
|
||||
|
||||
public WalkInfo(String routeName)
|
||||
{
|
||||
_routeName = routeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of route of this WalkInfo.
|
||||
*/
|
||||
public L2WalkRoute getRoute()
|
||||
{
|
||||
return WalkingManager.getInstance().getRoute(_routeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current node of this WalkInfo.
|
||||
*/
|
||||
public L2NpcWalkerNode getCurrentNode()
|
||||
{
|
||||
return getRoute().getNodeList().get(_currentNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate next node for this WalkInfo and send debug message from given npc
|
||||
* @param npc NPC to debug message to be sent from
|
||||
* @return
|
||||
*/
|
||||
public boolean calculateNextNode(L2Npc npc)
|
||||
{
|
||||
// Check this first, within the bounds of random moving, we have no conception of "first" or "last" node
|
||||
if (getRoute().getRepeatType() == WalkingManager.REPEAT_RANDOM)
|
||||
{
|
||||
int newNode = _currentNode;
|
||||
|
||||
while (newNode == _currentNode)
|
||||
{
|
||||
newNode = Rnd.get(getRoute().getNodesCount());
|
||||
}
|
||||
|
||||
_currentNode = newNode;
|
||||
npc.sendDebugMessage("Route: " + getRoute().getName() + ", next random node is " + _currentNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_forward)
|
||||
{
|
||||
_currentNode++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentNode--;
|
||||
}
|
||||
|
||||
if (_currentNode == getRoute().getNodesCount()) // Last node arrived
|
||||
{
|
||||
// Notify quest
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcMoveRouteFinished(npc), npc);
|
||||
npc.sendDebugMessage("Route: " + getRoute().getName() + ", last node arrived");
|
||||
|
||||
if (!getRoute().repeatWalk())
|
||||
{
|
||||
WalkingManager.getInstance().cancelMoving(npc);
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (getRoute().getRepeatType())
|
||||
{
|
||||
case WalkingManager.REPEAT_GO_BACK:
|
||||
{
|
||||
_forward = false;
|
||||
_currentNode -= 2;
|
||||
break;
|
||||
}
|
||||
case WalkingManager.REPEAT_GO_FIRST:
|
||||
{
|
||||
_currentNode = 0;
|
||||
break;
|
||||
}
|
||||
case WalkingManager.REPEAT_TELE_FIRST:
|
||||
{
|
||||
npc.teleToLocation(npc.getSpawn().getLocation());
|
||||
_currentNode = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (_currentNode == -1) // First node arrived, when direction is first <-- last
|
||||
{
|
||||
_currentNode = 1;
|
||||
_forward = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if walking task is blocked, {@code false} otherwise,
|
||||
*/
|
||||
public boolean isBlocked()
|
||||
{
|
||||
return _blocked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val
|
||||
*/
|
||||
public void setBlocked(boolean val)
|
||||
{
|
||||
_blocked = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if walking task is suspended, {@code false} otherwise,
|
||||
*/
|
||||
public boolean isSuspended()
|
||||
{
|
||||
return _suspended;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val
|
||||
*/
|
||||
public void setSuspended(boolean val)
|
||||
{
|
||||
_suspended = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if walking task shall be stopped by attack, {@code false} otherwise,
|
||||
*/
|
||||
public boolean isStoppedByAttack()
|
||||
{
|
||||
return _stoppedByAttack;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val
|
||||
*/
|
||||
public void setStoppedByAttack(boolean val)
|
||||
{
|
||||
_stoppedByAttack = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id of the current node in this walking task.
|
||||
*/
|
||||
public int getCurrentNodeId()
|
||||
{
|
||||
return _currentNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code long} last action time used only for debugging.
|
||||
*/
|
||||
public long getLastAction()
|
||||
{
|
||||
return _lastActionTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val
|
||||
*/
|
||||
public void setLastAction(long val)
|
||||
{
|
||||
_lastActionTime = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return walking check task.
|
||||
*/
|
||||
public ScheduledFuture<?> getWalkCheckTask()
|
||||
{
|
||||
return _walkCheckTask;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val walking check task.
|
||||
*/
|
||||
public void setWalkCheckTask(ScheduledFuture<?> val)
|
||||
{
|
||||
_walkCheckTask = val;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user