Search in sources :

Example 1 with DeleteRegionEvent

use of br.net.fabiozumbi12.RedProtect.Bukkit.events.DeleteRegionEvent in project RedProtect by FabioZumbi12.

the class RPCommands method handleDelete.

private static void handleDelete(Player p) {
    Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
    if (RedProtect.get().ph.hasRegionPermLeader(p, "delete", r)) {
        if (r == null) {
            sendNotInRegionMessage(p);
            return;
        }
        int claims = RPConfig.getInt("region-settings.first-home.can-delete-after-claims");
        if (!r.canDelete() && (claims == -1 || RedProtect.get().rm.getPlayerRegions(p.getName(), p.getWorld()) < claims) && !p.hasPermission("redprotect.bypass")) {
            if (claims != -1) {
                RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst-claims").replace("{claims}", "" + claims));
            } else {
                RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst"));
            }
            return;
        }
        DeleteRegionEvent event = new DeleteRegionEvent(r, p);
        Bukkit.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return;
        }
        String rname = r.getName();
        String w = r.getWorld();
        RedProtect.get().rm.remove(r, RedProtect.get().serv.getWorld(w));
        RPLang.sendMessage(p, RPLang.get("cmdmanager.region.deleted") + " " + rname);
        RedProtect.get().logger.addLog("(World " + w + ") Player " + p.getName() + " REMOVED region " + rname);
    } else {
        sendNoPermissionMessage(p);
    }
}
Also used : DeleteRegionEvent(br.net.fabiozumbi12.RedProtect.Bukkit.events.DeleteRegionEvent) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region)

Example 2 with DeleteRegionEvent

use of br.net.fabiozumbi12.RedProtect.Bukkit.events.DeleteRegionEvent in project RedProtect by FabioZumbi12.

the class RPCommands method handleDeleteName.

private static void handleDeleteName(Player p, String rname, String world) {
    Region r = RedProtect.get().rm.getRegion(rname, p.getWorld());
    if (!world.equals("")) {
        if (Bukkit.getWorld(world) != null) {
            r = RedProtect.get().rm.getRegion(rname, Bukkit.getWorld(world));
        } else {
            RPLang.sendMessage(p, "cmdmanager.region.invalidworld");
            return;
        }
    }
    if (RedProtect.get().ph.hasRegionPermLeader(p, "delete", r)) {
        if (r == null) {
            RPLang.sendMessage(p, RPLang.get("cmdmanager.region.doesntexist") + ": " + rname);
            return;
        }
        int claims = RPConfig.getInt("region-settings.first-home.can-delete-after-claims");
        if (!r.canDelete() && (claims == -1 || RedProtect.get().rm.getPlayerRegions(p.getName(), p.getWorld()) < claims) && !p.hasPermission("redprotect.bypass")) {
            if (claims != -1) {
                RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst-claims").replace("{claims}", "" + claims));
            } else {
                RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst"));
            }
            return;
        }
        DeleteRegionEvent event = new DeleteRegionEvent(r, p);
        Bukkit.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return;
        }
        RedProtect.get().rm.remove(r, RedProtect.get().serv.getWorld(r.getWorld()));
        RPLang.sendMessage(p, RPLang.get("cmdmanager.region.deleted") + " " + rname);
        RedProtect.get().logger.addLog("(World " + world + ") Player " + p.getName() + " REMOVED region " + rname);
    } else {
        sendNoPermissionMessage(p);
    }
}
Also used : DeleteRegionEvent(br.net.fabiozumbi12.RedProtect.Bukkit.events.DeleteRegionEvent) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region)

Example 3 with DeleteRegionEvent

use of br.net.fabiozumbi12.RedProtect.Bukkit.events.DeleteRegionEvent in project RedProtect by FabioZumbi12.

the class RPCommands method handleDeleteName.

private static void handleDeleteName(Player p, String rname, String world) {
    Region r = RedProtect.get().rm.getRegion(rname, p.getWorld());
    if (!world.equals("")) {
        if (Sponge.getServer().getWorld(world).isPresent()) {
            r = RedProtect.get().rm.getRegion(rname, Sponge.getServer().getWorld(world).get());
        } else {
            RPLang.sendMessage(p, "cmdmanager.region.invalidworld");
            return;
        }
    }
    if (RedProtect.get().ph.hasRegionPermLeader(p, "delete", r)) {
        if (r == null) {
            RPLang.sendMessage(p, RPLang.get("cmdmanager.region.doesntexist") + ": " + rname);
            return;
        }
        String puuid = RPUtil.PlayerToUUID(p.getName());
        if (r.isRentFor(puuid)) {
            RPLang.sendMessage(p, "cmdmanager.rent.cantdothisrent");
            return;
        }
        int claims = RedProtect.get().cfgs.getInt("region-settings.first-home.can-delete-after-claims");
        if (!r.canDelete() && (claims == -1 || RedProtect.get().rm.getPlayerRegions(p.getName(), p.getWorld()) < claims) && !p.hasPermission("redprotect.bypass")) {
            if (claims != -1) {
                RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst-claims").replace("{claims}", "" + claims));
            } else {
                RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst"));
            }
            return;
        }
        DeleteRegionEvent event = new DeleteRegionEvent(r, p);
        if (Sponge.getEventManager().post(event)) {
            return;
        }
        RedProtect.get().rm.remove(r, RedProtect.get().serv.getWorld(r.getWorld()).get());
        RPLang.sendMessage(p, RPLang.get("cmdmanager.region.deleted") + " " + rname);
        RedProtect.get().logger.addLog("(World " + world + ") Player " + p.getName() + " REMOVED region " + rname);
    } else {
        sendNoPermissionMessage(p);
    }
}
Also used : DeleteRegionEvent(br.net.fabiozumbi12.RedProtect.Sponge.events.DeleteRegionEvent)

Example 4 with DeleteRegionEvent

use of br.net.fabiozumbi12.RedProtect.Bukkit.events.DeleteRegionEvent in project RedProtect by FabioZumbi12.

the class RPCommands method handleDelete.

private static void handleDelete(Player p) {
    Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
    if (RedProtect.get().ph.hasRegionPermLeader(p, "delete", r)) {
        if (r == null) {
            sendNotInRegionMessage(p);
            return;
        }
        String puuid = RPUtil.PlayerToUUID(p.getName());
        if (r.isRentFor(puuid)) {
            RPLang.sendMessage(p, "cmdmanager.rent.cantdothisrent");
            return;
        }
        int claims = RedProtect.get().cfgs.getInt("region-settings.first-home.can-delete-after-claims");
        if (!r.canDelete() && (claims == -1 || RedProtect.get().rm.getPlayerRegions(p.getName(), p.getWorld()) < claims) && !p.hasPermission("redprotect.bypass")) {
            if (claims != -1) {
                RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst-claims").replace("{claims}", "" + claims));
            } else {
                RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst"));
            }
            return;
        }
        DeleteRegionEvent event = new DeleteRegionEvent(r, p);
        if (Sponge.getEventManager().post(event)) {
            return;
        }
        String rname = r.getName();
        String w = r.getWorld();
        RedProtect.get().rm.remove(r, RedProtect.get().serv.getWorld(w).get());
        RPLang.sendMessage(p, RPLang.get("cmdmanager.region.deleted") + " " + rname);
        RedProtect.get().logger.addLog("(World " + w + ") Player " + p.getName() + " REMOVED region " + rname);
    } else {
        sendNoPermissionMessage(p);
    }
}
Also used : DeleteRegionEvent(br.net.fabiozumbi12.RedProtect.Sponge.events.DeleteRegionEvent)

Aggregations

Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)2 DeleteRegionEvent (br.net.fabiozumbi12.RedProtect.Bukkit.events.DeleteRegionEvent)2 DeleteRegionEvent (br.net.fabiozumbi12.RedProtect.Sponge.events.DeleteRegionEvent)2