Updated TutorialFurnace plugin to listener
This commit is contained in:
-54
@@ -1,54 +0,0 @@
|
|||||||
package core.game.interaction.item.withobject;
|
|
||||||
|
|
||||||
import api.events.ResourceProducedEvent;
|
|
||||||
import core.plugin.Initializable;
|
|
||||||
import core.game.node.entity.skill.Skills;
|
|
||||||
import core.game.node.entity.skill.smithing.smelting.Bar;
|
|
||||||
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 org.rs09.consts.Items;
|
|
||||||
import rs09.game.world.GameWorld;
|
|
||||||
import core.game.world.update.flag.context.Animation;
|
|
||||||
import core.plugin.Plugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 'Vexia
|
|
||||||
*/
|
|
||||||
@Initializable
|
|
||||||
public class TutorialFurnaceHandler extends UseWithHandler {
|
|
||||||
public TutorialFurnaceHandler() {
|
|
||||||
super(438, 436);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
|
||||||
addHandler(3044, OBJECT_TYPE, this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(NodeUsageEvent event) {
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
if (player.getInventory().containItems(438, 436)) {
|
|
||||||
player.animate(new Animation(833));
|
|
||||||
GameWorld.getPulser().submit(new Pulse(2) {
|
|
||||||
@Override
|
|
||||||
public boolean pulse() {
|
|
||||||
player.getInventory().remove(new Item(438, 1));
|
|
||||||
player.getInventory().remove(new Item(436, 1));
|
|
||||||
player.getInventory().add(Bar.BRONZE.getProduct());
|
|
||||||
player.getSkills().addExperience(Skills.SMITHING, Bar.BRONZE.getExperience());
|
|
||||||
player.dispatch(new ResourceProducedEvent(Bar.BRONZE.getProduct().getId(), 1, player, Items.COPPER_ORE_436));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package rs09.game.content.tutorial
|
||||||
|
|
||||||
|
import api.*
|
||||||
|
import api.events.ResourceProducedEvent
|
||||||
|
import core.game.node.entity.skill.Skills
|
||||||
|
import core.game.node.entity.skill.smithing.smelting.Bar
|
||||||
|
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 tutorial island furnace
|
||||||
|
* @author Byte
|
||||||
|
*/
|
||||||
|
class TutorialFurnaceListener : InteractionListener {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val ANIMATION = Animation(833)
|
||||||
|
|
||||||
|
private val ORES = intArrayOf(
|
||||||
|
Items.TIN_ORE_438,
|
||||||
|
Items.COPPER_ORE_436
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun defineListeners() {
|
||||||
|
onUseWith(IntType.SCENERY, ORES, Scenery.FURNACE_3044) { player, _, _ ->
|
||||||
|
if (!inInventory(player, Items.TIN_ORE_438) || !inInventory(player, Items.COPPER_ORE_436)) {
|
||||||
|
return@onUseWith true
|
||||||
|
}
|
||||||
|
|
||||||
|
animate(player, ANIMATION)
|
||||||
|
submitIndividualPulse(player, object: Pulse(2) {
|
||||||
|
override fun pulse(): Boolean {
|
||||||
|
removeItem(player, Items.TIN_ORE_438)
|
||||||
|
removeItem(player, Items.COPPER_ORE_436)
|
||||||
|
addItem(player, Items.BRONZE_BAR_2349)
|
||||||
|
rewardXP(player, Skills.SMITHING, Bar.BRONZE.experience)
|
||||||
|
player.dispatch(ResourceProducedEvent(Items.BRONZE_BAR_2349, 1, player, Items.COPPER_ORE_436))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return@onUseWith true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user