Prohibit parameter assignments.
This commit is contained in:
@@ -350,46 +350,46 @@ public class CommonUtil
|
||||
|
||||
/**
|
||||
* Re-Maps a value from one range to another.
|
||||
* @param input
|
||||
* @param inputValue
|
||||
* @param inputMin
|
||||
* @param inputMax
|
||||
* @param outputMin
|
||||
* @param outputMax
|
||||
* @return The mapped value
|
||||
*/
|
||||
public static int map(int input, int inputMin, int inputMax, int outputMin, int outputMax)
|
||||
public static int map(int inputValue, int inputMin, int inputMax, int outputMin, int outputMax)
|
||||
{
|
||||
input = constrain(input, inputMin, inputMax);
|
||||
final int input = constrain(inputValue, inputMin, inputMax);
|
||||
return (((input - inputMin) * (outputMax - outputMin)) / (inputMax - inputMin)) + outputMin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-Maps a value from one range to another.
|
||||
* @param input
|
||||
* @param inputValue
|
||||
* @param inputMin
|
||||
* @param inputMax
|
||||
* @param outputMin
|
||||
* @param outputMax
|
||||
* @return The mapped value
|
||||
*/
|
||||
public static long map(long input, long inputMin, long inputMax, long outputMin, long outputMax)
|
||||
public static long map(long inputValue, long inputMin, long inputMax, long outputMin, long outputMax)
|
||||
{
|
||||
input = constrain(input, inputMin, inputMax);
|
||||
final long input = constrain(inputValue, inputMin, inputMax);
|
||||
return (((input - inputMin) * (outputMax - outputMin)) / (inputMax - inputMin)) + outputMin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-Maps a value from one range to another.
|
||||
* @param input
|
||||
* @param inputValue
|
||||
* @param inputMin
|
||||
* @param inputMax
|
||||
* @param outputMin
|
||||
* @param outputMax
|
||||
* @return The mapped value
|
||||
*/
|
||||
public static double map(double input, double inputMin, double inputMax, double outputMin, double outputMax)
|
||||
public static double map(double inputValue, double inputMin, double inputMax, double outputMin, double outputMax)
|
||||
{
|
||||
input = constrain(input, inputMin, inputMax);
|
||||
final double input = constrain(inputValue, inputMin, inputMax);
|
||||
return (((input - inputMin) * (outputMax - outputMin)) / (inputMax - inputMin)) + outputMin;
|
||||
}
|
||||
|
||||
|
@@ -59,12 +59,14 @@ public class HexUtils
|
||||
/**
|
||||
* Method to generate the hexadecimal character presentation of a byte
|
||||
* @param data byte to generate the hexadecimal character presentation from
|
||||
* @param dstHexChars the char array the hexadecimal character presentation should be copied to, if this is null, dstOffset is ignored and a new char array with 2 elements is created
|
||||
* @param dstOffset offset at which the hexadecimal character presentation is copied to dstHexChars
|
||||
* @param dstHexCharsValue the char array the hexadecimal character presentation should be copied to, if this is null, dstOffset is ignored and a new char array with 2 elements is created
|
||||
* @param dstOffsetValue offset at which the hexadecimal character presentation is copied to dstHexChars
|
||||
* @return the char array the hexadecimal character presentation was copied to
|
||||
*/
|
||||
public static char[] b2HexChars(byte data, char[] dstHexChars, int dstOffset)
|
||||
public static char[] b2HexChars(byte data, char[] dstHexCharsValue, int dstOffsetValue)
|
||||
{
|
||||
char[] dstHexChars = dstHexCharsValue;
|
||||
int dstOffset = dstOffsetValue;
|
||||
if (dstHexChars == null)
|
||||
{
|
||||
dstHexChars = new char[2];
|
||||
@@ -92,12 +94,14 @@ public class HexUtils
|
||||
/**
|
||||
* Method to generate the hexadecimal character presentation of an integer
|
||||
* @param data integer to generate the hexadecimal character presentation from
|
||||
* @param dstHexChars the char array the hexadecimal character presentation should be copied to, if this is null, dstOffset is ignored and a new char array with 8 elements is created
|
||||
* @param dstOffset offset at which the hexadecimal character presentation is copied to dstHexChars
|
||||
* @param dstHexCharsValue the char array the hexadecimal character presentation should be copied to, if this is null, dstOffset is ignored and a new char array with 8 elements is created
|
||||
* @param dstOffsetValue offset at which the hexadecimal character presentation is copied to dstHexChars
|
||||
* @return the char array the hexadecimal character presentation was copied to
|
||||
*/
|
||||
public static char[] int2HexChars(int data, char[] dstHexChars, int dstOffset)
|
||||
public static char[] int2HexChars(int data, char[] dstHexCharsValue, int dstOffsetValue)
|
||||
{
|
||||
char[] dstHexChars = dstHexCharsValue;
|
||||
int dstOffset = dstOffsetValue;
|
||||
if (dstHexChars == null)
|
||||
{
|
||||
dstHexChars = new char[8];
|
||||
@@ -108,6 +112,7 @@ public class HexUtils
|
||||
b2HexChars((byte) ((data & 0x00FF0000) >> 16), dstHexChars, dstOffset + 2);
|
||||
b2HexChars((byte) ((data & 0x0000FF00) >> 8), dstHexChars, dstOffset + 4);
|
||||
b2HexChars((byte) (data & 0x000000FF), dstHexChars, dstOffset + 6);
|
||||
|
||||
return dstHexChars;
|
||||
}
|
||||
|
||||
@@ -129,12 +134,14 @@ public class HexUtils
|
||||
* @param data byte array to generate the hexadecimal character presentation from
|
||||
* @param offset offset where to start in data array
|
||||
* @param len number of bytes to generate the hexadecimal character presentation from
|
||||
* @param dstHexChars the char array the hexadecimal character presentation should be copied to, if this is null, dstOffset is ignored and a new char array with len*2 elements is created
|
||||
* @param dstOffset offset at which the hexadecimal character presentation is copied to dstHexChars
|
||||
* @param dstHexCharsValue the char array the hexadecimal character presentation should be copied to, if this is null, dstOffset is ignored and a new char array with len*2 elements is created
|
||||
* @param dstOffsetValue offset at which the hexadecimal character presentation is copied to dstHexChars
|
||||
* @return the char array the hexadecimal character presentation was copied to
|
||||
*/
|
||||
public static char[] bArr2HexChars(byte[] data, int offset, int len, char[] dstHexChars, int dstOffset)
|
||||
public static char[] bArr2HexChars(byte[] data, int offset, int len, char[] dstHexCharsValue, int dstOffsetValue)
|
||||
{
|
||||
char[] dstHexChars = dstHexCharsValue;
|
||||
int dstOffset = dstOffsetValue;
|
||||
if (dstHexChars == null)
|
||||
{
|
||||
dstHexChars = new char[len * 2];
|
||||
@@ -157,8 +164,10 @@ public class HexUtils
|
||||
return bArr2AsciiChars(data, offset, len, new char[len], 0);
|
||||
}
|
||||
|
||||
public static char[] bArr2AsciiChars(byte[] data, int offset, int len, char[] dstAsciiChars, int dstOffset)
|
||||
public static char[] bArr2AsciiChars(byte[] data, int offset, int len, char[] dstAsciiCharsValue, int dstOffsetValue)
|
||||
{
|
||||
char[] dstAsciiChars = dstAsciiCharsValue;
|
||||
int dstOffset = dstOffsetValue;
|
||||
if (dstAsciiChars == null)
|
||||
{
|
||||
dstAsciiChars = new char[len];
|
||||
|
@@ -1130,6 +1130,7 @@ public class BlowfishEngine
|
||||
* @param xr
|
||||
* @param table
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
private void processTable(int xl, int xr, int[] table)
|
||||
{
|
||||
final int size = table.length;
|
||||
|
@@ -499,9 +499,9 @@ public class GameServer
|
||||
INSTANCE = new GameServer();
|
||||
}
|
||||
|
||||
private void printSection(String s)
|
||||
private void printSection(String section)
|
||||
{
|
||||
s = "=[ " + s + " ]";
|
||||
String s = "=[ " + section + " ]";
|
||||
while (s.length() < 61)
|
||||
{
|
||||
s = "-" + s;
|
||||
|
@@ -99,11 +99,7 @@ public class Shutdown extends Thread
|
||||
*/
|
||||
public Shutdown(int seconds, boolean restart)
|
||||
{
|
||||
if (seconds < 0)
|
||||
{
|
||||
seconds = 0;
|
||||
}
|
||||
_secondsShut = seconds;
|
||||
_secondsShut = Math.max(0, seconds);
|
||||
_shutdownMode = restart ? GM_RESTART : GM_SHUTDOWN;
|
||||
}
|
||||
|
||||
|
@@ -423,13 +423,14 @@ public abstract class AbstractAI implements Ctrl
|
||||
* Move the actor to Pawn server side AND client side by sending Server->Client packet MoveToPawn <i>(broadcast)</i>.<br>
|
||||
* <font color=#FF0000><b><u>Caution</u>: Low level function, used by AI subclasses</b></font>
|
||||
* @param pawn
|
||||
* @param offset
|
||||
* @param offsetValue
|
||||
*/
|
||||
public void moveToPawn(WorldObject pawn, int offset)
|
||||
public void moveToPawn(WorldObject pawn, int offsetValue)
|
||||
{
|
||||
// Check if actor can move
|
||||
if (!_actor.isMovementDisabled() && !_actor.isAttackingNow() && !_actor.isCastingNow())
|
||||
{
|
||||
int offset = offsetValue;
|
||||
if (offset < 10)
|
||||
{
|
||||
offset = 10;
|
||||
|
@@ -199,12 +199,13 @@ public class AttackableAI extends CreatureAI
|
||||
/**
|
||||
* Set the Intention of this CreatureAI and create an AI Task executed every 1s (call onEvtThink method) for this Attackable.<br>
|
||||
* <font color=#FF0000><b><u>Caution</u>: If actor _knowPlayer isn't EMPTY, AI_INTENTION_IDLE will be change in AI_INTENTION_ACTIVE</b></font>
|
||||
* @param intention The new Intention to set to the AI
|
||||
* @param newIntention The new Intention to set to the AI
|
||||
* @param args The first parameter of the Intention
|
||||
*/
|
||||
@Override
|
||||
synchronized void changeIntention(CtrlIntention intention, Object... args)
|
||||
synchronized void changeIntention(CtrlIntention newIntention, Object... args)
|
||||
{
|
||||
CtrlIntention intention = newIntention;
|
||||
if ((intention == AI_INTENTION_IDLE) || (intention == AI_INTENTION_ACTIVE))
|
||||
{
|
||||
// Check if actor is not dead
|
||||
|
@@ -945,10 +945,10 @@ public class CreatureAI extends AbstractAI
|
||||
* <li>PLayerAI, SummonAI</li>
|
||||
* </ul>
|
||||
* @param target The targeted WorldObject
|
||||
* @param offset The Interact area radius
|
||||
* @param offsetValue The Interact area radius
|
||||
* @return True if a movement must be done
|
||||
*/
|
||||
protected boolean maybeMoveToPawn(WorldObject target, int offset)
|
||||
protected boolean maybeMoveToPawn(WorldObject target, int offsetValue)
|
||||
{
|
||||
// Get the distance between the current position of the Creature and the target (x,y)
|
||||
if (target == null)
|
||||
@@ -956,12 +956,12 @@ public class CreatureAI extends AbstractAI
|
||||
LOGGER.warning("maybeMoveToPawn: target == NULL!");
|
||||
return false;
|
||||
}
|
||||
if (offset < 0)
|
||||
if (offsetValue < 0)
|
||||
{
|
||||
return false; // skill radius -1
|
||||
}
|
||||
|
||||
int offsetWithCollision = offset + _actor.getTemplate().getCollisionRadius();
|
||||
int offsetWithCollision = offsetValue + _actor.getTemplate().getCollisionRadius();
|
||||
if (target.isCreature())
|
||||
{
|
||||
offsetWithCollision += ((Creature) target).getTemplate().getCollisionRadius();
|
||||
@@ -1008,6 +1008,7 @@ public class CreatureAI extends AbstractAI
|
||||
}
|
||||
|
||||
stopFollow();
|
||||
int offset = offsetValue;
|
||||
if (target.isCreature() && !target.isDoor())
|
||||
{
|
||||
if (((Creature) target).isMoving())
|
||||
|
@@ -203,11 +203,12 @@ public class DoppelgangerAI extends CreatureAI
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveToPawn(WorldObject pawn, int offset)
|
||||
public void moveToPawn(WorldObject pawn, int offsetValue)
|
||||
{
|
||||
// Check if actor can move
|
||||
if (!_actor.isMovementDisabled() && (_actor.getMoveSpeed() > 0))
|
||||
{
|
||||
int offset = offsetValue;
|
||||
if (offset < 10)
|
||||
{
|
||||
offset = 10;
|
||||
|
@@ -103,7 +103,7 @@ public class ExperienceData implements IXmlReader
|
||||
{
|
||||
if (level > Config.PLAYER_MAXIMUM_LEVEL)
|
||||
{
|
||||
level = Config.PLAYER_MAXIMUM_LEVEL;
|
||||
return _expTable.get((int) Config.PLAYER_MAXIMUM_LEVEL);
|
||||
}
|
||||
return _expTable.get(level);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class ExperienceData implements IXmlReader
|
||||
{
|
||||
if (level > Config.PLAYER_MAXIMUM_LEVEL)
|
||||
{
|
||||
level = Config.PLAYER_MAXIMUM_LEVEL;
|
||||
return _traningRateTable.get((int) Config.PLAYER_MAXIMUM_LEVEL);
|
||||
}
|
||||
return _traningRateTable.get(level);
|
||||
}
|
||||
|
@@ -109,14 +109,15 @@ public class ExtendDropData implements IXmlReader
|
||||
StatSet statSet = null;
|
||||
List<Object> list = null;
|
||||
Object text = null;
|
||||
for (node = node.getFirstChild(); node != null; node = node.getNextSibling())
|
||||
Node n = node;
|
||||
for (n = n.getFirstChild(); n != null; n = n.getNextSibling())
|
||||
{
|
||||
final String nodeName = node.getNodeName();
|
||||
switch (node.getNodeName())
|
||||
final String nodeName = n.getNodeName();
|
||||
switch (n.getNodeName())
|
||||
{
|
||||
case "#text":
|
||||
{
|
||||
final String value = node.getNodeValue().trim();
|
||||
final String value = n.getNodeValue().trim();
|
||||
if (!value.isEmpty())
|
||||
{
|
||||
text = value;
|
||||
@@ -130,7 +131,7 @@ public class ExtendDropData implements IXmlReader
|
||||
list = new LinkedList<>();
|
||||
}
|
||||
|
||||
final Object value = parseValue(node);
|
||||
final Object value = parseValue(n);
|
||||
if (value != null)
|
||||
{
|
||||
list.add(value);
|
||||
@@ -139,7 +140,7 @@ public class ExtendDropData implements IXmlReader
|
||||
}
|
||||
default:
|
||||
{
|
||||
final Object value = parseValue(node);
|
||||
final Object value = parseValue(n);
|
||||
if (value != null)
|
||||
{
|
||||
if (statSet == null)
|
||||
@@ -156,7 +157,7 @@ public class ExtendDropData implements IXmlReader
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
throw new IllegalArgumentException("Text and list in same node are not allowed. Node[" + node + "]");
|
||||
throw new IllegalArgumentException("Text and list in same node are not allowed. Node[" + n + "]");
|
||||
}
|
||||
if (statSet != null)
|
||||
{
|
||||
@@ -171,7 +172,7 @@ public class ExtendDropData implements IXmlReader
|
||||
{
|
||||
if (list != null)
|
||||
{
|
||||
throw new IllegalArgumentException("Text and list in same node are not allowed. Node[" + node + "]");
|
||||
throw new IllegalArgumentException("Text and list in same node are not allowed. Node[" + n + "]");
|
||||
}
|
||||
if (statSet != null)
|
||||
{
|
||||
|
@@ -224,10 +224,10 @@ public class MultisellData implements IXmlReader
|
||||
* @param player
|
||||
* @param npc
|
||||
* @param inventoryOnly
|
||||
* @param ingredientMultiplier
|
||||
* @param productMultiplier
|
||||
* @param ingredientMultiplierValue
|
||||
* @param productMultiplierValue
|
||||
*/
|
||||
public void separateAndSend(int listId, PlayerInstance player, Npc npc, boolean inventoryOnly, double ingredientMultiplier, double productMultiplier)
|
||||
public void separateAndSend(int listId, PlayerInstance player, Npc npc, boolean inventoryOnly, double ingredientMultiplierValue, double productMultiplierValue)
|
||||
{
|
||||
final MultisellListHolder template = _multisells.get(listId);
|
||||
if (template == null)
|
||||
@@ -250,9 +250,8 @@ public class MultisellData implements IXmlReader
|
||||
}
|
||||
|
||||
// Check if ingredient/product multipliers are set, if not, set them to the template value.
|
||||
ingredientMultiplier = (Double.isNaN(ingredientMultiplier) ? template.getIngredientMultiplier() : ingredientMultiplier);
|
||||
productMultiplier = (Double.isNaN(productMultiplier) ? template.getProductMultiplier() : productMultiplier);
|
||||
|
||||
final double ingredientMultiplier = (Double.isNaN(ingredientMultiplierValue) ? template.getIngredientMultiplier() : ingredientMultiplierValue);
|
||||
final double productMultiplier = (Double.isNaN(productMultiplierValue) ? template.getProductMultiplier() : productMultiplierValue);
|
||||
final PreparedMultisellListHolder list = new PreparedMultisellListHolder(template, inventoryOnly, player.getInventory(), npc, ingredientMultiplier, productMultiplier);
|
||||
int index = 0;
|
||||
do
|
||||
@@ -262,6 +261,7 @@ public class MultisellData implements IXmlReader
|
||||
index += PAGE_SIZE;
|
||||
}
|
||||
while (index < list.getEntries().size());
|
||||
|
||||
player.setMultiSell(list);
|
||||
}
|
||||
|
||||
|
@@ -98,6 +98,7 @@ public class SendMessageLocalisationData implements IXmlReader
|
||||
// Consider using proper SystemMessages where possible.
|
||||
String[] searchMessage;
|
||||
String[] replacementMessage;
|
||||
String localisation = message;
|
||||
boolean found;
|
||||
for (Entry<String[], String[]> entry : localisations.entrySet())
|
||||
{
|
||||
@@ -107,7 +108,7 @@ public class SendMessageLocalisationData implements IXmlReader
|
||||
// Exact match.
|
||||
if (searchMessage.length == 1)
|
||||
{
|
||||
if (searchMessage[0].equals(message))
|
||||
if (searchMessage[0].equals(localisation))
|
||||
{
|
||||
return replacementMessage[0];
|
||||
}
|
||||
@@ -117,7 +118,7 @@ public class SendMessageLocalisationData implements IXmlReader
|
||||
found = true;
|
||||
for (String part : searchMessage)
|
||||
{
|
||||
if (!message.contains(part))
|
||||
if (!localisation.contains(part))
|
||||
{
|
||||
found = false;
|
||||
break;
|
||||
@@ -127,12 +128,13 @@ public class SendMessageLocalisationData implements IXmlReader
|
||||
{
|
||||
for (int i = 0; i < searchMessage.length; i++)
|
||||
{
|
||||
message = message.replace(searchMessage[i], replacementMessage[i]);
|
||||
localisation = localisation.replace(searchMessage[i], replacementMessage[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return localisation;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
|
@@ -446,7 +446,8 @@ public class SkillData implements IXmlReader
|
||||
|
||||
private NamedParamInfo parseNamedParamInfo(Node node, Map<String, Map<Integer, Map<Integer, Object>>> variableValues)
|
||||
{
|
||||
final NamedNodeMap attributes = node.getAttributes();
|
||||
Node n = node;
|
||||
final NamedNodeMap attributes = n.getAttributes();
|
||||
final String name = parseString(attributes, "name");
|
||||
final Integer level = parseInteger(attributes, "level");
|
||||
final Integer fromLevel = parseInteger(attributes, "fromLevel", level);
|
||||
@@ -455,11 +456,11 @@ public class SkillData implements IXmlReader
|
||||
final Integer fromSubLevel = parseInteger(attributes, "fromSubLevel", subLevel);
|
||||
final Integer toSubLevel = parseInteger(attributes, "toSubLevel", subLevel);
|
||||
final Map<Integer, Map<Integer, StatSet>> info = new HashMap<>();
|
||||
for (node = node.getFirstChild(); node != null; node = node.getNextSibling())
|
||||
for (n = n.getFirstChild(); n != null; n = n.getNextSibling())
|
||||
{
|
||||
if (!node.getNodeName().equals("#text"))
|
||||
if (!n.getNodeName().equals("#text"))
|
||||
{
|
||||
parseInfo(node, variableValues, info);
|
||||
parseInfo(n, variableValues, info);
|
||||
}
|
||||
}
|
||||
return new NamedParamInfo(name, fromLevel, toLevel, fromSubLevel, toSubLevel, info);
|
||||
@@ -491,23 +492,24 @@ public class SkillData implements IXmlReader
|
||||
|
||||
private Map<Integer, Map<Integer, Object>> parseValues(Node node)
|
||||
{
|
||||
Node n = node;
|
||||
final Map<Integer, Map<Integer, Object>> values = new HashMap<>();
|
||||
Object parsedValue = parseValue(node, true, false, Collections.emptyMap());
|
||||
Object parsedValue = parseValue(n, true, false, Collections.emptyMap());
|
||||
if (parsedValue != null)
|
||||
{
|
||||
values.computeIfAbsent(-1, k -> new HashMap<>()).put(-1, parsedValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (node = node.getFirstChild(); node != null; node = node.getNextSibling())
|
||||
for (n = n.getFirstChild(); n != null; n = n.getNextSibling())
|
||||
{
|
||||
if (node.getNodeName().equalsIgnoreCase("value"))
|
||||
if (n.getNodeName().equalsIgnoreCase("value"))
|
||||
{
|
||||
final NamedNodeMap attributes = node.getAttributes();
|
||||
final NamedNodeMap attributes = n.getAttributes();
|
||||
final Integer level = parseInteger(attributes, "level");
|
||||
if (level != null)
|
||||
{
|
||||
parsedValue = parseValue(node, false, false, Collections.emptyMap());
|
||||
parsedValue = parseValue(n, false, false, Collections.emptyMap());
|
||||
if (parsedValue != null)
|
||||
{
|
||||
final Integer subLevel = parseInteger(attributes, "subLevel", -1);
|
||||
@@ -533,7 +535,7 @@ public class SkillData implements IXmlReader
|
||||
{
|
||||
variables.put("base", Double.parseDouble(String.valueOf(base)));
|
||||
}
|
||||
parsedValue = parseValue(node, false, false, variables);
|
||||
parsedValue = parseValue(n, false, false, variables);
|
||||
if (parsedValue != null)
|
||||
{
|
||||
subValues.put(j, parsedValue);
|
||||
@@ -549,22 +551,23 @@ public class SkillData implements IXmlReader
|
||||
|
||||
Object parseValue(Node node, boolean blockValue, boolean parseAttributes, Map<String, Double> variables)
|
||||
{
|
||||
Node n = node;
|
||||
StatSet statSet = null;
|
||||
List<Object> list = null;
|
||||
Object text = null;
|
||||
if (parseAttributes && (!node.getNodeName().equals("value") || !blockValue) && (node.getAttributes().getLength() > 0))
|
||||
if (parseAttributes && (!n.getNodeName().equals("value") || !blockValue) && (n.getAttributes().getLength() > 0))
|
||||
{
|
||||
statSet = new StatSet();
|
||||
parseAttributes(node.getAttributes(), "", statSet, variables);
|
||||
parseAttributes(n.getAttributes(), "", statSet, variables);
|
||||
}
|
||||
for (node = node.getFirstChild(); node != null; node = node.getNextSibling())
|
||||
for (n = n.getFirstChild(); n != null; n = n.getNextSibling())
|
||||
{
|
||||
final String nodeName = node.getNodeName();
|
||||
switch (node.getNodeName())
|
||||
final String nodeName = n.getNodeName();
|
||||
switch (n.getNodeName())
|
||||
{
|
||||
case "#text":
|
||||
{
|
||||
final String value = node.getNodeValue().trim();
|
||||
final String value = n.getNodeValue().trim();
|
||||
if (!value.isEmpty())
|
||||
{
|
||||
text = parseNodeValue(value, variables);
|
||||
@@ -578,7 +581,7 @@ public class SkillData implements IXmlReader
|
||||
list = new LinkedList<>();
|
||||
}
|
||||
|
||||
final Object value = parseValue(node, false, true, variables);
|
||||
final Object value = parseValue(n, false, true, variables);
|
||||
if (value != null)
|
||||
{
|
||||
list.add(value);
|
||||
@@ -595,7 +598,7 @@ public class SkillData implements IXmlReader
|
||||
}
|
||||
default:
|
||||
{
|
||||
final Object value = parseValue(node, false, true, variables);
|
||||
final Object value = parseValue(n, false, true, variables);
|
||||
if (value != null)
|
||||
{
|
||||
if (statSet == null)
|
||||
@@ -612,7 +615,7 @@ public class SkillData implements IXmlReader
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
throw new IllegalArgumentException("Text and list in same node are not allowed. Node[" + node + "]");
|
||||
throw new IllegalArgumentException("Text and list in same node are not allowed. Node[" + n + "]");
|
||||
}
|
||||
if (statSet != null)
|
||||
{
|
||||
@@ -627,7 +630,7 @@ public class SkillData implements IXmlReader
|
||||
{
|
||||
if (list != null)
|
||||
{
|
||||
throw new IllegalArgumentException("Text and list in same node are not allowed. Node[" + node + "]");
|
||||
throw new IllegalArgumentException("Text and list in same node are not allowed. Node[" + n + "]");
|
||||
}
|
||||
if (statSet != null)
|
||||
{
|
||||
|
@@ -444,10 +444,11 @@ public class SkillTreeData implements IXmlReader
|
||||
final Map<Long, SkillLearn> skillTree = new HashMap<>();
|
||||
// Add all skills that belong to all classes.
|
||||
skillTree.putAll(_commonSkillTree);
|
||||
while ((classId != null) && (_classSkillTrees.get(classId) != null))
|
||||
ClassId currentClassId = classId;
|
||||
while ((currentClassId != null) && (_classSkillTrees.get(currentClassId) != null))
|
||||
{
|
||||
skillTree.putAll(_classSkillTrees.get(classId));
|
||||
classId = _parentClassMap.get(classId);
|
||||
skillTree.putAll(_classSkillTrees.get(currentClassId));
|
||||
currentClassId = _parentClassMap.get(currentClassId);
|
||||
}
|
||||
return skillTree;
|
||||
}
|
||||
|
@@ -193,14 +193,15 @@ public abstract class DocumentBase
|
||||
_tables.put(name, table);
|
||||
}
|
||||
|
||||
protected void parseTemplate(Node n, Object template)
|
||||
protected void parseTemplate(Node node, Object template)
|
||||
{
|
||||
Condition condition = null;
|
||||
n = n.getFirstChild();
|
||||
Node n = node.getFirstChild();
|
||||
if (n == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ("cond".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
condition = parseCondition(n.getFirstChild(), template);
|
||||
@@ -274,8 +275,9 @@ public abstract class DocumentBase
|
||||
}
|
||||
}
|
||||
|
||||
protected Condition parseCondition(Node n, Object template)
|
||||
protected Condition parseCondition(Node node, Object template)
|
||||
{
|
||||
Node n = node;
|
||||
while ((n != null) && (n.getNodeType() != Node.ELEMENT_NODE))
|
||||
{
|
||||
n = n.getNextSibling();
|
||||
@@ -323,12 +325,14 @@ public abstract class DocumentBase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return condition;
|
||||
}
|
||||
|
||||
protected Condition parseLogicAnd(Node n, Object template)
|
||||
protected Condition parseLogicAnd(Node node, Object template)
|
||||
{
|
||||
final ConditionLogicAnd cond = new ConditionLogicAnd();
|
||||
Node n = node;
|
||||
for (n = n.getFirstChild(); n != null; n = n.getNextSibling())
|
||||
{
|
||||
if (n.getNodeType() == Node.ELEMENT_NODE)
|
||||
@@ -343,9 +347,10 @@ public abstract class DocumentBase
|
||||
return cond;
|
||||
}
|
||||
|
||||
protected Condition parseLogicOr(Node n, Object template)
|
||||
protected Condition parseLogicOr(Node node, Object template)
|
||||
{
|
||||
final ConditionLogicOr cond = new ConditionLogicOr();
|
||||
Node n = node;
|
||||
for (n = n.getFirstChild(); n != null; n = n.getNextSibling())
|
||||
{
|
||||
if (n.getNodeType() == Node.ELEMENT_NODE)
|
||||
@@ -360,8 +365,9 @@ public abstract class DocumentBase
|
||||
return cond;
|
||||
}
|
||||
|
||||
protected Condition parseLogicNot(Node n, Object template)
|
||||
protected Condition parseLogicNot(Node node, Object template)
|
||||
{
|
||||
Node n = node;
|
||||
for (n = n.getFirstChild(); n != null; n = n.getNextSibling())
|
||||
{
|
||||
if (n.getNodeType() == Node.ELEMENT_NODE)
|
||||
|
@@ -102,8 +102,9 @@ public class DocumentItem extends DocumentBase implements IXmlReader
|
||||
}
|
||||
}
|
||||
|
||||
protected void parseItem(Node n) throws InvocationTargetException
|
||||
protected void parseItem(Node node) throws InvocationTargetException
|
||||
{
|
||||
Node n = node;
|
||||
final int itemId = Integer.parseInt(n.getAttributes().getNamedItem("id").getNodeValue());
|
||||
final String className = n.getAttributes().getNamedItem("type").getNodeValue();
|
||||
final String itemName = n.getAttributes().getNamedItem("name").getNodeValue();
|
||||
|
@@ -494,19 +494,26 @@ public class GeoEngine
|
||||
|
||||
/**
|
||||
* Simple check for origin to target visibility.
|
||||
* @param gox : origin X geodata coordinate
|
||||
* @param goy : origin Y geodata coordinate
|
||||
* @param goz : origin Z geodata coordinate
|
||||
* @param goxValue : origin X geodata coordinate
|
||||
* @param goyValue : origin Y geodata coordinate
|
||||
* @param gozValue : origin Z geodata coordinate
|
||||
* @param oheight : origin height (if instance of {@link Character})
|
||||
* @param gtx : target X geodata coordinate
|
||||
* @param gty : target Y geodata coordinate
|
||||
* @param gtz : target Z geodata coordinate
|
||||
* @param gtxValue : target X geodata coordinate
|
||||
* @param gtyValue : target Y geodata coordinate
|
||||
* @param gtzValue : target Z geodata coordinate
|
||||
* @param theight : target height (if instance of {@link Character})
|
||||
* @param instance
|
||||
* @return {@code boolean} : True, when target can be seen.
|
||||
*/
|
||||
private final boolean checkSee(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight, Instance instance)
|
||||
private final boolean checkSee(int goxValue, int goyValue, int gozValue, double oheight, int gtxValue, int gtyValue, int gtzValue, double theight, Instance instance)
|
||||
{
|
||||
int goz = gozValue;
|
||||
int gtz = gtzValue;
|
||||
int gox = goxValue;
|
||||
int goy = goyValue;
|
||||
int gtx = gtxValue;
|
||||
int gty = gtyValue;
|
||||
|
||||
// get line of sight Z coordinates
|
||||
double losoz = goz + ((oheight * Config.PART_OF_CHARACTER_HEIGHT) / 100);
|
||||
double lostz = gtz + ((theight * Config.PART_OF_CHARACTER_HEIGHT) / 100);
|
||||
|
@@ -167,10 +167,10 @@ final class GeoEnginePathfinding extends GeoEngine
|
||||
|
||||
/**
|
||||
* Create list of node locations as result of calculated buffer node tree.
|
||||
* @param target : the entry point
|
||||
* @param node : the entry point
|
||||
* @return List<NodeLoc> : list of node location
|
||||
*/
|
||||
private static List<Location> constructPath(Node target)
|
||||
private static List<Location> constructPath(Node node)
|
||||
{
|
||||
// create empty list
|
||||
final LinkedList<Location> list = new LinkedList<>();
|
||||
@@ -180,6 +180,7 @@ final class GeoEnginePathfinding extends GeoEngine
|
||||
int dy = 0;
|
||||
|
||||
// get target parent
|
||||
Node target = node;
|
||||
Node parent = target.getParent();
|
||||
|
||||
// while parent exists
|
||||
|
@@ -50,8 +50,9 @@ public class BypassHandler implements IHandler<IBypassHandler, String>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBypassHandler getHandler(String command)
|
||||
public IBypassHandler getHandler(String commandValue)
|
||||
{
|
||||
String command = commandValue;
|
||||
if (command.contains(" "))
|
||||
{
|
||||
command = command.substring(0, command.indexOf(' '));
|
||||
|
@@ -62,12 +62,13 @@ public class CastleManager implements InstanceListManager
|
||||
return findNearestCastle(obj, Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
public Castle findNearestCastle(WorldObject obj, long maxDistance)
|
||||
public Castle findNearestCastle(WorldObject obj, long maxDistanceValue)
|
||||
{
|
||||
Castle nearestCastle = getCastle(obj);
|
||||
if (nearestCastle == null)
|
||||
{
|
||||
double distance;
|
||||
long maxDistance = maxDistanceValue;
|
||||
for (Castle castle : _castles.values())
|
||||
{
|
||||
distance = castle.getDistance(obj);
|
||||
|
@@ -330,9 +330,9 @@ public class ClanEntryManager
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<PledgeWaitingInfo> getSortedWaitingList(int levelMin, int levelMax, int role, int sortBy, boolean descending)
|
||||
public List<PledgeWaitingInfo> getSortedWaitingList(int levelMin, int levelMax, int role, int sortByValue, boolean descending)
|
||||
{
|
||||
sortBy = CommonUtil.constrain(sortBy, 1, PLAYER_COMPARATOR.size() - 1);
|
||||
final int sortBy = CommonUtil.constrain(sortByValue, 1, PLAYER_COMPARATOR.size() - 1);
|
||||
|
||||
// TODO: Handle Role
|
||||
//@formatter:off
|
||||
@@ -373,9 +373,10 @@ public class ClanEntryManager
|
||||
return _clanList.values().stream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<PledgeRecruitInfo> getSortedClanList(int clanLevel, int karma, int sortBy, boolean descending)
|
||||
public List<PledgeRecruitInfo> getSortedClanList(int clanLevel, int karma, int sortByValue, boolean descending)
|
||||
{
|
||||
sortBy = CommonUtil.constrain(sortBy, 1, CLAN_COMPARATOR.size() - 1);
|
||||
final int sortBy = CommonUtil.constrain(sortByValue, 1, CLAN_COMPARATOR.size() - 1);
|
||||
|
||||
//@formatter:off
|
||||
return _clanList.values().stream()
|
||||
.filter((p -> (((clanLevel < 0) && (karma >= 0) && (karma != p.getKarma())) || ((clanLevel >= 0) && (karma < 0) && (clanLevel != (p.getClan() != null ? p.getClanLevel() : 0))) || ((clanLevel >= 0) && (karma >= 0) && ((clanLevel != (p.getClan() != null ? p.getClanLevel() : 0)) || (karma != p.getKarma()))))))
|
||||
|
@@ -42,11 +42,12 @@ public class FortManager implements InstanceListManager
|
||||
return findNearestFort(obj, Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
public Fort findNearestFort(WorldObject obj, long maxDistance)
|
||||
public Fort findNearestFort(WorldObject obj, long maxDistanceValue)
|
||||
{
|
||||
Fort nearestFort = getFort(obj);
|
||||
if (nearestFort == null)
|
||||
{
|
||||
long maxDistance = maxDistanceValue;
|
||||
for (Fort fort : _forts.values())
|
||||
{
|
||||
final double distance = fort.getDistance(obj);
|
||||
|
@@ -825,17 +825,17 @@ public class Party extends AbstractPlayerGroup
|
||||
* <li>Get the PlayerInstance owner of the ServitorInstance (if necessary)</li>
|
||||
* <li>Calculate the Experience and SP reward distribution rate</li>
|
||||
* <li>Add Experience and SP to the PlayerInstance</li><br>
|
||||
* @param xpReward The Experience reward to distribute
|
||||
* @param spReward The SP reward to distribute
|
||||
* @param xpRewardValue The Experience reward to distribute
|
||||
* @param spRewardValue The SP reward to distribute
|
||||
* @param rewardedMembers The list of PlayerInstance to reward
|
||||
* @param topLvl
|
||||
* @param target
|
||||
*/
|
||||
public void distributeXpAndSp(double xpReward, double spReward, List<PlayerInstance> rewardedMembers, int topLvl, Attackable target)
|
||||
public void distributeXpAndSp(double xpRewardValue, double spRewardValue, List<PlayerInstance> rewardedMembers, int topLvl, Attackable target)
|
||||
{
|
||||
final List<PlayerInstance> validMembers = getValidMembers(rewardedMembers, topLvl);
|
||||
xpReward *= getExpBonus(validMembers.size(), target.getInstanceWorld());
|
||||
spReward *= getSpBonus(validMembers.size(), target.getInstanceWorld());
|
||||
double xpReward = xpRewardValue * getExpBonus(validMembers.size(), target.getInstanceWorld());
|
||||
double spReward = spRewardValue * getSpBonus(validMembers.size(), target.getInstanceWorld());
|
||||
int sqLevelSum = 0;
|
||||
for (PlayerInstance member : validMembers)
|
||||
{
|
||||
@@ -881,10 +881,10 @@ public class Party extends AbstractPlayerGroup
|
||||
}
|
||||
}
|
||||
|
||||
private double calculateExpSpPartyCutoff(PlayerInstance player, int topLvl, double addExp, double addSp, boolean vit)
|
||||
private double calculateExpSpPartyCutoff(PlayerInstance player, int topLvl, double addExpValue, double addSpValue, boolean vit)
|
||||
{
|
||||
addExp *= Config.EXP_AMOUNT_MULTIPLIERS.getOrDefault(player.getClassId(), 1f);
|
||||
addSp *= Config.SP_AMOUNT_MULTIPLIERS.getOrDefault(player.getClassId(), 1f);
|
||||
final double addExp = addExpValue * Config.EXP_AMOUNT_MULTIPLIERS.getOrDefault(player.getClassId(), 1f);
|
||||
final double addSp = addSpValue * Config.SP_AMOUNT_MULTIPLIERS.getOrDefault(player.getClassId(), 1f);
|
||||
double xp = addExp;
|
||||
double sp = addSp;
|
||||
if (Config.PARTY_XP_CUTOFF_METHOD.equalsIgnoreCase("highfive"))
|
||||
|
@@ -48,7 +48,7 @@ public class Petition
|
||||
public Petition(PlayerInstance petitioner, String petitionText, int petitionType)
|
||||
{
|
||||
_id = IdFactory.getNextId();
|
||||
_type = PetitionType.values()[--petitionType];
|
||||
_type = PetitionType.values()[petitionType - 1];
|
||||
_content = petitionText;
|
||||
_petitioner = petitioner;
|
||||
}
|
||||
|
@@ -187,25 +187,28 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (x > World.MAP_MAX_X)
|
||||
int spawnX = x;
|
||||
if (spawnX > World.MAP_MAX_X)
|
||||
{
|
||||
x = World.MAP_MAX_X - 5000;
|
||||
spawnX = World.MAP_MAX_X - 5000;
|
||||
}
|
||||
if (x < World.MAP_MIN_X)
|
||||
if (spawnX < World.MAP_MIN_X)
|
||||
{
|
||||
x = World.MAP_MIN_X + 5000;
|
||||
spawnX = World.MAP_MIN_X + 5000;
|
||||
}
|
||||
if (y > World.MAP_MAX_Y)
|
||||
|
||||
int spawnY = y;
|
||||
if (spawnY > World.MAP_MAX_Y)
|
||||
{
|
||||
y = World.MAP_MAX_Y - 5000;
|
||||
spawnY = World.MAP_MAX_Y - 5000;
|
||||
}
|
||||
if (y < World.MAP_MIN_Y)
|
||||
if (spawnY < World.MAP_MIN_Y)
|
||||
{
|
||||
y = World.MAP_MIN_Y + 5000;
|
||||
spawnY = World.MAP_MIN_Y + 5000;
|
||||
}
|
||||
|
||||
// Set the x,y,z position of the WorldObject. If flagged with _isSpawned, setXYZ will automatically update world region, so avoid that.
|
||||
setXYZ(x, y, z);
|
||||
setXYZ(spawnX, spawnY, z);
|
||||
}
|
||||
|
||||
// Spawn and update its _worldregion
|
||||
@@ -502,24 +505,27 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
|
||||
|
||||
public void setXYZInvisible(int x, int y, int z)
|
||||
{
|
||||
if (x > World.MAP_MAX_X)
|
||||
int correctX = x;
|
||||
if (correctX > World.MAP_MAX_X)
|
||||
{
|
||||
x = World.MAP_MAX_X - 5000;
|
||||
correctX = World.MAP_MAX_X - 5000;
|
||||
}
|
||||
if (x < World.MAP_MIN_X)
|
||||
if (correctX < World.MAP_MIN_X)
|
||||
{
|
||||
x = World.MAP_MIN_X + 5000;
|
||||
}
|
||||
if (y > World.MAP_MAX_Y)
|
||||
{
|
||||
y = World.MAP_MAX_Y - 5000;
|
||||
}
|
||||
if (y < World.MAP_MIN_Y)
|
||||
{
|
||||
y = World.MAP_MIN_Y + 5000;
|
||||
correctX = World.MAP_MIN_X + 5000;
|
||||
}
|
||||
|
||||
setXYZ(x, y, z);
|
||||
int correctY = y;
|
||||
if (correctY > World.MAP_MAX_Y)
|
||||
{
|
||||
correctY = World.MAP_MAX_Y - 5000;
|
||||
}
|
||||
if (correctY < World.MAP_MIN_Y)
|
||||
{
|
||||
correctY = World.MAP_MIN_Y + 5000;
|
||||
}
|
||||
|
||||
setXYZ(correctX, correctY, z);
|
||||
setSpawned(false);
|
||||
}
|
||||
|
||||
|
@@ -665,12 +665,13 @@ public class Attackable extends Npc
|
||||
|
||||
/**
|
||||
* Add damage and hate to the attacker AggroInfo of the Attackable _aggroList.
|
||||
* @param attacker The Creature that gave damages to this Attackable
|
||||
* @param creature The Creature that gave damages to this Attackable
|
||||
* @param damage The number of damages given by the attacker Creature
|
||||
* @param aggro The hate (=damage) given by the attacker Creature
|
||||
* @param aggroValue The hate (=damage) given by the attacker Creature
|
||||
*/
|
||||
public void addDamageHate(Creature attacker, int damage, int aggro)
|
||||
public void addDamageHate(Creature creature, int damage, int aggroValue)
|
||||
{
|
||||
Creature attacker = creature;
|
||||
if ((attacker == null) || (attacker == this))
|
||||
{
|
||||
return;
|
||||
@@ -697,6 +698,7 @@ public class Attackable extends Npc
|
||||
// traps does not cause aggro
|
||||
// making this hack because not possible to determine if damage made by trap
|
||||
// so just check for triggered trap here
|
||||
int aggro = aggroValue;
|
||||
if ((targetPlayer == null) || (targetPlayer.getTrap() == null) || !targetPlayer.getTrap().isTriggered())
|
||||
{
|
||||
ai.addHate(aggro);
|
||||
@@ -744,8 +746,7 @@ public class Attackable extends Npc
|
||||
ai.addHate(amount);
|
||||
}
|
||||
|
||||
amount = getHating(mostHated);
|
||||
if (amount >= 0)
|
||||
if (getHating(mostHated) >= 0)
|
||||
{
|
||||
((AttackableAI) getAI()).setGlobalAggro(-25);
|
||||
clearAggroList();
|
||||
|
@@ -728,14 +728,20 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
* <li>Send a Server->Client packet TeleportToLocationt to the Creature AND to all PlayerInstance in its _KnownPlayers</li>
|
||||
* <li>Modify the position of the pet if necessary</li>
|
||||
* </ul>
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param heading
|
||||
* @param instance
|
||||
* @param xValue
|
||||
* @param yValue
|
||||
* @param zValue
|
||||
* @param headingValue
|
||||
* @param instanceValue
|
||||
*/
|
||||
public void teleToLocation(int x, int y, int z, int heading, Instance instance)
|
||||
public void teleToLocation(int xValue, int yValue, int zValue, int headingValue, Instance instanceValue)
|
||||
{
|
||||
int x = xValue;
|
||||
int y = yValue;
|
||||
int z = zValue;
|
||||
int heading = headingValue;
|
||||
Instance instance = instanceValue;
|
||||
|
||||
final LocationReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureTeleport(this, x, y, z, heading, instance), this, LocationReturn.class);
|
||||
if (term != null)
|
||||
{
|
||||
@@ -838,8 +844,10 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
teleToLocation(x, y, z, heading, randomOffset, getInstanceWorld());
|
||||
}
|
||||
|
||||
public void teleToLocation(int x, int y, int z, int heading, int randomOffset, Instance instance)
|
||||
public void teleToLocation(int xValue, int yValue, int z, int heading, int randomOffset, Instance instance)
|
||||
{
|
||||
int x = xValue;
|
||||
int y = yValue;
|
||||
if (Config.OFFSET_ON_TELEPORT_ENABLED && (randomOffset > 0))
|
||||
{
|
||||
x += Rnd.get(-randomOffset, randomOffset);
|
||||
@@ -1092,7 +1100,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
case TWOHANDCROSSBOW:
|
||||
{
|
||||
crossbow = true;
|
||||
// fallthough
|
||||
// fallthrough
|
||||
}
|
||||
case BOW:
|
||||
{
|
||||
@@ -1247,11 +1255,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
return attack;
|
||||
}
|
||||
|
||||
private Hit generateHit(Creature target, Weapon weapon, boolean shotConsumed, boolean halfDamage)
|
||||
private Hit generateHit(Creature target, Weapon weapon, boolean shotConsumedValue, boolean halfDamage)
|
||||
{
|
||||
int damage = 0;
|
||||
byte shld = 0;
|
||||
boolean crit = false;
|
||||
boolean shotConsumed = shotConsumedValue;
|
||||
final boolean miss = Formulas.calcHitMiss(this, target);
|
||||
if (!shotConsumed)
|
||||
{
|
||||
@@ -3152,9 +3161,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
{
|
||||
if ((object != null) && !object.isSpawned())
|
||||
{
|
||||
object = null;
|
||||
_target = null;
|
||||
return;
|
||||
}
|
||||
|
||||
_target = object;
|
||||
}
|
||||
|
||||
@@ -3205,12 +3214,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
* <li>AI : onIntentionMoveTo(Location), onIntentionPickUp(WorldObject), onIntentionInteract(WorldObject)</li>
|
||||
* <li>FollowTask</li>
|
||||
* </ul>
|
||||
* @param x The X position of the destination
|
||||
* @param y The Y position of the destination
|
||||
* @param z The Y position of the destination
|
||||
* @param offset The size of the interaction area of the Creature targeted
|
||||
* @param xValue The X position of the destination
|
||||
* @param yValue The Y position of the destination
|
||||
* @param zValue The Y position of the destination
|
||||
* @param offsetValue The size of the interaction area of the Creature targeted
|
||||
*/
|
||||
public void moveToLocation(int x, int y, int z, int offset)
|
||||
public void moveToLocation(int xValue, int yValue, int zValue, int offsetValue)
|
||||
{
|
||||
// Get the Move Speed of the Creature
|
||||
final double speed = _stat.getMoveSpeed();
|
||||
@@ -3219,6 +3228,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
return;
|
||||
}
|
||||
|
||||
int x = xValue;
|
||||
int y = yValue;
|
||||
int z = zValue;
|
||||
int offset = offsetValue;
|
||||
|
||||
// Get current position of the Creature
|
||||
final int curX = getX();
|
||||
final int curY = getY();
|
||||
@@ -3996,13 +4010,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
* <ul>
|
||||
* <li>PlayerInstance : Save update in the character_skills table of the database</li>
|
||||
* </ul>
|
||||
* @param newSkill The Skill to add to the Creature
|
||||
* @param skill The Skill to add to the Creature
|
||||
* @return The Skill replaced or null if just added a new Skill
|
||||
*/
|
||||
@Override
|
||||
public Skill addSkill(Skill newSkill)
|
||||
public Skill addSkill(Skill skill)
|
||||
{
|
||||
Skill oldSkill = null;
|
||||
Skill newSkill = skill;
|
||||
if (newSkill != null)
|
||||
{
|
||||
// Mobius: Keep sublevel on skill level increase.
|
||||
@@ -4364,7 +4379,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
_status.addStatusListener(object);
|
||||
}
|
||||
|
||||
public void doAttack(double damage, Creature target, Skill skill, boolean isDOT, boolean directlyToHp, boolean critical, boolean reflect)
|
||||
public void doAttack(double damageValue, Creature target, Skill skill, boolean isDOT, boolean directlyToHp, boolean critical, boolean reflect)
|
||||
{
|
||||
// Check if fake players should aggro each other.
|
||||
if (isFakePlayer() && !Config.FAKE_PLAYER_AGGRO_FPC && target.isFakePlayer())
|
||||
@@ -4382,6 +4397,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
getAI().clientStartAutoAttack();
|
||||
|
||||
// ImmobileDamageBonus and ImmobileDamageResist effect bonuses.
|
||||
double damage = damageValue;
|
||||
if (target.isImmobilized())
|
||||
{
|
||||
damage *= _stat.getValue(Stat.IMMOBILE_DAMAGE_BONUS, 1);
|
||||
@@ -4481,20 +4497,22 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
public void reduceCurrentHp(double value, Creature attacker, Skill skill)
|
||||
public void reduceCurrentHp(double amount, Creature attacker, Skill skill)
|
||||
{
|
||||
reduceCurrentHp(value, attacker, skill, false, false, false, false);
|
||||
reduceCurrentHp(amount, attacker, skill, false, false, false, false);
|
||||
}
|
||||
|
||||
public void reduceCurrentHp(double value, Creature attacker, Skill skill, boolean isDOT, boolean directlyToHp, boolean critical, boolean reflect)
|
||||
public void reduceCurrentHp(double amountValue, Creature attacker, Skill skill, boolean isDOT, boolean directlyToHp, boolean critical, boolean reflect)
|
||||
{
|
||||
double amount = amountValue;
|
||||
|
||||
// Notify of this attack only if there is an attacking creature.
|
||||
if (attacker != null)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureDamageDealt(attacker, this, value, skill, critical, isDOT, reflect), attacker);
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureDamageDealt(attacker, this, amount, skill, critical, isDOT, reflect), attacker);
|
||||
}
|
||||
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureDamageReceived(attacker, this, value, skill, critical, isDOT, reflect), this, DamageReturn.class);
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureDamageReceived(attacker, this, amount, skill, critical, isDOT, reflect), this, DamageReturn.class);
|
||||
if (term != null)
|
||||
{
|
||||
if (term.terminate())
|
||||
@@ -4503,14 +4521,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
}
|
||||
else if (term.override())
|
||||
{
|
||||
value = term.getDamage();
|
||||
amount = term.getDamage();
|
||||
}
|
||||
}
|
||||
|
||||
final double damageCap = _stat.getValue(Stat.DAMAGE_LIMIT);
|
||||
if (damageCap > 0)
|
||||
{
|
||||
value = Math.min(value, damageCap);
|
||||
amount = Math.min(amount, damageCap);
|
||||
}
|
||||
|
||||
// Calculate PvP/PvE damage received. It is a post-attack stat.
|
||||
@@ -4518,45 +4536,45 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
{
|
||||
if (attacker.isPlayable())
|
||||
{
|
||||
value *= (100 + Math.max(_stat.getValue(Stat.PVP_DAMAGE_TAKEN), -80)) / 100;
|
||||
amount *= (100 + Math.max(_stat.getValue(Stat.PVP_DAMAGE_TAKEN), -80)) / 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
value *= (100 + Math.max(_stat.getValue(Stat.PVE_DAMAGE_TAKEN), -80)) / 100;
|
||||
amount *= (100 + Math.max(_stat.getValue(Stat.PVE_DAMAGE_TAKEN), -80)) / 100;
|
||||
}
|
||||
|
||||
if (attacker.isRaid() || attacker.isRaidMinion())
|
||||
{
|
||||
value *= (100 + Math.max(_stat.getValue(Stat.PVE_DAMAGE_TAKEN_RAID), -80)) / 100;
|
||||
amount *= (100 + Math.max(_stat.getValue(Stat.PVE_DAMAGE_TAKEN_RAID), -80)) / 100;
|
||||
}
|
||||
else if (attacker.isMonster())
|
||||
{
|
||||
value *= (100 + Math.max(_stat.getValue(Stat.PVE_DAMAGE_TAKEN_MONSTER), -80)) / 100;
|
||||
amount *= (100 + Math.max(_stat.getValue(Stat.PVE_DAMAGE_TAKEN_MONSTER), -80)) / 100;
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.CHAMPION_ENABLE && isChampion() && (Config.CHAMPION_HP != 0))
|
||||
{
|
||||
_status.reduceHp(value / Config.CHAMPION_HP, attacker, (skill == null) || !skill.isToggle(), isDOT, false);
|
||||
_status.reduceHp(amount / Config.CHAMPION_HP, attacker, (skill == null) || !skill.isToggle(), isDOT, false);
|
||||
}
|
||||
else if (isPlayer())
|
||||
{
|
||||
getActingPlayer().getStatus().reduceHp(value, attacker, (skill == null) || !skill.isToggle(), isDOT, false, directlyToHp);
|
||||
getActingPlayer().getStatus().reduceHp(amount, attacker, (skill == null) || !skill.isToggle(), isDOT, false, directlyToHp);
|
||||
}
|
||||
else
|
||||
{
|
||||
_status.reduceHp(value, attacker, (skill == null) || !skill.isToggle(), isDOT, false);
|
||||
_status.reduceHp(amount, attacker, (skill == null) || !skill.isToggle(), isDOT, false);
|
||||
}
|
||||
|
||||
if (attacker != null)
|
||||
{
|
||||
attacker.sendDamageMessage(this, skill, (int) value, critical, false);
|
||||
attacker.sendDamageMessage(this, skill, (int) amount, critical, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void reduceCurrentMp(double i)
|
||||
public void reduceCurrentMp(double amount)
|
||||
{
|
||||
_status.reduceMp(i);
|
||||
_status.reduceMp(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -5060,8 +5078,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public final List<SkillCaster> getSkillCasters(Predicate<SkillCaster> filter, Predicate<SkillCaster>... filters)
|
||||
public final List<SkillCaster> getSkillCasters(Predicate<SkillCaster> filterValue, Predicate<SkillCaster>... filters)
|
||||
{
|
||||
Predicate<SkillCaster> filter = filterValue;
|
||||
for (Predicate<SkillCaster> additionalFilter : filters)
|
||||
{
|
||||
filter = filter.and(additionalFilter);
|
||||
@@ -5070,8 +5089,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public final SkillCaster getSkillCaster(Predicate<SkillCaster> filter, Predicate<SkillCaster>... filters)
|
||||
public final SkillCaster getSkillCaster(Predicate<SkillCaster> filterValue, Predicate<SkillCaster>... filters)
|
||||
{
|
||||
Predicate<SkillCaster> filter = filterValue;
|
||||
for (Predicate<SkillCaster> additionalFilter : filters)
|
||||
{
|
||||
filter = filter.and(additionalFilter);
|
||||
|
@@ -107,8 +107,9 @@ public class FortCommanderInstance extends DefenderInstance
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDamage(Creature attacker, int damage, Skill skill)
|
||||
public void addDamage(Creature creature, int damage, Skill skill)
|
||||
{
|
||||
Creature attacker = creature;
|
||||
final Spawn spawn = getSpawn();
|
||||
if ((spawn != null) && canTalk())
|
||||
{
|
||||
|
@@ -149,13 +149,14 @@ public class GuardInstance extends Attackable
|
||||
* @param player The PlayerInstance that start an action on the GuardInstance
|
||||
*/
|
||||
@Override
|
||||
public void onAction(PlayerInstance player, boolean interact)
|
||||
public void onAction(PlayerInstance player, boolean interactValue)
|
||||
{
|
||||
if (!canTarget(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean interact = interactValue;
|
||||
if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_GUARDS_ENABLED && ((player.isGood() && getTemplate().isClan(Config.FACTION_EVIL_TEAM_NAME)) || (player.isEvil() && getTemplate().isClan(Config.FACTION_GOOD_TEAM_NAME))))
|
||||
{
|
||||
interact = false;
|
||||
@@ -213,6 +214,7 @@ public class GuardInstance extends Attackable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send a Server->Client ActionFailed to the PlayerInstance in order to avoid that the client wait another packet
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
|
@@ -802,9 +802,9 @@ public class PetInstance extends Summon
|
||||
}
|
||||
}
|
||||
|
||||
public void dropItemHere(ItemInstance dropit, boolean protect)
|
||||
public void dropItemHere(ItemInstance item, boolean protect)
|
||||
{
|
||||
dropit = _inventory.dropItem("Drop", dropit.getObjectId(), dropit.getCount(), getOwner(), this);
|
||||
final ItemInstance dropit = _inventory.dropItem("Drop", item.getObjectId(), item.getCount(), getOwner(), this);
|
||||
if (dropit != null)
|
||||
{
|
||||
if (protect)
|
||||
|
@@ -2024,13 +2024,15 @@ public class PlayerInstance extends Playable
|
||||
|
||||
/**
|
||||
* Set the reputation of the PlayerInstance and send a Server->Client packet StatusUpdate (broadcast).
|
||||
* @param reputation
|
||||
* @param value
|
||||
*/
|
||||
@Override
|
||||
public void setReputation(int reputation)
|
||||
public void setReputation(int value)
|
||||
{
|
||||
// Notify to scripts.
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerReputationChanged(this, getReputation(), reputation), this);
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerReputationChanged(this, getReputation(), value), this);
|
||||
|
||||
int reputation = value;
|
||||
if (reputation > Config.MAX_REPUTATION) // Max count of positive reputation
|
||||
{
|
||||
reputation = Config.MAX_REPUTATION;
|
||||
@@ -2700,12 +2702,7 @@ public class PlayerInstance extends Playable
|
||||
*/
|
||||
public void setExp(long exp)
|
||||
{
|
||||
if (exp < 0)
|
||||
{
|
||||
exp = 0;
|
||||
}
|
||||
|
||||
getStat().setExp(exp);
|
||||
getStat().setExp(Math.max(0, exp));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2746,12 +2743,7 @@ public class PlayerInstance extends Playable
|
||||
*/
|
||||
public void setSp(long sp)
|
||||
{
|
||||
if (sp < 0)
|
||||
{
|
||||
sp = 0;
|
||||
}
|
||||
|
||||
super.getStat().setSp(sp);
|
||||
super.getStat().setSp(Math.max(0, sp));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3423,8 +3415,8 @@ public class PlayerInstance extends Playable
|
||||
*/
|
||||
public boolean destroyItem(String process, ItemInstance item, long count, WorldObject reference, boolean sendMessage)
|
||||
{
|
||||
item = _inventory.destroyItem(process, item, count, this, reference);
|
||||
if (item == null)
|
||||
final ItemInstance destoyedItem = _inventory.destroyItem(process, item, count, this, reference);
|
||||
if (destoyedItem == null)
|
||||
{
|
||||
if (sendMessage)
|
||||
{
|
||||
@@ -3437,7 +3429,7 @@ public class PlayerInstance extends Playable
|
||||
if (!Config.FORCE_INVENTORY_UPDATE)
|
||||
{
|
||||
final InventoryUpdate playerIU = new InventoryUpdate();
|
||||
playerIU.addItem(item);
|
||||
playerIU.addItem(destoyedItem);
|
||||
sendInventoryUpdate(playerIU);
|
||||
}
|
||||
else
|
||||
@@ -3451,14 +3443,14 @@ public class PlayerInstance extends Playable
|
||||
if (count > 1)
|
||||
{
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.S2_S1_S_DISAPPEARED);
|
||||
sm.addItemName(item);
|
||||
sm.addItemName(destoyedItem);
|
||||
sm.addLong(count);
|
||||
sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.S1_DISAPPEARED);
|
||||
sm.addItemName(item);
|
||||
sm.addItemName(destoyedItem);
|
||||
sendPacket(sm);
|
||||
}
|
||||
}
|
||||
@@ -3695,8 +3687,8 @@ public class PlayerInstance extends Playable
|
||||
*/
|
||||
public boolean dropItem(String process, ItemInstance item, WorldObject reference, boolean sendMessage, boolean protectItem)
|
||||
{
|
||||
item = _inventory.dropItem(process, item, this, reference);
|
||||
if (item == null)
|
||||
final ItemInstance droppedItem = _inventory.dropItem(process, item, this, reference);
|
||||
if (droppedItem == null)
|
||||
{
|
||||
if (sendMessage)
|
||||
{
|
||||
@@ -3705,33 +3697,33 @@ public class PlayerInstance extends Playable
|
||||
return false;
|
||||
}
|
||||
|
||||
item.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20);
|
||||
if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable()))
|
||||
droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20);
|
||||
if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable()))
|
||||
{
|
||||
ItemsAutoDestroy.getInstance().addItem(item);
|
||||
ItemsAutoDestroy.getInstance().addItem(droppedItem);
|
||||
}
|
||||
|
||||
// protection against auto destroy dropped item
|
||||
if (Config.DESTROY_DROPPED_PLAYER_ITEM)
|
||||
{
|
||||
item.setProtected(item.isEquipable() && (!item.isEquipable() || !Config.DESTROY_EQUIPABLE_PLAYER_ITEM));
|
||||
droppedItem.setProtected(droppedItem.isEquipable() && (!droppedItem.isEquipable() || !Config.DESTROY_EQUIPABLE_PLAYER_ITEM));
|
||||
}
|
||||
else
|
||||
{
|
||||
item.setProtected(true);
|
||||
droppedItem.setProtected(true);
|
||||
}
|
||||
|
||||
// retail drop protection
|
||||
if (protectItem)
|
||||
{
|
||||
item.getDropProtection().protect(this);
|
||||
droppedItem.getDropProtection().protect(this);
|
||||
}
|
||||
|
||||
// Send inventory update packet
|
||||
if (!Config.FORCE_INVENTORY_UPDATE)
|
||||
{
|
||||
final InventoryUpdate playerIU = new InventoryUpdate();
|
||||
playerIU.addItem(item);
|
||||
playerIU.addItem(droppedItem);
|
||||
sendInventoryUpdate(playerIU);
|
||||
}
|
||||
else
|
||||
@@ -3743,7 +3735,7 @@ public class PlayerInstance extends Playable
|
||||
if (sendMessage)
|
||||
{
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_DROPPED_S1);
|
||||
sm.addItemName(item);
|
||||
sm.addItemName(droppedItem);
|
||||
sendPacket(sm);
|
||||
}
|
||||
|
||||
@@ -4610,11 +4602,12 @@ public class PlayerInstance extends Playable
|
||||
* <li>Add the PlayerInstance to the _statusListener of the new target if it's a Creature</li>
|
||||
* <li>Target the new WorldObject (add the target to the PlayerInstance _target, _knownObject and PlayerInstance to _KnownObject of the WorldObject)</li>
|
||||
* </ul>
|
||||
* @param newTarget The WorldObject to target
|
||||
* @param worldObject The WorldObject to target
|
||||
*/
|
||||
@Override
|
||||
public void setTarget(WorldObject newTarget)
|
||||
public void setTarget(WorldObject worldObject)
|
||||
{
|
||||
WorldObject newTarget = worldObject;
|
||||
if (newTarget != null)
|
||||
{
|
||||
final boolean isInParty = (newTarget.isPlayer() && isInParty() && _party.containsPlayer(newTarget.getActingPlayer()));
|
||||
@@ -8253,32 +8246,34 @@ public class PlayerInstance extends Playable
|
||||
@Override
|
||||
public boolean useMagic(Skill skill, ItemInstance item, boolean forceUse, boolean dontMove)
|
||||
{
|
||||
Skill usedSkill = skill;
|
||||
|
||||
// Passive skills cannot be used.
|
||||
if (skill.isPassive())
|
||||
if (usedSkill.isPassive())
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return false;
|
||||
}
|
||||
|
||||
// If Alternate rule Karma punishment is set to true, forbid skill Return to player with Karma
|
||||
if (!Config.ALT_GAME_KARMA_PLAYER_CAN_TELEPORT && (getReputation() < 0) && skill.hasEffectType(EffectType.TELEPORT))
|
||||
if (!Config.ALT_GAME_KARMA_PLAYER_CAN_TELEPORT && (getReputation() < 0) && usedSkill.hasEffectType(EffectType.TELEPORT))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return false;
|
||||
}
|
||||
|
||||
// players mounted on pets cannot use any toggle skills
|
||||
if (skill.isToggle() && isMounted())
|
||||
if (usedSkill.isToggle() && isMounted())
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Support for wizard skills with stances (Fire, Water, Wind, Earth)
|
||||
final Skill attachedSkill = skill.getAttachedSkill(this);
|
||||
final Skill attachedSkill = usedSkill.getAttachedSkill(this);
|
||||
if (attachedSkill != null)
|
||||
{
|
||||
skill = attachedSkill;
|
||||
usedSkill = attachedSkill;
|
||||
}
|
||||
|
||||
// Alter skills
|
||||
@@ -8291,7 +8286,7 @@ public class PlayerInstance extends Playable
|
||||
// ************************************* Check Player State *******************************************
|
||||
|
||||
// Abnormal effects(ex : Stun, Sleep...) are checked in Creature useMagic()
|
||||
if (!skill.canCastWhileDisabled() && (isControlBlocked() || hasBlockActions()))
|
||||
if (!usedSkill.canCastWhileDisabled() && (isControlBlocked() || hasBlockActions()))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return false;
|
||||
@@ -8305,7 +8300,7 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
|
||||
// Check if fishing and trying to use non-fishing skills.
|
||||
if (isFishing() && !skill.hasEffectType(EffectType.FISHING, EffectType.FISHING_START))
|
||||
if (isFishing() && !usedSkill.hasEffectType(EffectType.FISHING, EffectType.FISHING_START))
|
||||
{
|
||||
sendPacket(SystemMessageId.ONLY_FISHING_SKILLS_MAY_BE_USED_AT_THIS_TIME);
|
||||
return false;
|
||||
@@ -8318,32 +8313,32 @@ public class PlayerInstance extends Playable
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isSkillDisabled(skill))
|
||||
if (isSkillDisabled(usedSkill))
|
||||
{
|
||||
final SystemMessage sm;
|
||||
if (hasSkillReuse(skill.getReuseHashCode()))
|
||||
if (hasSkillReuse(usedSkill.getReuseHashCode()))
|
||||
{
|
||||
final int remainingTime = (int) (getSkillRemainingReuseTime(skill.getReuseHashCode()) / 1000);
|
||||
final int remainingTime = (int) (getSkillRemainingReuseTime(usedSkill.getReuseHashCode()) / 1000);
|
||||
final int hours = remainingTime / 3600;
|
||||
final int minutes = (remainingTime % 3600) / 60;
|
||||
final int seconds = (remainingTime % 60);
|
||||
if (hours > 0)
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.THERE_ARE_S2_HR_S3_MIN_AND_S4_SEC_REMAINING_IN_S1_S_RE_USE_TIME);
|
||||
sm.addSkillName(skill);
|
||||
sm.addSkillName(usedSkill);
|
||||
sm.addInt(hours);
|
||||
sm.addInt(minutes);
|
||||
}
|
||||
else if (minutes > 0)
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.THERE_ARE_S2_MIN_S3_SEC_REMAINING_IN_S1_S_RE_USE_TIME);
|
||||
sm.addSkillName(skill);
|
||||
sm.addSkillName(usedSkill);
|
||||
sm.addInt(minutes);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.THERE_ARE_S2_SEC_REMAINING_IN_S1_S_RE_USE_TIME);
|
||||
sm.addSkillName(skill);
|
||||
sm.addSkillName(usedSkill);
|
||||
}
|
||||
|
||||
sm.addInt(seconds);
|
||||
@@ -8351,11 +8346,11 @@ public class PlayerInstance extends Playable
|
||||
else
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.S1_IS_NOT_AVAILABLE_AT_THIS_TIME_BEING_PREPARED_FOR_REUSE);
|
||||
sm.addSkillName(skill);
|
||||
sm.addSkillName(usedSkill);
|
||||
}
|
||||
|
||||
// Don't send packet for Raise/Focus Shield if Final Ultimate Defense is active.
|
||||
if ((getEffectList().getBuffInfoBySkillId(10017) == null) && ((skill.getId() == 10020) || (skill.getId() == 10021)))
|
||||
if ((getEffectList().getBuffInfoBySkillId(10017) == null) && ((usedSkill.getId() == 10020) || (usedSkill.getId() == 10021)))
|
||||
{
|
||||
sendPacket(sm);
|
||||
return false;
|
||||
@@ -8371,20 +8366,20 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
|
||||
// Check if the skill type is toggle and disable it, unless the toggle is necessary to be on.
|
||||
if (skill.isToggle())
|
||||
if (usedSkill.isToggle())
|
||||
{
|
||||
if (isAffectedBySkill(skill.getId()))
|
||||
if (isAffectedBySkill(usedSkill.getId()))
|
||||
{
|
||||
if (!skill.isNecessaryToggle())
|
||||
if (!usedSkill.isNecessaryToggle())
|
||||
{
|
||||
stopSkillEffects(true, skill.getId());
|
||||
stopSkillEffects(true, usedSkill.getId());
|
||||
}
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return false;
|
||||
}
|
||||
else if (skill.getToggleGroupId() > 0)
|
||||
else if (usedSkill.getToggleGroupId() > 0)
|
||||
{
|
||||
getEffectList().stopAllTogglesOfGroup(skill.getToggleGroupId());
|
||||
getEffectList().stopAllTogglesOfGroup(usedSkill.getToggleGroupId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8398,9 +8393,9 @@ public class PlayerInstance extends Playable
|
||||
|
||||
// ************************************* Check Target *******************************************
|
||||
// Create and set a WorldObject containing the target of the skill
|
||||
final WorldObject target = skill.getTarget(this, forceUse, dontMove, true);
|
||||
final WorldObject target = usedSkill.getTarget(this, forceUse, dontMove, true);
|
||||
final Location worldPosition = _currentSkillWorldPosition;
|
||||
if ((skill.getTargetType() == TargetType.GROUND) && (worldPosition == null))
|
||||
if ((usedSkill.getTargetType() == TargetType.GROUND) && (worldPosition == null))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return false;
|
||||
@@ -8414,27 +8409,27 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
|
||||
// Check if all casting conditions are completed
|
||||
if (!skill.checkCondition(this, target))
|
||||
if (!usedSkill.checkCondition(this, target))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
||||
// Upon failed conditions, next action is called.
|
||||
if ((skill.getNextAction() != NextActionType.NONE) && (target != this) && target.isAutoAttackable(this) && ((getAI().getNextIntention() == null) || (getAI().getNextIntention().getCtrlIntention() != CtrlIntention.AI_INTENTION_MOVE_TO)))
|
||||
if ((usedSkill.getNextAction() != NextActionType.NONE) && (target != this) && target.isAutoAttackable(this) && ((getAI().getNextIntention() == null) || (getAI().getNextIntention().getCtrlIntention() != CtrlIntention.AI_INTENTION_MOVE_TO)))
|
||||
{
|
||||
if (skill.getNextAction() == NextActionType.ATTACK)
|
||||
if (usedSkill.getNextAction() == NextActionType.ATTACK)
|
||||
{
|
||||
getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
}
|
||||
else if (skill.getNextAction() == NextActionType.CAST)
|
||||
else if (usedSkill.getNextAction() == NextActionType.CAST)
|
||||
{
|
||||
getAI().setIntention(CtrlIntention.AI_INTENTION_CAST, skill, target, item, false, false);
|
||||
getAI().setIntention(CtrlIntention.AI_INTENTION_CAST, usedSkill, target, item, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
final boolean doubleCast = isAffected(EffectFlag.DOUBLE_CAST) && skill.canDoubleCast();
|
||||
final boolean doubleCast = isAffected(EffectFlag.DOUBLE_CAST) && usedSkill.canDoubleCast();
|
||||
|
||||
// If a skill is currently being used, queue this one if this is not the same
|
||||
// In case of double casting, check if both slots are occupied, then queue skill.
|
||||
@@ -8444,7 +8439,7 @@ public class PlayerInstance extends Playable
|
||||
if (item == null)
|
||||
{
|
||||
// Create a new SkillDat object and queue it in the player _queuedSkill
|
||||
setQueuedSkill(skill, item, forceUse, dontMove);
|
||||
setQueuedSkill(usedSkill, item, forceUse, dontMove);
|
||||
}
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return false;
|
||||
@@ -8456,7 +8451,7 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
|
||||
// Notify the AI with AI_INTENTION_CAST and target
|
||||
getAI().setIntention(CtrlIntention.AI_INTENTION_CAST, skill, target, item, forceUse, dontMove);
|
||||
getAI().setIntention(CtrlIntention.AI_INTENTION_CAST, usedSkill, target, item, forceUse, dontMove);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -40,19 +40,20 @@ public class PlayableStat extends CreatureStat
|
||||
super(player);
|
||||
}
|
||||
|
||||
public boolean addExp(long value)
|
||||
public boolean addExp(long amount)
|
||||
{
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(new OnPlayableExpChanged(getActiveChar(), getExp(), getExp() + value), getActiveChar(), TerminateReturn.class);
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(new OnPlayableExpChanged(getActiveChar(), getExp(), getExp() + amount), getActiveChar(), TerminateReturn.class);
|
||||
if ((term != null) && term.terminate())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (((getExp() + value) < 0) || ((value > 0) && (getExp() == (getExpForLevel(getMaxLevel()) - 1))))
|
||||
if (((getExp() + amount) < 0) || ((amount > 0) && (getExp() == (getExpForLevel(getMaxLevel()) - 1))))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
long value = amount;
|
||||
if ((getExp() + value) >= getExpForLevel(getMaxLevel()))
|
||||
{
|
||||
value = getExpForLevel(getMaxLevel()) - 1 - getExp();
|
||||
@@ -95,8 +96,9 @@ public class PlayableStat extends CreatureStat
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeExp(long value)
|
||||
public boolean removeExp(long amount)
|
||||
{
|
||||
long value = amount;
|
||||
if (((getExp() - value) < getExpForLevel(getLevel())) && (!Config.PLAYER_DELEVEL || (Config.PLAYER_DELEVEL && (getLevel() <= Config.DELEVEL_MINIMUM))))
|
||||
{
|
||||
value = getExp() - getExpForLevel(getLevel());
|
||||
@@ -146,8 +148,9 @@ public class PlayableStat extends CreatureStat
|
||||
return expRemoved || spRemoved;
|
||||
}
|
||||
|
||||
public boolean addLevel(byte value)
|
||||
public boolean addLevel(byte amount)
|
||||
{
|
||||
byte value = amount;
|
||||
if ((getLevel() + value) > (getMaxLevel() - 1))
|
||||
{
|
||||
if (getLevel() < (getMaxLevel() - 1))
|
||||
@@ -186,19 +189,21 @@ public class PlayableStat extends CreatureStat
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean addSp(long value)
|
||||
public boolean addSp(long amount)
|
||||
{
|
||||
if (value < 0)
|
||||
if (amount < 0)
|
||||
{
|
||||
LOGGER.warning("wrong usage");
|
||||
return false;
|
||||
}
|
||||
|
||||
final long currentSp = getSp();
|
||||
if (currentSp >= Config.MAX_SP)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
long value = amount;
|
||||
if (currentSp > (Config.MAX_SP - value))
|
||||
{
|
||||
value = Config.MAX_SP - currentSp;
|
||||
@@ -208,14 +213,15 @@ public class PlayableStat extends CreatureStat
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeSp(long value)
|
||||
public boolean removeSp(long amount)
|
||||
{
|
||||
final long currentSp = getSp();
|
||||
if (currentSp < value)
|
||||
if (currentSp < amount)
|
||||
{
|
||||
value = currentSp;
|
||||
setSp(getSp() - currentSp);
|
||||
return true;
|
||||
}
|
||||
setSp(getSp() - value);
|
||||
setSp(getSp() - amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -96,7 +96,7 @@ public class PlayerStat extends PlayableStat
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addExpAndSp(double addToExp, double addToSp, boolean useBonuses)
|
||||
public void addExpAndSp(double addToExpValue, double addToSpValue, boolean useBonuses)
|
||||
{
|
||||
final PlayerInstance player = getActiveChar();
|
||||
|
||||
@@ -106,6 +106,9 @@ public class PlayerStat extends PlayableStat
|
||||
return;
|
||||
}
|
||||
|
||||
double addToExp = addToExpValue;
|
||||
double addToSp = addToSpValue;
|
||||
|
||||
// Premium rates
|
||||
if (player.hasPremiumStatus())
|
||||
{
|
||||
@@ -407,18 +410,19 @@ public class PlayerStat extends PlayableStat
|
||||
@Override
|
||||
public void setLevel(byte value)
|
||||
{
|
||||
if (value > (ExperienceData.getInstance().getMaxLevel() - 1))
|
||||
byte level = value;
|
||||
if (level > (ExperienceData.getInstance().getMaxLevel() - 1))
|
||||
{
|
||||
value = (byte) (ExperienceData.getInstance().getMaxLevel() - 1);
|
||||
level = (byte) (ExperienceData.getInstance().getMaxLevel() - 1);
|
||||
}
|
||||
|
||||
if (getActiveChar().isSubClassActive())
|
||||
{
|
||||
getActiveChar().getSubClasses().get(getActiveChar().getClassIndex()).setLevel(value);
|
||||
getActiveChar().getSubClasses().get(getActiveChar().getClassIndex()).setLevel(level);
|
||||
}
|
||||
else
|
||||
{
|
||||
super.setLevel(value);
|
||||
super.setLevel(level);
|
||||
}
|
||||
|
||||
// Removed used by new Clan system.
|
||||
@@ -491,9 +495,9 @@ public class PlayerStat extends PlayableStat
|
||||
/*
|
||||
* Set current vitality points to this value if quiet = true - does not send system messages
|
||||
*/
|
||||
public void setVitalityPoints(int points, boolean quiet)
|
||||
public void setVitalityPoints(int value, boolean quiet)
|
||||
{
|
||||
points = Math.min(Math.max(points, MIN_VITALITY_POINTS), MAX_VITALITY_POINTS);
|
||||
final int points = Math.min(Math.max(value, MIN_VITALITY_POINTS), MAX_VITALITY_POINTS);
|
||||
if (points == getVitalityPoints())
|
||||
{
|
||||
return;
|
||||
@@ -534,13 +538,14 @@ public class PlayerStat extends PlayableStat
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void updateVitalityPoints(int points, boolean useRates, boolean quiet)
|
||||
public synchronized void updateVitalityPoints(int value, boolean useRates, boolean quiet)
|
||||
{
|
||||
if ((points == 0) || !Config.ENABLE_VITALITY)
|
||||
if ((value == 0) || !Config.ENABLE_VITALITY)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int points = value;
|
||||
if (useRates)
|
||||
{
|
||||
if (getActiveChar().isLucky())
|
||||
|
@@ -123,7 +123,8 @@ public class PlayerStatus extends PlayableStatus
|
||||
}
|
||||
}
|
||||
|
||||
int fullValue = (int) value;
|
||||
double amount = value;
|
||||
int fullValue = (int) amount;
|
||||
int tDmg = 0;
|
||||
int mpDam = 0;
|
||||
if ((attacker != null) && (attacker != getActiveChar()))
|
||||
@@ -159,27 +160,27 @@ public class PlayerStatus extends PlayableStatus
|
||||
final Summon summon = getActiveChar().getFirstServitor();
|
||||
if ((summon != null) && Util.checkIfInRange(1000, getActiveChar(), summon, true))
|
||||
{
|
||||
tDmg = ((int) value * (int) getActiveChar().getStat().getValue(Stat.TRANSFER_DAMAGE_SUMMON_PERCENT, 0)) / 100;
|
||||
tDmg = ((int) amount * (int) getActiveChar().getStat().getValue(Stat.TRANSFER_DAMAGE_SUMMON_PERCENT, 0)) / 100;
|
||||
|
||||
// Only transfer dmg up to current HP, it should not be killed
|
||||
tDmg = Math.min((int) summon.getCurrentHp() - 1, tDmg);
|
||||
if (tDmg > 0)
|
||||
{
|
||||
summon.reduceCurrentHp(tDmg, attacker, null);
|
||||
value -= tDmg;
|
||||
fullValue = (int) value; // reduce the announced value here as player will get a message about summon damage
|
||||
amount -= tDmg;
|
||||
fullValue = (int) amount; // reduce the announced value here as player will get a message about summon damage
|
||||
}
|
||||
}
|
||||
|
||||
mpDam = ((int) value * (int) getActiveChar().getStat().getValue(Stat.MANA_SHIELD_PERCENT, 0)) / 100;
|
||||
mpDam = ((int) amount * (int) getActiveChar().getStat().getValue(Stat.MANA_SHIELD_PERCENT, 0)) / 100;
|
||||
if (mpDam > 0)
|
||||
{
|
||||
mpDam = (int) (value - mpDam);
|
||||
mpDam = (int) (amount - mpDam);
|
||||
if (mpDam > getActiveChar().getCurrentMp())
|
||||
{
|
||||
getActiveChar().sendPacket(SystemMessageId.MP_BECAME_0_AND_THE_ARCANE_SHIELD_IS_DISAPPEARING);
|
||||
getActiveChar().stopSkillEffects(true, 1556);
|
||||
value = mpDam - getActiveChar().getCurrentMp();
|
||||
amount = mpDam - getActiveChar().getCurrentMp();
|
||||
getActiveChar().setCurrentMp(0);
|
||||
}
|
||||
else
|
||||
@@ -196,7 +197,7 @@ public class PlayerStatus extends PlayableStatus
|
||||
if ((caster != null) && (getActiveChar().getParty() != null) && Util.checkIfInRange(1000, getActiveChar(), caster, true) && !caster.isDead() && (getActiveChar() != caster) && getActiveChar().getParty().getMembers().contains(caster))
|
||||
{
|
||||
int transferDmg = 0;
|
||||
transferDmg = ((int) value * (int) getActiveChar().getStat().getValue(Stat.TRANSFER_DAMAGE_TO_PLAYER, 0)) / 100;
|
||||
transferDmg = ((int) amount * (int) getActiveChar().getStat().getValue(Stat.TRANSFER_DAMAGE_TO_PLAYER, 0)) / 100;
|
||||
transferDmg = Math.min((int) caster.getCurrentHp() - 1, transferDmg);
|
||||
if (transferDmg > 0)
|
||||
{
|
||||
@@ -225,22 +226,22 @@ public class PlayerStatus extends PlayableStatus
|
||||
if (membersInRange > 0)
|
||||
{
|
||||
caster.reduceCurrentHp(transferDmg / membersInRange, attacker, null);
|
||||
value -= transferDmg;
|
||||
fullValue = (int) value;
|
||||
amount -= transferDmg;
|
||||
fullValue = (int) amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!ignoreCP && (attacker.isPlayable() || attacker.isFakePlayer()))
|
||||
{
|
||||
if (_currentCp >= value)
|
||||
if (_currentCp >= amount)
|
||||
{
|
||||
setCurrentCp(_currentCp - value); // Set Cp to diff of Cp vs value
|
||||
value = 0; // No need to subtract anything from Hp
|
||||
setCurrentCp(_currentCp - amount); // Set Cp to diff of Cp vs value
|
||||
amount = 0; // No need to subtract anything from Hp
|
||||
}
|
||||
else
|
||||
{
|
||||
value -= _currentCp; // Get diff from value vs Cp; will apply diff to Hp
|
||||
amount -= _currentCp; // Get diff from value vs Cp; will apply diff to Hp
|
||||
setCurrentCp(0, false); // Set Cp to 0
|
||||
}
|
||||
}
|
||||
@@ -277,9 +278,9 @@ public class PlayerStatus extends PlayableStatus
|
||||
}
|
||||
}
|
||||
|
||||
if (value > 0)
|
||||
if (amount > 0)
|
||||
{
|
||||
double newHp = Math.max(getCurrentHp() - value, getActiveChar().isUndying() ? 1 : 0);
|
||||
double newHp = Math.max(getCurrentHp() - amount, getActiveChar().isUndying() ? 1 : 0);
|
||||
if (newHp <= 0)
|
||||
{
|
||||
if (getActiveChar().isInDuel())
|
||||
@@ -339,7 +340,7 @@ public class PlayerStatus extends PlayableStatus
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentCp(double newCp, boolean broadcastPacket)
|
||||
public void setCurrentCp(double value, boolean broadcastPacket)
|
||||
{
|
||||
// Get the Max CP of the Creature
|
||||
final int currentCp = (int) _currentCp;
|
||||
@@ -352,11 +353,7 @@ public class PlayerStatus extends PlayableStatus
|
||||
return;
|
||||
}
|
||||
|
||||
if (newCp < 0)
|
||||
{
|
||||
newCp = 0;
|
||||
}
|
||||
|
||||
final double newCp = Math.max(0, value);
|
||||
if (newCp >= maxCp)
|
||||
{
|
||||
// Set the RegenActive flag to false
|
||||
|
@@ -37,9 +37,8 @@ public class SiegeFlagStatus extends NpcStatus
|
||||
{
|
||||
if (getActiveChar().isAdvancedHeadquarter())
|
||||
{
|
||||
value /= 2.;
|
||||
super.reduceHp(value / 2, attacker, awake, isDOT, isHpConsumption);
|
||||
}
|
||||
|
||||
super.reduceHp(value, attacker, awake, isDOT, isHpConsumption);
|
||||
}
|
||||
|
||||
|
@@ -37,7 +37,7 @@ public class SummonStatus extends PlayableStatus
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reduceHp(double value, Creature attacker, boolean awake, boolean isDOT, boolean isHPConsumption)
|
||||
public void reduceHp(double amount, Creature attacker, boolean awake, boolean isDOT, boolean isHPConsumption)
|
||||
{
|
||||
if ((attacker == null) || getActiveChar().isDead())
|
||||
{
|
||||
@@ -50,6 +50,7 @@ public class SummonStatus extends PlayableStatus
|
||||
attackerPlayer.setDuelState(Duel.DUELSTATE_INTERRUPTED);
|
||||
}
|
||||
|
||||
double value = amount;
|
||||
final PlayerInstance caster = getActiveChar().getTransferingDamageTo();
|
||||
if (getActiveChar().getOwner().getParty() != null)
|
||||
{
|
||||
@@ -110,6 +111,7 @@ public class SummonStatus extends PlayableStatus
|
||||
value -= transferDmg;
|
||||
}
|
||||
}
|
||||
|
||||
super.reduceHp(value, attacker, awake, isDOT, isHPConsumption);
|
||||
}
|
||||
|
||||
|
@@ -950,13 +950,13 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
||||
return _collisionHeightGrown;
|
||||
}
|
||||
|
||||
public static boolean isAssignableTo(Class<?> sub, Class<?> clazz)
|
||||
public static boolean isAssignableTo(Class<?> subValue, Class<?> clazz)
|
||||
{
|
||||
// If clazz represents an interface
|
||||
if (clazz.isInterface())
|
||||
{
|
||||
// check if obj implements the clazz interface
|
||||
for (Class<?> interface1 : sub.getInterfaces())
|
||||
for (Class<?> interface1 : subValue.getInterfaces())
|
||||
{
|
||||
if (clazz.getName().equals(interface1.getName()))
|
||||
{
|
||||
@@ -966,13 +966,13 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
||||
}
|
||||
else
|
||||
{
|
||||
Class<?> sub = subValue;
|
||||
do
|
||||
{
|
||||
if (sub.getName().equals(clazz.getName()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
sub = sub.getSuperclass();
|
||||
}
|
||||
while (sub != null);
|
||||
|
@@ -98,9 +98,9 @@ public class SubClass
|
||||
{
|
||||
if (!_dualClass && (expValue > (ExperienceData.getInstance().getExpForLevel(MAX_LEVEL + 1) - 1)))
|
||||
{
|
||||
expValue = ExperienceData.getInstance().getExpForLevel(MAX_LEVEL + 1) - 1;
|
||||
_exp = ExperienceData.getInstance().getExpForLevel(MAX_LEVEL + 1) - 1;
|
||||
return;
|
||||
}
|
||||
|
||||
_exp = expValue;
|
||||
}
|
||||
|
||||
@@ -128,13 +128,14 @@ public class SubClass
|
||||
{
|
||||
if (!_dualClass && (levelValue > MAX_LEVEL))
|
||||
{
|
||||
levelValue = MAX_LEVEL;
|
||||
_level = MAX_LEVEL;
|
||||
return;
|
||||
}
|
||||
else if (levelValue < Config.BASE_SUBCLASS_LEVEL)
|
||||
{
|
||||
levelValue = Config.BASE_SUBCLASS_LEVEL;
|
||||
_level = Config.BASE_SUBCLASS_LEVEL;
|
||||
return;
|
||||
}
|
||||
|
||||
_level = levelValue;
|
||||
}
|
||||
}
|
||||
|
@@ -1075,8 +1075,9 @@ public class Clan implements IIdentifiable, INamable
|
||||
}
|
||||
}
|
||||
|
||||
private void storeNotice(String notice, boolean enabled)
|
||||
private void storeNotice(String noticeValue, boolean enabled)
|
||||
{
|
||||
String notice = noticeValue;
|
||||
if (notice == null)
|
||||
{
|
||||
notice = "";
|
||||
|
@@ -206,8 +206,9 @@ public class CubicInstance
|
||||
}
|
||||
}
|
||||
|
||||
private void tryToUseSkill(WorldObject target, CubicSkill cubicSkill)
|
||||
private void tryToUseSkill(WorldObject worldObject, CubicSkill cubicSkill)
|
||||
{
|
||||
WorldObject target = worldObject;
|
||||
final Skill skill = cubicSkill.getSkill();
|
||||
if ((_template.getTargetType() != CubicTargetType.MASTER) && !((_template.getTargetType() == CubicTargetType.BY_SKILL) && (cubicSkill.getTargetType() == CubicTargetType.MASTER)))
|
||||
{
|
||||
|
@@ -281,9 +281,9 @@ public class Castle extends AbstractResidence
|
||||
// This method add to the treasury
|
||||
/**
|
||||
* Add amount to castle instance's treasury (warehouse).
|
||||
* @param amount
|
||||
* @param amountValue
|
||||
*/
|
||||
public void addToTreasury(long amount)
|
||||
public void addToTreasury(long amountValue)
|
||||
{
|
||||
// check if owned
|
||||
if (_ownerId <= 0)
|
||||
@@ -291,6 +291,7 @@ public class Castle extends AbstractResidence
|
||||
return;
|
||||
}
|
||||
|
||||
long amount = amountValue;
|
||||
switch (getName().toLowerCase())
|
||||
{
|
||||
case "schuttgart":
|
||||
@@ -327,21 +328,23 @@ public class Castle extends AbstractResidence
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
addToTreasuryNoTax(amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add amount to castle instance's treasury (warehouse), no tax paying.
|
||||
* @param amount
|
||||
* @param amountValue
|
||||
* @return
|
||||
*/
|
||||
public boolean addToTreasuryNoTax(long amount)
|
||||
public boolean addToTreasuryNoTax(long amountValue)
|
||||
{
|
||||
if (_ownerId <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
long amount = amountValue;
|
||||
if (amount < 0)
|
||||
{
|
||||
amount *= -1;
|
||||
@@ -371,6 +374,7 @@ public class Castle extends AbstractResidence
|
||||
{
|
||||
LOGGER.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -187,10 +187,10 @@ public class Hero
|
||||
}
|
||||
}
|
||||
|
||||
private String calcFightTime(long fightTime)
|
||||
private String calcFightTime(long fightTimeValue)
|
||||
{
|
||||
final String format = String.format("%%0%dd", 2);
|
||||
fightTime /= 1000;
|
||||
final long fightTime = fightTimeValue / 1000;
|
||||
return String.format(format, (fightTime % 3600) / 60) + ":" + String.format(format, fightTime % 60);
|
||||
}
|
||||
|
||||
|
@@ -2188,9 +2188,9 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
|
||||
* Add a temporary spawn of the specified NPC.
|
||||
* @param summoner the NPC that requires this spawn
|
||||
* @param npcId the ID of the NPC to spawn
|
||||
* @param x the X coordinate of the spawn location
|
||||
* @param y the Y coordinate of the spawn location
|
||||
* @param z the Z coordinate (height) of the spawn location
|
||||
* @param xValue the X coordinate of the spawn location
|
||||
* @param yValue the Y coordinate of the spawn location
|
||||
* @param zValue the Z coordinate (height) of the spawn location
|
||||
* @param heading the heading of the NPC
|
||||
* @param randomOffset if {@code true}, adds +/- 50~100 to X/Y coordinates of the spawn location
|
||||
* @param despawnDelay time in milliseconds till the NPC is despawned (0 - only despawned on server shutdown)
|
||||
@@ -2201,17 +2201,19 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
|
||||
* @see #addSpawn(int, int, int, int, int, boolean, long)
|
||||
* @see #addSpawn(int, int, int, int, int, boolean, long, boolean)
|
||||
*/
|
||||
public static Npc addSpawn(Npc summoner, int npcId, int x, int y, int z, int heading, boolean randomOffset, long despawnDelay, boolean isSummonSpawn, int instance)
|
||||
public static Npc addSpawn(Npc summoner, int npcId, int xValue, int yValue, int zValue, int heading, boolean randomOffset, long despawnDelay, boolean isSummonSpawn, int instance)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Spawn spawn = new Spawn(npcId);
|
||||
if ((x == 0) && (y == 0))
|
||||
if ((xValue == 0) && (yValue == 0))
|
||||
{
|
||||
LOGGER.severe("addSpawn(): invalid spawn coordinates for NPC #" + npcId + "!");
|
||||
return null;
|
||||
}
|
||||
|
||||
int x = xValue;
|
||||
int y = yValue;
|
||||
if (randomOffset)
|
||||
{
|
||||
int offset = Rnd.get(50, 100);
|
||||
@@ -2230,7 +2232,7 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
|
||||
|
||||
spawn.setInstanceId(instance);
|
||||
spawn.setHeading(heading);
|
||||
spawn.setXYZ(x, y, z);
|
||||
spawn.setXYZ(x, y, zValue);
|
||||
spawn.stopRespawn();
|
||||
|
||||
final Npc npc = spawn.doSpawn(isSummonSpawn);
|
||||
@@ -2582,16 +2584,16 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
|
||||
* Give a reward to player using multipliers.
|
||||
* @param player the player to whom to give the item
|
||||
* @param itemId the ID of the item to give
|
||||
* @param count the amount of items to give
|
||||
* @param countValue the amount of items to give
|
||||
*/
|
||||
public static void rewardItems(PlayerInstance player, int itemId, long count)
|
||||
public static void rewardItems(PlayerInstance player, int itemId, long countValue)
|
||||
{
|
||||
if (player.isSimulatingTalking())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (count <= 0)
|
||||
if (countValue <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2602,6 +2604,7 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
|
||||
return;
|
||||
}
|
||||
|
||||
long count = countValue;
|
||||
try
|
||||
{
|
||||
if (itemId == Inventory.ADENA_ID)
|
||||
@@ -2872,29 +2875,29 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
|
||||
return true;
|
||||
}
|
||||
|
||||
minAmount *= Config.RATE_QUEST_DROP;
|
||||
maxAmount *= Config.RATE_QUEST_DROP;
|
||||
dropChance *= Config.RATE_QUEST_DROP; // TODO separate configs for rate and amount
|
||||
long minAmountWithBonus = (long) (minAmount * Config.RATE_QUEST_DROP);
|
||||
long maxAmountWithBonus = (long) (maxAmount * Config.RATE_QUEST_DROP);
|
||||
long dropChanceWithBonus = (long) (dropChance * Config.RATE_QUEST_DROP); // TODO separate configs for rate and amount
|
||||
if ((npc != null) && Config.CHAMPION_ENABLE && npc.isChampion())
|
||||
{
|
||||
if ((itemId == Inventory.ADENA_ID) || (itemId == Inventory.ANCIENT_ADENA_ID))
|
||||
{
|
||||
dropChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||
minAmount *= Config.CHAMPION_ADENAS_REWARDS_AMOUNT;
|
||||
maxAmount *= Config.CHAMPION_ADENAS_REWARDS_AMOUNT;
|
||||
dropChanceWithBonus *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||
minAmountWithBonus *= Config.CHAMPION_ADENAS_REWARDS_AMOUNT;
|
||||
maxAmountWithBonus *= Config.CHAMPION_ADENAS_REWARDS_AMOUNT;
|
||||
}
|
||||
else
|
||||
{
|
||||
dropChance *= Config.CHAMPION_REWARDS_CHANCE;
|
||||
minAmount *= Config.CHAMPION_REWARDS_AMOUNT;
|
||||
maxAmount *= Config.CHAMPION_REWARDS_AMOUNT;
|
||||
dropChanceWithBonus *= Config.CHAMPION_REWARDS_CHANCE;
|
||||
minAmountWithBonus *= Config.CHAMPION_REWARDS_AMOUNT;
|
||||
maxAmountWithBonus *= Config.CHAMPION_REWARDS_AMOUNT;
|
||||
}
|
||||
}
|
||||
|
||||
long amountToGive = (minAmount == maxAmount) ? minAmount : Rnd.get(minAmount, maxAmount);
|
||||
long amountToGive = (minAmountWithBonus == maxAmountWithBonus) ? minAmountWithBonus : Rnd.get(minAmountWithBonus, maxAmountWithBonus);
|
||||
final double random = Rnd.nextDouble();
|
||||
// Inventory slot check (almost useless for non-stacking items)
|
||||
if ((dropChance >= random) && (amountToGive > 0) && player.getInventory().validateCapacityByItemId(itemId))
|
||||
if ((dropChanceWithBonus >= random) && (amountToGive > 0) && player.getInventory().validateCapacityByItemId(itemId))
|
||||
{
|
||||
if ((limit > 0) && ((currentCount + amountToGive) > limit))
|
||||
{
|
||||
@@ -2932,10 +2935,10 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
|
||||
* Take an amount of a specified item from player's inventory.
|
||||
* @param player the player whose item to take
|
||||
* @param itemId the ID of the item to take
|
||||
* @param amount the amount to take
|
||||
* @param amountValue the amount to take
|
||||
* @return {@code true} if any items were taken, {@code false} otherwise
|
||||
*/
|
||||
public static boolean takeItems(PlayerInstance player, int itemId, long amount)
|
||||
public static boolean takeItems(PlayerInstance player, int itemId, long amountValue)
|
||||
{
|
||||
if (player.isSimulatingTalking())
|
||||
{
|
||||
@@ -2950,7 +2953,8 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
|
||||
}
|
||||
|
||||
// Tests on count value in order not to have negative value
|
||||
if ((amount < 0) || (amount > item.getCount()))
|
||||
long amount = amountValue;
|
||||
if ((amountValue < 0) || (amountValue > item.getCount()))
|
||||
{
|
||||
amount = item.getCount();
|
||||
}
|
||||
@@ -2967,6 +2971,7 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
|
||||
player.sendInventoryUpdate(iu);
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
return player.destroyItemByItemId("Quest", itemId, amount, player, true);
|
||||
}
|
||||
|
||||
|
@@ -212,11 +212,12 @@ public class EventDispatcher
|
||||
* @param listeners
|
||||
* @param event
|
||||
* @param returnBackClass
|
||||
* @param callback
|
||||
* @param callbackValue
|
||||
* @return
|
||||
*/
|
||||
private <T extends AbstractEventReturn> T notifyToListeners(Queue<AbstractEventListener> listeners, IBaseEvent event, Class<T> returnBackClass, T callback)
|
||||
private <T extends AbstractEventReturn> T notifyToListeners(Queue<AbstractEventListener> listeners, IBaseEvent event, Class<T> returnBackClass, T callbackValue)
|
||||
{
|
||||
T callback = callbackValue;
|
||||
for (AbstractEventListener listener : listeners)
|
||||
{
|
||||
try
|
||||
|
@@ -286,7 +286,7 @@ public class Fishing
|
||||
}
|
||||
}
|
||||
|
||||
private void reelIn(FishingEndReason reason, boolean consumeBait)
|
||||
private void reelIn(FishingEndReason reasonValue, boolean consumeBait)
|
||||
{
|
||||
if (!_isFishing)
|
||||
{
|
||||
@@ -295,6 +295,7 @@ public class Fishing
|
||||
|
||||
cancelTasks();
|
||||
|
||||
FishingEndReason reason = reasonValue;
|
||||
try
|
||||
{
|
||||
final ItemInstance bait = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
|
||||
|
@@ -457,11 +457,12 @@ public class Instance implements IIdentifiable, INamable
|
||||
|
||||
/**
|
||||
* @param groupName
|
||||
* @param filter
|
||||
* @param filterValue
|
||||
* @return {@code Stream<Npc>} of NPCs that is part of a group and matches filter specified
|
||||
*/
|
||||
public Stream<Npc> getStreamOfGroup(String groupName, Predicate<Npc> filter)
|
||||
public Stream<Npc> getStreamOfGroup(String groupName, Predicate<Npc> filterValue)
|
||||
{
|
||||
Predicate<Npc> filter = filterValue;
|
||||
if (filter == null)
|
||||
{
|
||||
filter = Objects::nonNull;
|
||||
|
@@ -69,8 +69,9 @@ public class AuctionDateGenerator
|
||||
return calcDestTime(_calendar.getTimeInMillis(), date, TimeUnit.MILLISECONDS.convert(_interval, TimeUnit.DAYS));
|
||||
}
|
||||
|
||||
private long calcDestTime(long time, long date, long add)
|
||||
private long calcDestTime(long timeValue, long date, long add)
|
||||
{
|
||||
long time = timeValue;
|
||||
if (time < date)
|
||||
{
|
||||
time += ((date - time) / add) * add;
|
||||
|
@@ -77,13 +77,14 @@ public abstract class ItemContainer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filter
|
||||
* @param filterValue
|
||||
* @param filters
|
||||
* @return the quantity of items in the inventory
|
||||
*/
|
||||
@SafeVarargs
|
||||
public final int getSize(Predicate<ItemInstance> filter, Predicate<ItemInstance>... filters)
|
||||
public final int getSize(Predicate<ItemInstance> filterValue, Predicate<ItemInstance>... filters)
|
||||
{
|
||||
Predicate<ItemInstance> filter = filterValue;
|
||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||
{
|
||||
filter = filter.and(additionalFilter);
|
||||
@@ -102,13 +103,14 @@ public abstract class ItemContainer
|
||||
|
||||
/**
|
||||
* Gets the items in inventory filtered by filter.
|
||||
* @param filter the filter
|
||||
* @param filterValue the filter
|
||||
* @param filters multiple filters
|
||||
* @return the filtered items in inventory
|
||||
*/
|
||||
@SafeVarargs
|
||||
public final Collection<ItemInstance> getItems(Predicate<ItemInstance> filter, Predicate<ItemInstance>... filters)
|
||||
public final Collection<ItemInstance> getItems(Predicate<ItemInstance> filterValue, Predicate<ItemInstance>... filters)
|
||||
{
|
||||
Predicate<ItemInstance> filter = filterValue;
|
||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||
{
|
||||
filter = filter.and(additionalFilter);
|
||||
@@ -196,32 +198,33 @@ public abstract class ItemContainer
|
||||
*/
|
||||
public ItemInstance addItem(String process, ItemInstance item, PlayerInstance actor, Object reference)
|
||||
{
|
||||
final ItemInstance olditem = getItemByItemId(item.getId());
|
||||
ItemInstance newItem = item;
|
||||
final ItemInstance olditem = getItemByItemId(newItem.getId());
|
||||
|
||||
// If stackable item is found in inventory just add to current quantity
|
||||
if ((olditem != null) && olditem.isStackable())
|
||||
{
|
||||
final long count = item.getCount();
|
||||
final long count = newItem.getCount();
|
||||
olditem.changeCount(process, count, actor, reference);
|
||||
olditem.setLastChange(ItemInstance.MODIFIED);
|
||||
|
||||
// And destroys the item
|
||||
ItemTable.getInstance().destroyItem(process, item, actor, reference);
|
||||
item.updateDatabase();
|
||||
item = olditem;
|
||||
ItemTable.getInstance().destroyItem(process, newItem, actor, reference);
|
||||
newItem.updateDatabase();
|
||||
newItem = olditem;
|
||||
}
|
||||
else // If item hasn't be found in inventory, create new one
|
||||
{
|
||||
item.setOwnerId(process, getOwnerId(), actor, reference);
|
||||
item.setItemLocation(getBaseLocation());
|
||||
item.setLastChange((ItemInstance.ADDED));
|
||||
newItem.setOwnerId(process, getOwnerId(), actor, reference);
|
||||
newItem.setItemLocation(getBaseLocation());
|
||||
newItem.setLastChange((ItemInstance.ADDED));
|
||||
|
||||
// Add item in inventory
|
||||
addItem(item);
|
||||
addItem(newItem);
|
||||
}
|
||||
|
||||
refreshWeight();
|
||||
return item;
|
||||
return newItem;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,13 +281,13 @@ public abstract class ItemContainer
|
||||
* Transfers item to another inventory
|
||||
* @param process string Identifier of process triggering this action
|
||||
* @param objectId Item Identifier of the item to be transfered
|
||||
* @param count Quantity of items to be transfered
|
||||
* @param countValue Quantity of items to be transfered
|
||||
* @param target the item container where the item will be moved.
|
||||
* @param actor Player requesting the item transfer
|
||||
* @param reference Object Object referencing current action like NPC selling item or previous item in transformation
|
||||
* @return ItemInstance corresponding to the new item or the updated item in inventory
|
||||
*/
|
||||
public ItemInstance transferItem(String process, int objectId, long count, ItemContainer target, PlayerInstance actor, Object reference)
|
||||
public ItemInstance transferItem(String process, int objectId, long countValue, ItemContainer target, PlayerInstance actor, Object reference)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
@@ -307,6 +310,7 @@ public abstract class ItemContainer
|
||||
}
|
||||
|
||||
// Check if requested quantity is available
|
||||
long count = countValue;
|
||||
if (count > sourceitem.getCount())
|
||||
{
|
||||
count = sourceitem.getCount();
|
||||
|
@@ -379,20 +379,20 @@ public class PlayerInventory extends Inventory
|
||||
@Override
|
||||
public ItemInstance addItem(String process, ItemInstance item, PlayerInstance actor, Object reference)
|
||||
{
|
||||
item = super.addItem(process, item, actor, reference);
|
||||
if (item != null)
|
||||
final ItemInstance addedItem = super.addItem(process, item, actor, reference);
|
||||
if (addedItem != null)
|
||||
{
|
||||
if ((item.getId() == ADENA_ID) && !item.equals(_adena))
|
||||
if ((addedItem.getId() == ADENA_ID) && !addedItem.equals(_adena))
|
||||
{
|
||||
_adena = item;
|
||||
_adena = addedItem;
|
||||
}
|
||||
else if ((item.getId() == ANCIENT_ADENA_ID) && !item.equals(_ancientAdena))
|
||||
else if ((addedItem.getId() == ANCIENT_ADENA_ID) && !addedItem.equals(_ancientAdena))
|
||||
{
|
||||
_ancientAdena = item;
|
||||
_ancientAdena = addedItem;
|
||||
}
|
||||
else if ((item.getId() == BEAUTY_TICKET_ID) && !item.equals(_beautyTickets))
|
||||
else if ((addedItem.getId() == BEAUTY_TICKET_ID) && !addedItem.equals(_beautyTickets))
|
||||
{
|
||||
_beautyTickets = item;
|
||||
_beautyTickets = addedItem;
|
||||
}
|
||||
|
||||
if (actor != null)
|
||||
@@ -401,7 +401,7 @@ public class PlayerInventory extends Inventory
|
||||
if (!Config.FORCE_INVENTORY_UPDATE)
|
||||
{
|
||||
final InventoryUpdate playerIU = new InventoryUpdate();
|
||||
playerIU.addItem(item);
|
||||
playerIU.addItem(addedItem);
|
||||
actor.sendInventoryUpdate(playerIU);
|
||||
}
|
||||
else
|
||||
@@ -410,11 +410,10 @@ public class PlayerInventory extends Inventory
|
||||
}
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemAdd(actor, item), actor, item.getItem());
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemAdd(actor, addedItem), actor, addedItem.getItem());
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
return addedItem;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -498,6 +497,7 @@ public class PlayerInventory extends Inventory
|
||||
public ItemInstance transferItem(String process, int objectId, long count, ItemContainer target, PlayerInstance actor, Object reference)
|
||||
{
|
||||
final ItemInstance item = super.transferItem(process, objectId, count, target, actor, reference);
|
||||
|
||||
if ((_adena != null) && ((_adena.getCount() <= 0) || (_adena.getOwnerId() != getOwnerId())))
|
||||
{
|
||||
_adena = null;
|
||||
@@ -510,18 +510,19 @@ public class PlayerInventory extends Inventory
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemTransfer(actor, item, target), item.getItem());
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInstance detachItem(String process, ItemInstance item, long count, ItemLocation newLocation, PlayerInstance actor, Object reference)
|
||||
{
|
||||
item = super.detachItem(process, item, count, newLocation, actor, reference);
|
||||
if ((item != null) && (actor != null))
|
||||
final ItemInstance detachedItem = super.detachItem(process, item, count, newLocation, actor, reference);
|
||||
if ((detachedItem != null) && (actor != null))
|
||||
{
|
||||
actor.sendItemList();
|
||||
}
|
||||
return item;
|
||||
return detachedItem;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -549,7 +550,8 @@ public class PlayerInventory extends Inventory
|
||||
@Override
|
||||
public ItemInstance destroyItem(String process, ItemInstance item, long count, PlayerInstance actor, Object reference)
|
||||
{
|
||||
item = super.destroyItem(process, item, count, actor, reference);
|
||||
final ItemInstance destroyedItem = super.destroyItem(process, item, count, actor, reference);
|
||||
|
||||
if ((_adena != null) && (_adena.getCount() <= 0))
|
||||
{
|
||||
_adena = null;
|
||||
@@ -561,11 +563,12 @@ public class PlayerInventory extends Inventory
|
||||
}
|
||||
|
||||
// Notify to scripts
|
||||
if (item != null)
|
||||
if (destroyedItem != null)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDestroy(actor, item), item.getItem());
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDestroy(actor, destroyedItem), destroyedItem.getItem());
|
||||
}
|
||||
return item;
|
||||
|
||||
return destroyedItem;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -611,7 +614,8 @@ public class PlayerInventory extends Inventory
|
||||
@Override
|
||||
public ItemInstance dropItem(String process, ItemInstance item, PlayerInstance actor, Object reference)
|
||||
{
|
||||
item = super.dropItem(process, item, actor, reference);
|
||||
final ItemInstance droppedItem = super.dropItem(process, item, actor, reference);
|
||||
|
||||
if ((_adena != null) && ((_adena.getCount() <= 0) || (_adena.getOwnerId() != getOwnerId())))
|
||||
{
|
||||
_adena = null;
|
||||
@@ -623,11 +627,12 @@ public class PlayerInventory extends Inventory
|
||||
}
|
||||
|
||||
// Notify to scripts
|
||||
if (item != null)
|
||||
if (droppedItem != null)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(actor, item, item.getLocation()), item.getItem());
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(actor, droppedItem, droppedItem.getLocation()), droppedItem.getItem());
|
||||
}
|
||||
return item;
|
||||
|
||||
return droppedItem;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -643,6 +648,7 @@ public class PlayerInventory extends Inventory
|
||||
public ItemInstance dropItem(String process, int objectId, long count, PlayerInstance actor, Object reference)
|
||||
{
|
||||
final ItemInstance item = super.dropItem(process, objectId, count, actor, reference);
|
||||
|
||||
if ((_adena != null) && ((_adena.getCount() <= 0) || (_adena.getOwnerId() != getOwnerId())))
|
||||
{
|
||||
_adena = null;
|
||||
|
@@ -86,20 +86,17 @@ public enum CrystalType
|
||||
return getLevel() < crystalType.getLevel();
|
||||
}
|
||||
|
||||
public CrystalType plusLevel(int level)
|
||||
public CrystalType plusLevel(int levelValue)
|
||||
{
|
||||
level += _level;
|
||||
|
||||
final int level = levelValue + _level;
|
||||
if (level >= CrystalType.R99.getLevel())
|
||||
{
|
||||
return CrystalType.R99;
|
||||
}
|
||||
|
||||
if (level <= CrystalType.NONE.getLevel())
|
||||
{
|
||||
return CrystalType.NONE;
|
||||
}
|
||||
|
||||
return getByLevel(level);
|
||||
}
|
||||
|
||||
@@ -112,7 +109,6 @@ public enum CrystalType
|
||||
return crystalType;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -195,7 +195,8 @@ public class QuestState
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
value = "";
|
||||
_vars.put(var, "");
|
||||
return;
|
||||
}
|
||||
|
||||
_vars.put(var, value);
|
||||
@@ -222,9 +223,9 @@ public class QuestState
|
||||
* If the key doesn't exist, the couple is added/created in the database</li>
|
||||
* <ul>
|
||||
* @param var String indicating the name of the variable for quest
|
||||
* @param value String indicating the value of the variable for quest
|
||||
* @param val String indicating the value of the variable for quest
|
||||
*/
|
||||
public void set(String var, String value)
|
||||
public void set(String var, String val)
|
||||
{
|
||||
if (_simulated)
|
||||
{
|
||||
@@ -236,6 +237,7 @@ public class QuestState
|
||||
_vars = new HashMap<>();
|
||||
}
|
||||
|
||||
String value = val;
|
||||
if (value == null)
|
||||
{
|
||||
value = "";
|
||||
|
@@ -133,7 +133,7 @@ public class SkillCaster implements Runnable
|
||||
/**
|
||||
* Checks if the caster can cast the specified skill on the given target with the selected parameters.
|
||||
* @param caster the creature trying to cast
|
||||
* @param target the selected target for cast
|
||||
* @param worldObject the selected target for cast
|
||||
* @param skill the skill being cast
|
||||
* @param item the reference item which requests the skill cast
|
||||
* @param castingType the type of casting
|
||||
@@ -142,7 +142,7 @@ public class SkillCaster implements Runnable
|
||||
* @param castTime custom cast time in milliseconds or -1 for default.
|
||||
* @return {@code SkillCaster} object containing casting data if casting has started or {@code null} if casting was not started.
|
||||
*/
|
||||
public static SkillCaster castSkill(Creature caster, WorldObject target, Skill skill, ItemInstance item, SkillCastingType castingType, boolean ctrlPressed, boolean shiftPressed, int castTime)
|
||||
public static SkillCaster castSkill(Creature caster, WorldObject worldObject, Skill skill, ItemInstance item, SkillCastingType castingType, boolean ctrlPressed, boolean shiftPressed, int castTime)
|
||||
{
|
||||
if ((caster == null) || (skill == null) || (castingType == null))
|
||||
{
|
||||
@@ -155,7 +155,7 @@ public class SkillCaster implements Runnable
|
||||
}
|
||||
|
||||
// Check true aiming target of the skill.
|
||||
target = skill.getTarget(caster, target, ctrlPressed, shiftPressed, false);
|
||||
final WorldObject target = skill.getTarget(caster, worldObject, ctrlPressed, shiftPressed, false);
|
||||
if (target == null)
|
||||
{
|
||||
return null;
|
||||
@@ -809,20 +809,21 @@ public class SkillCaster implements Runnable
|
||||
creature.disableSkill(skill, skill.getReuseDelay());
|
||||
}
|
||||
|
||||
WorldObject currentTarget = target;
|
||||
if (!ignoreTargetType)
|
||||
{
|
||||
final WorldObject objTarget = skill.getTarget(creature, false, false, false);
|
||||
if ((objTarget != null) && objTarget.isCreature())
|
||||
{
|
||||
target = objTarget;
|
||||
currentTarget = objTarget;
|
||||
}
|
||||
}
|
||||
|
||||
final WorldObject[] targets = skill.getTargetsAffected(creature, target).toArray(new WorldObject[0]);
|
||||
final WorldObject[] targets = skill.getTargetsAffected(creature, currentTarget).toArray(new WorldObject[0]);
|
||||
|
||||
if (!skill.isNotBroadcastable())
|
||||
{
|
||||
creature.broadcastPacket(new MagicSkillUse(creature, target, skill.getDisplayId(), skill.getLevel(), 0, 0));
|
||||
creature.broadcastPacket(new MagicSkillUse(creature, currentTarget, skill.getDisplayId(), skill.getLevel(), 0, 0));
|
||||
}
|
||||
|
||||
// Launch the magic skill and calculate its effects
|
||||
|
@@ -204,14 +204,16 @@ public class Formulas
|
||||
|
||||
/**
|
||||
* Returns true in case of critical hit
|
||||
* @param rate
|
||||
* @param rateValue
|
||||
* @param skill
|
||||
* @param creature
|
||||
* @param target
|
||||
* @return
|
||||
*/
|
||||
public static boolean calcCrit(double rate, Creature creature, Creature target, Skill skill)
|
||||
public static boolean calcCrit(double rateValue, Creature creature, Creature target, Skill skill)
|
||||
{
|
||||
double rate = rateValue;
|
||||
|
||||
if (skill != null)
|
||||
{
|
||||
// Magic Critical Rate.
|
||||
@@ -1238,7 +1240,7 @@ public class Formulas
|
||||
final double karmaLooseMul = KarmaData.getInstance().getMultiplier(player.getLevel());
|
||||
if (finalExp > 0) // Received exp
|
||||
{
|
||||
finalExp /= Config.RATE_KARMA_LOST;
|
||||
return (int) ((Math.abs(finalExp / Config.RATE_KARMA_LOST) / karmaLooseMul) / 30);
|
||||
}
|
||||
return (int) ((Math.abs(finalExp) / karmaLooseMul) / 30);
|
||||
}
|
||||
|
@@ -331,16 +331,16 @@ public enum Stat
|
||||
|
||||
public static Stat valueOfXml(String name)
|
||||
{
|
||||
name = name.intern();
|
||||
String internName = name.intern();
|
||||
for (Stat s : values())
|
||||
{
|
||||
if (s.getValue().equals(name))
|
||||
if (s.getValue().equals(internName))
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NoSuchElementException("Unknown name '" + name + "' for enum " + Stat.class.getSimpleName());
|
||||
throw new NoSuchElementException("Unknown name '" + internName + "' for enum " + Stat.class.getSimpleName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -81,7 +81,8 @@ public abstract class AbstractHtmlPacket implements IClientOutgoingPacket
|
||||
|
||||
if (!html.contains("<html") && !html.startsWith("..\\L2"))
|
||||
{
|
||||
html = "<html><body>" + html + "</body></html>";
|
||||
_html = "<html><body>" + html + "</body></html>";
|
||||
return;
|
||||
}
|
||||
|
||||
_html = html;
|
||||
|
@@ -46,9 +46,9 @@ public class MagicSkillLaunched implements IClientOutgoingPacket
|
||||
_castingType = castingType;
|
||||
if (targets == null)
|
||||
{
|
||||
targets = Collections.singletonList(creature);
|
||||
_targets = Collections.singletonList(creature);
|
||||
return;
|
||||
}
|
||||
|
||||
_targets = targets;
|
||||
}
|
||||
|
||||
|
@@ -151,16 +151,17 @@ public class ScriptEngineManager implements IXmlReader
|
||||
}
|
||||
}
|
||||
|
||||
public void executeScript(Path sourceFile) throws Exception
|
||||
public void executeScript(Path sourceFiles) throws Exception
|
||||
{
|
||||
if (!sourceFile.isAbsolute())
|
||||
Path path = sourceFiles;
|
||||
if (!path.isAbsolute())
|
||||
{
|
||||
sourceFile = SCRIPT_FOLDER.resolve(sourceFile);
|
||||
path = SCRIPT_FOLDER.resolve(path);
|
||||
}
|
||||
|
||||
sourceFile = sourceFile.toAbsolutePath();
|
||||
path = path.toAbsolutePath();
|
||||
|
||||
final Entry<Path, Throwable> error = _javaExecutionContext.executeScript(sourceFile);
|
||||
final Entry<Path, Throwable> error = _javaExecutionContext.executeScript(path);
|
||||
if (error != null)
|
||||
{
|
||||
throw new Exception("ScriptEngine: " + error.getKey() + " failed execution!", error.getValue());
|
||||
|
@@ -103,19 +103,20 @@ final class ScriptingFileManager implements StandardJavaFileManager
|
||||
return _wrapped.getJavaFileForOutput(location, className, kind, sibling);
|
||||
}
|
||||
|
||||
if (className.contains("/"))
|
||||
String javaName = className;
|
||||
if (javaName.contains("/"))
|
||||
{
|
||||
className = className.replace('/', '.');
|
||||
javaName = javaName.replace('/', '.');
|
||||
}
|
||||
|
||||
ScriptingOutputFileObject fileObject;
|
||||
if (sibling != null)
|
||||
{
|
||||
fileObject = new ScriptingOutputFileObject(Paths.get(sibling.getName()), className, className.substring(className.lastIndexOf('.') + 1));
|
||||
fileObject = new ScriptingOutputFileObject(Paths.get(sibling.getName()), javaName, javaName.substring(javaName.lastIndexOf('.') + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
fileObject = new ScriptingOutputFileObject(null, className, className.substring(className.lastIndexOf('.') + 1));
|
||||
fileObject = new ScriptingOutputFileObject(null, javaName, javaName.substring(javaName.lastIndexOf('.') + 1));
|
||||
}
|
||||
|
||||
_classOutputs.add(fileObject);
|
||||
|
@@ -100,7 +100,7 @@ public class SecondaryPasswordAuth
|
||||
}
|
||||
}
|
||||
|
||||
public boolean savePassword(String password)
|
||||
public boolean savePassword(String value)
|
||||
{
|
||||
if (passwordExist())
|
||||
{
|
||||
@@ -109,14 +109,13 @@ public class SecondaryPasswordAuth
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!validatePassword(password))
|
||||
if (!validatePassword(value))
|
||||
{
|
||||
_activeClient.sendPacket(new Ex2ndPasswordAck(0, Ex2ndPasswordAck.WRONG_PATTERN));
|
||||
return false;
|
||||
}
|
||||
|
||||
password = cryptPassword(password);
|
||||
|
||||
final String password = cryptPassword(value);
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(INSERT_PASSWORD))
|
||||
{
|
||||
@@ -173,12 +172,11 @@ public class SecondaryPasswordAuth
|
||||
return false;
|
||||
}
|
||||
|
||||
newPassword = cryptPassword(newPassword);
|
||||
|
||||
final String password = cryptPassword(newPassword);
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(UPDATE_PASSWORD))
|
||||
{
|
||||
statement.setString(1, newPassword);
|
||||
statement.setString(1, password);
|
||||
statement.setString(2, _activeClient.getAccountName());
|
||||
statement.setString(3, VAR_PWD);
|
||||
statement.execute();
|
||||
@@ -189,14 +187,14 @@ public class SecondaryPasswordAuth
|
||||
return false;
|
||||
}
|
||||
|
||||
_password = newPassword;
|
||||
_password = password;
|
||||
_authed = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkPassword(String password, boolean skipAuth)
|
||||
public boolean checkPassword(String value, boolean skipAuth)
|
||||
{
|
||||
password = cryptPassword(password);
|
||||
final String password = cryptPassword(value);
|
||||
if (!password.equals(_password))
|
||||
{
|
||||
_wrongAttempts++;
|
||||
|
@@ -62,10 +62,11 @@ public class AttackStanceTaskManager
|
||||
|
||||
/**
|
||||
* Removes the attack stance task.
|
||||
* @param actor the actor
|
||||
* @param creature the actor
|
||||
*/
|
||||
public void removeAttackStanceTask(Creature actor)
|
||||
public void removeAttackStanceTask(Creature creature)
|
||||
{
|
||||
Creature actor = creature;
|
||||
if (actor != null)
|
||||
{
|
||||
if (actor.isSummon())
|
||||
@@ -78,11 +79,12 @@ public class AttackStanceTaskManager
|
||||
|
||||
/**
|
||||
* Checks for attack stance task.
|
||||
* @param actor the actor
|
||||
* @param creature the actor
|
||||
* @return {@code true} if the character has an attack stance task, {@code false} otherwise
|
||||
*/
|
||||
public boolean hasAttackStanceTask(Creature actor)
|
||||
public boolean hasAttackStanceTask(Creature creature)
|
||||
{
|
||||
Creature actor = creature;
|
||||
if (actor != null)
|
||||
{
|
||||
if (actor.isSummon())
|
||||
|
@@ -136,13 +136,14 @@ public class SystemPanel extends JPanel
|
||||
|
||||
static String getDurationBreakdown(long millis)
|
||||
{
|
||||
final long days = TimeUnit.MILLISECONDS.toDays(millis);
|
||||
millis -= TimeUnit.DAYS.toMillis(days);
|
||||
final long hours = TimeUnit.MILLISECONDS.toHours(millis);
|
||||
millis -= TimeUnit.HOURS.toMillis(hours);
|
||||
final long minutes = TimeUnit.MILLISECONDS.toMinutes(millis);
|
||||
millis -= TimeUnit.MINUTES.toMillis(minutes);
|
||||
final long seconds = TimeUnit.MILLISECONDS.toSeconds(millis);
|
||||
long remaining = millis;
|
||||
final long days = TimeUnit.MILLISECONDS.toDays(remaining);
|
||||
remaining -= TimeUnit.DAYS.toMillis(days);
|
||||
final long hours = TimeUnit.MILLISECONDS.toHours(remaining);
|
||||
remaining -= TimeUnit.HOURS.toMillis(hours);
|
||||
final long minutes = TimeUnit.MILLISECONDS.toMinutes(remaining);
|
||||
remaining -= TimeUnit.MINUTES.toMillis(minutes);
|
||||
final long seconds = TimeUnit.MILLISECONDS.toSeconds(remaining);
|
||||
return (days + "d " + hours + "h " + minutes + "m " + seconds + "s");
|
||||
}
|
||||
}
|
||||
|
@@ -121,10 +121,11 @@ public class Broadcast
|
||||
* <font color=#FF0000><b><u>Caution</u>: This method DOESN'T SEND Server->Client packet to this Creature (to do this use method toSelfAndKnownPlayers)</b></font>
|
||||
* @param creature
|
||||
* @param mov
|
||||
* @param radius
|
||||
* @param radiusValue
|
||||
*/
|
||||
public static void toKnownPlayersInRadius(Creature creature, IClientOutgoingPacket mov, int radius)
|
||||
public static void toKnownPlayersInRadius(Creature creature, IClientOutgoingPacket mov, int radiusValue)
|
||||
{
|
||||
int radius = radiusValue;
|
||||
if (radius < 0)
|
||||
{
|
||||
radius = 1500;
|
||||
@@ -154,8 +155,9 @@ public class Broadcast
|
||||
}
|
||||
|
||||
// To improve performance we are comparing values of radius^2 instead of calculating sqrt all the time
|
||||
public static void toSelfAndKnownPlayersInRadius(Creature creature, IClientOutgoingPacket mov, int radius)
|
||||
public static void toSelfAndKnownPlayersInRadius(Creature creature, IClientOutgoingPacket mov, int radiusValue)
|
||||
{
|
||||
int radius = radiusValue;
|
||||
if (radius < 0)
|
||||
{
|
||||
radius = 600;
|
||||
|
@@ -145,7 +145,7 @@ public class HtmlUtil
|
||||
/**
|
||||
* Gets the HTML representation of a gauge.
|
||||
* @param width the width
|
||||
* @param current the current value
|
||||
* @param currentValue the current value
|
||||
* @param max the max value
|
||||
* @param displayAsPercentage if {@code true} the text in middle will be displayed as percent else it will be displayed as "current / max"
|
||||
* @param backgroundImage the background image
|
||||
@@ -154,9 +154,9 @@ public class HtmlUtil
|
||||
* @param top the top adjustment
|
||||
* @return the HTML
|
||||
*/
|
||||
private static String getGauge(int width, long current, long max, boolean displayAsPercentage, String backgroundImage, String image, long imageHeight, long top)
|
||||
private static String getGauge(int width, long currentValue, long max, boolean displayAsPercentage, String backgroundImage, String image, long imageHeight, long top)
|
||||
{
|
||||
current = Math.min(current, max);
|
||||
final long current = Math.min(currentValue, max);
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("<table width=");
|
||||
sb.append(width);
|
||||
|
@@ -51,13 +51,14 @@ public class Locator
|
||||
|
||||
/**
|
||||
* Find the directory or jar a given resource has been loaded from.
|
||||
* @param c the classloader to be consulted for the source.
|
||||
* @param classLoader the classloader to be consulted for the source.
|
||||
* @param resource the resource whose location is required.
|
||||
* @return the file with the resource source or null if we cannot determine the location.
|
||||
* @since Ant 1.6
|
||||
*/
|
||||
public static File getResourceSource(ClassLoader c, String resource)
|
||||
public static File getResourceSource(ClassLoader classLoader, String resource)
|
||||
{
|
||||
ClassLoader c = classLoader;
|
||||
if (c == null)
|
||||
{
|
||||
c = Locator.class.getClassLoader();
|
||||
@@ -98,12 +99,13 @@ public class Locator
|
||||
* <p>
|
||||
* Swallows '%' that are not followed by two characters, doesn't deal with non-ASCII characters.
|
||||
* </p>
|
||||
* @param uri the URI designating a file in the local filesystem.
|
||||
* @param uriValue the URI designating a file in the local filesystem.
|
||||
* @return the local file system path for the file.
|
||||
* @since Ant 1.6
|
||||
*/
|
||||
public static String fromURI(String uri)
|
||||
public static String fromURI(String uriValue)
|
||||
{
|
||||
String uri = uriValue;
|
||||
URL url = null;
|
||||
try
|
||||
{
|
||||
@@ -113,10 +115,12 @@ public class Locator
|
||||
{
|
||||
// Ignore malformed exception
|
||||
}
|
||||
|
||||
if ((url == null) || !("file".equals(url.getProtocol())))
|
||||
{
|
||||
throw new IllegalArgumentException("Can only handle valid file: URIs");
|
||||
}
|
||||
|
||||
final StringBuilder buf = new StringBuilder(url.getHost());
|
||||
if (buf.length() > 0)
|
||||
{
|
||||
@@ -125,13 +129,12 @@ public class Locator
|
||||
final String file = url.getFile();
|
||||
final int queryPos = file.indexOf('?');
|
||||
buf.append((queryPos < 0) ? file : file.substring(0, queryPos));
|
||||
|
||||
uri = buf.toString().replace('/', File.separatorChar);
|
||||
|
||||
if ((File.pathSeparatorChar == ';') && uri.startsWith("\\") && (uri.length() > 2) && Character.isLetter(uri.charAt(1)) && (uri.lastIndexOf(':') > -1))
|
||||
{
|
||||
uri = uri.substring(1);
|
||||
}
|
||||
|
||||
return decodeUri(uri);
|
||||
}
|
||||
|
||||
|
@@ -71,7 +71,7 @@ public class TimeAmountInterpreter
|
||||
* Please keep in mind, that this method is primarily designed to be used with heap text builders. Therefore, if the given text builder throws an {@link IOException}, this exception will be wrapped in a {@link RuntimeException} and returned to the caller as an unchecked exception.
|
||||
* @param <T>
|
||||
* @param textBuilder a character sequence builder
|
||||
* @param timeAmount amount of time to be written
|
||||
* @param amount amount of time to be written
|
||||
* @param timeUnit unit of the given amount
|
||||
* @param minConsolidationUnit smallest unit to be included within the description
|
||||
* @param maxConsolidationUnit largest unit to be included within the description
|
||||
@@ -79,10 +79,11 @@ public class TimeAmountInterpreter
|
||||
* @return {@code textBuilder}
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T extends Appendable & CharSequence> T appendConsolidated(T textBuilder, long timeAmount, TimeUnit timeUnit, TimeUnit minConsolidationUnit, TimeUnit maxConsolidationUnit, String noTimeUsedIndicator)
|
||||
private static <T extends Appendable & CharSequence> T appendConsolidated(T textBuilder, long amount, TimeUnit timeUnit, TimeUnit minConsolidationUnit, TimeUnit maxConsolidationUnit, String noTimeUsedIndicator)
|
||||
{
|
||||
try
|
||||
{
|
||||
long timeAmount = amount;
|
||||
if (timeAmount < 1)
|
||||
{
|
||||
return (T) textBuilder.append(noTimeUsedIndicator);
|
||||
@@ -117,6 +118,7 @@ public class TimeAmountInterpreter
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return textBuilder;
|
||||
}
|
||||
}
|
||||
|
@@ -642,8 +642,7 @@ public class Util
|
||||
*/
|
||||
public static int map(int input, int inputMin, int inputMax, int outputMin, int outputMax)
|
||||
{
|
||||
input = constrain(input, inputMin, inputMax);
|
||||
return (((input - inputMin) * (outputMax - outputMin)) / (inputMax - inputMin)) + outputMin;
|
||||
return (((constrain(input, inputMin, inputMax) - inputMin) * (outputMax - outputMin)) / (inputMax - inputMin)) + outputMin;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -657,8 +656,7 @@ public class Util
|
||||
*/
|
||||
public static long map(long input, long inputMin, long inputMax, long outputMin, long outputMax)
|
||||
{
|
||||
input = constrain(input, inputMin, inputMax);
|
||||
return (((input - inputMin) * (outputMax - outputMin)) / (inputMax - inputMin)) + outputMin;
|
||||
return (((constrain(input, inputMin, inputMax) - inputMin) * (outputMax - outputMin)) / (inputMax - inputMin)) + outputMin;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -672,8 +670,7 @@ public class Util
|
||||
*/
|
||||
public static double map(double input, double inputMin, double inputMax, double outputMin, double outputMax)
|
||||
{
|
||||
input = constrain(input, inputMin, inputMax);
|
||||
return (((input - inputMin) * (outputMax - outputMin)) / (inputMax - inputMin)) + outputMin;
|
||||
return (((constrain(input, inputMin, inputMax) - inputMin) * (outputMax - outputMin)) / (inputMax - inputMin)) + outputMin;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -272,16 +272,17 @@ public class CronParser
|
||||
/**
|
||||
* Parses a crontab-like line.
|
||||
* @param table The table on which the parsed task will be stored, by side-effect.
|
||||
* @param line The crontab-like line.
|
||||
* @param lineValue The crontab-like line.
|
||||
* @throws Exception The supplied line doesn't represent a valid task line.
|
||||
*/
|
||||
public static void parseLine(TaskTable table, String line) throws Exception
|
||||
public static void parseLine(TaskTable table, String lineValue) throws Exception
|
||||
{
|
||||
line = line.trim();
|
||||
String line = lineValue.trim();
|
||||
if ((line.isEmpty()) || (line.charAt(0) == '#'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Detecting the pattern.
|
||||
int size = line.length();
|
||||
String pattern = null;
|
||||
@@ -298,8 +299,10 @@ public class CronParser
|
||||
{
|
||||
throw new Exception("Invalid cron line: " + line);
|
||||
}
|
||||
|
||||
line = line.substring(pattern.length());
|
||||
size = line.length();
|
||||
|
||||
// Splitting the line
|
||||
final ArrayList<String> splitted = new ArrayList<>();
|
||||
StringBuilder current = null;
|
||||
@@ -351,6 +354,7 @@ public class CronParser
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((current != null) && (current.length() > 0))
|
||||
{
|
||||
String str = current.toString();
|
||||
@@ -361,6 +365,7 @@ public class CronParser
|
||||
splitted.add(str);
|
||||
current = null;
|
||||
}
|
||||
|
||||
// Analyzing
|
||||
size = splitted.size();
|
||||
int status = 0;
|
||||
@@ -377,6 +382,7 @@ public class CronParser
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
final String tk = splitted.get(i);
|
||||
|
||||
// Check the local status.
|
||||
if (status == 0)
|
||||
{
|
||||
@@ -424,8 +430,10 @@ public class CronParser
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Task preparing.
|
||||
Task task;
|
||||
|
||||
// Command evaluation.
|
||||
if (command == null)
|
||||
{
|
||||
@@ -471,6 +479,7 @@ public class CronParser
|
||||
{
|
||||
cmdarray[i + 1] = argsList.get(i);
|
||||
}
|
||||
|
||||
// Environments.
|
||||
String[] envs = null;
|
||||
size = envsList.size();
|
||||
@@ -482,6 +491,7 @@ public class CronParser
|
||||
envs[i] = envsList.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Working directory.
|
||||
File dir = null;
|
||||
if (dirString != null)
|
||||
@@ -492,8 +502,10 @@ public class CronParser
|
||||
throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
|
||||
}
|
||||
}
|
||||
|
||||
// Builds the task.
|
||||
final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
|
||||
|
||||
// Channels.
|
||||
if (stdinFile != null)
|
||||
{
|
||||
@@ -509,6 +521,7 @@ public class CronParser
|
||||
}
|
||||
task = process;
|
||||
}
|
||||
|
||||
// End.
|
||||
table.add(new SchedulingPattern(pattern), task);
|
||||
}
|
||||
|
@@ -145,7 +145,9 @@ public class LoginServer
|
||||
lnr.lines()
|
||||
.map(String::trim)
|
||||
.filter(l -> !l.isEmpty() && (l.charAt(0) != '#'))
|
||||
.forEach(line -> {
|
||||
.forEach(lineValue ->
|
||||
{
|
||||
String line = lineValue;
|
||||
String[] parts = line.split("#", 2); // address[ duration][ # comments]
|
||||
line = parts[0];
|
||||
parts = line.split("\\s+"); // durations might be aligned via multiple spaces
|
||||
|
@@ -100,16 +100,17 @@ public class DBInstallerConsole implements DBOutputInterface
|
||||
*/
|
||||
public DBInstallerConsole(String defDatabase, String dir, String host, String port, String user, String pass, String database, String mode) throws Exception
|
||||
{
|
||||
if ((database == null) || database.isEmpty())
|
||||
String currentDatabase = database;
|
||||
if ((currentDatabase == null) || currentDatabase.isEmpty())
|
||||
{
|
||||
database = defDatabase;
|
||||
currentDatabase = defDatabase;
|
||||
}
|
||||
|
||||
final MySqlConnect connector = new MySqlConnect(host, port, user, pass, database, true);
|
||||
final MySqlConnect connector = new MySqlConnect(host, port, user, pass, currentDatabase, true);
|
||||
_con = connector.getConnection();
|
||||
if ((mode != null) && ("c".equalsIgnoreCase(mode) || "u".equalsIgnoreCase(mode)))
|
||||
{
|
||||
final RunTasks rt = new RunTasks(this, database, dir);
|
||||
final RunTasks rt = new RunTasks(this, currentDatabase, dir);
|
||||
rt.run();
|
||||
}
|
||||
}
|
||||
|
@@ -274,11 +274,13 @@ public class GeoDataConverter
|
||||
* @param x : Geodata X coordinate.
|
||||
* @param y : Geodata Y coordinate.
|
||||
* @param z : Geodata Z coordinate.
|
||||
* @param nswe : NSWE flag to be updated.
|
||||
* @param nsweValue : NSWE flag to be updated.
|
||||
* @return byte : Updated NSWE flag.
|
||||
*/
|
||||
private static byte updateNsweBelow(int x, int y, short z, byte nswe)
|
||||
private static byte updateNsweBelow(int x, int y, short z, byte nsweValue)
|
||||
{
|
||||
byte nswe = nsweValue;
|
||||
|
||||
// calculate virtual layer height
|
||||
final short height = (short) (z + GeoStructure.CELL_IGNORE_HEIGHT);
|
||||
|
||||
|
@@ -303,12 +303,13 @@ public abstract class BaseGameServerRegister
|
||||
|
||||
/**
|
||||
* Show the error.
|
||||
* @param msg the msg
|
||||
* @param message the msg
|
||||
* @param t the t
|
||||
*/
|
||||
public void showError(String msg, Throwable t)
|
||||
public void showError(String message, Throwable t)
|
||||
{
|
||||
String title;
|
||||
String msg = message;
|
||||
if (_bundle != null)
|
||||
{
|
||||
title = _bundle.getString("error");
|
||||
|
@@ -320,7 +320,6 @@ public class GameServerRegister extends BaseGameServerRegister
|
||||
@Override
|
||||
public void showError(String msg, Throwable t)
|
||||
{
|
||||
msg += Config.EOL + "Reason: " + t.getMessage();
|
||||
System.out.println("Error: " + msg);
|
||||
System.out.println("Error: " + msg + Config.EOL + "Reason: " + t.getMessage());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user