mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +00:00
Add APIv3 and API events
This commit is contained in:
1 parent
0fc56dc758
commit
59249f285a
25 files changed
+985
-100
No files matched your search
@@ -72,7 +72,7 @@ public class RtpCommand extends CommandBase implements ConsoleExecutable {
|
||||
}
|
||||
|
||||
// Get a random position and teleport
|
||||
plugin.getRtpEngine().getRandomPosition(userPosition)
|
||||
plugin.getRandomTeleportEngine().getRandomPosition(userPosition)
|
||||
.thenAccept(position -> {
|
||||
if (position.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_rtp_randomization_timeout")
|
||||
@@ -107,7 +107,7 @@ public class RtpCommand extends CommandBase implements ConsoleExecutable {
|
||||
}
|
||||
|
||||
plugin.getLoggingAdapter().log(Level.INFO, "Finding a random position for " + foundUser.get().username + "...");
|
||||
plugin.getRtpEngine().getRandomPosition(foundUser.get().getPosition()).thenAccept(position -> {
|
||||
plugin.getRandomTeleportEngine().getRandomPosition(foundUser.get().getPosition()).thenAccept(position -> {
|
||||
if (position.isEmpty()) {
|
||||
plugin.getLoggingAdapter().log(Level.WARNING, "Failed to teleport " + foundUser.get().username + " to a random position; randomization timed out!");
|
||||
return;
|
||||
|
||||
@@ -19,25 +19,31 @@ public class SetSpawnCommand extends CommandBase {
|
||||
|
||||
@Override
|
||||
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
CompletableFuture.supplyAsync(() -> {
|
||||
if (args.length > 0) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax", "/setspawn")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
final Position position = onlineUser.getPosition();
|
||||
if (plugin.getSettings().crossServer && plugin.getSettings().globalSpawn) {
|
||||
final Optional<Warp> warp = plugin.getDatabase().getWarp(plugin.getSettings().globalSpawnName).join();
|
||||
if (warp.isPresent()) {
|
||||
plugin.getSavedPositionManager().updateWarpPosition(warp.get(), position).join();
|
||||
return plugin.getSavedPositionManager().updateWarpPosition(warp.get(), position).join();
|
||||
} else {
|
||||
plugin.getSavedPositionManager().setWarp(new PositionMeta(plugin.getSettings().globalSpawnName,
|
||||
return plugin.getSavedPositionManager().setWarp(new PositionMeta(plugin.getSettings().globalSpawnName,
|
||||
plugin.getLocales().getRawLocale("spawn_warp_default_description")
|
||||
.orElse("")), position).join();
|
||||
.orElse("")), position).join().resultType().successful;
|
||||
}
|
||||
} else {
|
||||
plugin.setServerSpawn(position);
|
||||
return true;
|
||||
}
|
||||
}).thenRun(() -> plugin.getLocales().getLocale("set_spawn_success").ifPresent(onlineUser::sendMessage));
|
||||
}).thenAccept(succeeded -> {
|
||||
if (succeeded) {
|
||||
plugin.getLocales().getLocale("set_spawn_success")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user