ON_LOGIN = EventFactory.createArrayBacked(OnLogin.class, callbacks -> (address, profile, reason) -> {
for (OnLogin callback : callbacks) {
callback.onLogin(address, profile, reason);
}
});
/**
* Called when Plan is enabled.
*
* This includes, but might not be limited to:
*
* - First time the plugin enables successfully
* - Plan is reloaded
* - Plan is enabled after it was disabled
*
*
* This event provides full access to the Plan instance. However, it is advised to
* only call {@link PlanFabric#isSystemEnabled} to determine if the enable was successful.
* It is not guaranteed that this event is called when the plugin fails to enable properly.
*/
public static final Event ON_ENABLE = EventFactory.createArrayBacked(OnEnable.class, callbacks -> plugin -> {
for (OnEnable callback : callbacks) {
callback.onEnable(plugin);
}
});
@FunctionalInterface
public interface OnKilled {
/**
* Called when a living entity is killed
*
* @param killed the entity that died
* @param killer the entity that killed
*/
void onKilled(LivingEntity killed, Entity killer);
}
@FunctionalInterface
public interface OnChat {
/**
* Called when a player sends a chat message / command
*
* @param handler the handler of the sending player
* @param message the message sent (starts with "/" if it is a command)
*/
void onChat(ServerPlayNetworkHandler handler, String message);
}
@FunctionalInterface
public interface OnMove {
/**
* Called when a sends a valid movement packet
*
* @param handler the handler of the sending player
* @param packet the send packet
*/
void onMove(ServerPlayNetworkHandler handler, PlayerMoveC2SPacket packet);
}
@FunctionalInterface
public interface OnGameModeChange {
/**
* Called when a player changes gamemode
*
* @param player the player that changed gamemodes
* @param newGameMode the new gamemode
*/
void onGameModeChange(ServerPlayerEntity player, GameMode newGameMode);
}
@FunctionalInterface
public interface OnPlayerKicked {
/**
* Called when a player (or multiple) get kicked from the server
*
* @param source the source that initated the kick
* @param targets the player(s) that got kicked
* @param reason the provided kick reason
*/
void onKicked(ServerCommandSource source, Collection targets, Text reason);
}
@FunctionalInterface
public interface OnLogin {
/**
* Called when a player attempts to login
*
* @param address the address of the player
* @param profile the profile of the player
* @param reason the provided kick reason (null if player is permitted to join)
*/
void onLogin(SocketAddress address, GameProfile profile, Text reason);
}
@FunctionalInterface
public interface OnEnable {
void onEnable(PlanFabric plugin);
}
}