Search in sources :

Example 6 with LPlayer

use of biz.princeps.landlord.persistent.LPlayer in project LandLord by SpatiumPrinceps.

the class LPlayerManager method getInactiveRemainingDays.

private Long getInactiveRemainingDays(UUID owner) {
    long days = plugin.getConfig().getInt("BuyUpInactive.timegate");
    LPlayer lPlayer = getLPlayer(owner);
    if (lPlayer != null) {
        return days - (Duration.between(LocalDateTime.now(), lPlayer.getLastSeen()).toDays());
    }
    return -1L;
}
Also used : LPlayer(biz.princeps.landlord.persistent.LPlayer)

Example 7 with LPlayer

use of biz.princeps.landlord.persistent.LPlayer in project LandLord by SpatiumPrinceps.

the class LPlayerManager method save.

public void save(UUID id) {
    LPlayer lp = get(id);
    Landlord.getInstance().getDatabaseAPI().saveObject(lp);
}
Also used : LPlayer(biz.princeps.landlord.persistent.LPlayer)

Example 8 with LPlayer

use of biz.princeps.landlord.persistent.LPlayer in project LandLord by SpatiumPrinceps.

the class Info method onInfo.

public void onInfo(Player player) {
    if (plugin.getConfig().getStringList("disabled-worlds").contains(player.getWorld().getName())) {
        player.sendMessage(lm.getString("Disabled-World"));
        return;
    }
    Chunk chunk = player.getLocation().getChunk();
    OwnedLand land = plugin.getWgHandler().getRegion(chunk);
    new BukkitRunnable() {

        @Override
        public void run() {
            // claimed
            if (land != null) {
                String lastseen;
                LocalDateTime lastSeenDate = null;
                OfflinePlayer op = Bukkit.getOfflinePlayer(land.getOwner());
                if (op.isOnline()) {
                    lastseen = lm.getRawString("Commands.Info.online");
                } else {
                    List<Object> list = plugin.getDatabaseAPI().retrieveObjects(LPlayer.class, new Conditions.Builder().addCondition("uuid", op.getUniqueId().toString()).create());
                    if (list.size() > 0) {
                        lastseen = ((LPlayer) list.get(0)).getLastSeenAsString();
                        lastSeenDate = ((LPlayer) list.get(0)).getLastSeen();
                    } else {
                        lastseen = lm.getRawString("Commands.Info.noLastSeen");
                    }
                }
                if (Util.isInactive(lastSeenDate)) {
                    player.sendMessage(replaceInMessage(inactive, land.getName(), land.printOwners(), land.printMembers(), lastseen, Util.formatCash(plugin.getCostManager().calculateCost(player.getUniqueId()))));
                    OwnedLand.highlightLand(player, CParticle.DRIPLAVA);
                    return;
                }
                Offers offer = plugin.getPlayerManager().getOffer(land.getName());
                if (offer != null) {
                    // advertised land
                    player.sendMessage(replaceInMessage(advertised, land.getName(), land.printOwners(), land.printMembers(), lastseen, Util.formatCash(offer.getPrice())));
                } else {
                    // normal owned land
                    player.sendMessage(replaceInMessage(owned, land.getName(), land.printOwners(), land.printMembers(), lastseen, ""));
                }
                OwnedLand.highlightLand(player, CParticle.DRIPWATER);
            } else {
                // unclaimed
                player.sendMessage(replaceInMessage(free, OwnedLand.getName(chunk), "", "", "", Util.formatCash(plugin.getCostManager().calculateCost(player.getUniqueId()))));
                OwnedLand.highlightLand(player, CParticle.DRIPLAVA);
            }
        }
    }.runTaskAsynchronously(plugin);
}
Also used : LocalDateTime(java.time.LocalDateTime) LPlayer(biz.princeps.landlord.persistent.LPlayer) OwnedLand(biz.princeps.landlord.util.OwnedLand) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) OfflinePlayer(org.bukkit.OfflinePlayer) List(java.util.List) Offers(biz.princeps.landlord.persistent.Offers) Chunk(org.bukkit.Chunk)

Aggregations

LPlayer (biz.princeps.landlord.persistent.LPlayer)8 OwnedLand (biz.princeps.landlord.util.OwnedLand)3 List (java.util.List)3 OfflinePlayer (org.bukkit.OfflinePlayer)3 Conditions (biz.princeps.lib.storage.requests.Conditions)2 Chunk (org.bukkit.Chunk)2 Player (org.bukkit.entity.Player)2 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)2 FinishedLoadingPlayerEvent (biz.princeps.landlord.api.events.FinishedLoadingPlayerEvent)1 LandUnclaimEvent (biz.princeps.landlord.api.events.LandUnclaimEvent)1 LandlordCommand (biz.princeps.landlord.commands.LandlordCommand)1 ManageGUIAll (biz.princeps.landlord.guis.ManageGUIAll)1 VaultHandler (biz.princeps.landlord.handler.VaultHandler)1 WorldGuardHandler (biz.princeps.landlord.handler.WorldGuardHandler)1 CostManager (biz.princeps.landlord.manager.CostManager)1 LPlayerManager (biz.princeps.landlord.manager.LPlayerManager)1 LangManager (biz.princeps.landlord.manager.LangManager)1 MapManager (biz.princeps.landlord.manager.map.MapManager)1 Offers (biz.princeps.landlord.persistent.Offers)1 Requests (biz.princeps.landlord.persistent.Requests)1