Skip to main content

Extractioncraft Developer API

Extractioncraft exposes a query class and Bukkit events under com.magmaguy.extractioncraft.api so other plugins can track and react to matches. All events are standard synchronous Bukkit events.

Queries​

MethodReturns
ExtractionCraftAPI.getMatch(Player player)The ExtractionMatch the player is in, as a player or spectator, or null
ExtractionCraftAPI.getMatches()A copy of every match that has been created and not yet destroyed

ExtractionMatch extends the match class of the MagmaCore copy bundled in the Extractioncraft jar, relocated to com.magmaguy.extractioncraft.magmacore.match.Match. Its public methods include getPhase(), getMatchPlayers(), getActivePlayers(), admit(players), admitSpectator(player), leave(player, reason), start() and end(outcome). Extractioncraft has no join or spectate command, so admit and admitSpectator are how another plugin brings more players or spectators into a match. Players can only be admitted while the match is waiting, up to its maxPlayers; spectators need the content package to set spectatable: true.

Events​

EventCancellableExposed dataFires
ExtractionMatchJoinEventYesExtractionMatch match, Player playerBefore a player or spectator is admitted, once per player
ExtractionMatchStartEventYesExtractionMatch matchWhen /exc start passes the minimum-player check, before the countdown
ExtractionMatchLeaveEventNoExtractionMatch match, Player player, ExtractionLeaveReason reasonWhile a participant is leaving
ExtractionMatchEndEventNoExtractionMatch match, ExtractionMatchOutcome outcomeWhen the match ends

Cancelling ExtractionMatchJoinEvent keeps out the player and every player being admitted with them. When it refuses the creator of a freshly generated match, the match and its world are destroyed and the creator is told The generated match could not be started.

Cancelling ExtractionMatchStartEvent keeps the match waiting. Players can run /exc start again.

ExtractionMatchLeaveEvent fires after Extractioncraft has soulbound or cleared the player's inventory for the leave reason, while the player is still a participant and still in the match world. They are teleported out afterwards.

ExtractionMatchEndEvent fires before the players still inside are removed. They then leave with MATCH_ENDED. A server shutdown or plugin reload destroys matches without ending them, so no end event fires; players leave with SHUTDOWN instead.

Leave Reasons​

ExtractionLeaveReasonMeaningItems once the match is live
QUITLeft on their own, for example with /exc quitLost with the default config
DISCONNECTDisconnected from the serverLost with the default config
DIEDTook lethal damageLost with the default config
EXTRACTEDExtracted at an extraction pointKept and soulbound
MATCH_ENDEDStill inside when the match ended, including when the timer ran outLost with the default config
SHUTDOWNThe server or plugin shut down during the matchKept and soulbound

Leaving before the match goes live never touches the inventory. See death and item loss.

Match Outcomes​

ExtractionMatchOutcomeWhen Extractioncraft uses it
DEFEATThe 15-minute timer ran out, or the last active player left the match, including by extracting
NEUTRALThe player count dropped below minPlayers during the countdown
VICTORYNever set by Extractioncraft itself; only a plugin calling end(...) can produce it

Usage Example​

import com.magmaguy.extractioncraft.api.ExtractionLeaveReason;
import com.magmaguy.extractioncraft.api.ExtractionMatchLeaveEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

public class MyExtractionListener implements Listener {
@EventHandler
public void onLeave(ExtractionMatchLeaveEvent event) {
if (event.getReason() == ExtractionLeaveReason.EXTRACTED) {
// Reward the player for a successful extraction
}
}
}