mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 14:38:53 +00:00
Add @YamlKey specification to some fields in spawn and server files, fix #242
This commit is contained in:
1 parent
8663de2411
commit
98f812bcd9
6 files changed
+35
-19
No files matched your search
@@ -103,10 +103,10 @@ public class HuskHomesCommand extends CommandBase implements ConsoleExecutable,
|
|||||||
newestVersion.ifPresentOrElse(
|
newestVersion.ifPresentOrElse(
|
||||||
newVersion -> onlineUser.sendMessage(
|
newVersion -> onlineUser.sendMessage(
|
||||||
new MineDown("[HuskHomes](#00fb9a bold) [| A new version of HuskHomes is available!"
|
new MineDown("[HuskHomes](#00fb9a bold) [| A new version of HuskHomes is available!"
|
||||||
+ " (v" + newVersion + " (Running: v" + plugin.getPluginVersion() + ")](#00fb9a)")),
|
+ " (v" + newVersion + " (Running: v" + plugin.getPluginVersion() + ")](#00fb9a)")),
|
||||||
() -> onlineUser.sendMessage(
|
() -> onlineUser.sendMessage(
|
||||||
new MineDown("[HuskHomes](#00fb9a bold) [| HuskHomes is up-to-date."
|
new MineDown("[HuskHomes](#00fb9a bold) [| HuskHomes is up-to-date."
|
||||||
+ " (Running: v" + plugin.getPluginVersion() + ")](#00fb9a)"))));
|
+ " (Running: v" + plugin.getPluginVersion() + ")](#00fb9a)"))));
|
||||||
}
|
}
|
||||||
case "migrate" -> plugin.getLocales().getLocale("error_console_command_only")
|
case "migrate" -> plugin.getLocales().getLocale("error_console_command_only")
|
||||||
.ifPresent(onlineUser::sendMessage);
|
.ifPresent(onlineUser::sendMessage);
|
||||||
@@ -131,8 +131,8 @@ public class HuskHomesCommand extends CommandBase implements ConsoleExecutable,
|
|||||||
.stream().filter(command -> command instanceof ConsoleExecutable)
|
.stream().filter(command -> command instanceof ConsoleExecutable)
|
||||||
.forEach(command -> plugin.getLoggingAdapter().log(Level.INFO,
|
.forEach(command -> plugin.getLoggingAdapter().log(Level.INFO,
|
||||||
command.command +
|
command.command +
|
||||||
(command.command.length() < 16 ? " ".repeat(16 - command.command.length()) : "")
|
(command.command.length() < 16 ? " ".repeat(16 - command.command.length()) : "")
|
||||||
+ " - " + command.getDescription()));
|
+ " - " + command.getDescription()));
|
||||||
}
|
}
|
||||||
case "reload" -> plugin.reload().thenAccept(reloaded -> {
|
case "reload" -> plugin.reload().thenAccept(reloaded -> {
|
||||||
if (!reloaded) {
|
if (!reloaded) {
|
||||||
@@ -144,10 +144,10 @@ public class HuskHomesCommand extends CommandBase implements ConsoleExecutable,
|
|||||||
case "update" -> plugin.getLatestVersionIfOutdated().thenAccept(newestVersion ->
|
case "update" -> plugin.getLatestVersionIfOutdated().thenAccept(newestVersion ->
|
||||||
newestVersion.ifPresentOrElse(newVersion -> plugin.getLoggingAdapter().log(Level.WARNING,
|
newestVersion.ifPresentOrElse(newVersion -> plugin.getLoggingAdapter().log(Level.WARNING,
|
||||||
"An update is available for HuskHomes, v" + newVersion
|
"An update is available for HuskHomes, v" + newVersion
|
||||||
+ " (Running v" + plugin.getPluginVersion() + ")"),
|
+ " (Running v" + plugin.getPluginVersion() + ")"),
|
||||||
() -> plugin.getLoggingAdapter().log(Level.INFO,
|
() -> plugin.getLoggingAdapter().log(Level.INFO,
|
||||||
"HuskHomes is up to date" +
|
"HuskHomes is up to date" +
|
||||||
" (Running v" + plugin.getPluginVersion() + ")")));
|
" (Running v" + plugin.getPluginVersion() + ")")));
|
||||||
case "migrate" -> {
|
case "migrate" -> {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
plugin.getLoggingAdapter().log(Level.INFO,
|
plugin.getLoggingAdapter().log(Level.INFO,
|
||||||
@@ -177,7 +177,7 @@ public class HuskHomesCommand extends CommandBase implements ConsoleExecutable,
|
|||||||
}, () -> {
|
}, () -> {
|
||||||
plugin.getLoggingAdapter().log(Level.INFO,
|
plugin.getLoggingAdapter().log(Level.INFO,
|
||||||
"Please specify a valid migrator.\n" +
|
"Please specify a valid migrator.\n" +
|
||||||
"If a migrator is not available, please verify that you meet the prerequisites to use it.");
|
"If a migrator is not available, please verify that you meet the prerequisites to use it.");
|
||||||
logMigratorsList();
|
logMigratorsList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -187,9 +187,9 @@ public class HuskHomesCommand extends CommandBase implements ConsoleExecutable,
|
|||||||
private void logMigratorsList() {
|
private void logMigratorsList() {
|
||||||
plugin.getLoggingAdapter().log(Level.INFO,
|
plugin.getLoggingAdapter().log(Level.INFO,
|
||||||
"List of available migrators:\nMigrator ID / Migrator Name:\n" +
|
"List of available migrators:\nMigrator ID / Migrator Name:\n" +
|
||||||
plugin.getMigrators().stream()
|
plugin.getMigrators().stream()
|
||||||
.map(migrator -> migrator.getIdentifier() + " - " + migrator.getName())
|
.map(migrator -> migrator.getIdentifier() + " - " + migrator.getName())
|
||||||
.collect(Collectors.joining("\n")));
|
.collect(Collectors.joining("\n")));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendAboutMenu(@NotNull OnlineUser onlineUser) {
|
private void sendAboutMenu(@NotNull OnlineUser onlineUser) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.william278.huskhomes.config;
|
package net.william278.huskhomes.config;
|
||||||
|
|
||||||
import net.william278.annotaml.YamlFile;
|
import net.william278.annotaml.YamlFile;
|
||||||
|
import net.william278.annotaml.YamlKey;
|
||||||
import net.william278.huskhomes.position.Server;
|
import net.william278.huskhomes.position.Server;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ public class CachedServer {
|
|||||||
/**
|
/**
|
||||||
* Name of the server (must match proxy config ID)
|
* Name of the server (must match proxy config ID)
|
||||||
*/
|
*/
|
||||||
|
@YamlKey("server_name")
|
||||||
public String serverName;
|
public String serverName;
|
||||||
|
|
||||||
public CachedServer(@NotNull String serverName) {
|
public CachedServer(@NotNull String serverName) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.william278.huskhomes.config;
|
package net.william278.huskhomes.config;
|
||||||
|
|
||||||
import net.william278.annotaml.YamlFile;
|
import net.william278.annotaml.YamlFile;
|
||||||
|
import net.william278.annotaml.YamlKey;
|
||||||
import net.william278.huskhomes.position.Location;
|
import net.william278.huskhomes.position.Location;
|
||||||
import net.william278.huskhomes.position.Position;
|
import net.william278.huskhomes.position.Position;
|
||||||
import net.william278.huskhomes.position.Server;
|
import net.william278.huskhomes.position.Server;
|
||||||
@@ -25,7 +26,9 @@ public class CachedSpawn {
|
|||||||
public double z;
|
public double z;
|
||||||
public float yaw;
|
public float yaw;
|
||||||
public float pitch;
|
public float pitch;
|
||||||
|
@YamlKey("world_name")
|
||||||
public String worldName;
|
public String worldName;
|
||||||
|
@YamlKey("world_uuid")
|
||||||
public String worldUuid;
|
public String worldUuid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -499,8 +499,6 @@ public class MySqlDatabase extends Database {
|
|||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
getLogger().log(Level.SEVERE, "Failed to query a player's home", e);
|
getLogger().log(Level.SEVERE, "Failed to query a player's home", e);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -120,7 +120,10 @@ public class EventListener {
|
|||||||
plugin.getSettings().getSoundEffect(Settings.SoundEffectAction.TELEPORTATION_COMPLETE)
|
plugin.getSettings().getSoundEffect(Settings.SoundEffectAction.TELEPORTATION_COMPLETE)
|
||||||
.ifPresent(onlineUser::playSound);
|
.ifPresent(onlineUser::playSound);
|
||||||
}
|
}
|
||||||
}).thenRun(() -> plugin.getDatabase().setCurrentTeleport(onlineUser, null));
|
}).thenRun(() -> plugin.getDatabase().setCurrentTeleport(onlineUser, null)).exceptionally(throwable -> {
|
||||||
|
plugin.getLoggingAdapter().log(Level.SEVERE, "An error occurred while teleporting an inbound player", throwable);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return CompletableFuture.completedFuture(null);
|
return CompletableFuture.completedFuture(null);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cross-platform teleportation manager
|
* Cross-platform teleportation manager
|
||||||
@@ -371,15 +372,24 @@ public class TeleportManager {
|
|||||||
* @return future completing when the teleport is complete with a {@link TeleportResult}.
|
* @return future completing when the teleport is complete with a {@link TeleportResult}.
|
||||||
* Successful cross-server teleports will return {@link TeleportResult#COMPLETED_CROSS_SERVER}.
|
* Successful cross-server teleports will return {@link TeleportResult#COMPLETED_CROSS_SERVER}.
|
||||||
* <p>Note that cross-server teleports will return with a {@link TeleportResult#FAILED_INVALID_SERVER} result if the
|
* <p>Note that cross-server teleports will return with a {@link TeleportResult#FAILED_INVALID_SERVER} result if the
|
||||||
* target server is not online
|
* target server is not online, or connection timed out
|
||||||
*/
|
*/
|
||||||
private CompletableFuture<TeleportResult> teleportCrossServer(@NotNull OnlineUser onlineUser, @NotNull Teleport teleport) {
|
private CompletableFuture<TeleportResult> teleportCrossServer(@NotNull OnlineUser onlineUser, @NotNull Teleport teleport) {
|
||||||
|
|
||||||
return plugin.getDatabase().setCurrentTeleport(teleport.player, teleport)
|
final CompletableFuture<TeleportResult> teleportFuture = new CompletableFuture<>();
|
||||||
.thenApplyAsync(ignored -> plugin.getNetworkMessenger().sendPlayer(onlineUser, teleport.target.server)
|
plugin.getDatabase().setCurrentTeleport(teleport.player, teleport)
|
||||||
.thenApply(completed -> completed ? TeleportResult.COMPLETED_CROSS_SERVER :
|
.thenApply(ignored -> plugin.getNetworkMessenger()
|
||||||
TeleportResult.FAILED_INVALID_SERVER)
|
.sendPlayer(onlineUser, teleport.target.server)
|
||||||
.join());
|
.thenApply(completed -> completed ? TeleportResult.COMPLETED_CROSS_SERVER
|
||||||
|
: TeleportResult.FAILED_INVALID_SERVER))
|
||||||
|
.orTimeout(10, TimeUnit.SECONDS)
|
||||||
|
.exceptionally(throwable -> {
|
||||||
|
plugin.getLoggingAdapter().log(Level.WARNING, "Cross-server teleport timed out for " + onlineUser.username);
|
||||||
|
plugin.getDatabase().setCurrentTeleport(teleport.player, null);
|
||||||
|
return CompletableFuture.completedFuture(TeleportResult.FAILED_INVALID_SERVER);
|
||||||
|
})
|
||||||
|
.thenAccept(result -> result.thenAcceptAsync(teleportFuture::complete));
|
||||||
|
return teleportFuture;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user