/
tofu
/
l2interlude
Обзор
Документация
Войти
/
tofu
/
l2interlude
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/main/java/com/l2jserver/gameserver/model/items/L2EtcItem.java
143 строки
4 KB
Zoey76
Copyright Update
01 янв 2025, 07:57
01 янв 2025, 07:57
16130a5
Код
Авторство
О чём код?
/* * Copyright © 2004-2025 L2J Server * * This file is part of L2J Server. * * L2J Server is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * L2J Server is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.l2jserver.gameserver.model.items; import java.util.ArrayList; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.l2jserver.gameserver.model.L2ExtractableProduct; import com.l2jserver.gameserver.model.StatsSet; import com.l2jserver.gameserver.model.itemcontainer.Inventory; import com.l2jserver.gameserver.model.items.type.EtcItemType; import com.l2jserver.gameserver.model.items.type.ItemType1; import com.l2jserver.gameserver.model.items.type.ItemType2; /** * This class is dedicated to the management of EtcItem. */ public final class L2EtcItem extends L2Item { private static final Logger LOG = LoggerFactory.getLogger(L2EtcItem.class); private String _handler; private EtcItemType _type; private final boolean _isBlessed; private final List<L2ExtractableProduct> _extractableItems; /** * Constructor for EtcItem. * @param set StatsSet designating the set of couples (key,value) for description of the Etc */ public L2EtcItem(StatsSet set) { super(set); _type = set.getEnum("etcitem_type", EtcItemType.class, EtcItemType.NONE); // l2j custom - L2EtcItemType.SHOT switch (getDefaultAction()) { case SOULSHOT, SUMMON_SOULSHOT, SUMMON_SPIRITSHOT, SPIRITSHOT -> _type = EtcItemType.SHOT; } _type1 = ItemType1.ITEM_QUESTITEM_ADENA; _type2 = ItemType2.OTHER; // default is other if (isQuestItem()) { _type2 = ItemType2.QUEST; } else if ((getId() == Inventory.ADENA_ID) || (getId() == Inventory.ANCIENT_ADENA_ID)) { _type2 = ItemType2.MONEY; } _handler = set.getString("handler", null); // ! null ! _isBlessed = set.getBoolean("blessed", false); // Extractable String capsuled_items = set.getString("capsuled_items", null); if (capsuled_items != null) { String[] split = capsuled_items.split(";"); _extractableItems = new ArrayList<>(split.length); for (String part : split) { if (part.trim().isEmpty()) { continue; } String[] data = part.split(","); if (data.length != 4) { LOG.warn("Couldn't parse {} in capsuled_items! item {}!", part, this); continue; } int itemId = Integer.parseInt(data[0]); int min = Integer.parseInt(data[1]); int max = Integer.parseInt(data[2]); double chance = Double.parseDouble(data[3]); if (max < min) { LOG.warn("Max amount < Min amount in {}, item {}!", part, this); continue; } L2ExtractableProduct product = new L2ExtractableProduct(itemId, min, max, chance); _extractableItems.add(product); } ((ArrayList<?>) _extractableItems).trimToSize(); // check for handler if (_handler == null) { LOG.warn("Item {} define capsuled_items but missing handler!", this); _handler = "ExtractableItems"; } } else { _extractableItems = null; } } /** * @return the type of Etc Item. */ @Override public EtcItemType getItemType() { return _type; } /** * @return the ID of the Etc item after applying the mask. */ @Override public int getItemMask() { return getItemType().mask(); } /** * @return the handler name, null if no handler for item. */ public String getHandlerName() { return _handler; } /** * @return {@code true} if the item is blessed, {@code false} otherwise. */ public boolean isBlessed() { return _isBlessed; } /** * @return the extractable items list. */ public List<L2ExtractableProduct> getExtractableItems() { return _extractableItems; } }