mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
refactor: improve adapter on Bukkit
This commit is contained in:
10 files changed
+100
-168
No files matched your search
@@ -47,6 +47,7 @@ import net.william278.huskhomes.manager.Manager;
|
||||
import net.william278.huskhomes.network.Broker;
|
||||
import net.william278.huskhomes.network.PluginMessageBroker;
|
||||
import net.william278.huskhomes.network.RedisBroker;
|
||||
import net.william278.huskhomes.position.Location;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.position.World;
|
||||
import net.william278.huskhomes.random.NormalDistributionEngine;
|
||||
@@ -272,9 +273,7 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
||||
|
||||
@Override
|
||||
public void setWorldSpawn(@NotNull Position position) {
|
||||
BukkitAdapter.adaptLocation(position).ifPresent(location -> Objects
|
||||
.requireNonNull(location.getWorld(), "World is null")
|
||||
.setSpawnLocation(location));
|
||||
Objects.requireNonNull(Adapter.adapt(position).getWorld()).setSpawnLocation(Adapter.adapt(position));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -322,10 +321,7 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
||||
@Override
|
||||
@NotNull
|
||||
public List<World> getWorlds() {
|
||||
return getServer().getWorlds().stream()
|
||||
.filter(world -> BukkitAdapter.adaptWorld(world).isPresent())
|
||||
.map(world -> BukkitAdapter.adaptWorld(world).orElse(null))
|
||||
.toList();
|
||||
return getServer().getWorlds().stream().map(Adapter::adapt).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -418,4 +414,47 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Adapter {
|
||||
|
||||
@NotNull
|
||||
public static Position adapt(@NotNull org.bukkit.Location location, @NotNull String server) {
|
||||
return Position.at(
|
||||
location.getX(), location.getY(), location.getZ(),
|
||||
location.getYaw(), location.getPitch(),
|
||||
adapt(Objects.requireNonNull(location.getWorld(), "Location world is null")),
|
||||
server
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Location adapt(@NotNull org.bukkit.Location location) {
|
||||
return Position.at(
|
||||
location.getX(), location.getY(), location.getZ(),
|
||||
location.getYaw(), location.getPitch(),
|
||||
adapt(Objects.requireNonNull(location.getWorld(), "Location world is null"))
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static org.bukkit.Location adapt(@NotNull Location position) {
|
||||
return new org.bukkit.Location(
|
||||
adapt(position.getWorld()),
|
||||
position.getX(), position.getY(), position.getZ(),
|
||||
position.getYaw(), position.getPitch()
|
||||
);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static org.bukkit.World adapt(@NotNull World world) {
|
||||
return Optional.ofNullable(Bukkit.getWorld(world.getUuid()))
|
||||
.or(() -> Optional.ofNullable(Bukkit.getWorld(world.getName())))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static World adapt(@NotNull org.bukkit.World world) {
|
||||
return World.from(world.getName(), world.getUID(), World.Environment.match(world.getEnvironment().name()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.user.BukkitUser;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.user.User;
|
||||
import net.william278.huskhomes.util.BukkitAdapter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -105,7 +104,7 @@ public class HuskHomesAPI extends BaseHuskHomesAPI {
|
||||
*/
|
||||
@Nullable
|
||||
public org.bukkit.Location getLocation(@NotNull Position position) {
|
||||
return BukkitAdapter.adaptLocation(position).orElse(null);
|
||||
return BukkitHuskHomes.Adapter.adapt(position);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,7 +116,7 @@ public class HuskHomesAPI extends BaseHuskHomesAPI {
|
||||
*/
|
||||
@Nullable
|
||||
public Location adaptLocation(@NotNull org.bukkit.Location location) {
|
||||
return BukkitAdapter.adaptLocation(location).orElse(null);
|
||||
return BukkitHuskHomes.Adapter.adapt(location);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,9 +24,7 @@ import com.earth2me.essentials.Warps;
|
||||
import com.earth2me.essentials.commands.WarpNotFoundException;
|
||||
import net.william278.huskhomes.BukkitHuskHomes;
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.user.User;
|
||||
import net.william278.huskhomes.util.BukkitAdapter;
|
||||
import net.william278.huskhomes.util.ValidationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -61,19 +59,15 @@ public class EssentialsXImporter extends Importer {
|
||||
if (essentialsUser.getHome(homeName) == null || essentialsUser.getHome(homeName).getWorld() == null) {
|
||||
continue;
|
||||
}
|
||||
BukkitAdapter.adaptLocation(essentialsUser.getHome(homeName))
|
||||
.map(location -> Position.at(location, plugin.getServerName()))
|
||||
.ifPresent(position -> {
|
||||
plugin.getManager().homes().createHome(
|
||||
user,
|
||||
this.normalizeName(homeName),
|
||||
position,
|
||||
true,
|
||||
true,
|
||||
true
|
||||
);
|
||||
homesImported.getAndIncrement();
|
||||
});
|
||||
plugin.getManager().homes().createHome(
|
||||
user,
|
||||
this.normalizeName(homeName),
|
||||
BukkitHuskHomes.Adapter.adapt(essentialsUser.getHome(homeName), plugin.getServerName()),
|
||||
true,
|
||||
true,
|
||||
true
|
||||
);
|
||||
homesImported.getAndIncrement();
|
||||
}
|
||||
}
|
||||
return homesImported.get();
|
||||
@@ -87,16 +81,11 @@ public class EssentialsXImporter extends Importer {
|
||||
if (warps.getWarp(warpName) == null || warps.getWarp(warpName).getWorld() == null) {
|
||||
continue;
|
||||
}
|
||||
BukkitAdapter.adaptLocation(warps.getWarp(warpName))
|
||||
.map(location -> Position.at(location, plugin.getServerName()))
|
||||
.ifPresent(position -> {
|
||||
plugin.getManager().warps().createWarp(
|
||||
this.normalizeName(warpName),
|
||||
position,
|
||||
true
|
||||
);
|
||||
warpsImported.getAndIncrement();
|
||||
});
|
||||
plugin.getManager().warps().createWarp(
|
||||
this.normalizeName(warpName),
|
||||
BukkitHuskHomes.Adapter.adapt(warps.getWarp(warpName), plugin.getServerName()),
|
||||
true
|
||||
);
|
||||
} catch (WarpNotFoundException e) {
|
||||
plugin.log(Level.WARNING, String.format("Skipped importing warp %s (could not be found)", warpName));
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import net.william278.huskhomes.BukkitHuskHomes;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.user.BukkitUser;
|
||||
import net.william278.huskhomes.util.BukkitAdapter;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.data.type.Bed;
|
||||
import org.bukkit.block.data.type.RespawnAnchor;
|
||||
@@ -85,9 +84,10 @@ public class BukkitEventListener extends EventListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
final BukkitUser bukkitUser = BukkitUser.adapt(player, (BukkitHuskHomes) plugin);
|
||||
BukkitAdapter.adaptLocation(event.getFrom()).ifPresent(sourceLocation ->
|
||||
handlePlayerTeleport(bukkitUser, Position.at(sourceLocation, plugin.getServerName())));
|
||||
this.handlePlayerTeleport(
|
||||
BukkitUser.adapt(player, (BukkitHuskHomes) plugin),
|
||||
BukkitHuskHomes.Adapter.adapt(event.getFrom(), plugin.getServerName())
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
@@ -107,9 +107,9 @@ public class BukkitEventListener extends EventListener implements Listener {
|
||||
}
|
||||
|
||||
// Update the player's respawn location
|
||||
BukkitAdapter.adaptLocation(location).ifPresent(adaptedLocation -> super.handlePlayerUpdateSpawnPoint(
|
||||
this.handlePlayerUpdateSpawnPoint(
|
||||
BukkitUser.adapt(event.getPlayer(), (BukkitHuskHomes) plugin),
|
||||
Position.at(adaptedLocation, plugin.getServerName()))
|
||||
BukkitHuskHomes.Adapter.adapt(location, plugin.getServerName())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.william278.huskhomes.network.PluginMessageBroker;
|
||||
import net.william278.huskhomes.position.Location;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.teleport.TeleportationException;
|
||||
import net.william278.huskhomes.util.BukkitAdapter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
@@ -61,17 +60,13 @@ public class BukkitUser extends OnlineUser {
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return Position.at(BukkitAdapter.adaptLocation(player.getLocation()).orElseThrow(
|
||||
() -> new IllegalStateException("Failed to get the position of a BukkitPlayer (null)")
|
||||
),
|
||||
plugin.getServerName());
|
||||
|
||||
return BukkitHuskHomes.Adapter.adapt(player.getLocation(), plugin.getServerName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Position> getBedSpawnPosition() {
|
||||
return Optional.ofNullable(player.getBedSpawnLocation()).flatMap(BukkitAdapter::adaptLocation)
|
||||
.map(location -> Position.at(location, plugin.getServerName()));
|
||||
return Optional.ofNullable(player.getBedSpawnLocation())
|
||||
.map(loc -> BukkitHuskHomes.Adapter.adapt(loc, plugin.getServerName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,16 +102,13 @@ public class BukkitUser extends OnlineUser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleportLocally(@NotNull Location location, boolean async) throws TeleportationException {
|
||||
// Ensure the world exists
|
||||
final Optional<org.bukkit.Location> resolvedLocation = BukkitAdapter.adaptLocation(location);
|
||||
if (resolvedLocation.isEmpty() || resolvedLocation.get().getWorld() == null) {
|
||||
public void teleportLocally(@NotNull Location target, boolean async) throws TeleportationException {
|
||||
// Ensure the location is valid (world exists, coordinates are within the world border)
|
||||
final org.bukkit.Location location = BukkitHuskHomes.Adapter.adapt(target);
|
||||
if (location.getWorld() == null) {
|
||||
throw new TeleportationException(TeleportationException.Type.WORLD_NOT_FOUND, plugin);
|
||||
}
|
||||
|
||||
// Ensure the coordinates are within the world limits
|
||||
final org.bukkit.Location bukkitLocation = resolvedLocation.get();
|
||||
if (!bukkitLocation.getWorld().getWorldBorder().isInside(resolvedLocation.get())) {
|
||||
if (!location.getWorld().getWorldBorder().isInside(location)) {
|
||||
throw new TeleportationException(TeleportationException.Type.ILLEGAL_TARGET_COORDINATES, plugin);
|
||||
}
|
||||
|
||||
@@ -125,10 +117,10 @@ public class BukkitUser extends OnlineUser {
|
||||
player.leaveVehicle();
|
||||
player.eject();
|
||||
if (async || ((BukkitHuskHomes) plugin).getScheduler().isUsingFolia()) {
|
||||
PaperLib.teleportAsync(player, bukkitLocation, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
PaperLib.teleportAsync(player, location, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
return;
|
||||
}
|
||||
player.teleport(bukkitLocation, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
player.teleport(location, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
}, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* This file is part of HuskHomes, licensed under the Apache License 2.0.
|
||||
*
|
||||
* Copyright (c) William278 <[email protected]>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.william278.huskhomes.util;
|
||||
|
||||
import net.william278.huskhomes.position.Location;
|
||||
import net.william278.huskhomes.position.World;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Static class providing utility methods for adapting Bukkit objects to HuskHomes and vice versa.
|
||||
*/
|
||||
public final class BukkitAdapter {
|
||||
|
||||
/**
|
||||
* Adapt a Bukkit {@link org.bukkit.Location} to a HuskHomes {@link Location}.
|
||||
*
|
||||
* @param location the Bukkit {@link org.bukkit.Location} to adapt
|
||||
* @return the adapted {@link Location}
|
||||
*/
|
||||
public static Optional<org.bukkit.Location> adaptLocation(@NotNull Location location) {
|
||||
org.bukkit.World world = Bukkit.getWorld(location.getWorld().getName());
|
||||
if (world == null) {
|
||||
world = Bukkit.getWorld(location.getWorld().getUuid());
|
||||
}
|
||||
if (world == null) {
|
||||
world = Bukkit.getWorlds().stream()
|
||||
.filter(w -> w.getEnvironment().name().equalsIgnoreCase(
|
||||
location.getWorld().getEnvironment().name())).findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
if (world == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(new org.bukkit.Location(
|
||||
world,
|
||||
location.getX(),
|
||||
location.getY(),
|
||||
location.getZ(),
|
||||
location.getYaw(),
|
||||
location.getPitch()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapt a HuskHomes {@link org.bukkit.Location} to a Bukkit {@link org.bukkit.Location}.
|
||||
*
|
||||
* @param location the HuskHomes {@link org.bukkit.Location} to adapt
|
||||
* @return the adapted {@link org.bukkit.Location}
|
||||
*/
|
||||
public static Optional<Location> adaptLocation(@NotNull org.bukkit.Location location) {
|
||||
if (location.getWorld() == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(Location.at(location.getX(), location.getY(), location.getZ(),
|
||||
location.getYaw(), location.getPitch(),
|
||||
adaptWorld(location.getWorld()).orElse(new net.william278.huskhomes.position.World())));
|
||||
}
|
||||
|
||||
public static Optional<World> adaptWorld(@Nullable org.bukkit.World world) {
|
||||
if (world == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(World.from(
|
||||
world.getName(), world.getUID(),
|
||||
switch (world.getEnvironment()) {
|
||||
case NORMAL -> World.Environment.OVERWORLD;
|
||||
case NETHER -> World.Environment.NETHER;
|
||||
case THE_END -> World.Environment.THE_END;
|
||||
default -> World.Environment.CUSTOM;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
package net.william278.huskhomes.util;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.william278.huskhomes.BukkitHuskHomes;
|
||||
import net.william278.huskhomes.position.Location;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
@@ -33,7 +34,7 @@ public interface BukkitSafetyResolver extends SafetyResolver {
|
||||
|
||||
@Override
|
||||
default CompletableFuture<Optional<Location>> findSafeGroundLocation(@NotNull Location location) {
|
||||
final org.bukkit.Location bukkitLocation = BukkitAdapter.adaptLocation(location).orElse(null);
|
||||
final org.bukkit.Location bukkitLocation = BukkitHuskHomes.Adapter.adapt(location);
|
||||
if (bukkitLocation == null || bukkitLocation.getWorld() == null) {
|
||||
return CompletableFuture.completedFuture(Optional.empty());
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import net.william278.huskhomes.user.BukkitUser;
|
||||
import net.william278.huskhomes.user.ConsoleUser;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.user.User;
|
||||
import net.william278.huskhomes.util.BukkitAdapter;
|
||||
import net.william278.huskhomes.util.TransactionResolver;
|
||||
import net.william278.huskhomes.util.ValidationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -362,7 +361,7 @@ public class BukkitPluginTests {
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(4)
|
||||
public void testWarpRelocation(@NotNull String name, @NotNull Position position) {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final World world = BukkitHuskHomes.Adapter.adapt(server.getWorld("world"));
|
||||
final Position newPosition = Position.at(
|
||||
position.getX() + 10, position.getY() + 10, position.getZ() + 10,
|
||||
0, 0,
|
||||
@@ -382,7 +381,7 @@ public class BukkitPluginTests {
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(5)
|
||||
public void testWarpOverwrite(@NotNull String name, @NotNull Position position) {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final World world = BukkitHuskHomes.Adapter.adapt(server.getWorld("world"));
|
||||
final Position newPosition = Position.at(
|
||||
position.getX() + 10, position.getY() + 10, position.getZ() + 10,
|
||||
0, 0,
|
||||
@@ -442,7 +441,7 @@ public class BukkitPluginTests {
|
||||
|
||||
@NotNull
|
||||
public static Stream<Arguments> provideWarpData() {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final World world = BukkitHuskHomes.Adapter.adapt(server.getWorld("world"));
|
||||
final Position position = Position.at(0, 0, 0, 0, 0, world, plugin.getServerName());
|
||||
return WARP_NAMES.stream()
|
||||
.flatMap(name -> Stream.of(Arguments.of(name, position)));
|
||||
@@ -536,7 +535,7 @@ public class BukkitPluginTests {
|
||||
@Order(4)
|
||||
public void testHomeRelocation(@NotNull OnlineUser owner, @NotNull String name,
|
||||
@NotNull Position position) {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final World world = BukkitHuskHomes.Adapter.adapt(server.getWorld("world"));
|
||||
final Position newPosition = Position.at(
|
||||
position.getX() + 10, position.getY() + 10, position.getZ() + 10,
|
||||
0, 0,
|
||||
@@ -557,7 +556,7 @@ public class BukkitPluginTests {
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(5)
|
||||
public void testHomeOverwrite(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position position) {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final World world = BukkitHuskHomes.Adapter.adapt(server.getWorld("world"));
|
||||
final Position newPosition = Position.at(
|
||||
position.getX() + 10, position.getY() + 10, position.getZ() + 10,
|
||||
0, 0,
|
||||
@@ -651,7 +650,7 @@ public class BukkitPluginTests {
|
||||
|
||||
@NotNull
|
||||
public static Stream<Arguments> provideHomeData() {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final World world = BukkitHuskHomes.Adapter.adapt(server.getWorld("world"));
|
||||
final Position position = Position.at(0, 0, 0, 0, 0, world, plugin.getServerName());
|
||||
return HOME_NAMES.stream()
|
||||
.flatMap(name -> Stream.of(Arguments.of(homeOwner, name, position)));
|
||||
|
||||
@@ -23,6 +23,7 @@ import lombok.NoArgsConstructor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -99,7 +100,16 @@ public class World {
|
||||
OVERWORLD,
|
||||
NETHER,
|
||||
THE_END,
|
||||
CUSTOM
|
||||
CUSTOM;
|
||||
|
||||
public static Environment match(@NotNull String name) {
|
||||
return switch (name.toLowerCase(Locale.ENGLISH)) {
|
||||
case "overworld" -> OVERWORLD;
|
||||
case "nether" -> NETHER;
|
||||
case "the_end" -> THE_END;
|
||||
default -> CUSTOM;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,9 +23,7 @@ import com.destroystokyo.paper.event.player.PlayerSetSpawnEvent;
|
||||
import net.william278.huskhomes.BukkitHuskHomes;
|
||||
import net.william278.huskhomes.PaperHuskHomes;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.user.BukkitUser;
|
||||
import net.william278.huskhomes.util.BukkitAdapter;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -61,9 +59,9 @@ public class PaperEventListener extends BukkitEventListener implements Listener
|
||||
}
|
||||
|
||||
// Update the player's respawn location
|
||||
BukkitAdapter.adaptLocation(location).ifPresent(adaptedLocation -> super.handlePlayerUpdateSpawnPoint(
|
||||
BukkitUser.adapt(event.getPlayer(), (PaperHuskHomes) plugin),
|
||||
Position.at(adaptedLocation, plugin.getServerName()))
|
||||
this.handlePlayerUpdateSpawnPoint(
|
||||
BukkitUser.adapt(event.getPlayer(), (BukkitHuskHomes) plugin),
|
||||
BukkitHuskHomes.Adapter.adapt(location, plugin.getServerName())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user