Updated EctophialFill plugin to listener
This commit is contained in:
@@ -1,52 +0,0 @@
|
|||||||
package core.game.interaction.item.withobject;
|
|
||||||
|
|
||||||
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.game.system.task.Pulse;
|
|
||||||
import rs09.game.world.GameWorld;
|
|
||||||
import core.game.world.update.flag.context.Animation;
|
|
||||||
import core.plugin.Initializable;
|
|
||||||
import core.plugin.Plugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fills an ectophial.
|
|
||||||
* @author Vexia
|
|
||||||
*/
|
|
||||||
@Initializable
|
|
||||||
public class EctophialFillPlugin extends UseWithHandler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new {@code EctophialFillPlugin} {@code Object}
|
|
||||||
*/
|
|
||||||
public EctophialFillPlugin() {
|
|
||||||
super(4252);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
|
||||||
addHandler(5282, OBJECT_TYPE, this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(NodeUsageEvent event) {
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
player.lock(3);
|
|
||||||
player.animate(Animation.create(1652));
|
|
||||||
player.getAudioManager().send(1132);
|
|
||||||
GameWorld.getPulser().submit(new Pulse(3, player) {
|
|
||||||
@Override
|
|
||||||
public boolean pulse() {
|
|
||||||
if (player.getInventory().remove(new Item(4252))) {
|
|
||||||
player.getInventory().add(new Item(4251));
|
|
||||||
}
|
|
||||||
player.sendMessage("You refill the ectophial from the Ectofuntus.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package rs09.game.interaction.item.withobject
|
||||||
|
|
||||||
|
import api.*
|
||||||
|
import core.game.node.entity.player.link.audio.Audio
|
||||||
|
import core.game.system.task.Pulse
|
||||||
|
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
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener for filling empty ectophial
|
||||||
|
* @author Byte
|
||||||
|
*/
|
||||||
|
@Suppress("unused")
|
||||||
|
class EctophialFillListener : InteractionListener {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val ANIMATION = Animation(1652)
|
||||||
|
private val AUDIO = Audio(1132)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun defineListeners() {
|
||||||
|
onUseWith(IntType.SCENERY, Items.ECTOPHIAL_4252, Scenery.ECTOFUNTUS_5282) { player, used, _ ->
|
||||||
|
lock(player, 5)
|
||||||
|
animate(player, ANIMATION)
|
||||||
|
playAudio(player, AUDIO)
|
||||||
|
|
||||||
|
submitIndividualPulse(player, object: Pulse(3) {
|
||||||
|
override fun pulse(): Boolean {
|
||||||
|
if (removeItem(player, used)) {
|
||||||
|
addItem(player, Items.ECTOPHIAL_4251)
|
||||||
|
sendMessage(player, "You refill the ectophial from the Ectofuntus.")
|
||||||
|
unlock(player)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return@onUseWith true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user