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());
});
}
Aggregations