Search in sources :

Example 11 with OwnedLand

use of biz.princeps.landlord.util.OwnedLand in project LandLord by SpatiumPrinceps.

the class Manage method onManage.

public void onManage(Player player, String[] args) {
    OwnedLand land = plugin.getWgHandler().getRegion(player.getLocation().getChunk());
    if (land == null) {
        player.sendMessage(lm.getString("Commands.Manage.notOwnFreeLand"));
        return;
    }
    if (!land.isOwner(player.getUniqueId()) && !player.hasPermission("landlord.admin.manage")) {
        player.sendMessage(lm.getString("Commands.Manage.notOwn").replace("%owner%", land.printOwners()));
        return;
    }
    // land manage
    if (args.length == 0) {
        ManageGUI gui = new ManageGUI(player, land);
        gui.display();
    } else if (args.length == 1) {
        // land manage <landid>
        World world;
        try {
            world = Bukkit.getWorld(args[0].split("_")[0]);
        } catch (IndexOutOfBoundsException e) {
            player.sendMessage(lm.getString("Commands.manage.invalidArguments"));
            return;
        }
        if (Bukkit.getWorlds().contains(world)) {
            RegionManager rm = plugin.getWgHandler().getWG().getRegionManager(world);
            if (rm != null) {
                ProtectedRegion target = rm.getRegion(args[0]);
                if (target != null) {
                    ManageGUI gui = new ManageGUI(player, plugin.getLand(target));
                    gui.display();
                }
            }
        }
    } else {
        // land manage <allCommands>
        switch(args[0]) {
            case "setgreetall":
                StringBuilder sb1 = new StringBuilder();
                for (int i = 1; i < args.length; i++) {
                    sb1.append(args[i]).append(" ");
                }
                String newmsg1 = sb1.toString();
                for (ProtectedRegion protectedRegion : plugin.getWgHandler().getRegions(player.getUniqueId())) {
                    protectedRegion.setFlag(DefaultFlag.GREET_MESSAGE, newmsg1);
                }
                player.sendMessage(lm.getString("Commands.Manage.SetGreet.successful").replace("%msg%", newmsg1));
                break;
            case "setfarewellall":
                StringBuilder sb = new StringBuilder();
                for (int i = 1; i < args.length; i++) {
                    sb.append(args[i]).append(" ");
                }
                String newmsg = sb.toString();
                for (ProtectedRegion protectedRegion : plugin.getWgHandler().getRegions(player.getUniqueId())) {
                    protectedRegion.setFlag(DefaultFlag.FAREWELL_MESSAGE, newmsg);
                }
                player.sendMessage(lm.getString("Commands.Manage.SetFarewell.successful").replace("%msg%", newmsg));
                break;
            case "setgreet":
                setGreet(player, args, plugin.getLand(player.getLocation()).getWGLand(), 1);
                break;
            case "setfarewell":
                setFarewell(player, args, plugin.getLand(player.getLocation()).getWGLand(), 1);
                break;
            default:
                try {
                    World world = Bukkit.getWorld(args[0].split("_")[0]);
                    if (Bukkit.getWorlds().contains(world)) {
                        RegionManager rm = plugin.getWgHandler().getWG().getRegionManager(world);
                        if (rm != null) {
                            ProtectedRegion target = rm.getRegion(args[0]);
                            switch(args[1]) {
                                case "setgreet":
                                    setGreet(player, args, target, 2);
                                    break;
                                case "setfarewell":
                                    setFarewell(player, args, target, 2);
                                    break;
                            }
                        }
                    }
                } catch (IndexOutOfBoundsException e) {
                    player.sendMessage(lm.getString("Commands.manage.invalidArguments"));
                }
                break;
        }
    }
}
Also used : ManageGUI(biz.princeps.landlord.guis.ManageGUI) OwnedLand(biz.princeps.landlord.util.OwnedLand) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) World(org.bukkit.World)

Example 12 with OwnedLand

use of biz.princeps.landlord.util.OwnedLand in project LandLord by SpatiumPrinceps.

the class ManageAll method onManageAll.

public void onManageAll(Player player) {
    List<OwnedLand> lands = new ArrayList<>();
    for (World world : Bukkit.getWorlds()) {
        for (ProtectedRegion pr : plugin.getWgHandler().getRegions(player.getUniqueId(), world)) {
            lands.add(plugin.getLand(pr));
        }
    }
    ManageGUIAll gui = new ManageGUIAll(player, lands);
    gui.display();
}
Also used : ManageGUIAll(biz.princeps.landlord.guis.ManageGUIAll) OwnedLand(biz.princeps.landlord.util.OwnedLand) ArrayList(java.util.ArrayList) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) World(org.bukkit.World)

Example 13 with OwnedLand

use of biz.princeps.landlord.util.OwnedLand in project LandLord by SpatiumPrinceps.

the class WorldGuardHandler method getRegion.

public OwnedLand getRegion(Chunk chunk) {
    RegionManager manager = wg.getRegionContainer().get(chunk.getWorld());
    ProtectedRegion pr = manager != null ? manager.getRegion(OwnedLand.getName(chunk)) : null;
    return (pr != null ? new OwnedLand(pr, chunk) : null);
}
Also used : OwnedLand(biz.princeps.landlord.util.OwnedLand) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) RegionManager(com.sk89q.worldguard.protection.managers.RegionManager)

Example 14 with OwnedLand

use of biz.princeps.landlord.util.OwnedLand in project LandLord by SpatiumPrinceps.

the class WorldGuardHandler method getRegionsAsOL.

public List<OwnedLand> getRegionsAsOL(UUID id) {
    List<OwnedLand> list = new ArrayList<>();
    OfflinePlayer op = Bukkit.getOfflinePlayer(id);
    if (op != null)
        for (World world : Bukkit.getWorlds()) {
            // Only count enabled worlds
            if (!Landlord.getInstance().getConfig().getStringList("disabled-worlds").contains(world.getName()))
                for (ProtectedRegion protectedRegion : getRegions(id, world)) {
                    list.add(getRegion(protectedRegion));
                }
        }
    return list;
}
Also used : OwnedLand(biz.princeps.landlord.util.OwnedLand) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion)

Example 15 with OwnedLand

use of biz.princeps.landlord.util.OwnedLand in project LandLord by SpatiumPrinceps.

the class TresholdListener method onBucketEmpty.

@EventHandler
public void onBucketEmpty(PlayerBucketEmptyEvent e) {
    Player p = e.getPlayer();
    OwnedLand land = plugin.getLand(e.getBlockClicked().getLocation());
    handleLand(p, e.getBlockClicked().getLocation(), land, e);
}
Also used : Player(org.bukkit.entity.Player) OwnedLand(biz.princeps.landlord.util.OwnedLand) EventHandler(org.bukkit.event.EventHandler)

Aggregations

OwnedLand (biz.princeps.landlord.util.OwnedLand)20 Chunk (org.bukkit.Chunk)9 Player (org.bukkit.entity.Player)7 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)6 LPlayer (biz.princeps.landlord.persistent.LPlayer)4 Offers (biz.princeps.landlord.persistent.Offers)4 EventHandler (org.bukkit.event.EventHandler)4 RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)3 OfflinePlayer (org.bukkit.OfflinePlayer)3 Landlord (biz.princeps.landlord.Landlord)2 ManageGUIAll (biz.princeps.landlord.guis.ManageGUIAll)2 LangManager (biz.princeps.landlord.manager.LangManager)2 ConfirmationGUI (biz.princeps.lib.gui.ConfirmationGUI)2 MultiPagedGUI (biz.princeps.lib.gui.MultiPagedGUI)2 Icon (biz.princeps.lib.gui.simple.Icon)2 DefaultFlag (com.sk89q.worldguard.protection.flags.DefaultFlag)2 java.util (java.util)2 ArrayList (java.util.ArrayList)2 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)2 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)2