com.palmergames.bukkit.towny.exceptions.NotRegisteredException Java Examples

The following examples show how to use com.palmergames.bukkit.towny.exceptions.NotRegisteredException. 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: Towny.java    From Modern-LWC with MIT License 6 votes vote down vote up
public void unclaimTowny(TownUnclaimEvent event) throws NotRegisteredException, TownyException {
    if (towny == null) {
        return;
    }
    List<WorldCoord> wcl = AreaSelectionUtil.selectWorldCoordArea(event.getTown(), event.getWorldCoord(),
            new String[]{"auto"});
    wcl = AreaSelectionUtil.filterOwnedBlocks(event.getTown(), wcl);
    for (WorldCoord wc : wcl) {
        PlotBlockData pbd = new PlotBlockData(wc.getTownBlock());
        for (int z = 0; z < pbd.getSize(); z++)
            for (int x = 0; x < pbd.getSize(); x++)
                for (int y = pbd.getHeight(); y > 0; y--) {
                    Block b = event.getWorldCoord().getBukkitWorld().getBlockAt((pbd.getX() * pbd.getSize()) + x, y,
                            (pbd.getZ() * pbd.getSize()) + z);
                    LWC lwc = LWC.getInstance();
                    Protection protection = lwc.getPhysicalDatabase()
                            .loadProtection(event.getWorldCoord().getWorldName(), b.getX(), b.getY(), b.getZ());
                    if (protection != null) {
                        protection.remove();
                    }

                }
    }
}
 
Example #2
Source File: HookTowny.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
public static Town getTown(Location location) {
    try {
        TownBlock townBlock = getTownBlock(location);
        if(townBlock == null) return null;

        return townBlock.getTown();
    } catch(NotRegisteredException ex) {
        return null;
    }
}
 
Example #3
Source File: TownyFeature.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public boolean isAllowed(Player player, TownBlock block) {
    if (block == null) {
        return false;
    }
    Resident resident;
    try {
        resident = TownyUniverse.getDataSource().getResident(player.getName());
        try {
            if (block.getResident().equals(resident)) {
                return true;
            }
        } catch (NotRegisteredException ignore) {}
        Town town = block.getTown();
        if (town.isMayor(resident)) {
            return true;
        }
        if (!town.hasResident(resident)) return false;
        if (player.hasPermission("fawe.towny.*")) {
            return true;
        }
        for (String rank : resident.getTownRanks()) {
            if (player.hasPermission("fawe.towny." + rank)) {
                return true;
            }
        }
    } catch (NotRegisteredException e) {
        return false;
    }
    return false;
}
 
Example #4
Source File: TownyListener.java    From ShopChest with MIT License 5 votes vote down vote up
private boolean handleForLocation(Player player, Location loc, Cancellable e) {
    TownBlock townBlock = TownyUniverse.getTownBlock(loc);
    if (townBlock == null)
        return false;

    try {
        Town town = townBlock.getTown();
        Optional<Resident> playerResident = town.getResidents().stream()
                .filter(r -> r.getName().equals(player.getName()))
                .findFirst();
                
        if (!playerResident.isPresent()) {
            e.setCancelled(true);
            plugin.debug("Cancel Reason: Towny (no resident)");
            return true;
        }

        Resident resident = playerResident.get();
        String plotType = townBlock.getType().name();
        boolean cancel = (resident.isMayor() && !Config.townyShopPlotsMayor.contains(plotType))
                || (resident.isKing() && !Config.townyShopPlotsKing.contains(plotType))
                || (!resident.isKing() && !resident.isMayor() && !Config.townyShopPlotsResidents.contains(plotType));
        
        if (cancel) {
            e.setCancelled(true);
            plugin.debug("Cancel Reason: Towny (no permission)");
            return true;
        }
    } catch (NotRegisteredException ignored) {
    }
    return false;
}
 
Example #5
Source File: TownBlock.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public Town getTown() throws NotRegisteredException {
    throw new UnsupportedOperationException("Dummy API");
}