Added support for uuids in claimslist command
This commit is contained in:
parent
f34f0161ae
commit
6cd0d56e9b
|
|
@ -630,6 +630,10 @@ public abstract class DataStore
|
|||
return playerData;
|
||||
}
|
||||
|
||||
synchronized public PlayerData getPlayerDataIfExists(UUID playerID) {
|
||||
return this.playerNameToPlayerDataMap.get(playerID);
|
||||
}
|
||||
|
||||
abstract PlayerData getPlayerDataFromStorage(UUID playerID);
|
||||
|
||||
//deletes a claim or subdivision
|
||||
|
|
|
|||
|
|
@ -2046,13 +2046,14 @@ public class GriefPrevention extends JavaPlugin
|
|||
if (args.length > 1) return false;
|
||||
|
||||
//player whose claims will be listed
|
||||
OfflinePlayer otherPlayer;
|
||||
// OfflinePlayer otherPlayer;
|
||||
UUID uuid;
|
||||
|
||||
//if another player isn't specified, assume current player
|
||||
if (args.length < 1)
|
||||
{
|
||||
if (player != null)
|
||||
otherPlayer = player;
|
||||
uuid = player.getUniqueId();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2067,21 +2068,31 @@ public class GriefPrevention extends JavaPlugin
|
|||
//otherwise try to find the specified player
|
||||
else
|
||||
{
|
||||
otherPlayer = this.resolvePlayerByName(args[0]);
|
||||
OfflinePlayer otherPlayer = this.resolvePlayerByName(args[0]);
|
||||
if (otherPlayer == null)
|
||||
{
|
||||
GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2);
|
||||
return true;
|
||||
try {
|
||||
uuid = UUID.fromString(args[0]);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
uuid = otherPlayer.getUniqueId();
|
||||
}
|
||||
}
|
||||
|
||||
//load the target player's data
|
||||
PlayerData playerData = this.dataStore.getPlayerData(otherPlayer.getUniqueId());
|
||||
PlayerData playerData = this.dataStore.getPlayerDataIfExists(uuid);
|
||||
if (playerData == null) {
|
||||
GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2);
|
||||
return true;
|
||||
}
|
||||
Vector<Claim> claims = playerData.getClaims();
|
||||
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.StartBlockMath,
|
||||
String.valueOf(playerData.getAccruedClaimBlocks()),
|
||||
String.valueOf((playerData.getBonusClaimBlocks() + this.dataStore.getGroupBonusBlocks(otherPlayer.getUniqueId()))),
|
||||
String.valueOf((playerData.getAccruedClaimBlocks() + playerData.getBonusClaimBlocks() + this.dataStore.getGroupBonusBlocks(otherPlayer.getUniqueId()))));
|
||||
String.valueOf((playerData.getBonusClaimBlocks() + this.dataStore.getGroupBonusBlocks(uuid))),
|
||||
String.valueOf((playerData.getAccruedClaimBlocks() + playerData.getBonusClaimBlocks() + this.dataStore.getGroupBonusBlocks(uuid))));
|
||||
if (claims.size() > 0)
|
||||
{
|
||||
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.ClaimsListHeader);
|
||||
|
|
@ -2095,8 +2106,8 @@ public class GriefPrevention extends JavaPlugin
|
|||
}
|
||||
|
||||
//drop the data we just loaded, if the player isn't online
|
||||
if (!otherPlayer.isOnline())
|
||||
this.dataStore.clearCachedPlayerData(otherPlayer.getUniqueId());
|
||||
if (!Bukkit.getOfflinePlayer(uuid).isOnline())
|
||||
this.dataStore.clearCachedPlayerData(uuid);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user