Code improvements.
This commit is contained in:
@@ -216,8 +216,7 @@ public abstract class DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -270,16 +269,7 @@ public abstract class DocumentBase
|
||||
}
|
||||
|
||||
final String valueString = n.getAttributes().getNamedItem("val").getNodeValue();
|
||||
double value;
|
||||
if (valueString.charAt(0) == '#')
|
||||
{
|
||||
value = Double.parseDouble(getTableValue(valueString));
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Double.parseDouble(valueString);
|
||||
}
|
||||
|
||||
final double value = valueString.charAt(0) == '#' ? Double.parseDouble(getTableValue(valueString)) : Double.parseDouble(valueString);
|
||||
final Condition applayCond = parseCondition(n.getFirstChild(), template);
|
||||
final FuncTemplate ft = new FuncTemplate(attachCond, applayCond, functionName, order, stat, value);
|
||||
if (template instanceof L2Item)
|
||||
@@ -675,8 +665,7 @@ public abstract class DocumentBase
|
||||
final ArrayList<Integer> array = new ArrayList<>(st.countTokens());
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
final String item = st.nextToken().trim();
|
||||
array.add(Integer.decode(getValue(item, template)));
|
||||
array.add(Integer.decode(getValue(st.nextToken().trim(), template)));
|
||||
}
|
||||
cond = joinAnd(cond, new ConditionPlayerHasClanHall(array));
|
||||
break;
|
||||
@@ -751,8 +740,7 @@ public abstract class DocumentBase
|
||||
final ArrayList<Integer> array = new ArrayList<>(st.countTokens());
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
final String item = st.nextToken().trim();
|
||||
array.add(Integer.decode(getValue(item, template)));
|
||||
array.add(Integer.decode(getValue(st.nextToken().trim(), template)));
|
||||
}
|
||||
cond = joinAnd(cond, new ConditionPlayerClassIdRestriction(array));
|
||||
break;
|
||||
@@ -774,8 +762,7 @@ public abstract class DocumentBase
|
||||
final ArrayList<Integer> array = new ArrayList<>(st.countTokens());
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
final String item = st.nextToken().trim();
|
||||
array.add(Integer.decode(getValue(item, template)));
|
||||
array.add(Integer.decode(getValue(st.nextToken().trim(), template)));
|
||||
}
|
||||
cond = joinAnd(cond, new ConditionPlayerInstanceId(array));
|
||||
break;
|
||||
@@ -798,8 +785,7 @@ public abstract class DocumentBase
|
||||
final ArrayList<Integer> array = new ArrayList<>(st.countTokens());
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
final String item = st.nextToken().trim();
|
||||
array.add(Integer.decode(getValue(item, template)));
|
||||
array.add(Integer.decode(getValue(st.nextToken().trim(), template)));
|
||||
}
|
||||
cond = joinAnd(cond, new ConditionPlayerHasPet(array));
|
||||
break;
|
||||
@@ -820,9 +806,7 @@ public abstract class DocumentBase
|
||||
{
|
||||
npcIds[index] = Integer.parseInt(getValue(ids[index], template));
|
||||
}
|
||||
final int radius = Integer.parseInt(st.nextToken());
|
||||
final boolean val = Boolean.parseBoolean(st.nextToken());
|
||||
cond = joinAnd(cond, new ConditionPlayerRangeFromNpc(npcIds, radius, val));
|
||||
cond = joinAnd(cond, new ConditionPlayerRangeFromNpc(npcIds, Integer.parseInt(st.nextToken()), Boolean.parseBoolean(st.nextToken())));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -902,8 +886,7 @@ public abstract class DocumentBase
|
||||
final List<Integer> array = new ArrayList<>(st.countTokens());
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
final String item = st.nextToken().trim();
|
||||
array.add(Integer.decode(getValue(item, template)));
|
||||
array.add(Integer.decode(getValue(st.nextToken().trim(), template)));
|
||||
}
|
||||
cond = joinAnd(cond, new ConditionPlayerInsideZoneId(array));
|
||||
break;
|
||||
@@ -1013,8 +996,7 @@ public abstract class DocumentBase
|
||||
final List<Integer> array = new ArrayList<>(st.countTokens());
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
final String item = st.nextToken().trim();
|
||||
array.add(Integer.decode(getValue(item, null)));
|
||||
array.add(Integer.decode(getValue(st.nextToken().trim(), null)));
|
||||
}
|
||||
cond = joinAnd(cond, new ConditionTargetClassIdRestriction(array));
|
||||
break;
|
||||
@@ -1103,8 +1085,7 @@ public abstract class DocumentBase
|
||||
final List<Integer> array = new ArrayList<>(st.countTokens());
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
final String item = st.nextToken().trim();
|
||||
array.add(Integer.decode(getValue(item, null)));
|
||||
array.add(Integer.decode(getValue(st.nextToken().trim(), null)));
|
||||
}
|
||||
cond = joinAnd(cond, new ConditionTargetNpcId(array));
|
||||
break;
|
||||
@@ -1222,11 +1203,7 @@ public abstract class DocumentBase
|
||||
final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ";");
|
||||
final int id = Integer.parseInt(st.nextToken().trim());
|
||||
final int slot = Integer.parseInt(st.nextToken().trim());
|
||||
int enchant = 0;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
enchant = Integer.parseInt(st.nextToken().trim());
|
||||
}
|
||||
final int enchant = st.hasMoreTokens() ? Integer.parseInt(st.nextToken().trim()) : 0;
|
||||
cond = joinAnd(cond, new ConditionSlotItemId(slot, id, enchant));
|
||||
break;
|
||||
}
|
||||
@@ -1255,18 +1232,15 @@ public abstract class DocumentBase
|
||||
final Node a = attrs.item(i);
|
||||
if ("skill".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final boolean val = Boolean.parseBoolean(a.getNodeValue());
|
||||
cond = joinAnd(cond, new ConditionWithSkill(val));
|
||||
cond = joinAnd(cond, new ConditionWithSkill(Boolean.parseBoolean(a.getNodeValue())));
|
||||
}
|
||||
if ("night".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final boolean val = Boolean.parseBoolean(a.getNodeValue());
|
||||
cond = joinAnd(cond, new ConditionGameTime(CheckGameTime.NIGHT, val));
|
||||
cond = joinAnd(cond, new ConditionGameTime(CheckGameTime.NIGHT, Boolean.parseBoolean(a.getNodeValue())));
|
||||
}
|
||||
if ("chance".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final int val = Integer.decode(getValue(a.getNodeValue(), null));
|
||||
cond = joinAnd(cond, new ConditionGameChance(val));
|
||||
cond = joinAnd(cond, new ConditionGameChance(Integer.decode(getValue(a.getNodeValue(), null))));
|
||||
}
|
||||
}
|
||||
if (cond == null)
|
||||
@@ -1298,14 +1272,7 @@ public abstract class DocumentBase
|
||||
final String name = n.getAttributes().getNamedItem("name").getNodeValue().trim();
|
||||
final String value = n.getAttributes().getNamedItem("val").getNodeValue().trim();
|
||||
final char ch = value.isEmpty() ? ' ' : value.charAt(0);
|
||||
if ((ch == '#') || (ch == '-') || Character.isDigit(ch))
|
||||
{
|
||||
set.set(name, String.valueOf(getValue(value, level)));
|
||||
}
|
||||
else
|
||||
{
|
||||
set.set(name, value);
|
||||
}
|
||||
set.set(name, (ch == '#') || (ch == '-') || Character.isDigit(ch) ? String.valueOf(getValue(value, level)) : value);
|
||||
}
|
||||
|
||||
protected void setExtractableSkillData(StatsSet set, String value)
|
||||
|
@@ -17,7 +17,6 @@
|
||||
package com.l2jmobius.gameserver.engines.items;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -98,12 +97,7 @@ public final class DocumentItem extends DocumentBase
|
||||
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();
|
||||
String additionalName = null;
|
||||
if (n.getAttributes().getNamedItem("additionalName") != null)
|
||||
{
|
||||
additionalName = n.getAttributes().getNamedItem("additionalName").getNodeValue();
|
||||
}
|
||||
|
||||
final String additionalName = n.getAttributes().getNamedItem("additionalName") != null ? n.getAttributes().getNamedItem("additionalName").getNodeValue() : null;
|
||||
_currentItem.id = itemId;
|
||||
_currentItem.name = itemName;
|
||||
_currentItem.type = className;
|
||||
@@ -149,8 +143,7 @@ public final class DocumentItem extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -170,8 +163,7 @@ public final class DocumentItem extends DocumentBase
|
||||
}
|
||||
try
|
||||
{
|
||||
final Constructor<?> c = Class.forName("com.l2jmobius.gameserver.model.items.L2" + _currentItem.type).getConstructor(StatsSet.class);
|
||||
_currentItem.item = (L2Item) c.newInstance(_currentItem.set);
|
||||
_currentItem.item = (L2Item) Class.forName("com.l2jmobius.gameserver.model.items.L2" + _currentItem.type).getConstructor(StatsSet.class).newInstance(_currentItem.set);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@@ -553,8 +553,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -611,8 +610,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -673,8 +671,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -731,8 +728,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -793,8 +789,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -847,8 +842,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -909,8 +903,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -967,8 +960,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -1029,8 +1021,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -1087,8 +1078,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -1149,8 +1139,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -1207,8 +1196,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -1269,8 +1257,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -1327,8 +1314,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -1389,8 +1375,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -1447,8 +1432,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -1509,8 +1493,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -1567,8 +1550,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
@@ -1629,8 +1611,7 @@ public class DocumentSkill extends DocumentBase
|
||||
else if ((condition != null) && (msgId != null))
|
||||
{
|
||||
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
|
||||
final Node addName = n.getAttributes().getNamedItem("addName");
|
||||
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
|
||||
{
|
||||
condition.addName();
|
||||
}
|
||||
|
Reference in New Issue
Block a user