/TransferClaim updates.

1. Requires new transferclaim permission.
2. Does not adjust anyone's bonus blocks.
3. No argument means "make it an admin claim".
This commit is contained in:
ryanhamshire 2015-02-11 15:39:30 -08:00
parent c8d7c3a08a
commit 27089048ea
3 changed files with 21 additions and 19 deletions

View File

@ -120,7 +120,7 @@ commands:
description: Converts an administrative claim to a private claim. description: Converts an administrative claim to a private claim.
usage: /TransferClaim <player> usage: /TransferClaim <player>
aliases: giveclaim aliases: giveclaim
permission: griefprevention.adjustclaimblocks permission: griefprevention.transferclaim
unlockdrops: unlockdrops:
description: Allows other players to pick up the items you dropped when you died. description: Allows other players to pick up the items you dropped when you died.
usage: /UnlockDrops usage: /UnlockDrops
@ -167,9 +167,13 @@ permissions:
griefprevention.reload: true griefprevention.reload: true
griefprevention.visualizenearbyclaims: true griefprevention.visualizenearbyclaims: true
griefprevention.overrideclaimcountlimit: true griefprevention.overrideclaimcountlimit: true
griefprevention.transferclaim: true
griefprevention.restorenature: griefprevention.restorenature:
description: Grants permission to use /RestoreNature. description: Grants permission to use /RestoreNature.
default: op default: op
griefprevention.transferclaim:
description: Grants permission to use /TransferClaim.
default: op
griefprevention.ignoreclaims: griefprevention.ignoreclaims:
description: Grants permission to use /IgnoreClaims. description: Grants permission to use /IgnoreClaims.
default: op default: op

View File

@ -334,13 +334,9 @@ public abstract class DataStore
if(ownerData != null) if(ownerData != null)
{ {
ownerData.getClaims().remove(claim); ownerData.getClaims().remove(claim);
ownerData.setBonusClaimBlocks(ownerData.getBonusClaimBlocks() - claim.getArea());
this.savePlayerData(claim.ownerID, ownerData);
} }
newOwnerData.getClaims().add(claim); newOwnerData.getClaims().add(claim);
newOwnerData.setBonusClaimBlocks(newOwnerData.getBonusClaimBlocks() + claim.getArea());
this.savePlayerData(newOwnerID, newOwnerData);
} }
//adds a claim to the datastore, making it an effective claim //adds a claim to the datastore, making it an effective claim

View File

@ -961,16 +961,6 @@ public class GriefPrevention extends JavaPlugin
//transferclaim <player> //transferclaim <player>
else if(cmd.getName().equalsIgnoreCase("transferclaim") && player != null) else if(cmd.getName().equalsIgnoreCase("transferclaim") && player != null)
{ {
//requires exactly one parameter, the other player's name
if(args.length != 1) return false;
//check additional permission
if(!player.hasPermission("griefprevention.adminclaims"))
{
GriefPrevention.sendMessage(player, TextMode.Err, Messages.TransferClaimPermission);
return true;
}
//which claim is the user in? //which claim is the user in?
Claim claim = this.dataStore.getClaimAt(player.getLocation(), true, null); Claim claim = this.dataStore.getClaimAt(player.getLocation(), true, null);
if(claim == null) if(claim == null)
@ -979,12 +969,24 @@ public class GriefPrevention extends JavaPlugin
return true; return true;
} }
OfflinePlayer targetPlayer = this.resolvePlayerByName(args[0]); //check additional permission for admin claims
if(claim.isAdminClaim() && !player.hasPermission("griefprevention.adminclaims"))
{
GriefPrevention.sendMessage(player, TextMode.Err, Messages.TransferClaimPermission);
return true;
}
OfflinePlayer targetPlayer = null; //no argument = make an admin claim
if(args.length > 0)
{
targetPlayer = this.resolvePlayerByName(args[0]);
if(targetPlayer == null) if(targetPlayer == null)
{ {
GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2); GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2);
return true; return true;
} }
}
//change ownerhsip //change ownerhsip
try try