Search in sources :

Example 1 with ResAccess

use of mc.dragons.res.ResLoader.Residence.ResAccess in project DragonsOnline by UniverseCraft.

the class ResLoader method goToResidence.

public void goToResidence(User user, int id, boolean bypass) {
    Residence res = getResidenceById(id);
    if (res.isLocked() && !bypass) {
        user.getPlayer().sendMessage(ChatColor.RED + "This residence has been locked by an administrator.");
        return;
    }
    boolean canAccess = bypass;
    ResAccess access = res.getAccessLevel();
    if (access == ResAccess.ALL) {
        canAccess = true;
    }
    if (access == ResAccess.PRIVATE && res.getOwner().getIdentifier().equals(user.getIdentifier())) {
        canAccess = true;
    }
    if (!canAccess) {
        user.getPlayer().sendMessage(ChatColor.RED + "You do not have access to this residence! (Guild-only and friend-only status doesn't work yet)");
        return;
    }
    Location spawn = generateResidence(id);
    // send user to residence
    if (!user.getPlayer().getWorld().getName().equals("res_temp")) {
        user.getStorageAccess().set("resExitTo", StorageUtil.locToDoc(user.getPlayer().getLocation()));
    }
    user.getStorageAccess().set("lastResId", id);
    user.getPlayer().teleport(spawn);
    user.getPlayer().sendMessage(ChatColor.GREEN + "Welcome to your residence (ID #" + id + ")");
}
Also used : Residence(mc.dragons.res.ResLoader.Residence) ResAccess(mc.dragons.res.ResLoader.Residence.ResAccess) Location(org.bukkit.Location)

Aggregations

Residence (mc.dragons.res.ResLoader.Residence)1 ResAccess (mc.dragons.res.ResLoader.Residence.ResAccess)1 Location (org.bukkit.Location)1