Package com.bekvon.bukkit.residence.protection

Examples of com.bekvon.bukkit.residence.protection.ClaimedResidence


        if(Residence.getTransactionManager().isForSale(landName))
        {
            player.sendMessage(ChatColor.RED+Residence.getLanguage().getPhrase("SellRentFail"));
            return;
        }
        ClaimedResidence res = Residence.getResidenceManager().getByName(landName);
        if(res == null)
        {
            player.sendMessage(ChatColor.RED+Residence.getLanguage().getPhrase("InvalidResidence"));
            return;
        }
        if(!resadmin)
        {
            if(!res.getPermissions().hasResidencePermission(player, true))
            {
                player.sendMessage(ChatColor.RED+Residence.getLanguage().getPhrase("NoPermission"));
                return;
            }
            PermissionGroup group = Residence.getPermissionManager().getGroup(player);
View Full Code Here


        if(!Residence.getConfigManager().enabledRentSystem())
        {
            player.sendMessage(ChatColor.RED+Residence.getLanguage().getPhrase("RentDisabled"));
            return;
        }
        ClaimedResidence res = Residence.getResidenceManager().getByName(landName);
        if(res!=null)
        {
            if(res.getPermissions().getOwner().equalsIgnoreCase(player.getName()))
            {
                player.sendMessage(ChatColor.RED+Residence.getLanguage().getPhrase("OwnerRentFail"));
                return;
            }
        }
        else
        {
            player.sendMessage(ChatColor.RED+Residence.getLanguage().getPhrase("InvalidResidence"));
            return;
        }
        PermissionGroup group = Residence.getPermissionManager().getGroup(player);
        if(!resadmin && this.getRentCount(player.getName()) >= group.getMaxRents())
        {
            player.sendMessage(ChatColor.RED+Residence.getLanguage().getPhrase("ResidenceMaxRent"));
            return;
        }
        if(!this.isForRent(landName))
        {
            player.sendMessage(ChatColor.RED+Residence.getLanguage().getPhrase("ResidenceNotForRent"));
            return;
        }
        if(this.isRented(landName))
        {
            String[] split = landName.split("\\.");
            if(split.length!=0)
                player.sendMessage(Residence.getLanguage().getPhrase("ResidenceAlreadyRented",ChatColor.YELLOW+split[split.length-1] + ChatColor.RED+"."+ChatColor.YELLOW + this.getRentingPlayer(landName)));
            return;
        }
        RentableLand land = rentableLand.get(landName);
        if(Residence.getEconomyManager().canAfford(player.getName(), land.cost))
        {
            ResidenceRentEvent revent = new ResidenceRentEvent(res,player,RentEventType.RENT);
            Residence.getServ().getPluginManager().callEvent(revent);
            if(revent.isCancelled())
                return;
            if(Residence.getEconomyManager().transfer(player.getName(), res.getPermissions().getOwner(), land.cost))
            {
                RentedLand newrent = new RentedLand();
                newrent.player = player.getName();
                newrent.startTime = System.currentTimeMillis();
                newrent.endTime = System.currentTimeMillis() + daysToMs(land.days);
                newrent.autoRefresh = repeat;
                rentedLand.put(landName, newrent);
                res.getPermissions().copyUserPermissions(res.getPermissions().getOwner(), player.getName());
                res.getPermissions().clearPlayersFlags(res.getPermissions().getOwner());
                res.getPermissions().setPlayerFlag(player.getName(), "admin", FlagState.TRUE);
                String[] split = landName.split("\\.");
                if(split.length!=0)
                    player.sendMessage(ChatColor.GREEN+Residence.getLanguage().getPhrase("ResidenceRentSuccess",ChatColor.YELLOW + split[split.length-1] + ChatColor.GREEN+"."+ChatColor.YELLOW + land.days + ChatColor.GREEN));
            }
            else
View Full Code Here

            rentedLand.remove(landName);
            if(!rentableLand.get(landName).repeatable)
            {
                rentableLand.remove(landName);
            }
            ClaimedResidence res = Residence.getResidenceManager().getByName(landName);
            if(res!=null)
                res.getPermissions().applyDefaultFlags();
            player.sendMessage(ChatColor.GREEN+Residence.getLanguage().getPhrase("ResidenceUnrent",ChatColor.YELLOW+landName + ChatColor.GREEN));
        }
        else
        {
            player.sendMessage(ChatColor.RED+Residence.getLanguage().getPhrase("NoPermission"));
View Full Code Here

    }

    public void unrent(Player player, String landName, boolean resadmin)
    {
        String[] split = landName.split("\\.");
        ClaimedResidence res = Residence.getResidenceManager().getByName(landName);
        if(res == null)
        {
            player.sendMessage(ChatColor.YELLOW+Residence.getLanguage().getPhrase("InvalidResidence"));
            return;
        }
        if(!res.getPermissions().hasResidencePermission(player, true) && !resadmin)
        {
            player.sendMessage(ChatColor.RED+Residence.getLanguage().getPhrase("NoPermission"));
            return;
        }
        if(rentedLand.containsKey(landName) && !resadmin)
        {
            if(split.length!=0)
                player.sendMessage(ChatColor.RED+Residence.getLanguage().getPhrase("ResidenceAlreadyRented",ChatColor.YELLOW+split[split.length-1] + ChatColor.RED+"."+ChatColor.YELLOW + rentedLand.get(landName).player)+ChatColor.YELLOW);
            return;
        }
        if(rentableLand.containsKey(landName))
        {
            ResidenceRentEvent revent = new ResidenceRentEvent(res,player,RentEventType.UNRENT);
            Residence.getServ().getPluginManager().callEvent(revent);
            if(revent.isCancelled())
                return;
            rentableLand.remove(landName);
            if(rentedLand.containsKey(landName))
            {
                rentedLand.remove(landName);
                if(res!=null)
                    res.getPermissions().applyDefaultFlags();
            }
            if(split.length!=0)
                player.sendMessage(ChatColor.RED+Residence.getLanguage().getPhrase("ResidenceRemoveRentable",ChatColor.YELLOW+split[split.length-1] + ChatColor.RED));

        }
View Full Code Here

        {
            Entry<String, RentedLand> next = it.next();
            RentedLand land = next.getValue();
            if(land.endTime<=System.currentTimeMillis())
            {
                ClaimedResidence res = Residence.getResidenceManager().getByName(next.getKey());
                if(Residence.getConfigManager().debugEnabled())
                    System.out.println("Rent Check: "+next.getKey());
                if (res != null) {
                    ResidenceRentEvent revent = new ResidenceRentEvent(res, null, RentEventType.RENT_EXPIRE);
                    Residence.getServ().getPluginManager().callEvent(revent);
                    if (!revent.isCancelled()) {
                        RentableLand rentable = rentableLand.get(next.getKey());
                        if (!rentable.repeatable) {
                            rentableLand.remove(next.getKey());
                            it.remove();
                            res.getPermissions().applyDefaultFlags();
                        } else if (land.autoRefresh) {
                            if (!Residence.getEconomyManager().canAfford(land.player, rentable.cost)) {
                                it.remove();
                                res.getPermissions().applyDefaultFlags();
                            } else {
                                if (!Residence.getEconomyManager().transfer(land.player, res.getPermissions().getOwner(), rentable.cost)) {
                                    it.remove();
                                    res.getPermissions().applyDefaultFlags();
                                }
                                else
                                {
                                    land.endTime = System.currentTimeMillis() + this.daysToMs(rentable.days);
                                }
                            }
                        } else {
                            res.getPermissions().applyDefaultFlags();
                            it.remove();
                        }
                    }
                }
                else
View Full Code Here

    @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
    public void onPlayerSpawn(PlayerRespawnEvent event) {
        Location loc = event.getRespawnLocation();
        Boolean bed = event.isBedSpawn();
        Player player = event.getPlayer();
        ClaimedResidence res = Residence.getResidenceManager().getByLoc(loc);
        if (res == null) {
            return;
        }
        if (res.getPermissions().playerHas(player.getName(), "move", true)) {
            return;
        }
        if (bed) {
            loc = player.getWorld().getSpawnLocation();
        }
        res = Residence.getResidenceManager().getByLoc(loc);
        if (res != null) {
            if (!res.getPermissions().playerHas(player.getName(), "move", true)) {
                loc = res.getOutsideFreeLoc(loc);
            }
        }
        player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NoSpawn"));
        event.setRespawnLocation(loc);
    }
View Full Code Here

        Player player = event.getPlayer();
        if (Residence.isResAdminOn(player)) {
            return;
        }
        String pname = player.getName();
        ClaimedResidence res = Residence.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
        if (res != null) {
            if (Residence.getConfigManager().preventRentModify() && Residence.getConfigManager().enabledRentSystem()) {
                if (Residence.getRentManager().isRented(res.getName())) {
                    player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("RentedModifyDeny"));
                    event.setCancelled(true);
                    return;
                }
            }
View Full Code Here

        Player player = event.getPlayer();
        String pname = player.getName();
        if (Residence.isResAdminOn(player)) {
            return;
        }
        ClaimedResidence res = Residence.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
        if (res != null) {
            if (Residence.getConfigManager().preventRentModify() && Residence.getConfigManager().enabledRentSystem()) {
                if (Residence.getRentManager().isRented(res.getName())) {
                    player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("RentedModifyDeny"));
                    event.setCancelled(true);
                    return;
                }
            }
View Full Code Here

        if (Residence.isResAdminOn(player)) {
            handleNewLocation(player, loc, false);
            return;
        }
       
        ClaimedResidence res = Residence.getResidenceManager().getByLoc(loc);
        if (event.getCause() == TeleportCause.ENDER_PEARL) {
            if (res != null) {
                String areaname = Residence.getResidenceManager().getNameByLoc(loc);
                if (!res.getPermissions().playerHas(player.getName(), "move", true)) {
                    event.setCancelled(true);
                    player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("ResidenceMoveDeny", areaname));
                    return;
                }
            }
        }
        if (event.getCause() == TeleportCause.PLUGIN) {
            if (res != null) {
                String areaname = Residence.getResidenceManager().getNameByLoc(loc);
                if (!res.getPermissions().playerHas(player.getName(), "tp", true) && !player.hasPermission("residence.admin.tp")) {
                    event.setCancelled(true);
                    player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("TeleportDeny", areaname));
                    return;
                }
            }
View Full Code Here

    }

    public void handleNewLocation(Player player, Location loc, boolean move) {
        String pname = player.getName();

        ClaimedResidence res = Residence.getResidenceManager().getByLoc(loc);
        String areaname = null;
        boolean chatchange = false;
        String subzone = null;
        if (res != null) {
            areaname = Residence.getResidenceManager().getNameByLoc(loc);
            while (res.getSubzoneByLoc(player.getLocation()) != null) {
                subzone = res.getSubzoneNameByLoc(player.getLocation());
                res = res.getSubzoneByLoc(player.getLocation());
                areaname = areaname + "." + subzone;
            }
        }
        ClaimedResidence ResOld = null;
        if (currentRes.containsKey(pname)) {
            ResOld = Residence.getResidenceManager().getByName(currentRes.get(pname));
            if (ResOld == null) {
                currentRes.remove(pname);
            }
        }
        if (res == null) {
            lastOutsideLoc.put(pname, loc);
            if (ResOld != null) {
                String leave = ResOld.getLeaveMessage();
                /*
                 * TODO - ResidenceLeaveEvent is deprecated as of 21-MAY-2013. Its functionality is replaced by
                 * ResidenceChangedEvent. For now, this event is still supported until it is removed at a
                 * suitable time in the future.
                 */
                ResidenceLeaveEvent leaveevent = new ResidenceLeaveEvent(ResOld, player);
                Residence.getServ().getPluginManager().callEvent(leaveevent);
               
                // New ResidenceChangeEvent
                ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(ResOld, null, player);
                Residence.getServ().getPluginManager().callEvent(chgEvent);
               
                if (leave != null && !leave.equals("")) {
                    player.sendMessage(ChatColor.YELLOW + this.insertMessages(player, ResOld.getName(), ResOld, leave));
                }
                currentRes.remove(pname);
                Residence.getChatManager().removeFromChannel(pname);
            }
            return;
        }
        if (move) {
            if (!res.getPermissions().playerHas(pname, "move", true) && !Residence.isResAdminOn(player) && !player.hasPermission("residence.admin.move")) {
                Location lastLoc = lastOutsideLoc.get(pname);
                if (lastLoc != null) {
                    player.teleport(lastLoc);
                } else {
                    player.teleport(res.getOutsideFreeLoc(loc));
                }
                player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("ResidenceMoveDeny", res.getName().split("\\.")[res.getName().split("\\.").length - 1]));
                return;
            }
        }
        lastOutsideLoc.put(pname, loc);
        if (!currentRes.containsKey(pname) || ResOld != res) {
            currentRes.put(pname, areaname);
            if (subzone == null) {
                chatchange = true;
            }
           
            // "from" residence for ResidenceChangedEvent
            ClaimedResidence chgFrom = null;
            if (ResOld != res && ResOld != null) {
                String leave = ResOld.getLeaveMessage();
                chgFrom = ResOld;
               
                /*
 
View Full Code Here

TOP

Related Classes of com.bekvon.bukkit.residence.protection.ClaimedResidence

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.