Optimize location3DEqual

Former-commit-id: 5a04fb06859af6def40a2e311a84250714b9e155 [formerly 2b6368fb0c28e57ed3b53a57eb06a5d44f79aee5]
Former-commit-id: 54922e734d04b15d55439dba89dc242a031cb5b9
This commit is contained in:
Sotr committed 2019-04-12 12:44:36 +08:00
1 parent 2b770749fd
commit 399e928bda
1 file changed
+12 -4
@@ -46,6 +46,7 @@ public class Util {
private static QuickShop plugin;
private static Method storageContents;
static Map<UUID, Long> timerMap = new HashMap<UUID, Long>();
protected static boolean devMode;
public String boolean2String(boolean bool) {
if (bool) {
return "Enabled";
@@ -57,6 +58,8 @@ public class Util {
blacklist.clear();
shoppables.clear();
restrictedPrices.clear();
devMode = plugin.getConfig().getBoolean("dev-mode");
plugin = QuickShop.instance;
for (String s : plugin.getConfig().getStringList("shop-blocks")) {
@@ -237,11 +240,11 @@ public class Util {
Util.debugLog("Find args: "+b.getLocation().toString());
Util.debugLog("Left: "+leftC.getLocation().toString());
Util.debugLog("Right: "+rightC.getLocation().toString());
if(location3DEqual(b.getLocation(),leftC.getLocation())) {
if(equalsBlockStateLocation(oneSideOfChest, leftC)) {
Util.debugLog("Clicked left chest");
return rightC.getBlock();
}
if(location3DEqual(b.getLocation(),rightC.getLocation())) {
if(equalsBlockStateLocation(oneSideOfChest, leftC)) {
Util.debugLog("Clicked right chest");
return leftC.getBlock();
}
@@ -252,6 +255,11 @@ public class Util {
return null;
}
}
private static final boolean equalsBlockStateLocation(BlockState b1, BlockState b2) {
return b1.getX() == b2.getX() && b1.getY() == b2.getY() && b1.getZ() == b2.getZ();
}
public static boolean location3DEqual(Location loc1, Location loc2){
if(loc1.getWorld().getName() != loc2.getWorld().getName())
return false;
@@ -875,8 +883,8 @@ public class Util {
* @param String logs
*/
public static void debugLog(String logs) {
if(plugin.getConfig().getBoolean("dev-mode")) {
plugin.getLogger().info("[DEBUG] "+logs);
if(devMode) {
plugin.getLogger().warning("[DEBUG] "+logs);
}
}