diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 25a6401..ce86fc9 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -24,6 +24,10 @@ import me.ryanhamshire.GriefPrevention.events.SaveTrappedPlayerEvent; import me.ryanhamshire.GriefPrevention.events.TrustChangedEvent; import me.ryanhamshire.GriefPrevention.alttd.listeners.AltitudeListener; import me.ryanhamshire.GriefPrevention.metrics.MetricsHandler; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; import net.milkbowl.vault.economy.Economy; import org.bukkit.BanList; import org.bukkit.BanList.Type; @@ -2212,6 +2216,68 @@ public class GriefPrevention extends JavaPlugin return true; } + //claimslist or claimslist + else if (cmd.getName().equalsIgnoreCase("claimslistextra")) + { + //at most one parameter + if (args.length > 1) return false; + + //player whose claims will be listed + OfflinePlayer otherPlayer; + + //if another player isn't specified, assume current player + if (args.length < 1) + { + if (player != null) + otherPlayer = player; + else + return false; + } + + //otherwise if no permission to delve into another player's claims data + else if (player != null && !player.hasPermission("griefprevention.claimslistother")) + { + GriefPrevention.sendMessage(player, TextMode.Err, Messages.ClaimsListNoPermission); + return true; + } + + //otherwise try to find the specified player + else + { + otherPlayer = this.resolvePlayerByName(args[0]); + if (otherPlayer == null) + { + GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2); + return true; + } + } + + //load the target player's data + PlayerData playerData = this.dataStore.getPlayerData(otherPlayer.getUniqueId()); + Vector 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())))); + if (claims.size() > 0) + { + GriefPrevention.sendMessage(player, TextMode.Instr, Messages.ClaimsListHeader); + claims.stream().forEach(claim -> { + TextComponent claimInfo = new TextComponent(getExtraLocationString(claim.getLesserBoundaryCorner(), claim.getGreaterBoundaryCorner()) + this.dataStore.getMessage(Messages.ContinueBlockMath, String.valueOf(claim.getArea()))); + claimInfo.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Click here to visit this claim.").create())); + claimInfo.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tppos " + claim.getLesserBoundaryCorner().getBlockX() + " " + claim.getLesserBoundaryCorner().getBlockY() + " " + claim.getLesserBoundaryCorner().getBlockZ() + " ")); + sender.sendMessage(claimInfo); + }); + GriefPrevention.sendMessage(player, TextMode.Instr, Messages.EndBlockMath, String.valueOf(playerData.getRemainingClaimBlocks())); + } + + //drop the data we just loaded, if the player isn't online + if (!otherPlayer.isOnline()) + this.dataStore.clearCachedPlayerData(otherPlayer.getUniqueId()); + + return true; + } + //adminclaimslist else if (cmd.getName().equalsIgnoreCase("adminclaimslist")) { @@ -2878,6 +2944,11 @@ public class GriefPrevention extends JavaPlugin return location.getWorld().getName() + ": x" + location.getBlockX() + ", z" + location.getBlockZ(); } + public static String getExtraLocationString(Location location, Location location2) + { + return location.getWorld().getName() + ": x" + location.getBlockX() + ", z" + location.getBlockZ() + " to x" + location2.getBlockX() + ", z" + location2.getBlockZ(); + } + private boolean abandonClaimHandler(Player player, boolean deleteTopLevelClaim) { PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId()); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 3571777..198665f 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -171,6 +171,11 @@ commands: usage: /ClaimsList or /ClaimsList aliases: [claimlist, listclaims] permission: griefprevention.claims + claimslistextra: + description: Lists information about a player's claim blocks and claims. + usage: /ClaimsList or /ClaimsList + aliases: [ claimlistall ] + permission: griefprevention.claimslistother claimexplosions: description: Toggles whether explosives may be used in a specific land claim. usage: /ClaimExplosions