Drop of IntIntHolder class.

This commit is contained in:
MobiusDev
2018-08-10 18:32:32 +00:00
parent 7352425305
commit dcd734b447
16 changed files with 109 additions and 339 deletions

View File

@@ -24,7 +24,7 @@ import java.util.Map;
import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.IntIntHolder; import com.l2jmobius.gameserver.model.holders.ItemHolder;
import com.l2jmobius.gameserver.model.quest.Quest; import com.l2jmobius.gameserver.model.quest.Quest;
import com.l2jmobius.gameserver.model.quest.QuestState; import com.l2jmobius.gameserver.model.quest.QuestState;
import com.l2jmobius.gameserver.model.quest.State; import com.l2jmobius.gameserver.model.quest.State;
@@ -50,18 +50,18 @@ public class Q325_GrimCollector extends Quest
private static final int VARSAK = 30342; private static final int VARSAK = 30342;
private static final int SAMED = 30434; private static final int SAMED = 30434;
private static final Map<Integer, List<IntIntHolder>> DROPLIST = new HashMap<>(); private static final Map<Integer, List<ItemHolder>> DROPLIST = new HashMap<>();
{ {
DROPLIST.put(20026, Arrays.asList(new IntIntHolder(ZOMBIE_HEAD, 30), new IntIntHolder(ZOMBIE_HEART, 50), new IntIntHolder(ZOMBIE_LIVER, 75))); DROPLIST.put(20026, Arrays.asList(new ItemHolder(ZOMBIE_HEAD, 30), new ItemHolder(ZOMBIE_HEART, 50), new ItemHolder(ZOMBIE_LIVER, 75)));
DROPLIST.put(20029, Arrays.asList(new IntIntHolder(ZOMBIE_HEAD, 30), new IntIntHolder(ZOMBIE_HEART, 52), new IntIntHolder(ZOMBIE_LIVER, 75))); DROPLIST.put(20029, Arrays.asList(new ItemHolder(ZOMBIE_HEAD, 30), new ItemHolder(ZOMBIE_HEART, 52), new ItemHolder(ZOMBIE_LIVER, 75)));
DROPLIST.put(20035, Arrays.asList(new IntIntHolder(SKULL, 5), new IntIntHolder(RIB_BONE, 15), new IntIntHolder(SPINE, 29), new IntIntHolder(THIGH_BONE, 79))); DROPLIST.put(20035, Arrays.asList(new ItemHolder(SKULL, 5), new ItemHolder(RIB_BONE, 15), new ItemHolder(SPINE, 29), new ItemHolder(THIGH_BONE, 79)));
DROPLIST.put(20042, Arrays.asList(new IntIntHolder(SKULL, 6), new IntIntHolder(RIB_BONE, 19), new IntIntHolder(ARM_BONE, 69), new IntIntHolder(THIGH_BONE, 86))); DROPLIST.put(20042, Arrays.asList(new ItemHolder(SKULL, 6), new ItemHolder(RIB_BONE, 19), new ItemHolder(ARM_BONE, 69), new ItemHolder(THIGH_BONE, 86)));
DROPLIST.put(20045, Arrays.asList(new IntIntHolder(SKULL, 9), new IntIntHolder(SPINE, 59), new IntIntHolder(ARM_BONE, 77), new IntIntHolder(THIGH_BONE, 97))); DROPLIST.put(20045, Arrays.asList(new ItemHolder(SKULL, 9), new ItemHolder(SPINE, 59), new ItemHolder(ARM_BONE, 77), new ItemHolder(THIGH_BONE, 97)));
DROPLIST.put(20051, Arrays.asList(new IntIntHolder(SKULL, 9), new IntIntHolder(RIB_BONE, 59), new IntIntHolder(SPINE, 79), new IntIntHolder(ARM_BONE, 100))); DROPLIST.put(20051, Arrays.asList(new ItemHolder(SKULL, 9), new ItemHolder(RIB_BONE, 59), new ItemHolder(SPINE, 79), new ItemHolder(ARM_BONE, 100)));
DROPLIST.put(20457, Arrays.asList(new IntIntHolder(ZOMBIE_HEAD, 40), new IntIntHolder(ZOMBIE_HEART, 60), new IntIntHolder(ZOMBIE_LIVER, 80))); DROPLIST.put(20457, Arrays.asList(new ItemHolder(ZOMBIE_HEAD, 40), new ItemHolder(ZOMBIE_HEART, 60), new ItemHolder(ZOMBIE_LIVER, 80)));
DROPLIST.put(20458, Arrays.asList(new IntIntHolder(ZOMBIE_HEAD, 40), new IntIntHolder(ZOMBIE_HEART, 70), new IntIntHolder(ZOMBIE_LIVER, 100))); DROPLIST.put(20458, Arrays.asList(new ItemHolder(ZOMBIE_HEAD, 40), new ItemHolder(ZOMBIE_HEART, 70), new ItemHolder(ZOMBIE_LIVER, 100)));
DROPLIST.put(20514, Arrays.asList(new IntIntHolder(SKULL, 6), new IntIntHolder(RIB_BONE, 21), new IntIntHolder(SPINE, 30), new IntIntHolder(ARM_BONE, 31), new IntIntHolder(THIGH_BONE, 64))); DROPLIST.put(20514, Arrays.asList(new ItemHolder(SKULL, 6), new ItemHolder(RIB_BONE, 21), new ItemHolder(SPINE, 30), new ItemHolder(ARM_BONE, 31), new ItemHolder(THIGH_BONE, 64)));
DROPLIST.put(20515, Arrays.asList(new IntIntHolder(SKULL, 5), new IntIntHolder(RIB_BONE, 20), new IntIntHolder(SPINE, 31), new IntIntHolder(ARM_BONE, 33), new IntIntHolder(THIGH_BONE, 69))); DROPLIST.put(20515, Arrays.asList(new ItemHolder(SKULL, 5), new ItemHolder(RIB_BONE, 20), new ItemHolder(SPINE, 31), new ItemHolder(ARM_BONE, 33), new ItemHolder(THIGH_BONE, 69)));
} }
public Q325_GrimCollector() public Q325_GrimCollector()
@@ -247,9 +247,9 @@ public class Q325_GrimCollector extends Quest
if (st.hasQuestItems(ANATOMY_DIAGRAM)) if (st.hasQuestItems(ANATOMY_DIAGRAM))
{ {
final int chance = Rnd.get(100); final int chance = Rnd.get(100);
for (IntIntHolder drop : DROPLIST.get(npc.getNpcId())) for (ItemHolder drop : DROPLIST.get(npc.getNpcId()))
{ {
if (chance < drop.getValue()) if (chance < drop.getCount())
{ {
st.dropItemsAlways(drop.getId(), 1, 0); st.dropItemsAlways(drop.getId(), 1, 0);
break; break;

View File

@@ -438,7 +438,7 @@ public class L2SchemeBufferInstance extends L2FolkInstance
int fee = 0; int fee = 0;
for (int sk : list) for (int sk : list)
{ {
fee += BufferTable.getInstance().getAvailableBuff(sk).getValue(); fee += BufferTable.getInstance().getAvailableBuff(sk).getPrice();
} }
return fee; return fee;

View File

@@ -19,19 +19,31 @@ package com.l2jmobius.gameserver.model.holders;
/** /**
* A container used for schemes buffer. * A container used for schemes buffer.
*/ */
public final class BuffSkillHolder extends IntIntHolder public final class BuffSkillHolder
{ {
private final int _id;
private final int _price;
private final String _type; private final String _type;
private final String _description; private final String _description;
public BuffSkillHolder(int id, int price, String type, String description) public BuffSkillHolder(int id, int price, String type, String description)
{ {
super(id, price); _id = id;
_price = price;
_type = type; _type = type;
_description = description; _description = description;
} }
public int getId()
{
return _id;
}
public int getPrice()
{
return _price;
}
public final String getType() public final String getType()
{ {
return _type; return _type;

View File

@@ -16,54 +16,40 @@
*/ */
package com.l2jmobius.gameserver.model.holders; package com.l2jmobius.gameserver.model.holders;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.model.L2Skill;
/** /**
* A generic int/int container. * A simple DTO for items; contains item ID and count.<br>
* @author UnAfraid
*/ */
public class IntIntHolder public class ItemHolder
{ {
private int _id; private final int _id;
private int _value; private final long _count;
public IntIntHolder(int id, int value) public ItemHolder(int id, long count)
{ {
_id = id; _id = id;
_value = value; _count = count;
} }
/**
* @return the ID of the item contained in this object
*/
public int getId() public int getId()
{ {
return _id; return _id;
} }
public int getValue()
{
return _value;
}
public void setId(int id)
{
_id = id;
}
public void setValue(int value)
{
_value = value;
}
/** /**
* @return the L2Skill associated to the id/value. * @return the count of items contained in this object
*/ */
public final L2Skill getSkill() public long getCount()
{ {
return SkillTable.getInstance().getInfo(_id, _value); return _count;
} }
@Override @Override
public String toString() public String toString()
{ {
return getClass().getSimpleName() + ": Id: " + _id + ", Value: " + _value; return "[" + getClass().getSimpleName() + "] ID: " + _id + ", count: " + _count;
} }
} }

View File

@@ -429,7 +429,7 @@ public class L2SchemeBufferInstance extends L2Npc
int fee = 0; int fee = 0;
for (int sk : list) for (int sk : list)
{ {
fee += SchemeBufferTable.getInstance().getAvailableBuff(sk).getValue(); fee += SchemeBufferTable.getInstance().getAvailableBuff(sk).getPrice();
} }
return fee; return fee;

View File

@@ -19,19 +19,31 @@ package com.l2jmobius.gameserver.model.holders;
/** /**
* A container used for schemes buffer. * A container used for schemes buffer.
*/ */
public final class BuffSkillHolder extends IntIntHolder public final class BuffSkillHolder
{ {
private final int _id;
private final int _price;
private final String _type; private final String _type;
private final String _description; private final String _description;
public BuffSkillHolder(int id, int price, String type, String description) public BuffSkillHolder(int id, int price, String type, String description)
{ {
super(id, price); _id = id;
_price = price;
_type = type; _type = type;
_description = description; _description = description;
} }
public int getId()
{
return _id;
}
public int getPrice()
{
return _price;
}
public final String getType() public final String getType()
{ {
return _type; return _type;

View File

@@ -1,69 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program 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.
*
* This program 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.l2jmobius.gameserver.model.holders;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.model.skills.Skill;
/**
* A generic int/int container.
*/
public class IntIntHolder
{
private int _id;
private int _value;
public IntIntHolder(int id, int value)
{
_id = id;
_value = value;
}
public int getId()
{
return _id;
}
public int getValue()
{
return _value;
}
public void setId(int id)
{
_id = id;
}
public void setValue(int value)
{
_value = value;
}
/**
* @return the L2Skill associated to the id/value.
*/
public final Skill getSkill()
{
return SkillData.getInstance().getSkill(_id, _value);
}
@Override
public String toString()
{
return getClass().getSimpleName() + ": Id: " + _id + ", Value: " + _value;
}
}

View File

@@ -429,7 +429,7 @@ public class L2SchemeBufferInstance extends L2Npc
int fee = 0; int fee = 0;
for (int sk : list) for (int sk : list)
{ {
fee += SchemeBufferTable.getInstance().getAvailableBuff(sk).getValue(); fee += SchemeBufferTable.getInstance().getAvailableBuff(sk).getPrice();
} }
return fee; return fee;

View File

@@ -19,19 +19,31 @@ package com.l2jmobius.gameserver.model.holders;
/** /**
* A container used for schemes buffer. * A container used for schemes buffer.
*/ */
public final class BuffSkillHolder extends IntIntHolder public final class BuffSkillHolder
{ {
private final int _id;
private final int _price;
private final String _type; private final String _type;
private final String _description; private final String _description;
public BuffSkillHolder(int id, int price, String type, String description) public BuffSkillHolder(int id, int price, String type, String description)
{ {
super(id, price); _id = id;
_price = price;
_type = type; _type = type;
_description = description; _description = description;
} }
public int getId()
{
return _id;
}
public int getPrice()
{
return _price;
}
public final String getType() public final String getType()
{ {
return _type; return _type;

View File

@@ -1,69 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program 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.
*
* This program 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.l2jmobius.gameserver.model.holders;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.model.skills.Skill;
/**
* A generic int/int container.
*/
public class IntIntHolder
{
private int _id;
private int _value;
public IntIntHolder(int id, int value)
{
_id = id;
_value = value;
}
public int getId()
{
return _id;
}
public int getValue()
{
return _value;
}
public void setId(int id)
{
_id = id;
}
public void setValue(int value)
{
_value = value;
}
/**
* @return the L2Skill associated to the id/value.
*/
public final Skill getSkill()
{
return SkillData.getInstance().getSkill(_id, _value);
}
@Override
public String toString()
{
return getClass().getSimpleName() + ": Id: " + _id + ", Value: " + _value;
}
}

View File

@@ -429,7 +429,7 @@ public class L2SchemeBufferInstance extends L2Npc
int fee = 0; int fee = 0;
for (int sk : list) for (int sk : list)
{ {
fee += SchemeBufferTable.getInstance().getAvailableBuff(sk).getValue(); fee += SchemeBufferTable.getInstance().getAvailableBuff(sk).getPrice();
} }
return fee; return fee;

View File

@@ -19,19 +19,31 @@ package com.l2jmobius.gameserver.model.holders;
/** /**
* A container used for schemes buffer. * A container used for schemes buffer.
*/ */
public final class BuffSkillHolder extends IntIntHolder public final class BuffSkillHolder
{ {
private final int _id;
private final int _price;
private final String _type; private final String _type;
private final String _description; private final String _description;
public BuffSkillHolder(int id, int price, String type, String description) public BuffSkillHolder(int id, int price, String type, String description)
{ {
super(id, price); _id = id;
_price = price;
_type = type; _type = type;
_description = description; _description = description;
} }
public int getId()
{
return _id;
}
public int getPrice()
{
return _price;
}
public final String getType() public final String getType()
{ {
return _type; return _type;

View File

@@ -1,69 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program 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.
*
* This program 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.l2jmobius.gameserver.model.holders;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.model.skills.Skill;
/**
* A generic int/int container.
*/
public class IntIntHolder
{
private int _id;
private int _value;
public IntIntHolder(int id, int value)
{
_id = id;
_value = value;
}
public int getId()
{
return _id;
}
public int getValue()
{
return _value;
}
public void setId(int id)
{
_id = id;
}
public void setValue(int value)
{
_value = value;
}
/**
* @return the L2Skill associated to the id/value.
*/
public final Skill getSkill()
{
return SkillData.getInstance().getSkill(_id, _value);
}
@Override
public String toString()
{
return getClass().getSimpleName() + ": Id: " + _id + ", Value: " + _value;
}
}

View File

@@ -429,7 +429,7 @@ public class L2SchemeBufferInstance extends L2Npc
int fee = 0; int fee = 0;
for (int sk : list) for (int sk : list)
{ {
fee += SchemeBufferTable.getInstance().getAvailableBuff(sk).getValue(); fee += SchemeBufferTable.getInstance().getAvailableBuff(sk).getPrice();
} }
return fee; return fee;

View File

@@ -19,19 +19,31 @@ package com.l2jmobius.gameserver.model.holders;
/** /**
* A container used for schemes buffer. * A container used for schemes buffer.
*/ */
public final class BuffSkillHolder extends IntIntHolder public final class BuffSkillHolder
{ {
private final int _id;
private final int _price;
private final String _type; private final String _type;
private final String _description; private final String _description;
public BuffSkillHolder(int id, int price, String type, String description) public BuffSkillHolder(int id, int price, String type, String description)
{ {
super(id, price); _id = id;
_price = price;
_type = type; _type = type;
_description = description; _description = description;
} }
public int getId()
{
return _id;
}
public int getPrice()
{
return _price;
}
public final String getType() public final String getType()
{ {
return _type; return _type;

View File

@@ -1,69 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program 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.
*
* This program 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.l2jmobius.gameserver.model.holders;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.model.skills.Skill;
/**
* A generic int/int container.
*/
public class IntIntHolder
{
private int _id;
private int _value;
public IntIntHolder(int id, int value)
{
_id = id;
_value = value;
}
public int getId()
{
return _id;
}
public int getValue()
{
return _value;
}
public void setId(int id)
{
_id = id;
}
public void setValue(int value)
{
_value = value;
}
/**
* @return the L2Skill associated to the id/value.
*/
public final Skill getSkill()
{
return SkillData.getInstance().getSkill(_id, _value);
}
@Override
public String toString()
{
return getClass().getSimpleName() + ": Id: " + _id + ", Value: " + _value;
}
}