mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Remove formatting from error_in_game_only, tweaks to OnlinePlayer
This commit is contained in:
1 parent
f1929a0fa6
commit
7e9229cc1a
13 files changed
+24
-19
No files matched your search
@@ -9,9 +9,9 @@ import net.william278.huskhomes.command.BukkitCommandType;
|
||||
import net.william278.huskhomes.command.CommandBase;
|
||||
import net.william278.huskhomes.command.DisabledCommand;
|
||||
import net.william278.huskhomes.config.CachedServer;
|
||||
import net.william278.huskhomes.config.CachedSpawn;
|
||||
import net.william278.huskhomes.config.Locales;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.config.CachedSpawn;
|
||||
import net.william278.huskhomes.database.Database;
|
||||
import net.william278.huskhomes.database.MySqlDatabase;
|
||||
import net.william278.huskhomes.database.SqLiteDatabase;
|
||||
|
||||
@@ -3,7 +3,6 @@ package net.william278.huskhomes.command;
|
||||
import me.lucko.commodore.CommodoreProvider;
|
||||
import net.william278.huskhomes.BukkitHuskHomes;
|
||||
import net.william278.huskhomes.player.BukkitPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -11,7 +10,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Bukkit executor that implements and executes {@link CommandBase}s
|
||||
@@ -58,8 +57,9 @@ public class BukkitCommand implements CommandExecutor, TabExecutor {
|
||||
if (this.command instanceof ConsoleExecutable consoleExecutable) {
|
||||
consoleExecutable.onConsoleExecute(args);
|
||||
} else {
|
||||
plugin.getLocales().getLocale("error_in_game_only")
|
||||
.ifPresent(locale -> plugin.getAudiences().sender(sender).sendMessage(locale.toComponent()));
|
||||
plugin.getLoggingAdapter().log(Level.WARNING, plugin.getLocales()
|
||||
.getRawLocale("error_in_game_only")
|
||||
.orElse("Error: That command can only be run in-game."));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -26,10 +26,15 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class BukkitPlayer extends OnlineUser {
|
||||
|
||||
// Instance of the implementing plugin
|
||||
private final BukkitHuskHomes plugin;
|
||||
|
||||
// The Bukkit player
|
||||
private final Player player;
|
||||
|
||||
private BukkitPlayer(@NotNull Player player) {
|
||||
super(player.getUniqueId(), player.getName());
|
||||
this.plugin = BukkitHuskHomes.getInstance();
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@@ -62,14 +67,14 @@ public class BukkitPlayer extends OnlineUser {
|
||||
public Position getPosition() {
|
||||
return new Position(BukkitAdapter.adaptLocation(player.getLocation())
|
||||
.orElseThrow(() -> new HuskHomesException("Failed to get the position of a BukkitPlayer (null)")),
|
||||
BukkitHuskHomes.getInstance().getPluginServer());
|
||||
plugin.getPluginServer());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Position> getBedSpawnPosition() {
|
||||
return Optional.ofNullable(player.getBedSpawnLocation()).flatMap(BukkitAdapter::adaptLocation)
|
||||
.map(location -> new Position(location, BukkitHuskHomes.getInstance().getPluginServer()));
|
||||
.map(location -> new Position(location, plugin.getPluginServer()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,7 +96,7 @@ public class BukkitPlayer extends OnlineUser {
|
||||
|
||||
@Override
|
||||
protected @NotNull Audience getAudience() {
|
||||
return BukkitHuskHomes.getInstance().getAudiences().player(player);
|
||||
return plugin.getAudiences().player(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,7 +110,7 @@ public class BukkitPlayer extends OnlineUser {
|
||||
return CompletableFuture.completedFuture(TeleportResult.FAILED_ILLEGAL_COORDINATES);
|
||||
}
|
||||
final CompletableFuture<TeleportResult> resultCompletableFuture = new CompletableFuture<>();
|
||||
Bukkit.getScheduler().runTask(BukkitHuskHomes.getInstance(), () -> {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if (asynchronous) {
|
||||
PaperLib.teleportAsync(player, bukkitLocation.get(), PlayerTeleportEvent.TeleportCause.PLUGIN)
|
||||
.thenAccept(result -> resultCompletableFuture.complete(
|
||||
|
||||
Reference in new issue
Block a user