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)
|
synchronized public void changeClaimOwner(Claim claim, UUID newOwnerID)
|
||||||
{
|
{
|
||||||
//if it's a subdivision, throw an exception
|
//if it's a subdivision, throw an exception
|
||||||
|
|
@ -402,11 +412,19 @@ public abstract class DataStore
|
||||||
|
|
||||||
//determine current claim owner
|
//determine current claim owner
|
||||||
PlayerData ownerData = null;
|
PlayerData ownerData = null;
|
||||||
|
|
||||||
|
//determine new owner
|
||||||
|
PlayerData newOwnerData = null;
|
||||||
if (!claim.isAdminClaim())
|
if (!claim.isAdminClaim())
|
||||||
{
|
{
|
||||||
ownerData = this.getPlayerData(claim.ownerID);
|
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
|
//call event
|
||||||
ClaimTransferEvent event = new ClaimTransferEvent(claim, newOwnerID);
|
ClaimTransferEvent event = new ClaimTransferEvent(claim, newOwnerID);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
@ -414,9 +432,6 @@ public abstract class DataStore
|
||||||
//return if event is cancelled
|
//return if event is cancelled
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
//determine new owner
|
|
||||||
PlayerData newOwnerData = null;
|
|
||||||
|
|
||||||
if (event.getNewOwner() != null)
|
if (event.getNewOwner() != null)
|
||||||
{
|
{
|
||||||
newOwnerData = this.getPlayerData(event.getNewOwner());
|
newOwnerData = this.getPlayerData(event.getNewOwner());
|
||||||
|
|
|
||||||
|
|
@ -1294,6 +1294,11 @@ public class GriefPrevention extends JavaPlugin
|
||||||
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.TransferTopLevel);
|
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.TransferTopLevel);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
catch (DataStore.NoClaimblocksTransferException e)
|
||||||
|
{
|
||||||
|
player.sendMiniMessage("<red>target does have the claimblocks to claim this area.", null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//confirm
|
//confirm
|
||||||
GriefPrevention.sendMessage(player, TextMode.Success, Messages.TransferSuccess);
|
GriefPrevention.sendMessage(player, TextMode.Success, Messages.TransferSuccess);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user