Java Code Examples for br.net.fabiozumbi12.RedProtect.Bukkit.Region#getTPPoint()

The following examples show how to use br.net.fabiozumbi12.RedProtect.Bukkit.Region#getTPPoint() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedProtectUtil.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public void addProps(YamlConfiguration fileDB, Region r) {
    String rname = r.getName();
    fileDB.createSection(rname);
    fileDB.set(rname + ".name", rname);
    fileDB.set(rname + ".lastvisit", r.getDate());
    fileDB.set(rname + ".admins", r.getAdmins().stream().map(t -> t.getUUID() + "@" + t.getPlayerName()).collect(Collectors.toList()));
    fileDB.set(rname + ".members", r.getMembers().stream().map(t -> t.getUUID() + "@" + t.getPlayerName()).collect(Collectors.toList()));
    fileDB.set(rname + ".leaders", r.getLeaders().stream().map(t -> t.getUUID() + "@" + t.getPlayerName()).collect(Collectors.toList()));
    fileDB.set(rname + ".priority", r.getPrior());
    fileDB.set(rname + ".welcome", r.getWelcome());
    fileDB.set(rname + ".world", r.getWorld());
    fileDB.set(rname + ".maxX", r.getMaxMbrX());
    fileDB.set(rname + ".maxZ", r.getMaxMbrZ());
    fileDB.set(rname + ".minX", r.getMinMbrX());
    fileDB.set(rname + ".minZ", r.getMinMbrZ());
    fileDB.set(rname + ".maxY", r.getMaxY());
    fileDB.set(rname + ".minY", r.getMinY());
    fileDB.set(rname + ".value", r.getValue());
    fileDB.set(rname + ".flags", r.getFlags());
    fileDB.set(rname + ".candelete", r.canDelete());
    fileDB.set(rname + ".canpurge", r.canPurge());

    Location loc = r.getTPPoint();
    if (loc != null) {
        int x = loc.getBlockX();
        int y = loc.getBlockY();
        int z = loc.getBlockZ();
        float yaw = loc.getYaw();
        float pitch = loc.getPitch();
        fileDB.set(rname + ".tppoint", x + "," + y + "," + z + "," + yaw + "," + pitch);
    } else {
        fileDB.set(rname + ".tppoint", "");
    }
}
 
Example 2
Source File: RegionManager.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public Region renameRegion(String newName, Region old) {
    Region newr = new Region(newName, old.getAdmins(), old.getMembers(), old.getLeaders(), new int[]{old.getMinMbrX(), old.getMinMbrX(), old.getMaxMbrX(), old.getMaxMbrX()},
            new int[]{old.getMinMbrZ(), old.getMinMbrZ(), old.getMaxMbrZ(), old.getMaxMbrZ()}, old.getMinY(), old.getMaxY(), old.getPrior(), old.getWorld(), old.getDate(), old.getFlags(), old.getWelcome(), old.getValue(), old.getTPPoint(), old.canDelete(), old.canPurge());

    this.add(newr, newr.getWorld());
    this.remove(old, old.getWorld());
    return newr;
}
 
Example 3
Source File: CommandHandlers.java    From RedProtect with GNU General Public License v3.0 4 votes vote down vote up
public static void handletp(CommandSender sender, String rname, String wname, Player play) {
    World w = RedProtect.get().getServer().getWorld(wname);
    if (w == null) {
        RedProtect.get().lang.sendMessage(sender, "cmdmanager.region.invalidworld");
        return;
    }
    Region region = RedProtect.get().rm.getRegion(rname, w.getName());
    if (region == null) {
        RedProtect.get().lang.sendMessage(sender, RedProtect.get().lang.get("cmdmanager.region.doesntexist") + ": " + rname);
        return;
    }

    if (play == null) {
        if (sender instanceof Player && !RedProtect.get().ph.hasRegionPermMember((Player) sender, "teleport", region)) {
            RedProtect.get().lang.sendMessage(sender, "no.permission");
            return;
        }
    } else {
        if (!RedProtect.get().ph.hasPerm(sender, "redprotect.command.admin.teleport")) {
            RedProtect.get().lang.sendMessage(sender, "no.permission");
            return;
        }
    }

    Location loc = null;
    if (region.getTPPoint() != null) {
        loc = region.getTPPoint();
        loc.setX(loc.getBlockX() + 0.500);
        loc.setZ(loc.getBlockZ() + 0.500);
    } else {
        int limit = w.getMaxHeight();
        if (w.getEnvironment().equals(World.Environment.NETHER)) {
            limit = 124;
        }
        for (int i = limit; i > 0; i--) {
            Material mat = w.getBlockAt(region.getCenterX(), i, region.getCenterZ()).getType();
            Material mat1 = w.getBlockAt(region.getCenterX(), i + 1, region.getCenterZ()).getType();
            Material mat2 = w.getBlockAt(region.getCenterX(), i + 2, region.getCenterZ()).getType();
            if (!mat.name().contains("LAVA") && !mat.equals(Material.AIR) && mat1.equals(Material.AIR) && mat2.equals(Material.AIR)) {
                loc = new Location(w, region.getCenterX() + 0.500, i + 1, region.getCenterZ() + 0.500);
                break;
            }
        }
    }

    if (loc != null) {
        if (play != null) {
            if (RedProtect.get().hooks.essentials && sender instanceof Player) {
                RedProtect.get().hooks.pless.getUser(sender).setLastLocation();
            }
            play.teleport(loc);
            RedProtect.get().lang.sendMessage(play, RedProtect.get().lang.get("cmdmanager.region.teleport") + " " + rname);
            RedProtect.get().lang.sendMessage(sender, RedProtect.get().lang.get("cmdmanager.region.tpother") + " " + rname);
        } else if (sender instanceof Player) {
            tpWait((Player) sender, loc, rname);
        }
    }
}