Closed Dandielo closed 12 years ago
Not sure I follow the intent of this request.
Are you looking for an event notification system? By this I mean you want to write a plugin, have that plugin register interest in a Denizen, and then be notified of what that Denizen does? There may already be a way to hook into what you want with the basic Bukkit and Citizens APIs.
What he wants is a command that would trigger an event. Dan made a trader character that has a few methods to trade, sell, etc. What he envisions is a script that allows the player to interact with a Denizen, but could also initiate a trade.
Ahh, ok. Now I understand better. I guess we'd just have to check CommandSender to see if it is an instance Player like Denizen does already, and then expose something like /denizen trigger <npc> '<script-name>'
that would lookup the NPC, make sure it is a denizen, and then invoke the named script?
Should these types of scripts be a new kind of Trigger or should any script be allowed to be triggered?
Hmm... interesting though, but I was thinking the other way around, his trader listening for a Denizen event. Like an EVENT [event] script command. His plugin could listen for the Denizen event . EVENT could initiate a custom bukkit event with the information in brackets.
At least I think that can work, haha.
Ok, let me restate to make sure I've got it. Basically there are two parts here. One part is the script part:
'Name of script':
Type: Trigger
...
Steps:
1:
Click Trigger:
Script:
- EVENT This is my custom event data.
And the other is a new custom event we broadcast with Bukkit as so:
// Create the event here with some context, and the event data specified in the script.
DenizenCustomEvent event = new DenizenCustomEvent(thePlayer, theDenizen, eventData);
// Call the event
Bukkit.getServer().getPluginManager().callEvent(event);
// Now you do the event
Bukkit.getServer().broadcastMessage(event.getMessage());
Is that what you were thinking?
And yep! Exactly! That'll work, right?
Good question. Bukkit's wiki mentions custom events, but no word on whether or not other plugins can see them. I'll code up a quick test to validate this.
yeah you can see them like the NPC events build in Citizens2.0 or the Citizens1.2 API where hooking into citizens mainly consisted of event listening, btw would it be of any use to make the events working only for the plugin that made them?
This is addressed in 0.7 which will be available really soon. It features a modular command system. Requirements will be soon.
A way for developers to hook int a comand ;) like an event that will be send to bukkit prividing a command name ;) denizen etc ;)