mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-21 09:02:07 -07:00
moved bone on loader usewithhandler to BoneGrinderListener.kt
This commit is contained in:
parent
6f23a5ed2f
commit
5f70aa801c
3 changed files with 14 additions and 52 deletions
|
|
@ -2,15 +2,13 @@ package core.game.content.zone.phasmatys;
|
||||||
|
|
||||||
import core.game.content.global.Bones;
|
import core.game.content.global.Bones;
|
||||||
import core.game.content.global.action.ClimbActionHandler;
|
import core.game.content.global.action.ClimbActionHandler;
|
||||||
import core.game.node.entity.skill.Skills;
|
|
||||||
import core.game.node.entity.skill.agility.AgilityHandler;
|
|
||||||
import core.game.interaction.NodeUsageEvent;
|
|
||||||
import core.game.interaction.Option;
|
import core.game.interaction.Option;
|
||||||
import core.game.interaction.UseWithHandler;
|
|
||||||
import core.game.node.Node;
|
import core.game.node.Node;
|
||||||
import core.game.node.entity.Entity;
|
import core.game.node.entity.Entity;
|
||||||
import core.game.node.entity.npc.NPC;
|
import core.game.node.entity.npc.NPC;
|
||||||
import core.game.node.entity.player.Player;
|
import core.game.node.entity.player.Player;
|
||||||
|
import core.game.node.entity.skill.Skills;
|
||||||
|
import core.game.node.entity.skill.agility.AgilityHandler;
|
||||||
import core.game.node.item.Item;
|
import core.game.node.item.Item;
|
||||||
import core.game.node.object.GameObject;
|
import core.game.node.object.GameObject;
|
||||||
import core.game.node.object.ObjectBuilder;
|
import core.game.node.object.ObjectBuilder;
|
||||||
|
|
@ -21,12 +19,10 @@ import core.game.world.map.zone.MapZone;
|
||||||
import core.game.world.map.zone.ZoneBorders;
|
import core.game.world.map.zone.ZoneBorders;
|
||||||
import core.game.world.map.zone.ZoneBuilder;
|
import core.game.world.map.zone.ZoneBuilder;
|
||||||
import core.game.world.update.flag.context.Animation;
|
import core.game.world.update.flag.context.Animation;
|
||||||
import core.plugin.Plugin;
|
|
||||||
import core.plugin.Initializable;
|
import core.plugin.Initializable;
|
||||||
|
import core.plugin.Plugin;
|
||||||
import rs09.plugin.PluginManager;
|
import rs09.plugin.PluginManager;
|
||||||
|
|
||||||
import static java.lang.Thread.sleep;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the phasmatyz zone area.
|
* Handles the phasmatyz zone area.
|
||||||
*
|
*
|
||||||
|
|
@ -52,7 +48,6 @@ public final class PhasmatysZone extends MapZone implements Plugin<Object> {
|
||||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||||
ZoneBuilder.configure(this);
|
ZoneBuilder.configure(this);
|
||||||
PluginManager.definePlugin(new GravingasNPC());
|
PluginManager.definePlugin(new GravingasNPC());
|
||||||
PluginManager.definePlugin(new BoneLoaderHandler());
|
|
||||||
PluginManager.definePlugin(new NecrovarusDialogue());
|
PluginManager.definePlugin(new NecrovarusDialogue());
|
||||||
PluginManager.definePlugin(new GhostSailorDialogue());
|
PluginManager.definePlugin(new GhostSailorDialogue());
|
||||||
PluginManager.definePlugin(new EctoplasmFillPlugin());
|
PluginManager.definePlugin(new EctoplasmFillPlugin());
|
||||||
|
|
@ -383,49 +378,6 @@ public final class PhasmatysZone extends MapZone implements Plugin<Object> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles the bone loader.
|
|
||||||
*
|
|
||||||
* @author Vexia
|
|
||||||
*/
|
|
||||||
public static final class BoneLoaderHandler extends UseWithHandler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new {@code BoneLoaderHandler} {@code Object}.
|
|
||||||
*/
|
|
||||||
public BoneLoaderHandler() {
|
|
||||||
super(Bones.getArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
|
||||||
addHandler(11162, OBJECT_TYPE, this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(NodeUsageEvent event) {
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
final GameObject object = (GameObject) event.getUsedWith();
|
|
||||||
final Bones bone = Bones.forId(event.getUsedItem().getId());
|
|
||||||
if (hasBones(player, object, true)) {
|
|
||||||
player.sendMessage("There are already some bones in the grinder's hopper.");
|
|
||||||
return true;
|
|
||||||
} else if (hasBones(player, object, false)) {
|
|
||||||
player.sendMessage("You need to empty the grinder's bin before you put more bones in it.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (player.getInventory().remove(event.getUsedItem())) {
|
|
||||||
player.lock(2);
|
|
||||||
player.animate(Animation.create(1649));
|
|
||||||
player.getConfigManager().set(408, bone.getConfigValue(true), true);
|
|
||||||
player.sendMessage("You put some bones in the grinder's hopper.", 1);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object fireEvent(String identifier, Object... args) {
|
public Object fireEvent(String identifier, Object... args) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ private val SCOOP_ANIM = Animation(1650)
|
||||||
|
|
||||||
class BoneGrinderListener : InteractionListener() {
|
class BoneGrinderListener : InteractionListener() {
|
||||||
|
|
||||||
|
val boneIDs = Bones.values().map { it.itemId }.toIntArray()
|
||||||
|
|
||||||
override fun defineListeners() {
|
override fun defineListeners() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -52,6 +54,14 @@ class BoneGrinderListener : InteractionListener() {
|
||||||
handleEmpty(player)
|
handleEmpty(player)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Bone -> Hopper
|
||||||
|
*/
|
||||||
|
on(OBJECT,LOADER,*boneIDs){player,_,_ ->
|
||||||
|
handleFill(player)
|
||||||
|
return@on true
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleFill(player: Player): Boolean{
|
fun handleFill(player: Player): Boolean{
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ object Listeners {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun add(type: Int, used: Int, with: IntArray, method: (Player, Node, Node) -> Boolean){
|
fun add(type: Int, used: Int, with: IntArray, method: (Player, Node, Node) -> Boolean){
|
||||||
for(id in with){
|
for(id in with){
|
||||||
useWithListeners["$used:$with:$type"] = method
|
useWithListeners["$used:$id:$type"] = method
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue