Bug fixes for recent /transferclaim changes.

This commit is contained in:
ryanhamshire 2015-02-11 17:24:40 -08:00
parent ed3347ab9b
commit a29f18fe7a
2 changed files with 19 additions and 7 deletions

View File

@ -324,7 +324,12 @@ public abstract class DataStore
}
//determine new owner
PlayerData newOwnerData = this.getPlayerData(newOwnerID);
PlayerData newOwnerData = null;
if(newOwnerID != null)
{
newOwnerData = this.getPlayerData(newOwnerID);
}
//transfer
claim.ownerID = newOwnerID;
@ -336,7 +341,10 @@ public abstract class DataStore
ownerData.getClaims().remove(claim);
}
newOwnerData.getClaims().add(claim);
if(newOwnerData != null)
{
newOwnerData.getClaims().add(claim);
}
}
//adds a claim to the datastore, making it an effective claim

View File

@ -976,32 +976,36 @@ public class GriefPrevention extends JavaPlugin
return true;
}
OfflinePlayer targetPlayer = null; //no argument = make an admin claim
UUID newOwnerID = null; //no argument = make an admin claim
String ownerName = "admin";
if(args.length > 0)
{
targetPlayer = this.resolvePlayerByName(args[0]);
OfflinePlayer targetPlayer = this.resolvePlayerByName(args[0]);
if(targetPlayer == null)
{
GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2);
return true;
}
newOwnerID = targetPlayer.getUniqueId();
ownerName = targetPlayer.getName();
}
//change ownerhsip
try
{
this.dataStore.changeClaimOwner(claim, targetPlayer.getUniqueId());
this.dataStore.changeClaimOwner(claim, newOwnerID);
}
catch(Exception e)
{
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.TransferTopLevel);
e.printStackTrace();
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.TransferTopLevel);
return true;
}
//confirm
GriefPrevention.sendMessage(player, TextMode.Success, Messages.TransferSuccess);
GriefPrevention.AddLogEntry(player.getName() + " transferred a claim at " + GriefPrevention.getfriendlyLocationString(claim.getLesserBoundaryCorner()) + " to " + targetPlayer.getName() + ".");
GriefPrevention.AddLogEntry(player.getName() + " transferred a claim at " + GriefPrevention.getfriendlyLocationString(claim.getLesserBoundaryCorner()) + " to " + ownerName + ".");
return true;
}