Skip to content

API tutorial

Daniel Saukel edited this page Jul 24, 2016 · 13 revisions

Currently very outdated!

Introduction

Welcome to the DungeonsXL API tutorial. The API aims to be as powerful and user-friendly as possible. Please submit issues or pull requests if you think that important methods are missing!

In DungeonsXL 0.11, you'll find many methods without explanation why they are marked as deprecated and without links to supported methods. This is because even though the code has been made a lot more dynamic in 0.10 and 0.11, there is still some work to do. Deprecated methods in DungeonsXL will not stay part of the plugin for legacy reasons. They are still working and in use - the problem is that they are very unlikely to exist or to work the same way in the release version 1.0. This does not mean that methods which are not deprecated are guaranteed to be part of the release, though. Unfortunately, promises are not possible at all, yet.

Important Objects

This list contains some the most important objects you'll probably have to deal with if you create addons for DungeonsXL.

DungeonsXL (main class)

DungeonsXL is the main class of the DungeonsXL plugin. It extends BRPlugin which extends JavaPlugin. Its purpose is to handle things which have to happen when the plugin loads and to initialize and store objects.

Players

There are some different representations of a player. The DPlayers class handles it.

The main representation for all players that are online.

Extends DGlobalPlayer.

Represents players who edit a map.

Currently not in use.

Extends DGlobalPlayer.

Represents players who play a dungeon.

Deprecated: Also represents players who edit a map.

A DPlayer contains a DSavePlayer object.

Represents players saved in the savePlayers.yml file, usually because they are in a dungeon. Therefore, DSavePlayer is a bridge to make a DPlayer persistent.

A collection of _DPlayer_s who are a team in a dungeon.

Primarily, a Game is a collection of _DGroup_s.

A Game also has a GameType. GameType is an interface and its implementation is an enum called GameTypeDefault. A game type defines some game rules additionally to those configured in the configs. _GameType_s allow admins to easily use a map for different purposes.

A GameWorld is the representation of a played map. A GameWorld may or may not have a running Game.

Configs

TO DO

TO DO

TO DO

TO DO

Events

DungeonsXL provides a feature-rich event system to allow you to hook into its actions as good as possible.

DGroup events

TO DO

DMob events

TO DO

DPlayer events

TO DO

DSign events

TO DO

EditWorld events

TO DO

GameWorld events

TO DO

Requirement events

TO DO

Reward events

TO DO

Trigger events

TO DO

Creating custom contents

This topic shows you examples how to create common custom contents with the DXL API.

Commands

DungeonsXL uses the command API provided by BRCommons. Therefore, creating custom subcommands to /dxl is simple. Just create a new class which extends BRCommand, like, for example, this one. Then, add this to your onEnable() method in the main class:

@Override
public void onEnable() {
    BRCommands dCommands = DungeonsXL.getInstance().getCommands();
    dCommands.addCommand(new MyCommandExtendsBRCommand());
    dCommands.addCommand(new YetAnotherCustomCommand());
}

GameTypes

GameType is an interface sothat you can implement it in a new enum in your addon to add new values. Have a look at the default implementation to see how to do that.

After you created your own implementation of GameType, you should add it to the instance of the game type handler class: GameTypes.

@Override
public void onEnable() {
    GameTypes gameTypes = DungeonsXL.getInstance().getGameTypes();
    for (GameType gameType : MyGameTypeImplementation.values()) {
        gameTypes.addGameType(gameType);
    }
}

GlobalProtections

TO DO

Requirements

TO DO

Rewards

TO DO

DSigns

TO DO

Triggers

TO DO

Clone this wiki locally