mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +00:00
Add fabric builds for older MC versions & add checkstyle (#449)
* Remove instance getters, improve command logic, register APi * Publish multiple fabric builds, enforce checkstyle * Bump guava * Bump to 4.4.2
This commit is contained in:
1 parent
51baf196b3
commit
c9f5262292
219 files changed
+8032
-1392
No files matched your search
@@ -38,34 +38,45 @@ import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Bukkit implementation of an {@link OnlineUser}
|
||||
* Bukkit's implementation of an {@link OnlineUser}.
|
||||
*/
|
||||
public class BukkitUser extends OnlineUser {
|
||||
|
||||
private final BukkitHuskHomes plugin;
|
||||
private final Player player;
|
||||
|
||||
private BukkitUser(@NotNull Player player) {
|
||||
private BukkitUser(@NotNull Player player, @NotNull BukkitHuskHomes plugin) {
|
||||
super(player.getUniqueId(), player.getName());
|
||||
this.plugin = BukkitHuskHomes.getInstance();
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapt a {@link Player} to a {@link OnlineUser}
|
||||
* Adapt a {@link Player} to a {@link OnlineUser}.
|
||||
*
|
||||
* @param player the online {@link Player} to adapt
|
||||
* @return the adapted {@link OnlineUser}
|
||||
*/
|
||||
@NotNull
|
||||
public static BukkitUser adapt(@NotNull Player player) {
|
||||
return new BukkitUser(player);
|
||||
public static BukkitUser adapt(@NotNull Player player, @NotNull BukkitHuskHomes plugin) {
|
||||
return new BukkitUser(player, plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link Player} wrapped by this {@link BukkitUser}.
|
||||
*
|
||||
* @return the {@link Player} wrapped by this {@link BukkitUser}
|
||||
*/
|
||||
@NotNull
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return Position.at(BukkitAdapter.adaptLocation(player.getLocation())
|
||||
.orElseThrow(() -> new IllegalStateException("Failed to get the position of a BukkitPlayer (null)")),
|
||||
return Position.at(BukkitAdapter.adaptLocation(player.getLocation()).orElseThrow(
|
||||
() -> new IllegalStateException("Failed to get the position of a BukkitPlayer (null)")
|
||||
),
|
||||
plugin.getServerName());
|
||||
|
||||
}
|
||||
@@ -104,7 +115,7 @@ public class BukkitUser extends OnlineUser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleportLocally(@NotNull Location location, boolean asynchronous) throws TeleportationException {
|
||||
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) {
|
||||
@@ -120,7 +131,7 @@ public class BukkitUser extends OnlineUser {
|
||||
// Run on the appropriate thread scheduler for this platform
|
||||
plugin.getScheduler().entitySpecificScheduler(player).run(
|
||||
() -> {
|
||||
if (asynchronous || plugin.getScheduler().isUsingFolia()) {
|
||||
if (async || plugin.getScheduler().isUsingFolia()) {
|
||||
PaperLib.teleportAsync(player, bukkitLocation, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
return;
|
||||
}
|
||||
@@ -131,7 +142,7 @@ public class BukkitUser extends OnlineUser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player momentum and return if they are moving
|
||||
* Get the player momentum and return if they are moving.
|
||||
*
|
||||
* @return {@code true} if the player is moving, {@code false} otherwise
|
||||
**/
|
||||
@@ -141,7 +152,7 @@ public class BukkitUser extends OnlineUser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of the player's "vanished" metadata tag if they have it
|
||||
* Return the value of the player's "vanished" metadata tag if they have it.
|
||||
*
|
||||
* @return {@code true} if the player is vanished, {@code false} otherwise
|
||||
*/
|
||||
@@ -155,18 +166,10 @@ public class BukkitUser extends OnlineUser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a Bukkit plugin message to the player
|
||||
* Send a Bukkit plugin message to the player.
|
||||
*/
|
||||
public void sendPluginMessage(@NotNull String channel, final byte[] message) {
|
||||
player.sendPluginMessage(plugin, channel, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link Player} wrapped by this {@link BukkitUser}
|
||||
*
|
||||
* @return the {@link Player} wrapped by this {@link BukkitUser}
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user