Converted all item -> withnpc plugins to listeners
This commit is contained in:
@@ -117,11 +117,7 @@ enum class Bones
|
||||
for (i in bones.keys) {
|
||||
list.add(i)
|
||||
}
|
||||
val array = IntArray(list.size)
|
||||
for (i in list.indices) {
|
||||
array[i] = list[i]
|
||||
}
|
||||
return array
|
||||
return list.toIntArray()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
package core.game.interaction.item.withnpc;
|
||||
|
||||
import org.rs09.consts.Items;
|
||||
import core.game.interaction.NodeUsageEvent;
|
||||
import core.game.interaction.UseWithHandler;
|
||||
import core.game.node.entity.npc.NPC;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.map.zone.ZoneBorders;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Represents the plugin used to "poison" King Arthur.
|
||||
* @author afaroutdude
|
||||
*/
|
||||
@Initializable
|
||||
public final class ForestersArmsCiderPlugin extends UseWithHandler {
|
||||
private static final Item CIDER = new Item(Items.CIDER_5763);
|
||||
|
||||
/**
|
||||
* Constructs a new {@code LadyKeliRopePlugin} {@code Object}.
|
||||
*/
|
||||
public ForestersArmsCiderPlugin() {
|
||||
super(Items.CIDER_5763);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
int[] ids = {1,2,3,4,5};
|
||||
for (int id : ids) {
|
||||
addHandler(id, NPC_TYPE, this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (!new ZoneBorders(2689, 3488, 2700, 3498, 0).insideBorder(player)) {
|
||||
return true;
|
||||
}
|
||||
final NPC npc = event.getUsedWith() instanceof NPC ? event.getUsedWith().asNpc() : null;
|
||||
if (npc != null) {
|
||||
player.getDialogueInterpreter().open(npc.getId(), npc, CIDER);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
package core.game.interaction.item.withnpc;
|
||||
|
||||
import core.game.interaction.NodeUsageEvent;
|
||||
import core.game.interaction.UseWithHandler;
|
||||
import core.game.node.entity.npc.NPC;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.quest.Quest;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.system.task.Pulse;
|
||||
import rs09.game.world.World;
|
||||
import core.game.world.map.Location;
|
||||
import core.game.world.map.path.Path;
|
||||
import core.game.world.map.path.Pathfinder;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Represents the plugin used to handle the use with interactions.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class GertrudeCatUsePlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Represents the animation of bending down.
|
||||
*/
|
||||
private static final Animation BEND_DOWN = Animation.create(827);
|
||||
|
||||
/**
|
||||
* Represents the empty bucket.
|
||||
*/
|
||||
private static final Item EMPTY_BUCKET = new Item(1925);
|
||||
|
||||
/**
|
||||
* Constructs a new {@code GertrudeCatUsePlugin} {@code Object}.
|
||||
*/
|
||||
public GertrudeCatUsePlugin() {
|
||||
super(1927, 1552, 327, 13236);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
addHandler(2997, NPC_TYPE, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final NPC npc = ((NPC) event.getUsedWith());
|
||||
final Quest quest = player.getQuestRepository().getQuest("Gertrude's Cat");
|
||||
if (event.getUsedItem().getId() == 1927 && quest.getStage(player) == 20) {
|
||||
if (player.getInventory().remove(event.getUsedItem())) {
|
||||
player.getInventory().add(EMPTY_BUCKET);
|
||||
player.animate(BEND_DOWN);
|
||||
npc.sendChat("Mew!");
|
||||
quest.setStage(player, 30);
|
||||
}
|
||||
} else if (event.getUsedItem().getId() == 1552 && quest.getStage(player) == 30) {
|
||||
if (player.getInventory().remove(event.getUsedItem())) {
|
||||
player.animate(BEND_DOWN);
|
||||
npc.sendChat("Mew!");
|
||||
quest.setStage(player, 40);
|
||||
}
|
||||
} else if (event.getUsedItem().getId() == 327 && quest.getStage(player) == 50) {
|
||||
player.getDialogueInterpreter().sendDialogue("The cat doesn't seem interested in that.");
|
||||
} else if (event.getUsedItem().getId() == 13236) {
|
||||
if (player.getInventory().remove(event.getUsedItem())) {
|
||||
quest.setStage(player, 60);
|
||||
player.lock(5);
|
||||
World.getPulser().submit(new Pulse(1) {
|
||||
int count = 0;
|
||||
final NPC kitten = NPC.create(761, player.getLocation());
|
||||
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
switch (count) {
|
||||
case 0:
|
||||
kitten.init();
|
||||
kitten.face(npc);
|
||||
npc.face(kitten);
|
||||
npc.sendChat("Pur...");
|
||||
kitten.sendChat("Pur...");
|
||||
final Path path = Pathfinder.find(npc, new Location(3310, 3510, 1));
|
||||
path.walk(npc);
|
||||
final Path pathh = Pathfinder.find(kitten, new Location(3310, 3510, 1));
|
||||
pathh.walk(kitten);
|
||||
break;
|
||||
case 5:
|
||||
kitten.clear();
|
||||
player.setAttribute("hidefluff", System.currentTimeMillis() + 60000);
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
return count == 6;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
package core.game.interaction.item.withnpc;
|
||||
|
||||
import org.rs09.consts.Items;
|
||||
import core.game.interaction.NodeUsageEvent;
|
||||
import core.game.interaction.UseWithHandler;
|
||||
import core.game.node.entity.npc.NPC;
|
||||
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 "poison" King Arthur.
|
||||
* @author afaroutdude
|
||||
*/
|
||||
@Initializable
|
||||
public final class KingArthurPoisonChalicePlugin extends UseWithHandler {
|
||||
private static final Item POISON_CHALICE = new Item(Items.POISON_CHALICE_197);
|
||||
|
||||
/**
|
||||
* Constructs a new {@code LadyKeliRopePlugin} {@code Object}.
|
||||
*/
|
||||
public KingArthurPoisonChalicePlugin() {
|
||||
super(POISON_CHALICE.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
addHandler(251, NPC_TYPE, this);
|
||||
return new KingArthurPoisonChalicePlugin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final NPC npc = event.getUsedWith() instanceof NPC ? event.getUsedWith().asNpc() : null;
|
||||
if (npc != null) {
|
||||
player.getDialogueInterpreter().open(npc.getId(), npc, POISON_CHALICE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package core.game.interaction.item.withnpc;
|
||||
|
||||
import core.game.interaction.NodeUsageEvent;
|
||||
import core.game.interaction.UseWithHandler;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.quest.Quest;
|
||||
import core.game.node.item.Item;
|
||||
import rs09.game.world.World;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Represents the plugin used to tie up lady keli.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class LadyKeliRopePlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Represents the rope item.
|
||||
*/
|
||||
private static final Item ROPE = new Item(954);
|
||||
|
||||
/**
|
||||
* Constructs a new {@code LadyKeliRopePlugin} {@code Object}.
|
||||
*/
|
||||
public LadyKeliRopePlugin() {
|
||||
super(954);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
addHandler(919, NPC_TYPE, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final Quest quest = player.getQuestRepository().getQuest("Prince Ali Rescue");
|
||||
if (quest.getStage(player) >= 40 && player.getAttribute("guard-drunk", false) && quest.getStage(player) != 100) {
|
||||
if (player.getInventory().remove(ROPE)) {
|
||||
player.getDialogueInterpreter().sendDialogue("You overpower Keli, tie her up, and put her in a cupboard.");
|
||||
quest.setStage(player, 50);
|
||||
player.setAttribute("keli-gone", World.getTicks() + 350);
|
||||
}
|
||||
} else {
|
||||
if (quest.getStage(player) == 40) {
|
||||
player.getPacketDispatch().sendMessage("You need to do something about the guard first.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package core.game.interaction.item.withnpc;
|
||||
|
||||
import core.game.interaction.NodeUsageEvent;
|
||||
import core.game.interaction.UseWithHandler;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Represents the needle on a cow plugin.
|
||||
* @author 'Vexia
|
||||
* @date 18/11/2013
|
||||
*/
|
||||
@Initializable
|
||||
public class NeedleCowPlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Constructs a new {@code NeedleCowPlugin} {@code Object}.
|
||||
*/
|
||||
public NeedleCowPlugin() {
|
||||
super(1733);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
addHandler(81, NPC_TYPE, this);
|
||||
addHandler(397, NPC_TYPE, this);
|
||||
addHandler(955, NPC_TYPE, this);
|
||||
addHandler(1691, NPC_TYPE, this);
|
||||
addHandler(1766, NPC_TYPE, this);
|
||||
addHandler(1767, NPC_TYPE, this);
|
||||
addHandler(1768, NPC_TYPE, this);
|
||||
addHandler(1886, NPC_TYPE, this);
|
||||
addHandler(1998, NPC_TYPE, this);
|
||||
addHandler(1999, NPC_TYPE, this);
|
||||
addHandler(2000, NPC_TYPE, this);
|
||||
addHandler(2310, NPC_TYPE, this);
|
||||
addHandler(3309, NPC_TYPE, this);
|
||||
addHandler(5210, NPC_TYPE, this);
|
||||
addHandler(5211, NPC_TYPE, this);
|
||||
addHandler(5603, NPC_TYPE, this);
|
||||
addHandler(7484, NPC_TYPE, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
event.getPlayer().getPacketDispatch().sendMessage("The cow doesn't want that.");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package core.game.interaction.item.withnpc;
|
||||
|
||||
import core.game.interaction.NodeUsageEvent;
|
||||
import core.game.interaction.UseWithHandler;
|
||||
import core.game.node.entity.npc.NPC;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.diary.DiaryType;
|
||||
import core.game.node.item.Item;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Handles the bones on stray dogs plugin.
|
||||
* @author Vexia
|
||||
*/
|
||||
@Initializable
|
||||
public class StrayDogBonesPlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* The dog ids.
|
||||
*/
|
||||
private static final int[] DOGS = new int[] { 4766, 4767, 5917, 5918 };
|
||||
|
||||
/**
|
||||
* Constructs a new {@code StrayDogBonesPlugin} {@code Object}
|
||||
*/
|
||||
public StrayDogBonesPlugin() {
|
||||
super(526, 528, 530, 532, 534, 536, 2530, 2859, 3123, 3125, 3127, 3128, 3129, 3130, 3131, 3132, 3133, 3179, 3180, 3181, 3182, 3183, 3185, 3186, 3187, 4812, 4830, 4832, 4834, 6729, 6812, 11806);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
for (int id : DOGS) {
|
||||
addHandler(id, NPC_TYPE, this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
final Item item = event.getUsedItem();
|
||||
final Player player = event.getPlayer();
|
||||
final NPC npc = event.getUsedWith().asNpc();
|
||||
if (player.getInventory().remove(item)) {
|
||||
player.sendMessage("You feed your dog bones.");
|
||||
npc.sendChat("Woof");
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.VARROCK, 0, 8);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user