mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-21 09:02:07 -07:00
Updated CauldronOfThunder plugin to listener
This commit is contained in:
parent
22b7b7ab98
commit
eae259d2ec
2 changed files with 45 additions and 58 deletions
|
|
@ -1,58 +0,0 @@
|
||||||
package core.game.interaction.item.withobject;
|
|
||||||
|
|
||||||
import core.game.interaction.NodeUsageEvent;
|
|
||||||
import core.game.interaction.UseWithHandler;
|
|
||||||
import core.game.node.item.Item;
|
|
||||||
import core.game.world.update.flag.context.Animation;
|
|
||||||
import core.plugin.Initializable;
|
|
||||||
import core.plugin.Plugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the plugin handler used for with the cauldron of thunder.
|
|
||||||
* @author 'Vexia
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
@Initializable
|
|
||||||
public final class CauldronOfThunder extends UseWithHandler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the animation to use.
|
|
||||||
*/
|
|
||||||
private static final Animation ANIMATION = new Animation(833);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the enchanted items.
|
|
||||||
*/
|
|
||||||
private static final Item[] ITEMS = new Item[] { new Item(524, 1), new Item(522, 1), new Item(523, 1), new Item(525, 1) };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new {@code CauldronOfThunder} {@code Object}.
|
|
||||||
*/
|
|
||||||
public CauldronOfThunder() {
|
|
||||||
super(2136, 2132, 2134, 2138);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
|
||||||
addHandler(2142, OBJECT_TYPE, this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(NodeUsageEvent event) {
|
|
||||||
event.getPlayer().animate(ANIMATION);
|
|
||||||
event.getPlayer().getInventory().remove(event.getUsedItem());
|
|
||||||
if (event.getUsedItem().getId() == 2136) {
|
|
||||||
event.getPlayer().getInventory().add(ITEMS[0]);
|
|
||||||
} else if (event.getUsedItem().getId() == 2132) {
|
|
||||||
event.getPlayer().getInventory().add(ITEMS[1]);
|
|
||||||
} else if (event.getUsedItem().getId() == 2134) {
|
|
||||||
event.getPlayer().getInventory().add(ITEMS[2]);
|
|
||||||
} else if (event.getUsedItem().getId() == 2138) {
|
|
||||||
event.getPlayer().getInventory().add(ITEMS[3]);
|
|
||||||
}
|
|
||||||
event.getPlayer().getPacketDispatch().sendMessage("You dip the " + event.getUsedItem().getName().toLowerCase() + " in the cauldron.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
package rs09.game.interaction.item.withobject
|
||||||
|
|
||||||
|
import api.addItem
|
||||||
|
import api.animate
|
||||||
|
import api.removeItem
|
||||||
|
import api.sendMessage
|
||||||
|
import core.game.world.update.flag.context.Animation
|
||||||
|
import org.rs09.consts.Items
|
||||||
|
import org.rs09.consts.Scenery
|
||||||
|
import rs09.game.interaction.IntType
|
||||||
|
import rs09.game.interaction.InteractionListener
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener for Cauldron of Thunder interaction
|
||||||
|
* @author Byte
|
||||||
|
*/
|
||||||
|
@Suppress("unused")
|
||||||
|
class CauldronOfThunderListener : InteractionListener {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val ANIMATION = Animation(833)
|
||||||
|
|
||||||
|
private val ITEM_MAP = mapOf(
|
||||||
|
Items.RAW_BEEF_2132 to Items.ENCHANTED_BEEF_522,
|
||||||
|
Items.RAW_RAT_MEAT_2134 to Items.ENCHANTED_RAT_MEAT_523,
|
||||||
|
Items.RAW_BEAR_MEAT_2136 to Items.ENCHANTED_BEAR_MEAT_524,
|
||||||
|
Items.RAW_CHICKEN_2138 to Items.ENCHANTED_CHICKEN_525
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun defineListeners() {
|
||||||
|
onUseWith(IntType.SCENERY, ITEM_MAP.keys.toIntArray(), Scenery.CAULDRON_OF_THUNDER_2142) { player, used, _ ->
|
||||||
|
if (!removeItem(player, used)) {
|
||||||
|
return@onUseWith false
|
||||||
|
}
|
||||||
|
|
||||||
|
animate(player, ANIMATION)
|
||||||
|
addItem(player, ITEM_MAP[used.id]!!)
|
||||||
|
sendMessage(player, "You dip the " + used.name.lowercase(Locale.getDefault()) + " in the cauldron.")
|
||||||
|
|
||||||
|
return@onUseWith true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue