From 1a1bddef367fa8bf3a638774d547ff2884b20eba Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Sun, 16 Nov 2014 14:17:40 -0800 Subject: [PATCH] Perf: Claim Lookup --- src/me/ryanhamshire/GriefPrevention/Claim.java | 16 ++++++++-------- .../ryanhamshire/GriefPrevention/DataStore.java | 10 ++-------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/me/ryanhamshire/GriefPrevention/Claim.java b/src/me/ryanhamshire/GriefPrevention/Claim.java index e52f443..e625897 100644 --- a/src/me/ryanhamshire/GriefPrevention/Claim.java +++ b/src/me/ryanhamshire/GriefPrevention/Claim.java @@ -642,16 +642,16 @@ public class Claim //not in the same world implies false if(!location.getWorld().equals(this.lesserBoundaryCorner.getWorld())) return false; - int x = location.getBlockX(); - int y = location.getBlockY(); - int z = location.getBlockZ(); + double x = location.getX(); + double y = location.getY(); + double z = location.getZ(); //main check - boolean inClaim = (ignoreHeight || y >= this.lesserBoundaryCorner.getBlockY()) && - x >= this.lesserBoundaryCorner.getBlockX() && - x <= this.greaterBoundaryCorner.getBlockX() && - z >= this.lesserBoundaryCorner.getBlockZ() && - z <= this.greaterBoundaryCorner.getBlockZ(); + boolean inClaim = (ignoreHeight || y >= this.lesserBoundaryCorner.getY()) && + x >= this.lesserBoundaryCorner.getX() && + x <= this.greaterBoundaryCorner.getX() && + z >= this.lesserBoundaryCorner.getZ() && + z <= this.greaterBoundaryCorner.getZ(); if(!inClaim) return false; diff --git a/src/me/ryanhamshire/GriefPrevention/DataStore.java b/src/me/ryanhamshire/GriefPrevention/DataStore.java index 815f3ce..9aed141 100644 --- a/src/me/ryanhamshire/GriefPrevention/DataStore.java +++ b/src/me/ryanhamshire/GriefPrevention/DataStore.java @@ -457,8 +457,7 @@ public abstract class DataStore this.playerNameToPlayerDataMap.put(playerID, playerData); } - //try the hash map again. if it's STILL not there, we have a bug to fix - return this.playerNameToPlayerDataMap.get(playerID); + return playerData; } abstract PlayerData getPlayerDataFromStorage(UUID playerID); @@ -566,12 +565,7 @@ public abstract class DataStore //gets a unique, persistent identifier string for a chunk private String getChunkString(Location location) { - StringBuilder builder = new StringBuilder( - String.valueOf(location.getBlockX() >> 4)) - .append(location.getWorld().getName()) - .append(location.getBlockZ() >> 4); - - return builder.toString(); + return (location.getBlockX() >> 4) + location.getWorld().getName() + (location.getBlockZ() >> 4); } //creates a claim.