Signs now update quicker when updated, as opposed to waiting for the
next update
This commit is contained in:
parent
7ed6a0674b
commit
f1b20038c5
@ -6,6 +6,7 @@ import java.util.regex.Pattern;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -29,7 +30,6 @@ public class REListener implements Listener
|
|||||||
pm.registerEvents(this, RealEstate.instance);
|
pm.registerEvents(this, RealEstate.instance);
|
||||||
//RealEstate.instance.getCommand("re").setExecutor(this);
|
//RealEstate.instance.getCommand("re").setExecutor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onSignChange(SignChangeEvent event)
|
public void onSignChange(SignChangeEvent event)
|
||||||
{
|
{
|
||||||
@ -40,7 +40,6 @@ public class REListener implements Listener
|
|||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location loc = event.getBlock().getLocation();
|
Location loc = event.getBlock().getLocation();
|
||||||
|
|
||||||
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(loc, false, null);
|
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(loc, false, null);
|
||||||
if(claim == null)// must have something to sell
|
if(claim == null)// must have something to sell
|
||||||
{
|
{
|
||||||
@ -259,6 +258,7 @@ public class REListener implements Listener
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
RealEstate.transactionsStore.rent(claim, player, price, event.getBlock().getLocation(), duration, rentPeriods,
|
RealEstate.transactionsStore.rent(claim, player, price, event.getBlock().getLocation(), duration, rentPeriods,
|
||||||
RealEstate.instance.config.cfgRentKeywords.contains(event.getLine(0).toLowerCase()));
|
RealEstate.instance.config.cfgRentKeywords.contains(event.getLine(0).toLowerCase()));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(RealEstate.instance.config.cfgLeaseKeywords.contains(event.getLine(0).toLowerCase()))// we want to rent it
|
else if(RealEstate.instance.config.cfgLeaseKeywords.contains(event.getLine(0).toLowerCase()))// we want to rent it
|
||||||
{
|
{
|
||||||
@ -364,6 +364,17 @@ public class REListener implements Listener
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
RealEstate.transactionsStore.lease(claim, player, price, event.getBlock().getLocation(), frequency, paymentsCount);
|
RealEstate.transactionsStore.lease(claim, player, price, event.getBlock().getLocation(), frequency, paymentsCount);
|
||||||
}
|
}
|
||||||
|
RealEstate.instance.getServer().getScheduler().scheduleSyncDelayedTask(RealEstate.instance, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
//in short we want to have the transaction update here...
|
||||||
|
//
|
||||||
|
Transaction tr = RealEstate.transactionsStore.getTransaction(claim);
|
||||||
|
RealEstate.transactionsStore.kickTransaction(tr);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,8 @@ import java.time.LocalTime;
|
|||||||
import java.time.Period;
|
import java.time.Period;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|||||||
@ -175,7 +175,23 @@ public class TransactionsStore
|
|||||||
}
|
}
|
||||||
saveData();
|
saveData();
|
||||||
}
|
}
|
||||||
|
public void kickTransaction (Transaction tr)
|
||||||
|
{
|
||||||
|
if(tr instanceof ClaimSell)
|
||||||
|
{
|
||||||
|
tr.update();
|
||||||
|
}
|
||||||
|
if(tr instanceof ClaimRent)
|
||||||
|
{
|
||||||
|
tr.update();
|
||||||
|
}
|
||||||
|
if(tr instanceof ClaimLease)
|
||||||
|
{
|
||||||
|
tr.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
public boolean canCancelTransaction(Transaction tr)
|
public boolean canCancelTransaction(Transaction tr)
|
||||||
{
|
{
|
||||||
return tr instanceof ClaimSell || (tr instanceof ClaimRent && ((ClaimRent)tr).buyer == null) ||
|
return tr instanceof ClaimSell || (tr instanceof ClaimRent && ((ClaimRent)tr).buyer == null) ||
|
||||||
@ -227,6 +243,7 @@ public class TransactionsStore
|
|||||||
|
|
||||||
public void rent(Claim claim, Player player, double price, Location sign, int duration, int rentPeriods, boolean buildTrust)
|
public void rent(Claim claim, Player player, double price, Location sign, int duration, int rentPeriods, boolean buildTrust)
|
||||||
{
|
{
|
||||||
|
|
||||||
ClaimRent cr = new ClaimRent(claim, claim.isAdminClaim() ? null : player, price, sign, duration, rentPeriods, buildTrust);
|
ClaimRent cr = new ClaimRent(claim, claim.isAdminClaim() ? null : player, price, sign, duration, rentPeriods, buildTrust);
|
||||||
claimRent.put(claim.getID().toString(), cr);
|
claimRent.put(claim.getID().toString(), cr);
|
||||||
cr.update();
|
cr.update();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user