Search in sources :

Example 1 with LastConfirmedCommand

use of com.alessiodp.parties.bukkit.utils.LastConfirmedCommand in project Parties by AlessioDP.

the class BukkitCommandConfirm method onCommand.

@Override
public void onCommand(CommandData commandData) {
    User sender = commandData.getSender();
    BukkitPartyPlayerImpl partyPlayer = (BukkitPartyPlayerImpl) ((PartiesCommandData) commandData).getPartyPlayer();
    // Command handling
    LastConfirmedCommand packet = partyPlayer.getLastConfirmedCommand();
    if (packet == null || ((System.currentTimeMillis() - packet.getTimestamp()) > BukkitConfigMain.ADDONS_VAULT_CONFIRM_TIMEOUT)) {
        sendMessage(sender, partyPlayer, BukkitMessages.ADDCMD_VAULT_CONFIRM_NOCMD);
        return;
    }
    // Command starts
    packet.setConfirmed(true);
    partyPlayer.setLastConfirmedCommand(packet);
    sendMessage(sender, partyPlayer, BukkitMessages.ADDCMD_VAULT_CONFIRM_CONFIRMED);
    // Make it sync
    plugin.getScheduler().getSyncExecutor().execute(() -> {
        Player player = Bukkit.getPlayer(sender.getUUID());
        if (player != null)
            Bukkit.getServer().dispatchCommand(player, packet.getCommand());
    });
}
Also used : Player(org.bukkit.entity.Player) User(com.alessiodp.core.common.user.User) BukkitPartyPlayerImpl(com.alessiodp.parties.bukkit.players.objects.BukkitPartyPlayerImpl) LastConfirmedCommand(com.alessiodp.parties.bukkit.utils.LastConfirmedCommand)

Aggregations

User (com.alessiodp.core.common.user.User)1 BukkitPartyPlayerImpl (com.alessiodp.parties.bukkit.players.objects.BukkitPartyPlayerImpl)1 LastConfirmedCommand (com.alessiodp.parties.bukkit.utils.LastConfirmedCommand)1 Player (org.bukkit.entity.Player)1