mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-09 16:45:44 -07:00
Port NettleTeaPlugin.java and NettleWaterPlugin.java to TeaInteraction.kt
This commit is contained in:
parent
f9a3026fb3
commit
dd444a2bf3
3 changed files with 27 additions and 99 deletions
|
|
@ -1,61 +0,0 @@
|
||||||
package content.global.skill.cooking;
|
|
||||||
|
|
||||||
import core.game.interaction.NodeUsageEvent;
|
|
||||||
import core.game.interaction.UseWithHandler;
|
|
||||||
import core.game.node.entity.player.Player;
|
|
||||||
import core.game.node.item.Item;
|
|
||||||
import core.plugin.Initializable;
|
|
||||||
import core.plugin.Plugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the plugin used to create nettle tea in a cup.
|
|
||||||
* @author 'Vexia
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
@Initializable
|
|
||||||
public final class NettleTeaPlugin extends UseWithHandler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the empty cup item.
|
|
||||||
*/
|
|
||||||
private static final Item EMPTY_CUP = new Item(1980, 1);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the nettle tea item.
|
|
||||||
*/
|
|
||||||
private static final Item NETTLE_TEA = new Item(4239, 1);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the bowl item.
|
|
||||||
*/
|
|
||||||
private static final Item BOWL = new Item(1923);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the cup of tea item.
|
|
||||||
*/
|
|
||||||
private static final Item CUP_OF_TEA = new Item(4242, 1);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new {@code NettleTeaPlugin} {@code Object}.
|
|
||||||
*/
|
|
||||||
public NettleTeaPlugin() {
|
|
||||||
super(1980);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
|
||||||
addHandler(4239, ITEM_TYPE, this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(NodeUsageEvent event) {
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
if (player.getInventory().remove(EMPTY_CUP) && player.getInventory().remove(NETTLE_TEA)) {
|
|
||||||
player.getInventory().add(BOWL);
|
|
||||||
player.getInventory().add(CUP_OF_TEA);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
package content.global.skill.cooking;
|
|
||||||
|
|
||||||
import core.game.interaction.NodeUsageEvent;
|
|
||||||
import core.game.interaction.UseWithHandler;
|
|
||||||
import core.game.node.entity.player.Player;
|
|
||||||
import core.game.node.item.Item;
|
|
||||||
import core.plugin.Initializable;
|
|
||||||
import core.plugin.Plugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Adam
|
|
||||||
*/
|
|
||||||
@Initializable
|
|
||||||
public class NettleWaterPlugin extends UseWithHandler {
|
|
||||||
|
|
||||||
public NettleWaterPlugin() {
|
|
||||||
super(1921);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(NodeUsageEvent event) {
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
player.getInventory().remove(new Item(1921, 1));
|
|
||||||
player.getInventory().remove(new Item(4241, 1));
|
|
||||||
player.getInventory().add(new Item(4237, 1));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
|
||||||
addHandler(4241, ITEM_TYPE, this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
package content.global.skill.cooking
|
package content.global.skill.cooking
|
||||||
|
|
||||||
import core.api.addItem
|
import core.api.addItem
|
||||||
|
import core.api.getDynLevel
|
||||||
import core.api.removeItem
|
import core.api.removeItem
|
||||||
|
import core.api.sendDialogue
|
||||||
import core.game.interaction.InteractionListener
|
import core.game.interaction.InteractionListener
|
||||||
|
import core.game.node.entity.skill.Skills
|
||||||
import org.rs09.consts.Items
|
import org.rs09.consts.Items
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This deals with all tea mixtures
|
* This deals with all tea mixtures
|
||||||
* cup of tea
|
* cup of tea - done
|
||||||
* nettle tea
|
* nettle tea
|
||||||
* nettle water
|
* nettle water
|
||||||
* nettle tea (cup)
|
* nettle tea (cup)
|
||||||
|
|
@ -18,6 +21,7 @@ import org.rs09.consts.Items
|
||||||
*/
|
*/
|
||||||
class TeaInteraction : InteractionListener {
|
class TeaInteraction : InteractionListener {
|
||||||
private val teaMilkMap = mapOf(
|
private val teaMilkMap = mapOf(
|
||||||
|
Items.NETTLE_TEA_4239 to Items.NETTLE_TEA_4240,
|
||||||
Items.CUP_OF_TEA_4242 to Items.CUP_OF_TEA_4243,
|
Items.CUP_OF_TEA_4242 to Items.CUP_OF_TEA_4243,
|
||||||
Items.CUP_OF_TEA_4245 to Items.CUP_OF_TEA_4246,
|
Items.CUP_OF_TEA_4245 to Items.CUP_OF_TEA_4246,
|
||||||
Items.CUP_OF_TEA_7730 to Items.CUP_OF_TEA_7731,
|
Items.CUP_OF_TEA_7730 to Items.CUP_OF_TEA_7731,
|
||||||
|
|
@ -25,6 +29,12 @@ class TeaInteraction : InteractionListener {
|
||||||
Items.CUP_OF_TEA_7736 to Items.CUP_OF_TEA_7737,
|
Items.CUP_OF_TEA_7736 to Items.CUP_OF_TEA_7737,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val teaCupMap = mapOf(
|
||||||
|
Items.NETTLE_TEA_4239 to Items.CUP_OF_TEA_4242,
|
||||||
|
Items.NETTLE_TEA_4240 to Items.CUP_OF_TEA_4246,
|
||||||
|
Items.BOWL_OF_HOT_WATER_4456 to Items.CUP_OF_HOT_WATER_4460
|
||||||
|
)
|
||||||
|
|
||||||
override fun defineListeners() {
|
override fun defineListeners() {
|
||||||
onUseWith(ITEM, teaMilkMap.keys.toIntArray(), Items.BUCKET_OF_MILK_1927){ player, used, with ->
|
onUseWith(ITEM, teaMilkMap.keys.toIntArray(), Items.BUCKET_OF_MILK_1927){ player, used, with ->
|
||||||
if (removeItem(player, used) && removeItem(player, with)){
|
if (removeItem(player, used) && removeItem(player, with)){
|
||||||
|
|
@ -34,12 +44,26 @@ class TeaInteraction : InteractionListener {
|
||||||
return@onUseWith true
|
return@onUseWith true
|
||||||
}
|
}
|
||||||
|
|
||||||
onUseWith(ITEM, Items.BOWL_OF_HOT_WATER_4456, Items.EMPTY_CUP_1980){ player, used, with ->
|
onUseWith(ITEM, teaCupMap.keys.toIntArray(), Items.EMPTY_CUP_1980){ player, used, with ->
|
||||||
|
if (used.id != Items.BOWL_OF_HOT_WATER_4456){
|
||||||
|
if (getDynLevel(player, Skills.COOKING) < 20){
|
||||||
|
sendDialogue(player, "You need a cooking level of 20 to make tea.")
|
||||||
|
return@onUseWith false
|
||||||
|
}
|
||||||
|
}
|
||||||
if (removeItem(player, used) && removeItem(player, with)) {
|
if (removeItem(player, used) && removeItem(player, with)) {
|
||||||
addItem(player, Items.CUP_OF_HOT_WATER_4460)
|
addItem(player, teaCupMap[used.id]!!)
|
||||||
|
addItem(player, Items.BOWL_1923)
|
||||||
}
|
}
|
||||||
return@onUseWith true
|
return@onUseWith true
|
||||||
|
}
|
||||||
|
|
||||||
|
onUseWith(ITEM, Items.BOWL_OF_WATER_1921, Items.NETTLES_4241) { player, used, with ->
|
||||||
|
if (removeItem(player, used) && removeItem(player, with)){
|
||||||
|
addItem(player, Items.NETTLE_WATER_4237)
|
||||||
}
|
}
|
||||||
|
return@onUseWith true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue