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