use of net.countercraft.movecraft.events.CraftReleaseEvent in project Movecraft by APDevTeam.
the class CraftManager method release.
public void release(@NotNull Craft craft, @NotNull CraftReleaseEvent.Reason reason, boolean force) {
CraftReleaseEvent e = new CraftReleaseEvent(craft, reason);
Bukkit.getServer().getPluginManager().callEvent(e);
if (e.isCancelled()) {
if (force)
throw new NonCancellableReleaseException();
else
return;
}
crafts.remove(craft);
if (craft instanceof PlayerCraft)
playerCrafts.remove(((PlayerCraft) craft).getPilot());
if (craft.getHitBox().isEmpty())
Movecraft.getInstance().getLogger().warning(I18nSupport.getInternationalisedString("Release - Empty Craft Release Console"));
else {
if (craft instanceof PlayerCraft)
craft.getAudience().sendMessage(Component.text(I18nSupport.getInternationalisedString("Release - Craft has been released")));
if (craft instanceof PilotedCraft)
Movecraft.getInstance().getLogger().info(String.format(I18nSupport.getInternationalisedString("Release - Player has released a craft console"), ((PilotedCraft) craft).getPilot().getName(), craft.getType().getStringProperty(CraftType.NAME), craft.getHitBox().size(), craft.getHitBox().getMinX(), craft.getHitBox().getMinZ()));
else
Movecraft.getInstance().getLogger().info(String.format(I18nSupport.getInternationalisedString("Release - Null Craft Release Console"), craft.getType().getStringProperty(CraftType.NAME), craft.getHitBox().size(), craft.getHitBox().getMinX(), craft.getHitBox().getMinZ()));
}
Movecraft.getInstance().getAsyncManager().addWreck(craft);
}
Aggregations