Use of singleton holders for class instances.

This commit is contained in:
MobiusDevelopment
2019-08-23 21:00:02 +00:00
parent d2deb75d85
commit d885d11741
100 changed files with 1186 additions and 1409 deletions

View File

@ -81,19 +81,9 @@ public class nProtect
protected Method _sendRequest = null;
protected Method _closeSession = null;
protected Method _sendGGQuery = null;
private static nProtect _instance = null;
private static boolean enabled = false;
public static nProtect getInstance()
{
if (_instance == null)
{
_instance = new nProtect();
}
return _instance;
}
private nProtect()
{
Class<?> clazz = null;
@ -220,4 +210,14 @@ public class nProtect
{
return enabled;
}
public static nProtect getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final nProtect INSTANCE = new nProtect();
}
}

View File

@ -42,18 +42,6 @@ public class NetcoreConfig
public int CLIENT_PACKET_QUEUE_MAX_UNDERFLOWS_PER_MIN; // default 1
public int CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN; // default 5
// ============================================================
private static NetcoreConfig _instance;
public static NetcoreConfig getInstance()
{
if (_instance == null)
{
_instance = new NetcoreConfig();
}
return _instance;
}
private NetcoreConfig()
{
final String MMO_CONFIG = "./config/protected/MmoCore.ini";
@ -84,4 +72,14 @@ public class NetcoreConfig
throw new Error("Failed to Load " + MMO_CONFIG + " File.");
}
}
public static NetcoreConfig getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final NetcoreConfig INSTANCE = new NetcoreConfig();
}
}

View File

@ -341,7 +341,7 @@ public class GameServer
PetitionManager.getInstance();
CursedWeaponsManager.getInstance();
TaskManager.getInstance();
PetDataTable.getInstance().loadPetsData();
PetDataTable.getInstance();
if (Config.SAVE_DROPPED_ITEM)
{
ItemsOnGroundManager.getInstance();

View File

@ -30,29 +30,12 @@ import org.l2jmobius.gameserver.model.items.type.EtcItemType;
public class ItemsAutoDestroy
{
protected static final Logger LOGGER = Logger.getLogger(ItemsAutoDestroy.class.getName());
private static ItemsAutoDestroy _instance;
protected Collection<ItemInstance> _items = null;
protected static long _sleep;
private ItemsAutoDestroy()
{
_items = ConcurrentHashMap.newKeySet();
_sleep = Config.AUTODESTROY_ITEM_AFTER * 1000;
if (_sleep == 0)
{
_sleep = 3600000;
}
ThreadPool.scheduleAtFixedRate(new CheckItemsForDestroy(), 5000, 5000);
}
private final Collection<ItemInstance> _items = ConcurrentHashMap.newKeySet();
public static ItemsAutoDestroy getInstance()
protected ItemsAutoDestroy()
{
if (_instance == null)
{
LOGGER.info("Initializing ItemsAutoDestroy.");
_instance = new ItemsAutoDestroy();
}
return _instance;
ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000);
}
public synchronized void addItem(ItemInstance item)
@ -61,7 +44,7 @@ public class ItemsAutoDestroy
_items.add(item);
}
public synchronized void removeItems()
private synchronized void removeItems()
{
if (_items.isEmpty())
{
@ -90,7 +73,7 @@ public class ItemsAutoDestroy
}
}
}
else if ((curtime - item.getDropTime()) > _sleep)
else if ((curtime - item.getDropTime()) > (Config.AUTODESTROY_ITEM_AFTER * 1000))
{
World.getInstance().removeVisibleObject(item, item.getWorldRegion());
World.getInstance().removeObject(item);
@ -104,12 +87,13 @@ public class ItemsAutoDestroy
}
}
protected class CheckItemsForDestroy extends Thread
public static ItemsAutoDestroy getInstance()
{
@Override
public void run()
{
removeItems();
}
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy();
}
}

View File

@ -62,8 +62,6 @@ public class LoginServerThread extends Thread
protected static final Logger LOGGER = Logger.getLogger(LoginServerThread.class.getName());
/** The LoginServerThread singleton */
private static LoginServerThread _instance;
private static final int REVISION = 0x0102;
private RSAPublicKey _publicKey;
private final String _hostname;
@ -122,15 +120,6 @@ public class LoginServerThread extends Thread
_maxPlayer = Config.MAXIMUM_ONLINE_USERS;
}
public static LoginServerThread getInstance()
{
if (_instance == null)
{
_instance = new LoginServerThread();
}
return _instance;
}
@Override
public void run()
{
@ -207,7 +196,7 @@ public class LoginServerThread extends Thread
final int packetType = decrypt[0] & 0xff;
switch (packetType)
{
case 00:
case 0x00:
{
final InitLS init = new InitLS(decrypt);
if (init.getRevision() != REVISION)
@ -225,7 +214,7 @@ public class LoginServerThread extends Thread
}
catch (GeneralSecurityException e)
{
LOGGER.warning("Troubles while init the public key send by login");
LOGGER.warning("Trouble while init the public key send by login");
break;
}
// send the blowfish key through the rsa encryption
@ -239,14 +228,14 @@ public class LoginServerThread extends Thread
sendPacket(ar);
break;
}
case 01:
case 0x01:
{
final LoginServerFail lsf = new LoginServerFail(decrypt);
LOGGER.info("Damn! Registeration Failed: " + lsf.getReasonString());
// login will close the connection here
break;
}
case 02:
case 0x02:
{
final AuthResponse aresp = new AuthResponse(decrypt);
_serverID = aresp.getServerId();
@ -299,7 +288,7 @@ public class LoginServerThread extends Thread
}
break;
}
case 03:
case 0x03:
{
final PlayerAuthResponse par = new PlayerAuthResponse(decrypt);
final String account = par.getAccount();
@ -345,7 +334,7 @@ public class LoginServerThread extends Thread
}
break;
}
case 04:
case 0x04:
{
KickPlayer kp = new KickPlayer(decrypt);
doKickPlayer(kp.getAccount());
@ -708,4 +697,18 @@ public class LoginServerThread extends Thread
{
return _interrupted;
}
/**
* Gets the single instance of LoginServerThread.
* @return single instance of LoginServerThread
*/
public static LoginServerThread getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final LoginServerThread INSTANCE = new LoginServerThread();
}
}

View File

@ -72,7 +72,6 @@ public class Shutdown extends Thread
protected static final Logger LOGGER = Logger.getLogger(Shutdown.class.getName());
private static Shutdown _instance;
private static Shutdown _counterInstance = null;
private int _secondsShut;
@ -81,13 +80,9 @@ public class Shutdown extends Thread
private boolean _shutdownStarted;
/** 0 */
public static final int SIGTERM = 0;
/** 1 */
public static final int GM_SHUTDOWN = 1;
/** 2 */
public static final int GM_RESTART = 2;
/** 3 */
public static final int ABORT = 3;
private static final String[] MODE_TEXT =
@ -132,19 +127,6 @@ public class Shutdown extends Thread
_shutdownStarted = false;
}
/**
* get the shutdown-hook instance the shutdown-hook instance is created by the first call of this function, but it has to be registered externally.
* @return instance of Shutdown, to be used as shutdown hook
*/
public static Shutdown getInstance()
{
if (_instance == null)
{
_instance = new Shutdown();
}
return _instance;
}
public boolean isShutdownStarted()
{
boolean output = _shutdownStarted;
@ -165,7 +147,7 @@ public class Shutdown extends Thread
@Override
public void run()
{
if (this == _instance)
if (this == getInstance())
{
closeServer();
}
@ -373,7 +355,7 @@ public class Shutdown extends Thread
LOGGER.info("[STATUS] Server shutdown successfully.");
if (_instance._shutdownMode == GM_RESTART)
if (getInstance()._shutdownMode == GM_RESTART)
{
Runtime.getRuntime().halt(2);
}
@ -557,4 +539,18 @@ public class Shutdown extends Thread
}
}
}
/**
* Get the shutdown-hook instance the shutdown-hook instance is created by the first call of this function, but it has to be registered externally.<br>
* @return instance of Shutdown, to be used as shutdown hook
*/
public static Shutdown getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final Shutdown INSTANCE = new Shutdown();
}
}

View File

@ -42,7 +42,6 @@ import org.l2jmobius.gameserver.model.actor.instance.ItemInstance;
public class TradeController
{
private static Logger LOGGER = Logger.getLogger(TradeController.class.getName());
private static TradeController _instance;
private int _nextListId;
private final Map<Integer, StoreTradeList> _lists;
@ -73,15 +72,6 @@ public class TradeController
}
}
public static TradeController getInstance()
{
if (_instance == null)
{
_instance = new TradeController();
}
return _instance;
}
private TradeController()
{
_lists = new HashMap<>();
@ -625,11 +615,13 @@ public class TradeController
return _nextListId++;
}
/**
* This will reload buylists info from DataBase
*/
public static void reload()
public static TradeController getInstance()
{
_instance = new TradeController();
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final TradeController INSTANCE = new TradeController();
}
}

View File

@ -41,29 +41,13 @@ public class CrestCache
{
private static Logger LOGGER = Logger.getLogger(CrestCache.class.getName());
private static CrestCache _instance;
private final Map<Integer, byte[]> _cachePledge = new HashMap<>();
private final Map<Integer, byte[]> _cachePledgeLarge = new HashMap<>();
private final Map<Integer, byte[]> _cacheAlly = new HashMap<>();
private int _loadedFiles;
private long _bytesBuffLen;
public static CrestCache getInstance()
{
if (_instance == null)
{
_instance = new CrestCache();
}
return _instance;
}
public CrestCache()
private CrestCache()
{
convertOldPedgeFiles();
reload();
@ -394,4 +378,14 @@ public class CrestCache
return file.getName().startsWith("Pledge_");
}
}
public static CrestCache getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CrestCache INSTANCE = new CrestCache();
}
}

View File

@ -33,24 +33,12 @@ import org.l2jmobius.gameserver.util.Util;
public class HtmCache
{
private static Logger LOGGER = Logger.getLogger(HtmCache.class.getName());
private static HtmCache _instance;
private final Map<Integer, String> _cache;
private int _loadedFiles;
private long _bytesBuffLen;
public static HtmCache getInstance()
{
if (_instance == null)
{
_instance = new HtmCache();
}
return _instance;
}
public HtmCache()
private HtmCache()
{
_cache = new HashMap<>();
reload();
@ -248,4 +236,14 @@ public class HtmCache
return false;
}
public static HtmCache getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final HtmCache INSTANCE = new HtmCache();
}
}

View File

@ -28,20 +28,9 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
*/
public class WarehouseCacheManager
{
private static WarehouseCacheManager _instance;
protected final Map<PlayerInstance, Long> _cachedWh;
protected final long _cacheTime;
public static WarehouseCacheManager getInstance()
{
if (_instance == null)
{
_instance = new WarehouseCacheManager();
}
return _instance;
}
private WarehouseCacheManager()
{
_cacheTime = Config.WAREHOUSE_CACHE_TIME * 60000; // 60*1000 = 60000
@ -75,4 +64,14 @@ public class WarehouseCacheManager
}
}
}
public static WarehouseCacheManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager();
}
}

View File

@ -23,7 +23,6 @@ import org.l2jmobius.gameserver.model.Skill;
*/
public class HeroSkillTable
{
private static HeroSkillTable _instance;
private static Skill[] _heroSkills;
private HeroSkillTable()
@ -36,16 +35,6 @@ public class HeroSkillTable
_heroSkills[4] = SkillTable.getInstance().getInfo(1376, 1);
}
public static HeroSkillTable getInstance()
{
if (_instance == null)
{
_instance = new HeroSkillTable();
}
return _instance;
}
public static Skill[] getHeroSkills()
{
return _heroSkills;
@ -72,4 +61,14 @@ public class HeroSkillTable
return false;
}
public static HeroSkillTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final HeroSkillTable INSTANCE = new HeroSkillTable();
}
}

View File

@ -27,27 +27,16 @@ import org.l2jmobius.gameserver.model.actor.instance.ControllableMobInstance;
*/
public class MobGroupTable
{
private static MobGroupTable _instance;
private final Map<Integer, MobGroup> _groupMap;
public static final int FOLLOW_RANGE = 300;
public static final int RANDOM_RANGE = 300;
public MobGroupTable()
private MobGroupTable()
{
_groupMap = new HashMap<>();
}
public static MobGroupTable getInstance()
{
if (_instance == null)
{
_instance = new MobGroupTable();
}
return _instance;
}
public void addGroup(int groupKey, MobGroup group)
{
_groupMap.put(groupKey, group);
@ -85,4 +74,14 @@ public class MobGroupTable
{
return _groupMap.remove(groupKey) != null;
}
public static MobGroupTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final MobGroupTable INSTANCE = new MobGroupTable();
}
}

View File

@ -23,7 +23,6 @@ import org.l2jmobius.gameserver.model.Skill;
*/
public class NobleSkillTable
{
private static NobleSkillTable _instance;
private static Skill[] _nobleSkills;
private NobleSkillTable()
@ -39,18 +38,18 @@ public class NobleSkillTable
_nobleSkills[7] = SkillTable.getInstance().getInfo(1327, 1);
}
public static NobleSkillTable getInstance()
{
if (_instance == null)
{
_instance = new NobleSkillTable();
}
return _instance;
}
public Skill[] GetNobleSkills()
{
return _nobleSkills;
}
public static NobleSkillTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final NobleSkillTable INSTANCE = new NobleSkillTable();
}
}

View File

@ -25,31 +25,18 @@ import org.l2jmobius.gameserver.model.items.type.WeaponType;
public class SkillTable
{
// private static Logger LOGGER = Logger.getLogger(SkillTable.class);
private static SkillTable _instance;
private final Map<Integer, Skill> _skills;
private final Map<Integer, Skill> _skills = new HashMap<>();
private final boolean _initialized = true;
public static SkillTable getInstance()
{
if (_instance == null)
{
_instance = new SkillTable();
}
return _instance;
}
private SkillTable()
{
_skills = new HashMap<>();
DocumentEngine.getInstance().loadAllSkills(_skills);
reload();
}
public void reload()
{
_instance = new SkillTable();
_skills.clear();
DocumentEngine.getInstance().loadAllSkills(_skills);
}
public boolean isInitialized()
@ -135,4 +122,14 @@ public class SkillTable
return weaponsAllowed;
}
public static SkillTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final SkillTable INSTANCE = new SkillTable();
}
}

View File

@ -38,18 +38,6 @@ public class ExtractableItemsData
// Map<itemid, ExtractableItem>
private Map<Integer, ExtractableItem> _items;
private static ExtractableItemsData _instance = null;
public static ExtractableItemsData getInstance()
{
if (_instance == null)
{
_instance = new ExtractableItemsData();
}
return _instance;
}
public ExtractableItemsData()
{
_items = new HashMap<>();
@ -176,4 +164,14 @@ public class ExtractableItemsData
}
return result;
}
public static ExtractableItemsData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final ExtractableItemsData INSTANCE = new ExtractableItemsData();
}
}

View File

@ -37,18 +37,12 @@ import org.l2jmobius.gameserver.model.FishData;
public class FishTable
{
private static Logger LOGGER = Logger.getLogger(SkillTreeTable.class.getName());
private static final FishTable INSTANCE = new FishTable();
private static List<FishData> _fishsNormal;
private static List<FishData> _fishsEasy;
private static List<FishData> _fishsHard;
public static FishData fish;
public static FishTable getInstance()
{
return INSTANCE;
}
private FishTable()
{
int count = 0;
@ -221,4 +215,14 @@ public class FishTable
return result;
}
public static FishTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final FishTable INSTANCE = new FishTable();
}
}

View File

@ -31,28 +31,13 @@ import org.l2jmobius.Config;
import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.items.Henna;
/**
* @version $Revision$ $Date$
*/
public class HennaTable
{
private static Logger LOGGER = Logger.getLogger(HennaTable.class.getName());
private static HennaTable _instance;
private final Map<Integer, Henna> _henna;
private final boolean _initialized = true;
public static HennaTable getInstance()
{
if (_instance == null)
{
_instance = new HennaTable();
}
return _instance;
}
private HennaTable()
{
_henna = new HashMap<>();
@ -163,4 +148,13 @@ public class HennaTable
return _henna.get(id);
}
public static HennaTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final HennaTable INSTANCE = new HennaTable();
}
}

View File

@ -49,10 +49,7 @@ public class MapRegionTable
{
private static Logger LOGGER = Logger.getLogger(MapRegionTable.class.getName());
private static MapRegionTable _instance;
private final int[][] _regions = new int[19][21];
private final int[][] _pointsWithKarmas;
public enum TeleportWhereType
@ -64,16 +61,6 @@ public class MapRegionTable
Fortress
}
public static MapRegionTable getInstance()
{
if (_instance == null)
{
_instance = new MapRegionTable();
}
return _instance;
}
private MapRegionTable()
{
FileReader reader = null;
@ -620,4 +607,14 @@ public class MapRegionTable
coord = local_zone.getSpawnLoc();
return new Location(coord[0], coord[1], coord[2]);
}
public static MapRegionTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final MapRegionTable INSTANCE = new MapRegionTable();
}
}

View File

@ -39,24 +39,10 @@ public class NpcWalkerRoutesTable
{
protected static final Logger LOGGER = Logger.getLogger(NpcWalkerRoutesTable.class.getName());
private static NpcWalkerRoutesTable _instance;
private List<NpcWalkerNode> _routes;
public static NpcWalkerRoutesTable getInstance()
{
if (_instance == null)
{
_instance = new NpcWalkerRoutesTable();
LOGGER.info("Initializing Walkers Routes Table.");
}
return _instance;
}
private NpcWalkerRoutesTable()
{
// not here
}
public void load()
@ -166,7 +152,6 @@ public class NpcWalkerRoutesTable
public List<NpcWalkerNode> getRouteForNpc(int id)
{
final List<NpcWalkerNode> _return = new ArrayList<>();
for (NpcWalkerNode node : _routes)
{
if (node.getNpcId() == id)
@ -174,7 +159,16 @@ public class NpcWalkerRoutesTable
_return.add(node);
}
}
return _return;
}
public static NpcWalkerRoutesTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final NpcWalkerRoutesTable INSTANCE = new NpcWalkerRoutesTable();
}
}

View File

@ -38,20 +38,9 @@ import org.l2jmobius.gameserver.model.actor.instance.RecipeInstance;
public class RecipeTable extends RecipeController
{
private static final Logger LOGGER = Logger.getLogger(RecipeTable.class.getName());
private final Map<Integer, RecipeList> _lists;
private static RecipeTable instance;
public static RecipeTable getInstance()
{
if (instance == null)
{
instance = new RecipeTable();
}
return instance;
}
private RecipeTable()
{
_lists = new HashMap<>();
@ -232,4 +221,14 @@ public class RecipeTable extends RecipeController
}
return null;
}
public static RecipeTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final RecipeTable INSTANCE = new RecipeTable();
}
}

View File

@ -34,19 +34,8 @@ public class StaticObjects
{
private static Logger LOGGER = Logger.getLogger(StaticObjects.class.getName());
private static StaticObjects _instance;
private final Map<Integer, StaticObjectInstance> _staticObjects;
public static StaticObjects getInstance()
{
if (_instance == null)
{
_instance = new StaticObjects();
}
return _instance;
}
public StaticObjects()
{
_staticObjects = new HashMap<>();
@ -152,4 +141,14 @@ public class StaticObjects
return obj;
}
public static StaticObjects getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final StaticObjects INSTANCE = new StaticObjects();
}
}

View File

@ -31,18 +31,6 @@ public class SummonItemsData
private final Map<Integer, SummonItem> _summonitems;
private static SummonItemsData _instance;
public static SummonItemsData getInstance()
{
if (_instance == null)
{
_instance = new SummonItemsData();
}
return _instance;
}
public SummonItemsData()
{
_summonitems = new HashMap<>();
@ -132,4 +120,14 @@ public class SummonItemsData
}
return result;
}
public static SummonItemsData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final SummonItemsData INSTANCE = new SummonItemsData();
}
}

View File

@ -29,21 +29,10 @@ import org.l2jmobius.gameserver.model.ArmorSet;
public class ArmorSetsTable
{
private static final Logger LOGGER = Logger.getLogger(ArmorSetsTable.class.getName());
private static ArmorSetsTable _instance;
public Map<Integer, ArmorSet> armorSets;
private final Map<Integer, ArmorDummy> cusArmorSets;
public static ArmorSetsTable getInstance()
{
if (_instance == null)
{
_instance = new ArmorSetsTable();
}
return _instance;
}
private ArmorSetsTable()
{
armorSets = new HashMap<>();
@ -162,4 +151,14 @@ public class ArmorSetsTable
return _shield;
}
}
public static ArmorSetsTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final ArmorSetsTable INSTANCE = new ArmorSetsTable();
}
}

View File

@ -28,17 +28,6 @@ public class CharNameTable
{
private static final Logger LOGGER = Logger.getLogger(CharNameTable.class.getName());
private static CharNameTable _instance;
public static CharNameTable getInstance()
{
if (_instance == null)
{
_instance = new CharNameTable();
}
return _instance;
}
public synchronized boolean doesCharNameExist(String name)
{
boolean result = true;
@ -166,4 +155,14 @@ public class CharNameTable
return number;
}
public static CharNameTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CharNameTable INSTANCE = new CharNameTable();
}
}

View File

@ -36,8 +36,6 @@ public class CharTemplateTable
{
private static Logger LOGGER = Logger.getLogger(CharTemplateTable.class.getName());
private static CharTemplateTable _instance;
private static final String[] CHAR_CLASSES =
{
"Human Fighter",
@ -163,16 +161,6 @@ public class CharTemplateTable
private final Map<Integer, PlayerTemplate> _templates;
public static CharTemplateTable getInstance()
{
if (_instance == null)
{
_instance = new CharTemplateTable();
}
return _instance;
}
private CharTemplateTable()
{
_templates = new HashMap<>();
@ -269,7 +257,6 @@ public class CharTemplateTable
public static final int getClassIdByName(String className)
{
int currId = 1;
for (String name : CHAR_CLASSES)
{
if (name.equalsIgnoreCase(className))
@ -279,7 +266,16 @@ public class CharTemplateTable
currId++;
}
return currId;
}
public static CharTemplateTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CharTemplateTable INSTANCE = new CharTemplateTable();
}
}

View File

@ -54,62 +54,16 @@ public class ClanTable
{
private static Logger LOGGER = Logger.getLogger(ClanTable.class.getName());
private static ClanTable _instance;
private final Map<Integer, Clan> _clans;
public static ClanTable getInstance()
{
if (_instance == null)
{
_instance = new ClanTable();
}
return _instance;
}
public static void reload()
{
_instance = null;
getInstance();
}
public Clan[] getClans()
{
return _clans.values().toArray(new Clan[_clans.size()]);
}
public int getTopRate(int clan_id)
{
Clan clan = getClan(clan_id);
if (clan.getLevel() < 3)
{
return 0;
}
int i = 1;
for (Clan clans : getClans())
{
if (clan != clans)
{
if (clan.getLevel() < clans.getLevel())
{
i++;
}
else if (clan.getLevel() == clans.getLevel())
{
if (clan.getReputationScore() <= clans.getReputationScore())
{
i++;
}
}
}
}
return i;
}
private final Map<Integer, Clan> _clans = new HashMap<>();
private ClanTable()
{
_clans = new HashMap<>();
load();
}
public void load()
{
_clans.clear();
Clan clan;
try (Connection con = DatabaseFactory.getConnection())
{
@ -154,6 +108,39 @@ public class ClanTable
restoreClanWars();
}
public Clan[] getClans()
{
return _clans.values().toArray(new Clan[_clans.size()]);
}
public int getTopRate(int clan_id)
{
Clan clan = getClan(clan_id);
if (clan.getLevel() < 3)
{
return 0;
}
int i = 1;
for (Clan clans : getClans())
{
if (clan != clans)
{
if (clan.getLevel() < clans.getLevel())
{
i++;
}
else if (clan.getLevel() == clans.getLevel())
{
if (clan.getReputationScore() <= clans.getReputationScore())
{
i++;
}
}
}
}
return i;
}
/**
* @param clanId
* @return
@ -558,4 +545,14 @@ public class ClanTable
e.printStackTrace();
}
}
public static ClanTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final ClanTable INSTANCE = new ClanTable();
}
}

View File

@ -30,16 +30,6 @@ import org.l2jmobius.gameserver.model.ArmorSet;
public class CustomArmorSetsTable
{
private static final Logger LOGGER = Logger.getLogger(CustomArmorSetsTable.class.getName());
private static CustomArmorSetsTable _instance;
public static CustomArmorSetsTable getInstance()
{
if (_instance == null)
{
_instance = new CustomArmorSetsTable();
}
return _instance;
}
public CustomArmorSetsTable()
{
@ -71,4 +61,14 @@ public class CustomArmorSetsTable
LOGGER.warning("ArmorSetsTable: Error reading Custom ArmorSets table " + e);
}
}
public static CustomArmorSetsTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CustomArmorSetsTable INSTANCE = new CustomArmorSetsTable();
}
}

View File

@ -35,28 +35,17 @@ public class HelperBuffTable
{
private static final Logger LOGGER = Logger.getLogger(HennaTable.class.getName());
private static HelperBuffTable _instance;
public List<HelperBuffHolder> helperBuff;
public List<HelperBuffHolder> helperBuff = new ArrayList<>();
private final boolean _initialized = true;
private int _magicClassLowestLevel = 100;
private int _physicClassLowestLevel = 100;
private int _magicClassHighestLevel = 1;
private int _physicClassHighestLevel = 1;
public static HelperBuffTable getInstance()
public void load()
{
if (_instance == null)
{
_instance = new HelperBuffTable();
}
return _instance;
}
public static void reload()
{
_instance = null;
getInstance();
helperBuff.clear();
restoreHelperBuffData();
}
/**
@ -64,8 +53,7 @@ public class HelperBuffTable
*/
private HelperBuffTable()
{
helperBuff = new ArrayList<>();
restoreHelperBuffData();
load();
}
/**
@ -222,4 +210,14 @@ public class HelperBuffTable
{
_physicClassLowestLevel = physicClassLowestLevel;
}
public static HelperBuffTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final HelperBuffTable INSTANCE = new HelperBuffTable();
}
}

View File

@ -34,15 +34,10 @@ import org.l2jmobius.gameserver.model.items.Henna;
public class HennaTreeTable
{
private static Logger LOGGER = Logger.getLogger(HennaTreeTable.class.getName());
private static final HennaTreeTable INSTANCE = new HennaTreeTable();
private final Map<ClassId, List<HennaInstance>> _hennaTrees;
private final boolean _initialized = true;
public static HennaTreeTable getInstance()
{
return INSTANCE;
}
private HennaTreeTable()
{
_hennaTrees = new HashMap<>();
@ -128,4 +123,14 @@ public class HennaTreeTable
{
return _initialized;
}
public static HennaTreeTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final HennaTreeTable INSTANCE = new HennaTreeTable();
}
}

View File

@ -48,23 +48,11 @@ public class LevelUpData
private static final Logger LOGGER = Logger.getLogger(LevelUpData.class.getName());
private static LevelUpData _instance;
private final Map<Integer, LvlupData> lvlTable;
public static LevelUpData getInstance()
{
if (_instance == null)
{
_instance = new LevelUpData();
}
return _instance;
}
private final Map<Integer, LvlupData> _lvlTable;
private LevelUpData()
{
lvlTable = new HashMap<>();
_lvlTable = new HashMap<>();
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement(SELECT_ALL);
@ -86,13 +74,13 @@ public class LevelUpData
lvlDat.setClassMpAdd(rset.getFloat(MP_ADD));
lvlDat.setClassMpModifier(rset.getFloat(MP_MOD));
lvlTable.put(lvlDat.getClassid(), lvlDat);
_lvlTable.put(lvlDat.getClassid(), lvlDat);
}
statement.close();
rset.close();
LOGGER.info("LevelUpData: Loaded " + lvlTable.size() + " Character Level Up Templates.");
LOGGER.info("LevelUpData: Loaded " + _lvlTable.size() + " Character Level Up Templates.");
}
catch (Exception e)
{
@ -106,11 +94,21 @@ public class LevelUpData
*/
public LvlupData getTemplate(int classId)
{
return lvlTable.get(classId);
return _lvlTable.get(classId);
}
public LvlupData getTemplate(ClassId classId)
{
return lvlTable.get(classId.getId());
return _lvlTable.get(classId.getId());
}
public static LevelUpData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final LevelUpData INSTANCE = new LevelUpData();
}
}

View File

@ -46,30 +46,18 @@ public class NpcTable
{
private static final Logger LOGGER = Logger.getLogger(NpcTable.class.getName());
private static NpcTable _instance;
private final Map<Integer, NpcTemplate> npcs;
private final Map<Integer, NpcTemplate> _npcs = new HashMap<>();
private boolean _initialized = false;
public static NpcTable getInstance()
{
if (_instance == null)
{
_instance = new NpcTable();
}
return _instance;
}
private NpcTable()
{
npcs = new HashMap<>();
restoreNpcData();
load();
}
private void restoreNpcData()
private void load()
{
_npcs.clear();
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM npc");
@ -109,7 +97,7 @@ public class NpcTable
while (npcskills.next())
{
final int mobId = npcskills.getInt("npcid");
npcDat = npcs.get(mobId);
npcDat = _npcs.get(mobId);
if (npcDat == null)
{
@ -156,7 +144,7 @@ public class NpcTable
{
final int mobId = dropData.getInt("mobId");
final NpcTemplate npcDat = npcs.get(mobId);
final NpcTemplate npcDat = _npcs.get(mobId);
if (npcDat == null)
{
@ -196,7 +184,7 @@ public class NpcTable
{
final int mobId = dropData.getInt("mobId");
npcDat = npcs.get(mobId);
npcDat = _npcs.get(mobId);
if (npcDat == null)
{
@ -270,7 +258,7 @@ public class NpcTable
{
final int raidId = minionData.getInt("boss_id");
npcDat = npcs.get(raidId);
npcDat = _npcs.get(raidId);
minionDat = new MinionData();
minionDat.setMinionId(minionData.getInt("minion_id"));
minionDat.setAmountMin(minionData.getInt("amount_min"));
@ -535,10 +523,10 @@ public class NpcTable
template.addVulnerability(Stats.BLUNT_WPN_VULN, 1);
template.addVulnerability(Stats.DAGGER_WPN_VULN, 1);
npcs.put(id, template);
_npcs.put(id, template);
}
LOGGER.info("NpcTable: Loaded " + npcs.size() + " Npc Templates.");
LOGGER.info("NpcTable: Loaded " + _npcs.size() + " Npc Templates.");
}
public void reloadNpc(int id)
@ -611,7 +599,7 @@ public class NpcTable
public void reloadAllNpc()
{
restoreNpcData();
load();
}
public void saveNpc(StatsSet npc)
@ -666,17 +654,17 @@ public class NpcTable
public void replaceTemplate(NpcTemplate npc)
{
npcs.put(npc.npcId, npc);
_npcs.put(npc.npcId, npc);
}
public NpcTemplate getTemplate(int id)
{
return npcs.get(id);
return _npcs.get(id);
}
public NpcTemplate getTemplateByName(String name)
{
for (NpcTemplate npcTemplate : npcs.values())
for (NpcTemplate npcTemplate : _npcs.values())
{
if (npcTemplate.name.equalsIgnoreCase(name))
{
@ -691,7 +679,7 @@ public class NpcTable
{
final List<NpcTemplate> list = new ArrayList<>();
for (NpcTemplate t : npcs.values())
for (NpcTemplate t : _npcs.values())
{
if (t.level == lvl)
{
@ -706,7 +694,7 @@ public class NpcTable
{
final List<NpcTemplate> list = new ArrayList<>();
for (NpcTemplate t : npcs.values())
for (NpcTemplate t : _npcs.values())
{
if ((t.level == lvl) && "Monster".equals(t.type))
{
@ -721,7 +709,7 @@ public class NpcTable
{
final List<NpcTemplate> list = new ArrayList<>();
for (NpcTemplate t : npcs.values())
for (NpcTemplate t : _npcs.values())
{
if (t.name.startsWith(letter) && "Npc".equals(t.type))
{
@ -761,6 +749,16 @@ public class NpcTable
public Map<Integer, NpcTemplate> getAllTemplates()
{
return npcs;
return _npcs;
}
public static NpcTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final NpcTable INSTANCE = new NpcTable();
}
}

View File

@ -30,26 +30,18 @@ import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
public class PetDataTable
{
private static final Logger LOGGER = Logger.getLogger(PetInstance.class.getName());
private static PetDataTable _instance;
private static Map<Integer, Map<Integer, PetData>> _petTable;
public static PetDataTable getInstance()
{
if (_instance == null)
{
_instance = new PetDataTable();
}
return _instance;
}
private static Map<Integer, Map<Integer, PetData>> _petTable = new HashMap<>();
private PetDataTable()
{
_petTable = new HashMap<>();
load();
}
public void loadPetsData()
private void load()
{
_petTable.clear();
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT typeID, level, expMax, hpMax, mpMax, patk, pdef, matk, mdef, acc, evasion, crit, speed, atk_speed, cast_speed, feedMax, feedbattle, feednormal, loadMax, hpregen, mpregen, owner_exp_taken FROM pets_stats");
@ -447,4 +439,14 @@ public class PetDataTable
|| (npcId == 12528) // twilight strider
|| (npcId == 12621); // wyvern
}
public static PetDataTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final PetDataTable INSTANCE = new PetDataTable();
}
}

View File

@ -32,18 +32,6 @@ public class PetNameTable
{
private static final Logger LOGGER = Logger.getLogger(PetNameTable.class.getName());
private static PetNameTable _instance;
public static PetNameTable getInstance()
{
if (_instance == null)
{
_instance = new PetNameTable();
}
return _instance;
}
public boolean doesPetNameExist(String name, int petNpcId)
{
boolean result = true;
@ -120,4 +108,14 @@ public class PetNameTable
return result;
}
public static PetNameTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final PetNameTable INSTANCE = new PetNameTable();
}
}

View File

@ -32,20 +32,9 @@ import org.l2jmobius.gameserver.model.Skill;
public class SkillSpellbookTable
{
private static final Logger LOGGER = Logger.getLogger(SkillTreeTable.class.getName());
private static SkillSpellbookTable _instance;
private static Map<Integer, Integer> skillSpellbooks;
public static SkillSpellbookTable getInstance()
{
if (_instance == null)
{
_instance = new SkillSpellbookTable();
}
return _instance;
}
private SkillSpellbookTable()
{
skillSpellbooks = new HashMap<>();
@ -116,4 +105,14 @@ public class SkillSpellbookTable
{
return getBookForSkill(skill.getId(), level);
}
public static SkillSpellbookTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final SkillSpellbookTable INSTANCE = new SkillSpellbookTable();
}
}

View File

@ -44,7 +44,7 @@ import org.l2jmobius.gameserver.skills.holders.PlayerSkillHolder;
public class SkillTreeTable
{
private static final Logger LOGGER = Logger.getLogger(SkillTreeTable.class.getName());
private static SkillTreeTable _instance;
private Map<ClassId, Map<Integer, SkillLearn>> _skillTrees;
private List<SkillLearn> _fishingSkillTrees; // all common skills (teached by Fisherman)
private List<SkillLearn> _expandDwarfCraftSkillTrees; // list of special skill for dwarf (expand dwarf craft) learned by class teacher
@ -256,16 +256,6 @@ public class SkillTreeTable
LOGGER.info("PledgeSkillTreeTable: Loaded " + count5 + " pledge skills.");
}
public static SkillTreeTable getInstance()
{
if (_instance == null)
{
_instance = new SkillTreeTable();
}
return _instance;
}
/**
* Return the minimum level needed to have this Expertise.<BR>
* <BR>
@ -712,4 +702,14 @@ public class SkillTreeTable
}
return holder.getSkills().values();
}
public static SkillTreeTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final SkillTreeTable INSTANCE = new SkillTreeTable();
}
}

View File

@ -39,19 +39,11 @@ public class SpawnTable
{
private static final Logger LOGGER = Logger.getLogger(SpawnTable.class.getName());
private static final SpawnTable INSTANCE = new SpawnTable();
private final Map<Integer, Spawn> spawntable = new ConcurrentHashMap<>();
private int npcSpawnCount;
private int customSpawnCount;
private final Map<Integer, Spawn> _spawntable = new ConcurrentHashMap<>();
private int _npcSpawnCount;
private int _customSpawnCount;
private int _highestId;
public static SpawnTable getInstance()
{
return INSTANCE;
}
private SpawnTable()
{
if (!Config.ALT_DEV_NO_SPAWNS)
@ -62,7 +54,7 @@ public class SpawnTable
public Map<Integer, Spawn> getSpawnTable()
{
return spawntable;
return _spawntable;
}
private void fillSpawnTable()
@ -125,24 +117,24 @@ public class SpawnTable
{
case 0: // default
{
npcSpawnCount += spawnDat.init();
_npcSpawnCount += spawnDat.init();
break;
}
case 1: // Day
{
DayNightSpawnManager.getInstance().addDayCreature(spawnDat);
npcSpawnCount++;
_npcSpawnCount++;
break;
}
case 2: // Night
{
DayNightSpawnManager.getInstance().addNightCreature(spawnDat);
npcSpawnCount++;
_npcSpawnCount++;
break;
}
}
spawntable.put(spawnDat.getId(), spawnDat);
_spawntable.put(spawnDat.getId(), spawnDat);
if (spawnDat.getId() > _highestId)
{
_highestId = spawnDat.getId();
@ -166,8 +158,8 @@ public class SpawnTable
LOGGER.warning("SpawnTable: Spawn could not be initialized. " + e);
}
LOGGER.info("SpawnTable: Loaded " + spawntable.size() + " Npc Spawn Locations. ");
LOGGER.info("SpawnTable: Total number of NPCs in the world: " + npcSpawnCount);
LOGGER.info("SpawnTable: Loaded " + _spawntable.size() + " Npc Spawn Locations. ");
LOGGER.info("SpawnTable: Total number of NPCs in the world: " + _npcSpawnCount);
// -------------------------------Custom Spawnlist----------------------------//
if (Config.CUSTOM_SPAWNLIST_TABLE)
@ -227,24 +219,24 @@ public class SpawnTable
{
case 0: // default
{
customSpawnCount += spawnDat.init();
_customSpawnCount += spawnDat.init();
break;
}
case 1: // Day
{
DayNightSpawnManager.getInstance().addDayCreature(spawnDat);
customSpawnCount++;
_customSpawnCount++;
break;
}
case 2: // Night
{
DayNightSpawnManager.getInstance().addNightCreature(spawnDat);
customSpawnCount++;
_customSpawnCount++;
break;
}
}
spawntable.put(spawnDat.getId(), spawnDat);
_spawntable.put(spawnDat.getId(), spawnDat);
if (spawnDat.getId() > _highestId)
{
_highestId = spawnDat.getId();
@ -264,21 +256,21 @@ public class SpawnTable
LOGGER.warning("CustomSpawnTable: Spawn could not be initialized. " + e);
}
LOGGER.info("CustomSpawnTable: Loaded " + customSpawnCount + " Npc Spawn Locations. ");
LOGGER.info("CustomSpawnTable: Total number of NPCs in the world: " + customSpawnCount);
LOGGER.info("CustomSpawnTable: Loaded " + _customSpawnCount + " Npc Spawn Locations. ");
LOGGER.info("CustomSpawnTable: Total number of NPCs in the world: " + _customSpawnCount);
}
}
public Spawn getTemplate(int id)
{
return spawntable.get(id);
return _spawntable.get(id);
}
public void addNewSpawn(Spawn spawn, boolean storeInDb)
{
_highestId++;
spawn.setId(_highestId);
spawntable.put(_highestId, spawn);
_spawntable.put(_highestId, spawn);
if (storeInDb)
{
@ -306,7 +298,7 @@ public class SpawnTable
public void deleteSpawn(Spawn spawn, boolean updateDb)
{
if (spawntable.remove(spawn.getId()) == null)
if (_spawntable.remove(spawn.getId()) == null)
{
return;
}
@ -361,7 +353,7 @@ public class SpawnTable
public void findNPCInstances(PlayerInstance player, int npcId, int teleportIndex)
{
int index = 0;
for (Spawn spawn : spawntable.values())
for (Spawn spawn : _spawntable.values())
{
if (npcId == spawn.getNpcId())
{
@ -389,6 +381,16 @@ public class SpawnTable
public Map<Integer, Spawn> getAllTemplates()
{
return spawntable;
return _spawntable;
}
public static SpawnTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final SpawnTable INSTANCE = new SpawnTable();
}
}

View File

@ -34,28 +34,16 @@ public class TeleportLocationTable
{
private static final Logger LOGGER = Logger.getLogger(TeleportLocationTable.class.getName());
private static TeleportLocationTable _instance;
private Map<Integer, TeleportLocation> teleports;
public static TeleportLocationTable getInstance()
{
if (_instance == null)
{
_instance = new TeleportLocationTable();
}
return _instance;
}
private final Map<Integer, TeleportLocation> _teleports = new HashMap<>();
private TeleportLocationTable()
{
reloadAll();
load();
}
public void reloadAll()
public void load()
{
teleports = new HashMap<>();
_teleports.clear();
try (Connection con = DatabaseFactory.getConnection())
{
@ -74,13 +62,13 @@ public class TeleportLocationTable
teleport.setPrice(rset.getInt("price"));
teleport.setIsForNoble(rset.getInt("fornoble") == 1);
teleports.put(teleport.getTeleId(), teleport);
_teleports.put(teleport.getTeleId(), teleport);
}
statement.close();
rset.close();
LOGGER.info("TeleportLocationTable: Loaded " + teleports.size() + " Teleport Location Templates");
LOGGER.info("TeleportLocationTable: Loaded " + _teleports.size() + " Teleport Location Templates");
}
catch (Exception e)
{
@ -95,7 +83,7 @@ public class TeleportLocationTable
final ResultSet rset = statement.executeQuery();
TeleportLocation teleport;
int _cTeleCount = teleports.size();
int _cTeleCount = _teleports.size();
while (rset.next())
{
@ -106,13 +94,13 @@ public class TeleportLocationTable
teleport.setZ(rset.getInt("loc_z"));
teleport.setPrice(rset.getInt("price"));
teleport.setIsForNoble(rset.getInt("fornoble") == 1);
teleports.put(teleport.getTeleId(), teleport);
_teleports.put(teleport.getTeleId(), teleport);
}
statement.close();
rset.close();
_cTeleCount = teleports.size() - _cTeleCount;
_cTeleCount = _teleports.size() - _cTeleCount;
if (_cTeleCount > 0)
{
@ -126,12 +114,18 @@ public class TeleportLocationTable
}
}
/**
* @param id
* @return
*/
public TeleportLocation getTemplate(int id)
{
return teleports.get(id);
return _teleports.get(id);
}
public static TeleportLocationTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final TeleportLocationTable INSTANCE = new TeleportLocationTable();
}
}

View File

@ -32,11 +32,6 @@ public class TerritoryTable
private static final Logger LOGGER = Logger.getLogger(TradeController.class.getName());
private static Map<Integer, Territory> _territory = new HashMap<>();
public static TerritoryTable getInstance()
{
return SingletonHolder.INSTANCE;
}
public TerritoryTable()
{
_territory.clear();
@ -84,6 +79,11 @@ public class TerritoryTable
LOGGER.info("TerritoryTable: Loaded " + _territory.size() + " locations.");
}
public static TerritoryTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final TerritoryTable INSTANCE = new TerritoryTable();

View File

@ -38,48 +38,38 @@ import org.l2jmobius.gameserver.model.actor.instance.ItemInstance;
public class TradeListTable
{
private static final Logger LOGGER = Logger.getLogger(TradeListTable.class.getName());
private static TradeListTable _instance;
private int _nextListId;
private final Map<Integer, StoreTradeList> _lists;
private final Map<Integer, StoreTradeList> _lists = new HashMap<>();
/** Task launching the function for restore count of Item (Clan Hall) */
private class RestoreCount implements Runnable
{
private final int timer;
private final int _timer;
public RestoreCount(int time)
{
timer = time;
_timer = time;
}
@Override
public void run()
{
restoreCount(timer);
dataTimerSave(timer);
ThreadPool.schedule(new RestoreCount(timer), timer * 60 * 60 * 1000);
restoreCount(_timer);
dataTimerSave(_timer);
ThreadPool.schedule(new RestoreCount(_timer), _timer * 60 * 60 * 1000);
}
}
public static TradeListTable getInstance()
{
if (_instance == null)
{
_instance = new TradeListTable();
}
return _instance;
}
private TradeListTable()
{
_lists = new HashMap<>();
load();
}
private void load(boolean custom)
{
_lists.clear();
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement1 = con.prepareStatement("SELECT shop_id,npc_id FROM " + (custom ? "custom_merchant_shopids" : "merchant_shopids"));
@ -318,4 +308,14 @@ public class TradeListTable
LOGGER.warning("TradeController: Could not store Count Item. " + e);
}
}
public static TradeListTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final TradeListTable INSTANCE = new TradeListTable();
}
}

View File

@ -46,18 +46,6 @@ public class AugmentationData
{
private static final Logger LOGGER = Logger.getLogger(AugmentationData.class.getName());
private static AugmentationData _instance;
public static final AugmentationData getInstance()
{
if (_instance == null)
{
_instance = new AugmentationData();
}
return _instance;
}
// stats
private static final int STAT_START = 1;
private static final int STAT_END = 14560;
@ -74,13 +62,18 @@ public class AugmentationData
private static final int BASESTAT_INT = 16343;
private static final int BASESTAT_MEN = 16344;
private final List<augmentationStat> _augmentationStats[];
private final Map<Integer, ArrayList<augmentationSkill>> _blueSkills;
private final Map<Integer, ArrayList<augmentationSkill>> _purpleSkills;
private final Map<Integer, ArrayList<augmentationSkill>> _redSkills;
private static List<augmentationStat> _augmentationStats[] = null;
private static Map<Integer, ArrayList<augmentationSkill>> _blueSkills = null;
private static Map<Integer, ArrayList<augmentationSkill>> _purpleSkills = null;
private static Map<Integer, ArrayList<augmentationSkill>> _redSkills = null;
private AugmentationData()
{
load();
}
@SuppressWarnings("unchecked")
private AugmentationData()
public void load()
{
LOGGER.info("Initializing AugmentationData.");
@ -100,102 +93,6 @@ public class AugmentationData
_redSkills.put(i, new ArrayList<augmentationSkill>());
}
load();
// Use size*4: since theres 4 blocks of stat-data with equivalent size
LOGGER.info("AugmentationData: Loaded " + (_augmentationStats[0].size() * 4) + " augmentation stats.");
}
public static void reload()
{
_instance = null;
getInstance();
}
public class augmentationSkill
{
private final int _skillId;
private final int _maxSkillLevel;
private final int _augmentationSkillId;
public augmentationSkill(int skillId, int maxSkillLevel, int augmentationSkillId)
{
_skillId = skillId;
_maxSkillLevel = maxSkillLevel;
_augmentationSkillId = augmentationSkillId;
}
public Skill getSkill(int level)
{
if (level > _maxSkillLevel)
{
return SkillTable.getInstance().getInfo(_skillId, _maxSkillLevel);
}
return SkillTable.getInstance().getInfo(_skillId, level);
}
public int getAugmentationSkillId()
{
return _augmentationSkillId;
}
}
public class augmentationStat
{
private final Stats _stat;
private final int _singleSize;
private final int _combinedSize;
private final float _singleValues[];
private final float _combinedValues[];
public augmentationStat(Stats stat, float sValues[], float cValues[])
{
_stat = stat;
_singleSize = sValues.length;
_singleValues = sValues;
_combinedSize = cValues.length;
_combinedValues = cValues;
}
public int getSingleStatSize()
{
return _singleSize;
}
public int getCombinedStatSize()
{
return _combinedSize;
}
public float getSingleStatValue(int i)
{
if ((i >= _singleSize) || (i < 0))
{
return _singleValues[_singleSize - 1];
}
return _singleValues[i];
}
public float getCombinedStatValue(int i)
{
if ((i >= _combinedSize) || (i < 0))
{
return _combinedValues[_combinedSize - 1];
}
return _combinedValues[i];
}
public Stats getStat()
{
return _stat;
}
}
private final void load()
{
// Load the skillmap
// Note: the skillmap data is only used when generating new augmentations the client expects a different id in order to display the skill in the items description.
try
@ -375,6 +272,9 @@ public class AugmentationData
return;
}
}
// Use size*4: since theres 4 blocks of stat-data with equivalent size
LOGGER.info("AugmentationData: Loaded " + (_augmentationStats[0].size() * 4) + " augmentation stats.");
}
/**
@ -687,4 +587,96 @@ public class AugmentationData
return temp;
}
public class augmentationSkill
{
private final int _skillId;
private final int _maxSkillLevel;
private final int _augmentationSkillId;
public augmentationSkill(int skillId, int maxSkillLevel, int augmentationSkillId)
{
_skillId = skillId;
_maxSkillLevel = maxSkillLevel;
_augmentationSkillId = augmentationSkillId;
}
public Skill getSkill(int level)
{
if (level > _maxSkillLevel)
{
return SkillTable.getInstance().getInfo(_skillId, _maxSkillLevel);
}
return SkillTable.getInstance().getInfo(_skillId, level);
}
public int getAugmentationSkillId()
{
return _augmentationSkillId;
}
}
public class augmentationStat
{
private final Stats _stat;
private final int _singleSize;
private final int _combinedSize;
private final float _singleValues[];
private final float _combinedValues[];
public augmentationStat(Stats stat, float sValues[], float cValues[])
{
_stat = stat;
_singleSize = sValues.length;
_singleValues = sValues;
_combinedSize = cValues.length;
_combinedValues = cValues;
}
public int getSingleStatSize()
{
return _singleSize;
}
public int getCombinedStatSize()
{
return _combinedSize;
}
public float getSingleStatValue(int i)
{
if ((i >= _singleSize) || (i < 0))
{
return _singleValues[_singleSize - 1];
}
return _singleValues[i];
}
public float getCombinedStatValue(int i)
{
if ((i >= _combinedSize) || (i < 0))
{
return _combinedValues[_combinedSize - 1];
}
return _combinedValues[i];
}
public Stats getStat()
{
return _stat;
}
}
public static AugmentationData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final AugmentationData INSTANCE = new AugmentationData();
}
}

View File

@ -44,10 +44,10 @@ public class ExperienceData
private ExperienceData()
{
loadData();
load();
}
private void loadData()
public void load()
{
final File xml = new File(Config.DATAPACK_ROOT, "data/stats/experience.xml");
if (!xml.exists())

View File

@ -70,15 +70,6 @@ public class ItemTable
_crystalTypes.put("none", Item.CRYSTAL_NONE);
}
/**
* Returns instance of ItemTable
* @return ItemTable
*/
public static ItemTable getInstance()
{
return SingletonHolder.INSTANCE;
}
/**
* Returns a new object Item
* @return
@ -365,6 +356,15 @@ public class ItemTable
return _allTemplates.length;
}
/**
* Returns instance of ItemTable
* @return ItemTable
*/
public static ItemTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final ItemTable INSTANCE = new ItemTable();

View File

@ -68,42 +68,19 @@ import org.l2jmobius.gameserver.model.zone.type.TownZone;
import org.l2jmobius.gameserver.model.zone.type.WaterZone;
/**
* This class manages the augmentation data and can also create new augmentations.
* @author durgus
*/
public class ZoneData
{
private static final Logger LOGGER = Logger.getLogger(ZoneData.class.getName());
private static ZoneData _instance;
public static final ZoneData getInstance()
{
if (_instance == null)
{
_instance = new ZoneData();
}
return _instance;
}
public ZoneData()
{
LOGGER.info("Loading zones...");
load();
}
public void reload()
{
synchronized (_instance)
{
_instance = null;
_instance = new ZoneData();
}
}
private final void load()
public void load()
{
int zoneCount = 0;
@ -559,4 +536,14 @@ public class ZoneData
LOGGER.info("Done: loaded " + zoneCount + " zones.");
}
public static ZoneData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final ZoneData INSTANCE = new ZoneData();
}
}

View File

@ -97,19 +97,8 @@ public class AdminCommandHandler
{
protected static final Logger LOGGER = Logger.getLogger(AdminCommandHandler.class.getName());
private static AdminCommandHandler _instance;
private final Map<String, IAdminCommandHandler> _datatable;
public static AdminCommandHandler getInstance()
{
if (_instance == null)
{
_instance = new AdminCommandHandler();
}
return _instance;
}
private AdminCommandHandler()
{
_datatable = new HashMap<>();
@ -213,4 +202,14 @@ public class AdminCommandHandler
return _datatable.get(command);
}
public static AdminCommandHandler getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final AdminCommandHandler INSTANCE = new AdminCommandHandler();
}
}

View File

@ -38,7 +38,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
public class AutoAnnouncementHandler
{
protected static final Logger LOGGER = Logger.getLogger(AutoAnnouncementHandler.class.getName());
private static AutoAnnouncementHandler _instance;
private static final long DEFAULT_ANNOUNCEMENT_DELAY = 180000; // 3 mins by default
protected Map<Integer, AutoAnnouncementInstance> _registeredAnnouncements;
@ -117,19 +117,6 @@ public class AutoAnnouncementHandler
player.sendPacket(adminReply);
}
/**
* @return
*/
public static AutoAnnouncementHandler getInstance()
{
if (_instance == null)
{
_instance = new AutoAnnouncementHandler();
}
return _instance;
}
/**
* @return
*/
@ -467,4 +454,14 @@ public class AutoAnnouncementHandler
}
}
}
public static AutoAnnouncementHandler getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final AutoAnnouncementHandler INSTANCE = new AutoAnnouncementHandler();
}
}

View File

@ -46,10 +46,8 @@ import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
public class AutoChatHandler implements SpawnListener
{
protected static final Logger LOGGER = Logger.getLogger(AutoChatHandler.class.getName());
private static AutoChatHandler _instance;
private static final long DEFAULT_CHAT_DELAY = 30000; // 30 secs by default
protected Map<Integer, AutoChatInstance> _registeredChats;
protected AutoChatHandler()
@ -100,16 +98,6 @@ public class AutoChatHandler implements SpawnListener
}
}
public static AutoChatHandler getInstance()
{
if (_instance == null)
{
_instance = new AutoChatHandler();
}
return _instance;
}
public int size()
{
return _registeredChats.size();
@ -825,4 +813,14 @@ public class AutoChatHandler implements SpawnListener
}
}
}
public static AutoChatHandler getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final AutoChatHandler INSTANCE = new AutoChatHandler();
}
}

View File

@ -68,24 +68,8 @@ public class ItemHandler
{
private static final Logger LOGGER = Logger.getLogger(GameServer.class.getName());
private static ItemHandler _instance;
private final Map<Integer, IItemHandler> _datatable;
/**
* Create ItemHandler if doesn't exist and returns ItemHandler
* @return ItemHandler
*/
public static ItemHandler getInstance()
{
if (_instance == null)
{
_instance = new ItemHandler();
}
return _instance;
}
/**
* Returns the number of elements contained in datatable
* @return int : Size of the datatable
@ -174,4 +158,14 @@ public class ItemHandler
{
return _datatable.get(itemId);
}
public static ItemHandler getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final ItemHandler INSTANCE = new ItemHandler();
}
}

View File

@ -61,20 +61,8 @@ public class SkillHandler
{
private static final Logger LOGGER = Logger.getLogger(GameServer.class.getName());
private static SkillHandler _instance;
private final Map<SkillType, ISkillHandler> _datatable;
public static SkillHandler getInstance()
{
if (_instance == null)
{
_instance = new SkillHandler();
}
return _instance;
}
private SkillHandler()
{
_datatable = new TreeMap<>();
@ -134,4 +122,14 @@ public class SkillHandler
{
return _datatable.size();
}
public static SkillHandler getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final SkillHandler INSTANCE = new SkillHandler();
}
}

View File

@ -41,20 +41,8 @@ public class UserCommandHandler
{
private static final Logger LOGGER = Logger.getLogger(GameServer.class.getName());
private static UserCommandHandler _instance;
private final Map<Integer, IUserCommandHandler> _datatable;
public static UserCommandHandler getInstance()
{
if (_instance == null)
{
_instance = new UserCommandHandler();
}
return _instance;
}
private UserCommandHandler()
{
_datatable = new HashMap<>();
@ -95,4 +83,14 @@ public class UserCommandHandler
{
return _datatable.size();
}
public static UserCommandHandler getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final UserCommandHandler INSTANCE = new UserCommandHandler();
}
}

View File

@ -38,20 +38,8 @@ public class VoicedCommandHandler
{
private static Logger LOGGER = Logger.getLogger(GameServer.class.getName());
private static VoicedCommandHandler _instance;
private final Map<String, IVoicedCommandHandler> _datatable;
public static VoicedCommandHandler getInstance()
{
if (_instance == null)
{
_instance = new VoicedCommandHandler();
}
return _instance;
}
private VoicedCommandHandler()
{
_datatable = new HashMap<>();
@ -131,4 +119,14 @@ public class VoicedCommandHandler
{
return _datatable.size();
}
public static VoicedCommandHandler getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final VoicedCommandHandler INSTANCE = new VoicedCommandHandler();
}
}

View File

@ -72,7 +72,7 @@ public class AdminReload implements IAdminCommandHandler
}
else if (type.startsWith("teleport"))
{
TeleportLocationTable.getInstance().reloadAll();
TeleportLocationTable.getInstance().load();
sendReloadPage(activeChar);
BuilderUtil.sendSysMessage(activeChar, "Teleport location table reloaded.");
}
@ -133,7 +133,7 @@ public class AdminReload implements IAdminCommandHandler
}
else if (type.equals("tradelist"))
{
TradeController.reload();
TradeController.getInstance();
sendReloadPage(activeChar);
BuilderUtil.sendSysMessage(activeChar, "TradeList Table reloaded.");
}

View File

@ -203,7 +203,7 @@ public class AdminSpawn implements IAdminCommandHandler
}
else if (command.startsWith("admin_teleport_reload"))
{
TeleportLocationTable.getInstance().reloadAll();
TeleportLocationTable.getInstance().load();
AdminData.broadcastMessageToGMs("Teleport List Table reloaded.");
}
else if (command.startsWith("admin_topspawncount") || command.startsWith("admin_top_spawn_count"))

View File

@ -37,34 +37,18 @@ public class CustomBypassHandler
{
private static Logger LOGGER = Logger.getLogger(BitSetIDFactory.class.getName());
private static CustomBypassHandler _instance = null;
private final Map<String, ICustomByPassHandler> _handlers;
private CustomBypassHandler()
{
_handlers = new HashMap<>();
registerCustomBypassHandler(new ExtractableByPassHandler());
}
/**
* Receives the non-static instance of the RebirthManager.
* @return
*/
public static CustomBypassHandler getInstance()
{
if (_instance == null)
{
_instance = new CustomBypassHandler();
}
return _instance;
}
/**
* @param handler as ICustomByPassHandler
*/
public void registerCustomBypassHandler(ICustomByPassHandler handler)
private void registerCustomBypassHandler(ICustomByPassHandler handler)
{
for (String s : handler.getByPassCommands())
{
@ -110,4 +94,14 @@ public class CustomBypassHandler
Rebirth.getInstance().handleCommand(player, command);
}
}
public static CustomBypassHandler getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CustomBypassHandler INSTANCE = new CustomBypassHandler();
}
}

View File

@ -26,27 +26,11 @@ import org.l2jmobius.gameserver.model.entity.Rebirth;
*/
public class CustomWorldHandler
{
private static CustomWorldHandler _instance = null;
private CustomWorldHandler()
{
// Do Nothing ^_-
}
/**
* Receives the non-static instance of the RebirthManager.
* @return
*/
public static CustomWorldHandler getInstance()
{
if (_instance == null)
{
_instance = new CustomWorldHandler();
}
return _instance;
}
/**
* Requests entry into the world - manages appropriately.
* @param player
@ -68,4 +52,14 @@ public class CustomWorldHandler
{
// TODO: Remove the rebirth engine's bonus skills from player?
}
public static CustomWorldHandler getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CustomWorldHandler INSTANCE = new CustomWorldHandler();
}
}

View File

@ -18,29 +18,15 @@ package org.l2jmobius.gameserver.instancemanager;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.zone.type.ArenaZone;
public class ArenaManager
{
private static ArenaManager _instance;
private static final Logger LOGGER = Logger.getLogger(ArenaManager.class.getName());
public static final ArenaManager getInstance()
{
if (_instance == null)
{
LOGGER.info("Initializing ArenaManager");
_instance = new ArenaManager();
}
return _instance;
}
private List<ArenaZone> _arenas;
public ArenaManager()
private ArenaManager()
{
}
@ -85,4 +71,14 @@ public class ArenaManager
return null;
}
public static ArenaManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final ArenaManager INSTANCE = new ArenaManager();
}
}

View File

@ -29,7 +29,6 @@ import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/**
* <b>AutoSave</b> only
* @author Shyla
*/
public class AutoSaveManager

View File

@ -34,17 +34,12 @@ import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
public class AwayManager
{
protected static final Logger LOGGER = Logger.getLogger(AwayManager.class.getName());
private static AwayManager _instance;
protected Map<PlayerInstance, RestoreData> _awayPlayers;
public static final AwayManager getInstance()
private AwayManager()
{
if (_instance == null)
{
_instance = new AwayManager();
LOGGER.info("AwayManager: initialized.");
}
return _instance;
_awayPlayers = Collections.synchronizedMap(new WeakHashMap<PlayerInstance, RestoreData>());
}
private final class RestoreData
@ -72,11 +67,6 @@ public class AwayManager
}
}
private AwayManager()
{
_awayPlayers = Collections.synchronizedMap(new WeakHashMap<PlayerInstance, RestoreData>());
}
public void setAway(PlayerInstance player, String text)
{
player.set_awaying(true);
@ -212,4 +202,14 @@ public class AwayManager
_player.sendMessage("You are Back now!");
}
}
public static AwayManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final AwayManager INSTANCE = new AwayManager();
}
}

View File

@ -46,8 +46,6 @@ public class CastleManorManager
{
protected static Logger LOGGER = Logger.getLogger(CastleManorManager.class.getName());
private static CastleManorManager _instance;
public static final int PERIOD_CURRENT = 0;
public static final int PERIOD_NEXT = 1;
public static int APPROVE = -1;
@ -64,16 +62,6 @@ public class CastleManorManager
boolean _underMaintenance;
boolean _disabled;
public static CastleManorManager getInstance()
{
if (_instance == null)
{
LOGGER.info("Initializing CastleManorManager");
_instance = new CastleManorManager();
}
return _instance;
}
public class CropProcure
{
int _cropId;
@ -555,4 +543,14 @@ public class CastleManorManager
}
}
}
public static CastleManorManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CastleManorManager INSTANCE = new CastleManorManager();
}
}

View File

@ -37,31 +37,27 @@ public class ClanHallManager
{
private static final Logger LOGGER = Logger.getLogger(ClanHallManager.class.getName());
private final Map<String, List<ClanHall>> _allClanHalls;
private final Map<Integer, ClanHall> _clanHall;
private final Map<Integer, ClanHall> _freeClanHall;
private final Map<String, List<ClanHall>> _allClanHalls = new HashMap<>();
private final Map<Integer, ClanHall> _clanHall = new HashMap<>();
private final Map<Integer, ClanHall> _freeClanHall = new HashMap<>();
private boolean _loaded = false;
public static ClanHallManager getInstance()
{
return SingletonHolder.INSTANCE;
}
public boolean loaded()
{
return _loaded;
}
protected ClanHallManager()
private ClanHallManager()
{
_allClanHalls = new HashMap<>();
_clanHall = new HashMap<>();
_freeClanHall = new HashMap<>();
load();
}
private final void load()
private void load()
{
_allClanHalls.clear();
_clanHall.clear();
_freeClanHall.clear();
LOGGER.info("Initializing ClanHallManager");
try (Connection con = DatabaseFactory.getConnection())
{
@ -254,6 +250,11 @@ public class ClanHallManager
return null;
}
public static ClanHallManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final ClanHallManager INSTANCE = new ClanHallManager();

View File

@ -31,20 +31,9 @@ import org.l2jmobius.gameserver.model.entity.siege.Castle;
public class CrownManager
{
protected static final Logger LOGGER = Logger.getLogger(CrownManager.class.getName());
private static CrownManager _instance;
public static final CrownManager getInstance()
{
if (_instance == null)
{
_instance = new CrownManager();
}
return _instance;
}
public CrownManager()
{
LOGGER.info("CrownManager: initialized");
}
public void checkCrowns(Clan clan)
@ -147,4 +136,14 @@ public class CrownManager
}
}
}
public static CrownManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CrownManager INSTANCE = new CrownManager();
}
}

View File

@ -34,7 +34,7 @@ import org.l2jmobius.commons.util.Rnd;
public class CustomNpcInstanceManager
{
private static final Logger LOGGER = Logger.getLogger(CustomNpcInstanceManager.class.getName());
private static CustomNpcInstanceManager _instance;
private Map<Integer, customInfo> spawns; // <Object id , info>
private Map<Integer, customInfo> templates; // <Npc Template Id , info>
@ -57,19 +57,6 @@ public class CustomNpcInstanceManager
load();
}
/**
* Initiates the manager (if not initiated yet) and/or returns <b>this</b> manager instance
* @return CustomNpcInstanceManager _instance
*/
public static final CustomNpcInstanceManager getInstance()
{
if (_instance == null)
{
_instance = new CustomNpcInstanceManager();
}
return _instance;
}
/**
* Flush the old data, and load new data
*/
@ -306,4 +293,14 @@ public class CustomNpcInstanceManager
LOGGER.warning("Could not add Npc Morph info into the DB: ");
}
}
public static CustomNpcInstanceManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CustomNpcInstanceManager INSTANCE = new CustomNpcInstanceManager();
}
}

View File

@ -27,9 +27,9 @@ public class DatatablesManager
public static void reloadAll()
{
AdminData.getInstance().load();
AugmentationData.reload();
ClanTable.reload();
HelperBuffTable.reload();
ExperienceData.getInstance();
AugmentationData.getInstance().load();
ClanTable.getInstance().load();
HelperBuffTable.getInstance().load();
ExperienceData.getInstance().load();
}
}

View File

@ -42,24 +42,12 @@ public class DayNightSpawnManager
{
private static Logger LOGGER = Logger.getLogger(DayNightSpawnManager.class.getName());
private static DayNightSpawnManager _instance;
private final List<Spawn> _dayCreatures = new ArrayList<>();
private final List<Spawn> _nightCreatures = new ArrayList<>();
private final Map<Spawn, RaidBossInstance> _bosses = new ConcurrentHashMap<>();
public static DayNightSpawnManager getInstance()
{
if (_instance == null)
{
_instance = new DayNightSpawnManager();
}
return _instance;
}
private DayNightSpawnManager()
{
LOGGER.info("DayNightSpawnManager: Day/Night handler initialised");
}
public void addDayCreature(Spawn spawnDat)
@ -300,4 +288,14 @@ public class DayNightSpawnManager
}
return null;
}
public static DayNightSpawnManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final DayNightSpawnManager INSTANCE = new DayNightSpawnManager();
}
}

View File

@ -55,21 +55,11 @@ import org.l2jmobius.gameserver.util.Util;
public class DimensionalRiftManager
{
protected static final Logger LOGGER = Logger.getLogger(DimensionalRiftManager.class.getName());
private static DimensionalRiftManager _instance;
private final Map<Byte, Map<Byte, DimensionalRiftRoom>> _rooms = new HashMap<>();
private final short DIMENSIONAL_FRAGMENT_ITEM_ID = 7079;
private static final int MAX_PARTY_PER_AREA = 3;
public static DimensionalRiftManager getInstance()
{
if (_instance == null)
{
_instance = new DimensionalRiftManager();
}
return _instance;
}
private DimensionalRiftManager()
{
loadRooms();
@ -601,4 +591,14 @@ public class DimensionalRiftManager
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " tried to cheat in dimensional rift.", Config.DEFAULT_PUNISH);
}
}
public static DimensionalRiftManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final DimensionalRiftManager INSTANCE = new DimensionalRiftManager();
}
}

View File

@ -29,17 +29,6 @@ public class DuelManager
{
private static final Logger LOGGER = Logger.getLogger(DuelManager.class.getName());
private static DuelManager _instance;
public static final DuelManager getInstance()
{
if (_instance == null)
{
_instance = new DuelManager();
}
return _instance;
}
private final List<Duel> _duels;
private int _currentDuelId = 0x90;
@ -238,4 +227,14 @@ public class DuelManager
}
}
}
public static DuelManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final DuelManager INSTANCE = new DuelManager();
}
}

View File

@ -18,30 +18,16 @@ package org.l2jmobius.gameserver.instancemanager;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.l2jmobius.gameserver.model.zone.type.FishingZone;
import org.l2jmobius.gameserver.model.zone.type.WaterZone;
public class FishingZoneManager
{
private static FishingZoneManager _instance;
private static final Logger LOGGER = Logger.getLogger(FishingZoneManager.class.getName());
public static final FishingZoneManager getInstance()
{
if (_instance == null)
{
LOGGER.info("Initializing FishingZoneManager");
_instance = new FishingZoneManager();
}
return _instance;
}
private List<FishingZone> _fishingZones;
private List<WaterZone> _waterZones;
public FishingZoneManager()
private FishingZoneManager()
{
}
@ -92,4 +78,14 @@ public class FishingZoneManager
}
return null;
}
public static FishingZoneManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final FishingZoneManager INSTANCE = new FishingZoneManager();
}
}

View File

@ -55,7 +55,7 @@ import org.l2jmobius.gameserver.util.Util;
*/
public class FourSepulchersManager extends GrandBossManager
{
private static final String QUEST_ID = "620_FourGoblets";
private static final String QUEST_ID = "Q620_FourGoblets";
private static final int ENTRANCE_PASS = 7075;
private static final int USED_PASS = 7261;
@ -1544,7 +1544,7 @@ public class FourSepulchersManager extends GrandBossManager
}
else
{
LOGGER.warning("Ahenbek ashelbek! Shaitanama!! " + doorId);
LOGGER.warning("Could not find door with id " + doorId);
}
}
catch (Exception e)

View File

@ -63,26 +63,11 @@ public class GrandBossManager
private static final String UPDATE_GRAND_BOSS_DATA = "UPDATE grandboss_data set loc_x = ?, loc_y = ?, loc_z = ?, heading = ?, respawn_time = ?, currentHP = ?, currentMP = ?, status = ? where boss_id = ?";
private static final String UPDATE_GRAND_BOSS_DATA2 = "UPDATE grandboss_data set status = ? where boss_id = ?";
private static GrandBossManager _instance;
protected static Map<Integer, GrandBossInstance> _bosses;
protected static Map<Integer, StatsSet> _storedInfo;
private Map<Integer, Integer> _bossStatus;
private Collection<BossZone> _zones;
public static GrandBossManager getInstance()
{
if (_instance == null)
{
LOGGER.info("Initializing GrandBossManager");
_instance = new GrandBossManager();
}
return _instance;
}
public GrandBossManager()
{
init();
@ -472,4 +457,14 @@ public class GrandBossManager
{
return _bossStatus.get(bossId) != null;
}
public static GrandBossManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final GrandBossManager INSTANCE = new GrandBossManager();
}
}

View File

@ -27,7 +27,6 @@ public class Manager
if (!Config.ALT_DEV_NO_QUESTS)
{
QuestManager.getInstance();
QuestManager.reload();
}
}
}

View File

@ -25,19 +25,7 @@ import org.l2jmobius.gameserver.model.zone.type.OlympiadStadiumZone;
public class OlympiadStadiaManager
{
protected static Logger LOGGER = Logger.getLogger(OlympiadStadiaManager.class.getName());
private static OlympiadStadiaManager _instance;
public static final OlympiadStadiaManager getInstance()
{
if (_instance == null)
{
LOGGER.info("Initializing OlympiadStadiaManager");
_instance = new OlympiadStadiaManager();
}
return _instance;
}
protected static final Logger LOGGER = Logger.getLogger(OlympiadStadiaManager.class.getName());
private List<OlympiadStadiumZone> _olympiadStadias;
@ -83,4 +71,14 @@ public class OlympiadStadiaManager
return null;
}
public static OlympiadStadiaManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final OlympiadStadiaManager INSTANCE = new OlympiadStadiaManager();
}
}

View File

@ -42,7 +42,6 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class PetitionManager
{
protected static final Logger LOGGER = Logger.getLogger(PetitionManager.class.getName());
private static PetitionManager _instance;
final Map<Integer, Petition> _pendingPetitions;
final Map<Integer, Petition> _completedPetitions;
@ -73,17 +72,6 @@ public class PetitionManager
Other
}
public static PetitionManager getInstance()
{
if (_instance == null)
{
LOGGER.info("Initializing PetitionManager");
_instance = new PetitionManager();
}
return _instance;
}
private class Petition
{
private final long _submitTime = System.currentTimeMillis();
@ -627,4 +615,14 @@ public class PetitionManager
htmlMsg.setHtml(htmlContent.toString());
player.sendPacket(htmlMsg);
}
public static PetitionManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final PetitionManager INSTANCE = new PetitionManager();
}
}

View File

@ -25,23 +25,12 @@ import org.l2jmobius.gameserver.model.quest.Quest;
public class QuestManager
{
protected static final Logger LOGGER = Logger.getLogger(QuestManager.class.getName());
private Map<String, Quest> _quests = new HashMap<>();
private static QuestManager _instance;
private int _questCount;
public static QuestManager getInstance()
{
if (_instance == null)
{
_instance = new QuestManager();
}
return _instance;
}
private static Map<String, Quest> _quests = new HashMap<>();
private static int _questCount = 0;
public QuestManager()
private QuestManager()
{
LOGGER.info("Initializing QuestManager.");
_questCount = 0;
}
public boolean reload(String questFolder)
@ -142,14 +131,6 @@ public class QuestManager
return _quests;
}
/**
* This will reload quests
*/
public static void reload()
{
_instance = new QuestManager();
}
public Iterable<Quest> getAllManagedScripts()
{
return _quests.values();
@ -184,4 +165,14 @@ public class QuestManager
}
getInstance().report();
}
public static QuestManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final QuestManager INSTANCE = new QuestManager();
}
}

View File

@ -18,7 +18,6 @@ package org.l2jmobius.gameserver.instancemanager;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.l2jmobius.gameserver.datatables.csv.MapRegionTable;
import org.l2jmobius.gameserver.model.WorldObject;
@ -27,23 +26,9 @@ import org.l2jmobius.gameserver.model.zone.type.TownZone;
public class TownManager
{
private static final Logger LOGGER = Logger.getLogger(TownManager.class.getName());
private static TownManager _instance;
public static final TownManager getInstance()
{
if (_instance == null)
{
LOGGER.info("Initializing TownManager");
_instance = new TownManager();
}
return _instance;
}
private List<TownZone> _towns;
public TownManager()
private TownManager()
{
}
@ -325,4 +310,14 @@ public class TownManager
return null;
}
public static TownManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final TownManager INSTANCE = new TownManager();
}
}

View File

@ -39,30 +39,18 @@ import org.l2jmobius.gameserver.model.items.Item;
public class Manor
{
private static Logger LOGGER = Logger.getLogger(Manor.class.getName());
private static Manor _instance;
private static Map<Integer, SeedData> _seeds;
private static Map<Integer, SeedData> _seeds = new ConcurrentHashMap<>();
public Manor()
{
_seeds = new ConcurrentHashMap<>();
_seeds.clear();
parseData();
}
public static Manor getInstance()
{
if (_instance == null)
{
_instance = new Manor();
}
return _instance;
}
public List<Integer> getAllCrops()
{
final List<Integer> crops = new ArrayList<>();
for (SeedData seed : _seeds.values())
{
if (!crops.contains(seed.getCrop()) && (seed.getCrop() != 0) && !crops.contains(seed.getCrop()))
@ -70,7 +58,6 @@ public class Manor
crops.add(seed.getCrop());
}
}
return crops;
}
@ -94,14 +81,12 @@ public class Manor
return getSeedBasicPrice(seed.getId());
}
}
return 0;
}
public int getCropBasicPrice(int cropId)
{
final Item cropItem = ItemTable.getInstance().getTemplate(cropId);
if (cropItem != null)
{
return cropItem.getReferencePrice();
@ -129,14 +114,12 @@ public class Manor
public int getSeedBuyPrice(int seedId)
{
final int buyPrice = getSeedBasicPrice(seedId) / 10;
return buyPrice > 0 ? buyPrice : 1;
}
public int getSeedMinLevel(int seedId)
{
final SeedData seed = _seeds.get(seedId);
if (seed != null)
{
return seed.getLevel() - 5;
@ -147,7 +130,6 @@ public class Manor
public int getSeedMaxLevel(int seedId)
{
final SeedData seed = _seeds.get(seedId);
if (seed != null)
{
return seed.getLevel() + 5;
@ -170,7 +152,6 @@ public class Manor
public int getSeedLevel(int seedId)
{
final SeedData seed = _seeds.get(seedId);
if (seed != null)
{
return seed.getLevel();
@ -193,7 +174,6 @@ public class Manor
public int getCropType(int seedId)
{
final SeedData seed = _seeds.get(seedId);
if (seed != null)
{
return seed.getCrop();
@ -216,7 +196,6 @@ public class Manor
public synchronized int getRewardItemBySeed(int seedId, int type)
{
final SeedData seed = _seeds.get(seedId);
if (seed != null)
{
return seed.getReward(type);
@ -232,7 +211,6 @@ public class Manor
public List<Integer> getCropsForCastle(int castleId)
{
final List<Integer> crops = new ArrayList<>();
for (SeedData seed : _seeds.values())
{
if ((seed.getManorId() == castleId) && !crops.contains(seed.getCrop()))
@ -240,7 +218,6 @@ public class Manor
crops.add(seed.getCrop());
}
}
return crops;
}
@ -252,7 +229,6 @@ public class Manor
public List<Integer> getSeedsForCastle(int castleId)
{
final List<Integer> seedsID = new ArrayList<>();
for (SeedData seed : _seeds.values())
{
if ((seed.getManorId() == castleId) && !seedsID.contains(seed.getId()))
@ -260,7 +236,6 @@ public class Manor
seedsID.add(seed.getId());
}
}
return seedsID;
}
@ -282,7 +257,6 @@ public class Manor
public int getSeedSaleLimit(int seedId)
{
final SeedData seed = _seeds.get(seedId);
if (seed != null)
{
return seed.getSeedLimit();
@ -477,4 +451,14 @@ public class Manor
return seed;
}
public static Manor getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final Manor INSTANCE = new Manor();
}
}

View File

@ -37,11 +37,11 @@ public class Potion extends WorldObject
class PotionHpHealing implements Runnable
{
Creature _instance;
Creature _creature;
public PotionHpHealing(Creature instance)
public PotionHpHealing(Creature creature)
{
_instance = instance;
_creature = creature;
}
@Override
@ -51,7 +51,7 @@ public class Potion extends WorldObject
{
synchronized (_hpLock)
{
double nowHp = _instance.getCurrentHp();
double nowHp = _creature.getCurrentHp();
if (_duration == 0)
{
@ -60,7 +60,7 @@ public class Potion extends WorldObject
if (_duration != 0)
{
nowHp += _effect;
_instance.setCurrentHp(nowHp);
_creature.setCurrentHp(nowHp);
_duration = _duration - (_milliseconds / 1000);
setCurrentHpPotion2();
}

View File

@ -71,9 +71,6 @@ public class World
/** List with the pets instances and their owner id. */
private static final Map<Integer, PetInstance> _petsInstance = new ConcurrentHashMap<>();
/** The _instance. */
private static World _instance = null;
/** The _world regions. */
private WorldRegion[][] _worldRegions;
@ -82,19 +79,6 @@ public class World
initRegions();
}
/**
* Gets the single instance of World.
* @return the current instance of World.
*/
public static World getInstance()
{
if (_instance == null)
{
_instance = new World();
}
return _instance;
}
/**
* Add WorldObject object in _allObjects.<BR>
* <BR>
@ -853,19 +837,29 @@ public class World
/**
* Gets the account players.
* @param account_name the account_name
* @param account the account_name
* @return the account players
*/
public List<PlayerInstance> getAccountPlayers(String account_name)
public List<PlayerInstance> getAccountPlayers(String account)
{
final List<PlayerInstance> players_for_account = new ArrayList<>();
final List<PlayerInstance> result = new ArrayList<>();
for (PlayerInstance actual : _allPlayers.values())
{
if (actual.getAccountName().equals(account_name))
if (actual.getAccountName().equals(account))
{
players_for_account.add(actual);
result.add(actual);
}
}
return players_for_account;
return result;
}
public static World getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final World INSTANCE = new World();
}
}

View File

@ -46,7 +46,6 @@ public class Announcements
{
private static Logger LOGGER = Logger.getLogger(Announcements.class.getName());
private static Announcements _instance;
private final List<String> _announcements = new ArrayList<>();
private final List<List<Object>> _eventAnnouncements = new ArrayList<>();
@ -55,16 +54,6 @@ public class Announcements
loadAnnouncements();
}
public static Announcements getInstance()
{
if (_instance == null)
{
_instance = new Announcements();
}
return _instance;
}
public void loadAnnouncements()
{
_announcements.clear();
@ -287,4 +276,14 @@ public class Announcements
{
}
}
public static Announcements getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final Announcements INSTANCE = new Announcements();
}
}

View File

@ -48,7 +48,6 @@ public class Hero
{
private static final Logger LOGGER = Logger.getLogger(Hero.class.getName());
private static Hero _instance;
private static final String GET_HEROES = "SELECT * FROM heroes WHERE played = 1";
private static final String GET_ALL_HEROES = "SELECT * FROM heroes";
private static final String UPDATE_ALL = "UPDATE heroes SET played = 0";
@ -68,15 +67,6 @@ public class Hero
public static final String ALLY_NAME = "ally_name";
public static final String ALLY_CREST = "ally_crest";
public static Hero getInstance()
{
if (_instance == null)
{
_instance = new Hero();
}
return _instance;
}
public Hero()
{
init();
@ -496,4 +486,14 @@ public class Hero
e.printStackTrace();
}
}
public static Hero getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final Hero INSTANCE = new Hero();
}
}

View File

@ -27,7 +27,6 @@ import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
public class MonsterRace
{
private final NpcInstance[] _monsters;
private static MonsterRace _instance;
private Constructor<?> _constructor;
private int[][] _speeds;
private final int[] _first;
@ -41,16 +40,6 @@ public class MonsterRace
_second = new int[2];
}
public static MonsterRace getInstance()
{
if (_instance == null)
{
_instance = new MonsterRace();
}
return _instance;
}
public void newRace()
{
int random = 0;
@ -148,4 +137,14 @@ public class MonsterRace
{
return _second[0];
}
public static MonsterRace getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final MonsterRace INSTANCE = new MonsterRace();
}
}

View File

@ -47,7 +47,6 @@ public class Rebirth
{
private static Logger LOGGER = Logger.getLogger(BitSetIDFactory.class.getName());
private static Rebirth _instance = null;
private final HashMap<Integer, Integer> _playersRebirthInfo = new HashMap<>();
private Rebirth()
@ -55,19 +54,6 @@ public class Rebirth
// Do Nothing ^_-
}
/**
* Receives the non-static instance of the RebirthManager.
* @return single instance of Rebirth
*/
public static Rebirth getInstance()
{
if (_instance == null)
{
_instance = new Rebirth();
}
return _instance;
}
/**
* This is what it called from the Bypass Handler. (I think that's all thats needed here).
* @param player the player
@ -478,4 +464,14 @@ public class Rebirth
e.printStackTrace();
}
}
public static Rebirth getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final Rebirth INSTANCE = new Rebirth();
}
}

View File

@ -52,8 +52,6 @@ public class Lottery
protected boolean _isStarted;
protected long _enddate;
private static Lottery _instance;
private Lottery()
{
_number = 1;
@ -68,16 +66,6 @@ public class Lottery
}
}
public static Lottery getInstance()
{
if (_instance == null)
{
_instance = new Lottery();
}
return _instance;
}
public int getId()
{
return _number;
@ -554,4 +542,14 @@ public class Lottery
return res;
}
public static Lottery getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final Lottery INSTANCE = new Lottery();
}
}

View File

@ -31,17 +31,6 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class PcPoint implements Runnable
{
Logger LOGGER = Logger.getLogger(PcPoint.class.getName());
private static PcPoint _instance;
public static PcPoint getInstance()
{
if (_instance == null)
{
_instance = new PcPoint();
}
return _instance;
}
private PcPoint()
{
@ -83,4 +72,14 @@ public class PcPoint implements Runnable
}
}
}
public static PcPoint getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final PcPoint INSTANCE = new PcPoint();
}
}

View File

@ -57,7 +57,6 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class Olympiad
{
protected static final Logger LOGGER = Logger.getLogger(Olympiad.class.getName());
private static Olympiad _instance;
private static Map<Integer, StatsSet> _nobles;
private static Map<Integer, StatsSet> _oldnobles;
@ -161,15 +160,6 @@ public class Olympiad
NON_CLASSED
}
public static Olympiad getInstance()
{
if (_instance == null)
{
_instance = new Olympiad();
}
return _instance;
}
public Olympiad()
{
load();
@ -1774,4 +1764,14 @@ public class Olympiad
_nextWeeklyChange = nextChange.getTimeInMillis() + restoreTime;
}
}
public static Olympiad getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final Olympiad INSTANCE = new Olympiad();
}
}

View File

@ -48,7 +48,6 @@ public class SevenSigns
{
protected static final Logger LOGGER = Logger.getLogger(SevenSigns.class.getName());
private static SevenSigns _instance;
public static final String SEVEN_SIGNS_DATA_FILE = "config/main/sevensigns.ini";
public static final String SEVEN_SIGNS_HTML_PATH = "data/html/seven_signs/";
public static final int CABAL_NULL = 0;
@ -349,20 +348,6 @@ public class SevenSigns
}
}
/**
* Gets the single instance of SevenSigns.
* @return single instance of SevenSigns
*/
public static SevenSigns getInstance()
{
if (_instance == null)
{
_instance = new SevenSigns();
}
return _instance;
}
/**
* Calc contribution score.
* @param blueCount the blue count
@ -1652,4 +1637,14 @@ public class SevenSigns
ThreadPool.schedule(sspc, getMilliToPeriodChange());
}
}
public static SevenSigns getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final SevenSigns INSTANCE = new SevenSigns();
}
}

View File

@ -64,7 +64,6 @@ public class SevenSignsFestival implements SpawnListener
{
protected static final Logger LOGGER = Logger.getLogger(SevenSignsFestival.class.getName());
private static SevenSignsFestival _instance;
private static final String GET_CLAN_NAME = "SELECT clan_name FROM clan_data WHERE clan_id = (SELECT clanid FROM characters WHERE char_name = ?)";
public static final long FESTIVAL_SIGNUP_TIME = Config.ALT_FESTIVAL_CYCLE_LENGTH - Config.ALT_FESTIVAL_LENGTH - 60000;
private static final int FESTIVAL_MAX_OFFSET_X = 230;
@ -3169,20 +3168,6 @@ public class SevenSignsFestival implements SpawnListener
startFestivalManager();
}
/**
* Gets the single instance of SevenSignsFestival.
* @return single instance of SevenSignsFestival
*/
public static SevenSignsFestival getInstance()
{
if (_instance == null)
{
_instance = new SevenSignsFestival();
}
return _instance;
}
/**
* Returns the associated name (level range) to a given festival ID.
* @param festivalID the festival id
@ -4920,4 +4905,14 @@ public class SevenSignsFestival implements SpawnListener
}
}
}
public static SevenSignsFestival getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final SevenSignsFestival INSTANCE = new SevenSignsFestival();
}
}

View File

@ -50,7 +50,7 @@ import org.l2jmobius.gameserver.taskmanager.ExclusiveTask;
public class BanditStrongholdSiege extends ClanHallSiege
{
protected static Logger LOGGER = Logger.getLogger(BanditStrongholdSiege.class.getName());
private static BanditStrongholdSiege _instance;
boolean _registrationPeriod = false;
private int _clanCounter = 0;
protected Map<Integer, clanPlayersInfo> _clansInfo = new HashMap<>();
@ -60,15 +60,6 @@ public class BanditStrongholdSiege extends ClanHallSiege
protected boolean _finalStage = false;
protected ScheduledFuture<?> _midTimer;
public static final BanditStrongholdSiege getInstance()
{
if (_instance == null)
{
_instance = new BanditStrongholdSiege();
}
return _instance;
}
private BanditStrongholdSiege()
{
LOGGER.info("SiegeManager of Bandits Stronghold");
@ -690,4 +681,14 @@ public class BanditStrongholdSiege extends ClanHallSiege
public MonsterInstance _mob = null;
public List<String> _players = new ArrayList<>();
}
public static BanditStrongholdSiege getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final BanditStrongholdSiege INSTANCE = new BanditStrongholdSiege();
}
}

View File

@ -43,7 +43,7 @@ import org.l2jmobius.gameserver.model.spawn.Spawn;
public class DevastatedCastle
{
private static final Logger LOGGER = Logger.getLogger(DevastatedCastle.class.getName());
private static DevastatedCastle _instance;
private final Map<Integer, DamageInfo> _clansDamageInfo;
private static int START_DAY = 1;
@ -70,15 +70,6 @@ public class DevastatedCastle
public boolean _progress = false;
public static DevastatedCastle getInstance()
{
if (_instance == null)
{
_instance = new DevastatedCastle();
}
return _instance;
}
protected class DamageInfo
{
public Clan _clan;
@ -883,4 +874,14 @@ public class DevastatedCastle
e.printStackTrace();
}
}
public static DevastatedCastle getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final DevastatedCastle INSTANCE = new DevastatedCastle();
}
}

View File

@ -41,7 +41,7 @@ import org.l2jmobius.gameserver.model.spawn.Spawn;
public class FortressOfResistance
{
private static final Logger LOGGER = Logger.getLogger(FortressOfResistance.class.getName());
private static FortressOfResistance _instance;
private final Map<Integer, DamageInfo> _clansDamageInfo;
private static int START_DAY = 1;
@ -56,15 +56,6 @@ public class FortressOfResistance
private final Calendar _capturetime = Calendar.getInstance();
public static FortressOfResistance getInstance()
{
if (_instance == null)
{
_instance = new FortressOfResistance();
}
return _instance;
}
protected class DamageInfo
{
public Clan _clan;
@ -375,4 +366,14 @@ public class FortressOfResistance
e.printStackTrace();
}
}
public static FortressOfResistance getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final FortressOfResistance INSTANCE = new FortressOfResistance();
}
}

View File

@ -47,7 +47,7 @@ import org.l2jmobius.gameserver.taskmanager.ExclusiveTask;
public class WildBeastFarmSiege extends ClanHallSiege
{
protected static Logger LOGGER = Logger.getLogger(WildBeastFarmSiege.class.getName());
private static WildBeastFarmSiege _instance;
boolean _registrationPeriod = false;
private int _clanCounter = 0;
protected Map<Integer, clanPlayersInfo> _clansInfo = new HashMap<>();
@ -57,15 +57,6 @@ public class WildBeastFarmSiege extends ClanHallSiege
protected ScheduledFuture<?> _midTimer;
private ClanHallZone zone;
public static final WildBeastFarmSiege getInstance()
{
if (_instance == null)
{
_instance = new WildBeastFarmSiege();
}
return _instance;
}
private WildBeastFarmSiege()
{
LOGGER.info("SiegeManager of Wild Beasts Farm");
@ -676,4 +667,14 @@ public class WildBeastFarmSiege extends ClanHallSiege
public MonsterInstance _mob = null;
public List<String> _players = new ArrayList<>();
}
public static WildBeastFarmSiege getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final WildBeastFarmSiege INSTANCE = new WildBeastFarmSiege();
}
}

View File

@ -43,7 +43,6 @@ public class Multisell
{
private static Logger LOGGER = Logger.getLogger(Multisell.class.getName());
private final List<MultiSellListContainer> _entries = new ArrayList<>();
private static Multisell _instance;
public MultiSellListContainer getList(int id)
{
@ -72,15 +71,6 @@ public class Multisell
parseData();
}
public static Multisell getInstance()
{
if (_instance == null)
{
_instance = new Multisell();
}
return _instance;
}
private void parseData()
{
_entries.clear();
@ -476,4 +466,14 @@ public class Multisell
}
}
}
public static Multisell getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final Multisell INSTANCE = new Multisell();
}
}

View File

@ -40,7 +40,6 @@ public class QuestStateManager
}
}
private static QuestStateManager _instance;
private List<QuestState> _questStates = new ArrayList<>();
public QuestStateManager()
@ -87,15 +86,6 @@ public class QuestStateManager
qs = null;
}
public static final QuestStateManager getInstance()
{
if (_instance == null)
{
_instance = new QuestStateManager();
}
return _instance;
}
/**
* Return QuestState for specified player instance
* @param player
@ -109,9 +99,7 @@ public class QuestStateManager
{
return getQuestStates().get(i);
}
}
return null;
}
@ -125,7 +113,16 @@ public class QuestStateManager
{
_questStates = new ArrayList<>();
}
return _questStates;
}
public static QuestStateManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final QuestStateManager INSTANCE = new QuestStateManager();
}
}

View File

@ -51,8 +51,6 @@ public class AutoSpawn
{
protected static final Logger LOGGER = Logger.getLogger(AutoSpawn.class.getName());
private static AutoSpawn _instance;
private static final int DEFAULT_INITIAL_SPAWN = 30000; // 30 seconds after registration
private static final int DEFAULT_RESPAWN = 3600000; // 1 hour in millisecs
private static final int DEFAULT_DESPAWN = 3600000; // 1 hour in millisecs
@ -70,16 +68,6 @@ public class AutoSpawn
restoreSpawnData();
}
public static AutoSpawn getInstance()
{
if (_instance == null)
{
_instance = new AutoSpawn();
}
return _instance;
}
public int size()
{
synchronized (_registeredSpawns)
@ -813,4 +801,14 @@ public class AutoSpawn
}
}
}
public static AutoSpawn getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final AutoSpawn INSTANCE = new AutoSpawn();
}
}

View File

@ -26,21 +26,9 @@ import java.util.List;
*/
public class EventDroplist
{
private static EventDroplist _instance;
/** The table containing all DataDrop object */
private final List<DateDrop> _allNpcDateDrops;
public static EventDroplist getInstance()
{
if (_instance == null)
{
_instance = new EventDroplist();
}
return _instance;
}
public class DateDrop
{
/** Start and end date of the Event */
@ -105,4 +93,14 @@ public class EventDroplist
}
return list;
}
public static EventDroplist getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final EventDroplist INSTANCE = new EventDroplist();
}
}

View File

@ -31,25 +31,14 @@ import org.l2jmobius.gameserver.model.actor.instance.RaidBossInstance;
public class DecayTaskManager
{
protected static final Logger LOGGER = Logger.getLogger(DecayTaskManager.class.getName());
protected Map<Creature, Long> _decayTasks = new ConcurrentHashMap<>();
private static DecayTaskManager _instance;
public DecayTaskManager()
private DecayTaskManager()
{
ThreadPool.scheduleAtFixedRate(new DecayScheduler(), 10000, 5000);
}
public static DecayTaskManager getInstance()
{
if (_instance == null)
{
_instance = new DecayTaskManager();
}
return _instance;
}
public void addDecayTask(Creature actor)
{
_decayTasks.put(actor, System.currentTimeMillis());
@ -127,4 +116,14 @@ public class DecayTaskManager
return ret;
}
public static DecayTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final DecayTaskManager INSTANCE = new DecayTaskManager();
}
}

View File

@ -29,23 +29,11 @@ public class KnownListUpdateTaskManager
{
protected static final Logger LOGGER = Logger.getLogger(DecayTaskManager.class.getName());
private static KnownListUpdateTaskManager _instance;
public KnownListUpdateTaskManager()
{
ThreadPool.scheduleAtFixedRate(new KnownListUpdate(), 1000, 750);
}
public static KnownListUpdateTaskManager getInstance()
{
if (_instance == null)
{
_instance = new KnownListUpdateTaskManager();
}
return _instance;
}
private class KnownListUpdate implements Runnable
{
boolean toggle = false;
@ -136,4 +124,14 @@ public class KnownListUpdateTaskManager
}
}
public static KnownListUpdateTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final KnownListUpdateTaskManager INSTANCE = new KnownListUpdateTaskManager();
}
}

View File

@ -54,7 +54,6 @@ import org.l2jmobius.gameserver.taskmanager.tasks.TaskShutdown;
public class TaskManager
{
protected static final Logger LOGGER = Logger.getLogger(TaskManager.class.getName());
private static TaskManager _instance;
protected static final String[] SQL_STATEMENTS =
{
@ -171,15 +170,6 @@ public class TaskManager
}
public static TaskManager getInstance()
{
if (_instance == null)
{
_instance = new TaskManager();
}
return _instance;
}
private TaskManager()
{
initializate();
@ -408,4 +398,14 @@ public class TaskManager
return output;
}
public static TaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final TaskManager INSTANCE = new TaskManager();
}
}

View File

@ -18,11 +18,8 @@ package org.l2jmobius.loginserver;
import java.io.File;
import java.math.BigInteger;
import java.security.GeneralSecurityException;
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.spec.RSAKeyGenParameterSpec;
import java.sql.Connection;
import java.sql.PreparedStatement;
@ -52,7 +49,6 @@ import org.l2jmobius.loginserver.network.gameserverpackets.ServerStatus;
public class GameServerTable
{
private static Logger LOGGER = Logger.getLogger(GameServerTable.class.getName());
private static GameServerTable _instance;
// Server Names Config
private static Map<Integer, String> _serverNames = new HashMap<>();
@ -64,24 +60,10 @@ public class GameServerTable
private static final int KEYS_SIZE = 10;
private KeyPair[] _keyPairs;
public static void load() throws GeneralSecurityException
{
if (_instance == null)
{
_instance = new GameServerTable();
}
else
{
throw new IllegalStateException("Load can only be invoked a single time.");
}
}
public static GameServerTable getInstance()
{
return _instance;
}
public GameServerTable() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException
/**
* Instantiates a new game server table.
*/
public GameServerTable()
{
loadServerNames();
LOGGER.info("Loaded " + _serverNames.size() + " server names");
@ -93,16 +75,23 @@ public class GameServerTable
LOGGER.info("Cached " + _keyPairs.length + " RSA keys for Game Server communication.");
}
private void loadRSAKeys() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException
private void loadRSAKeys()
{
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
RSAKeyGenParameterSpec spec = new RSAKeyGenParameterSpec(512, RSAKeyGenParameterSpec.F4);
keyGen.initialize(spec);
_keyPairs = new KeyPair[KEYS_SIZE];
for (int i = 0; i < KEYS_SIZE; i++)
try
{
_keyPairs[i] = keyGen.genKeyPair();
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
RSAKeyGenParameterSpec spec = new RSAKeyGenParameterSpec(512, RSAKeyGenParameterSpec.F4);
keyGen.initialize(spec);
_keyPairs = new KeyPair[KEYS_SIZE];
for (int i = 0; i < KEYS_SIZE; i++)
{
_keyPairs[i] = keyGen.genKeyPair();
}
}
catch (Exception e)
{
LOGGER.severe("Error loading RSA keys for Game Server communication!");
}
}
@ -459,4 +448,21 @@ public class GameServerTable
setStatus(ServerStatus.STATUS_DOWN);
}
}
/**
* Gets the single instance of GameServerTable.
* @return single instance of GameServerTable
*/
public static GameServerTable getInstance()
{
return SingletonHolder.INSTANCE;
}
/**
* The Class SingletonHolder.
*/
private static class SingletonHolder
{
protected static final GameServerTable INSTANCE = new GameServerTable();
}
}

View File

@ -104,12 +104,7 @@ public class LoginServer
try
{
GameServerTable.load();
}
catch (GeneralSecurityException e)
{
LOGGER.severe("Failed to load GameServerTable" + e);
System.exit(1);
GameServerTable.getInstance();
}
catch (Exception e)
{

View File

@ -765,13 +765,13 @@ public class GameStatusThread extends Thread
else if (type.equals("zone"))
{
_print.print("Reloading zone tables... ");
ZoneData.getInstance().reload();
ZoneData.getInstance().load();
_print.println("done");
}
else if (type.equals("teleports"))
{
_print.print("Reloading telport location table... ");
TeleportLocationTable.getInstance().reloadAll();
TeleportLocationTable.getInstance().load();
_print.println("done");
}
else if (type.equals("spawns"))

View File

@ -21,7 +21,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigInteger;
import java.security.GeneralSecurityException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@ -69,16 +68,6 @@ public abstract class BaseGameServerRegister
Config.load(ServerMode.LOGIN);
DatabaseFactory.init();
GameServerTable.getInstance();
try
{
GameServerTable.load();
}
catch (GeneralSecurityException e)
{
e.printStackTrace();
}
_loaded = true;
}