Small code improvements.

This commit is contained in:
MobiusDev
2017-08-28 03:19:28 +00:00
parent cfb8cc59e2
commit aec0c9dddb
114 changed files with 549 additions and 606 deletions

View File

@@ -54,7 +54,7 @@ public class IPSubnet
_mask = getMask(mask, _addr.length);
if (!applyMask(_addr))
{
throw new UnknownHostException(addr.toString() + "/" + mask);
throw new UnknownHostException(addr + "/" + mask);
}
}
@@ -117,7 +117,7 @@ public class IPSubnet
try
{
return InetAddress.getByAddress(_addr).toString() + "/" + size;
return InetAddress.getByAddress(_addr) + "/" + size;
}
catch (UnknownHostException e)
{
@@ -144,7 +144,7 @@ public class IPSubnet
return false;
}
private static final byte[] getMask(int n, int maxLength) throws UnknownHostException
private static byte[] getMask(int n, int maxLength) throws UnknownHostException
{
if ((n > (maxLength << 3)) || (n < 0))
{

View File

@@ -61,7 +61,7 @@ public class GeoEngine
* Returns the instance of the {@link GeoEngine}.
* @return {@link GeoEngine} : The instance.
*/
public static final GeoEngine getInstance()
public static GeoEngine getInstance()
{
return SingletonHolder._instance;
}
@@ -226,7 +226,7 @@ public class GeoEngine
* @param worldX
* @return int : Geo X
*/
public static final int getGeoX(int worldX)
public static int getGeoX(int worldX)
{
return (MathUtil.limit(worldX, L2World.MAP_MIN_X, L2World.MAP_MAX_X) - L2World.MAP_MIN_X) >> 4;
}
@@ -236,7 +236,7 @@ public class GeoEngine
* @param worldY
* @return int : Geo Y
*/
public static final int getGeoY(int worldY)
public static int getGeoY(int worldY)
{
return (MathUtil.limit(worldY, L2World.MAP_MIN_Y, L2World.MAP_MAX_Y) - L2World.MAP_MIN_Y) >> 4;
}
@@ -246,7 +246,7 @@ public class GeoEngine
* @param geoX
* @return int : World X
*/
public static final int getWorldX(int geoX)
public static int getWorldX(int geoX)
{
return (MathUtil.limit(geoX, 0, GeoStructure.GEO_CELLS_X) << 4) + L2World.MAP_MIN_X + 8;
}
@@ -256,7 +256,7 @@ public class GeoEngine
* @param geoY
* @return int : World Y
*/
public static final int getWorldY(int geoY)
public static int getWorldY(int geoY)
{
return (MathUtil.limit(geoY, 0, GeoStructure.GEO_CELLS_Y) << 4) + L2World.MAP_MIN_Y + 8;
}
@@ -364,7 +364,7 @@ public class GeoEngine
* @param inside : 2D description of {@link IGeoObject}
* @return byte[][] : Returns NSWE flags of {@link IGeoObject}.
*/
public static final byte[][] calculateGeoObject(boolean inside[][])
public static byte[][] calculateGeoObject(boolean inside[][])
{
// get dimensions
final int width = inside.length;
@@ -1260,7 +1260,7 @@ public class GeoEngine
* @param dirY : Y direction NSWE flag
* @return byte : NSWE flag of combined direction
*/
private static final byte getDirXY(byte dirX, byte dirY)
private static byte getDirXY(byte dirX, byte dirY)
{
// check axis directions
if (dirY == GeoStructure.CELL_FLAG_N)

View File

@@ -171,7 +171,7 @@ final class GeoEnginePathfinding extends GeoEngine
* @param target : the entry point
* @return List<NodeLoc> : list of node location
*/
private static final List<Location> constructPath(Node target)
private static List<Location> constructPath(Node target)
{
// create empty list
LinkedList<Location> list = new LinkedList<>();

View File

@@ -151,7 +151,7 @@ public final class BlockComplexDynamic extends BlockComplex implements IBlockDyn
}
@Override
public synchronized final void addGeoObject(IGeoObject object)
final synchronized public void addGeoObject(IGeoObject object)
{
// add geo object, update block geodata when added
if (_objects.add(object))
@@ -161,7 +161,7 @@ public final class BlockComplexDynamic extends BlockComplex implements IBlockDyn
}
@Override
public synchronized final void removeGeoObject(IGeoObject object)
final synchronized public void removeGeoObject(IGeoObject object)
{
// remove geo object, update block geodata when removed
if (_objects.remove(object))

View File

@@ -34,7 +34,7 @@ public class BlockMultilayer extends ABlock
/**
* Initializes the temporarily buffer.
*/
public static final void initialize()
public static void initialize()
{
// initialize temporarily buffer and sorting mechanism
_temp = ByteBuffer.allocate(GeoStructure.BLOCK_CELLS * MAX_LAYERS * 3);
@@ -44,7 +44,7 @@ public class BlockMultilayer extends ABlock
/**
* Releases temporarily buffer.
*/
public static final void release()
public static void release()
{
_temp = null;
}

View File

@@ -196,7 +196,7 @@ public final class BlockMultilayerDynamic extends BlockMultilayer implements IBl
}
@Override
public synchronized final void addGeoObject(IGeoObject object)
final synchronized public void addGeoObject(IGeoObject object)
{
// add geo object, update block geodata when added
if (_objects.add(object))
@@ -206,7 +206,7 @@ public final class BlockMultilayerDynamic extends BlockMultilayer implements IBl
}
@Override
public synchronized final void removeGeoObject(IGeoObject object)
final synchronized public void removeGeoObject(IGeoObject object)
{
// remove geo object, update block geodata when removed
if (_objects.remove(object))

View File

@@ -25,11 +25,11 @@ public interface IBlockDynamic
* Adds {@link IGeoObject} to the {@link ABlock}. The block will update geodata according the object.
* @param object : {@link IGeoObject} to be added.
*/
public void addGeoObject(IGeoObject object);
void addGeoObject(IGeoObject object);
/**
* Removes {@link IGeoObject} from the {@link ABlock}. The block will update geodata according the object.
* @param object : {@link IGeoObject} to be removed.
*/
public void removeGeoObject(IGeoObject object);
void removeGeoObject(IGeoObject object);
}

View File

@@ -25,29 +25,29 @@ public interface IGeoObject
* Returns geodata X coordinate of the {@link IGeoObject}.
* @return int : Geodata X coordinate.
*/
public int getGeoX();
int getGeoX();
/**
* Returns geodata Y coordinate of the {@link IGeoObject}.
* @return int : Geodata Y coordinate.
*/
public int getGeoY();
int getGeoY();
/**
* Returns geodata Z coordinate of the {@link IGeoObject}.
* @return int : Geodata Z coordinate.
*/
public int getGeoZ();
int getGeoZ();
/**
* Returns height of the {@link IGeoObject}.
* @return int : Height.
*/
public int getHeight();
int getHeight();
/**
* Returns {@link IGeoObject} data.
* @return byte[][] : {@link IGeoObject} data.
*/
public byte[][] getObjectGeoData();
byte[][] getObjectGeoData();
}

View File

@@ -44,12 +44,12 @@ import com.l2jmobius.gameserver.network.serverpackets.ExBrPremiumState;
*/
public class PremiumManager
{
private final static Logger LOGGER = Logger.getLogger(PremiumManager.class.getName());
private static final Logger LOGGER = Logger.getLogger(PremiumManager.class.getName());
// SQL Statement
private final static String LOAD_SQL = "SELECT account_name,enddate FROM account_premium";
private final static String UPDATE_SQL = "UPDATE account_premium SET enddate = ? WHERE account_name = ?";
private final static String ADD_SQL = "INSERT INTO account_premium (enddate,account_name) VALUE (?,?)";
private static final String LOAD_SQL = "SELECT account_name,enddate FROM account_premium";
private static final String UPDATE_SQL = "UPDATE account_premium SET enddate = ? WHERE account_name = ?";
private static final String ADD_SQL = "INSERT INTO account_premium (enddate,account_name) VALUE (?,?)";
class PremiumExpireTask implements Runnable
{

View File

@@ -59,7 +59,7 @@ public class PcStat extends PlayableStat
public static final int MAX_VITALITY_POINTS = 140000;
public static final int MIN_VITALITY_POINTS = 0;
private final static int FANCY_FISHING_ROD_SKILL = 21484;
private static final int FANCY_FISHING_ROD_SKILL = 21484;
public PcStat(L2PcInstance activeChar)
{

View File

@@ -242,29 +242,26 @@ public class PlayerVariables extends AbstractVariables
final String data = getString(EXTEND_DROP, "");
if (data.isEmpty())
{
result = Integer.toString(id) + "," + Long.toString(count);
result = id + "," + count;
}
else if (data.contains(";"))
{
for (String s : data.split(";"))
{
final String[] drop = s.split(",");
if (drop[0].equals(Integer.toString(id)))
{
s += ";" + drop[0] + "," + count;
continue;
}
result += ";" + s;
}
result = result.substring(1);
}
else
{
if (data.contains(";"))
{
for (String s : data.split(";"))
{
final String[] drop = s.split(",");
if (drop[0].equals(Integer.toString(id)))
{
s += ";" + drop[0] + "," + Long.toString(count);
continue;
}
result += ";" + s;
}
result = result.substring(1);
}
else
{
result = Integer.toString(id) + "," + Long.toString(count);
}
result = id + "," + count;
}
set(EXTEND_DROP, result);
}

View File

@@ -31,18 +31,18 @@ public interface SchedulerListener
* This one is called by the scheduler when a task execution is starting.
* @param executor The task executor.
*/
public void taskLaunching(TaskExecutor executor);
void taskLaunching(TaskExecutor executor);
/**
* This one is called by the scheduler to notify that a task execution has been successfully completed.
* @param executor The task executor.
*/
public void taskSucceeded(TaskExecutor executor);
void taskSucceeded(TaskExecutor executor);
/**
* This one is called by the scheduler to notify that a task execution has failed.
* @param executor The task executor.
* @param exception The exception representing the failure notification.
*/
public void taskFailed(TaskExecutor executor, Throwable exception);
void taskFailed(TaskExecutor executor, Throwable exception);
}

View File

@@ -519,19 +519,19 @@ public class SchedulingPattern
* @return The parsed value.
* @throws Exception If the value can't be parsed.
*/
public int parse(String value) throws Exception;
int parse(String value) throws Exception;
/**
* Returns the minimum value accepred by the parser.
* @return The minimum value accepred by the parser.
*/
public int getMinValue();
int getMinValue();
/**
* Returns the maximum value accepred by the parser.
* @return The maximum value accepred by the parser.
*/
public int getMaxValue();
int getMaxValue();
}
/**

View File

@@ -33,5 +33,5 @@ public interface TaskCollector
* returned table elements, executing any task whose scheduling pattern is matching the current system time.
* @return The task table that will be automatically injected in the scheduler.
*/
public TaskTable getTasks();
TaskTable getTasks();
}

View File

@@ -32,36 +32,36 @@ public interface TaskExecutionContext
* Returns the scheduler.
* @return The scheduler.
*/
public Scheduler getScheduler();
Scheduler getScheduler();
/**
* Returns the task executor.
* @return The task executor.
*/
public TaskExecutor getTaskExecutor();
TaskExecutor getTaskExecutor();
/**
* Sets the current status tracking message, that has to be something about what the task is doing at the moment.
* @param message A message representing the current execution status. Null messages will be blanked.
*/
public void setStatusMessage(String message);
void setStatusMessage(String message);
/**
* Sets the completeness tracking value, that has to be between 0 and 1.
* @param completeness A completeness value, between 0 and 1. Values out of range will be ignored.
*/
public void setCompleteness(double completeness);
void setCompleteness(double completeness);
/**
* If the task execution has been paused, stops until the operation is resumed. It can also returns because of a stop operation without any previous resuming. Due to this the task developer should always check the {@link TaskExecutionContext#isStopped()} value after any
* <em>pauseIfRequested()</em> call. Note that a task execution can be paused only if the task {@link Task#canBePaused()} method returns <em>true</em>.
*/
public void pauseIfRequested();
void pauseIfRequested();
/**
* Checks whether the task execution has been demanded to be stopped. If the returned value is <em>true</em>, the task developer must shut down gracefully its task execution, as soon as possible. Note that a task execution can be stopped only if the task {@link Task#canBePaused()} method returns
* <em>true</em>.
* @return <em>true</em> if the current task execution has been demanded to be stopped; <em>false</em> otherwise.
*/
public boolean isStopped();
boolean isStopped();
}

View File

@@ -30,38 +30,38 @@ public interface TaskExecutorListener
* Called when the execution has been requested to be paused.
* @param executor The source executor.
*/
public void executionPausing(TaskExecutor executor);
void executionPausing(TaskExecutor executor);
/**
* Called when the execution has been requested to be resumed.
* @param executor The source executor.
*/
public void executionResuming(TaskExecutor executor);
void executionResuming(TaskExecutor executor);
/**
* Called when the executor has been requested to be stopped.
* @param executor The source executor.
*/
public void executionStopping(TaskExecutor executor);
void executionStopping(TaskExecutor executor);
/**
* Called at execution end. If the execution has failed due to an error, the encountered exception is reported.
* @param executor The source executor.
* @param exception If the execution has been terminated due to an error, this is the encountered exception; otherwise the parameter is null.
*/
public void executionTerminated(TaskExecutor executor, Throwable exception);
void executionTerminated(TaskExecutor executor, Throwable exception);
/**
* Called every time the execution status message changes.
* @param executor The source executor.
* @param statusMessage The new status message.
*/
public void statusMessageChanged(TaskExecutor executor, String statusMessage);
void statusMessageChanged(TaskExecutor executor, String statusMessage);
/**
* Called every time the execution completeness value changes.
* @param executor The source executor.
* @param completenessValue The new completeness value.
*/
public void completenessValueChanged(TaskExecutor executor, double completenessValue);
void completenessValueChanged(TaskExecutor executor, double completenessValue);
}

View File

@@ -31,5 +31,5 @@ interface ValueMatcher
* @param value The value.
* @return true if the given value matches the rules of the ValueMatcher, false otherwise.
*/
public boolean match(int value);
boolean match(int value);
}

View File

@@ -165,7 +165,7 @@ public class ExpressionBuilder
{
for (Operator o : operators)
{
this.operator(o);
operator(o);
}
return this;
}
@@ -179,7 +179,7 @@ public class ExpressionBuilder
{
for (Operator o : operators)
{
this.operator(o);
operator(o);
}
return this;
}

View File

@@ -228,7 +228,7 @@ public class Tokenizer
while (symbol.length() > 0)
{
Operator op = this.getOperator(symbol.toString());
Operator op = getOperator(symbol.toString());
if (op == null)
{
symbol.setLength(symbol.length() - 1);

View File

@@ -49,7 +49,7 @@ public class IPv4Filter implements IAcceptFilter, Runnable
* @param ip
* @return
*/
private static final int hash(byte[] ip)
private static int hash(byte[] ip)
{
return (ip[0] & 0xFF) | ((ip[1] << 8) & 0xFF00) | ((ip[2] << 16) & 0xFF0000) | ((ip[3] << 24) & 0xFF000000);
}

View File

@@ -70,7 +70,7 @@ public final class GeoDataConverter
_format = type.equalsIgnoreCase("J") ? GeoFormat.L2J : GeoFormat.L2OFF;
// start conversion
System.out.println("GeoDataConverter: Converting all " + _format.toString() + " files.");
System.out.println("GeoDataConverter: Converting all " + _format + " files.");
// initialize geodata container
_blocks = new ABlock[GeoStructure.REGION_BLOCKS_X][GeoStructure.REGION_BLOCKS_Y];
@@ -116,7 +116,7 @@ public final class GeoDataConverter
}
}
}
System.out.println("GeoDataConverter: Converted " + converted + " " + _format.toString() + " to L2D region file(s).");
System.out.println("GeoDataConverter: Converted " + converted + " " + _format + " to L2D region file(s).");
// release multilayer block temporarily buffer
BlockMultilayer.release();
@@ -127,7 +127,7 @@ public final class GeoDataConverter
* @param filename : The name of the to load.
* @return boolean : True when successful.
*/
private static final boolean loadGeoBlocks(String filename)
private static boolean loadGeoBlocks(String filename)
{
// region file is load-able, try to load it
try (RandomAccessFile raf = new RandomAccessFile(Config.GEODATA_PATH + filename, "r");
@@ -217,7 +217,7 @@ public final class GeoDataConverter
* Recalculate diagonal flags for the region file.
* @return boolean : True when successful.
*/
private static final boolean recalculateNswe()
private static boolean recalculateNswe()
{
try
{
@@ -268,7 +268,7 @@ public final class GeoDataConverter
* @param nswe : NSWE flag to be updated.
* @return byte : Updated NSWE flag.
*/
private static final byte updateNsweBelow(int x, int y, short z, byte nswe)
private static byte updateNsweBelow(int x, int y, short z, byte nswe)
{
// calculate virtual layer height
short height = (short) (z + GeoStructure.CELL_IGNORE_HEIGHT);
@@ -306,7 +306,7 @@ public final class GeoDataConverter
return nswe;
}
private static final byte getNsweBelow(int geoX, int geoY, short worldZ)
private static byte getNsweBelow(int geoX, int geoY, short worldZ)
{
// out of geo coordinates
if ((geoX < 0) || (geoX >= GeoStructure.REGION_CELLS_X))
@@ -333,7 +333,7 @@ public final class GeoDataConverter
* @param filename : The name of file to save.
* @return boolean : True when successful.
*/
private static final boolean saveGeoBlocks(String filename)
private static boolean saveGeoBlocks(String filename)
{
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(Config.GEODATA_PATH + filename), GeoStructure.REGION_BLOCKS * GeoStructure.BLOCK_CELLS * 3))
{
@@ -357,7 +357,7 @@ public final class GeoDataConverter
}
}
private static final void loadGeoengineConfigs()
private static void loadGeoengineConfigs()
{
final PropertiesParser geoData = new PropertiesParser(Config.GEODATA_FILE);
Config.GEODATA_PATH = geoData.getString("GeoDataPath", "./data/geodata/");