API usage - LeonidMem/DialogsM-Wiki GitHub Wiki

Events

Connected with the dialogs

  • DialogsPreReloadEvent - calls when dialogs' files are going to be loaded.

  • DialogsReloadEvent - calls when dialogs' files were loaded.

  • DialogLoadEvent - calls when a dialog was loaded from the map.

    • getDialogName() - returns loaded dialog's file name.
    • getMap() - returns immutable map from which the dialog was loaded.
  • DialogPreOpenEvent (cancellable) - calls before a dialog was opened to the player.

    • getDialogName() - returns dialog's file name.
    • getPlayer() - returns the player who opened the dialog.
  • DialogOpenEvent - calls when a dialog was opened to the player.

    • getDialogName() - returns dialog's file name.
    • getPlayer() - returns the player who opened the dialog.
  • DialogAddEvent - calls when a dialog was added as read to the player.

    • getDialogName() - returns dialog's file name.
    • getOfflinePlayer() - returns the OfflinePlayer to whom the dialog was added.
  • DialogRemoveEvent - calls when a dialog was removed as read to the player.

    • getDialogName() - returns dialog's file name.
    • getOfflinePlayer() - returns the OfflinePlayer from whom the dialog was removed.

Connected with the quests

  • QuestsPreReloadEvent - calls when quests' files are going to be loaded.

  • QuestsReloadEvent - calls when quests' files were loaded.

  • QuestLoadEvent - calls when a quest was loaded from the map.

    • getQuestName() - returns loaded quest's file name.
    • getMap() - returns immutable map from which the quest was loaded.
  • QuestStartEvent - calls when a quest was added as a quest in progress to the player.

    • getQuestName() - returns quest's file name.
    • getPlayer() - returns the player to whom the quest was added.
  • QuestPreCompleteEvent (cancellable) - calls before a quest was added as completed to the player.

    • getQuestName() - returns quest's file name.
    • getOfflinePlayer() - returns the OfflinePlayer to whom the quest was added.
  • QuestCompleteEvent - calls when a quest was added as completed to the player.

    • getQuestName() - returns quest's file name.
    • getOfflinePlayer() - returns the OfflinePlayer to whom the quest was added.
  • QuestRemoveEvent - calls when a quest was removed as completed or as a quest in progress from the player.

    • getQuestName() - returns quest's file name.
    • getOfflinePlayer() - returns the OfflinePlayer from whom the quest was removed.

Connected with the NPCs

  • NPCsPreReloadEvent - calls when NPCs' files are going to be loaded.

  • NPCsReloadEvent - calls when NPCs' files were loaded.

  • NPCLoadEvent - calls when NPC was loaded from the map.

    • getNpcName() - returns loaded NPC's file name.
    • getNpcUUID() - returns attached entity's uuid.
    • getMap() - returns immutable map from which the NPC was loaded.

Other

  • DialogsConfigReloadEvent - calls when DialogsM's config was reloaded.

DialogsAPI class methods

Get player's data

All methods below return true the if player has a dialog or a quest in needed stage, false if not or value of outIfExceptionOccurred if something went wrong.

  • isDialogRead(Player player, String dialogName, boolean outIfExceptionOccurred)
  • isQuestInProgress(Player player, String dialogName, boolean outIfExceptionOccurred)
  • isQuestCompleted(Player player, String dialogName, boolean outIfExceptionOccurred)

All methods below return list of names which player has in needed stage or value of outIfExceptionOccurred if something went wrong.

  • getReadDialogsNames(Player player, List<String> outIfExceptionOccurred)
  • getQuestsInProgressNames(Player player, List<String> outIfExceptionOccurred)
  • getCompletedQuestsNames(Player player, List<String> outIfExceptionOccurred)

Change player's data

All methods below return true if something changed after method call or false if not.

  • addDialog(OfflinePlayer player, String dialogName)
  • removeDialog(OfflinePlayer player, String dialogName)
  • startQuest(OfflinePlayer player, String dialogName)
  • addQuest(OfflinePlayer player, String dialogName)
  • removeQuest(OfflinePlayer player, String dialogName)

Check

All methods below return true if player fits in needed conditions or false if not.

  • canQuestBeCompleted(Player player, String questName)
  • canDialogBeRead(Player player, String questName)

The method below returns true if entity is a registered NPC.

  • isEntityNPC(UUID uuid)

Load from the map

  • loadDialogFromMap(String fileName, Map<String, Object> map)
  • loadQuestFromMap(String fileName, Map<String, Object> map)
  • loadNPCFromMap(String fileName, Map<String, Object> map)

Register decorators

You can use decorators to create your own conditions for the quests and dialogs. Just implement needed interface: DialogDecorator or QuestDecorator (overriden methods must return true if all conditions fit or false if not) and register it using methods below.

  • registerDecorator(DialogDecorator dialogDecorator)
  • registerDecorator(QuestDecorator questDecorator)
⚠️ **GitHub.com Fallback** ⚠️