mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 22:17:17 +00:00
refactor: Use native platform adventure implementations
This commit is contained in:
12 files changed
+66
-29
No files matched your search
@@ -19,6 +19,8 @@
|
||||
|
||||
package net.william278.huskhomes;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.platform.AudienceProvider;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.william278.annotaml.Annotaml;
|
||||
import net.william278.desertwell.util.Version;
|
||||
@@ -258,6 +260,12 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
||||
.toList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Audience getAudience(@NotNull UUID user) {
|
||||
return audiences.player(user);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<SavedUser> getSavedUsers() {
|
||||
@@ -476,7 +484,7 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public BukkitAudiences getAudiences() {
|
||||
public AudienceProvider getAudiences() {
|
||||
return audiences;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package net.william278.huskhomes.user;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.william278.huskhomes.BukkitHuskHomes;
|
||||
import net.william278.huskhomes.position.Location;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
@@ -31,6 +30,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import space.arim.morepaperlib.scheduling.GracefulScheduling;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -42,13 +42,11 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class BukkitUser extends OnlineUser {
|
||||
|
||||
private final BukkitHuskHomes plugin;
|
||||
private final Player player;
|
||||
|
||||
private BukkitUser(@NotNull Player player, @NotNull BukkitHuskHomes plugin) {
|
||||
super(player.getUniqueId(), player.getName());
|
||||
super(player.getUniqueId(), player.getName(), plugin);
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,12 +106,6 @@ public class BukkitUser extends OnlineUser {
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Audience getAudience() {
|
||||
return plugin.getAudiences().player(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleportLocally(@NotNull Location location, boolean async) throws TeleportationException {
|
||||
// Ensure the world exists
|
||||
@@ -129,11 +121,12 @@ public class BukkitUser extends OnlineUser {
|
||||
}
|
||||
|
||||
// Run on the appropriate thread scheduler for this platform
|
||||
plugin.getScheduler().entitySpecificScheduler(player).run(
|
||||
final GracefulScheduling scheduler = ((BukkitHuskHomes) plugin).getScheduler();
|
||||
scheduler.entitySpecificScheduler(player).run(
|
||||
() -> {
|
||||
player.leaveVehicle();
|
||||
player.eject();
|
||||
if (async || plugin.getScheduler().isUsingFolia()) {
|
||||
if (async || scheduler.isUsingFolia()) {
|
||||
PaperLib.teleportAsync(player, bukkitLocation, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
return;
|
||||
}
|
||||
@@ -171,7 +164,7 @@ public class BukkitUser extends OnlineUser {
|
||||
* Send a Bukkit plugin message to the player.
|
||||
*/
|
||||
public void sendPluginMessage(@NotNull String channel, final byte[] message) {
|
||||
player.sendPluginMessage(plugin, channel, message);
|
||||
player.sendPluginMessage((BukkitHuskHomes) plugin, channel, message);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user