Code improvements.
This commit is contained in:
@@ -167,14 +167,7 @@ public class HexUtils
|
||||
|
||||
for (int dataIdx = offset, charsIdx = dstOffset; dataIdx < (len + offset); ++dataIdx, ++charsIdx)
|
||||
{
|
||||
if ((data[dataIdx] > 0x1f) && (data[dataIdx] < 0x80))
|
||||
{
|
||||
dstAsciiChars[charsIdx] = (char) data[dataIdx];
|
||||
}
|
||||
else
|
||||
{
|
||||
dstAsciiChars[charsIdx] = '.';
|
||||
}
|
||||
dstAsciiChars[charsIdx] = (data[dataIdx] > 0x1f) && (data[dataIdx] < 0x80) ? (char) data[dataIdx] : '.';
|
||||
}
|
||||
|
||||
return dstAsciiChars;
|
||||
@@ -245,9 +238,7 @@ public class HexUtils
|
||||
}
|
||||
else if (dataLen < _HEX_ED_BPL)
|
||||
{
|
||||
// last line which shows less than _HEX_ED_BPL bytes
|
||||
final int lineHexDataEnd = lineHexDataStart + (dataLen * _HEX_ED_CPB);
|
||||
Arrays.fill(textData, lineHexDataEnd, lineHexDataEnd + ((_HEX_ED_BPL - dataLen) * _HEX_ED_CPB) + 1, ' '); // spaces, for the last line if there are not _HEX_ED_BPL bytes
|
||||
Arrays.fill(textData, (lineHexDataStart + (dataLen * _HEX_ED_CPB)), lineHexDataStart + (dataLen * _HEX_ED_CPB) + ((_HEX_ED_BPL - dataLen) * _HEX_ED_CPB) + 1, ' ');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -90,22 +90,16 @@ public class IPv4Filter implements IAcceptFilter, Runnable
|
||||
return false;
|
||||
}
|
||||
|
||||
f.lastAccess = current;
|
||||
if ((f.lastAccess + 1000) > current)
|
||||
{
|
||||
f.lastAccess = current;
|
||||
|
||||
if (f.trys >= 3)
|
||||
{
|
||||
f.trys = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
f.trys++;
|
||||
}
|
||||
else
|
||||
{
|
||||
f.lastAccess = current;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -129,8 +123,7 @@ public class IPv4Filter implements IAcceptFilter, Runnable
|
||||
final Iterator<Entry<Integer, Flood>> it = _ipFloodMap.entrySet().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
final Flood f = it.next().getValue();
|
||||
if (f.lastAccess < reference)
|
||||
if (it.next().getValue().lastAccess < reference)
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
|
@@ -214,12 +214,12 @@ public final class PropertiesParser
|
||||
public String getString(String key, String defaultValue)
|
||||
{
|
||||
final String value = getValue(key);
|
||||
if (value == null)
|
||||
if (value != null)
|
||||
{
|
||||
_log.warning("[" + _file.getName() + "] missing property for key: " + key + " using default value: " + defaultValue);
|
||||
return defaultValue;
|
||||
return value;
|
||||
}
|
||||
return value;
|
||||
_log.warning("[" + _file.getName() + "] missing property for key: " + key + " using default value: " + defaultValue);
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public <T extends Enum<T>> T getEnum(String key, Class<T> clazz, T defaultValue)
|
||||
|
@@ -1129,8 +1129,7 @@ public final class BlowfishEngine
|
||||
*/
|
||||
private void processTable(int xl, int xr, int[] table)
|
||||
{
|
||||
final int size = table.length;
|
||||
for (int s = 0; s < size; s += 2)
|
||||
for (int s = 0; s < table.length; s += 2)
|
||||
{
|
||||
xl ^= P[0];
|
||||
xr ^= func(xl) ^ P[1];
|
||||
|
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.util.file.filter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
|
||||
/**
|
||||
* Specialized {@link FileFilter} class.<br>
|
||||
* Accepts <b>files</b> ending with ".bmp" only.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class BMPFilter implements FileFilter
|
||||
{
|
||||
@Override
|
||||
public boolean accept(File f)
|
||||
{
|
||||
if ((f == null) || !f.isFile())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return f.getName().toLowerCase().endsWith(".bmp");
|
||||
}
|
||||
}
|
@@ -29,10 +29,6 @@ public class OldPledgeFilter implements FileFilter
|
||||
@Override
|
||||
public boolean accept(File f)
|
||||
{
|
||||
if ((f == null) || !f.isFile())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return f.getName().startsWith("Pledge_");
|
||||
return (f != null) && f.isFile() && f.getName().startsWith("Pledge_");
|
||||
}
|
||||
}
|
@@ -29,10 +29,6 @@ public class SQLFilter implements FileFilter
|
||||
@Override
|
||||
public boolean accept(File f)
|
||||
{
|
||||
if ((f == null) || !f.isFile())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return f.getName().toLowerCase().endsWith(".sql");
|
||||
return (f != null) && f.isFile() && f.getName().toLowerCase().endsWith(".sql");
|
||||
}
|
||||
}
|
||||
|
@@ -29,10 +29,6 @@ public class XMLFilter implements FileFilter
|
||||
@Override
|
||||
public boolean accept(File f)
|
||||
{
|
||||
if ((f == null) || !f.isFile())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return f.getName().toLowerCase().endsWith(".xml");
|
||||
return (f != null) && f.isFile() && f.getName().toLowerCase().endsWith(".xml");
|
||||
}
|
||||
}
|
||||
|
@@ -46,15 +46,12 @@ public abstract class BaseRecievePacket
|
||||
|
||||
public int readC()
|
||||
{
|
||||
final int result = _decrypt[_off++] & 0xff;
|
||||
return result;
|
||||
return _decrypt[_off++] & 0xff;
|
||||
}
|
||||
|
||||
public int readH()
|
||||
{
|
||||
int result = _decrypt[_off++] & 0xff;
|
||||
result |= (_decrypt[_off++] << 8) & 0xff00;
|
||||
return result;
|
||||
return (_decrypt[_off++] & 0xff) | ((_decrypt[_off++] << 8) & 0xff00);
|
||||
}
|
||||
|
||||
public double readF()
|
||||
|
Reference in New Issue
Block a user