diff --git a/Essentials/pom.xml b/Essentials/pom.xml
index a0401ec2a..4bd127aaf 100644
--- a/Essentials/pom.xml
+++ b/Essentials/pom.xml
@@ -36,6 +36,12 @@
false
+
+
+ io.papermc.lib
+ com.earth2me.essentials.paperlib
+
+
@@ -48,6 +54,12 @@
1.7
provided
+
+ io.papermc
+ paperlib
+ 1.0.2
+ compile
+
net.ess3
NMSProvider
@@ -95,12 +107,6 @@
ReflectionProvider
2.16.0
compile
-
-
- org.bukkit
- craftbukkit
-
-
net.ess3
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
index 9192d6c2d..f13443573 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
@@ -7,6 +7,7 @@ import com.earth2me.essentials.textreader.TextPager;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.LocationUtil;
import com.earth2me.essentials.utils.MaterialUtil;
+import io.papermc.lib.PaperLib;
import net.ess3.api.IEssentials;
import org.bukkit.BanEntry;
@@ -642,7 +643,7 @@ public class EssentialsPlayerListener implements Listener {
while (LocationUtil.isBlockDamaging(loc.getWorld(), loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ())) {
loc.setY(loc.getY() + 1d);
}
- user.getBase().teleport(loc, TeleportCause.PLUGIN);
+ PaperLib.teleportAsync(user.getBase(), loc, TeleportCause.PLUGIN);
}
}
ess.scheduleSyncDelayedTask(new DelayedClickJumpTask());
diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java
index 82d17ffae..4db4543cf 100644
--- a/Essentials/src/com/earth2me/essentials/Teleport.java
+++ b/Essentials/src/com/earth2me/essentials/Teleport.java
@@ -2,7 +2,9 @@ package com.earth2me.essentials;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.LocationUtil;
+import io.papermc.lib.PaperLib;
import net.ess3.api.IEssentials;
+import net.ess3.api.ITeleport;
import net.ess3.api.IUser;
import net.ess3.api.events.UserWarpEvent;
import org.bukkit.Bukkit;
@@ -18,7 +20,7 @@ import java.util.GregorianCalendar;
import static com.earth2me.essentials.I18n.tl;
-public class Teleport implements net.ess3.api.ITeleport {
+public class Teleport implements ITeleport {
private final IUser teleportOwner;
private final IEssentials ess;
private TimedTeleport timedTeleport;
@@ -49,7 +51,7 @@ public class Teleport implements net.ess3.api.ITeleport {
final long earliestLong = earliestTime.getTimeInMillis();
// When was the last teleportPlayer used?
- final Long lastTime = teleportOwner.getLastTeleportTimestamp();
+ final long lastTime = teleportOwner.getLastTeleportTimestamp();
if (lastTime > time.getTimeInMillis()) {
// This is to make sure time didn't get messed up on last teleportPlayer use.
@@ -124,21 +126,21 @@ public class Teleport implements net.ess3.api.ITeleport {
if (LocationUtil.isBlockUnsafeForUser(teleportee, loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
if (ess.getSettings().isTeleportSafetyEnabled()) {
if (ess.getSettings().isForceDisableTeleportSafety()) {
- teleportee.getBase().teleport(loc, cause);
+ PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
} else {
- teleportee.getBase().teleport(LocationUtil.getSafeDestination(ess, teleportee, loc), cause);
+ PaperLib.teleportAsync(teleportee.getBase(), LocationUtil.getSafeDestination(ess, teleportee, loc), cause);
}
} else {
throw new Exception(tl("unsafeTeleportDestination", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
}
} else {
if (ess.getSettings().isForceDisableTeleportSafety()) {
- teleportee.getBase().teleport(loc, cause);
+ PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
} else {
if (ess.getSettings().isTeleportToCenterLocation()) {
loc = LocationUtil.getRoundedDestination(loc);
}
- teleportee.getBase().teleport(loc, cause);
+ PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
}
}
}
@@ -231,7 +233,7 @@ public class Teleport implements net.ess3.api.ITeleport {
initTimer((long) (delay * 1000.0), teleportOwner, null, chargeFor, cause, true);
}
- protected void respawnNow(IUser teleportee, TeleportCause cause) throws Exception {
+ void respawnNow(IUser teleportee, TeleportCause cause) throws Exception {
final Player player = teleportee.getBase();
Location bed = player.getBedSpawnLocation();
if (bed != null) {
diff --git a/Essentials/src/com/earth2me/essentials/TimedTeleport.java b/Essentials/src/com/earth2me/essentials/TimedTeleport.java
index 0544c6c8c..c3e959f58 100644
--- a/Essentials/src/com/earth2me/essentials/TimedTeleport.java
+++ b/Essentials/src/com/earth2me/essentials/TimedTeleport.java
@@ -16,9 +16,9 @@ public class TimedTeleport implements Runnable {
private final IEssentials ess;
private final Teleport teleport;
private final UUID timer_teleportee;
- private int timer_task = -1;
- private final long timer_started; // time this task was initiated
- private final long timer_delay; // how long to delay the teleportPlayer
+ private int timer_task;
+ private final long timer_started; // time this task was initiated
+ private final long timer_delay; // how long to delay the teleportPlayer
private double timer_health;
// note that I initially stored a clone of the location for reference, but...
// when comparing locations, I got incorrect mismatches (rounding errors, looked like)
@@ -32,8 +32,7 @@ public class TimedTeleport implements Runnable {
private final Trade timer_chargeFor;
private final TeleportCause timer_cause;
- public TimedTeleport(IUser user, IEssentials ess, Teleport teleport, long delay, IUser teleportUser, ITarget target, Trade chargeFor, TeleportCause cause, boolean respawn) {
-
+ TimedTeleport(IUser user, IEssentials ess, Teleport teleport, long delay, IUser teleportUser, ITarget target, Trade chargeFor, TeleportCause cause, boolean respawn) {
this.teleportOwner = user;
this.ess = ess;
this.teleport = teleport;
@@ -111,8 +110,7 @@ public class TimedTeleport implements Runnable {
if (timer_chargeFor != null) {
timer_chargeFor.charge(teleportOwner);
}
- } catch (Exception ex) {
- }
+ } catch (Exception ignored) {}
} catch (Exception ex) {
ess.showError(teleportOwner.getSource(), ex, "\\ teleport");
@@ -124,7 +122,7 @@ public class TimedTeleport implements Runnable {
}
//If we need to cancelTimer a pending teleportPlayer call this method
- public void cancelTimer(boolean notifyUser) {
+ void cancelTimer(boolean notifyUser) {
if (timer_task == -1) {
return;
}
diff --git a/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java b/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java
index 571333347..d8a54781c 100644
--- a/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java
+++ b/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java
@@ -17,7 +17,7 @@ import static com.earth2me.essentials.I18n.tl;
public class LocationUtil {
// The player can stand inside these materials
- public static final Set HOLLOW_MATERIALS = new HashSet<>();
+ private static final Set HOLLOW_MATERIALS = new HashSet<>();
private static final Set TRANSPARENT_MATERIALS = new HashSet<>();
static {
@@ -32,8 +32,7 @@ public class LocationUtil {
TRANSPARENT_MATERIALS.add(Material.WATER);
try {
TRANSPARENT_MATERIALS.add(Material.valueOf("FLOWING_WATER"));
- } catch (Exception ignored) { // 1.13 WATER uses Levelled
- }
+ } catch (Exception ignored) {} // 1.13 WATER uses Levelled
}
public static final int RADIUS = 3;
@@ -49,7 +48,7 @@ public class LocationUtil {
public int y;
public int z;
- public Vector3D(int x, int y, int z) {
+ Vector3D(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
@@ -57,7 +56,7 @@ public class LocationUtil {
}
static {
- List pos = new ArrayList();
+ List pos = new ArrayList<>();
for (int x = -RADIUS; x <= RADIUS; x++) {
for (int y = -RADIUS; y <= RADIUS; y++) {
for (int z = -RADIUS; z <= RADIUS; z++) {
@@ -65,30 +64,22 @@ public class LocationUtil {
}
}
}
- Collections.sort(pos, new Comparator() {
- @Override
- public int compare(Vector3D a, Vector3D b) {
- return (a.x * a.x + a.y * a.y + a.z * a.z) - (b.x * b.x + b.y * b.y + b.z * b.z);
- }
- });
+ pos.sort(Comparator.comparingInt(a -> (a.x * a.x + a.y * a.y + a.z * a.z)));
VOLUME = pos.toArray(new Vector3D[0]);
}
- @SuppressWarnings("deprecation")
public static Location getTarget(final LivingEntity entity) throws Exception {
Block block = null;
try {
block = entity.getTargetBlock(TRANSPARENT_MATERIALS, 300);
- } catch (NoSuchMethodError e) {
- // failing now :(
- }
+ } catch (NoSuchMethodError ignored) {} // failing now :(
if (block == null) {
throw new Exception("Not targeting a block");
}
return block.getLocation();
}
- static boolean isBlockAboveAir(final World world, final int x, final int y, final int z) {
+ public static boolean isBlockAboveAir(final World world, final int x, final int y, final int z) {
return y > world.getMaxHeight() || HOLLOW_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType());
}
@@ -124,8 +115,7 @@ public class LocationUtil {
if (below.getType() == Material.valueOf("FLOWING_LAVA")) {
return true;
}
- } catch (Exception ignored) { // 1.13 LAVA uses Levelled
- }
+ } catch (Exception ignored) {} // 1.13 LAVA uses Levelled
Material PORTAL = EnumUtil.getMaterial("NETHER_PORTAL", "PORTAL");
@@ -159,7 +149,6 @@ public class LocationUtil {
user.getBase().setFlying(true);
}
// ess can be null if old deprecated method is calling it.
- System.out.println((ess == null) + " " + ess.getSettings().isTeleportToCenterLocation());
if (ess == null || ess.getSettings().isTeleportToCenterLocation()) {
return getRoundedDestination(loc);
} else {
diff --git a/Essentials/test/com/earth2me/essentials/FakeServer.java b/Essentials/test/com/earth2me/essentials/FakeServer.java
index 4adcce1ac..f0e8d9e09 100644
--- a/Essentials/test/com/earth2me/essentials/FakeServer.java
+++ b/Essentials/test/com/earth2me/essentials/FakeServer.java
@@ -445,6 +445,10 @@ public class FakeServer implements Server {
}
@Override
+ public MapView getMap(short i) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
public MapView getMap(int id) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -1050,7 +1054,6 @@ public class FakeServer implements Server {
throw new UnsupportedOperationException("Not supported yet.");
}
- @Override
public Iterable> getTags(String registry, Class clazz) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -1216,10 +1219,10 @@ public class FakeServer implements Server {
}
}
- @Override
+ @Override
public LootTable getLootTable(NamespacedKey arg0) {
throw new UnsupportedOperationException("Not supported yet.");
- }
+ }
@Override
public List selectEntities(CommandSender sender, String selector) throws IllegalArgumentException {
diff --git a/EssentialsSpawn/pom.xml b/EssentialsSpawn/pom.xml
index f32b8eace..e2946535d 100644
--- a/EssentialsSpawn/pom.xml
+++ b/EssentialsSpawn/pom.xml
@@ -21,5 +21,10 @@
EssentialsX
${project.version}
+
+ io.papermc
+ paperlib
+ 1.0.2
+
\ No newline at end of file
diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
index d4e787f6b..05db07ed8 100644
--- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
+++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
@@ -6,6 +6,7 @@ import com.earth2me.essentials.User;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.KeywordReplacer;
import com.earth2me.essentials.textreader.SimpleTextPager;
+import io.papermc.lib.PaperLib;
import net.ess3.api.IEssentials;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -74,8 +75,7 @@ class EssentialsSpawnPlayerListener implements Listener {
ess.scheduleSyncDelayedTask(() -> {
Location spawn = spawns.getSpawn(user.getGroup());
try {
- // We don't use user.getTeleport() because it stores last location, which is unwanted in this case.
- user.getBase().teleport(spawn, TeleportCause.PLUGIN);
+ PaperLib.teleportAsync(user.getBase(), spawn, TeleportCause.PLUGIN);
} catch (Exception e) {
ess.showError(user.getSource(), e, "spawn-on-join");
}
diff --git a/pom.xml b/pom.xml
index 84bdab522..0c75e67ec 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,6 +31,10 @@
bukkit-repo
https://hub.spigotmc.org/nexus/content/groups/public/
+
+ paper-repo
+ https://papermc.io/repo/repository/maven-public/
+