feat: Update to 1.16.5-R0.1-SNAPSHOT dependency

This commit is contained in:
Ben Woo 2023-02-02 15:01:07 +08:00
parent 697fee8c4c
commit 27c2f7b9e9
7 changed files with 30 additions and 246 deletions

View File

@ -280,10 +280,10 @@
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- SerializationConfig Dependency -->
<dependency>

View File

@ -89,20 +89,19 @@ import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
import com.onarandombox.MultiverseCore.listeners.MVWorldInitListener;
import com.onarandombox.MultiverseCore.listeners.MVWorldListener;
import com.onarandombox.MultiverseCore.utils.AnchorManager;
import com.onarandombox.MultiverseCore.utils.CompatibilityLayer;
import com.onarandombox.MultiverseCore.utils.MVEconomist;
import com.onarandombox.MultiverseCore.utils.MVMessaging;
import com.onarandombox.MultiverseCore.utils.MVPermissions;
import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
import com.onarandombox.MultiverseCore.utils.MaterialConverter;
import com.onarandombox.MultiverseCore.utils.TestingMode;
import com.onarandombox.MultiverseCore.utils.metrics.MetricsConfigurator;
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.TestingMode;
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
import com.onarandombox.MultiverseCore.utils.VaultHandler;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import com.onarandombox.MultiverseCore.utils.metrics.MetricsConfigurator;
import com.pneumaticraft.commandhandler.CommandHandler;
import me.main__.util.SerializationConfig.NoSuchPropertyException;
import me.main__.util.SerializationConfig.SerializationConfig;
@ -257,8 +256,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Setup our SafeTTeleporter
this.safeTTeleporter = new SimpleSafeTTeleporter(this);
this.unsafeCallWrapper = new UnsafeCallWrapper(this);
// Setup our CompatibilityLayer
CompatibilityLayer.init();
}

View File

@ -11,6 +11,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
import java.util.UUID;
/**
* Used by {@link CommandQueueManager}, so different commands block can be recognised as one.
@ -27,6 +28,16 @@ class DummyCommandBlockSender implements CommandSender {
throw new UnsupportedOperationException();
}
@Override
public void sendMessage(@Nullable UUID uuid, @NotNull String s) {
throw new UnsupportedOperationException();
}
@Override
public void sendMessage(@Nullable UUID uuid, @NotNull String[] strings) {
throw new UnsupportedOperationException();
}
@Override
public @NotNull Server getServer() {
return Bukkit.getServer();
@ -37,6 +48,12 @@ class DummyCommandBlockSender implements CommandSender {
return "DummyCommandBlockSender";
}
@NotNull
@Override
public Spigot spigot() {
throw new UnsupportedOperationException();
}
@Override
public boolean isPermissionSet(@NotNull String name) {
throw new UnsupportedOperationException();

View File

@ -11,7 +11,6 @@ import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.CompatibilityLayer;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -24,8 +23,6 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import java.util.logging.Level;
/**
* Multiverse's Entity {@link Listener}.
*/
@ -119,7 +116,7 @@ public class MVEntityListener implements Listener {
return;
}
if (!this.plugin.getMVConfig().isUsingDefaultPortalSearch()) {
CompatibilityLayer.setPortalSearchRadius(event, this.plugin.getMVConfig().getPortalSearchRadius());
event.setSearchRadius(this.plugin.getMVConfig().getPortalSearchRadius());
}
}
}

View File

@ -7,13 +7,14 @@
package com.onarandombox.MultiverseCore.listeners;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.enums.RespawnType;
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
import com.onarandombox.MultiverseCore.utils.CompatibilityLayer;
import com.onarandombox.MultiverseCore.utils.PermissionTools;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -31,9 +32,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Multiverse's {@link Listener} for players.
*/
@ -70,16 +68,8 @@ public class MVPlayerListener implements Listener {
return;
}
RespawnType respawnType = RespawnType.OTHER;
if (event.isBedSpawn()) {
respawnType = RespawnType.BED;
}
if (CompatibilityLayer.isAnchorSpawn(event)) {
respawnType = RespawnType.ANCHOR;
}
if (mvWorld.getBedRespawn() && (respawnType == RespawnType.BED || respawnType == RespawnType.ANCHOR)) {
Logging.fine("Spawning %s at their %s", event.getPlayer().getName(), respawnType);
if (mvWorld.getBedRespawn() && (event.isBedSpawn() || event.isAnchorSpawn())) {
Logging.fine("Spawning %s at their %s.", event.getPlayer().getName(), event.isBedSpawn() ? "BED" : "ANCHOR");
return;
}
@ -313,7 +303,7 @@ public class MVPlayerListener implements Listener {
+ "' because enforceaccess is off.");
}
if (!this.plugin.getMVConfig().isUsingDefaultPortalSearch()) {
CompatibilityLayer.setPortalSearchRadius(event, this.plugin.getMVConfig().getPortalSearchRadius());
event.setSearchRadius(this.plugin.getMVConfig().getPortalSearchRadius());
}
}

View File

@ -1,111 +0,0 @@
package com.onarandombox.MultiverseCore.utils;
import java.util.logging.Level;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.destination.CannonDestination;
import org.bukkit.Location;
import org.bukkit.TravelAgent;
import org.bukkit.event.player.PlayerPortalEvent;
public class BukkitTravelAgent implements TravelAgent {
private final MVTravelAgent agent;
public BukkitTravelAgent(MVTravelAgent agent) {
this.agent = agent;
}
/**
* {@inheritDoc}
*/
@Override
public BukkitTravelAgent setSearchRadius(int radius) {
return this;
}
/**
* {@inheritDoc}
*/
@Override
public int getSearchRadius() {
return 0;
}
/**
* {@inheritDoc}
*/
@Override
public BukkitTravelAgent setCreationRadius(int radius) {
return this;
}
/**
* {@inheritDoc}
*/
@Override
public int getCreationRadius() {
return 0;
}
/**
* {@inheritDoc}
*/
@Override
public boolean getCanCreatePortal() {
return false;
}
/**
* {@inheritDoc}
*/
@Override
public void setCanCreatePortal(boolean create) {
}
/**
* {@inheritDoc}
*/
@Override
public Location findOrCreate(Location location) {
return this.getSafeLocation();
}
/**
* {@inheritDoc}
*/
@Override
public Location findPortal(Location location) {
return this.getSafeLocation();
}
/**
* {@inheritDoc}
*/
@Override
public boolean createPortal(Location location) {
return false;
}
private Location getSafeLocation() {
// At this time, these can never use the velocity.
if (agent.destination instanceof CannonDestination) {
Logging.fine("Using Stock TP method. This cannon will have 0 velocity");
}
SafeTTeleporter teleporter = agent.core.getSafeTTeleporter();
Location newLoc = agent.destination.getLocation(agent.player);
if (agent.destination.useSafeTeleporter()) {
newLoc = teleporter.getSafeLocation(agent.player, agent.destination);
}
if (newLoc == null) {
return agent.player.getLocation();
}
return newLoc;
}
public void setPortalEventTravelAgent(PlayerPortalEvent event) {
event.setPortalTravelAgent(this);
event.useTravelAgent(true);
}
}

View File

@ -1,106 +0,0 @@
package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.event.entity.EntityPortalEvent;
import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import java.lang.reflect.Method;
/**
* Utility class to enable version specific minecraft features.
*/
public class CompatibilityLayer {
private static Method checkAnchorSpawn;
private static boolean useTravelAgent;
private static Method playerPortalSearchRadius;
private static Method entityPortalSearchRadius;
/**
* Initialise the reflection class, methods and fields.
*/
public static void init() {
checkAnchorSpawn = ReflectHelper.getMethod(PlayerRespawnEvent.class, "isAnchorSpawn");
useTravelAgent = ReflectHelper.hasClass("org.bukkit.TravelAgent");
playerPortalSearchRadius = ReflectHelper.getMethod(PlayerPortalEvent.class, "setSearchRadius", int.class);
entityPortalSearchRadius = ReflectHelper.getMethod(EntityPortalEvent.class, "setSearchRadius", int.class);
}
/**
* <p>Check if the respawn point is of respawn anchor type.</p>
* <p>Introduced in minecraft 1.16</p>
*
* @param event A player respawn event.
* @return If the respawn location is an anchor point.
*/
public static boolean isAnchorSpawn(PlayerRespawnEvent event) {
if (checkAnchorSpawn == null) {
return false;
}
Boolean result = ReflectHelper.invokeMethod(event, checkAnchorSpawn);
if (result == null) {
Logging.warning("Unable to check if spawning at respawn anchor!");
return false;
}
return result;
}
/**
* <p>Gets if Travel Agent is supported on the server's minecraft version.</p>
* <p>Removed in minecraft 1.14</p>
*
* @return True if Travel Agent is supported, else false.
*/
public static boolean isUseTravelAgent() {
return useTravelAgent;
}
/**
* <p>Sets search radius for a PlayerPortalEvent.</p>
*
* <p>Use travel agent if available, else using new PlayerPortalEvent.setSearchRadius(int) method
* introduced in minecraft 1.15</p>
*
* @param event A Player Portal Event.
* @param searchRadius Target search radius to set to.
*/
public static void setPortalSearchRadius(PlayerPortalEvent event, int searchRadius) {
if (useTravelAgent) {
event.getPortalTravelAgent().setSearchRadius(searchRadius);
event.useTravelAgent(true);
Logging.finer("Used travel agent to set player portal search radius.");
return;
}
if (playerPortalSearchRadius == null) {
Logging.warning("Unable to set player portal search radius!");
return;
}
ReflectHelper.invokeMethod(event, playerPortalSearchRadius, searchRadius);
Logging.finer("Used new method to set player portal search radius.");
}
/**
* <p>Sets search radius for a EntityPortalEvent.</p>
*
* <p>Use travel agent if available, else using new EntityPortalEvent.setSearchRadius(int) method
* introduced in minecraft 1.15</p>
*
* @param event A Entity Portal Event.
* @param searchRadius Target search radius to set to.
*/
public static void setPortalSearchRadius(EntityPortalEvent event, int searchRadius) {
if (useTravelAgent) {
event.getPortalTravelAgent().setSearchRadius(searchRadius);
event.useTravelAgent(true);
Logging.finer("Used travel agent to set entity portal search radius.");
return;
}
if (entityPortalSearchRadius == null) {
Logging.warning("Unable to set entity portal search radius!");
return;
}
ReflectHelper.invokeMethod(event, entityPortalSearchRadius, searchRadius);
Logging.finer("Used new method to set entity portal search radius.");
}
}