use of net.countercraft.movecraft.events.ManOverboardEvent in project Movecraft by APDevTeam.
the class ManOverboardCommand method onCommand.
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (!command.getName().equalsIgnoreCase("manOverBoard"))
return false;
if (!(commandSender instanceof Player)) {
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("ManOverboard - Must Be Player"));
return true;
}
Player player = (Player) commandSender;
Craft craft = CraftManager.getInstance().getCraftByPlayerName(player.getName());
if (craft == null) {
player.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("ManOverboard - No Craft Found"));
return true;
}
Location telPoint = getCraftTeleportPoint(craft);
if (craft.getWorld() != player.getWorld()) {
player.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("ManOverboard - Other World"));
return true;
}
if ((System.currentTimeMillis() - CraftManager.getInstance().getTimeFromOverboard(player)) / 1_000 > Settings.ManOverboardTimeout && !MathUtils.locIsNearCraftFast(craft, MathUtils.bukkit2MovecraftLoc(player.getLocation()))) {
player.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("ManOverboard - Timed Out"));
return true;
}
if (telPoint.distanceSquared(player.getLocation()) > Settings.ManOverboardDistSquared) {
player.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("ManOverboard - Distance Too Far"));
return true;
}
if (craft.getDisabled() || craft instanceof SinkingCraft) {
player.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("ManOverboard - Disabled"));
return true;
}
ManOverboardEvent event = new ManOverboardEvent(craft, telPoint);
Bukkit.getServer().getPluginManager().callEvent(event);
player.setVelocity(new Vector(0, 0, 0));
player.setFallDistance(0);
player.teleport(telPoint);
return true;
}
Aggregations