From e76755118874154b4bb3e3e98180520258761cf7 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Wed, 21 Oct 2015 13:09:14 -0700 Subject: [PATCH] Public API to get claims by chunk. --- .../GriefPrevention/DataStore.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/me/ryanhamshire/GriefPrevention/DataStore.java b/src/me/ryanhamshire/GriefPrevention/DataStore.java index f89d9a1..5651cdf 100644 --- a/src/me/ryanhamshire/GriefPrevention/DataStore.java +++ b/src/me/ryanhamshire/GriefPrevention/DataStore.java @@ -661,10 +661,29 @@ public abstract class DataStore return Collections.unmodifiableCollection(this.claims); } + public Collection getClaims(int chunkx, int chunkz) + { + ArrayList chunkClaims = this.chunksToClaimsMap.get(this.getChunkString(chunkx, chunkz)); + if(chunkClaims != null) + { + return Collections.unmodifiableCollection(chunkClaims); + } + else + { + return Collections.unmodifiableCollection(new ArrayList()); + } + } + + //gets an almost-unique, persistent identifier string for a chunk + String getChunkString(int chunkx, int chunkz) + { + return String.valueOf(chunkx) + (chunkz); + } + //gets an almost-unique, persistent identifier string for a chunk String getChunkString(Location location) { - return String.valueOf(location.getBlockX() >> 4) + (location.getBlockZ() >> 4); + return this.getChunkString(location.getBlockX() >> 4, location.getBlockZ() >> 4); } //creates a claim.