Added show all nearby claims by holding shift.
While holding the stick. Requires a new permission node, to avoid any lag from spamming this operation.
This commit is contained in:
parent
58c6a818ba
commit
298830f076
|
|
@ -156,6 +156,7 @@ permissions:
|
||||||
griefprevention.deathblow: true
|
griefprevention.deathblow: true
|
||||||
griefprevention.softmute: true
|
griefprevention.softmute: true
|
||||||
griefprevention.reload: true
|
griefprevention.reload: true
|
||||||
|
griefprevention.visualizenearbyclaims: true
|
||||||
griefprevention.restorenature:
|
griefprevention.restorenature:
|
||||||
description: Grants permission to use /RestoreNature.
|
description: Grants permission to use /RestoreNature.
|
||||||
default: op
|
default: op
|
||||||
|
|
@ -198,3 +199,6 @@ permissions:
|
||||||
griefprevention.buysellclaimblocks:
|
griefprevention.buysellclaimblocks:
|
||||||
description: Grants access to claim block buy/sell commands.
|
description: Grants access to claim block buy/sell commands.
|
||||||
default: true
|
default: true
|
||||||
|
griefprevention.visualizenearbyclaims:
|
||||||
|
description: Allows a player to see all nearby claims at once.
|
||||||
|
default: op
|
||||||
|
|
@ -1304,4 +1304,29 @@ public abstract class DataStore
|
||||||
asyncSavePlayerData(this.playerID, this.playerData);
|
asyncSavePlayerData(this.playerID, this.playerData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//gets all the claims "near" a location
|
||||||
|
ArrayList<Claim> getNearbyClaims(Location location)
|
||||||
|
{
|
||||||
|
ArrayList<Claim> claims = new ArrayList<Claim>();
|
||||||
|
|
||||||
|
Chunk lesserChunk = location.getWorld().getChunkAt(location.subtract(150, 0, 150));
|
||||||
|
Chunk greaterChunk = location.getWorld().getChunkAt(location.add(300, 0, 300));
|
||||||
|
|
||||||
|
for(int chunk_x = lesserChunk.getX(); chunk_x <= greaterChunk.getX(); chunk_x++)
|
||||||
|
{
|
||||||
|
for(int chunk_z = lesserChunk.getZ(); chunk_z <= greaterChunk.getZ(); chunk_z++)
|
||||||
|
{
|
||||||
|
Chunk chunk = location.getWorld().getChunkAt(chunk_x, chunk_z);
|
||||||
|
String chunkID = this.getChunkString(chunk.getBlock(0, 0, 0).getLocation());
|
||||||
|
ArrayList<Claim> claimsInChunk = this.chunksToClaimsMap.get(chunkID);
|
||||||
|
if(claimsInChunk != null)
|
||||||
|
{
|
||||||
|
claims.addAll(claimsInChunk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return claims;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1361,7 +1361,20 @@ class PlayerEventHandler implements Listener
|
||||||
//if he's investigating a claim
|
//if he's investigating a claim
|
||||||
else if(materialInHand == GriefPrevention.instance.config_claims_investigationTool)
|
else if(materialInHand == GriefPrevention.instance.config_claims_investigationTool)
|
||||||
{
|
{
|
||||||
//FEATURE: shovel and stick can be used from a distance away
|
//if holding shift (sneaking), show all claims in area
|
||||||
|
if(player.isSneaking() && player.hasPermission("griefprevention.visualizenearbyclaims"))
|
||||||
|
{
|
||||||
|
//find nearby claims
|
||||||
|
ArrayList<Claim> claims = this.dataStore.getNearbyClaims(player.getLocation());
|
||||||
|
|
||||||
|
//visualize boundaries
|
||||||
|
Visualization visualization = Visualization.fromClaims(claims, (int)player.getEyeHeight(), VisualizationType.Claim, player.getLocation());
|
||||||
|
Visualization.Apply(player, visualization);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//FEATURE: shovel and stick can be used from a distance away
|
||||||
if(action == Action.RIGHT_CLICK_AIR)
|
if(action == Action.RIGHT_CLICK_AIR)
|
||||||
{
|
{
|
||||||
//try to find a far away non-air block along line of sight
|
//try to find a far away non-air block along line of sight
|
||||||
|
|
@ -1400,7 +1413,7 @@ class PlayerEventHandler implements Listener
|
||||||
GriefPrevention.sendMessage(player, TextMode.Info, Messages.BlockClaimed, claim.getOwnerName());
|
GriefPrevention.sendMessage(player, TextMode.Info, Messages.BlockClaimed, claim.getOwnerName());
|
||||||
|
|
||||||
//visualize boundary
|
//visualize boundary
|
||||||
Visualization visualization = Visualization.FromClaim(claim, clickedBlock.getY(), VisualizationType.Claim, player.getLocation());
|
Visualization visualization = Visualization.FromClaim(claim, (int)player.getEyeHeight(), VisualizationType.Claim, player.getLocation());
|
||||||
Visualization.Apply(player, visualization);
|
Visualization.Apply(player, visualization);
|
||||||
|
|
||||||
//if can resize this claim, tell about the boundaries
|
//if can resize this claim, tell about the boundaries
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public class Visualization
|
||||||
}
|
}
|
||||||
|
|
||||||
//if he's online, create a task to send him the visualization in about half a second
|
//if he's online, create a task to send him the visualization in about half a second
|
||||||
if(player.isOnline() && visualization.elements.get(0).location.getWorld().equals(player.getWorld()))
|
if(player.isOnline() && visualization.elements.size() > 0 && visualization.elements.get(0).location.getWorld().equals(player.getWorld()))
|
||||||
{
|
{
|
||||||
GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, new VisualizationApplicationTask(player, playerData, visualization), 1L);
|
GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, new VisualizationApplicationTask(player, playerData, visualization), 1L);
|
||||||
}
|
}
|
||||||
|
|
@ -183,10 +183,10 @@ public class Visualization
|
||||||
this.elements.add(new VisualizationElement(getVisibleLocation(world, smallx, height, bigz - 1, waterIsTransparent), accentMaterial, (byte)0));
|
this.elements.add(new VisualizationElement(getVisibleLocation(world, smallx, height, bigz - 1, waterIsTransparent), accentMaterial, (byte)0));
|
||||||
|
|
||||||
//locality
|
//locality
|
||||||
int minx = locality.getBlockX() - 100;
|
int minx = locality.getBlockX() - 200;
|
||||||
int minz = locality.getBlockZ() - 100;
|
int minz = locality.getBlockZ() - 200;
|
||||||
int maxx = locality.getBlockX() + 100;
|
int maxx = locality.getBlockX() + 200;
|
||||||
int maxz = locality.getBlockZ() + 100;
|
int maxz = locality.getBlockZ() + 200;
|
||||||
|
|
||||||
//top line
|
//top line
|
||||||
for(int x = smallx + 10; x < bigx - 10; x += 10)
|
for(int x = smallx + 10; x < bigx - 10; x += 10)
|
||||||
|
|
@ -249,4 +249,16 @@ public class Visualization
|
||||||
(waterIsTransparent && block.getType() == Material.STATIONARY_WATER) ||
|
(waterIsTransparent && block.getType() == Material.STATIONARY_WATER) ||
|
||||||
block.getType().isTransparent()));
|
block.getType().isTransparent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Visualization fromClaims(ArrayList<Claim> claims, int height, VisualizationType type, Location locality)
|
||||||
|
{
|
||||||
|
Visualization visualization = new Visualization();
|
||||||
|
|
||||||
|
for(Claim claim : claims)
|
||||||
|
{
|
||||||
|
visualization.addClaimElements(claim, height, type, locality);
|
||||||
|
}
|
||||||
|
|
||||||
|
return visualization;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user