@Override public void schedule(String world, String region) { if (Utils.getEntryBoolean(this, world, region, "taken")) { if (Utils.getEntryLong(this, world, region, "expiredate") < System.currentTimeMillis()) { if (Utils.getEntry(this, world, region, "owner") != null) { final String owner = Utils.getEntryString(this, world, region, "owner"); final String account = Utils.getEntryString(this, world, region, "account"); final Double price = Utils.getEntryDouble(this, world, region, "price"); final Player player = Bukkit.getPlayer(owner); if (SimpleRegionMarket.econManager.econHasEnough(owner, price)) { if (SimpleRegionMarket.econManager.moneyTransaction(owner, account, price)) { final long newExpTime = Utils.getEntryLong(this, world, region, "expiredate") + Utils.getEntryLong(this, world, region, "renttime"); Utils.setEntry(this, world, region, "expiredate", newExpTime); if (player != null) { if (SimpleRegionMarket.configurationHandler .getConfig() .getBoolean("Show_Auto_Expand_Message", true)) { final ArrayList<String> list = new ArrayList<String>(); list.add(region); LangHandler.NormalOut(player, "PLAYER.REGION.AUTO_EXPANDED", list); } SimpleRegionMarket.statisticManager.onMoneysUse( this.id, world, price, account, player.getName()); } return; } } if (player != null) { final ArrayList<String> list = new ArrayList<String>(); list.add(region); LangHandler.NormalOut(player, "PLAYER.REGION.EXPIRED", list); } } untakeRegion(world, region); } } }
@Override public void takeRegion(Player newOwner, String world, String region) { final ProtectedRegion protectedRegion = SimpleRegionMarket.wgManager.getProtectedRegion(Bukkit.getWorld(world), region); if (Utils.getEntryBoolean(this, world, region, "taken")) { final Player oldOwner = Bukkit.getPlayer(Utils.getEntryString(this, world, region, "owner")); final ArrayList<String> list = new ArrayList<String>(); list.add(region); list.add(newOwner.getName()); LangHandler.NormalOut(oldOwner, "PLAYER.REGION.JUST_TAKEN_BY", list); untakeRegion(world, region); } else { // Clear Members protectedRegion.setMembers(new DefaultDomain()); } protectedRegion.getMembers().addPlayer(SimpleRegionMarket.wgManager.wrapPlayer(newOwner)); checkTakeActions(protectedRegion, world); Utils.setEntry(this, world, region, "taken", true); Utils.setEntry(this, world, region, "owner", newOwner.getName()); Utils.setEntry( this, world, region, "expiredate", System.currentTimeMillis() + Utils.getEntryLong(this, world, region, "renttime")); Utils.setEntry(this, world, region, "hidden", true); final ArrayList<String> list = new ArrayList<String>(); list.add(region); LangHandler.NormalOut(newOwner, "PLAYER.REGION.RENT", list); tokenManager.updateSigns(this, world, region); }