Basic data table cleanup.

This commit is contained in:
MobiusDevelopment
2021-05-16 12:01:19 +00:00
parent 84a67bc5a0
commit b513e66c88
58 changed files with 753 additions and 938 deletions

View File

@@ -36,9 +36,7 @@ import org.l2jmobius.commons.util.PropertiesParser;
import org.l2jmobius.gameserver.cache.CrestCache;
import org.l2jmobius.gameserver.cache.HtmCache;
import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager;
import org.l2jmobius.gameserver.data.HeroSkillTable;
import org.l2jmobius.gameserver.data.ItemTable;
import org.l2jmobius.gameserver.data.NobleSkillTable;
import org.l2jmobius.gameserver.data.SchemeBufferTable;
import org.l2jmobius.gameserver.data.SkillTable;
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
@@ -224,8 +222,6 @@ public class GameServer
}
SkillTreeTable.getInstance();
SkillSpellbookTable.getInstance();
NobleSkillTable.getInstance();
HeroSkillTable.getInstance();
if (!HelperBuffTable.getInstance().isInitialized())
{
throw new Exception("Could not initialize the Helper Buff Table.");

View File

@@ -16,100 +16,44 @@
*/
package org.l2jmobius.gameserver.data;
import java.util.ArrayList;
import java.util.List;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
/**
* This class has just one simple function to return the item id of a crown regarding to castleid
* @author evill33t
* This class has just one simple function to return the item id of the crown related to a castle id.
* @author Mobius
*/
public class CrownTable
{
private static List<Integer> _crownList = new ArrayList<>();
public static final int CROWN_OF_THE_LORD = 6841;
public static List<Integer> getCrownList()
private static final Map<Integer, Integer> CROWNS = new HashMap<>();
static
{
if (_crownList.isEmpty())
{
_crownList.add(6841); // Crown of the lord
_crownList.add(6834); // Innadril
_crownList.add(6835); // Dion
_crownList.add(6836); // Goddard
_crownList.add(6837); // Oren
_crownList.add(6838); // Gludio
_crownList.add(6839); // Giran
_crownList.add(6840); // Aden
_crownList.add(8182); // Rune
_crownList.add(8183); // Schuttgart
}
return _crownList;
CROWNS.put(1, 6838); // Gludio
CROWNS.put(2, 6835); // Dion
CROWNS.put(3, 6839); // Giran
CROWNS.put(4, 6837); // Oren
CROWNS.put(5, 6840); // Aden
CROWNS.put(6, 6834); // Innadril
CROWNS.put(7, 6836); // Goddard
CROWNS.put(8, 8182); // Rune
CROWNS.put(9, 8183); // Schuttgart
}
public static Collection<Integer> getCrownList()
{
return CROWNS.values();
}
public static int getCrownId(int castleId)
{
int crownId = 0;
switch (castleId)
final Integer crownId = CROWNS.get(castleId);
if (crownId != null)
{
// Gludio
case 1:
{
crownId = 6838;
break;
}
// Dion
case 2:
{
crownId = 6835;
break;
}
// Giran
case 3:
{
crownId = 6839;
break;
}
// Oren
case 4:
{
crownId = 6837;
break;
}
// Aden
case 5:
{
crownId = 6840;
break;
}
// Innadril
case 6:
{
crownId = 6834;
break;
}
// Goddard
case 7:
{
crownId = 6836;
break;
}
// Rune
case 8:
{
crownId = 8182;
break;
}
// Schuttgart
case 9:
{
crownId = 8183;
break;
}
default:
{
crownId = 0;
break;
}
return crownId.intValue();
}
return crownId;
return 0;
}
}

View File

@@ -22,10 +22,6 @@ import java.util.Map;
import org.l2jmobius.gameserver.model.WorldObject;
/**
* @version $Revision$ $Date$
*/
public class DesireTable
{
public static final DesireType[] DEFAULT_DESIRES =
@@ -44,69 +40,6 @@ public class DesireTable
DAMAGE
}
class DesireValue
{
private float _value;
DesireValue()
{
this(0f);
}
DesireValue(Float pValue)
{
_value = pValue;
}
public void addValue(float pValue)
{
_value += pValue;
}
public float getValue()
{
return _value;
}
}
class Desires
{
private final Map<DesireType, DesireValue> _desireTable;
public Desires(DesireType... desireList)
{
_desireTable = new EnumMap<>(DesireType.class);
for (DesireType desire : desireList)
{
_desireTable.put(desire, new DesireValue());
}
}
public DesireValue getDesireValue(DesireType type)
{
return _desireTable.get(type);
}
public void addValue(DesireType type, float value)
{
final DesireValue temp = getDesireValue(type);
if (temp != null)
{
temp.addValue(value);
}
}
public void createDesire(DesireType type)
{
_desireTable.put(type, new DesireValue());
}
public void deleteDesire(DesireType type)
{
_desireTable.remove(type);
}
}
private final Map<WorldObject, Desires> _objectDesireTable;
private final Desires _generalDesires;
private final DesireType[] _desireTypes;
@@ -190,4 +123,67 @@ public class DesireTable
_objectDesireTable.put(object, new Desires(desireList));
}
}
private class DesireValue
{
private float _value;
DesireValue()
{
this(0f);
}
DesireValue(Float pValue)
{
_value = pValue;
}
public void addValue(float pValue)
{
_value += pValue;
}
public float getValue()
{
return _value;
}
}
private class Desires
{
private final Map<DesireType, DesireValue> _desireTable;
public Desires(DesireType... desireList)
{
_desireTable = new EnumMap<>(DesireType.class);
for (DesireType desire : desireList)
{
_desireTable.put(desire, new DesireValue());
}
}
public DesireValue getDesireValue(DesireType type)
{
return _desireTable.get(type);
}
public void addValue(DesireType type, float value)
{
final DesireValue temp = getDesireValue(type);
if (temp != null)
{
temp.addValue(value);
}
}
public void createDesire(DesireType type)
{
_desireTable.put(type, new DesireValue());
}
public void deleteDesire(DesireType type)
{
_desireTable.remove(type);
}
}
}

View File

@@ -16,57 +16,34 @@
*/
package org.l2jmobius.gameserver.data;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.l2jmobius.gameserver.model.Skill;
/**
* @author BiTi
* @author Mobius
*/
public class HeroSkillTable
{
private static final Integer[] HERO_SKILL_IDS = new Integer[]
private static final Map<Integer, Skill> HERO_SKILLS = new HashMap<>();
static
{
395,
396,
1374,
1375,
1376
};
private static Skill[] HERO_SKILLS;
protected HeroSkillTable()
{
HERO_SKILLS = new Skill[5];
HERO_SKILLS[0] = SkillTable.getInstance().getSkill(395, 1);
HERO_SKILLS[1] = SkillTable.getInstance().getSkill(396, 1);
HERO_SKILLS[2] = SkillTable.getInstance().getSkill(1374, 1);
HERO_SKILLS[3] = SkillTable.getInstance().getSkill(1375, 1);
HERO_SKILLS[4] = SkillTable.getInstance().getSkill(1376, 1);
HERO_SKILLS.put(395, SkillTable.getInstance().getSkill(395, 1));
HERO_SKILLS.put(396, SkillTable.getInstance().getSkill(396, 1));
HERO_SKILLS.put(1374, SkillTable.getInstance().getSkill(1374, 1));
HERO_SKILLS.put(1375, SkillTable.getInstance().getSkill(1375, 1));
HERO_SKILLS.put(1376, SkillTable.getInstance().getSkill(1376, 1));
}
public static Skill[] getHeroSkills()
public static Collection<Skill> getHeroSkills()
{
return HERO_SKILLS;
return HERO_SKILLS.values();
}
public static boolean isHeroSkill(int skillId)
{
for (int id : HERO_SKILL_IDS)
{
if (id == skillId)
{
return true;
}
}
return false;
}
public static HeroSkillTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final HeroSkillTable INSTANCE = new HeroSkillTable();
return HERO_SKILLS.containsKey(skillId);
}
}

View File

@@ -49,12 +49,12 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance.ItemLocation;
import org.l2jmobius.gameserver.util.DocumentItem;
/**
* @version $Revision: 1.9.2.6.2.9 $ $Date: 2005/04/02 15:57:34 $
* This class serves as a container for all item templates in the game.
*/
public class ItemTable
{
private static final Logger LOGGER = Logger.getLogger(ItemTable.class.getName());
private static final Logger _logItems = Logger.getLogger("item");
private static final Logger LOGGER_ITEMS = Logger.getLogger("item");
private Item[] _allTemplates;
private final Map<Integer, EtcItem> _etcItems;
@@ -189,12 +189,10 @@ public class ItemTable
}
/**
* Create the ItemInstance corresponding to the Item Identifier and quantitiy add logs the activity.<br>
* <br>
* <b><u>Actions</u>:</b><br>
* Create the ItemInstance corresponding to the Item Identifier and quantitiy add logs the activity. <b><u>Actions</u>:</b>
* <li>Create and Init the ItemInstance corresponding to the Item Identifier and quantity</li>
* <li>Add the ItemInstance object to _allObjects of L2world</li>
* <li>Logs Item creation according to LOGGER settings</li><br>
* <li>Logs Item creation according to log settings</li><br>
* @param process : String Identifier of process triggering this action
* @param itemId : int Item Identifier of the item to be created
* @param count : int Quantity of items to be created for stackable items
@@ -231,7 +229,7 @@ public class ItemTable
item.setOwnerId(actor.getObjectId());
delay = 15000;
}
itemLootShedule = ThreadPool.schedule(new resetOwner(item), delay);
itemLootShedule = ThreadPool.schedule(new ResetOwner(item), delay);
item.setItemLootShedule(itemLootShedule);
}
@@ -254,7 +252,7 @@ public class ItemTable
actor,
reference
});
_logItems.log(record);
LOGGER_ITEMS.log(record);
}
return item;
}
@@ -301,14 +299,16 @@ public class ItemTable
/**
* Destroys the ItemInstance.<br>
* <br>
* <b><u>Actions</u>:</b><br>
* <b><u>Actions</u>:</b>
* <ul>
* <li>Sets ItemInstance parameters to be unusable</li>
* <li>Removes the ItemInstance object to _allObjects of L2world</li>
* <li>Logs Item delettion according to LOGGER settings</li><br>
* @param process : String Identifier of process triggering this action
* @param item
* @param actor : PlayerInstance Player requesting the item destroy
* @param reference : WorldObject Object referencing current action like NPC selling item or previous item in transformation
* <li>Logs Item deletion according to log settings</li>
* </ul>
* @param process a string identifier of process triggering this action.
* @param item the item instance to be destroyed.
* @param actor the player requesting the item destroy.
* @param reference the object referencing current action like NPC selling item or previous item in transformation.
*/
public void destroyItem(String process, ItemInstance item, PlayerInstance actor, WorldObject reference)
{
@@ -345,23 +345,6 @@ public class ItemTable
load();
}
protected class resetOwner implements Runnable
{
ItemInstance _item;
public resetOwner(ItemInstance item)
{
_item = item;
}
@Override
public void run()
{
_item.setOwnerId(0);
_item.setItemLootShedule(null);
}
}
public Set<Integer> getAllArmorsId()
{
return _armors.keySet();
@@ -377,10 +360,23 @@ public class ItemTable
return _allTemplates.length;
}
/**
* Returns instance of ItemTable
* @return ItemTable
*/
protected static class ResetOwner implements Runnable
{
ItemInstance _item;
public ResetOwner(ItemInstance item)
{
_item = item;
}
@Override
public void run()
{
_item.setOwnerId(0);
_item.setItemLootShedule(null);
}
}
public static ItemTable getInstance()
{
return SingletonHolder.INSTANCE;

View File

@@ -28,11 +28,11 @@ import org.l2jmobius.gameserver.model.actor.instance.ControllableMobInstance;
*/
public class MobGroupTable
{
private final Map<Integer, MobGroup> _groupMap;
public static final int FOLLOW_RANGE = 300;
public static final int RANDOM_RANGE = 300;
private final Map<Integer, MobGroup> _groupMap;
protected MobGroupTable()
{
_groupMap = new HashMap<>();

View File

@@ -23,33 +23,20 @@ import org.l2jmobius.gameserver.model.Skill;
*/
public class NobleSkillTable
{
private static Skill[] _nobleSkills;
protected NobleSkillTable()
private static final Skill[] NOBLE_SKILLS = new Skill[]
{
_nobleSkills = new Skill[8];
_nobleSkills[0] = SkillTable.getInstance().getSkill(1323, 1);
_nobleSkills[1] = SkillTable.getInstance().getSkill(325, 1);
_nobleSkills[2] = SkillTable.getInstance().getSkill(326, 1);
_nobleSkills[3] = SkillTable.getInstance().getSkill(327, 1);
_nobleSkills[4] = SkillTable.getInstance().getSkill(1324, 1);
_nobleSkills[5] = SkillTable.getInstance().getSkill(1325, 1);
_nobleSkills[6] = SkillTable.getInstance().getSkill(1326, 1);
_nobleSkills[7] = SkillTable.getInstance().getSkill(1327, 1);
}
SkillTable.getInstance().getSkill(1323, 1),
SkillTable.getInstance().getSkill(325, 1),
SkillTable.getInstance().getSkill(326, 1),
SkillTable.getInstance().getSkill(327, 1),
SkillTable.getInstance().getSkill(1324, 1),
SkillTable.getInstance().getSkill(1325, 1),
SkillTable.getInstance().getSkill(1326, 1),
SkillTable.getInstance().getSkill(1327, 1)
};
public Skill[] GetNobleSkills()
public static Skill[] getNobleSkills()
{
return _nobleSkills;
}
public static NobleSkillTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final NobleSkillTable INSTANCE = new NobleSkillTable();
return NOBLE_SKILLS;
}
}

View File

@@ -229,6 +229,7 @@ public class SchemeBufferTable
return true;
}
}
return false;
}

View File

@@ -32,6 +32,21 @@ public class SkillTable
{
protected static final Logger LOGGER = Logger.getLogger(SkillTable.class.getName());
private static final WeaponType[] WEAPON_MASKS =
{
WeaponType.ETC,
WeaponType.BOW,
WeaponType.POLE,
WeaponType.DUALFIST,
WeaponType.DUAL,
WeaponType.BLUNT,
WeaponType.SWORD,
WeaponType.DAGGER,
WeaponType.BIGSWORD,
WeaponType.ROD,
WeaponType.BIGBLUNT
};
private final List<File> _skillFiles = new ArrayList<>();
private final Map<Integer, Skill> _skills = new HashMap<>();
private final boolean _initialized = true;
@@ -39,7 +54,6 @@ public class SkillTable
protected SkillTable()
{
hashFiles("data/stats/skills", _skillFiles);
reload();
}
@@ -51,6 +65,7 @@ public class SkillTable
LOGGER.info("Dir " + dir.getAbsolutePath() + " not exists");
return;
}
final File[] files = dir.listFiles();
for (File f : files)
{
@@ -59,6 +74,7 @@ public class SkillTable
hash.add(f);
}
}
final File customfile = new File(Config.DATAPACK_ROOT, dirname + "/custom.xml");
if (customfile.exists())
{
@@ -73,6 +89,7 @@ public class SkillTable
LOGGER.warning("Skill file not found.");
return null;
}
final DocumentSkill doc = new DocumentSkill(file);
doc.parse();
return doc.getSkills();
@@ -88,6 +105,7 @@ public class SkillTable
{
continue;
}
for (Skill skill : s)
{
allSkills.put(SkillTable.getSkillHashCode(skill), skill);
@@ -150,21 +168,6 @@ public class SkillTable
return result;
}
private static final WeaponType[] weaponDbMasks =
{
WeaponType.ETC,
WeaponType.BOW,
WeaponType.POLE,
WeaponType.DUALFIST,
WeaponType.DUAL,
WeaponType.BLUNT,
WeaponType.SWORD,
WeaponType.DAGGER,
WeaponType.BIGSWORD,
WeaponType.ROD,
WeaponType.BIGBLUNT
};
public int calcWeaponsAllowed(int mask)
{
if (mask == 0)
@@ -173,11 +176,11 @@ public class SkillTable
}
int weaponsAllowed = 0;
for (int i = 0; i < weaponDbMasks.length; i++)
for (int i = 0; i < WEAPON_MASKS.length; i++)
{
if ((mask & (1 << i)) != 0)
{
weaponsAllowed |= weaponDbMasks[i].mask();
weaponsAllowed |= WEAPON_MASKS[i].mask();
}
}

View File

@@ -24,6 +24,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Logger;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.data.CrownTable;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.Clan;
@@ -313,14 +314,14 @@ public class CastleManager
{
if (player.isClanLeader())
{
final ItemInstance crown = player.getInventory().getItemByItemId(6841);
final ItemInstance crown = player.getInventory().getItemByItemId(CrownTable.CROWN_OF_THE_LORD);
if (crown != null)
{
if (crown.isEquipped())
{
player.getInventory().unEquipItemInSlotAndRecord(crown.getEquipSlot());
}
player.destroyItemByItemId("CastleCrownRemoval", 6841, 1, player, true);
player.destroyItemByItemId("CastleCrownRemoval", CrownTable.CROWN_OF_THE_LORD, 1, player, true);
}
}
@@ -345,7 +346,7 @@ public class CastleManager
{
statement = con.prepareStatement("DELETE FROM items WHERE owner_id = ? and item_id = ?");
statement.setInt(1, member.getObjectId());
statement.setInt(2, 6841);
statement.setInt(2, CrownTable.CROWN_OF_THE_LORD);
statement.execute();
statement.close();

View File

@@ -85,9 +85,9 @@ public class CrownManager
if (crownId > 0)
{
if (isLeader && (player.getInventory().getItemByItemId(6841) == null))
if (isLeader && (player.getInventory().getItemByItemId(CrownTable.CROWN_OF_THE_LORD) == null))
{
player.addItem("Crown", 6841, 1, player, true);
player.addItem("Crown", CrownTable.CROWN_OF_THE_LORD, 1, player, true);
player.getInventory().updateDatabase();
}
@@ -114,7 +114,7 @@ public class CrownManager
continue;
}
}
else if ((item.getItemId() == 6841) && isLeader && !alreadyFoundCrown)
else if ((item.getItemId() == CrownTable.CROWN_OF_THE_LORD) && isLeader && !alreadyFoundCrown)
{
alreadyFoundCrown = true;
continue;

View File

@@ -11536,14 +11536,14 @@ public class PlayerInstance extends Playable
{
if (value)
{
for (Skill s : NobleSkillTable.getInstance().GetNobleSkills())
for (Skill s : NobleSkillTable.getNobleSkills())
{
addSkill(s, false); // Dont Save Noble skills to Sql
}
}
else
{
for (Skill s : NobleSkillTable.getInstance().GetNobleSkills())
for (Skill s : NobleSkillTable.getNobleSkills())
{
super.removeSkill(s); // Just Remove skills without deleting from Sql
}

View File

@@ -22,6 +22,7 @@ import java.util.List;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.data.CrownTable;
import org.l2jmobius.gameserver.data.SkillTable;
import org.l2jmobius.gameserver.handler.IItemHandler;
import org.l2jmobius.gameserver.handler.ItemHandler;
@@ -231,7 +232,7 @@ public class UseItem implements IClientIncomingPacket
}
// The Lord's Crown used by castle lords only
if ((itemId == 6841) && Config.CASTLE_CROWN && ((cl == null) || (cl.getCastleId() == 0) || !player.isClanLeader()) && !player.isGM())
if ((itemId == CrownTable.CROWN_OF_THE_LORD) && Config.CASTLE_CROWN && ((cl == null) || (cl.getCastleId() == 0) || !player.isClanLeader()) && !player.isGM())
{
player.sendMessage("You can't equip that.");
return;