Search in sources :

Example 1 with TrustService

use of gg.projecteden.nexus.models.trust.TrustService in project Nexus by ProjectEdenGG.

the class LWCTrustModule method onAccessRequest.

@Override
public void onAccessRequest(LWCAccessEvent event) {
    UUID owner;
    try {
        owner = UUID.fromString(event.getProtection().getOwner());
    } catch (IllegalArgumentException e) {
        return;
    }
    UUID requester = event.getPlayer().getUniqueId();
    List<UUID> trusted = new TrustService().get(owner).getLocks();
    if (trusted.contains(requester))
        event.setAccess(Permission.Access.PLAYER);
    if (Rank.of(requester).isStaff() && WorldGroup.of(event.getProtection().getBukkitWorld()) == WorldGroup.STAFF)
        event.setAccess(Permission.Access.PLAYER);
}
Also used : TrustService(gg.projecteden.nexus.models.trust.TrustService) UUID(java.util.UUID)

Example 2 with TrustService

use of gg.projecteden.nexus.models.trust.TrustService in project Nexus by ProjectEdenGG.

the class TrustProvider method openMenu.

public static void openMenu(Player player, int page, Runnable back, InventoryProvider provider) {
    Trust trust = new TrustService().get(player);
    int rows = (int) Math.min(6, Math.ceil(trust.getAll().size() / 9) + 3);
    SmartInventory.builder().provider(provider == null ? new TrustProvider(trust, back) : provider).size(rows, 9).title("Trusts").build().open(player, page);
}
Also used : TrustService(gg.projecteden.nexus.models.trust.TrustService) Trust(gg.projecteden.nexus.models.trust.Trust)

Example 3 with TrustService

use of gg.projecteden.nexus.models.trust.TrustService in project Nexus by ProjectEdenGG.

the class PoofCommand method player.

@Path("<player>")
void player(OfflinePlayer target) {
    if (isSelf(target))
        error("You cannot poof to yourself");
    if (!canSee(player(), target))
        throw new PlayerNotOnlineException(target);
    if (MuteMenuUser.hasMuted(target, MuteMenuItem.TP_REQUESTS))
        error(target.getName() + " has teleport requests disabled!");
    Location targetLocation = Nerd.of(target).getLocation();
    World targetWorld = targetLocation.getWorld();
    WorldGroup targetWorldGroup = WorldGroup.of(targetWorld);
    if (!isStaff()) {
        String cannotTeleport = "Cannot teleport to " + nickname(target);
        if (targetWorldGroup.isMinigames())
            error(cannotTeleport + ", they are playing minigames");
        if (targetWorldGroup.equals(WorldGroup.STAFF) || (targetWorld.equals(BearFair21.getWorld()) && !BearFair21.canWarp()))
            error(cannotTeleport + ", they are in a staff world");
    }
    Trust trust = new TrustService().get(target);
    if (trust.trusts(Type.TELEPORTS, player())) {
        player().teleportAsync(targetLocation, TeleportCause.COMMAND);
        send(PREFIX + "Poofing to &e" + Nickname.of(target) + (target.isOnline() && PlayerUtils.canSee(player(), target) ? "" : " &3(Offline)"));
        return;
    }
    Player targetPlayer = convertToPlayer(target);
    Poof request = new Poof(player(), targetPlayer, Poof.PoofType.POOF);
    service.save(request);
    send(json("&ePoof &3request sent to " + Nickname.of(targetPlayer) + ". ").next("&eClick to cancel").command("poof cancel"));
    send(targetPlayer, " &e" + nickname() + " &3is asking to poof &eto you&3.");
    send(targetPlayer, json("&3 Click one &3 || &3 ").group().next("&a&lAccept").command("/poof accept").hover("&eClick &3to accept").group().next("&3 &3 || &3 ").group().next("&c&lDeny").command("/poof deny").hover("&eClick &3to deny").group().next("&3 &3 ||"));
}
Also used : Poof(gg.projecteden.nexus.models.poof.Poof) Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) WorldGroup(gg.projecteden.nexus.utils.WorldGroup) TrustService(gg.projecteden.nexus.models.trust.TrustService) PlayerNotOnlineException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException) World(org.bukkit.World) Trust(gg.projecteden.nexus.models.trust.Trust) Location(org.bukkit.Location) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Aggregations

TrustService (gg.projecteden.nexus.models.trust.TrustService)3 Trust (gg.projecteden.nexus.models.trust.Trust)2 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)1 PlayerNotOnlineException (gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException)1 Poof (gg.projecteden.nexus.models.poof.Poof)1 WorldGroup (gg.projecteden.nexus.utils.WorldGroup)1 UUID (java.util.UUID)1 Location (org.bukkit.Location)1 OfflinePlayer (org.bukkit.OfflinePlayer)1 World (org.bukkit.World)1 Player (org.bukkit.entity.Player)1