Search in sources :

Example 1 with CraftScuttleEvent

use of net.countercraft.movecraft.events.CraftScuttleEvent in project Movecraft by APDevTeam.

the class ScuttleSign method scuttle.

private void scuttle(Craft craft, CommandSender commandSender) {
    if (craft instanceof SinkingCraft) {
        commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Scuttle - Craft Already Sinking"));
        return;
    }
    if (!commandSender.hasPermission("movecraft." + craft.getType().getStringProperty(CraftType.NAME) + ".scuttle")) {
        commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Insufficient Permissions"));
        return;
    }
    CraftScuttleEvent e = new CraftScuttleEvent(craft, (Player) commandSender);
    Bukkit.getServer().getPluginManager().callEvent(e);
    if (e.isCancelled())
        return;
    craft.setCruising(false);
    CraftManager.getInstance().sink(craft);
    commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Scuttle - Scuttle Activated"));
}
Also used : SinkingCraft(net.countercraft.movecraft.craft.SinkingCraft) CraftScuttleEvent(net.countercraft.movecraft.events.CraftScuttleEvent)

Example 2 with CraftScuttleEvent

use of net.countercraft.movecraft.events.CraftScuttleEvent in project Movecraft by APDevTeam.

the class ScuttleCommand method onCommand.

@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
    if (!command.getName().equalsIgnoreCase("scuttle")) {
        return false;
    }
    Craft craft = null;
    // Scuttle other player
    if (commandSender.hasPermission("movecraft.commands.scuttle.others") && strings.length >= 1) {
        Player player = Bukkit.getPlayer(strings[0]);
        if (player == null) {
            commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Scuttle - Must Be Online"));
            return true;
        }
        craft = CraftManager.getInstance().getCraftByPlayer(player);
    } else if (commandSender.hasPermission("movecraft.commands.scuttle.self") && strings.length == 0) {
        if (!(commandSender instanceof Player)) {
            commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Scuttle - Must Be Player"));
            return true;
        }
        craft = CraftManager.getInstance().getCraftByPlayer(Bukkit.getPlayer(commandSender.getName()));
    }
    if (craft == null) {
        commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("You must be piloting a craft"));
        return true;
    }
    if (craft instanceof SinkingCraft) {
        commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Scuttle - Craft Already Sinking"));
        return true;
    }
    if (!commandSender.hasPermission("movecraft." + craft.getType().getStringProperty(CraftType.NAME) + ".scuttle")) {
        commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Insufficient Permissions"));
        return true;
    }
    CraftScuttleEvent e = new CraftScuttleEvent(craft, (Player) commandSender);
    Bukkit.getServer().getPluginManager().callEvent(e);
    if (e.isCancelled())
        return true;
    craft.setCruising(false);
    CraftManager.getInstance().sink(craft);
    commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Scuttle - Scuttle Activated"));
    return true;
}
Also used : SinkingCraft(net.countercraft.movecraft.craft.SinkingCraft) CraftScuttleEvent(net.countercraft.movecraft.events.CraftScuttleEvent) Player(org.bukkit.entity.Player) SinkingCraft(net.countercraft.movecraft.craft.SinkingCraft) Craft(net.countercraft.movecraft.craft.Craft)

Aggregations

SinkingCraft (net.countercraft.movecraft.craft.SinkingCraft)2 CraftScuttleEvent (net.countercraft.movecraft.events.CraftScuttleEvent)2 Craft (net.countercraft.movecraft.craft.Craft)1 Player (org.bukkit.entity.Player)1