diff --git a/Server/build.gradle b/Server/build.gradle index 720fa2833..547596519 100644 --- a/Server/build.gradle +++ b/Server/build.gradle @@ -26,7 +26,7 @@ dependencies { implementation group: 'com.moandjiezana.toml', name: 'toml4j', version: '0.7.2' implementation files( "libs/PrimitiveExtensions-1.0.jar", - "libs/ConstLib-1.3.jar", + "libs/ConstLib-1.4.jar", "libs/json-simple-1.1.1.jar", "libs/markdown-jvm-0.2.4.jar", "libs/classgraph-4.8.98.jar", diff --git a/Server/libs/ConstLib-1.3.jar b/Server/libs/ConstLib-1.4.jar similarity index 53% rename from Server/libs/ConstLib-1.3.jar rename to Server/libs/ConstLib-1.4.jar index c46ffc6e9..0e948625a 100644 Binary files a/Server/libs/ConstLib-1.3.jar and b/Server/libs/ConstLib-1.4.jar differ diff --git a/Server/src/main/java/core/game/interaction/item/ToyHorsePlugin.java b/Server/src/main/java/core/game/interaction/item/ToyHorsePlugin.java deleted file mode 100644 index d32d7c8bf..000000000 --- a/Server/src/main/java/core/game/interaction/item/ToyHorsePlugin.java +++ /dev/null @@ -1,48 +0,0 @@ -package core.game.interaction.item; - -import core.cache.def.impl.ItemDefinition; -import core.game.interaction.OptionHandler; -import core.game.node.Node; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; -import core.game.world.update.flag.context.Animation; -import core.plugin.Plugin; -import core.plugin.Initializable; -import core.tools.RandomFunction; - -/** - * Handles the option for the toy horse. - * @author Vexia - */ -@Initializable -public class ToyHorsePlugin extends OptionHandler { - - /** - * The force chat's you can say. - */ - private static final String CHATS[] = { "Come-on Dobbin, we can win the race!", "Hi-ho Silver, and away!", "Neaahhhyyy!" }; - - @Override - public boolean handle(Player player, Node node, String option) { - player.lock(2); - int id = ((Item) node).getId(); - int anim = id == 2524 ? 920 : id == 2526 ? 921 : id == 2522 ? 919 : 918; - player.animate(new Animation(anim)); - player.sendChat(CHATS[RandomFunction.random(CHATS.length)]); - return true; - } - - @Override - public boolean isWalk() { - return false; - } - - @Override - public Plugin newInstance(Object arg) throws Throwable { - int[] ids = new int[] { 2524, 2526, 2522 }; - for (int id : ids) { - ItemDefinition.forId(id).getHandlers().put("play-with", this); - } - return this; - } -} diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/ToyHorseyListener.kt b/Server/src/main/kotlin/rs09/game/interaction/item/ToyHorseyListener.kt new file mode 100644 index 000000000..6938257a2 --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/interaction/item/ToyHorseyListener.kt @@ -0,0 +1,40 @@ +package rs09.game.interaction.item + +import api.animate +import api.sendChat +import api.stopWalk +import org.rs09.consts.Animations +import org.rs09.consts.Items +import rs09.game.interaction.InteractionListener + +/** + * Interaction listener for the Toy Horsey item + * @author Woah + */ +class ToyHorseListener : InteractionListener() { + + // Map of horse item ids to their correct emote + val HORSEY_MAP = mapOf( + Items.TOY_HORSEY_2520 to Animations.HUMAN_PLAY_WITH_BROWN_HORSE_918, + Items.TOY_HORSEY_2522 to Animations.HUMAN_PLAY_WITH_WHITE_HORSE_919, + Items.TOY_HORSEY_2524 to Animations.HUMAN_PLAY_WITH_BLACK_HORSE_920, + Items.TOY_HORSEY_2526 to Animations.HUMAN_PLAY_WITH_GRAY_HORSE_921 + ) + + // Array of phrases used during the interaction + val PHRASES = arrayOf( + "Come-on Dobbin, we can win the race!", + "Hi-ho Silver, and away", + "Neaahhhyyy! Giddy-up horsey!" + ) + + override fun defineListeners() { + on(HORSEY_MAP.keys.toIntArray(), ITEM, "play-with") { player, node -> + // "high-priority" interaction, so movement is stopped + stopWalk(player) + animate(player, HORSEY_MAP.get(node.id)) + sendChat(player, PHRASES.random()) + return@on true + } + } +} \ No newline at end of file