ItemTable slot variable refactor, plus other minor code changes.

This commit is contained in:
MobiusDev
2016-06-25 12:24:23 +00:00
parent b4ba1fc0a5
commit 2d382fad91
10 changed files with 60 additions and 63 deletions

View File

@@ -46,7 +46,7 @@ public final class Disarmor extends AbstractEffect
_unequippedItems = new ConcurrentHashMap<>(); _unequippedItems = new ConcurrentHashMap<>();
final String slot = params.getString("slot", "chest"); final String slot = params.getString("slot", "chest");
_slot = ItemTable._slots.getOrDefault(slot, L2Item.SLOT_NONE); _slot = ItemTable.SLOTS.getOrDefault(slot, L2Item.SLOT_NONE);
if (_slot == L2Item.SLOT_NONE) if (_slot == L2Item.SLOT_NONE)
{ {
_log.severe("Unknown bodypart slot for effect: " + slot); _log.severe("Unknown bodypart slot for effect: " + slot);

View File

@@ -113,7 +113,7 @@ public class AppearanceItemData implements IGameXmlReader
} }
case "bodyPart": case "bodyPart":
{ {
final int part = ItemTable._slots.get(c.getTextContent()); final int part = ItemTable.SLOTS.get(c.getTextContent());
stone.addBodyPart(part); stone.addBodyPart(part);
break; break;
} }

View File

@@ -118,7 +118,7 @@ public final class EnchantItemGroupsData implements IGameXmlReader
final NamedNodeMap attrs = z.getAttributes(); final NamedNodeMap attrs = z.getAttributes();
if (attrs.getNamedItem("slot") != null) if (attrs.getNamedItem("slot") != null)
{ {
rateGroup.addSlot(ItemTable._slots.get(parseString(attrs, "slot"))); rateGroup.addSlot(ItemTable.SLOTS.get(parseString(attrs, "slot")));
} }
if (attrs.getNamedItem("magicWeapon") != null) if (attrs.getNamedItem("magicWeapon") != null)
{ {

View File

@@ -24,7 +24,6 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -58,53 +57,52 @@ public class ItemTable
private static Logger LOGGER = Logger.getLogger(ItemTable.class.getName()); private static Logger LOGGER = Logger.getLogger(ItemTable.class.getName());
private static Logger LOGGER_ITEMS = Logger.getLogger("item"); private static Logger LOGGER_ITEMS = Logger.getLogger("item");
public static final Map<String, Integer> _slots = new HashMap<>(); public static final Map<String, Integer> SLOTS = new HashMap<>();
private L2Item[] _allTemplates; private L2Item[] _allTemplates;
private final Map<Integer, L2EtcItem> _etcItems; private final Map<Integer, L2EtcItem> _etcItems = new HashMap<>();
private final Map<Integer, L2Armor> _armors; private final Map<Integer, L2Armor> _armors = new HashMap<>();
private final Map<Integer, L2Weapon> _weapons; private final Map<Integer, L2Weapon> _weapons = new HashMap<>();
static static
{ {
_slots.put("shirt", L2Item.SLOT_UNDERWEAR); SLOTS.put("shirt", L2Item.SLOT_UNDERWEAR);
_slots.put("lbracelet", L2Item.SLOT_L_BRACELET); SLOTS.put("lbracelet", L2Item.SLOT_L_BRACELET);
_slots.put("rbracelet", L2Item.SLOT_R_BRACELET); SLOTS.put("rbracelet", L2Item.SLOT_R_BRACELET);
_slots.put("talisman", L2Item.SLOT_DECO); SLOTS.put("talisman", L2Item.SLOT_DECO);
_slots.put("chest", L2Item.SLOT_CHEST); SLOTS.put("chest", L2Item.SLOT_CHEST);
_slots.put("fullarmor", L2Item.SLOT_FULL_ARMOR); SLOTS.put("fullarmor", L2Item.SLOT_FULL_ARMOR);
_slots.put("head", L2Item.SLOT_HEAD); SLOTS.put("head", L2Item.SLOT_HEAD);
_slots.put("hair", L2Item.SLOT_HAIR); SLOTS.put("hair", L2Item.SLOT_HAIR);
_slots.put("hairall", L2Item.SLOT_HAIRALL); SLOTS.put("hairall", L2Item.SLOT_HAIRALL);
_slots.put("underwear", L2Item.SLOT_UNDERWEAR); SLOTS.put("underwear", L2Item.SLOT_UNDERWEAR);
_slots.put("back", L2Item.SLOT_BACK); SLOTS.put("back", L2Item.SLOT_BACK);
_slots.put("neck", L2Item.SLOT_NECK); SLOTS.put("neck", L2Item.SLOT_NECK);
_slots.put("legs", L2Item.SLOT_LEGS); SLOTS.put("legs", L2Item.SLOT_LEGS);
_slots.put("feet", L2Item.SLOT_FEET); SLOTS.put("feet", L2Item.SLOT_FEET);
_slots.put("gloves", L2Item.SLOT_GLOVES); SLOTS.put("gloves", L2Item.SLOT_GLOVES);
_slots.put("chest,legs", L2Item.SLOT_CHEST | L2Item.SLOT_LEGS); SLOTS.put("chest,legs", L2Item.SLOT_CHEST | L2Item.SLOT_LEGS);
_slots.put("belt", L2Item.SLOT_BELT); SLOTS.put("belt", L2Item.SLOT_BELT);
_slots.put("rhand", L2Item.SLOT_R_HAND); SLOTS.put("rhand", L2Item.SLOT_R_HAND);
_slots.put("lhand", L2Item.SLOT_L_HAND); SLOTS.put("lhand", L2Item.SLOT_L_HAND);
_slots.put("lrhand", L2Item.SLOT_LR_HAND); SLOTS.put("lrhand", L2Item.SLOT_LR_HAND);
_slots.put("rear;lear", L2Item.SLOT_R_EAR | L2Item.SLOT_L_EAR); SLOTS.put("rear;lear", L2Item.SLOT_R_EAR | L2Item.SLOT_L_EAR);
_slots.put("rfinger;lfinger", L2Item.SLOT_R_FINGER | L2Item.SLOT_L_FINGER); SLOTS.put("rfinger;lfinger", L2Item.SLOT_R_FINGER | L2Item.SLOT_L_FINGER);
_slots.put("wolf", L2Item.SLOT_WOLF); SLOTS.put("wolf", L2Item.SLOT_WOLF);
_slots.put("greatwolf", L2Item.SLOT_GREATWOLF); SLOTS.put("greatwolf", L2Item.SLOT_GREATWOLF);
_slots.put("hatchling", L2Item.SLOT_HATCHLING); SLOTS.put("hatchling", L2Item.SLOT_HATCHLING);
_slots.put("strider", L2Item.SLOT_STRIDER); SLOTS.put("strider", L2Item.SLOT_STRIDER);
_slots.put("babypet", L2Item.SLOT_BABYPET); SLOTS.put("babypet", L2Item.SLOT_BABYPET);
_slots.put("brooch", L2Item.SLOT_BROOCH); SLOTS.put("brooch", L2Item.SLOT_BROOCH);
_slots.put("brooch_jewel", L2Item.SLOT_BROOCH_JEWEL); SLOTS.put("brooch_jewel", L2Item.SLOT_BROOCH_JEWEL);
_slots.put("none", L2Item.SLOT_NONE); SLOTS.put("none", L2Item.SLOT_NONE);
// retail compatibility // retail compatibility
_slots.put("onepiece", L2Item.SLOT_FULL_ARMOR); SLOTS.put("onepiece", L2Item.SLOT_FULL_ARMOR);
_slots.put("hair2", L2Item.SLOT_HAIR2); SLOTS.put("hair2", L2Item.SLOT_HAIR2);
_slots.put("dhair", L2Item.SLOT_HAIRALL); SLOTS.put("dhair", L2Item.SLOT_HAIRALL);
_slots.put("alldress", L2Item.SLOT_ALLDRESS); SLOTS.put("alldress", L2Item.SLOT_ALLDRESS);
_slots.put("deco1", L2Item.SLOT_DECO); SLOTS.put("deco1", L2Item.SLOT_DECO);
_slots.put("waist", L2Item.SLOT_BELT); SLOTS.put("waist", L2Item.SLOT_BELT);
} }
/** /**
@@ -117,9 +115,6 @@ public class ItemTable
protected ItemTable() protected ItemTable()
{ {
_etcItems = new ConcurrentHashMap<>();
_armors = new ConcurrentHashMap<>();
_weapons = new ConcurrentHashMap<>();
load(); load();
} }

View File

@@ -1151,9 +1151,9 @@ public abstract class DocumentBase
{ {
final int old = mask; final int old = mask;
final String item = st.nextToken().trim(); final String item = st.nextToken().trim();
if (ItemTable._slots.containsKey(item)) if (ItemTable.SLOTS.containsKey(item))
{ {
mask |= ItemTable._slots.get(item); mask |= ItemTable.SLOTS.get(item);
} }
if (old == mask) if (old == mask)

View File

@@ -1727,16 +1727,13 @@ public abstract class Inventory extends ItemContainer
// find same (or incompatible) brooch jewel type // find same (or incompatible) brooch jewel type
for (int i = PAPERDOLL_BROOCH_JEWEL1; i < (PAPERDOLL_BROOCH_JEWEL1 + getBroochJewelSlots()); i++) for (int i = PAPERDOLL_BROOCH_JEWEL1; i < (PAPERDOLL_BROOCH_JEWEL1 + getBroochJewelSlots()); i++)
{ {
if (_paperdoll[i] != null) if ((_paperdoll[i] != null) && (getPaperdollItemId(i) == item.getId()))
{
if (getPaperdollItemId(i) == item.getId())
{ {
// overwtite // overwtite
setPaperdollItem(i, item); setPaperdollItem(i, item);
return; return;
} }
} }
}
// no free slot found - put on first free // no free slot found - put on first free
for (int i = PAPERDOLL_BROOCH_JEWEL1; i < (PAPERDOLL_BROOCH_JEWEL1 + getBroochJewelSlots()); i++) for (int i = PAPERDOLL_BROOCH_JEWEL1; i < (PAPERDOLL_BROOCH_JEWEL1 + getBroochJewelSlots()); i++)

View File

@@ -199,7 +199,7 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable
_duration = set.getInt("duration", -1); _duration = set.getInt("duration", -1);
_time = set.getInt("time", -1); _time = set.getInt("time", -1);
_autoDestroyTime = set.getInt("auto_destroy_time", -1) * 1000; _autoDestroyTime = set.getInt("auto_destroy_time", -1) * 1000;
_bodyPart = ItemTable._slots.get(set.getString("bodypart", "none")); _bodyPart = ItemTable.SLOTS.get(set.getString("bodypart", "none"));
_referencePrice = set.getInt("price", 0); _referencePrice = set.getInt("price", 0);
_crystalType = set.getEnum("crystal_type", CrystalType.class, CrystalType.NONE); _crystalType = set.getEnum("crystal_type", CrystalType.class, CrystalType.NONE);
_crystalCount = set.getInt("crystal_count", 0); _crystalCount = set.getInt("crystal_count", 0);

View File

@@ -84,7 +84,7 @@ public class AppearanceStone
addTargetType(targetType); addTargetType(targetType);
} }
final int bodyPart = ItemTable._slots.get(set.getString("bodyPart", "none")); final int bodyPart = ItemTable.SLOTS.get(set.getString("bodyPart", "none"));
if (bodyPart != L2Item.SLOT_NONE) if (bodyPart != L2Item.SLOT_NONE)
{ {
addBodyPart(bodyPart); addBodyPart(bodyPart);

View File

@@ -138,7 +138,7 @@ public class Debug
private static String getBodyPart(int bodyPart) private static String getBodyPart(int bodyPart)
{ {
for (Entry<String, Integer> entry : ItemTable._slots.entrySet()) for (Entry<String, Integer> entry : ItemTable.SLOTS.entrySet())
{ {
if ((entry.getValue() & bodyPart) == bodyPart) if ((entry.getValue() & bodyPart) == bodyPart)
{ {

View File

@@ -21,6 +21,7 @@ import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.data.xml.impl.ExperienceData; import com.l2jmobius.gameserver.data.xml.impl.ExperienceData;
import com.l2jmobius.gameserver.enums.AttributeType; import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.enums.UserInfoType; import com.l2jmobius.gameserver.enums.UserInfoType;
import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import com.l2jmobius.gameserver.model.L2Clan; import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2Party; import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -325,7 +326,10 @@ public class UserInfo extends AbstractMaskPacket<UserInfoType>
packet.writeC(_activeChar.getInventory().getTalismanSlots()); // Confirmed packet.writeC(_activeChar.getInventory().getTalismanSlots()); // Confirmed
packet.writeC(_activeChar.getInventory().getBroochJewelSlots()); // Confirmed packet.writeC(_activeChar.getInventory().getBroochJewelSlots()); // Confirmed
packet.writeC(_activeChar.getTeam().getId()); // Confirmed packet.writeC(_activeChar.getTeam().getId()); // Confirmed
packet.writeD(0x00); // (1 = Red, 2 = White, 3 = White Pink, there is higher values (23, 50, 100 produces different aura) dotted / straight circle ring on the floor packet.writeC(0x00); // (1 = Red, 2 = White, 3 = White Pink) dotted ring on the floor
packet.writeC(0x00);
packet.writeC(0x00);
packet.writeC(0x00);
} }
if (containsMask(UserInfoType.MOVEMENTS)) if (containsMask(UserInfoType.MOVEMENTS))
@@ -345,9 +349,10 @@ public class UserInfo extends AbstractMaskPacket<UserInfoType>
if (containsMask(UserInfoType.INVENTORY_LIMIT)) if (containsMask(UserInfoType.INVENTORY_LIMIT))
{ {
packet.writeH(9); packet.writeH(9);
packet.writeD(0x00); packet.writeH(0x00);
packet.writeH(0x00);
packet.writeH(_activeChar.getInventoryLimit()); packet.writeH(_activeChar.getInventoryLimit());
packet.writeC(0x00); // if greater than 1 show the attack cursor when interacting, CoC or Cursed Weapon level ? packet.writeC(_activeChar.isCursedWeaponEquipped() ? CursedWeaponsManager.getInstance().getLevel(_activeChar.getCursedWeaponEquippedId()) : 0);
} }
if (containsMask(UserInfoType.UNK_3)) if (containsMask(UserInfoType.UNK_3))