Check if target has claimblocks required when transfering claims
This commit is contained in:
parent
396b7d57fc
commit
e2dccaad95
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Ignore all differences in line endings
|
||||
* -crlf
|
||||
|
|
@ -390,6 +390,16 @@ public abstract class DataStore
|
|||
}
|
||||
}
|
||||
|
||||
public class NoClaimblocksTransferException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
NoClaimblocksTransferException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
synchronized public void changeClaimOwner(Claim claim, UUID newOwnerID)
|
||||
{
|
||||
//if it's a subdivision, throw an exception
|
||||
|
|
@ -402,11 +412,19 @@ public abstract class DataStore
|
|||
|
||||
//determine current claim owner
|
||||
PlayerData ownerData = null;
|
||||
|
||||
//determine new owner
|
||||
PlayerData newOwnerData = null;
|
||||
if (!claim.isAdminClaim())
|
||||
{
|
||||
ownerData = this.getPlayerData(claim.ownerID);
|
||||
}
|
||||
|
||||
if (newOwnerID != null) {
|
||||
newOwnerData = this.getPlayerData(newOwnerID);
|
||||
if (!(newOwnerData.getRemainingClaimBlocks() >= claim.getArea()))
|
||||
throw new NoClaimblocksTransferException("Target does not have the claimblocks to claim this area.");
|
||||
}
|
||||
//call event
|
||||
ClaimTransferEvent event = new ClaimTransferEvent(claim, newOwnerID);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
|
@ -414,9 +432,6 @@ public abstract class DataStore
|
|||
//return if event is cancelled
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
//determine new owner
|
||||
PlayerData newOwnerData = null;
|
||||
|
||||
if (event.getNewOwner() != null)
|
||||
{
|
||||
newOwnerData = this.getPlayerData(event.getNewOwner());
|
||||
|
|
|
|||
|
|
@ -1294,6 +1294,11 @@ public class GriefPrevention extends JavaPlugin
|
|||
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.TransferTopLevel);
|
||||
return true;
|
||||
}
|
||||
catch (DataStore.NoClaimblocksTransferException e)
|
||||
{
|
||||
player.sendMiniMessage("<red>target does have the claimblocks to claim this area.", null);
|
||||
return true;
|
||||
}
|
||||
|
||||
//confirm
|
||||
GriefPrevention.sendMessage(player, TextMode.Success, Messages.TransferSuccess);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user