Skip to content

Commit

Permalink
Fix LocationUtil#getSafeDestination NSME on older versions (#4708)
Browse files Browse the repository at this point in the history
Fixes a NoSuchMethodError from old guava versions in old MC versions.

Fixes #4703
  • Loading branch information
JRoy committed Dec 23, 2021
1 parent 6850842 commit 84326cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.earth2me.essentials.utils;

import com.earth2me.essentials.IEssentials;
import com.google.common.primitives.Ints;
import net.ess3.api.IUser;
import org.bukkit.GameMode;
import org.bukkit.Location;
Expand Down Expand Up @@ -232,12 +231,12 @@ public static Location getSafeDestination(IEssentials ess, final Location loc) t
i++;
if (i >= VOLUME.length) {
x = origX;
y = Ints.constrainToRange(origY + RADIUS, worldMinY, worldMaxY);
y = NumberUtil.constrainToRange(origY + RADIUS, worldMinY, worldMaxY);
z = origZ;
break;
}
x = origX + VOLUME[i].x;
y = Ints.constrainToRange(origY + VOLUME[i].y, worldMinY, worldMaxY);
y = NumberUtil.constrainToRange(origY + VOLUME[i].y, worldMinY, worldMaxY);
z = origZ + VOLUME[i].z;
}
while (isBlockUnsafe(ess, world, x, y, z)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,11 @@ public static boolean isPositiveInt(final String sInt) {
}
return Integer.parseInt(sInt) > 0;
}

/**
* Backport from Guava.
*/
public static int constrainToRange(int value, int min, int max) {
return Math.min(Math.max(value, min), max);
}
}

0 comments on commit 84326cf

Please sign in to comment.