TDXDevelopment
TDX Welcome Raffle

Developer API

Start and end raffles from your own plugin, and listen to raffle events.

TDX Welcome Raffle has a small public API and three cancellable Bukkit events. Add TDXWelcomeRaffle to softdepend in your plugin.yml and put the jar on your compile classpath.

The API

TDXWelcomeRaffleAPI api = TDXWelcomeRaffleAPI.get();
if (api != null) {
    api.startRaffle(player);                         // true when it opened
    api.isEntered(otherPlayer.getUniqueId());        // in any open raffle?
    api.endRaffle(player.getUniqueId(), true);       // draw now
    for (RaffleService.RaffleInfo info : api.getOpenRaffles()) {
        info.newcomerName();
        info.secondsLeft();
        info.entries();
    }
}

get() returns null while the plugin is not enabled. Call startRaffle on the server thread, or the player's own region on Folia, not from an async task.

Events

All three are in com.toosiedx.welcomeraffle.api.event and can be cancelled.

EventFired whenCancelling it
TDXRaffleStartEventA raffle is about to open for a newcomerNo raffle opens. setDurationSeconds changes its length.
TDXRaffleEnterEventA player passed every check and is about to be enteredThey are not entered into that raffle.
TDXRaffleWinEventA winner was drawn, before the prize is givenNo prize and no announcement.

TDXRaffleWinEvent carries the winner, the newcomer's name and UUID, the prize id from rewards.yml (null when there are no prizes) and the number of entries.

@EventHandler
public void onWin(TDXRaffleWinEvent event) {
    getLogger().info(event.getWinner().getName() + " won " + event.getRewardId());
}

On Folia, the enter event fires on the entering player's region and the win event on the global region. The start event fires where the raffle was opened: the newcomer's region for a join, the command sender's thread for /welcomeraffle start, the caller's thread for startRaffle.

On this page