|
Флудер
Регистрация: 20.01.2015
Сообщений: 7,201
С нами:
5952720
Репутация:
6527
|
|
Сообщение от Спойлер
package core.gameserver.utils;
import gnu.trove.map.hash.TIntIntHashMap;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import core.gameserver.model.quest.Quest;
import core.gameserver.utils.Util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AddonsConfig
{
private static final Logger log = LoggerFactory.getLogger(AddonsConfig.class);
private static final String dir = "./config/Addons";
private static ConcurrentHashMap properties = new ConcurrentHashMap();
private static ConcurrentHashMap questRewardRates = new ConcurrentHashMap();
private static ConcurrentHashMap questDropRates = new ConcurrentHashMap();
public static void load()
{
File files = new File(dir);
if (!files.exists())
log.warn("WARNING! " + dir + " not exists! Config not loaded!");
else
parseFiles(files.listFiles());
}
public static void reload()
{
synchronized(properties)
{
synchronized(questRewardRates)
{
synchronized(questDropRates)
{
properties = new ConcurrentHashMap();
questRewardRates = new ConcurrentHashMap();
questDropRates = new ConcurrentHashMap();
load();
}
}
}
}
private static void parseFiles(File[] files)
{
for (File f : files)
{
if (f.isHidden())
continue;
if (f.isDirectory() && !f.getName().contains("defaults"))
parseFiles(f.listFiles());
if (f.getName().startsWith("quest_reward_rates"))
{
try
{
InputStream is = new FileInputStream(f);
Properties p = new Properties();
p.load(is);
loadQuestRewardRates(p);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
else if (f.getName().startsWith("quest_drop_rates"))
{
try
{
InputStream is = new FileInputStream(f);
Properties p = new Properties();
p.load(is);
loadQuestDropRates(p);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
else if (f.getName().endsWith(".ini"))
{
try
{
InputStream is = new FileInputStream(f);
Properties p = new Properties();
p.load(is);
loadProperties(p);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
private static void loadQuestRewardRates(Properties p)
{
for (String name : p.stringPropertyNames())
{
int id;
try
{
id = Integer.parseInt(name);
}
catch (NumberFormatException nfe)
{
continue;
}
if(questRewardRates.get(id) != null)
{
questRewardRates.replace(id, Double.parseDouble(p.getProperty(name).trim()));
log.info("Duplicate quest id \"" + name + "\"");
}
else if (p.getProperty(name) == null)
log.info("Null property for quest id " + name);
else
questRewardRates.put(id, Double.parseDouble(p.getProperty(name).trim()));
}
p.clear();
}
private static void loadQuestDropRates(Properties p)
{
for (String name : p.stringPropertyNames())
{
int id;
try
{
id = Integer.parseInt(name);
} catch (NumberFormatException nfe)
{
continue;
}
if (questDropRates.get(id) != null)
{
questDropRates.replace(id, Double.parseDouble(p.getProperty(name).trim()));
log.info("Duplicate quest id \"" + name + "\"");
}
else if (p.getProperty(name) == null)
log.info("Null property for quest id " + name);
else
questDropRates.put(id, Double.parseDouble(p.getProperty(name).trim()));
}
p.clear();
}
private static void loadProperties(Properties p)
{
for (String name : p.stringPropertyNames())
{
if (properties.get(name) != null)
{
properties.replace(name, p.getProperty(name).trim());
log.info("Duplicate properties name \"" + name + "\" replaced with new value.");
}
else if (p.getProperty(name) == null)
log.info("Null property for key " + name);
else
properties.put(name, p.getProperty(name).trim());
}
p.clear();
}
public static double getQuestRewardRates(Quest q)
{
return questRewardRates.containsKey(q.getQuestIntId()) ? questRewardRates.get(q.getQuestIntId()) : 1.0;
}
public static double getQuestDropRates(Quest q)
{
return questDropRates.containsKey(q.getQuestIntId()) ? questDropRates.get(q.getQuestIntId()) : 1.0;
}
public static String get(String name)
{
if(properties.get(name) == null)
log.warn("ConfigSystem: Null value for key: " + name);
return properties.get(name);
}
public static float getFloat(String name)
{
return getFloat(name, Float.MAX_VALUE);
}
public static boolean getBoolean(String name)
{
return getBoolean(name, false);
}
public static int getInt(String name)
{
return getInt(name, Integer.MAX_VALUE);
}
public static int[] getIntArray(String name)
{
return getIntArray(name, new int[0]);
}
public static int getIntHex(String name)
{
return getIntHex(name, Integer.decode("0xFFFFFF"));
}
public static byte getByte(String name)
{
return getByte(name, Byte.MAX_VALUE);
}
public static long getLong(String name)
{
return getLong(name, Long.MAX_VALUE);
}
public static double getDouble(String name)
{
return getDouble(name, Double.MAX_VALUE);
}
public static String get(String name, String def)
{
return get(name) == null ? def : get(name);
}
public static float getFloat(String name, float def)
{
return Float.parseFloat(get(name, String.valueOf(def)));
}
public static boolean getBoolean(String name, boolean def)
{
return Boolean.parseBoolean(get(name, String.valueOf(def)));
}
public static int getInt(String name, int def)
{
return Integer.parseInt(get(name, String.valueOf(def)));
}
public static int[] getIntArray(String name, int[] def)
{
return get(name, null) == null ? def : Util.parseCommaSeparatedIntegerArray(get(name, null));
}
public static int getIntHex(String name, int def)
{
if(!get(name, String.valueOf(def)).trim().startsWith("0x"))
return Integer.decode("0x"+get(name, String.valueOf(def)));
else
return Integer.decode(get(name, String.valueOf(def)));
}
public static byte getByte(String name, byte def)
{
return Byte.parseByte(get(name, String.valueOf(def)));
}
public static double getDouble(String name, double def)
{
return Double.parseDouble(get(name, String.valueOf(def)));
}
public static long getLong(String name, long def)
{
return Long.parseLong(get(name, String.valueOf(def)));
}
public static void set(String name, String param)
{
properties.replace(name, param);
}
public static void set(String name, Object obj)
{
set(name, String.valueOf(obj));
}
public static TIntIntHashMap SKILL_DURATION_LIST;
public static TIntIntHashMap SKILL_REUSE_LIST;
public static void loadSkillDurationList()
{
if(getBoolean("EnableModifySkillDuration"))
{
String[] propertySplit = get("SkillDurationList").split(";");
SKILL_DURATION_LIST = new TIntIntHashMap(propertySplit.length);
for (String skill : propertySplit)
{
String[] skillSplit = skill.split(",");
if(skillSplit.length != 2)
log.warn(concat("[SkillDurationList]: invalid config property -> SkillDurationList \"", skill, "\""));
else
{
try
{
SKILL_DURATION_LIST.put(Integer.parseInt(skillSpli t[0]), Integer.parseInt(skillSplit[1]));
}
catch (NumberFormatException nfe)
{
if (!skill.isEmpty())
{
log.warn(concat("[SkillDurationList]: invalid config property -> SkillList \"", skillSplit[0], "\"", skillSplit[1]));
}
}
}
}
}
}
public static void loadSkillReuseList()
{
if(getBoolean("EnableModifySkillReuse"))
{
String[] propertySplit = get("SkillReuseList").split(";");
SKILL_REUSE_LIST = new TIntIntHashMap(propertySplit.length);
for (String skill : propertySplit)
{
String[] skillSplit = skill.split(",");
if (skillSplit.length != 2)
log.warn(concat("[SkillReuseList]: invalid config property -> SkillReuseList \"", skill, "\""));
else
{
try
{
SKILL_REUSE_LIST.put(Integer.valueOf(skillSplit[0]), Integer.valueOf(skillSplit[1]));
}
catch (NumberFormatException nfe)
{
if (!skill.isEmpty())
log.warn(concat("[SkillReuseList]: invalid config property -> SkillList \"", skillSplit[0], "\"", skillSplit[1]));
}
}
}
}
}
public static String concat(final String... strings)
{
final StringBuilder sbString = new StringBuilder(getLength(strings));
for (final String string : strings)
{
sbString.append(string);
}
return sbString.toString();
}
private static int getLength(final String[] strings)
{
int length = 0;
for (final String string : strings)
{
length += string.length();
}
return length;
}
}
Госпади, а зачем он ещё впиливал ScriptConfig. Одно другого хуже не разобрался как наверное реализовать по нормальному решил впилить шлак. Гавнокод в работе.
Сообщение от Спойлер
package core.gameserver.utils;
import core.gameserver.Config;
import core.gameserver.model.items.ItemInstance;
import core.gameserver.model.Player;
import core.gameserver.network.l2.s2c.InventoryUpdate;
public class FixEnchantOlympiad
{
public static void storeEnchantItemsOly(Player player)
{
ItemInstance[] arr = player.getInventory().getItems();
int len = arr.length;
StringBuilder items = new StringBuilder();
for (int i = 0; i Config.OLY_ENCHANT_LIMIT_WEAPON)
|| (item.isArmor() && item.getEnchantLevel() > Config.OLY_ENCHANT_LIMIT_ARMOR)
|| (item.isAccessory() && item.getEnchantLevel() > Config.OLY_ENCHANT_LIMIT_JEWEL))
return true;
return false;
}
public static void restoreEnchantItemsOly(Player player)
{
if(player.getVar("EnItemOlyRec") == null)
return;
String var;
var = player.getVar("EnItemOlyRec");
if(var != null)
{
String[] items = var.split(":");
for(String item : items)
{
if(item.equals(""))
continue;
String[] values = item.split(";");
if(values.length 0) // если он существует
{
if (last_modif >= lastModified(name)) // и новее оригинального файла
return Strings.bbParse(read(tmp)); // то вернуть локализованный
_log.warn("Last modify of " + name + " more then " + tmp); // если он существует но устарел - выругаться в лог
}
return Strings.bbParse(read(name)); // если локализованный файл отсутствует вернуть оригинальный
}
public static String langFileName(String name, String lang) {
if (lang == null || lang.equalsIgnoreCase("en"))
lang = "";
String tmp;
tmp = name.replaceAll("(.(\\.htm)", "$1-" + lang + "$2");
if (!tmp.equals(name) && lastModified(tmp) > 0)
return tmp;
tmp = name.replaceAll("(.(/[^/].+\\.htm)", "$1/" + lang + "$2");
if (!tmp.equals(name) && lastModified(tmp) > 0)
return tmp;
tmp = name.replaceAll("(.+?/html)/", "$1-" + lang + "/");
if (!tmp.equals(name) && lastModified(tmp) > 0)
return tmp;
if (lastModified(name) > 0)
return name;
return null;
}
public static long lastModified(String name) {
if (name == null)
return 0;
return new File(name).lastModified();
}
}
Госпади упаси от этого бреда. GameStats.java аналогично
А вот дальше пойдёт полная жопа.
Сообщение от Спойлер
package core.gameserver.utils;
import java.util.Arrays;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.NoSuchElementException;
import core.commons.util.Rnd;
/**
* Полный аналог ArrayList, но намного быстрее удаляет.
* Вместо сдвига всего массива перемещает последний элемент списка на место удаленного.
* Побочный эффект - размер массива при удалении элемента не меняется, но можно использовать clear.
*
* Базовая версия.
*
* @see core.Util.GCArray - конкуррентнобезопасная версия
* @see core.Util.GSArray - синхронизированная версия
* @see core.Util.GCSArray - конкуррентнобезопасная синхронизированная версия
*/
public class GArray implements Collection
{
protected transient E[] elementData;
protected transient int modCount = 0;
protected int size;
@SuppressWarnings("unchecked")
public GArray(int initialCapacity)
{
if(initialCapacity oldCapacity)
{
int newCapacity = oldCapacity * 3 / 2 + 1;
if(newCapacity T[] toArray(T[] a)
{
if(a.length size)
a[size] = null;
return a;
}
public E get(int index)
{
RangeCheck(index);
return elementData[index];
}
@SuppressWarnings("unchecked")
public boolean add(E e)
{
ensureCapacity(size + 1);
elementData[size++] = e;
return true;
}
public E getRandomize()
{
if (isEmpty())
return null;
int index = Rnd.get(size);
RangeCheck(index);
return elementData[index];
}
public boolean remove(Object o)
{
if(o == null)
{
for(int index = 0; index 0 ? remove(0) : null;
}
public E removeLast()
{
if(size > 0)
{
modCount++;
size--;
E old = elementData[size];
elementData[size] = null;
return old;
}
return null;
}
public E set(int index, E element)
{
RangeCheck(index);
E oldValue = elementData[index];
elementData[index] = element;
return oldValue;
}
public int indexOf(Object o)
{
if(o == null)
{
for(int i = 0; i c)
{
if(c == null)
return false;
boolean modified = false;
Iterator e = c.iterator();
while(e.hasNext())
if(add(e.next()))
modified = true;
return modified;
}
public boolean removeAll(Collection c)
{
boolean modified = false;
for(int i = 0; i c)
{
boolean modified = false;
for(int i = 0; i c)
{
for(int i = 0; i = size)
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
}
@SuppressWarnings("unchecked")
public void clear()
{
modCount++;
int oldSize = size;
size = 0;
if(oldSize > 1000)
elementData = (E[]) new Object[10];
else
for(int i = 0; i iterator()
{
return new Itr();
}
private class Itr implements Iterator
{
int cursor = 0;
int lastRet = -1;
int expectedModCount = modCount;
public boolean hasNext()
{
return cursor ";
}
@SuppressWarnings("unchecked")
public void sort()
{
Object tmp[] = toArray();
Arrays.sort(tmp);
elementData = (E[]) tmp;
}
public boolean addIfNotContains(E e)
{
if (contains(e))
return false;
return add(e);
}
}[/I]
Сообщение от Спойлер
package core.gameserver.utils;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* Аналог ArrayList, ArrayList, но намного быстрее удаляет.
* Вместо сдвига всего массива перемещает последний элемент списка на место удаленного.
* Побочный эффект - размер массива при удалении элемента не меняется, но можно использовать clear.
*
* Конкуррентнобезопасная версия, для итерации создается копия списка.
* Метод remove для итератора не работает и возвращает IllegalStateException.
*
* @see core.Util.GArray - базовая версия
* @see core.Util.GSArray - синхронизированная версия
* @see core.Util.GCSArray - конкуррентнобезопасная синхронизированная версия
*/
public class GCArray implements Collection
{
private transient E[] elementData;
private int size;
@SuppressWarnings("unchecked")
public GCArray(int initialCapacity)
{
super();
if(initialCapacity oldCapacity)
{
int newCapacity = oldCapacity * 3 / 2 + 1;
if(newCapacity T[] toArray(T[] a)
{
if(a.length size)
a[size] = null;
return a;
}
public E get(int index)
{
RangeCheck(index);
return elementData[index];
}
public boolean add(E e)
{
ensureCapacity(size + 1);
elementData[size++] = e;
return true;
}
public boolean remove(Object o)
{
if(o == null)
{
for(int index = 0; index c)
{
boolean modified = false;
Iterator e = c.iterator();
while(e.hasNext())
if(add(e.next()))
modified = true;
return modified;
}
public boolean removeAll(Collection c)
{
boolean modified = false;
for(int i = 0; i c)
{
boolean modified = false;
for(int i = 0; i c)
{
for(int i = 0; i = size)
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
}
@SuppressWarnings("unchecked")
public void clear()
{
int oldSize = size;
size = 0;
if(oldSize > 1000)
elementData = (E[]) new Object[10];
else
for(int i = 0; i iterator()
{
return new Itr();
}
private class Itr implements Iterator
{
E[] data = toNativeArray();
int size = data.length;
int cursor = 0;
public boolean hasNext()
{
return cursor != size;
}
public E next()
{
try
{
return data[cursor++];
}
catch(IndexOutOfBoundsException e)
{
throw new NoSuchElementException();
}
}
/**
* НЕ РАБОТАЕТ!
*/
public void remove()
{
throw new IllegalStateException();
}
}
}
Сообщение от Спойлер
package core.gameserver.utils;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* Аналог ArrayList, но намного быстрее удаляет.
* Вместо сдвига всего массива перемещает последний элемент списка на место удаленного.
* Побочный эффект - размер массива при удалении элемента не меняется, но можно использовать clear.
*
* Конкуррентнобезопасная синхронизированная версия, для итерации создается копия списка.
* Метод remove для итератора не работает и возвращает IllegalStateException.
*
* @see core.Util.GArray - базовая версия
* @see core.Util.GCArray - конкуррентнобезопасная версия
* @see core.Util.GSArray - синхронизированная версия
*/
public class GCSArray implements Collection
{
private transient E[] elementData;
private int size;
@SuppressWarnings("unchecked")
public GCSArray(int initialCapacity)
{
super();
if(initialCapacity oldCapacity)
{
int newCapacity = oldCapacity * 3 / 2 + 1;
if(newCapacity T[] toArray(T[] a)
{
if(a.length size)
a[size] = null;
return a;
}
public synchronized E get(int index)
{
RangeCheck(index);
return elementData[index];
}
public synchronized boolean add(E e)
{
ensureCapacity(size + 1);
elementData[size++] = e;
return true;
}
public synchronized boolean remove(Object o)
{
if(o == null)
{
for(int index = 0; index c)
{
boolean modified = false;
Iterator e = c.iterator();
while(e.hasNext())
if(add(e.next()))
modified = true;
return modified;
}
public synchronized boolean removeAll(Collection c)
{
boolean modified = false;
for(int i = 0; i c)
{
boolean modified = false;
for(int i = 0; i c)
{
for(int i = 0; i = size)
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
}
@SuppressWarnings("unchecked")
public synchronized void clear()
{
int oldSize = size;
size = 0;
if(oldSize > 1000)
elementData = (E[]) new Object[10];
else
for(int i = 0; i iterator()
{
return new Itr();
}
private class Itr implements Iterator
{
E[] data = toNativeArray();
int size = data.length;
int cursor = 0;
public boolean hasNext()
{
return cursor != size;
}
public E next()
{
try
{
return data[cursor++];
}
catch(IndexOutOfBoundsException e)
{
throw new NoSuchElementException();
}
}
/**
* НЕ РАБОТАЕТ!
*/
public void remove()
{
throw new IllegalStateException();
}
}
}
Сообщение от Спойлер
package core.gameserver.utils;
import java.util.Arrays;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* Аналог ArrayList, но намного быстрее удаляет.
* Вместо сдвига всего массива перемещает последний элемент списка на место удаленного.
* Побочный эффект - размер массива при удалении элемента не меняется, но можно использовать clear.
*
* Синхронизированная версия.
*
* @see core.Util.GArray - базовая версия
* @see core.Util.GCArray - конкуррентнобезопасная версия
* @see core.Util.GCSArray - конкуррентнобезопасная синхронизированная версия
*/
public class GSArray implements Collection
{
private transient E[] elementData;
private transient int modCount = 0;
private int size;
@SuppressWarnings("unchecked")
public GSArray(int initialCapacity)
{
super();
if(initialCapacity oldCapacity)
{
int newCapacity = oldCapacity * 3 / 2 + 1;
if(newCapacity T[] toArray(T[] a)
{
if(a.length size)
a[size] = null;
return a;
}
public synchronized E get(int index)
{
RangeCheck(index);
return elementData[index];
}
public synchronized boolean add(E e)
{
ensureCapacity(size + 1);
elementData[size++] = e;
return true;
}
public synchronized boolean remove(Object o)
{
if(o == null)
{
for(int index = 0; index c)
{
boolean modified = false;
Iterator e = c.iterator();
while(e.hasNext())
if(add(e.next()))
modified = true;
return modified;
}
public synchronized boolean removeAll(Collection c)
{
boolean modified = false;
for(int i = 0; i c)
{
boolean modified = false;
for(int i = 0; i c)
{
for(int i = 0; i = size)
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
}
@SuppressWarnings("unchecked")
public synchronized void clear()
{
modCount++;
int oldSize = size;
size = 0;
if(oldSize > 1000)
elementData = (E[]) new Object[10];
else
for(int i = 0; i iterator()
{
return new Itr();
}
private class Itr implements Iterator
{
int cursor = 0;
int lastRet = -1;
int expectedModCount = modCount;
public boolean hasNext()
{
return cursor != size();
}
public E next()
{
checkForComodification();
try
{
E next = get(cursor);
lastRet = cursor++;
return next;
}
catch(IndexOutOfBoundsException e)
{
checkForComodification();
throw new NoSuchElementException();
}
}
public void remove()
{
if(lastRet == -1)
throw new IllegalStateException();
checkForComodification();
try
{
GSArray.this.remove(lastRet);
if(lastRet banned_hwids = new GArray();
private static final GSArray>> bonus_hwids = new GSArray>>();
public static final HWIDComparator DefaultComparator = new HWIDComparator();
public static final HWIDComparator BAN_Comparator = new HWIDComparator();
public static final String SELECT_HWID = "SELECT HWID FROM " + GGConfig.HWID_BANS_TABLE;
public static final String REPLACE_HWID = "REPLACE INTO " + GGConfig.HWID_BANS_TABLE + " (hwid,comments) VALUES (?,?)";
public static final String DELETE_HWID = "DELETE FROM " + GGConfig.HWID_BANS_TABLE + " WHERE hwid=?";
public static void reloadBannedHWIDs()
{
synchronized (banned_hwids)
{
banned_hwids.clear();
}
Connection con = null;
PreparedStatement st = null;
ResultSet rs = null;
try
{
con = DatabaseFactory.getInstance().getConnection();
st = con.prepareStatement(SELECT_HWID);
rs = st.executeQuery();
synchronized (banned_hwids)
{
while (rs.next())
banned_hwids.add(new HardwareID(rs.getString("HWID")));
}
_log.info("Protection: Loaded " + banned_hwids.size() + " banned HWIDs");
}
catch(final Exception e)
{
_log.warn("Protection: Failed to load banned HWIDs", e);
}
finally
{
DbUtils.closeQuietly(con, st, rs);
}
}
public static boolean checkHWIDBanned(final HardwareID hwid)
{
synchronized (banned_hwids)
{
return hwid != null && BAN_Comparator.contains(hwid, banned_hwids);
}
}
public static String handleBanHWID(final String[] argv)
{
if(!GGConfig.ALLOW_GUARD_SYSTEM || !GGConfig.PROTECT_GS_ENABLE_HWID_BANS)
return "HWID bans feature disabled";
if(argv == null || argv.length 3)
{
for(int i = 3; i getPlayersByHWID(final HardwareID hwid)
{
final GArray result = new GArray();
if(hwid != null)
for(final Player cha : GameObjectsStorage.getAllPlayers())
if(!cha.isInOfflineMode() && cha.getNetConnection() != null && cha.getNetConnection().protect_used && hwid.equals(cha.getHWID()))
result.add(cha);
return result;
}
/**
* Возвращает список всех HWID, кторые попадают под условия компаратора.
*/
public static GArray>> getAllMatches(final HardwareID hwid, final HWIDComparator comparator)
{
final GArray>> ret = new GArray>>();
synchronized (bonus_hwids)
{
for(final Entry> entry : bonus_hwids)
if(comparator.compare(entry.getKey(), hwid) == HWIDComparator.EQUALS)
ret.add(entry);
}
return ret;
}
public static class HardwareID
{
public final String Full;
public HardwareID(final String s)
{
Full = s;
}
@Override
public int hashCode()
{
return Full.hashCode();
}
@Override
public boolean equals(final Object obj)
{
if(obj == null || !(obj instanceof HardwareID))
return false;
return DefaultComparator.compare(this, (HardwareID) obj) == HWIDComparator.EQUALS;
}
@Override
public String toString()
{
return String.format("%s", Full);
}
}
public static class HWIDComparator implements Comparator
{
public static final int EQUALS = 0;
public static final int NOT_EQUALS = 1;
public HWIDComparator()
{}
@Override
public int compare(final HardwareID o1, final HardwareID o2)
{
if(o1 == null || o2 == null)
return o1 == o2 ? EQUALS : NOT_EQUALS;
return EQUALS;
}
public int find(final HardwareID hwid, final List in)
{
for(int i = 0; i in)
{
return find(hwid, in) != -1;
}
public boolean remove(final HardwareID hwid, final List in)
{
final int i = find(hwid, in);
return i == -1 ? false : in.remove(i) != null;
}
public int find(final HardwareID hwid, final GArray in)
{
for(int i = 0; i in)
{
return find(hwid, in) != -1;
}
public boolean remove(final HardwareID hwid, final GArray in)
{
final int i = find(hwid, in);
return i == -1 ? false : in.remove(i) != null;
}
@Override
public String toString()
{
return "HWIDComparator";
}
}
private static final class Entry implements Map.Entry
{
private final K _key;
private V _value;
public Entry(final K key, final V value)
{
_key = key;
_value = value;
}
@Override
public K getKey()
{
return _key;
}
@Override
public V getValue()
{
return _value;
}
@Override
public V setValue(final V value)
{
return _value = value;
}
}
}
|