use of net.aufdemrand.denizen.events.bukkit.ListenerFinishEvent in project Denizen-For-Bukkit by DenizenScript.
the class ListenerRegistry method finish.
/**
* Finishes a listener, effectively removing and destroying the instance, but
* calls the optional finish_script and bukkit/world script events associated.
*
* @param player the dPlayer
* @param npc dNPC attached from the listen command (can be null)
* @param id id of the listener
* @param on_finish dScript to run on finish
*/
public void finish(dPlayer player, dNPC npc, String id, dScript on_finish) {
if (player == null || id == null) {
return;
}
// Remove listener instance from the player
removeListenerFor(player, id);
// Run finish script
if (on_finish != null) {
try {
// TODO: Add context to this
((TaskScriptContainer) on_finish.getContainer()).runTaskScript(new BukkitScriptEntryData(player, npc), null);
} catch (Exception e) {
// Hm, not a valid task script?
dB.echoError("Tried to run the finish task for: " + id + "/" + player.getName() + "," + "but it seems not to be valid!");
}
}
Bukkit.getPluginManager().callEvent(new ListenerFinishEvent(player, id));
}
Aggregations