Search in sources :

Example 1 with PlayerNotOnlineException

use of gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException in project Nexus by ProjectEdenGG.

the class PoofCommand method deny.

public void deny(Player receiver) {
    Poof request = service.getByReceiver(receiver);
    if (request == null || request.isExpired()) {
        error(receiver, "You do not have any pending Poof requests");
        return;
    }
    request.setExpired(true);
    service.save(request);
    OfflinePlayer toPlayer = request.getReceiverPlayer();
    OfflinePlayer fromPlayer = request.getSenderPlayer();
    if (request.getType() == Poof.PoofType.POOF_HERE) {
        toPlayer = request.getSenderPlayer();
        fromPlayer = request.getReceiverPlayer();
    }
    if (!fromPlayer.isOnline())
        throw new PlayerNotOnlineException(fromPlayer);
    if (request.getType() == Poof.PoofType.POOF) {
        send(toPlayer.getPlayer(), "&3You denied &e" + Nickname.of(fromPlayer) + "'s &3poof request");
        send(fromPlayer.getPlayer(), "&e" + Nickname.of(toPlayer) + " &3denied your poof request");
    } else {
        send(fromPlayer.getPlayer(), "&3You denied &e" + Nickname.of(toPlayer) + "'s &3poof-here request");
        send(toPlayer.getPlayer(), "&e" + Nickname.of(fromPlayer) + " &3denied your poof-here request");
    }
}
Also used : Poof(gg.projecteden.nexus.models.poof.Poof) OfflinePlayer(org.bukkit.OfflinePlayer) PlayerNotOnlineException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException)

Example 2 with PlayerNotOnlineException

use of gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException in project Nexus by ProjectEdenGG.

the class TeleportCommand method players.

private void players() {
    OfflinePlayer player1 = offlinePlayerArg(1);
    Location location1 = Nerd.of(player1).getLocation();
    if (isOfflinePlayerArg(2)) {
        OfflinePlayer player2 = offlinePlayerArg(2);
        if (player1.isOnline() && player1.getPlayer() != null) {
            if (checkTeleportDisabled(player1.getPlayer(), player2))
                return;
            player1.getPlayer().teleportAsync(Nerd.of(player2).getLocation(), TeleportCause.COMMAND);
            send(PREFIX + "Poofing to &e" + Nickname.of(player2) + (player2.isOnline() ? "" : " &3(Offline)"));
        } else
            throw new PlayerNotOnlineException(player1);
    } else {
        if (checkTeleportDisabled(player(), player1))
            return;
        player().teleportAsync(location1, TeleportCause.COMMAND);
        send(PREFIX + "Poofing to &e" + Nickname.of(player1) + (player1.isOnline() ? "" : " &3(Offline)"));
    }
}
Also used : OfflinePlayer(org.bukkit.OfflinePlayer) PlayerNotOnlineException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException) Location(org.bukkit.Location) RelativeLocation(gg.projecteden.nexus.utils.LocationUtils.RelativeLocation)

Example 3 with PlayerNotOnlineException

use of gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException in project Nexus by ProjectEdenGG.

the class SabotageMatchData method getProgress.

public double getProgress() {
    double progress = 0;
    double total = 0;
    for (Map.Entry<UUID, Set<Task>> entry : tasks.entrySet()) {
        UUID uuid = entry.getKey();
        Set<Task> taskSet = entry.getValue();
        Minigamer minigamer;
        try {
            minigamer = PlayerManager.get(uuid);
        } catch (PlayerNotOnlineException e) {
            continue;
        }
        if (SabotageTeam.of(minigamer) == SabotageTeam.IMPOSTOR)
            continue;
        for (Task task : taskSet) {
            if (task.getTask().getTaskType() == Tasks.TaskType.SABOTAGE)
                continue;
            progress += task.getCompleted();
            total += task.getTaskSize();
        }
    }
    return progress / total;
}
Also used : Task(gg.projecteden.nexus.features.minigames.models.mechanics.custom.sabotage.Task) Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) PlayerNotOnlineException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException) UUID(java.util.UUID) Map(java.util.Map) BiMap(com.google.common.collect.BiMap) HashMap(java.util.HashMap) HashBiMap(com.google.common.collect.HashBiMap) Minigamer(gg.projecteden.nexus.features.minigames.models.Minigamer)

Example 4 with PlayerNotOnlineException

use of gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException in project Nexus by ProjectEdenGG.

the class Tip method show.

public boolean show(TipType tipType) {
    if (!isOnline())
        throw new PlayerNotOnlineException(this);
    if (!received.contains(tipType)) {
        received.add(tipType);
        new TipService().save(this);
        return true;
    }
    if (!new CooldownService().check(uuid, "Tip-" + tipType.name(), tipType.getCooldown()))
        return false;
    if (tipType.getPredicate() != null)
        if (!tipType.getPredicate().test(getOnlinePlayer()))
            return false;
    if (tipType.getRetryChance() > 0)
        return RandomUtils.chanceOf(tipType.getRetryChance());
    return true;
}
Also used : PlayerNotOnlineException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService)

Example 5 with PlayerNotOnlineException

use of gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException in project Nexus by ProjectEdenGG.

the class PoofCommand method accept.

public void accept(Player receiver) {
    Poof request = service.getByReceiver(receiver);
    if (request == null || request.isExpired()) {
        error(receiver, "You do not have any pending Poof requests");
        return;
    }
    request.setExpired(true);
    service.save(request);
    OfflinePlayer toPlayer = request.getReceiverPlayer();
    OfflinePlayer fromPlayer = request.getSenderPlayer();
    if (request.getType() == Poof.PoofType.POOF_HERE) {
        toPlayer = request.getSenderPlayer();
        fromPlayer = request.getReceiverPlayer();
    }
    if (!fromPlayer.isOnline() || fromPlayer.getPlayer() == null)
        throw new PlayerNotOnlineException(fromPlayer);
    if (request.getType() == Poof.PoofType.POOF)
        fromPlayer.getPlayer().teleportAsync(toPlayer.getPlayer().getLocation(), TeleportCause.COMMAND);
    else
        fromPlayer.getPlayer().teleportAsync(request.getTeleportLocation(), TeleportCause.COMMAND);
    if (request.getType() == Poof.PoofType.POOF) {
        send(toPlayer.getPlayer(), "&3You accepted &e" + Nickname.of(fromPlayer) + "'s &3poof request");
        send(fromPlayer.getPlayer(), "&e" + Nickname.of(toPlayer) + " &3accepted your poof request");
    } else {
        send(fromPlayer.getPlayer(), "&3You accepted &e" + Nickname.of(toPlayer) + "'s &3poof-here request");
        if (toPlayer.isOnline())
            send(toPlayer.getPlayer(), "&e" + Nickname.of(fromPlayer) + " &3accepted your poof-here request");
    }
}
Also used : Poof(gg.projecteden.nexus.models.poof.Poof) OfflinePlayer(org.bukkit.OfflinePlayer) PlayerNotOnlineException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException)

Aggregations

PlayerNotOnlineException (gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException)8 OfflinePlayer (org.bukkit.OfflinePlayer)5 Poof (gg.projecteden.nexus.models.poof.Poof)4 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)2 Location (org.bukkit.Location)2 BiMap (com.google.common.collect.BiMap)1 HashBiMap (com.google.common.collect.HashBiMap)1 Minigamer (gg.projecteden.nexus.features.minigames.models.Minigamer)1 Task (gg.projecteden.nexus.features.minigames.models.mechanics.custom.sabotage.Task)1 CooldownService (gg.projecteden.nexus.models.cooldown.CooldownService)1 NerdService (gg.projecteden.nexus.models.nerd.NerdService)1 Trust (gg.projecteden.nexus.models.trust.Trust)1 TrustService (gg.projecteden.nexus.models.trust.TrustService)1 RelativeLocation (gg.projecteden.nexus.utils.LocationUtils.RelativeLocation)1 WorldGroup (gg.projecteden.nexus.utils.WorldGroup)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Set (java.util.Set)1