Hello I'm trying to create an addon for the quests plugin. When a player casts a spell, an event gets fired. After that, the stage must finish. But I get an error... Code (Java): package com.christophe6.dreamworldcore; import org.bukkit.event.EventHandler; import com.elmakers.mine.bukkit.api.event.CastEvent; import me.blackvein.quests.CustomObjective; public class WandCastObjective extends CustomObjective { public WandCastObjective() { this.setName("Wand Cast Objective"); this.setAuthor("Christophe6"); this.setEnableCount(true); this.setShowCount(true); this.setCountPrompt("Enter the amount of casts a player must do:"); this.setDisplay("Je moet %count% keer een spreuk uitvoeren."); } @EventHandler public void onCast(CastEvent e){ incrementObjective(e.getMage().getPlayer(), this, 1); } } Code (Text): Could not pass event CastEvent to Quests v2.7.6-b120 org.bukkit.event.EventException at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at com.elmakers.mine.bukkit.spell.BaseSpell.finish(BaseSpell.java:2543) [Magic-6.9.5.jar:?] at com.elmakers.mine.bukkit.action.CastContext.finish(CastContext.java:945) [Magic-6.9.5.jar:?] at com.elmakers.mine.bukkit.action.ActionHandler.start(ActionHandler.java:171) [Magic-6.9.5.jar:?] at com.elmakers.mine.bukkit.spell.ActionSpell.onCast(ActionSpell.java:138) [Magic-6.9.5.jar:?] at com.elmakers.mine.bukkit.spell.BaseSpell.finalizeCast(BaseSpell.java:1306) [Magic-6.9.5.jar:?] at com.elmakers.mine.bukkit.spell.BaseSpell.cast(BaseSpell.java:1185) [Magic-6.9.5.jar:?] at com.elmakers.mine.bukkit.spell.BaseSpell.cast(BaseSpell.java:980) [Magic-6.9.5.jar:?] at com.elmakers.mine.bukkit.spell.BaseSpell.cast(BaseSpell.java:1799) [Magic-6.9.5.jar:?] at com.elmakers.mine.bukkit.wand.Wand.cast(Wand.java:3591) [Magic-6.9.5.jar:?] at com.elmakers.mine.bukkit.wand.Wand.cast(Wand.java:3569) [Magic-6.9.5.jar:?] at com.elmakers.mine.bukkit.wand.Wand.performAction(Wand.java:4861) [Magic-6.9.5.jar:?] at com.elmakers.mine.bukkit.magic.listener.PlayerController.onPlayerInteract(PlayerController.java:538) [Magic-6.9.5.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at org.bukkit.craftbukkit.v1_11_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:234) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at org.bukkit.craftbukkit.v1_11_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:201) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at org.bukkit.craftbukkit.v1_11_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:197) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at net.minecraft.server.v1_11_R1.PlayerConnection.a(PlayerConnection.java:1392) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at net.minecraft.server.v1_11_R1.PacketPlayInArmAnimation.a(PacketPlayInArmAnimation.java:24) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at net.minecraft.server.v1_11_R1.PacketPlayInArmAnimation.a(PacketPlayInArmAnimation.java:1) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at net.minecraft.server.v1_11_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_121] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_121] at net.minecraft.server.v1_11_R1.SystemUtils.a(SourceFile:46) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:747) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121] Caused by: java.lang.NoSuchMethodError: com.christophe6.dreamworldcore.WandCastObjective.incrementObjective(Lorg/bukkit/entity/Player;Lme/blackvein/quests/CustomObjective;I)V at com.christophe6.dreamworldcore.WandCastObjective.onCast(WandCastObjective.java:22) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot-1.11.2.jar:git-Spigot-9ba269b-c19c293] ... 38 more
It's not broke, but you may need to update. The API (for a long while now) was changed to allow multiple active quests, because of this you have to pass the current Quest when incrementing an objective, like this: Code (Text): incrementObjective(player, this, 1, quest); See here for a working example, if you like: https://github.com/elBukkit/MagicQu...ne/bukkit/magicquests/SpellCastObjective.java And here for current versions of Quests to build against: https://github.com/elBukkit/MagicQuests/blob/master/pom.xml#L62
@NathanWolf Thank you for your reply! I saw you forked the quests plugin. Can I download it because we're currently using a buggy version. How would I use MagicQuests and where can I download it? EDIT: I can't seem to find a download link for a current version of quests.
FlyingPikachu's version is probably more up to date than my fork: https://www.spigotmc.org/resources/quests.3711/ Is that not what you're using? MagicQuests is my own quests module, you probably don't want it unless you happen to be using my Magic plugin
I'm using your Magic plugin and that's the reason why I wrote that peace of code. Can I have a download?
Oh lol! Heh sorry, I did recognize your name .. but yeah. http://jenkins.elmakers.com/view/Su...com.elmakers.mine.bukkit.plugins$MagicQuests/ EDIT: I'm completely facepalming now that I didn't even recognize my own package name in your code ... ugh sorry!
I tried to add your Spell Cast Objective. But when I start the quest, I can't proceed after casting Vermillious. (I added "Vermillious" as spell and cast count 1)
Hm.. well I haven't honestly used it in a while but I think it should still be working. Try "/mage debug 8" while on the quest, then cast the spell and see what it says in your chat. Should be a bunch of debug info from the quests module.
@NathanWolf This is a part of my config file: Code (Text): custom-objectives: custom1: name: Magic Spell Cast count: 1 data: Spell: Vermillious When I cast Vermillious this is the output: Action DamageAction: Skipped requires entity target Result changed from no_action to no_target Finish Vermillious: no_target Cast Vermillious from 2868,61,-1035: no_target(false) Do you know what's wrong? EDIT: This is the console output although everything seems good: Code (Text): [16:05:42 INFO]: [Quests] Enabling Quests v2.7.6-b120 [16:05:42 INFO]: [Quests] Loaded Module: Has Active Spell by NathanWolf [16:05:42 INFO]: [Quests] Loaded Module: Holding Magic Wand by NathanWolf [16:05:42 INFO]: [Quests] Loaded Module: Add Magic Spell by NathanWolf [16:05:42 INFO]: [Quests] Registered events for custom objective "Add Magic Spell" [16:05:42 INFO]: [Quests] Loaded Module: Craft Magic Wand by NathanWolf [16:05:42 INFO]: [Quests] Registered events for custom objective "Craft Magic Wand" [16:05:42 INFO]: [Quests] Loaded Module: Magic Brush by NathanWolf [16:05:42 INFO]: [Quests] Loaded Module: Magic Item by NathanWolf [16:05:42 INFO]: [Quests] Loaded Module: Kill Magic Mob by NathanWolf [16:05:42 INFO]: [Quests] Registered events for custom objective "Kill Magic Mob" [16:05:42 INFO]: [Quests] Loaded Module: Magic Loot by NathanWolf [16:05:42 INFO]: [Quests] Loaded Module: Magic Skill Points by NathanWolf [16:05:42 INFO]: [Quests] Loaded Module: Magic Spell by NathanWolf [16:05:42 INFO]: [Quests] Loaded Module: Magic Upgrade by NathanWolf [16:05:42 INFO]: [Quests] Loaded Module: Magic Wand by NathanWolf [16:05:42 INFO]: [Quests] Loaded Module: Has Wand Path by NathanWolf [16:05:42 INFO]: [Quests] Loaded Module: Magic Spell Cast by NathanWolf [16:05:42 INFO]: [Quests] Registered events for custom objective "Magic Spell Cast" [16:05:42 INFO]: [Quests] Loaded Module: Has Cast Magic Spell by NathanWolf [16:05:42 INFO]: [Quests] Loaded Module: Spell Cast by NathanWolf [16:05:42 INFO]: [Quests] Loaded Module: Magic Spell Upgrade by NathanWolf [16:05:42 INFO]: [Quests] Registered events for custom objective "Magic Spell Upgrade" [16:05:42 INFO]: [Quests] Loaded Module: Has Magic Wand by NathanWolf ANOTHER EDIT: I think I found why your code isn't working. Quester quester = Quests.getInstance().getQuester(player.getUniqueId()); doesn't work and must contain a string in my version? Is that possible? I had some issues with the download of the quests plugin too? Maybe I have an old version? The download link seems broken...
Ah- well you have to hit something with the spell for it to count! Try shooting at a mob and see if it increments the objective? "no_target" in debug info means you didn't hit something. Works the same way as SP gain, can't just spam the spell, it requires a successful cast. I think the API you're working with is outdated- Quests API was changed from a String (player name) to UUID a long time ago to avoid issues with players changing IGN.
@NathanWolf I'm using the built in api of quests... the download links seems to be broken... Do you know a working link or your Quests version download?
I use Maven- if you do as well you can copy the pom info I linked a few posts ago. Otherwise I don't really know- guess you could just download it from the Maven repo?
@NathanWolf It's perfectly working when casting on mobs but not on npc's. I just want to go to the next stage whenever Vermillious is cast even if there isn't a target. Is that possible?
No, spells in general don't count unless it's a successful cast. If you'd like spells to work on NPCs, add this to spells.yml: Code (Text): default: parameters: target_npc: true EDIT: Or if you really want, you can fork the MagicQuests module and change the way that works. Basically just remove the line that checks for success and built it: https://github.com/elBukkit/MagicQu...ukkit/magicquests/SpellCastObjective.java#L37