Code review Part 5.

This commit is contained in:
MobiusDevelopment
2019-12-22 15:33:46 +00:00
parent 4a563b8832
commit 7f3befa63c
4071 changed files with 23938 additions and 28938 deletions

View File

@@ -1689,7 +1689,7 @@ public class Config
}
Arrays.sort(ENCHANT_BLACKLIST);
DISABLE_OVER_ENCHANTING = Character.getBoolean("DisableOverEnchanting", true);
String[] array = Character.getString("AugmentationBlackList", "6656,6657,6658,6659,6660,6661,6662,8191,10170,10314,13740,13741,13742,13743,13744,13745,13746,13747,13748,14592,14593,14594,14595,14596,14597,14598,14599,14600,14664,14665,14666,14667,14668,14669,14670,14671,14672,14801,14802,14803,14804,14805,14806,14807,14808,14809,15282,15283,15284,15285,15286,15287,15288,15289,15290,15291,15292,15293,15294,15295,15296,15297,15298,15299,16025,16026,21712,22173,22174,22175").split(",");
final String[] array = Character.getString("AugmentationBlackList", "6656,6657,6658,6659,6660,6661,6662,8191,10170,10314,13740,13741,13742,13743,13744,13745,13746,13747,13748,14592,14593,14594,14595,14596,14597,14598,14599,14600,14664,14665,14666,14667,14668,14669,14670,14671,14672,14801,14802,14803,14804,14805,14806,14807,14808,14809,15282,15283,15284,15285,15286,15287,15288,15289,15290,15291,15292,15293,15294,15295,15296,15297,15298,15299,16025,16026,21712,22173,22174,22175").split(",");
AUGMENTATION_BLACKLIST = new int[array.length];
for (int i = 0; i < array.length; i++)
@@ -3298,11 +3298,11 @@ public class Config
NETWORK_SERVER_LINK = VoteReward.getString("NetworkServerLink", "");
NETWORK_VOTES_DIFFERENCE = VoteReward.getInt("NetworkVotesDifference", 5);
NETWORK_REWARD_CHECK_TIME = VoteReward.getInt("NetworkRewardCheckTime", 5);
String NETWORK_SMALL_REWARD_VALUE = VoteReward.getString("NetworkReward", "57,100000000;");
String[] NETWORK_small_reward_splitted_1 = NETWORK_SMALL_REWARD_VALUE.split(";");
final String NETWORK_SMALL_REWARD_VALUE = VoteReward.getString("NetworkReward", "57,100000000;");
final String[] NETWORK_small_reward_splitted_1 = NETWORK_SMALL_REWARD_VALUE.split(";");
for (String i : NETWORK_small_reward_splitted_1)
{
String[] NETWORK_small_reward_splitted_2 = i.split(",");
final String[] NETWORK_small_reward_splitted_2 = i.split(",");
NETWORK_REWARD.put(Integer.parseInt(NETWORK_small_reward_splitted_2[0]), Integer.parseInt(NETWORK_small_reward_splitted_2[1]));
}
NETWORK_DUALBOXES_ALLOWED = VoteReward.getInt("NetworkDualboxesAllowed", 1);
@@ -3311,11 +3311,11 @@ public class Config
TOPZONE_SERVER_LINK = VoteReward.getString("TopzoneServerLink", "");
TOPZONE_VOTES_DIFFERENCE = VoteReward.getInt("TopzoneVotesDifference", 5);
TOPZONE_REWARD_CHECK_TIME = VoteReward.getInt("TopzoneRewardCheckTime", 5);
String TOPZONE_SMALL_REWARD_VALUE = VoteReward.getString("TopzoneReward", "57,100000000;");
String[] topzone_small_reward_splitted_1 = TOPZONE_SMALL_REWARD_VALUE.split(";");
final String TOPZONE_SMALL_REWARD_VALUE = VoteReward.getString("TopzoneReward", "57,100000000;");
final String[] topzone_small_reward_splitted_1 = TOPZONE_SMALL_REWARD_VALUE.split(";");
for (String i : topzone_small_reward_splitted_1)
{
String[] topzone_small_reward_splitted_2 = i.split(",");
final String[] topzone_small_reward_splitted_2 = i.split(",");
TOPZONE_REWARD.put(Integer.parseInt(topzone_small_reward_splitted_2[0]), Integer.parseInt(topzone_small_reward_splitted_2[1]));
}
TOPZONE_DUALBOXES_ALLOWED = VoteReward.getInt("TopzoneDualboxesAllowed", 1);
@@ -3324,11 +3324,11 @@ public class Config
HOPZONE_SERVER_LINK = VoteReward.getString("HopzoneServerLink", "");
HOPZONE_VOTES_DIFFERENCE = VoteReward.getInt("HopzoneVotesDifference", 5);
HOPZONE_REWARD_CHECK_TIME = VoteReward.getInt("HopzoneRewardCheckTime", 5);
String HOPZONE_SMALL_REWARD_VALUE = VoteReward.getString("HopzoneReward", "57,100000000;");
String[] hopzone_small_reward_splitted_1 = HOPZONE_SMALL_REWARD_VALUE.split(";");
final String HOPZONE_SMALL_REWARD_VALUE = VoteReward.getString("HopzoneReward", "57,100000000;");
final String[] hopzone_small_reward_splitted_1 = HOPZONE_SMALL_REWARD_VALUE.split(";");
for (String i : hopzone_small_reward_splitted_1)
{
String[] hopzone_small_reward_splitted_2 = i.split(",");
final String[] hopzone_small_reward_splitted_2 = i.split(",");
HOPZONE_REWARD.put(Integer.parseInt(hopzone_small_reward_splitted_2[0]), Integer.parseInt(hopzone_small_reward_splitted_2[1]));
}
HOPZONE_DUALBOXES_ALLOWED = VoteReward.getInt("HopzoneDualboxesAllowed", 1);

View File

@@ -71,7 +71,7 @@ public class LimitLinesDocumentListener implements DocumentListener
{
if (maximumLines < 1)
{
String message = "Maximum lines must be greater than 0";
final String message = "Maximum lines must be greater than 0";
throw new IllegalArgumentException(message);
}
@@ -106,8 +106,8 @@ public class LimitLinesDocumentListener implements DocumentListener
private void removeLines(DocumentEvent e)
{
// The root Element of the Document will tell us the total number of line in the Document.
Document document = e.getDocument();
Element root = document.getDefaultRootElement();
final Document document = e.getDocument();
final Element root = document.getDefaultRootElement();
while (root.getElementCount() > _maximumLines)
{
@@ -127,8 +127,8 @@ public class LimitLinesDocumentListener implements DocumentListener
*/
private void removeFromStart(Document document, Element root)
{
Element line = root.getElement(0);
int end = line.getEndOffset();
final Element line = root.getElement(0);
final int end = line.getEndOffset();
try
{
@@ -147,9 +147,9 @@ public class LimitLinesDocumentListener implements DocumentListener
{
// We use start minus 1 to make sure we remove the newline character of the previous line.
Element line = root.getElement(root.getElementCount() - 1);
int start = line.getStartOffset();
int end = line.getEndOffset();
final Element line = root.getElement(root.getElementCount() - 1);
final int start = line.getStartOffset();
final int end = line.getEndOffset();
try
{

View File

@@ -44,7 +44,7 @@ public class SplashScreen extends JWindow
{
setBackground(new Color(0, 255, 0, 0)); // Transparency.
image = Toolkit.getDefaultToolkit().getImage(path);
ImageIcon imageIcon = new ImageIcon(image);
final ImageIcon imageIcon = new ImageIcon(image);
setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight());
setLocationRelativeTo(null);
setAlwaysOnTop(true);

View File

@@ -366,8 +366,9 @@ public class RecipeController
{
Thread.sleep(_delay);
}
catch (InterruptedException e)
catch (Exception e)
{
// Ignore.
}
finally
{

View File

@@ -120,7 +120,7 @@ public class HtmCache
BufferedInputStream bis = new BufferedInputStream(fis))
{
final int bytes = bis.available();
byte[] raw = new byte[bytes];
final byte[] raw = new byte[bytes];
bis.read(raw);
content = new String(raw, StandardCharsets.UTF_8);

View File

@@ -60,7 +60,7 @@ public class OfflineTradersTable
PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE);
PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS);
PreparedStatement stm3 = con.prepareStatement(SAVE_OFFLINE_STATUS);
PreparedStatement stm_items = con.prepareStatement(SAVE_ITEMS))
PreparedStatement stmItems = con.prepareStatement(SAVE_ITEMS))
{
stm1.execute();
stm2.execute();
@@ -88,12 +88,12 @@ public class OfflineTradersTable
title = pc.getBuyList().getTitle();
for (TradeItem i : pc.getBuyList().getItems())
{
stm_items.setInt(1, pc.getObjectId());
stm_items.setInt(2, i.getItem().getId());
stm_items.setLong(3, i.getCount());
stm_items.setLong(4, i.getPrice());
stm_items.executeUpdate();
stm_items.clearParameters();
stmItems.setInt(1, pc.getObjectId());
stmItems.setInt(2, i.getItem().getId());
stmItems.setLong(3, i.getCount());
stmItems.setLong(4, i.getPrice());
stmItems.executeUpdate();
stmItems.clearParameters();
}
break;
}
@@ -109,24 +109,24 @@ public class OfflineTradersTable
{
for (SellBuffHolder holder : pc.getSellingBuffs())
{
stm_items.setInt(1, pc.getObjectId());
stm_items.setInt(2, holder.getSkillId());
stm_items.setLong(3, 0);
stm_items.setLong(4, holder.getPrice());
stm_items.executeUpdate();
stm_items.clearParameters();
stmItems.setInt(1, pc.getObjectId());
stmItems.setInt(2, holder.getSkillId());
stmItems.setLong(3, 0);
stmItems.setLong(4, holder.getPrice());
stmItems.executeUpdate();
stmItems.clearParameters();
}
}
else
{
for (TradeItem i : pc.getSellList().getItems())
{
stm_items.setInt(1, pc.getObjectId());
stm_items.setInt(2, i.getObjectId());
stm_items.setLong(3, i.getCount());
stm_items.setLong(4, i.getPrice());
stm_items.executeUpdate();
stm_items.clearParameters();
stmItems.setInt(1, pc.getObjectId());
stmItems.setInt(2, i.getObjectId());
stmItems.setLong(3, i.getCount());
stmItems.setLong(4, i.getPrice());
stmItems.executeUpdate();
stmItems.clearParameters();
}
}
break;
@@ -140,12 +140,12 @@ public class OfflineTradersTable
title = pc.getStoreName();
for (ManufactureItem i : pc.getManufactureItems().values())
{
stm_items.setInt(1, pc.getObjectId());
stm_items.setInt(2, i.getRecipeId());
stm_items.setLong(3, 0);
stm_items.setLong(4, i.getCost());
stm_items.executeUpdate();
stm_items.clearParameters();
stmItems.setInt(1, pc.getObjectId());
stmItems.setInt(2, i.getRecipeId());
stmItems.setLong(3, 0);
stmItems.setLong(4, i.getCost());
stmItems.executeUpdate();
stmItems.clearParameters();
}
break;
}
@@ -231,10 +231,10 @@ public class OfflineTradersTable
}
player.spawnMe(player.getX(), player.getY(), player.getZ());
try (PreparedStatement stm_items = con.prepareStatement(LOAD_OFFLINE_ITEMS))
try (PreparedStatement stmItems = con.prepareStatement(LOAD_OFFLINE_ITEMS))
{
stm_items.setInt(1, player.getObjectId());
try (ResultSet items = stm_items.executeQuery())
stmItems.setInt(1, player.getObjectId());
try (ResultSet items = stmItems.executeQuery())
{
switch (type)
{

View File

@@ -93,7 +93,7 @@ public class ItemCrystallizationData implements IXmlReader
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
NamedNodeMap attrs = c.getAttributes();
final NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
@@ -117,7 +117,7 @@ public class ItemCrystallizationData implements IXmlReader
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
NamedNodeMap attrs = c.getAttributes();
final NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
@@ -154,7 +154,7 @@ public class ItemCrystallizationData implements IXmlReader
if (chance > 100.)
{
double countMul = Math.ceil(chance / 100.);
final double countMul = Math.ceil(chance / 100.);
chance /= countMul;
count *= countMul;
}

View File

@@ -175,7 +175,7 @@ public class VariationData implements IXmlReader
for (int item : itemGroup)
{
Map<Integer, VariationFee> fees = _fees.computeIfAbsent(item, k -> new HashMap<>());
final Map<Integer, VariationFee> fees = _fees.computeIfAbsent(item, k -> new HashMap<>());
fees.putAll(feeByMinerals);
}
}));
@@ -206,8 +206,8 @@ public class VariationData implements IXmlReader
private VariationInstance generateRandomVariation(Variation variation, VariationWeaponType weaponType)
{
Options option1 = variation.getRandomEffect(weaponType, 0);
Options option2 = variation.getRandomEffect(weaponType, 1);
final Options option1 = variation.getRandomEffect(weaponType, 0);
final Options option2 = variation.getRandomEffect(weaponType, 1);
return ((option1 != null) && (option2 != null)) ? new VariationInstance(variation.getMineralId(), option1, option2) : null;
}
@@ -246,7 +246,7 @@ public class VariationData implements IXmlReader
public boolean hasFeeData(int itemId)
{
Map<Integer, VariationFee> itemFees = _fees.get(itemId);
final Map<Integer, VariationFee> itemFees = _fees.get(itemId);
return (itemFees != null) && !itemFees.isEmpty();
}

View File

@@ -51,7 +51,7 @@ public class SchemeBufferTable
private static final String DELETE_SCHEMES = "TRUNCATE TABLE buffer_schemes";
private static final String INSERT_SCHEME = "INSERT INTO buffer_schemes (object_id, scheme_name, skills) VALUES (?,?,?)";
private final Map<Integer, Map<String, ArrayList<Integer>>> _schemesTable = new ConcurrentHashMap<>();
private final Map<Integer, Map<String, List<Integer>>> _schemesTable = new ConcurrentHashMap<>();
private final Map<Integer, BuffSkillHolder> _availableBuffs = new LinkedHashMap<>();
public SchemeBufferTable()
@@ -60,8 +60,8 @@ public class SchemeBufferTable
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement st = con.prepareStatement(LOAD_SCHEMES);
ResultSet rs = st.executeQuery();
final PreparedStatement st = con.prepareStatement(LOAD_SCHEMES);
final ResultSet rs = st.executeQuery();
while (rs.next())
{
@@ -70,7 +70,7 @@ public class SchemeBufferTable
final String schemeName = rs.getString("scheme_name");
final String[] skills = rs.getString("skills").split(",");
ArrayList<Integer> schemeList = new ArrayList<>();
final ArrayList<Integer> schemeList = new ArrayList<>();
for (String skill : skills)
{
@@ -97,9 +97,9 @@ public class SchemeBufferTable
try
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new File("./data/SchemeBufferSkills.xml"));
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
final DocumentBuilder db = dbf.newDocumentBuilder();
final Document doc = db.parse(new File("./data/SchemeBufferSkills.xml"));
final Node n = doc.getFirstChild();
@@ -146,9 +146,9 @@ public class SchemeBufferTable
// Save _schemesTable content.
try (PreparedStatement st = con.prepareStatement(INSERT_SCHEME))
{
for (Map.Entry<Integer, Map<String, ArrayList<Integer>>> player : _schemesTable.entrySet())
for (Map.Entry<Integer, Map<String, List<Integer>>> player : _schemesTable.entrySet())
{
for (Map.Entry<String, ArrayList<Integer>> scheme : player.getValue().entrySet())
for (Map.Entry<String, List<Integer>> scheme : player.getValue().entrySet())
{
// Build a String composed of skill ids seperated by a ",".
final StringBuilder sb = new StringBuilder();
@@ -178,7 +178,7 @@ public class SchemeBufferTable
}
}
public void setScheme(int playerId, String schemeName, ArrayList<Integer> list)
public void setScheme(int playerId, String schemeName, List<Integer> list)
{
if (!_schemesTable.containsKey(playerId))
{
@@ -196,7 +196,7 @@ public class SchemeBufferTable
* @param playerId : The player objectId to check.
* @return the list of schemes for a given player.
*/
public Map<String, ArrayList<Integer>> getPlayerSchemes(int playerId)
public Map<String, List<Integer>> getPlayerSchemes(int playerId)
{
return _schemesTable.get(playerId);
}
@@ -246,7 +246,7 @@ public class SchemeBufferTable
*/
public List<Integer> getSkillsIdsByType(String groupType)
{
List<Integer> skills = new ArrayList<>();
final List<Integer> skills = new ArrayList<>();
for (BuffSkillHolder skill : _availableBuffs.values())
{
if (skill.getType().equalsIgnoreCase(groupType))
@@ -262,7 +262,7 @@ public class SchemeBufferTable
*/
public List<String> getSkillTypes()
{
List<String> skillTypes = new ArrayList<>();
final List<String> skillTypes = new ArrayList<>();
for (BuffSkillHolder skill : _availableBuffs.values())
{
if (!skillTypes.contains(skill.getType()))

View File

@@ -134,7 +134,7 @@ public class GeoEngine
FileChannel fc = raf.getChannel())
{
// initialize file buffer
MappedByteBuffer buffer = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()).load();
final MappedByteBuffer buffer = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()).load();
buffer.order(ByteOrder.LITTLE_ENDIAN);
// get block indexes
@@ -563,7 +563,7 @@ public class GeoEngine
dirt = 0;
// calculate next point coordinates
int e2 = 2 * d;
final int e2 = 2 * d;
if ((e2 > -dy) && (e2 < dx))
{
// calculate next point XY coordinates
@@ -713,7 +713,7 @@ public class GeoEngine
}
// perform geodata check
GeoLocation loc = checkMove(gox, goy, goz, gtx, gty, gtz, instance);
final GeoLocation loc = checkMove(gox, goy, goz, gtx, gty, gtz, instance);
return (loc.getGeoX() == gtx) && (loc.getGeoY() == gty);
}
@@ -843,7 +843,7 @@ public class GeoEngine
direction = 0;
// calculate next point coordinates
int e2 = 2 * d;
final int e2 = 2 * d;
if ((e2 > -dy) && (e2 < dx))
{
d -= dy;

View File

@@ -40,18 +40,18 @@ final class GeoEnginePathfinding extends GeoEngine
{
super();
String[] array = Config.PATHFIND_BUFFERS.split(";");
final String[] array = Config.PATHFIND_BUFFERS.split(";");
_buffers = new BufferHolder[array.length];
int count = 0;
for (int i = 0; i < array.length; i++)
{
String buf = array[i];
String[] args = buf.split("x");
final String buf = array[i];
final String[] args = buf.split("x");
try
{
int size = Integer.parseInt(args[1]);
final int size = Integer.parseInt(args[1]);
count += size;
_buffers[i] = new BufferHolder(Integer.parseInt(args[0]), size);
}
@@ -68,24 +68,24 @@ final class GeoEnginePathfinding extends GeoEngine
public List<Location> findPath(int ox, int oy, int oz, int tx, int ty, int tz, Instance instance)
{
// get origin and check existing geo coords
int gox = getGeoX(ox);
int goy = getGeoY(oy);
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
if (!hasGeoPos(gox, goy))
{
return null;
}
short goz = getHeightNearest(gox, goy, oz);
final short goz = getHeightNearest(gox, goy, oz);
// get target and check existing geo coords
int gtx = getGeoX(tx);
int gty = getGeoY(ty);
final int gtx = getGeoX(tx);
final int gty = getGeoY(ty);
if (!hasGeoPos(gtx, gty))
{
return null;
}
short gtz = getHeightNearest(gtx, gty, tz);
final short gtz = getHeightNearest(gtx, gty, tz);
// Prepare buffer for pathfinding calculations
final NodeBuffer buffer = getBuffer(64 + (2 * Math.max(Math.abs(gox - gtx), Math.abs(goy - gty))));
@@ -98,7 +98,7 @@ final class GeoEnginePathfinding extends GeoEngine
List<Location> path = null;
try
{
Node result = buffer.findPath(gox, goy, goz, gtx, gty, gtz);
final Node result = buffer.findPath(gox, goy, goz, gtx, gty, gtz);
if (result == null)
{
@@ -124,7 +124,7 @@ final class GeoEnginePathfinding extends GeoEngine
}
// get path list iterator
ListIterator<Location> point = path.listIterator();
final ListIterator<Location> point = path.listIterator();
// get node A (origin)
int nodeAx = gox;
@@ -139,10 +139,10 @@ final class GeoEnginePathfinding extends GeoEngine
while (point.hasNext() && (count++ < Config.MAX_ITERATIONS))
{
// get node C
GeoLocation nodeC = (GeoLocation) path.get(point.nextIndex());
final GeoLocation nodeC = (GeoLocation) path.get(point.nextIndex());
// check movement from node A to node C
GeoLocation loc = checkMove(nodeAx, nodeAy, nodeAz, nodeC.getGeoX(), nodeC.getGeoY(), nodeC.getZ(), instance);
final GeoLocation loc = checkMove(nodeAx, nodeAy, nodeAz, nodeC.getGeoX(), nodeC.getGeoY(), nodeC.getZ(), instance);
if ((loc.getGeoX() == nodeC.getGeoX()) && (loc.getGeoY() == nodeC.getGeoY()))
{
// can move from node A to node C
@@ -175,7 +175,7 @@ final class GeoEnginePathfinding extends GeoEngine
private static List<Location> constructPath(Node target)
{
// create empty list
LinkedList<Location> list = new LinkedList<>();
final LinkedList<Location> list = new LinkedList<>();
// set direction X/Y
int dx = 0;

View File

@@ -86,7 +86,7 @@ public class BlockMultilayer extends ABlock
if (format != GeoFormat.L2D)
{
// get data
short data = bb.getShort();
final short data = bb.getShort();
// add nswe and height
_temp.put((byte) (data & 0x000F));
@@ -453,7 +453,7 @@ public class BlockMultilayer extends ABlock
for (int i = 0; i < GeoStructure.BLOCK_CELLS; i++)
{
// write layers count
byte layers = _buffer[index++];
final byte layers = _buffer[index++];
stream.write(layers);
// write cell data

View File

@@ -133,7 +133,7 @@ public class NodeBuffer
private final void expand()
{
// can't move anywhere, don't expand
byte nswe = _current.getLoc().getNSWE();
final byte nswe = _current.getLoc().getNSWE();
if (nswe == 0)
{
return;
@@ -217,7 +217,7 @@ public class NodeBuffer
}
// get node
Node result = _buffer[ix][iy];
final Node result = _buffer[ix][iy];
// check and update
if (result.getLoc() == null)
@@ -239,7 +239,7 @@ public class NodeBuffer
private final void addNode(int x, int y, short z, int weight)
{
// get node to be expanded
Node node = getNode(x, y, z);
final Node node = getNode(x, y, z);
if (node == null)
{
return;

View File

@@ -403,7 +403,7 @@ public class DBSpawnManager
{
for (Entry<Integer, StatsSet> entry : _storedInfo.entrySet())
{
Integer npcId = entry.getKey();
final Integer npcId = entry.getKey();
if (npcId == null)
{
continue;

View File

@@ -95,7 +95,7 @@ public class PremiumManager
private final Consumer<OnPlayerLogout> playerLogoutEvent = event ->
{
PlayerInstance player = event.getPlayer();
final PlayerInstance player = event.getPlayer();
stopExpireTask(player);
};
@@ -111,7 +111,7 @@ public class PremiumManager
*/
private void startExpireTask(PlayerInstance player, long delay)
{
ScheduledFuture<?> task = ThreadPool.schedule(new PremiumExpireTask(player), delay);
final ScheduledFuture<?> task = ThreadPool.schedule(new PremiumExpireTask(player), delay);
expiretasks.put(player.getAccountName(), task);
}
@@ -155,11 +155,11 @@ public class PremiumManager
public void addPremiumTime(String accountName, int timeValue, TimeUnit timeUnit)
{
long addTime = timeUnit.toMillis(timeValue);
long now = System.currentTimeMillis();
final long addTime = timeUnit.toMillis(timeValue);
final long now = System.currentTimeMillis();
// new premium task at least from now
long oldPremiumExpiration = Math.max(now, getPremiumExpiration(accountName));
long newPremiumExpiration = oldPremiumExpiration + addTime;
final long oldPremiumExpiration = Math.max(now, getPremiumExpiration(accountName));
final long newPremiumExpiration = oldPremiumExpiration + addTime;
// UPDATE DATABASE
try (Connection con = DatabaseFactory.getConnection();
@@ -178,7 +178,7 @@ public class PremiumManager
premiumData.put(accountName, newPremiumExpiration);
// UPDATE PlAYER PREMIUMSTATUS
PlayerInstance playerOnline = World.getInstance().getPlayers().stream().filter(p -> accountName.equals(p.getAccountName())).findFirst().orElse(null);
final PlayerInstance playerOnline = World.getInstance().getPlayers().stream().filter(p -> accountName.equals(p.getAccountName())).findFirst().orElse(null);
if (playerOnline != null)
{
stopExpireTask(playerOnline);
@@ -195,7 +195,7 @@ public class PremiumManager
{
if (checkOnline)
{
PlayerInstance playerOnline = World.getInstance().getPlayers().stream().filter(p -> accountName.equals(p.getAccountName())).findFirst().orElse(null);
final PlayerInstance playerOnline = World.getInstance().getPlayers().stream().filter(p -> accountName.equals(p.getAccountName())).findFirst().orElse(null);
if ((playerOnline != null) && playerOnline.hasPremiumStatus())
{
playerOnline.setPremiumStatus(false);

View File

@@ -875,7 +875,7 @@ public class Party extends AbstractPlayerGroup
// Add the XP/SP points to the requested party member
double exp = member.getStat().getValue(Stats.EXPSP_RATE, xpReward * preCalculation);
double sp = member.getStat().getValue(Stats.EXPSP_RATE, spReward * preCalculation);
final double sp = member.getStat().getValue(Stats.EXPSP_RATE, spReward * preCalculation);
exp = calculateExpSpPartyCutoff(member.getActingPlayer(), topLvl, exp, sp, target.useVitalityRate());
if (exp > 0)

View File

@@ -170,7 +170,7 @@ public class Territory
int zmin = _zMin;
for (Point p1 : _points)
{
double distance = Math.hypot(p1._x - x, p1._y - y);
final double distance = Math.hypot(p1._x - x, p1._y - y);
if ((curdistance == 0) || (distance < curdistance))
{
curdistance = distance;

View File

@@ -88,7 +88,7 @@ public class Attackable extends Npc
private boolean _isRaidMinion = false;
//
private boolean _champion = false;
private volatile Map<Creature, AggroInfo> _aggroList = new ConcurrentHashMap<>();
private final Map<Creature, AggroInfo> _aggroList = new ConcurrentHashMap<>();
private boolean _isReturningToSpawnPoint = false;
private boolean _canReturnToSpawnPoint = true;
private boolean _seeThroughSilentMove = false;
@@ -106,7 +106,7 @@ public class Attackable extends Npc
private double _overhitDamage;
private Creature _overhitAttacker;
// Command channel
private volatile CommandChannel _firstCommandChannelAttacked = null;
private CommandChannel _firstCommandChannelAttacked = null;
private CommandChannelTimer _commandChannelTimer = null;
private long _commandChannelLastAttack = 0;
// Misc
@@ -239,15 +239,12 @@ public class Attackable extends Npc
addDamage(attacker, (int) value, skill);
// Check Raidboss attack. Character will be petrified if attacking a raid that's more than 8 levels lower. In retail you deal damage to raid before curse.
if (_isRaid && giveRaidCurse() && !Config.RAID_DISABLE_CURSE)
if (_isRaid && giveRaidCurse() && !Config.RAID_DISABLE_CURSE && (attacker.getLevel() > (getLevel() + 8)))
{
if (attacker.getLevel() > (getLevel() + 8))
final Skill raidCurse = CommonSkill.RAID_CURSE2.getSkill();
if (raidCurse != null)
{
final Skill raidCurse = CommonSkill.RAID_CURSE2.getSkill();
if (raidCurse != null)
{
raidCurse.applyEffects(this, attacker);
}
raidCurse.applyEffects(this, attacker);
}
}
}
@@ -1436,19 +1433,16 @@ public class Attackable extends Npc
// Reset champion state
_champion = false;
if (Config.CHAMPION_ENABLE)
// Set champion on next spawn
if (Config.CHAMPION_ENABLE && isMonster() && !isQuestMonster() && !getTemplate().isUndying() && !_isRaid && !_isRaidMinion && (Config.CHAMPION_FREQUENCY > 0) && (getLevel() >= Config.CHAMP_MIN_LVL) && (getLevel() <= Config.CHAMP_MAX_LVL) && (Config.CHAMPION_ENABLE_IN_INSTANCES || (getInstanceId() == 0)))
{
// Set champion on next spawn
if (isMonster() && !isQuestMonster() && !getTemplate().isUndying() && !_isRaid && !_isRaidMinion && (Config.CHAMPION_FREQUENCY > 0) && (getLevel() >= Config.CHAMP_MIN_LVL) && (getLevel() <= Config.CHAMP_MAX_LVL) && (Config.CHAMPION_ENABLE_IN_INSTANCES || (getInstanceId() == 0)))
if (Rnd.get(100) < Config.CHAMPION_FREQUENCY)
{
if (Rnd.get(100) < Config.CHAMPION_FREQUENCY)
{
_champion = true;
}
if (Config.SHOW_CHAMPION_AURA)
{
setTeam(_champion ? Team.RED : Team.NONE, false);
}
_champion = true;
}
if (Config.SHOW_CHAMPION_AURA)
{
setTeam(_champion ? Team.RED : Team.NONE, false);
}
}
@@ -1748,12 +1742,9 @@ public class Attackable extends Npc
{
final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList;
if (target != null)
if ((target != null) && (aggroList != null))
{
if (aggroList != null)
{
aggroList.remove(target);
}
aggroList.remove(target);
}
if ((aggroList != null) && aggroList.isEmpty())
{

View File

@@ -179,7 +179,7 @@ import org.l2jmobius.gameserver.util.Util;
public abstract class Creature extends WorldObject implements ISkillsHolder, IDeletable
{
public static final Logger LOGGER = Logger.getLogger(Creature.class.getName());
private volatile Set<WeakReference<Creature>> _attackByList;
private Set<WeakReference<Creature>> _attackByList;
private boolean _isDead = false;
private boolean _isImmobilized = false;
@@ -193,7 +193,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
private boolean _isFlying = false;
private boolean _blockActions = false;
private volatile Map<Integer, AtomicInteger> _blockActionsAllowedSkills = new ConcurrentHashMap<>();
private final Map<Integer, AtomicInteger> _blockActionsAllowedSkills = new ConcurrentHashMap<>();
private CreatureStat _stat;
private CreatureStatus _status;
@@ -229,16 +229,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
private boolean _lethalable = true;
private volatile Map<Integer, OptionsSkillHolder> _triggerSkills;
private Map<Integer, OptionsSkillHolder> _triggerSkills;
private volatile Map<Integer, IgnoreSkillHolder> _ignoreSkillEffects;
private Map<Integer, IgnoreSkillHolder> _ignoreSkillEffects;
/** Creatures effect list. */
private final EffectList _effectList = new EffectList(this);
/** The creature that summons this character. */
private Creature _summoner = null;
/** Map of summoned NPCs by this creature. */
private volatile Map<Integer, Npc> _summonedNpcs = null;
private Map<Integer, Npc> _summonedNpcs = null;
private SkillChannelizer _channelizer = null;
@@ -260,7 +260,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
private volatile long _attackEndTime;
private volatile long _disableRangedAttackEndTime;
private volatile CreatureAI _ai = null;
private CreatureAI _ai = null;
/** Future Skill Cast */
protected Map<SkillCastingType, SkillCaster> _skillCasters = new ConcurrentHashMap<>();
@@ -269,12 +269,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
private final Map<Integer, Integer> _knownRelations = new ConcurrentHashMap<>();
private volatile CreatureContainer _seenCreatures;
private CreatureContainer _seenCreatures;
private final Map<StatusUpdateType, Integer> _statusUpdates = new ConcurrentHashMap<>();
/** A map holding info about basic property mesmerizing system. */
private volatile Map<BasicProperty, BasicPropertyResist> _basicPropertyResists;
private Map<BasicProperty, BasicPropertyResist> _basicPropertyResists;
private ScheduledFuture<?> _hitTask = null;
/** A set containing the shot types currently charged. */
@@ -920,14 +920,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if (isPlayer())
else if (isPlayer() && target.isDead())
{
if (target.isDead())
{
getAI().setIntention(AI_INTENTION_ACTIVE);
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
getAI().setIntention(AI_INTENTION_ACTIVE);
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (checkTransformed(transform -> !transform.canAttack()))
@@ -1091,6 +1088,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
case TWOHANDCROSSBOW:
{
crossbow = true;
// fallthrough
}
case BOW:
{
@@ -1129,6 +1127,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
_hitTask = ThreadPool.schedule(() -> onHitTimeNotDual(weaponItem, attack, timeToHit, timeAtk), timeToHit);
break;
}
// fallthrough
}
case DUAL:
case DUALFIST:
@@ -1249,13 +1248,13 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
int damage = 0;
byte shld = 0;
boolean crit = false;
boolean miss = Formulas.calcHitMiss(this, target);
final boolean miss = Formulas.calcHitMiss(this, target);
if (!shotConsumed)
{
shotConsumed = !miss && unchargeShot(ShotType.SOULSHOTS);
}
int ssGrade = (shotConsumed && (weapon != null)) ? weapon.getItemGrade().ordinal() : 0;
final int ssGrade = (shotConsumed && (weapon != null)) ? weapon.getItemGrade().ordinal() : 0;
// Check if hit isn't missed
if (!miss)
@@ -2956,7 +2955,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
final int xPrev = getX();
final int yPrev = getY();
int zPrev = getZ(); // the z coordinate may be modified by coordinate synchronizations
final int zPrev = getZ(); // the z coordinate may be modified by coordinate synchronizations
double dx;
double dy;
@@ -3778,12 +3777,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
{
for (OptionsSkillHolder holder : _triggerSkills.values())
{
if ((!hit.isCritical() && (holder.getSkillType() == OptionsSkillType.ATTACK)) || ((holder.getSkillType() == OptionsSkillType.CRITICAL) && hit.isCritical()))
if (((!hit.isCritical() && (holder.getSkillType() == OptionsSkillType.ATTACK)) || ((holder.getSkillType() == OptionsSkillType.CRITICAL) && hit.isCritical())) && (Rnd.get(100) < holder.getChance()))
{
if (Rnd.get(100) < holder.getChance())
{
SkillCaster.triggerCast(this, target, holder.getSkill(), null, false);
}
SkillCaster.triggerCast(this, target, holder.getSkill(), null, false);
}
}
}
@@ -4408,7 +4404,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
int reflectedDamage = 0;
// Reduce HP of the target and calculate reflection damage to reduce HP of attacker if necessary
double reflectPercent = target.getStat().getValue(Stats.REFLECT_DAMAGE_PERCENT, 0) - getStat().getValue(Stats.REFLECT_DAMAGE_PERCENT_DEFENSE, 0);
final double reflectPercent = target.getStat().getValue(Stats.REFLECT_DAMAGE_PERCENT, 0) - getStat().getValue(Stats.REFLECT_DAMAGE_PERCENT_DEFENSE, 0);
if (reflectPercent > 0)
{
reflectedDamage = (int) ((reflectPercent / 100.) * damage);

View File

@@ -698,7 +698,7 @@ public class Npc extends Creature
String html = HtmCache.getInstance().getHtm(player, "data/html/" + type + "/" + getId() + "-pk.htm");
if (html != null)
{
html = html.replaceAll("%objectId%", String.valueOf(getObjectId()));
html = html.replace("%objectId%", String.valueOf(getObjectId()));
player.sendPacket(new NpcHtmlMessage(getObjectId(), html));
player.sendPacket(ActionFailed.STATIC_PACKET);
return true;
@@ -1551,12 +1551,9 @@ public class Npc extends Creature
item.dropMe(this, newX, newY, newZ);
// Add drop to auto destroy item task.
if (!Config.LIST_PROTECTED_ITEMS.contains(itemId))
if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect())))
{
if (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))
{
ItemsAutoDestroy.getInstance().addItem(item);
}
ItemsAutoDestroy.getInstance().addItem(item);
}
item.setProtected(false);

View File

@@ -59,7 +59,7 @@ public class GuardInstance extends Attackable
}
if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_GUARDS_ENABLED && attacker.isPlayable())
{
PlayerInstance player = attacker.getActingPlayer();
final PlayerInstance player = attacker.getActingPlayer();
if ((player.isGood() && getTemplate().isClan(Config.FACTION_EVIL_TEAM_NAME)) || (player.isEvil() && getTemplate().isClan(Config.FACTION_GOOD_TEAM_NAME)))
{
return true;

View File

@@ -460,7 +460,7 @@ public class PlayerInstance extends Playable
/** The Raidboss points of this PlayerInstance */
private int _raidbossPoints;
private volatile ScheduledFuture<?> _teleportWatchdog;
private ScheduledFuture<?> _teleportWatchdog;
/** The Siege state of the PlayerInstance */
private byte _siegeState = 0;
@@ -549,7 +549,7 @@ public class PlayerInstance extends Playable
private TradeList _activeTradeList;
private ItemContainer _activeWarehouse;
private volatile Map<Integer, ManufactureItem> _manufactureItems;
private Map<Integer, ManufactureItem> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
@@ -627,7 +627,7 @@ public class PlayerInstance extends Playable
private long _clanCreateExpiryTime;
private int _powerGrade = 0;
private volatile EnumIntBitmask<ClanPrivilege> _clanPrivileges = new EnumIntBitmask<>(ClanPrivilege.class, false);
private EnumIntBitmask<ClanPrivilege> _clanPrivileges = new EnumIntBitmask<>(ClanPrivilege.class, false);
/** PlayerInstance's pledge class (knight, Baron, etc.) */
private int _pledgeClass = 0;
@@ -710,7 +710,7 @@ public class PlayerInstance extends Playable
private byte _handysBlockCheckerEventArena = -1;
/** new race ticket **/
private final int _race[] = new int[2];
private final int[] _race = new int[2];
private final BlockList _blockList = new BlockList(this);
@@ -1023,27 +1023,24 @@ public class PlayerInstance extends Playable
result |= RelationChanged.RELATION_ATTACKER;
}
}
if ((clan != null) && (targetClan != null))
if ((clan != null) && (targetClan != null) && (target.getPledgeType() != Clan.SUBUNIT_ACADEMY) && (getPledgeType() != Clan.SUBUNIT_ACADEMY))
{
if ((target.getPledgeType() != Clan.SUBUNIT_ACADEMY) && (getPledgeType() != Clan.SUBUNIT_ACADEMY))
final ClanWar war = clan.getWarWith(target.getClan().getId());
if (war != null)
{
ClanWar war = clan.getWarWith(target.getClan().getId());
if (war != null)
switch (war.getState())
{
switch (war.getState())
case DECLARATION:
case BLOOD_DECLARATION:
{
case DECLARATION:
case BLOOD_DECLARATION:
{
result |= RelationChanged.RELATION_DECLARED_WAR;
break;
}
case MUTUAL:
{
result |= RelationChanged.RELATION_DECLARED_WAR;
result |= RelationChanged.RELATION_MUTUAL_WAR;
break;
}
result |= RelationChanged.RELATION_DECLARED_WAR;
break;
}
case MUTUAL:
{
result |= RelationChanged.RELATION_DECLARED_WAR;
result |= RelationChanged.RELATION_MUTUAL_WAR;
break;
}
}
}
@@ -1467,7 +1464,7 @@ public class PlayerInstance extends Playable
}
/** List of all QuestState instance that needs to be notified of this PlayerInstance's or its pet's death */
private volatile Set<QuestState> _notifyQuestOfDeathList;
private Set<QuestState> _notifyQuestOfDeathList;
/**
* Add QuestState instance that is to be notified of PlayerInstance's death.
@@ -1625,11 +1622,7 @@ public class PlayerInstance extends Playable
public boolean isRegisteredOnThisSiegeField(int val)
{
if ((_siegeSide != val) && ((_siegeSide < 81) || (_siegeSide > 89)))
{
return false;
}
return true;
return (_siegeSide != val) && ((_siegeSide < 81) || (_siegeSide > 89));
}
public int getSiegeSide()
@@ -2047,7 +2040,7 @@ public class PlayerInstance extends Playable
/**
* Update the overloaded status of the PlayerInstance.
* @param broadcast TODO
* @param broadcast
*/
public void refreshOverloaded(boolean broadcast)
{
@@ -2337,9 +2330,9 @@ public class PlayerInstance extends Playable
/**
* Set the template of the PlayerInstance.
* @param Id The Identifier of the PlayerTemplate to set to the PlayerInstance
* @param id The Identifier of the PlayerTemplate to set to the PlayerInstance
*/
public void setClassId(int Id)
public void setClassId(int id)
{
if (!_subclassLock.tryLock())
{
@@ -2348,7 +2341,7 @@ public class PlayerInstance extends Playable
try
{
if ((getLvlJoinedAcademy() != 0) && (_clan != null) && CategoryData.getInstance().isInCategory(CategoryType.THIRD_CLASS_GROUP, Id))
if ((getLvlJoinedAcademy() != 0) && (_clan != null) && CategoryData.getInstance().isInCategory(CategoryType.THIRD_CLASS_GROUP, id))
{
if (_lvlJoinedAcademy <= 16)
{
@@ -2376,11 +2369,11 @@ public class PlayerInstance extends Playable
}
if (isSubClassActive())
{
getSubClasses().get(_classIndex).setClassId(Id);
getSubClasses().get(_classIndex).setClassId(id);
}
setTarget(this);
broadcastPacket(new MagicSkillUse(this, 5103, 1, 1000, 0));
setClassTemplate(Id);
setClassTemplate(id);
if (getClassId().level() == 3)
{
sendPacket(SystemMessageId.CONGRATULATIONS_YOU_VE_COMPLETED_YOUR_THIRD_CLASS_TRANSFER_QUEST);
@@ -3268,7 +3261,6 @@ public class PlayerInstance extends Playable
{
CursedWeaponsManager.getInstance().activate(this, newitem);
}
// Combat Flag
else if (FortSiegeManager.getInstance().isCombat(item.getId()))
{
@@ -3712,25 +3704,15 @@ public class PlayerInstance extends Playable
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()))
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()))
{
if ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())
{
ItemsAutoDestroy.getInstance().addItem(item);
}
ItemsAutoDestroy.getInstance().addItem(item);
}
// protection against auto destroy dropped item
if (Config.DESTROY_DROPPED_PLAYER_ITEM)
{
if (!item.isEquipable() || (item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM))
{
item.setProtected(false);
}
else
{
item.setProtected(true);
}
item.setProtected(item.isEquipable() && (!item.isEquipable() || !Config.DESTROY_EQUIPABLE_PLAYER_ITEM));
}
else
{
@@ -3801,23 +3783,13 @@ public class PlayerInstance extends Playable
item.dropMe(this, x, y, z);
if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()))
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()))
{
if ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())
{
ItemsAutoDestroy.getInstance().addItem(item);
}
ItemsAutoDestroy.getInstance().addItem(item);
}
if (Config.DESTROY_DROPPED_PLAYER_ITEM)
{
if (!item.isEquipable() || (item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM))
{
item.setProtected(false);
}
else
{
item.setProtected(true);
}
item.setProtected(item.isEquipable() && (!item.isEquipable() || !Config.DESTROY_EQUIPABLE_PLAYER_ITEM));
}
else
{
@@ -4170,7 +4142,7 @@ public class PlayerInstance extends Playable
// Update relation.
final int relation = getRelation(player);
Integer oldrelation = getKnownRelations().get(player.getObjectId());
final Integer oldrelation = getKnownRelations().get(player.getObjectId());
if ((oldrelation == null) || (oldrelation != relation))
{
final RelationChanged rc = new RelationChanged();
@@ -4465,12 +4437,9 @@ public class PlayerInstance extends Playable
}
// You can pickup only 1 combat flag
if (FortSiegeManager.getInstance().isCombat(target.getId()))
if (FortSiegeManager.getInstance().isCombat(target.getId()) && !FortSiegeManager.getInstance().checkIfCanPickup(this))
{
if (!FortSiegeManager.getInstance().checkIfCanPickup(this))
{
return;
}
return;
}
if ((target.getItemLootShedule() != null) && ((target.getOwnerId() == getObjectId()) || isInLooterParty(target.getOwnerId())))
@@ -4797,20 +4766,13 @@ public class PlayerInstance extends Playable
{
final ItemInstance legs = getLegsArmorInstance();
final ItemInstance armor = getChestArmorInstance();
if ((armor != null) && (legs != null))
if ((armor != null) && (legs != null) && (legs.getItemType() == ArmorType.HEAVY) && (armor.getItemType() == ArmorType.HEAVY))
{
if ((legs.getItemType() == ArmorType.HEAVY) && (armor.getItemType() == ArmorType.HEAVY))
{
return true;
}
return true;
}
if (armor != null)
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY)))
{
if (((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY)))
{
return true;
}
return true;
}
return false;
}
@@ -4819,20 +4781,13 @@ public class PlayerInstance extends Playable
{
final ItemInstance legs = getLegsArmorInstance();
final ItemInstance armor = getChestArmorInstance();
if ((armor != null) && (legs != null))
if ((armor != null) && (legs != null) && (legs.getItemType() == ArmorType.LIGHT) && (armor.getItemType() == ArmorType.LIGHT))
{
if ((legs.getItemType() == ArmorType.LIGHT) && (armor.getItemType() == ArmorType.LIGHT))
{
return true;
}
return true;
}
if (armor != null)
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT)))
{
if (((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT)))
{
return true;
}
return true;
}
return false;
}
@@ -4841,20 +4796,13 @@ public class PlayerInstance extends Playable
{
final ItemInstance legs = getLegsArmorInstance();
final ItemInstance armor = getChestArmorInstance();
if ((armor != null) && (legs != null))
if ((armor != null) && (legs != null) && (legs.getItemType() == ArmorType.MAGIC) && (armor.getItemType() == ArmorType.MAGIC))
{
if ((legs.getItemType() == ArmorType.MAGIC) && (armor.getItemType() == ArmorType.MAGIC))
{
return true;
}
return true;
}
if (armor != null)
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC)))
{
if (((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC)))
{
return true;
}
return true;
}
return false;
}
@@ -5307,29 +5255,29 @@ public class PlayerInstance extends Playable
public void updatePvPStatus(Creature target)
{
final PlayerInstance player_target = target.getActingPlayer();
if (player_target == null)
final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer == null)
{
return;
}
if (this == player_target)
if (this == targetPlayer)
{
return;
}
if (Config.FACTION_SYSTEM_ENABLED && target.isPlayer() && ((isGood() && player_target.isEvil()) || (isEvil() && player_target.isGood())))
if (Config.FACTION_SYSTEM_ENABLED && target.isPlayer() && ((isGood() && targetPlayer.isEvil()) || (isEvil() && targetPlayer.isGood())))
{
return;
}
if (_isInDuel && (player_target.getDuelId() == getDuelId()))
if (_isInDuel && (targetPlayer.getDuelId() == getDuelId()))
{
return;
}
if ((!isInsideZone(ZoneId.PVP) || !player_target.isInsideZone(ZoneId.PVP)) && (player_target.getReputation() >= 0))
if ((!isInsideZone(ZoneId.PVP) || !targetPlayer.isInsideZone(ZoneId.PVP)) && (targetPlayer.getReputation() >= 0))
{
if (checkIfPvP(player_target))
if (checkIfPvP(targetPlayer))
{
setPvpFlagLasts(System.currentTimeMillis() + Config.PVP_PVP_TIME);
}
@@ -5549,12 +5497,9 @@ public class PlayerInstance extends Playable
public PlayerInstance getActiveRequester()
{
final PlayerInstance requester = _activeRequester;
if (requester != null)
if ((requester != null) && requester.isRequestExpired() && (_activeTradeList == null))
{
if (requester.isRequestExpired() && (_activeTradeList == null))
{
_activeRequester = null;
}
_activeRequester = null;
}
return _activeRequester;
}
@@ -5599,7 +5544,7 @@ public class PlayerInstance extends Playable
*/
public boolean isRequestExpired()
{
return !(_requestExpireTime > GameTimeController.getInstance().getGameTicks());
return _requestExpireTime <= GameTimeController.getInstance().getGameTicks();
}
/**
@@ -6669,16 +6614,13 @@ public class PlayerInstance extends Playable
}
// Restore Subclass Data (cannot be done earlier in function)
if (restoreSubClassData(player))
if (restoreSubClassData(player) && (activeClassId != player.getBaseClass()))
{
if (activeClassId != player.getBaseClass())
for (SubClass subClass : player.getSubClasses().values())
{
for (SubClass subClass : player.getSubClasses().values())
if (subClass.getClassId() == activeClassId)
{
if (subClass.getClassId() == activeClassId)
{
player.setClassIndex(subClass.getClassIndex());
}
player.setClassIndex(subClass.getClassIndex());
}
}
}
@@ -7262,7 +7204,7 @@ public class PlayerInstance extends Playable
delete.execute();
}
int buff_index = 0;
int buffIndex = 0;
final List<Long> storedSkills = new ArrayList<>();
final long currentTime = System.currentTimeMillis();
@@ -7329,7 +7271,7 @@ public class PlayerInstance extends Playable
statement.setInt(8, 0); // Store type 0, active buffs/debuffs.
statement.setInt(9, _classIndex);
statement.setInt(10, ++buff_index);
statement.setInt(10, ++buffIndex);
statement.addBatch();
}
}
@@ -7357,7 +7299,7 @@ public class PlayerInstance extends Playable
statement.setDouble(7, t.getStamp());
statement.setInt(8, 1); // Restore type 1, skill reuse.
statement.setInt(9, _classIndex);
statement.setInt(10, ++buff_index);
statement.setInt(10, ++buffIndex);
statement.addBatch();
}
}
@@ -7631,15 +7573,12 @@ public class PlayerInstance extends Playable
// Add the Skill object to the Creature _skills and its Func objects to the calculator set of the Creature
addSkill(skill);
if (Config.SKILL_CHECK_ENABLE && (!canOverrideCond(PlayerCondOverride.SKILL_CONDITIONS) || Config.SKILL_CHECK_GM))
if (Config.SKILL_CHECK_ENABLE && (!canOverrideCond(PlayerCondOverride.SKILL_CONDITIONS) || Config.SKILL_CHECK_GM) && !SkillTreesData.getInstance().isSkillAllowed(this, skill))
{
if (!SkillTreesData.getInstance().isSkillAllowed(this, skill))
Util.handleIllegalPlayerAction(this, "Player " + getName() + " has invalid skill " + skill.getName() + " (" + skill.getId() + "/" + skill.getLevel() + "), class:" + ClassListData.getInstance().getClass(getClassId()).getClassName(), IllegalActionPunishmentType.BROADCAST);
if (Config.SKILL_CHECK_REMOVE)
{
Util.handleIllegalPlayerAction(this, "Player " + getName() + " has invalid skill " + skill.getName() + " (" + skill.getId() + "/" + skill.getLevel() + "), class:" + ClassListData.getInstance().getClass(getClassId()).getClassName(), IllegalActionPunishmentType.BROADCAST);
if (Config.SKILL_CHECK_REMOVE)
{
removeSkill(skill);
}
removeSkill(skill);
}
}
}
@@ -8218,11 +8157,7 @@ public class PlayerInstance extends Playable
// Check if the attacker is in olympia and olympia start
if (attacker.isPlayer() && attacker.getActingPlayer().isInOlympiadMode())
{
if (_inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId()))
{
return true;
}
return false;
return _inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId());
}
if (_isOnCustomEvent && (getTeam() == attacker.getTeam()))
@@ -8308,13 +8243,10 @@ public class PlayerInstance extends Playable
}
}
if (attacker instanceof DefenderInstance)
if ((attacker instanceof DefenderInstance) && (_clan != null))
{
if (_clan != null)
{
final Siege siege = SiegeManager.getInstance().getSiege(this);
return ((siege != null) && siege.checkIsAttacker(_clan));
}
final Siege siege = SiegeManager.getInstance().getSiege(this);
return ((siege != null) && siege.checkIsAttacker(_clan));
}
if (attacker instanceof GuardInstance)
@@ -8513,18 +8445,15 @@ public class PlayerInstance extends Playable
sendPacket(ActionFailed.STATIC_PACKET);
// Upon failed conditions, next action is called.
if ((skill.getNextAction() != NextActionType.NONE) && (target != this) && target.isAutoAttackable(this))
if ((skill.getNextAction() != NextActionType.NONE) && (target != this) && target.isAutoAttackable(this) && ((getAI().getNextIntention() == null) || (getAI().getNextIntention().getCtrlIntention() != CtrlIntention.AI_INTENTION_MOVE_TO)))
{
if ((getAI().getNextIntention() == null) || (getAI().getNextIntention().getCtrlIntention() != CtrlIntention.AI_INTENTION_MOVE_TO))
if (skill.getNextAction() == NextActionType.ATTACK)
{
if (skill.getNextAction() == NextActionType.ATTACK)
{
getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
}
else if (skill.getNextAction() == NextActionType.CAST)
{
getAI().setIntention(CtrlIntention.AI_INTENTION_CAST, skill, target, item, false, false);
}
getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
}
else if (skill.getNextAction() == NextActionType.CAST)
{
getAI().setIntention(CtrlIntention.AI_INTENTION_CAST, skill, target, item, false, false);
}
}
@@ -8557,9 +8486,9 @@ public class PlayerInstance extends Playable
return true;
}
public boolean isInLooterParty(int LooterId)
public boolean isInLooterParty(int looterId)
{
final PlayerInstance looter = World.getInstance().getPlayer(LooterId);
final PlayerInstance looter = World.getInstance().getPlayer(looterId);
// if PlayerInstance is in a CommandChannel
if (isInParty() && _party.isInCommandChannel() && (looter != null))
@@ -8975,9 +8904,9 @@ public class PlayerInstance extends Playable
return _apprentice;
}
public void setApprentice(int apprentice_id)
public void setApprentice(int apprenticeId)
{
_apprentice = apprentice_id;
_apprentice = apprenticeId;
}
public int getSponsor()
@@ -8985,9 +8914,9 @@ public class PlayerInstance extends Playable
return _sponsor;
}
public void setSponsor(int sponsor_id)
public void setSponsor(int sponsorId)
{
_sponsor = sponsor_id;
_sponsor = sponsorId;
}
public int getBookMarkSlot()
@@ -10035,12 +9964,7 @@ public class PlayerInstance extends Playable
public boolean isRentedPet()
{
if (_taskRentPet != null)
{
return true;
}
return false;
return _taskRentPet != null;
}
public void stopWaterTask()
@@ -10066,12 +9990,7 @@ public class PlayerInstance extends Playable
public boolean isInWater()
{
if (_taskWater != null)
{
return true;
}
return false;
return _taskWater != null;
}
public void checkWaterState()
@@ -10506,12 +10425,11 @@ public class PlayerInstance extends Playable
}
}
public void broadcastSnoop(ChatType type, String name, String _text)
public void broadcastSnoop(ChatType type, String name, String text)
{
if (!_snoopListener.isEmpty())
{
final Snoop sn = new Snoop(getObjectId(), getName(), type, name, _text);
final Snoop sn = new Snoop(getObjectId(), getName(), type, name, text);
for (PlayerInstance pci : _snoopListener)
{
if (pci != null)
@@ -11666,43 +11584,40 @@ public class PlayerInstance extends Playable
{
Collection<Skill> currentSkills = getAllSkills();
if (isTransformed())
if (isTransformed() && !_transformSkills.isEmpty())
{
if (!_transformSkills.isEmpty())
// Include transformation skills and those skills that are allowed during transformation.
currentSkills = currentSkills.stream().filter(Skill::allowOnTransform).collect(Collectors.toList());
// Revelation skills.
if (isDualClassActive())
{
// Include transformation skills and those skills that are allowed during transformation.
currentSkills = currentSkills.stream().filter(Skill::allowOnTransform).collect(Collectors.toList());
// Revelation skills.
if (isDualClassActive())
int revelationSkill = getVariables().getInt(PlayerVariables.REVELATION_SKILL_1_DUAL_CLASS, 0);
if (revelationSkill != 0)
{
int revelationSkill = getVariables().getInt(PlayerVariables.REVELATION_SKILL_1_DUAL_CLASS, 0);
if (revelationSkill != 0)
{
addSkill(SkillData.getInstance().getSkill(revelationSkill, 1), false);
}
revelationSkill = getVariables().getInt(PlayerVariables.REVELATION_SKILL_2_DUAL_CLASS, 0);
if (revelationSkill != 0)
{
addSkill(SkillData.getInstance().getSkill(revelationSkill, 1), false);
}
addSkill(SkillData.getInstance().getSkill(revelationSkill, 1), false);
}
else if (!isSubClassActive())
revelationSkill = getVariables().getInt(PlayerVariables.REVELATION_SKILL_2_DUAL_CLASS, 0);
if (revelationSkill != 0)
{
int revelationSkill = getVariables().getInt(PlayerVariables.REVELATION_SKILL_1_MAIN_CLASS, 0);
if (revelationSkill != 0)
{
addSkill(SkillData.getInstance().getSkill(revelationSkill, 1), false);
}
revelationSkill = getVariables().getInt(PlayerVariables.REVELATION_SKILL_2_MAIN_CLASS, 0);
if (revelationSkill != 0)
{
addSkill(SkillData.getInstance().getSkill(revelationSkill, 1), false);
}
addSkill(SkillData.getInstance().getSkill(revelationSkill, 1), false);
}
// Include transformation skills.
currentSkills.addAll(_transformSkills.values());
}
else if (!isSubClassActive())
{
int revelationSkill = getVariables().getInt(PlayerVariables.REVELATION_SKILL_1_MAIN_CLASS, 0);
if (revelationSkill != 0)
{
addSkill(SkillData.getInstance().getSkill(revelationSkill, 1), false);
}
revelationSkill = getVariables().getInt(PlayerVariables.REVELATION_SKILL_2_MAIN_CLASS, 0);
if (revelationSkill != 0)
{
addSkill(SkillData.getInstance().getSkill(revelationSkill, 1), false);
}
}
// Include transformation skills.
currentSkills.addAll(_transformSkills.values());
}
//@formatter:off
@@ -12167,6 +12082,11 @@ public class PlayerInstance extends Playable
}
}
public Collection<TeleportBookmark> getTeleportBookmarks()
{
return _tpbookmarks.values();
}
@Override
public void sendInfo(PlayerInstance player)
{
@@ -12800,19 +12720,6 @@ public class PlayerInstance extends Playable
return _multiSocialTarget;
}
public Collection<TeleportBookmark> getTeleportBookmarks()
{
return _tpbookmarks.values();
}
public int getBookmarkslot()
{
return _bookmarkslot;
}
/**
* @return
*/
public int getQuestInventoryLimit()
{
return Config.INVENTORY_MAXIMUM_QUEST_ITEMS;

View File

@@ -49,8 +49,8 @@ public class SchemeBufferInstance extends Npc
// Simple hack to use createscheme bypass with a space.
command = command.replace("createscheme ", "createscheme;");
StringTokenizer st = new StringTokenizer(command, ";");
String currentCommand = st.nextToken();
final StringTokenizer st = new StringTokenizer(command, ";");
final String currentCommand = st.nextToken();
if (currentCommand.startsWith("menu"))
{
@@ -189,7 +189,7 @@ public class SchemeBufferInstance extends Npc
return;
}
final Map<String, ArrayList<Integer>> schemes = SchemeBufferTable.getInstance().getPlayerSchemes(player.getObjectId());
final Map<String, List<Integer>> schemes = SchemeBufferTable.getInstance().getPlayerSchemes(player.getObjectId());
if (schemes != null)
{
if (schemes.size() == Config.BUFFER_MAX_SCHEMES)
@@ -218,7 +218,7 @@ public class SchemeBufferInstance extends Npc
try
{
final String schemeName = st.nextToken();
final Map<String, ArrayList<Integer>> schemes = SchemeBufferTable.getInstance().getPlayerSchemes(player.getObjectId());
final Map<String, List<Integer>> schemes = SchemeBufferTable.getInstance().getPlayerSchemes(player.getObjectId());
if ((schemes != null) && schemes.containsKey(schemeName))
{
@@ -257,14 +257,14 @@ public class SchemeBufferInstance extends Npc
{
final StringBuilder sb = new StringBuilder(200);
final Map<String, ArrayList<Integer>> schemes = SchemeBufferTable.getInstance().getPlayerSchemes(player.getObjectId());
final Map<String, List<Integer>> schemes = SchemeBufferTable.getInstance().getPlayerSchemes(player.getObjectId());
if ((schemes == null) || schemes.isEmpty())
{
sb.append("<font color=\"LEVEL\">You haven't defined any scheme.</font>");
}
else
{
for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet())
for (Map.Entry<String, List<Integer>> scheme : schemes.entrySet())
{
final int cost = getFee(scheme.getValue());
sb.append("<font color=\"LEVEL\">" + scheme.getKey() + " [" + scheme.getValue().size() + " skill(s)]" + ((cost > 0) ? " - cost: " + NumberFormat.getInstance(Locale.ENGLISH).format(cost) : "") + "</font><br1>");
@@ -429,7 +429,7 @@ public class SchemeBufferInstance extends Npc
* @param list : A list of skill ids.
* @return a global fee for all skills contained in list.
*/
private static int getFee(ArrayList<Integer> list)
private static int getFee(List<Integer> list)
{
if (Config.BUFFER_STATIC_BUFF_COST > 0)
{

View File

@@ -154,28 +154,17 @@ public class SiegeFlagInstance extends Npc
public void reduceCurrentHp(double damage, Creature attacker, Skill skill)
{
super.reduceCurrentHp(damage, attacker, skill);
if (canTalk())
if (canTalk() && (((getCastle() != null) && getCastle().getSiege().isInProgress()) || ((getFort() != null) && getFort().getSiege().isInProgress())) && (_clan != null))
{
if (((getCastle() != null) && getCastle().getSiege().isInProgress()) || ((getFort() != null) && getFort().getSiege().isInProgress()))
{
if (_clan != null)
{
// send warning to owners of headquarters that theirs base is under attack
_clan.broadcastToOnlineMembers(new SystemMessage(SystemMessageId.SIEGE_CAMP_IS_UNDER_ATTACK));
setCanTalk(false);
ThreadPool.schedule(new ScheduleTalkTask(), 20000);
}
}
// send warning to owners of headquarters that theirs base is under attack
_clan.broadcastToOnlineMembers(new SystemMessage(SystemMessageId.SIEGE_CAMP_IS_UNDER_ATTACK));
setCanTalk(false);
ThreadPool.schedule(new ScheduleTalkTask(), 20000);
}
}
private class ScheduleTalkTask implements Runnable
{
public ScheduleTalkTask()
{
}
@Override
public void run()
{

View File

@@ -32,13 +32,12 @@ public class VillageMasterDElfInstance extends VillageMasterInstance
}
@Override
protected final boolean checkVillageMasterRace(ClassId pclass)
protected final boolean checkVillageMasterRace(ClassId pClass)
{
if (pclass == null)
if (pClass == null)
{
return false;
}
return pclass.getRace() == Race.DARK_ELF;
return pClass.getRace() == Race.DARK_ELF;
}
}

View File

@@ -32,13 +32,12 @@ public class VillageMasterDwarfInstance extends VillageMasterInstance
}
@Override
protected final boolean checkVillageMasterRace(ClassId pclass)
protected final boolean checkVillageMasterRace(ClassId pClass)
{
if (pclass == null)
if (pClass == null)
{
return false;
}
return pclass.getRace() == Race.DWARF;
return pClass.getRace() == Race.DWARF;
}
}

View File

@@ -34,24 +34,22 @@ public class VillageMasterFighterInstance extends VillageMasterInstance
}
@Override
protected final boolean checkVillageMasterRace(ClassId pclass)
protected final boolean checkVillageMasterRace(ClassId pClass)
{
if (pclass == null)
if (pClass == null)
{
return false;
}
return (pclass.getRace() == Race.HUMAN) || (pclass.getRace() == Race.ELF);
return (pClass.getRace() == Race.HUMAN) || (pClass.getRace() == Race.ELF);
}
@Override
protected final boolean checkVillageMasterTeachType(ClassId pclass)
protected final boolean checkVillageMasterTeachType(ClassId pClass)
{
if (pclass == null)
if (pClass == null)
{
return false;
}
return CategoryData.getInstance().isInCategory(CategoryType.FIGHTER_GROUP, pclass.getId());
return CategoryData.getInstance().isInCategory(CategoryType.FIGHTER_GROUP, pClass.getId());
}
}

View File

@@ -395,7 +395,7 @@ public class VillageMasterInstance extends NpcInstance
}
}
}
catch (Exception NumberFormatException)
catch (Exception nfe)
{
LOGGER.warning(VillageMasterInstance.class.getName() + ": Wrong numeric values for command " + command);
}
@@ -554,19 +554,15 @@ public class VillageMasterInstance extends NpcInstance
allowAddition = false;
}
if (allowAddition)
if (allowAddition && !player.getSubClasses().isEmpty())
{
if (!player.getSubClasses().isEmpty())
for (Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext();)
{
for (Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext();)
final SubClass subClass = subList.next();
if (subClass.getLevel() < 75)
{
final SubClass subClass = subList.next();
if (subClass.getLevel() < 75)
{
allowAddition = false;
break;
}
allowAddition = false;
break;
}
}
}
@@ -896,7 +892,7 @@ public class VillageMasterInstance extends NpcInstance
}
}
Set<ClassId> unavailableClasses = subclassSetMap.get(pClass);
final Set<ClassId> unavailableClasses = subclassSetMap.get(pClass);
if (unavailableClasses != null)
{
subclasses.removeAll(unavailableClasses);
@@ -977,12 +973,12 @@ public class VillageMasterInstance extends NpcInstance
return found;
}
protected boolean checkVillageMasterRace(ClassId pclass)
protected boolean checkVillageMasterRace(ClassId pClass)
{
return true;
}
protected boolean checkVillageMasterTeachType(ClassId pclass)
protected boolean checkVillageMasterTeachType(ClassId pClass)
{
return true;
}

View File

@@ -34,24 +34,22 @@ public class VillageMasterMysticInstance extends VillageMasterInstance
}
@Override
protected final boolean checkVillageMasterRace(ClassId pclass)
protected final boolean checkVillageMasterRace(ClassId pClass)
{
if (pclass == null)
if (pClass == null)
{
return false;
}
return (pclass.getRace() == Race.HUMAN) || (pclass.getRace() == Race.ELF);
return (pClass.getRace() == Race.HUMAN) || (pClass.getRace() == Race.ELF);
}
@Override
protected final boolean checkVillageMasterTeachType(ClassId pclass)
protected final boolean checkVillageMasterTeachType(ClassId pClass)
{
if (pclass == null)
if (pClass == null)
{
return false;
}
return CategoryData.getInstance().isInCategory(CategoryType.MAGE_GROUP, pclass.getId());
return CategoryData.getInstance().isInCategory(CategoryType.MAGE_GROUP, pClass.getId());
}
}

View File

@@ -32,13 +32,12 @@ public class VillageMasterOrcInstance extends VillageMasterInstance
}
@Override
protected final boolean checkVillageMasterRace(ClassId pclass)
protected final boolean checkVillageMasterRace(ClassId pClass)
{
if (pclass == null)
if (pClass == null)
{
return false;
}
return pclass.getRace() == Race.ORC;
return pClass.getRace() == Race.ORC;
}
}

View File

@@ -34,24 +34,22 @@ public class VillageMasterPriestInstance extends VillageMasterInstance
}
@Override
protected final boolean checkVillageMasterRace(ClassId pclass)
protected final boolean checkVillageMasterRace(ClassId pClass)
{
if (pclass == null)
if (pClass == null)
{
return false;
}
return (pclass.getRace() == Race.HUMAN) || (pclass.getRace() == Race.ELF);
return (pClass.getRace() == Race.HUMAN) || (pClass.getRace() == Race.ELF);
}
@Override
protected final boolean checkVillageMasterTeachType(ClassId pclass)
protected final boolean checkVillageMasterTeachType(ClassId pClass)
{
if (pclass == null)
if (pClass == null)
{
return false;
}
return CategoryData.getInstance().isInCategory(CategoryType.CLERIC_GROUP, pclass.getId());
return CategoryData.getInstance().isInCategory(CategoryType.CLERIC_GROUP, pClass.getId());
}
}

View File

@@ -49,7 +49,7 @@ public class PetStat extends SummonStat
return false;
}
SystemMessage sm = new SystemMessage(SystemMessageId.YOUR_PET_GAINED_S1_XP);
final SystemMessage sm = new SystemMessage(SystemMessageId.YOUR_PET_GAINED_S1_XP);
sm.addLong(finalExp);
getActiveChar().updateAndBroadcastStatus(1);
getActiveChar().sendPacket(sm);

View File

@@ -140,7 +140,7 @@ public enum ClassId implements IIdentifiable
FORTUNE_SEEKER(117, false, Race.DWARF, BOUNTY_HUNTER),
MAESTRO(118, false, Race.DWARF, WARSMITH),
MALE_SOLDIER(123, false, Race.KAMAEL, null),
FEMALE_SOLDIER(124, false, Race.KAMAEL, null),
TROOPER(125, false, Race.KAMAEL, MALE_SOLDIER),
@@ -155,7 +155,7 @@ public enum ClassId implements IIdentifiable
TRICKSTER(134, false, Race.KAMAEL, ARBALESTER),
INSPECTOR(135, false, Race.KAMAEL, WARDER),
JUDICATOR(136, false, Race.KAMAEL, INSPECTOR),
SIGEL_KNIGHT(139, false, null, null),
TYRR_WARRIOR(140, false, null, null),
OTHELL_ROGUE(141, false, null, null),
@@ -164,7 +164,7 @@ public enum ClassId implements IIdentifiable
ISS_ENCHANTER(144, false, null, null),
WYNN_SUMMONER(145, false, null, null),
AEORE_HEALER(146, false, null, null),
SIGEL_PHOENIX_KNIGHT(148, false, Race.HUMAN, PHOENIX_KNIGHT),
SIGEL_HELL_KNIGHT(149, false, Race.HUMAN, HELL_KNIGHT),
SIGEL_EVA_TEMPLAR(150, false, Race.ELF, EVA_TEMPLAR),

View File

@@ -70,8 +70,8 @@ public class ProductList
return (_allowedNpcs != null) && _allowedNpcs.contains(npcId);
}
//public Set<Integer> getNpcsAllowed()
//{
// return _allowedNpcs;
//}
// public Set<Integer> getNpcsAllowed()
// {
// return _allowedNpcs;
// }
}

View File

@@ -163,7 +163,7 @@ public class Clan implements IIdentifiable, INamable
private ClanRewardBonus _lastMembersOnlineBonus = null;
private ClanRewardBonus _lastHuntingBonus = null;
private volatile ClanVariables _vars;
private ClanVariables _vars;
/**
* Called if a clan is referenced only by id. In this case all other data needs to be fetched from db
@@ -1290,11 +1290,6 @@ public class Clan implements IIdentifiable, INamable
*/
public Skill[] getAllSkills()
{
if (_skills == null)
{
return new Skill[0];
}
return _skills.values().toArray(new Skill[_skills.values().size()]);
}
@@ -1431,12 +1426,9 @@ public class Clan implements IIdentifiable, INamable
{
try
{
if ((temp != null) && temp.isOnline())
if ((temp != null) && temp.isOnline() && (skill.getMinPledgeClass() <= temp.getPlayerInstance().getPledgeClass()))
{
if (skill.getMinPledgeClass() <= temp.getPlayerInstance().getPledgeClass())
{
temp.getPlayerInstance().addSkill(skill, false); // Skill is not saved to player DB
}
temp.getPlayerInstance().addSkill(skill, false); // Skill is not saved to player DB
}
}
catch (NullPointerException e)
@@ -1803,7 +1795,7 @@ public class Clan implements IIdentifiable, INamable
*/
public SubPledge getSubPledge(int pledgeType)
{
return _subPledges == null ? null : _subPledges.get(pledgeType);
return _subPledges.get(pledgeType);
}
/**
@@ -1813,11 +1805,6 @@ public class Clan implements IIdentifiable, INamable
*/
public SubPledge getSubPledge(String pledgeName)
{
if (_subPledges == null)
{
return null;
}
for (SubPledge sp : _subPledges.values())
{
if (sp.getName().equalsIgnoreCase(pledgeName))
@@ -1834,11 +1821,6 @@ public class Clan implements IIdentifiable, INamable
*/
public SubPledge[] getAllSubPledges()
{
if (_subPledges == null)
{
return new SubPledge[0];
}
return _subPledges.values().toArray(new SubPledge[_subPledges.values().size()]);
}
@@ -2038,16 +2020,10 @@ public class Clan implements IIdentifiable, INamable
for (ClanMember cm : _members.values())
{
if (cm.isOnline())
if (cm.isOnline() && (cm.getPowerGrade() == rank) && (cm.getPlayerInstance() != null))
{
if (cm.getPowerGrade() == rank)
{
if (cm.getPlayerInstance() != null)
{
cm.getPlayerInstance().getClanPrivileges().setBitmask(privs);
cm.getPlayerInstance().sendPacket(new UserInfo(cm.getPlayerInstance()));
}
}
cm.getPlayerInstance().getClanPrivileges().setBitmask(privs);
cm.getPlayerInstance().sendPacket(new UserInfo(cm.getPlayerInstance()));
}
}
broadcastClanStatus();
@@ -2078,7 +2054,7 @@ public class Clan implements IIdentifiable, INamable
*/
public RankPrivs[] getAllRankPrivs()
{
return _privs == null ? new RankPrivs[0] : _privs.values().toArray(new RankPrivs[_privs.values().size()]);
return _privs.values().toArray(new RankPrivs[_privs.values().size()]);
}
public int getLeaderSubPledge(int leaderId)
@@ -2277,13 +2253,10 @@ public class Clan implements IIdentifiable, INamable
return false;
}
final Clan leaderClan = player.getClan();
if (leaderClan.getAllyPenaltyExpiryTime() > System.currentTimeMillis())
if ((leaderClan.getAllyPenaltyExpiryTime() > System.currentTimeMillis()) && (leaderClan.getAllyPenaltyType() == PENALTY_TYPE_DISMISS_CLAN))
{
if (leaderClan.getAllyPenaltyType() == PENALTY_TYPE_DISMISS_CLAN)
{
player.sendPacket(SystemMessageId.YOU_MAY_NOT_ACCEPT_ANY_CLAN_WITHIN_A_DAY_AFTER_EXPELLING_ANOTHER_CLAN);
return false;
}
player.sendPacket(SystemMessageId.YOU_MAY_NOT_ACCEPT_ANY_CLAN_WITHIN_A_DAY_AFTER_EXPELLING_ANOTHER_CLAN);
return false;
}
if (target == null)
{
@@ -2507,92 +2480,74 @@ public class Clan implements IIdentifiable, INamable
case 0:
{
// Upgrade to 1
if ((player.getSp() >= 1000) && (player.getAdena() >= 150000) && (_members.size() >= 1))
if ((player.getSp() >= 1000) && (player.getAdena() >= 150000) && (_members.size() >= 1) && player.reduceAdena("ClanLvl", 150000, player.getTarget(), true))
{
if (player.reduceAdena("ClanLvl", 150000, player.getTarget(), true))
{
player.setSp(player.getSp() - 1000);
final SystemMessage sp = new SystemMessage(SystemMessageId.YOUR_SP_HAS_DECREASED_BY_S1);
sp.addInt(1000);
player.sendPacket(sp);
increaseClanLevel = true;
}
player.setSp(player.getSp() - 1000);
final SystemMessage sp = new SystemMessage(SystemMessageId.YOUR_SP_HAS_DECREASED_BY_S1);
sp.addInt(1000);
player.sendPacket(sp);
increaseClanLevel = true;
}
break;
}
case 1:
{
// Upgrade to 2
if ((player.getSp() >= 15000) && (player.getAdena() >= 300000) && (_members.size() >= 1))
if ((player.getSp() >= 15000) && (player.getAdena() >= 300000) && (_members.size() >= 1) && player.reduceAdena("ClanLvl", 300000, player.getTarget(), true))
{
if (player.reduceAdena("ClanLvl", 300000, player.getTarget(), true))
{
player.setSp(player.getSp() - 15000);
final SystemMessage sp = new SystemMessage(SystemMessageId.YOUR_SP_HAS_DECREASED_BY_S1);
sp.addInt(15000);
player.sendPacket(sp);
increaseClanLevel = true;
}
player.setSp(player.getSp() - 15000);
final SystemMessage sp = new SystemMessage(SystemMessageId.YOUR_SP_HAS_DECREASED_BY_S1);
sp.addInt(15000);
player.sendPacket(sp);
increaseClanLevel = true;
}
break;
}
case 2:
{
// Upgrade to 3
if ((player.getSp() >= 100000) && (player.getInventory().getItemByItemId(1419) != null) && (_members.size() >= 1))
// Upgrade to 3 (itemId 1419 == Blood Mark)
if ((player.getSp() >= 100000) && (player.getInventory().getItemByItemId(1419) != null) && (_members.size() >= 1) && player.destroyItemByItemId("ClanLvl", 1419, 100, player.getTarget(), true))
{
// itemId 1419 == Blood Mark
if (player.destroyItemByItemId("ClanLvl", 1419, 100, player.getTarget(), true))
{
player.setSp(player.getSp() - 100000);
final SystemMessage sp = new SystemMessage(SystemMessageId.YOUR_SP_HAS_DECREASED_BY_S1);
sp.addInt(100000);
player.sendPacket(sp);
final SystemMessage sm = new SystemMessage(SystemMessageId.S1_DISAPPEARED);
sm.addItemName(1419);
player.sendPacket(sm);
increaseClanLevel = true;
}
player.setSp(player.getSp() - 100000);
final SystemMessage sp = new SystemMessage(SystemMessageId.YOUR_SP_HAS_DECREASED_BY_S1);
sp.addInt(100000);
player.sendPacket(sp);
final SystemMessage sm = new SystemMessage(SystemMessageId.S1_DISAPPEARED);
sm.addItemName(1419);
player.sendPacket(sm);
increaseClanLevel = true;
}
break;
}
case 3:
{
// Upgrade to 4
if ((player.getSp() >= 1000000) && (player.getInventory().getItemByItemId(1419) != null) && (_members.size() >= 1))
// Upgrade to 4 (itemId 1419 == Blood Mark)
if ((player.getSp() >= 1000000) && (player.getInventory().getItemByItemId(1419) != null) && (_members.size() >= 1) && player.destroyItemByItemId("ClanLvl", 1419, 5000, player.getTarget(), true))
{
// itemId 1419 == Blood Mark
if (player.destroyItemByItemId("ClanLvl", 1419, 5000, player.getTarget(), true))
{
player.setSp(player.getSp() - 1000000);
final SystemMessage sp = new SystemMessage(SystemMessageId.YOUR_SP_HAS_DECREASED_BY_S1);
sp.addInt(1000000);
player.sendPacket(sp);
final SystemMessage sm = new SystemMessage(SystemMessageId.S1_DISAPPEARED);
sm.addItemName(1419);
player.sendPacket(sm);
increaseClanLevel = true;
}
player.setSp(player.getSp() - 1000000);
final SystemMessage sp = new SystemMessage(SystemMessageId.YOUR_SP_HAS_DECREASED_BY_S1);
sp.addInt(1000000);
player.sendPacket(sp);
final SystemMessage sm = new SystemMessage(SystemMessageId.S1_DISAPPEARED);
sm.addItemName(1419);
player.sendPacket(sm);
increaseClanLevel = true;
}
break;
}
case 4:
{
// Upgrade to 5
if ((player.getSp() >= 5000000) && (player.getInventory().getItemByItemId(1419) != null) && (_members.size() >= 1))
// Upgrade to 5 (itemId 1419 == Blood Mark)
if ((player.getSp() >= 5000000) && (player.getInventory().getItemByItemId(1419) != null) && (_members.size() >= 1) && player.destroyItemByItemId("ClanLvl", 1419, 10000, player.getTarget(), true))
{
// itemId 1419 == Blood Mark
if (player.destroyItemByItemId("ClanLvl", 1419, 10000, player.getTarget(), true))
{
player.setSp(player.getSp() - 5000000);
final SystemMessage sp = new SystemMessage(SystemMessageId.YOUR_SP_HAS_DECREASED_BY_S1);
sp.addInt(5000000);
player.sendPacket(sp);
final SystemMessage sm = new SystemMessage(SystemMessageId.S1_DISAPPEARED);
sm.addItemName(1419);
player.sendPacket(sm);
increaseClanLevel = true;
}
player.setSp(player.getSp() - 5000000);
final SystemMessage sp = new SystemMessage(SystemMessageId.YOUR_SP_HAS_DECREASED_BY_S1);
sp.addInt(5000000);
player.sendPacket(sp);
final SystemMessage sm = new SystemMessage(SystemMessageId.S1_DISAPPEARED);
sm.addItemName(1419);
player.sendPacket(sm);
increaseClanLevel = true;
}
break;
}

View File

@@ -998,7 +998,7 @@ public class Duel
if (_partyDuel)
{
boolean teamdefeated = player.getParty().getMembers().stream().anyMatch(member -> member.getDuelState() == DUELSTATE_DUELLING);
final boolean teamdefeated = player.getParty().getMembers().stream().anyMatch(member -> member.getDuelState() == DUELSTATE_DUELLING);
if (teamdefeated)
{

View File

@@ -382,13 +382,13 @@ public class Fishing
// calculate a position in front of the player with a random distance
final int distMin = FishingData.getInstance().getBaitDistanceMin();
final int distMax = FishingData.getInstance().getBaitDistanceMax();
int distance = Rnd.get(distMin, distMax);
final int distance = Rnd.get(distMin, distMax);
final double angle = Util.convertHeadingToDegree(_player.getHeading());
final double radian = Math.toRadians(angle);
final double sin = Math.sin(radian);
final double cos = Math.cos(radian);
int baitX = (int) (_player.getX() + (cos * distance));
int baitY = (int) (_player.getY() + (sin * distance));
final int baitX = (int) (_player.getX() + (cos * distance));
final int baitY = (int) (_player.getY() + (sin * distance));
// search for fishing zone
FishingZone fishingZone = null;
@@ -411,7 +411,7 @@ public class Fishing
}
}
int baitZ = computeBaitZ(_player, baitX, baitY, fishingZone, waterZone);
final int baitZ = computeBaitZ(_player, baitX, baitY, fishingZone, waterZone);
if (baitZ == Integer.MIN_VALUE)
{
_player.sendPacket(SystemMessageId.YOU_CAN_T_FISH_HERE);

View File

@@ -636,7 +636,7 @@ public class InstanceTemplate extends ListenersContainer implements IIdentifiabl
// player < party < command channel
for (GroupType t : GroupType.values())
{
if (t != playerGroup && groupMaskContains(t))
if ((t != playerGroup) && groupMaskContains(t))
{
return t;
}

View File

@@ -1557,12 +1557,9 @@ public abstract class Inventory extends ItemContainer
if (pdollSlot >= 0)
{
final ItemInstance old = setPaperdollItem(pdollSlot, null);
if (old != null)
if ((old != null) && getOwner().isPlayer())
{
if (getOwner().isPlayer())
{
((PlayerInstance) getOwner()).refreshExpertisePenalty();
}
((PlayerInstance) getOwner()).refreshExpertisePenalty();
}
return old;
}
@@ -1990,14 +1987,11 @@ public abstract class Inventory extends ItemContainer
// find same (or incompatible) talisman type
for (int i = PAPERDOLL_DECO1; i < (PAPERDOLL_DECO1 + getTalismanSlots()); i++)
{
if (_paperdoll[i] != null)
if ((_paperdoll[i] != null) && (getPaperdollItemId(i) == item.getId()))
{
if (getPaperdollItemId(i) == item.getId())
{
// overwtite
setPaperdollItem(i, item);
return;
}
// overwrite
setPaperdollItem(i, item);
return;
}
}

View File

@@ -1021,9 +1021,9 @@ public class ItemInstance extends WorldObject
{
if (rs.next())
{
int mineralId = rs.getInt("mineralId");
int option1 = rs.getInt("option1");
int option2 = rs.getInt("option2");
final int mineralId = rs.getInt("mineralId");
final int option1 = rs.getInt("option1");
final int option2 = rs.getInt("option2");
if ((option1 != -1) && (option2 != -1))
{
_augmentation = new VariationInstance(mineralId, option1, option2);
@@ -1784,7 +1784,7 @@ public class ItemInstance extends WorldObject
{
return true;
}
Creature owner = getActingPlayer();
final Creature owner = getActingPlayer();
if (owner != null)
{
for (Condition condition : _item.getConditions())

View File

@@ -617,13 +617,13 @@ public class Olympiad extends ListenersContainer
sm.addInt(_currentCycle);
Broadcast.toAllOnlinePlayers(sm);
Calendar currentTime = Calendar.getInstance();
final Calendar currentTime = Calendar.getInstance();
currentTime.set(Calendar.AM_PM, Calendar.AM);
currentTime.set(Calendar.HOUR, 12);
currentTime.set(Calendar.MINUTE, 0);
currentTime.set(Calendar.SECOND, 0);
Calendar nextChange = Calendar.getInstance();
final Calendar nextChange = Calendar.getInstance();
switch (Config.ALT_OLY_PERIOD)
{
@@ -960,26 +960,23 @@ public class Olympiad extends ListenersContainer
return Collections.emptyList();
}
if (NOBLES != null)
LOGGER_OLYMPIAD.info("Noble,charid,classid,compDone,points");
StatsSet nobleInfo;
for (Entry<Integer, StatsSet> entry : NOBLES.entrySet())
{
LOGGER_OLYMPIAD.info("Noble,charid,classid,compDone,points");
StatsSet nobleInfo;
for (Entry<Integer, StatsSet> entry : NOBLES.entrySet())
nobleInfo = entry.getValue();
if (nobleInfo == null)
{
nobleInfo = entry.getValue();
if (nobleInfo == null)
{
continue;
}
final int charId = entry.getKey();
final int classId = nobleInfo.getInt(CLASS_ID);
final String charName = nobleInfo.getString(CHAR_NAME);
final int points = nobleInfo.getInt(POINTS);
final int compDone = nobleInfo.getInt(COMP_DONE);
LOGGER_OLYMPIAD.info(charName + "," + charId + "," + classId + "," + compDone + "," + points);
continue;
}
final int charId = entry.getKey();
final int classId = nobleInfo.getInt(CLASS_ID);
final String charName = nobleInfo.getString(CHAR_NAME);
final int points = nobleInfo.getInt(POINTS);
final int compDone = nobleInfo.getInt(COMP_DONE);
LOGGER_OLYMPIAD.info(charName + "," + charId + "," + classId + "," + compDone + "," + points);
}
final List<StatsSet> heroesToBe = new LinkedList<>();
@@ -991,7 +988,7 @@ public class Olympiad extends ListenersContainer
for (int element : HERO_IDS)
{
// Classic can have 2nd and 3rd class competitors, but only 1 hero
ClassId parent = ClassListData.getInstance().getClass(element).getParentClassId();
final ClassId parent = ClassListData.getInstance().getClass(element).getParentClassId();
statement.setInt(1, element);
statement.setInt(2, parent.getId());
@@ -1142,7 +1139,7 @@ public class Olympiad extends ListenersContainer
public int getCompetitionDone(int objId)
{
if ((NOBLES == null) || !NOBLES.containsKey(objId))
if (!NOBLES.containsKey(objId))
{
return 0;
}
@@ -1151,7 +1148,7 @@ public class Olympiad extends ListenersContainer
public int getCompetitionWon(int objId)
{
if ((NOBLES == null) || !NOBLES.containsKey(objId))
if (!NOBLES.containsKey(objId))
{
return 0;
}
@@ -1160,7 +1157,7 @@ public class Olympiad extends ListenersContainer
public int getCompetitionLost(int objId)
{
if ((NOBLES == null) || !NOBLES.containsKey(objId))
if (!NOBLES.containsKey(objId))
{
return 0;
}
@@ -1174,7 +1171,7 @@ public class Olympiad extends ListenersContainer
*/
public int getCompetitionDoneWeek(int objId)
{
if ((NOBLES == null) || !NOBLES.containsKey(objId))
if (!NOBLES.containsKey(objId))
{
return 0;
}

View File

@@ -134,7 +134,7 @@ public class Options
public List<OptionsSkillHolder> getActivationsSkills(OptionsSkillType type)
{
List<OptionsSkillHolder> temp = new ArrayList<>();
final List<OptionsSkillHolder> temp = new ArrayList<>();
if (_activationSkills != null)
{
for (OptionsSkillHolder holder : _activationSkills)

View File

@@ -48,7 +48,7 @@ public class Variation
public Options getRandomEffect(VariationWeaponType type, int order)
{
OptionDataGroup[] effects = _effects.get(type);
final OptionDataGroup[] effects = _effects.get(type);
if ((effects == null) || (effects[order] == null))
{
LOGGER.warning("Null effect: " + type + ", " + order);

View File

@@ -237,7 +237,7 @@ public class PunishmentTask implements Runnable
}
}
if (_type == PunishmentType.CHAT_BAN && _affect == PunishmentAffect.CHARACTER)
if ((_type == PunishmentType.CHAT_BAN) && (_affect == PunishmentAffect.CHARACTER))
{
final PlayerInstance player = World.getInstance().getPlayer(Integer.parseInt(_key));
if (player != null)

View File

@@ -243,7 +243,7 @@ public class Formulas
final double statBonus;
// There is a chance that activeChar has altered base stat for skill critical.
byte skillCritRateStat = (byte) creature.getStat().getValue(Stats.STAT_BONUS_SKILL_CRITICAL);
final byte skillCritRateStat = (byte) creature.getStat().getValue(Stats.STAT_BONUS_SKILL_CRITICAL);
if ((skillCritRateStat >= 0) && (skillCritRateStat < BaseStats.values().length))
{
// Best tested.
@@ -471,11 +471,11 @@ public class Formulas
public static double calcAtkSpdMultiplier(Creature creature)
{
double armorBonus = 1; // EquipedArmorSpeedByCrystal TODO: Implement me!
double dexBonus = BaseStats.DEX.calcBonus(creature);
double weaponAttackSpeed = Stats.weaponBaseValue(creature, Stats.PHYSICAL_ATTACK_SPEED) / armorBonus; // unk868
double attackSpeedPerBonus = creature.getStat().getMul(Stats.PHYSICAL_ATTACK_SPEED);
double attackSpeedDiffBonus = creature.getStat().getAdd(Stats.PHYSICAL_ATTACK_SPEED);
final double armorBonus = 1; // EquipedArmorSpeedByCrystal TODO: Implement me!
final double dexBonus = BaseStats.DEX.calcBonus(creature);
final double weaponAttackSpeed = Stats.weaponBaseValue(creature, Stats.PHYSICAL_ATTACK_SPEED) / armorBonus; // unk868
final double attackSpeedPerBonus = creature.getStat().getMul(Stats.PHYSICAL_ATTACK_SPEED);
final double attackSpeedDiffBonus = creature.getStat().getAdd(Stats.PHYSICAL_ATTACK_SPEED);
return (dexBonus * (weaponAttackSpeed / 333) * attackSpeedPerBonus) + (attackSpeedDiffBonus / 333);
}
@@ -513,7 +513,7 @@ public class Formulas
if (creature.isNpc())
{
double npcFactor = ((Npc) creature).getTemplate().getHitTimeFactorSkill();
final double npcFactor = ((Npc) creature).getTemplate().getHitTimeFactorSkill();
if (npcFactor > 0)
{
factor /= npcFactor;

View File

@@ -119,7 +119,7 @@ public interface IStatsFunction
(bodypart == Item.SLOT_HAIRALL))
{
// TODO: Item after enchant shows pDef, but scroll says mDef increase.
if (stat != Stats.PHYSICAL_DEFENCE && stat != Stats.MAGICAL_DEFENCE)
if ((stat != Stats.PHYSICAL_DEFENCE) && (stat != Stats.MAGICAL_DEFENCE))
{
continue;
}

View File

@@ -48,7 +48,7 @@ public class Hopzone extends VoteSystem
try
{
URLConnection con = new URL(Config.HOPZONE_SERVER_LINK).openConnection();
final URLConnection con = new URL(Config.HOPZONE_SERVER_LINK).openConnection();
con.addRequestProperty("User-Agent", "Mozilla/5.0");
isr = new InputStreamReader(con.getInputStream());
br = new BufferedReader(isr);

View File

@@ -48,7 +48,7 @@ public class Network extends VoteSystem
try
{
URLConnection con = new URL(Config.NETWORK_SERVER_LINK).openConnection();
final URLConnection con = new URL(Config.NETWORK_SERVER_LINK).openConnection();
con.addRequestProperty("User-Agent", "Mozilla/5.0");
isr = new InputStreamReader(con.getInputStream());
br = new BufferedReader(isr);

View File

@@ -48,7 +48,7 @@ public class Topzone extends VoteSystem
try
{
URLConnection con = new URL(Config.TOPZONE_SERVER_LINK).openConnection();
final URLConnection con = new URL(Config.TOPZONE_SERVER_LINK).openConnection();
con.addRequestProperty("User-Agent", "L2TopZone");
isr = new InputStreamReader(con.getInputStream());
br = new BufferedReader(isr);

View File

@@ -99,7 +99,7 @@ public abstract class VoteSystem implements Runnable
protected void reward()
{
int currentVotes = getVotes();
final int currentVotes = getVotes();
if (currentVotes == -1)
{
@@ -122,7 +122,7 @@ public abstract class VoteSystem implements Runnable
if (currentVotes >= (lastVotes + votesDiff))
{
Collection<PlayerInstance> pls = World.getInstance().getPlayers();
final Collection<PlayerInstance> pls = World.getInstance().getPlayers();
if (allowReport)
{
LOGGER.info("VoteSystem: Server votes on " + getSiteName() + ": " + currentVotes);
@@ -139,10 +139,10 @@ public abstract class VoteSystem implements Runnable
}
boolean canReward = false;
String pIp = p.getClient().getConnectionAddress().getHostAddress();
final String pIp = p.getClient().getConnectionAddress().getHostAddress();
if (playerIps.containsKey(pIp))
{
int count = playerIps.get(pIp);
final int count = playerIps.get(pIp);
if (count < boxes)
{
playerIps.remove(pIp);
@@ -185,7 +185,7 @@ public abstract class VoteSystem implements Runnable
private void announce(String msg)
{
CreatureSay cs = new CreatureSay(0, ChatType.CRITICAL_ANNOUNCE, "", msg);
final CreatureSay cs = new CreatureSay(0, ChatType.CRITICAL_ANNOUNCE, "", msg);
Broadcast.toAllOnlinePlayers(cs);
}

View File

@@ -122,7 +122,7 @@ public class MultiSellChoose implements IClientIncomingPacket
return;
}
PreparedMultisellListHolder list = player.getMultiSell();
final PreparedMultisellListHolder list = player.getMultiSell();
if ((list == null) || (list.getId() != _listId))
{
player.setMultiSell(null);
@@ -258,7 +258,7 @@ public class MultiSellChoose implements IClientIncomingPacket
// Check for enchanted item if its present in the inventory.
if ((itemEnchantment != null) && (inventory.getItemByObjectId(itemEnchantment.getObjectId()) == null))
{
SystemMessage sm = new SystemMessage(SystemMessageId.YOU_NEED_A_N_S1);
final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_NEED_A_N_S1);
sm.addItemName(itemEnchantment.getItem().getId());
player.sendPacket(sm);
return;
@@ -315,7 +315,7 @@ public class MultiSellChoose implements IClientIncomingPacket
if (clan != null)
{
clan.takeReputationScore((int) totalCount, true);
SystemMessage smsg = new SystemMessage(SystemMessageId.S1_POINT_S_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_S_REPUTATION);
final SystemMessage smsg = new SystemMessage(SystemMessageId.S1_POINT_S_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_S_REPUTATION);
smsg.addLong(totalCount);
player.sendPacket(smsg);
}
@@ -359,7 +359,7 @@ public class MultiSellChoose implements IClientIncomingPacket
}
else
{
SystemMessage sm = new SystemMessage(SystemMessageId.YOU_NEED_A_N_S1);
final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_NEED_A_N_S1);
sm.addItemName(ingredient.getId());
player.sendPacket(sm);
return;
@@ -376,7 +376,7 @@ public class MultiSellChoose implements IClientIncomingPacket
}
else
{
SystemMessage sm = new SystemMessage(SystemMessageId.YOU_NEED_A_N_S1);
final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_NEED_A_N_S1);
sm.addItemName(ingredient.getId());
player.sendPacket(sm);
return;
@@ -392,7 +392,7 @@ public class MultiSellChoose implements IClientIncomingPacket
}
else
{
SystemMessage sm = new SystemMessage(SystemMessageId.YOU_NEED_S2_S1_S);
final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_NEED_S2_S1_S);
sm.addItemName(ingredient.getId());
sm.addLong(totalCount);
player.sendPacket(sm);
@@ -641,7 +641,7 @@ public class MultiSellChoose implements IClientIncomingPacket
// Check if the necessary items are there. If list maintains enchantment, allow all enchanted items, otherwise only unenchanted. TODO: Check how retail does it.
else if (inventory.getInventoryItemCount(ingredientId, list.isMaintainEnchantment() ? -1 : 0, false) < totalCount)
{
SystemMessage sm = new SystemMessage(SystemMessageId.YOU_NEED_S2_S1_S);
final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_NEED_S2_S1_S);
sm.addItemName(ingredientId);
sm.addLong(totalCount);
player.sendPacket(sm);

View File

@@ -50,7 +50,7 @@ public class RequestDuelStart implements IClientIncomingPacket
{
if (player != null)
{
SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_DECLINED_YOUR_CHALLENGE_TO_A_DUEL);
final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_DECLINED_YOUR_CHALLENGE_TO_A_DUEL);
sm.addString(name);
player.sendPacket(sm);
player.onTransactionResponse();

View File

@@ -300,7 +300,7 @@ public class RequestExEnchantItemAttribute implements IClientIncomingPacket
return -1;
}
boolean success = Elementals.isSuccess(item, stone.getId());
final boolean success = Elementals.isSuccess(item, stone.getId());
if (success)
{

View File

@@ -77,7 +77,7 @@ public class RequestJoinParty implements IClientIncomingPacket
if (FakePlayerData.getInstance().isTalkable(_name))
{
SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY);
final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY);
sm.addString(FakePlayerData.getInstance().getProperName(_name));
requestor.sendPacket(sm);
if (!requestor.isProcessingRequest())

View File

@@ -47,7 +47,7 @@ public class RequestJoinPledge implements IClientIncomingPacket
{
if (player != null)
{
SystemMessage sm = new SystemMessage(SystemMessageId.S1_DID_NOT_RESPOND_INVITATION_TO_THE_CLAN_HAS_BEEN_CANCELLED);
final SystemMessage sm = new SystemMessage(SystemMessageId.S1_DID_NOT_RESPOND_INVITATION_TO_THE_CLAN_HAS_BEEN_CANCELLED);
sm.addString(name);
player.sendPacket(sm);
player.onTransactionResponse();

View File

@@ -40,7 +40,7 @@ public class RequestPrivateStoreSell implements IClientIncomingPacket
public boolean read(GameClient client, PacketReader packet)
{
_storePlayerId = packet.readD();
int itemsCount = packet.readD();
final int itemsCount = packet.readD();
if ((itemsCount <= 0) || (itemsCount > Config.MAX_ITEM_IN_PACKET))
{
return false;
@@ -58,12 +58,12 @@ public class RequestPrivateStoreSell implements IClientIncomingPacket
packet.readD(); // visual id
packet.readD(); // option 1
packet.readD(); // option 2
int soulCrystals = packet.readC();
final int soulCrystals = packet.readC();
for (int s = 0; s < soulCrystals; s++)
{
packet.readD(); // soul crystal option
}
int soulCrystals2 = packet.readC();
final int soulCrystals2 = packet.readC();
for (int s = 0; s < soulCrystals2; s++)
{
packet.readD(); // sa effect

View File

@@ -109,7 +109,7 @@ public class RequestRefine extends AbstractRefinePacket
final InventoryUpdate iu = new InventoryUpdate();
if (targetItem.isEquipped())
{
ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot());
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot());
for (ItemInstance itm : unequiped)
{
iu.addModifiedItem(itm);

View File

@@ -146,13 +146,13 @@ public class RequestSellItem implements IClientIncomingPacket
// Proceed the sell
for (UniqueItemHolder i : _items)
{
ItemInstance item = player.checkItemManipulation(i.getObjectId(), i.getCount(), "sell");
final ItemInstance item = player.checkItemManipulation(i.getObjectId(), i.getCount(), "sell");
if ((item == null) || (!item.isSellable()))
{
continue;
}
long price = item.getReferencePrice() / 2;
final long price = item.getReferencePrice() / 2;
totalPrice += price * i.getCount();
if (((MAX_ADENA / i.getCount()) < price) || (totalPrice > MAX_ADENA))
{

View File

@@ -61,7 +61,7 @@ public class RequestVoteNew implements IClientIncomingPacket
return;
}
SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_RECOMMENDED_C1_YOU_HAVE_S2_RECOMMENDATIONS_LEFT);
final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_RECOMMENDED_C1_YOU_HAVE_S2_RECOMMENDATIONS_LEFT);
sm.addString(FakePlayerData.getInstance().getProperName(object.getName()));
sm.addInt(player.getRecomLeft());
client.sendPacket(sm);

View File

@@ -56,7 +56,7 @@ public class SetPrivateStoreListBuy implements IClientIncomingPacket
_items = new TradeItem[count];
for (int i = 0; i < count; i++)
{
int itemId = packet.readD();
final int itemId = packet.readD();
final Item template = ItemTable.getInstance().getTemplate(itemId);
if (template == null)
@@ -68,8 +68,8 @@ public class SetPrivateStoreListBuy implements IClientIncomingPacket
final int enchantLevel = packet.readH();
packet.readH(); // TODO analyse this
long cnt = packet.readQ();
long price = packet.readQ();
final long cnt = packet.readQ();
final long price = packet.readQ();
if ((itemId < 1) || (cnt < 1) || (price < 0))
{
@@ -157,7 +157,7 @@ public class SetPrivateStoreListBuy implements IClientIncomingPacket
return;
}
TradeList tradeList = player.getBuyList();
final TradeList tradeList = player.getBuyList();
tradeList.clear();
// Check maximum number of allowed slots for pvt shops

View File

@@ -188,7 +188,7 @@ public class RequestShapeShiftingItem implements IClientIncomingPacket
extracItemId = extractItem.getId();
}
long cost = appearanceStone.getCost();
final long cost = appearanceStone.getCost();
if (cost > player.getAdena())
{
client.sendPacket(SystemMessageId.YOU_CANNOT_MODIFY_AS_YOU_DO_NOT_HAVE_ENOUGH_ADENA);

View File

@@ -83,7 +83,7 @@ public class RequestChangeAttributeItem implements IClientIncomingPacket
msg.addAttribute(oldElementId);
msg.addAttribute(_newElementId);
player.sendPacket(msg);
InventoryUpdate iu = new InventoryUpdate();
final InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(item);
for (ItemInstance i : player.getInventory().getItemsByItemId(_consumeItemId))
{

View File

@@ -51,7 +51,7 @@ public class RequestTryEnSoulExtraction implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
PlayerInstance player = client.getPlayer();
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;

View File

@@ -370,9 +370,9 @@ public class CharSelectionInfo implements IClientOutgoingPacket
{
if (result.next())
{
int mineralId = result.getInt("mineralId");
int option1 = result.getInt("option1");
int option2 = result.getInt("option2");
final int mineralId = result.getInt("mineralId");
final int option1 = result.getInt("option1");
final int option2 = result.getInt("option2");
if ((option1 != -1) && (option2 != -1))
{
charInfopackage.setAugmentation(new VariationInstance(mineralId, option1, option2));

View File

@@ -105,7 +105,7 @@ public class FakePlayerInfo implements IClientOutgoingPacket
packet.writeD(_fpcHolder.getEquipHair2());
for (@SuppressWarnings("unused")
int slot : getPaperdollOrderAugument())
final int slot : getPaperdollOrderAugument())
{
packet.writeD(0x00);
packet.writeD(0x00);
@@ -114,7 +114,7 @@ public class FakePlayerInfo implements IClientOutgoingPacket
packet.writeC(_fpcHolder.getArmorEnchantLevel());
for (@SuppressWarnings("unused")
int slot : getPaperdollOrderVisualId())
final int slot : getPaperdollOrderVisualId())
{
packet.writeD(0x00);
}

View File

@@ -56,7 +56,7 @@ public class SellListProcure implements IClientOutgoingPacket
for (Entry<ItemInstance, Long> entry : _sellList.entrySet())
{
ItemInstance item = entry.getKey();
final ItemInstance item = entry.getKey();
packet.writeH(item.getItem().getType1());
packet.writeD(item.getObjectId());
packet.writeD(item.getDisplayId());

View File

@@ -39,7 +39,7 @@ public class JavaScriptingEngine
public JavaScriptingEngine()
{
// Load config.
Properties props = new Properties();
final Properties props = new Properties();
try (FileInputStream fis = new FileInputStream("config/ScriptEngine.ini"))
{
props.load(fis);

View File

@@ -94,14 +94,14 @@ public class Gui
txtrConsole.getDocument().addDocumentListener(new LimitLinesDocumentListener(500));
// Initialize menu items.
JMenuBar menuBar = new JMenuBar();
final JMenuBar menuBar = new JMenuBar();
menuBar.setFont(new Font("Segoe UI", Font.PLAIN, 14));
JMenu mnActions = new JMenu("Actions");
final JMenu mnActions = new JMenu("Actions");
mnActions.setFont(new Font("Segoe UI", Font.PLAIN, 13));
menuBar.add(mnActions);
JMenuItem mntmShutdown = new JMenuItem("Shutdown");
final JMenuItem mntmShutdown = new JMenuItem("Shutdown");
mntmShutdown.setFont(new Font("Segoe UI", Font.PLAIN, 13));
mntmShutdown.addActionListener(arg0 ->
{
@@ -124,7 +124,7 @@ public class Gui
});
mnActions.add(mntmShutdown);
JMenuItem mntmRestart = new JMenuItem("Restart");
final JMenuItem mntmRestart = new JMenuItem("Restart");
mntmRestart.setFont(new Font("Segoe UI", Font.PLAIN, 13));
mntmRestart.addActionListener(arg0 ->
{
@@ -147,7 +147,7 @@ public class Gui
});
mnActions.add(mntmRestart);
JMenuItem mntmAbort = new JMenuItem("Abort");
final JMenuItem mntmAbort = new JMenuItem("Abort");
mntmAbort.setFont(new Font("Segoe UI", Font.PLAIN, 13));
mntmAbort.addActionListener(arg0 ->
{
@@ -158,11 +158,11 @@ public class Gui
});
mnActions.add(mntmAbort);
JMenu mnReload = new JMenu("Reload");
final JMenu mnReload = new JMenu("Reload");
mnReload.setFont(new Font("Segoe UI", Font.PLAIN, 13));
menuBar.add(mnReload);
JMenuItem mntmConfigs = new JMenuItem("Configs");
final JMenuItem mntmConfigs = new JMenuItem("Configs");
mntmConfigs.setFont(new Font("Segoe UI", Font.PLAIN, 13));
mntmConfigs.addActionListener(arg0 ->
{
@@ -173,7 +173,7 @@ public class Gui
});
mnReload.add(mntmConfigs);
JMenuItem mntmAccess = new JMenuItem("Access");
final JMenuItem mntmAccess = new JMenuItem("Access");
mntmAccess.setFont(new Font("Segoe UI", Font.PLAIN, 13));
mntmAccess.addActionListener(arg0 ->
{
@@ -184,7 +184,7 @@ public class Gui
});
mnReload.add(mntmAccess);
JMenuItem mntmHtml = new JMenuItem("HTML");
final JMenuItem mntmHtml = new JMenuItem("HTML");
mntmHtml.setFont(new Font("Segoe UI", Font.PLAIN, 13));
mntmHtml.addActionListener(arg0 ->
{
@@ -195,7 +195,7 @@ public class Gui
});
mnReload.add(mntmHtml);
JMenuItem mntmMultisells = new JMenuItem("Multisells");
final JMenuItem mntmMultisells = new JMenuItem("Multisells");
mntmMultisells.setFont(new Font("Segoe UI", Font.PLAIN, 13));
mntmMultisells.addActionListener(arg0 ->
{
@@ -206,7 +206,7 @@ public class Gui
});
mnReload.add(mntmMultisells);
JMenuItem mntmBuylists = new JMenuItem("Buylists");
final JMenuItem mntmBuylists = new JMenuItem("Buylists");
mntmBuylists.setFont(new Font("Segoe UI", Font.PLAIN, 13));
mntmBuylists.addActionListener(arg0 ->
{
@@ -217,11 +217,11 @@ public class Gui
});
mnReload.add(mntmBuylists);
JMenu mnAnnounce = new JMenu("Announce");
final JMenu mnAnnounce = new JMenu("Announce");
mnAnnounce.setFont(new Font("Segoe UI", Font.PLAIN, 13));
menuBar.add(mnAnnounce);
JMenuItem mntmNormal = new JMenuItem("Normal");
final JMenuItem mntmNormal = new JMenuItem("Normal");
mntmNormal.setFont(new Font("Segoe UI", Font.PLAIN, 13));
mntmNormal.addActionListener(arg0 ->
{
@@ -237,7 +237,7 @@ public class Gui
});
mnAnnounce.add(mntmNormal);
JMenuItem mntmCritical = new JMenuItem("Critical");
final JMenuItem mntmCritical = new JMenuItem("Critical");
mntmCritical.setFont(new Font("Segoe UI", Font.PLAIN, 13));
mntmCritical.addActionListener(arg0 ->
{
@@ -253,11 +253,11 @@ public class Gui
});
mnAnnounce.add(mntmCritical);
JMenu mnFont = new JMenu("Font");
final JMenu mnFont = new JMenu("Font");
mnFont.setFont(new Font("Segoe UI", Font.PLAIN, 13));
menuBar.add(mnFont);
String[] fonts =
final String[] fonts =
{
"16",
"21",
@@ -266,38 +266,38 @@ public class Gui
};
for (String font : fonts)
{
JMenuItem mntmFont = new JMenuItem(font);
final JMenuItem mntmFont = new JMenuItem(font);
mntmFont.setFont(new Font("Segoe UI", Font.PLAIN, 13));
mntmFont.addActionListener(arg0 -> txtrConsole.setFont(new Font("Monospaced", Font.PLAIN, Integer.parseInt(font))));
mnFont.add(mntmFont);
}
JMenu mnHelp = new JMenu("Help");
final JMenu mnHelp = new JMenu("Help");
mnHelp.setFont(new Font("Segoe UI", Font.PLAIN, 13));
menuBar.add(mnHelp);
JMenuItem mntmAbout = new JMenuItem("About");
final JMenuItem mntmAbout = new JMenuItem("About");
mntmAbout.setFont(new Font("Segoe UI", Font.PLAIN, 13));
mntmAbout.addActionListener(arg0 -> new frmAbout());
mnHelp.add(mntmAbout);
// Set icons.
List<Image> icons = new ArrayList<>();
final List<Image> icons = new ArrayList<>();
icons.add(new ImageIcon("..\\images\\l2jmobius_16x16.png").getImage());
icons.add(new ImageIcon("..\\images\\l2jmobius_32x32.png").getImage());
icons.add(new ImageIcon("..\\images\\l2jmobius_64x64.png").getImage());
icons.add(new ImageIcon("..\\images\\l2jmobius_128x128.png").getImage());
// Set Panels.
JPanel systemPanel = new SystemPanel();
JScrollPane scrollPanel = new JScrollPane(txtrConsole);
final JPanel systemPanel = new SystemPanel();
final JScrollPane scrollPanel = new JScrollPane(txtrConsole);
scrollPanel.setBounds(0, 0, 800, 550);
JLayeredPane layeredPanel = new JLayeredPane();
final JLayeredPane layeredPanel = new JLayeredPane();
layeredPanel.add(scrollPanel, 0, 0);
layeredPanel.add(systemPanel, 1, 0);
// Set frame.
JFrame frame = new JFrame("Mobius - GameServer");
final JFrame frame = new JFrame("Mobius - GameServer");
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
frame.addWindowListener(new WindowAdapter()
{
@@ -346,7 +346,7 @@ public class Gui
// Method that manages the redirect.
private void redirectSystemStreams()
{
OutputStream out = new OutputStream()
final OutputStream out = new OutputStream()
{
@Override
public void write(int b)

View File

@@ -49,37 +49,37 @@ public class SystemPanel extends JPanel
setOpaque(true);
setLayout(null);
JLabel lblProtocol = new JLabel("Protocol");
final JLabel lblProtocol = new JLabel("Protocol");
lblProtocol.setFont(new Font("Monospaced", Font.PLAIN, 16));
lblProtocol.setBounds(10, 5, 264, 17);
add(lblProtocol);
JLabel lblConnected = new JLabel("Connected");
final JLabel lblConnected = new JLabel("Connected");
lblConnected.setFont(new Font("Monospaced", Font.PLAIN, 16));
lblConnected.setBounds(10, 23, 264, 17);
add(lblConnected);
JLabel lblMaxConnected = new JLabel("Max connected");
final JLabel lblMaxConnected = new JLabel("Max connected");
lblMaxConnected.setFont(new Font("Monospaced", Font.PLAIN, 16));
lblMaxConnected.setBounds(10, 41, 264, 17);
add(lblMaxConnected);
JLabel lblOfflineShops = new JLabel("Offline trade");
final JLabel lblOfflineShops = new JLabel("Offline trade");
lblOfflineShops.setFont(new Font("Monospaced", Font.PLAIN, 16));
lblOfflineShops.setBounds(10, 59, 264, 17);
add(lblOfflineShops);
JLabel lblElapsedTime = new JLabel("Elapsed time");
final JLabel lblElapsedTime = new JLabel("Elapsed time");
lblElapsedTime.setFont(new Font("Monospaced", Font.PLAIN, 16));
lblElapsedTime.setBounds(10, 77, 264, 17);
add(lblElapsedTime);
JLabel lblJavaVersion = new JLabel("Build JDK");
final JLabel lblJavaVersion = new JLabel("Build JDK");
lblJavaVersion.setFont(new Font("Monospaced", Font.PLAIN, 16));
lblJavaVersion.setBounds(10, 95, 264, 17);
add(lblJavaVersion);
JLabel lblBuildDate = new JLabel("Build date");
final JLabel lblBuildDate = new JLabel("Build date");
lblBuildDate.setFont(new Font("Monospaced", Font.PLAIN, 16));
lblBuildDate.setBounds(10, 113, 264, 17);
add(lblBuildDate);
@@ -94,9 +94,9 @@ public class SystemPanel extends JPanel
lblBuildDate.setText("Build date: Unavailable");
try
{
File jarName = Locator.getClassSource(GameServer.class);
JarFile jarFile = new JarFile(jarName);
Attributes attrs = jarFile.getManifest().getMainAttributes();
final File jarName = Locator.getClassSource(GameServer.class);
final JarFile jarFile = new JarFile(jarName);
final Attributes attrs = jarFile.getManifest().getMainAttributes();
lblBuildDate.setText("Build date: " + attrs.getValue("Build-Date").split(" ")[0]);
jarFile.close();
}
@@ -131,13 +131,13 @@ public class SystemPanel extends JPanel
static String getDurationBreakdown(long millis)
{
long days = TimeUnit.MILLISECONDS.toDays(millis);
final long days = TimeUnit.MILLISECONDS.toDays(millis);
millis -= TimeUnit.DAYS.toMillis(days);
long hours = TimeUnit.MILLISECONDS.toHours(millis);
final long hours = TimeUnit.MILLISECONDS.toHours(millis);
millis -= TimeUnit.HOURS.toMillis(hours);
long minutes = TimeUnit.MILLISECONDS.toMinutes(millis);
final long minutes = TimeUnit.MILLISECONDS.toMinutes(millis);
millis -= TimeUnit.MINUTES.toMillis(minutes);
long seconds = TimeUnit.MILLISECONDS.toSeconds(millis);
final long seconds = TimeUnit.MILLISECONDS.toSeconds(millis);
return (days + "d " + hours + "h " + minutes + "m " + seconds + "s");
}

View File

@@ -59,30 +59,30 @@ public class frmAbout
frmAbout.setType(Type.UTILITY);
frmAbout.getContentPane().setLayout(null);
JLabel lblLjmobius = new JLabel("L2jMobius");
final JLabel lblLjmobius = new JLabel("L2jMobius");
lblLjmobius.setFont(new Font("Tahoma", Font.PLAIN, 32));
lblLjmobius.setHorizontalAlignment(SwingConstants.CENTER);
lblLjmobius.setBounds(10, 11, 271, 39);
frmAbout.getContentPane().add(lblLjmobius);
JLabel lblData = new JLabel("2013-" + Calendar.getInstance().get(Calendar.YEAR));
final JLabel lblData = new JLabel("2013-" + Calendar.getInstance().get(Calendar.YEAR));
lblData.setHorizontalAlignment(SwingConstants.CENTER);
lblData.setBounds(10, 44, 271, 14);
frmAbout.getContentPane().add(lblData);
JLabel lblSupports = new JLabel("Server Protocol");
final JLabel lblSupports = new JLabel("Server Protocol");
lblSupports.setHorizontalAlignment(SwingConstants.CENTER);
lblSupports.setFont(new Font("Tahoma", Font.PLAIN, 14));
lblSupports.setBounds(10, 78, 271, 23);
frmAbout.getContentPane().add(lblSupports);
JLabel lblProtocols = new JLabel("Protocol Number");
final JLabel lblProtocols = new JLabel("Protocol Number");
lblProtocols.setHorizontalAlignment(SwingConstants.CENTER);
lblProtocols.setFont(new Font("Tahoma", Font.PLAIN, 14));
lblProtocols.setBounds(10, 92, 271, 23);
frmAbout.getContentPane().add(lblProtocols);
JLabel site = new JLabel(URL);
final JLabel site = new JLabel(URL);
site.setText("<HTML><FONT color=\"#000099\"><U>" + URL + "</U></FONT></HTML>");
site.setHorizontalAlignment(SwingConstants.CENTER);
site.setBounds(76, 128, 140, 14);

View File

@@ -45,7 +45,7 @@ public class Locator
*/
public static File getClassSource(Class<?> c)
{
String classResource = c.getName().replace('.', '/') + ".class";
final String classResource = c.getName().replace('.', '/') + ".class";
return getResourceSource(c.getClassLoader(), classResource);
}
@@ -73,17 +73,17 @@ public class Locator
}
if (url != null)
{
String u = url.toString();
final String u = url.toString();
if (u.startsWith("jar:file:"))
{
int pling = u.indexOf('!');
String jarName = u.substring(4, pling);
final int pling = u.indexOf('!');
final String jarName = u.substring(4, pling);
return new File(fromURI(jarName));
}
else if (u.startsWith("file:"))
{
int tail = u.indexOf(resource);
String dirName = u.substring(0, tail);
final int tail = u.indexOf(resource);
final String dirName = u.substring(0, tail);
return new File(fromURI(dirName));
}
}
@@ -117,13 +117,13 @@ public class Locator
{
throw new IllegalArgumentException("Can only handle valid file: URIs");
}
StringBuilder buf = new StringBuilder(url.getHost());
final StringBuilder buf = new StringBuilder(url.getHost());
if (buf.length() > 0)
{
buf.insert(0, File.separatorChar).insert(0, File.separatorChar);
}
String file = url.getFile();
int queryPos = file.indexOf('?');
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);
@@ -146,20 +146,20 @@ public class Locator
{
return uri;
}
StringBuilder sb = new StringBuilder();
CharacterIterator iter = new StringCharacterIterator(uri);
final StringBuilder sb = new StringBuilder();
final CharacterIterator iter = new StringCharacterIterator(uri);
for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next())
{
if (c == '%')
{
char c1 = iter.next();
final char c1 = iter.next();
if (c1 != CharacterIterator.DONE)
{
int i1 = Character.digit(c1, 16);
char c2 = iter.next();
final int i1 = Character.digit(c1, 16);
final char c2 = iter.next();
if (c2 != CharacterIterator.DONE)
{
int i2 = Character.digit(c2, 16);
final int i2 = Character.digit(c2, 16);
sb.append((char) ((i1 << 4) + i2));
}
}
@@ -209,7 +209,7 @@ public class Locator
{
javaHome = javaHome.substring(0, javaHome.length() - 4);
}
File toolsJar = new File(javaHome + "/lib/tools.jar");
final File toolsJar = new File(javaHome + "/lib/tools.jar");
if (!toolsJar.exists())
{
System.out.println("Unable to locate tools.jar. " + "Expected to find it in " + toolsJar.getPath());
@@ -251,7 +251,7 @@ public class Locator
if (!location.isDirectory())
{
urls = new URL[1];
String path = location.getPath();
final String path = location.getPath();
for (String extension : extensions)
{
if (path.toLowerCase().endsWith(extension))
@@ -262,7 +262,7 @@ public class Locator
}
return urls;
}
File[] matches = location.listFiles((FilenameFilter) (dir, name) ->
final File[] matches = location.listFiles((FilenameFilter) (dir, name) ->
{
for (String extension : extensions)
{

View File

@@ -245,8 +245,8 @@ public class CronParser
*/
public static TaskTable parse(Reader reader) throws IOException
{
TaskTable table = new TaskTable();
BufferedReader bufferedReader = new BufferedReader(reader);
final TaskTable table = new TaskTable();
final BufferedReader bufferedReader = new BufferedReader(reader);
try
{
String line;
@@ -287,7 +287,7 @@ public class CronParser
String pattern = null;
for (int i = size; i >= 0; i--)
{
String aux = line.substring(0, i);
final String aux = line.substring(0, i);
if (SchedulingPattern.validate(aux))
{
pattern = aux;
@@ -301,12 +301,12 @@ public class CronParser
line = line.substring(pattern.length());
size = line.length();
// Splitting the line
ArrayList<String> splitted = new ArrayList<>();
final ArrayList<String> splitted = new ArrayList<>();
StringBuilder current = null;
boolean quotes = false;
for (int i = 0; i < size; i++)
{
char c = line.charAt(i);
final char c = line.charAt(i);
if (current == null)
{
if (c == '"')
@@ -371,12 +371,12 @@ public class CronParser
File stdinFile = null;
File stdoutFile = null;
File stderrFile = null;
ArrayList<String> envsList = new ArrayList<>();
final ArrayList<String> envsList = new ArrayList<>();
String command = null;
ArrayList<String> argsList = new ArrayList<>();
final ArrayList<String> argsList = new ArrayList<>();
for (int i = 0; i < size; i++)
{
String tk = splitted.get(i);
final String tk = splitted.get(i);
// Check the local status.
if (status == 0)
{
@@ -441,7 +441,7 @@ public class CronParser
throw new Exception("Invalid Java class name on line: " + line);
}
String methodName;
int sep = className.indexOf('#');
final int sep = className.indexOf('#');
if (sep == -1)
{
methodName = "main";
@@ -455,7 +455,7 @@ public class CronParser
throw new Exception("Invalid Java method name on line: " + line);
}
}
String[] args = new String[argsList.size()];
final String[] args = new String[argsList.size()];
for (int i = 0; i < argsList.size(); i++)
{
args[i] = argsList.get(i);
@@ -465,7 +465,7 @@ public class CronParser
else
{
// External command.
String[] cmdarray = new String[1 + argsList.size()];
final String[] cmdarray = new String[1 + argsList.size()];
cmdarray[0] = command;
for (int i = 0; i < argsList.size(); i++)
{
@@ -493,7 +493,7 @@ public class CronParser
}
}
// Builds the task.
ProcessTask process = new ProcessTask(cmdarray, envs, dir);
final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
// Channels.
if (stdinFile != null)
{
@@ -520,15 +520,15 @@ public class CronParser
*/
private static String escape(String str)
{
int size = str.length();
StringBuilder b = new StringBuilder();
final int size = str.length();
final StringBuilder b = new StringBuilder();
for (int i = 0; i < size; i++)
{
int skip = 0;
char c = str.charAt(i);
final char c = str.charAt(i);
if ((c == '\\') && (i < (size - 1)))
{
char d = str.charAt(i + 1);
final char d = str.charAt(i + 1);
if (d == '"')
{
b.append('"');
@@ -573,10 +573,10 @@ public class CronParser
{
if (i < (size - 5))
{
String hex = str.substring(i + 2, i + 6);
final String hex = str.substring(i + 2, i + 6);
try
{
int code = Integer.parseInt(hex, 16);
final int code = Integer.parseInt(hex, 16);
if (code >= 0)
{
b.append((char) code);

View File

@@ -60,8 +60,8 @@ class FileTaskCollector implements TaskCollector
*/
public synchronized File[] getFiles()
{
int size = files.size();
File[] ret = new File[size];
final int size = files.size();
final File[] ret = new File[size];
for (int i = 0; i < size; i++)
{
ret[i] = files.get(i);
@@ -75,11 +75,11 @@ class FileTaskCollector implements TaskCollector
@Override
public synchronized TaskTable getTasks()
{
TaskTable ret = new TaskTable();
int size = files.size();
final TaskTable ret = new TaskTable();
final int size = files.size();
for (int i = 0; i < size; i++)
{
File f = files.get(i);
final File f = files.get(i);
TaskTable aux = null;
try
{
@@ -87,12 +87,12 @@ class FileTaskCollector implements TaskCollector
}
catch (IOException e)
{
Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
e1.printStackTrace();
}
if (aux != null)
{
int auxSize = aux.size();
final int auxSize = aux.size();
for (int j = 0; j < auxSize; j++)
{
ret.add(aux.getSchedulingPattern(j), aux.getTask(j));

View File

@@ -41,7 +41,7 @@ class GUIDGenerator
*/
public static String generate()
{
StringBuilder id = new StringBuilder();
final StringBuilder id = new StringBuilder();
encode(id, MACHINE_DESCRIPTOR);
encode(id, Runtime.getRuntime());
encode(id, Thread.currentThread());
@@ -56,7 +56,7 @@ class GUIDGenerator
*/
private static String getMachineDescriptor()
{
StringBuilder descriptor = new StringBuilder();
final StringBuilder descriptor = new StringBuilder();
descriptor.append(System.getProperty("os.name"));
descriptor.append("::");
descriptor.append(System.getProperty("os.arch"));
@@ -65,7 +65,7 @@ class GUIDGenerator
descriptor.append("::");
descriptor.append(System.getProperty("user.name"));
descriptor.append("::");
StringBuilder b = buildNetworkInterfaceDescriptor();
final StringBuilder b = buildNetworkInterfaceDescriptor();
if (b != null)
{
descriptor.append(b);
@@ -102,13 +102,13 @@ class GUIDGenerator
// not available
return null;
}
StringBuilder b = new StringBuilder();
final StringBuilder b = new StringBuilder();
while (e1.hasMoreElements())
{
NetworkInterface ni = (NetworkInterface) e1.nextElement();
StringBuilder b1 = getMACAddressDescriptor(ni);
StringBuilder b2 = getInetAddressDescriptor(ni);
StringBuilder b3 = new StringBuilder();
final NetworkInterface ni = (NetworkInterface) e1.nextElement();
final StringBuilder b1 = getMACAddressDescriptor(ni);
final StringBuilder b2 = getInetAddressDescriptor(ni);
final StringBuilder b3 = new StringBuilder();
if (b1 != null)
{
b3.append(b1);
@@ -150,7 +150,7 @@ class GUIDGenerator
// not available.
haddr = null;
}
StringBuilder b = new StringBuilder();
final StringBuilder b = new StringBuilder();
if (haddr != null)
{
for (byte element : haddr)
@@ -159,7 +159,7 @@ class GUIDGenerator
{
b.append("-");
}
String hex = Integer.toHexString(0xff & element);
final String hex = Integer.toHexString(0xff & element);
if (hex.length() == 1)
{
b.append('0');
@@ -177,11 +177,11 @@ class GUIDGenerator
*/
private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
{
StringBuilder b = new StringBuilder();
Enumeration<?> e2 = ni.getInetAddresses();
final StringBuilder b = new StringBuilder();
final Enumeration<?> e2 = ni.getInetAddresses();
while (e2.hasMoreElements())
{
InetAddress addr = (InetAddress) e2.nextElement();
final InetAddress addr = (InetAddress) e2.nextElement();
if (b.length() > 0)
{
b.append(',');
@@ -217,8 +217,8 @@ class GUIDGenerator
*/
private static void encode(StringBuilder b, int value)
{
String hex = Integer.toHexString(value);
int hexSize = hex.length();
final String hex = Integer.toHexString(value);
final int hexSize = hex.length();
for (int i = 8; i > hexSize; i--)
{
b.append('0');
@@ -233,8 +233,8 @@ class GUIDGenerator
*/
private static void encode(StringBuilder b, long value)
{
String hex = Long.toHexString(value);
int hexSize = hex.length();
final String hex = Long.toHexString(value);
final int hexSize = hex.length();
for (int i = 16; i > hexSize; i--)
{
b.append('0');

View File

@@ -39,7 +39,7 @@ class IntArrayValueMatcher implements ValueMatcher
*/
public IntArrayValueMatcher(List<?> integers)
{
int size = integers.size();
final int size = integers.size();
values = new int[size];
for (int i = 0; i < size; i++)
{

View File

@@ -57,7 +57,7 @@ class LauncherThread extends Thread
this.collectors = collectors;
this.referenceTimeInMillis = referenceTimeInMillis;
// Thread name.
String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
setName(name);
}
@@ -78,18 +78,18 @@ class LauncherThread extends Thread
{
outer: for (TaskCollector collector : collectors)
{
TaskTable taskTable = collector.getTasks();
int size = taskTable.size();
final TaskTable taskTable = collector.getTasks();
final int size = taskTable.size();
for (int j = 0; j < size; j++)
{
if (isInterrupted())
{
break outer;
}
SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
{
Task task = taskTable.getTask(j);
final Task task = taskTable.getTask(j);
scheduler.spawnExecutor(task);
}
}

View File

@@ -66,7 +66,7 @@ class MemoryTaskCollector implements TaskCollector
*/
public synchronized String add(SchedulingPattern pattern, Task task)
{
String id = GUIDGenerator.generate();
final String id = GUIDGenerator.generate();
patterns.add(pattern);
tasks.add(task);
ids.add(id);
@@ -80,7 +80,7 @@ class MemoryTaskCollector implements TaskCollector
*/
public synchronized void update(String id, SchedulingPattern pattern)
{
int index = ids.indexOf(id);
final int index = ids.indexOf(id);
if (index > -1)
{
patterns.set(index, pattern);
@@ -94,7 +94,7 @@ class MemoryTaskCollector implements TaskCollector
*/
public synchronized void remove(String id) throws IndexOutOfBoundsException
{
int index = ids.indexOf(id);
final int index = ids.indexOf(id);
if (index > -1)
{
tasks.remove(index);
@@ -110,7 +110,7 @@ class MemoryTaskCollector implements TaskCollector
*/
public synchronized Task getTask(String id)
{
int index = ids.indexOf(id);
final int index = ids.indexOf(id);
if (index > -1)
{
return tasks.get(index);
@@ -125,7 +125,7 @@ class MemoryTaskCollector implements TaskCollector
*/
public synchronized SchedulingPattern getSchedulingPattern(String id)
{
int index = ids.indexOf(id);
final int index = ids.indexOf(id);
if (index > -1)
{
return patterns.get(index);
@@ -139,12 +139,12 @@ class MemoryTaskCollector implements TaskCollector
@Override
public synchronized TaskTable getTasks()
{
TaskTable ret = new TaskTable();
int size = tasks.size();
final TaskTable ret = new TaskTable();
final int size = tasks.size();
for (int i = 0; i < size; i++)
{
Task t = tasks.get(i);
SchedulingPattern p = patterns.get(i);
final Task t = tasks.get(i);
final SchedulingPattern p = patterns.get(i);
ret.add(p, t);
}
return ret;

View File

@@ -131,8 +131,8 @@ public class PastPredictor
return _time;
}
// Go through the matcher groups.
int size = _schedulingPattern.matcherSize;
long[] times = new long[size];
final int size = _schedulingPattern.matcherSize;
final long[] times = new long[size];
for (int k = 0; k < size; k++)
{
// Ok, split the time!
@@ -145,11 +145,11 @@ public class PastPredictor
int month = c.get(Calendar.MONTH);
int year = c.get(Calendar.YEAR);
// Gets the matchers.
ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
for (;;)
{ // day of week
for (;;)
@@ -195,7 +195,7 @@ public class PastPredictor
}
if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
{
DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
{
break;
@@ -267,7 +267,7 @@ public class PastPredictor
continue;
}
// Day of week.
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
if (dayOfWeekMatcher.match(dayOfWeek - 1))
{
break;

View File

@@ -69,7 +69,7 @@ public class Predictor
public Predictor(String schedulingPattern, long start) throws InvalidPatternException
{
this.schedulingPattern = new SchedulingPattern(schedulingPattern);
this.time = (start / (1000 * 60)) * 1000 * 60;
time = (start / (1000 * 60)) * 1000 * 60;
}
/**
@@ -102,7 +102,7 @@ public class Predictor
public Predictor(SchedulingPattern schedulingPattern, long start)
{
this.schedulingPattern = schedulingPattern;
this.time = (start / (1000 * 60)) * 1000 * 60;
time = (start / (1000 * 60)) * 1000 * 60;
}
/**
@@ -150,8 +150,8 @@ public class Predictor
return time;
}
// Go through the matcher groups.
int size = schedulingPattern.matcherSize;
long[] times = new long[size];
final int size = schedulingPattern.matcherSize;
final long[] times = new long[size];
for (int k = 0; k < size; k++)
{
// Ok, split the time!
@@ -164,11 +164,11 @@ public class Predictor
int month = c.get(Calendar.MONTH);
int year = c.get(Calendar.YEAR);
// Gets the matchers.
ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
for (;;)
{ // day of week
for (;;)
@@ -214,7 +214,7 @@ public class Predictor
}
if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
{
DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
{
break;
@@ -252,9 +252,9 @@ public class Predictor
c.set(Calendar.MONTH, month);
c.set(Calendar.YEAR, year);
// Day-of-month/month/year compatibility check.
int oldDayOfMonth = dayOfMonth;
int oldMonth = month;
int oldYear = year;
final int oldDayOfMonth = dayOfMonth;
final int oldMonth = month;
final int oldYear = year;
dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
month = c.get(Calendar.MONTH);
year = c.get(Calendar.YEAR);
@@ -264,7 +264,7 @@ public class Predictor
continue;
}
// Day of week.
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
if (dayOfWeekMatcher.match(dayOfWeek - 1))
{
break;

View File

@@ -241,22 +241,22 @@ public class ProcessTask extends Task
{
throw new RuntimeException(toString() + " cannot be started", e);
}
InputStream in = buildInputStream(stdinFile);
OutputStream out = buildOutputStream(stdoutFile);
OutputStream err = buildOutputStream(stderrFile);
final InputStream in = buildInputStream(stdinFile);
final OutputStream out = buildOutputStream(stdoutFile);
final OutputStream err = buildOutputStream(stderrFile);
if (in != null)
{
StreamBridge b = new StreamBridge(in, p.getOutputStream());
final StreamBridge b = new StreamBridge(in, p.getOutputStream());
b.start();
}
if (out != null)
{
StreamBridge b = new StreamBridge(p.getInputStream(), out);
final StreamBridge b = new StreamBridge(p.getInputStream(), out);
b.start();
}
if (err != null)
{
StreamBridge b = new StreamBridge(p.getErrorStream(), err);
final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
b.start();
}
int r;
@@ -315,7 +315,7 @@ public class ProcessTask extends Task
*/
private Process exec() throws IOException
{
Runtime rt = Runtime.getRuntime();
final Runtime rt = Runtime.getRuntime();
Process p;
try
{
@@ -385,7 +385,7 @@ public class ProcessTask extends Task
{
return "null";
}
StringBuilder b = new StringBuilder();
final StringBuilder b = new StringBuilder();
b.append('[');
for (int i = 0; i < arr.length; i++)
{
@@ -405,7 +405,7 @@ public class ProcessTask extends Task
@Override
public String toString()
{
StringBuilder b = new StringBuilder();
final StringBuilder b = new StringBuilder();
b.append("Task[");
b.append("cmd=");
b.append(listStrings(command));

View File

@@ -66,7 +66,7 @@ class RunnableTask extends Task
@Override
public String toString()
{
StringBuilder b = new StringBuilder();
final StringBuilder b = new StringBuilder();
b.append("Task[");
b.append("runnable=");
b.append(runnable);

View File

@@ -162,7 +162,7 @@ public class Scheduler
{
throw new IllegalStateException("Scheduler already started");
}
this.daemon = on;
daemon = on;
}
}
@@ -238,8 +238,8 @@ public class Scheduler
synchronized (collectors)
{
// Discard the first 2 elements in the list.
int size = collectors.size() - 2;
TaskCollector[] ret = new TaskCollector[size];
final int size = collectors.size() - 2;
final TaskCollector[] ret = new TaskCollector[size];
for (int i = 0; i < size; i++)
{
ret[i] = collectors.get(i + 2);
@@ -280,8 +280,8 @@ public class Scheduler
{
synchronized (listeners)
{
int size = listeners.size();
SchedulerListener[] ret = new SchedulerListener[size];
final int size = listeners.size();
final SchedulerListener[] ret = new SchedulerListener[size];
for (int i = 0; i < size; i++)
{
ret[i] = listeners.get(i);
@@ -299,8 +299,8 @@ public class Scheduler
{
synchronized (executors)
{
int size = executors.size();
TaskExecutor[] ret = new TaskExecutor[size];
final int size = executors.size();
final TaskExecutor[] ret = new TaskExecutor[size];
for (int i = 0; i < size; i++)
{
ret[i] = executors.get(i);
@@ -432,10 +432,10 @@ public class Scheduler
@Deprecated
public Runnable getTaskRunnable(Object id)
{
Task task = getTask((String) id);
final Task task = getTask((String) id);
if (task instanceof RunnableTask)
{
RunnableTask rt = (RunnableTask) task;
final RunnableTask rt = (RunnableTask) task;
return rt.getRunnable();
}
return null;
@@ -564,14 +564,14 @@ public class Scheduler
TaskCollector[] nowCollectors;
synchronized (collectors)
{
int size = collectors.size();
final int size = collectors.size();
nowCollectors = new TaskCollector[size];
for (int i = 0; i < size; i++)
{
nowCollectors[i] = collectors.get(i);
}
}
LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
synchronized (launchers)
{
launchers.add(l);
@@ -588,7 +588,7 @@ public class Scheduler
*/
TaskExecutor spawnExecutor(Task task)
{
TaskExecutor e = new TaskExecutor(this, task);
final TaskExecutor e = new TaskExecutor(this, task);
synchronized (executors)
{
executors.add(e);
@@ -629,10 +629,10 @@ public class Scheduler
{
synchronized (listeners)
{
int size = listeners.size();
final int size = listeners.size();
for (int i = 0; i < size; i++)
{
SchedulerListener l = listeners.get(i);
final SchedulerListener l = listeners.get(i);
l.taskLaunching(executor);
}
}
@@ -646,10 +646,10 @@ public class Scheduler
{
synchronized (listeners)
{
int size = listeners.size();
final int size = listeners.size();
for (int i = 0; i < size; i++)
{
SchedulerListener l = listeners.get(i);
final SchedulerListener l = listeners.get(i);
l.taskSucceeded(executor);
}
}
@@ -664,12 +664,12 @@ public class Scheduler
{
synchronized (listeners)
{
int size = listeners.size();
final int size = listeners.size();
if (size > 0)
{
for (int i = 0; i < size; i++)
{
SchedulerListener l = listeners.get(i);
final SchedulerListener l = listeners.get(i);
l.taskFailed(executor, exception);
}
}

View File

@@ -199,16 +199,16 @@ public class SchedulingPattern
*/
public SchedulingPattern(String pattern) throws InvalidPatternException
{
this.asString = pattern;
StringTokenizer st1 = new StringTokenizer(pattern, "|");
asString = pattern;
final StringTokenizer st1 = new StringTokenizer(pattern, "|");
if (st1.countTokens() < 1)
{
throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
}
while (st1.hasMoreTokens())
{
String localPattern = st1.nextToken();
StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
final String localPattern = st1.nextToken();
final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
if (st2.countTokens() != 5)
{
throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
@@ -270,11 +270,11 @@ public class SchedulingPattern
{
return new AlwaysTrueValueMatcher();
}
ArrayList<Object> values = new ArrayList<>();
StringTokenizer st = new StringTokenizer(str, ",");
final ArrayList<Object> values = new ArrayList<>();
final StringTokenizer st = new StringTokenizer(str, ",");
while (st.hasMoreTokens())
{
String element = st.nextToken();
final String element = st.nextToken();
ArrayList<Integer> local;
try
{
@@ -286,7 +286,7 @@ public class SchedulingPattern
}
for (Integer integer : local)
{
Object value = integer;
final Object value = integer;
if (!values.contains(value))
{
values.add(value);
@@ -313,8 +313,8 @@ public class SchedulingPattern
*/
private ArrayList<Integer> parseListElement(String str, ValueParser parser) throws Exception
{
StringTokenizer st = new StringTokenizer(str, "/");
int size = st.countTokens();
final StringTokenizer st = new StringTokenizer(str, "/");
final int size = st.countTokens();
if ((size < 1) || (size > 2))
{
throw new Exception("syntax error");
@@ -330,7 +330,7 @@ public class SchedulingPattern
}
if (size == 2)
{
String dStr = st.nextToken();
final String dStr = st.nextToken();
int div;
try
{
@@ -344,7 +344,7 @@ public class SchedulingPattern
{
throw new Exception("non positive divisor \"" + div + "\"");
}
ArrayList<Integer> values2 = new ArrayList<>();
final ArrayList<Integer> values2 = new ArrayList<>();
for (int i = 0; i < values.size(); i += div)
{
values2.add(values.get(i));
@@ -365,22 +365,22 @@ public class SchedulingPattern
{
if (str.equals("*"))
{
int min = parser.getMinValue();
int max = parser.getMaxValue();
ArrayList<Integer> values = new ArrayList<>();
final int min = parser.getMinValue();
final int max = parser.getMaxValue();
final ArrayList<Integer> values = new ArrayList<>();
for (int i = min; i <= max; i++)
{
values.add(i);
}
return values;
}
StringTokenizer st = new StringTokenizer(str, "-");
int size = st.countTokens();
final StringTokenizer st = new StringTokenizer(str, "-");
final int size = st.countTokens();
if ((size < 1) || (size > 2))
{
throw new Exception("syntax error");
}
String v1Str = st.nextToken();
final String v1Str = st.nextToken();
int v1;
try
{
@@ -392,11 +392,11 @@ public class SchedulingPattern
}
if (size == 1)
{
ArrayList<Integer> values = new ArrayList<>();
final ArrayList<Integer> values = new ArrayList<>();
values.add(v1);
return values;
}
String v2Str = st.nextToken();
final String v2Str = st.nextToken();
int v2;
try
{
@@ -406,7 +406,7 @@ public class SchedulingPattern
{
throw new Exception("invalid value \"" + v2Str + "\", " + e.getMessage());
}
ArrayList<Integer> values = new ArrayList<>();
final ArrayList<Integer> values = new ArrayList<>();
if (v1 < v2)
{
for (int i = v1; i <= v2; i++)
@@ -416,8 +416,8 @@ public class SchedulingPattern
}
else if (v1 > v2)
{
int min = parser.getMinValue();
int max = parser.getMaxValue();
final int min = parser.getMinValue();
final int max = parser.getMaxValue();
for (int i = v1; i <= max; i++)
{
values.add(i);
@@ -443,23 +443,23 @@ public class SchedulingPattern
*/
public boolean match(TimeZone timezone, long millis)
{
GregorianCalendar gc = new GregorianCalendar();
final GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(millis);
gc.setTimeZone(timezone);
int minute = gc.get(Calendar.MINUTE);
int hour = gc.get(Calendar.HOUR_OF_DAY);
int dayOfMonth = gc.get(Calendar.DAY_OF_MONTH);
int month = gc.get(Calendar.MONTH) + 1;
int dayOfWeek = gc.get(Calendar.DAY_OF_WEEK) - 1;
int year = gc.get(Calendar.YEAR);
final int minute = gc.get(Calendar.MINUTE);
final int hour = gc.get(Calendar.HOUR_OF_DAY);
final int dayOfMonth = gc.get(Calendar.DAY_OF_MONTH);
final int month = gc.get(Calendar.MONTH) + 1;
final int dayOfWeek = gc.get(Calendar.DAY_OF_WEEK) - 1;
final int year = gc.get(Calendar.YEAR);
for (int i = 0; i < matcherSize; i++)
{
ValueMatcher minuteMatcher = minuteMatchers.get(i);
ValueMatcher hourMatcher = hourMatchers.get(i);
ValueMatcher dayOfMonthMatcher = dayOfMonthMatchers.get(i);
ValueMatcher monthMatcher = monthMatchers.get(i);
ValueMatcher dayOfWeekMatcher = dayOfWeekMatchers.get(i);
boolean eval = minuteMatcher.match(minute) && hourMatcher.match(hour) && ((dayOfMonthMatcher instanceof DayOfMonthValueMatcher) ? ((DayOfMonthValueMatcher) dayOfMonthMatcher).match(dayOfMonth, month, gc.isLeapYear(year)) : dayOfMonthMatcher.match(dayOfMonth)) && monthMatcher.match(month) && dayOfWeekMatcher.match(dayOfWeek);
final ValueMatcher minuteMatcher = minuteMatchers.get(i);
final ValueMatcher hourMatcher = hourMatchers.get(i);
final ValueMatcher dayOfMonthMatcher = dayOfMonthMatchers.get(i);
final ValueMatcher monthMatcher = monthMatchers.get(i);
final ValueMatcher dayOfWeekMatcher = dayOfWeekMatchers.get(i);
final boolean eval = minuteMatcher.match(minute) && hourMatcher.match(hour) && ((dayOfMonthMatcher instanceof DayOfMonthValueMatcher) ? ((DayOfMonthValueMatcher) dayOfMonthMatcher).match(dayOfMonth, month, gc.isLeapYear(year)) : dayOfMonthMatcher.match(dayOfMonth)) && monthMatcher.match(month) && dayOfWeekMatcher.match(dayOfWeek);
if (eval)
{
return true;

View File

@@ -76,7 +76,7 @@ class StaticMethodTask extends Task
Method methodObject;
try
{
Class<?>[] argTypes = new Class[]
final Class<?>[] argTypes = new Class[]
{
String[].class
};
@@ -86,7 +86,7 @@ class StaticMethodTask extends Task
{
throw new RuntimeException("Cannot find a " + methodName + "(String[]) method in class " + className, e);
}
int modifiers = methodObject.getModifiers();
final int modifiers = methodObject.getModifiers();
if (!Modifier.isStatic(modifiers))
{
throw new RuntimeException("The method " + methodName + "(String[]) of the class " + className + " is not static");

View File

@@ -66,7 +66,7 @@ class StreamBridge
{
this.in = in;
this.out = out;
this.thread = new Thread(new Runner());
thread = new Thread(new Runner());
synchronized (traced)
{
traced.add(this);

View File

@@ -100,7 +100,7 @@ public class TaskExecutor
{
this.scheduler = scheduler;
this.task = task;
this.context = new MyContext();
context = new MyContext();
}
/**
@@ -135,8 +135,8 @@ public class TaskExecutor
{
synchronized (listeners)
{
int size = listeners.size();
TaskExecutorListener[] ret = new TaskExecutorListener[size];
final int size = listeners.size();
final TaskExecutorListener[] ret = new TaskExecutorListener[size];
for (int i = 0; i < size; i++)
{
ret[i] = listeners.get(i);
@@ -226,7 +226,7 @@ public class TaskExecutor
synchronized (lock)
{
startTime = System.currentTimeMillis();
String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::executor[" + guid + "]";
final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::executor[" + guid + "]";
thread = new Thread(new Runner());
thread.setDaemon(daemon);
thread.setName(name);
@@ -393,7 +393,7 @@ public class TaskExecutor
{
for (TaskExecutorListener taskExecutorListener : listeners)
{
TaskExecutorListener l = taskExecutorListener;
final TaskExecutorListener l = taskExecutorListener;
l.executionPausing(this);
}
}
@@ -408,7 +408,7 @@ public class TaskExecutor
{
for (TaskExecutorListener taskExecutorListener : listeners)
{
TaskExecutorListener l = taskExecutorListener;
final TaskExecutorListener l = taskExecutorListener;
l.executionResuming(this);
}
}
@@ -423,7 +423,7 @@ public class TaskExecutor
{
for (TaskExecutorListener taskExecutorListener : listeners)
{
TaskExecutorListener l = taskExecutorListener;
final TaskExecutorListener l = taskExecutorListener;
l.executionStopping(this);
}
}
@@ -439,7 +439,7 @@ public class TaskExecutor
{
for (TaskExecutorListener taskExecutorListener : listeners)
{
TaskExecutorListener l = taskExecutorListener;
final TaskExecutorListener l = taskExecutorListener;
l.executionTerminated(this, exception);
}
}
@@ -455,7 +455,7 @@ public class TaskExecutor
{
for (TaskExecutorListener taskExecutorListener : listeners)
{
TaskExecutorListener l = taskExecutorListener;
final TaskExecutorListener l = taskExecutorListener;
l.statusMessageChanged(this, statusMessage);
}
}
@@ -471,7 +471,7 @@ public class TaskExecutor
{
for (TaskExecutorListener taskExecutorListener : listeners)
{
TaskExecutorListener l = taskExecutorListener;
final TaskExecutorListener l = taskExecutorListener;
l.completenessValueChanged(this, completenessValue);
}
}

View File

@@ -45,7 +45,7 @@ class TimerThread extends Thread
{
this.scheduler = scheduler;
// Thread name.
String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::timer[" + guid + "]";
final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::timer[" + guid + "]";
setName(name);
}
@@ -69,9 +69,9 @@ class TimerThread extends Thread
long done = 0;
do
{
long before = System.currentTimeMillis();
final long before = System.currentTimeMillis();
sleep(millis - done);
long after = System.currentTimeMillis();
final long after = System.currentTimeMillis();
done += (after - before);
}
while (done < millis);
@@ -91,7 +91,7 @@ class TimerThread extends Thread
for (;;)
{
// Coffee break 'till next minute comes!
long sleepTime = (nextMinute - System.currentTimeMillis());
final long sleepTime = (nextMinute - System.currentTimeMillis());
if (sleepTime > 0)
{
try

View File

@@ -48,7 +48,7 @@ class ArrayStack
{
if ((idx + 1) == data.length)
{
double[] temp = new double[(int) (data.length * 1.2) + 1];
final double[] temp = new double[(int) (data.length * 1.2) + 1];
System.arraycopy(data, 0, temp, 0, data.length);
data = temp;
}

View File

@@ -157,7 +157,7 @@ public class Expression
}
break;
case Token.TOKEN_OPERATOR:
Operator op = ((OperatorToken) tok).getOperator();
final Operator op = ((OperatorToken) tok).getOperator();
if (op.getNumOperands() == 2)
{
count--;
@@ -209,7 +209,7 @@ public class Expression
}
else if (t.getType() == Token.TOKEN_OPERATOR)
{
OperatorToken op = (OperatorToken) t;
final OperatorToken op = (OperatorToken) t;
if (output.size() < op.getOperator().getNumOperands())
{
throw new IllegalArgumentException("Invalid number of operands available for '" + op.getOperator().getSymbol() + "' operator");
@@ -217,27 +217,27 @@ public class Expression
if (op.getOperator().getNumOperands() == 2)
{
/* pop the operands and push the result of the operation */
double rightArg = output.pop();
double leftArg = output.pop();
final double rightArg = output.pop();
final double leftArg = output.pop();
output.push(op.getOperator().apply(leftArg, rightArg));
}
else if (op.getOperator().getNumOperands() == 1)
{
/* pop the operand and push the result of the operation */
double arg = output.pop();
final double arg = output.pop();
output.push(op.getOperator().apply(arg));
}
}
else if (t.getType() == Token.TOKEN_FUNCTION)
{
FunctionToken func = (FunctionToken) t;
final FunctionToken func = (FunctionToken) t;
final int numArguments = func.getFunction().getNumArguments();
if (output.size() < numArguments)
{
throw new IllegalArgumentException("Invalid number of arguments available for '" + func.getFunction().getName() + "' function");
}
/* collect the arguments from the stack */
double[] args = new double[numArguments];
final double[] args = new double[numArguments];
for (int j = numArguments - 1; j >= 0; j--)
{
args[j] = output.pop();

View File

@@ -146,7 +146,7 @@ public class ExpressionBuilder
private void checkOperatorSymbol(Operator op)
{
String name = op.getSymbol();
final String name = op.getSymbol();
for (char ch : name.toCharArray())
{
if (!Operator.isAllowedOperatorChar(ch))

View File

@@ -86,7 +86,7 @@ public abstract class Function
@Deprecated
public static char[] getAllowedFunctionCharacters()
{
char[] chars = new char[53];
final char[] chars = new char[53];
int count = 0;
for (int i = 65; i < 91; i++)
{

View File

@@ -76,7 +76,7 @@ public class Functions
@Override
public double apply(double... args)
{
double tan = Math.tan(args[0]);
final double tan = Math.tan(args[0]);
if (tan == 0d)
{
throw new ArithmeticException("Division by zero in cotangent!");

View File

@@ -93,7 +93,7 @@ public abstract class Operator
public Operator(String symbol, int numberOfOperands, boolean leftAssociative, int precedence)
{
super();
this.numOperands = numberOfOperands;
numOperands = numberOfOperands;
this.leftAssociative = leftAssociative;
this.symbol = symbol;
this.precedence = precedence;

View File

@@ -33,7 +33,7 @@ public class OperatorToken extends Token
{
throw new IllegalArgumentException("Operator is unknown for token.");
}
this.operator = op;
operator = op;
}
/**

View File

@@ -43,7 +43,7 @@ public class ShuntingYard
final Tokenizer tokenizer = new Tokenizer(expression, userFunctions, userOperators, variableNames, implicitMultiplication);
while (tokenizer.hasNext())
{
Token token = tokenizer.nextToken();
final Token token = tokenizer.nextToken();
switch (token.getType())
{
case Token.TOKEN_NUMBER:
@@ -66,8 +66,8 @@ public class ShuntingYard
case Token.TOKEN_OPERATOR:
while (!stack.empty() && (stack.peek().getType() == Token.TOKEN_OPERATOR))
{
OperatorToken o1 = (OperatorToken) token;
OperatorToken o2 = (OperatorToken) stack.peek();
final OperatorToken o1 = (OperatorToken) token;
final OperatorToken o2 = (OperatorToken) stack.peek();
if ((o1.getOperator().getNumOperands() == 1) && (o2.getOperator().getNumOperands() == 2))
{
break;
@@ -103,7 +103,7 @@ public class ShuntingYard
}
while (!stack.empty())
{
Token t = stack.pop();
final Token t = stack.pop();
if ((t.getType() == Token.TOKEN_PARENTHESES_CLOSE) || (t.getType() == Token.TOKEN_PARENTHESES_OPEN))
{
throw new IllegalArgumentException("Mismatched parentheses detected. Please check the expression");

View File

@@ -39,7 +39,7 @@ public class Tokenizer
public Tokenizer(String expression, Map<String, Function> userFunctions, Map<String, Operator> userOperators, Set<String> variableNames, boolean implicitMultiplication)
{
this.expression = expression.trim().toCharArray();
this.expressionLength = this.expression.length;
expressionLength = this.expression.length;
this.userFunctions = userFunctions;
this.userOperators = userOperators;
this.variableNames = variableNames;
@@ -49,16 +49,16 @@ public class Tokenizer
public Tokenizer(String expression, Map<String, Function> userFunctions, Map<String, Operator> userOperators, Set<String> variableNames)
{
this.expression = expression.trim().toCharArray();
this.expressionLength = this.expression.length;
expressionLength = this.expression.length;
this.userFunctions = userFunctions;
this.userOperators = userOperators;
this.variableNames = variableNames;
this.implicitMultiplication = true;
implicitMultiplication = true;
}
public boolean hasNext()
{
return this.expression.length > pos;
return expression.length > pos;
}
public Token nextToken()
@@ -124,8 +124,8 @@ public class Tokenizer
private Token parseArgumentSeparatorToken(char ch)
{
this.pos++;
this.lastToken = new ArgumentSeparatorToken();
pos++;
lastToken = new ArgumentSeparatorToken();
return lastToken;
}
@@ -138,13 +138,13 @@ public class Tokenizer
{
if (open)
{
this.lastToken = new OpenParenthesesToken();
lastToken = new OpenParenthesesToken();
}
else
{
this.lastToken = new CloseParenthesesToken();
lastToken = new CloseParenthesesToken();
}
this.pos++;
pos++;
return lastToken;
}
@@ -160,19 +160,19 @@ public class Tokenizer
private Token parseFunctionOrVariable()
{
final int offset = this.pos;
final int offset = pos;
int testPos;
int lastValidLen = 1;
Token lastValidToken = null;
int len = 1;
if (isEndOfExpression(offset))
{
this.pos++;
pos++;
}
testPos = (offset + len) - 1;
while (!isEndOfExpression(testPos) && isVariableOrFunctionCharacter(expression[testPos]))
{
String name = new String(expression, offset, len);
final String name = new String(expression, offset, len);
if ((variableNames != null) && variableNames.contains(name))
{
lastValidLen = len;
@@ -202,9 +202,9 @@ public class Tokenizer
private Function getFunction(String name)
{
Function f = null;
if (this.userFunctions != null)
if (userFunctions != null)
{
f = this.userFunctions.get(name);
f = userFunctions.get(name);
}
if (f == null)
{
@@ -215,7 +215,7 @@ public class Tokenizer
private Token parseOperatorToken(char firstChar)
{
final int offset = this.pos;
final int offset = pos;
int len = 1;
final StringBuilder symbol = new StringBuilder();
Operator lastValid = null;
@@ -228,7 +228,7 @@ public class Tokenizer
while (symbol.length() > 0)
{
Operator op = getOperator(symbol.toString());
final Operator op = getOperator(symbol.toString());
if (op == null)
{
symbol.setLength(symbol.length() - 1);
@@ -248,9 +248,9 @@ public class Tokenizer
private Operator getOperator(String symbol)
{
Operator op = null;
if (this.userOperators != null)
if (userOperators != null)
{
op = this.userOperators.get(symbol);
op = userOperators.get(symbol);
}
if ((op == null) && (symbol.length() == 1))
{
@@ -261,7 +261,7 @@ public class Tokenizer
}
else
{
int lastTokenType = lastToken.getType();
final int lastTokenType = lastToken.getType();
if ((lastTokenType == Token.TOKEN_PARENTHESES_OPEN) || (lastTokenType == Token.TOKEN_SEPARATOR))
{
argc = 1;
@@ -283,9 +283,9 @@ public class Tokenizer
private Token parseNumberToken(char firstChar)
{
final int offset = this.pos;
final int offset = pos;
int len = 1;
this.pos++;
pos++;
if (isEndOfExpression(offset + len))
{
lastToken = new NumberToken(Double.parseDouble(String.valueOf(firstChar)));
@@ -294,7 +294,7 @@ public class Tokenizer
while (!isEndOfExpression(offset + len) && isNumeric(expression[offset + len], (expression[(offset + len) - 1] == 'e') || (expression[(offset + len) - 1] == 'E')))
{
len++;
this.pos++;
pos++;
}
// check if the e is at the end
if ((expression[(offset + len) - 1] == 'e') || (expression[(offset + len) - 1] == 'E'))
@@ -324,6 +324,6 @@ public class Tokenizer
private boolean isEndOfExpression(int offset)
{
return this.expressionLength <= offset;
return expressionLength <= offset;
}
}

View File

@@ -14,15 +14,15 @@ public class UnknownFunctionOrVariableException extends IllegalArgumentException
public UnknownFunctionOrVariableException(String expression, int position, int length)
{
this.expression = expression;
this.token = token(expression, position, length);
token = token(expression, position, length);
this.position = position;
this.message = "Unknown function or variable '" + token + "' at pos " + position + " in expression '" + expression + "'";
message = "Unknown function or variable '" + token + "' at pos " + position + " in expression '" + expression + "'";
}
private static String token(String expression, int position, int length)
{
int len = expression.length();
final int len = expression.length();
int end = (position + length) - 1;
if (len < end)

View File

@@ -75,7 +75,7 @@ public class RequestAuthLogin implements IIncomingPacket<LoginClient>
return;
}
byte[] decrypted = new byte[_newAuthMethod ? 256 : 128];
final byte[] decrypted = new byte[_newAuthMethod ? 256 : 128];
try
{
final Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding");

View File

@@ -64,7 +64,7 @@ public class RequestCmdLogin implements IIncomingPacket<LoginClient>
return;
}
byte[] decrypted = new byte[128];
final byte[] decrypted = new byte[128];
try
{
final Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding");

View File

@@ -33,9 +33,9 @@ public class RequestPIAgreementCheck implements IIncomingPacket<LoginClient>
public boolean read(LoginClient client, PacketReader packet)
{
_accountId = packet.readD();
byte[] padding0 = new byte[3];
byte[] checksum = new byte[4];
byte[] padding1 = new byte[12];
final byte[] padding0 = new byte[3];
final byte[] checksum = new byte[4];
final byte[] padding1 = new byte[12];
packet.readB(padding0, 0, padding0.length);
packet.readB(checksum, 0, checksum.length);
packet.readB(padding1, 0, padding1.length);

Some files were not shown because too many files have changed in this diff Show More