mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Complete /edithome
This commit is contained in:
1 parent
ced7ae3c35
commit
3651e1ea90
8 files changed
+210
-154
No files matched your search
@@ -10,10 +10,10 @@ import net.william278.huskhomes.util.RegexUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -82,14 +82,26 @@ public class EditHomeCommand extends CommandBase implements TabCompletable, Cons
|
||||
*/
|
||||
private void editHome(@NotNull Home home, @NotNull OnlineUser editor,
|
||||
@Nullable String editOperation, @Nullable String editArgs) {
|
||||
final AtomicBoolean showMenuFlag = new AtomicBoolean(false);
|
||||
final boolean otherOwner = !editor.uuid.equals(home.owner.uuid);
|
||||
|
||||
if (editOperation == null) {
|
||||
boolean otherOwner = editor.uuid.equals(home.owner.uuid);
|
||||
home.getHomeEditorWindow(plugin.getLocales(), otherOwner, plugin.getSettings().crossServer,
|
||||
!otherOwner || editor.hasPermission(Permission.COMMAND_HOME_OTHER.node),
|
||||
!otherOwner || editor.hasPermission(Permission.COMMAND_EDIT_HOME_OTHER.node))
|
||||
getHomeEditorWindow(home, true, otherOwner,
|
||||
!otherOwner || editor.hasPermission(Permission.COMMAND_HOME_OTHER.node))
|
||||
.forEach(editor::sendMessage);
|
||||
return;
|
||||
}
|
||||
if (editArgs != null) {
|
||||
String argToCheck = editArgs;
|
||||
if (editArgs.contains(Pattern.quote(" "))) {
|
||||
argToCheck = editArgs.split(Pattern.quote(" "))[0];
|
||||
}
|
||||
if (argToCheck.equals("-m")) {
|
||||
showMenuFlag.set(true);
|
||||
editArgs = editArgs.replaceFirst("-m", "");
|
||||
}
|
||||
}
|
||||
|
||||
switch (editOperation.toLowerCase()) {
|
||||
case "rename" -> {
|
||||
if (editArgs == null || editArgs.contains(Pattern.quote(" "))) {
|
||||
@@ -100,30 +112,25 @@ public class EditHomeCommand extends CommandBase implements TabCompletable, Cons
|
||||
}
|
||||
|
||||
final String oldHomeName = home.meta.name;
|
||||
plugin.getSavedPositionManager().updateHomeMeta(home, new PositionMeta(editArgs, home.meta.description))
|
||||
.thenAccept(renameResult ->
|
||||
editor.sendMessage(switch (renameResult.resultType()) {
|
||||
case SUCCESS -> {
|
||||
if (home.owner.uuid.equals(editor.uuid)) {
|
||||
yield plugin.getLocales().getLocale("edit_home_update_name",
|
||||
oldHomeName, editArgs).orElse(new MineDown(""));
|
||||
} else {
|
||||
yield plugin.getLocales().getLocale("edit_home_update_name_other",
|
||||
home.owner.username, oldHomeName, editArgs).orElse(new MineDown(""));
|
||||
}
|
||||
}
|
||||
case FAILED_DUPLICATE -> plugin.getLocales().getLocale("error_set_home_name_taken")
|
||||
.orElse(new MineDown(""));
|
||||
case FAILED_NAME_LENGTH ->
|
||||
plugin.getLocales().getLocale("error_set_home_invalid_length")
|
||||
.orElse(new MineDown(""));
|
||||
case FAILED_NAME_CHARACTERS ->
|
||||
plugin.getLocales().getLocale("error_set_home_invalid_characters")
|
||||
.orElse(new MineDown(""));
|
||||
default -> new MineDown("");
|
||||
}));
|
||||
final String newHomeName = editArgs;
|
||||
plugin.getSavedPositionManager().updateHomeMeta(home, new PositionMeta(newHomeName, home.meta.description))
|
||||
.thenAccept(renameResult -> (switch (renameResult.resultType()) {
|
||||
case SUCCESS -> {
|
||||
if (home.owner.uuid.equals(editor.uuid)) {
|
||||
yield plugin.getLocales().getLocale("edit_home_update_name",
|
||||
oldHomeName, newHomeName);
|
||||
} else {
|
||||
yield plugin.getLocales().getLocale("edit_home_update_name_other",
|
||||
home.owner.username, oldHomeName, newHomeName);
|
||||
}
|
||||
}
|
||||
case FAILED_DUPLICATE -> plugin.getLocales().getLocale("error_home_name_taken");
|
||||
case FAILED_NAME_LENGTH -> plugin.getLocales().getLocale("error_home_name_length");
|
||||
case FAILED_NAME_CHARACTERS -> plugin.getLocales().getLocale("error_home_name_characters");
|
||||
default -> Optional.of(new MineDown(""));
|
||||
}).ifPresent(editor::sendMessage));
|
||||
}
|
||||
case "description" -> { //todo not working
|
||||
case "description" -> {
|
||||
if (editArgs == null) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
"/edithome <name> description <new description>")
|
||||
@@ -132,26 +139,26 @@ public class EditHomeCommand extends CommandBase implements TabCompletable, Cons
|
||||
}
|
||||
|
||||
final String oldHomeDescription = home.meta.description;
|
||||
plugin.getSavedPositionManager().updateHomeMeta(home, new PositionMeta(home.meta.name, editArgs))
|
||||
.thenAccept(renameResult ->
|
||||
editor.sendMessage(switch (renameResult.resultType()) {
|
||||
case SUCCESS -> {
|
||||
if (home.owner.uuid.equals(editor.uuid)) {
|
||||
yield plugin.getLocales().getLocale("edit_home_update_name",
|
||||
oldHomeDescription, editArgs).orElse(new MineDown(""));
|
||||
} else {
|
||||
yield plugin.getLocales().getLocale("edit_home_update_name_other",
|
||||
home.owner.username, oldHomeDescription, editArgs).orElse(new MineDown(""));
|
||||
}
|
||||
}
|
||||
case FAILED_DESCRIPTION_LENGTH ->
|
||||
plugin.getLocales().getLocale("error_set_home_invalid_length")
|
||||
.orElse(new MineDown(""));
|
||||
case FAILED_DESCRIPTION_CHARACTERS ->
|
||||
plugin.getLocales().getLocale("error_set_home_invalid_characters")
|
||||
.orElse(new MineDown(""));
|
||||
default -> new MineDown("");
|
||||
}));
|
||||
final String newDescription = editArgs;
|
||||
plugin.getSavedPositionManager().updateHomeMeta(home, new PositionMeta(home.meta.name, newDescription))
|
||||
.thenAccept(descriptionUpdateResult -> (switch (descriptionUpdateResult.resultType()) {
|
||||
case SUCCESS -> {
|
||||
if (home.owner.uuid.equals(editor.uuid)) {
|
||||
yield plugin.getLocales().getLocale("edit_home_update_description",
|
||||
home.meta.name,
|
||||
oldHomeDescription, newDescription);
|
||||
} else {
|
||||
yield plugin.getLocales().getLocale("edit_home_update_description_other",
|
||||
home.owner.username, home.meta.name,
|
||||
oldHomeDescription, newDescription);
|
||||
}
|
||||
}
|
||||
case FAILED_DESCRIPTION_LENGTH ->
|
||||
plugin.getLocales().getLocale("error_home_description_length");
|
||||
case FAILED_DESCRIPTION_CHARACTERS ->
|
||||
plugin.getLocales().getLocale("error_home_description_characters");
|
||||
default -> Optional.of(new MineDown(""));
|
||||
}).ifPresent(editor::sendMessage));
|
||||
}
|
||||
case "relocate" -> editor.getPosition().thenAccept(position ->
|
||||
plugin.getSavedPositionManager().updateHomePosition(home, position).thenRun(() -> {
|
||||
@@ -162,10 +169,17 @@ public class EditHomeCommand extends CommandBase implements TabCompletable, Cons
|
||||
editor.sendMessage(plugin.getLocales().getLocale("edit_home_update_location_other",
|
||||
home.owner.username, home.meta.name).orElse(new MineDown("")));
|
||||
}
|
||||
|
||||
// Show the menu if the menu flag is set
|
||||
if (showMenuFlag.get()) {
|
||||
getHomeEditorWindow(home, false, otherOwner,
|
||||
!otherOwner || editor.hasPermission(Permission.COMMAND_HOME_OTHER.node))
|
||||
.forEach(editor::sendMessage);
|
||||
}
|
||||
}));
|
||||
case "privacy" -> {
|
||||
boolean newIsPublic = !home.isPublic;
|
||||
if (editArgs != null) {
|
||||
if (editArgs != null && !editArgs.isBlank()) {
|
||||
if (editArgs.equalsIgnoreCase("private")) {
|
||||
newIsPublic = false;
|
||||
} else if (editArgs.equalsIgnoreCase("public")) {
|
||||
@@ -198,6 +212,13 @@ public class EditHomeCommand extends CommandBase implements TabCompletable, Cons
|
||||
"edit_home_privacy_" + privacyKeyedString + "_success_other",
|
||||
home.owner.username, home.meta.name).orElse(new MineDown("")));
|
||||
}
|
||||
|
||||
// Show the menu if the menu flag is set
|
||||
if (showMenuFlag.get()) {
|
||||
getHomeEditorWindow(home, false, otherOwner,
|
||||
!otherOwner || editor.hasPermission(Permission.COMMAND_HOME_OTHER.node))
|
||||
.forEach(editor::sendMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
default -> plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
@@ -218,6 +239,71 @@ public class EditHomeCommand extends CommandBase implements TabCompletable, Cons
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a formatted home editor chat window for a supplied {@link Home}
|
||||
*
|
||||
* @param home The home to display
|
||||
* @param showTitle Whether to show the menu title
|
||||
* @param otherViewer If the viewer of the editor is not the homeowner
|
||||
* @param showTeleportButton Whether to show the teleport "use" button
|
||||
* @return List of {@link MineDown} messages to send to the editor that form the menu
|
||||
*/
|
||||
@NotNull
|
||||
private List<MineDown> getHomeEditorWindow(@NotNull Home home, final boolean showTitle,
|
||||
final boolean otherViewer, final boolean showTeleportButton) {
|
||||
return new ArrayList<>() {{
|
||||
if (showTitle) {
|
||||
if (!otherViewer) {
|
||||
plugin.getLocales().getLocale("edit_home_menu_title", home.meta.name)
|
||||
.ifPresent(this::add);
|
||||
} else {
|
||||
plugin.getLocales().getLocale("edit_home_menu_title_other", home.owner.username, home.meta.name)
|
||||
.ifPresent(this::add);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getLocales().getLocale("edit_home_menu_metadata_" + (!home.isPublic ? "private" : "public"),
|
||||
DateTimeFormatter.ofPattern("MMM dd yyyy, HH:mm")
|
||||
.format(home.meta.creationTime.atZone(ZoneId.systemDefault())),
|
||||
home.uuid.toString().split(Pattern.quote("-"))[0],
|
||||
home.uuid.toString())
|
||||
.ifPresent(this::add);
|
||||
|
||||
if (home.meta.description.length() > 0) {
|
||||
final String escapedDescription = MineDown.escape(home.meta.description);
|
||||
plugin.getLocales().getLocale("edit_home_menu_description",
|
||||
escapedDescription.length() > 50
|
||||
? escapedDescription.substring(0, 49).trim() + "…" : escapedDescription,
|
||||
String.join("\n", escapedDescription.split("(?<=\\G.{40,}\\s)")))
|
||||
.ifPresent(this::add);
|
||||
}
|
||||
|
||||
if (!plugin.getSettings().crossServer) {
|
||||
plugin.getLocales().getLocale("edit_home_menu_world", home.world.name).ifPresent(this::add);
|
||||
} else {
|
||||
plugin.getLocales().getLocale("edit_home_menu_world_server", home.world.name, home.server.name).ifPresent(this::add);
|
||||
}
|
||||
|
||||
plugin.getLocales().getLocale("edit_home_menu_coordinates",
|
||||
String.format("%.1f", home.x), String.format("%.1f", home.y), String.format("%.1f", home.z),
|
||||
String.format("%.2f", home.yaw), String.format("%.2f", home.pitch))
|
||||
.ifPresent(this::add);
|
||||
|
||||
final String formattedName = home.owner.username + "." + home.meta.name;
|
||||
if (showTeleportButton) {
|
||||
plugin.getLocales().getLocale("edit_home_menu_use_buttons",
|
||||
formattedName)
|
||||
.ifPresent(this::add);
|
||||
}
|
||||
plugin.getLocales().getLocale("edit_home_menu_manage_buttons",
|
||||
formattedName)
|
||||
.ifPresent(this::add);
|
||||
plugin.getLocales().getLocale("edit_home_menu_meta_edit_buttons",
|
||||
formattedName)
|
||||
.ifPresent(this::add);
|
||||
}};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConsoleExecute(@NotNull String[] args) {
|
||||
//todo
|
||||
|
||||
@@ -42,9 +42,9 @@ public class SetHomeCommand extends CommandBase {
|
||||
assert setResult.savedPosition().isPresent();
|
||||
yield plugin.getLocales().getLocale("set_home_success", setResult.savedPosition().get().meta.name);
|
||||
}
|
||||
case FAILED_DUPLICATE -> plugin.getLocales().getLocale("error_set_home_name_taken");
|
||||
case FAILED_NAME_LENGTH -> plugin.getLocales().getLocale("error_set_home_invalid_length");
|
||||
case FAILED_NAME_CHARACTERS -> plugin.getLocales().getLocale("error_set_home_invalid_characters");
|
||||
case FAILED_DUPLICATE -> plugin.getLocales().getLocale("error_home_name_taken");
|
||||
case FAILED_NAME_LENGTH -> plugin.getLocales().getLocale("error_home_name_length");
|
||||
case FAILED_NAME_CHARACTERS -> plugin.getLocales().getLocale("error_home_name_characters");
|
||||
default -> Optional.of(new MineDown(""));
|
||||
}).ifPresent(onlineUser::sendMessage)));
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import net.william278.huskhomes.position.PositionMeta;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class SetWarpCommand extends CommandBase {
|
||||
|
||||
public SetWarpCommand(@NotNull HuskHomes implementor) {
|
||||
@@ -26,21 +28,16 @@ public class SetWarpCommand extends CommandBase {
|
||||
private void setWarp(@NotNull OnlineUser onlineUser, @NotNull String warpName) {
|
||||
onlineUser.getPosition().thenAccept(position -> plugin.getSavedPositionManager().setWarp(new PositionMeta(warpName,
|
||||
plugin.getLocales().getRawLocale("warp_default_description").orElse("")),
|
||||
position).thenAccept(setResult ->
|
||||
onlineUser.sendMessage(switch (setResult.resultType()) {
|
||||
case SUCCESS -> {
|
||||
assert setResult.savedPosition().isPresent();
|
||||
yield plugin.getLocales().getLocale("set_warp_success", setResult.savedPosition().get().meta.name)
|
||||
.orElse(new MineDown(""));
|
||||
}
|
||||
case FAILED_DUPLICATE -> plugin.getLocales().getLocale("error_set_warp_name_taken")
|
||||
.orElse(new MineDown(""));
|
||||
case FAILED_NAME_LENGTH -> plugin.getLocales().getLocale("error_set_warp_invalid_length")
|
||||
.orElse(new MineDown(""));
|
||||
case FAILED_NAME_CHARACTERS -> plugin.getLocales().getLocale("error_set_warp_invalid_characters")
|
||||
.orElse(new MineDown(""));
|
||||
default -> new MineDown("");
|
||||
})));
|
||||
position).thenAccept(setResult -> (switch (setResult.resultType()) {
|
||||
case SUCCESS -> {
|
||||
assert setResult.savedPosition().isPresent();
|
||||
yield plugin.getLocales().getLocale("set_warp_success", setResult.savedPosition().get().meta.name);
|
||||
}
|
||||
case FAILED_DUPLICATE -> plugin.getLocales().getLocale("error_warp_name_taken");
|
||||
case FAILED_NAME_LENGTH -> plugin.getLocales().getLocale("error_warp_name_length");
|
||||
case FAILED_NAME_CHARACTERS -> plugin.getLocales().getLocale("error_warp_name_characters");
|
||||
default -> Optional.of(new MineDown(""));
|
||||
}).ifPresent(onlineUser::sendMessage)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,57 +43,4 @@ public class Home extends SavedPosition {
|
||||
this.isPublic = false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<MineDown> getHomeEditorWindow(@NotNull Locales locales, final boolean otherViewer,
|
||||
final boolean showServerInformation,
|
||||
final boolean showUseButtons, final boolean showManagementButtons) {
|
||||
return new ArrayList<>() {{
|
||||
if (!otherViewer) {
|
||||
locales.getLocale("edit_home_menu_title", meta.name)
|
||||
.ifPresent(this::add);
|
||||
} else {
|
||||
locales.getLocale("edit_home_menu_title_other", owner.username, meta.name)
|
||||
.ifPresent(this::add);
|
||||
}
|
||||
|
||||
locales.getLocale("edit_home_menu_metadata_" + (!isPublic ? "private" : "public"),
|
||||
DateTimeFormatter.ofPattern("MMM dd yyyy, HH:mm")
|
||||
.format(meta.creationTime.atZone(ZoneId.systemDefault())),
|
||||
uuid.toString().split(Pattern.quote("-"))[0],
|
||||
uuid.toString())
|
||||
.ifPresent(this::add);
|
||||
|
||||
if (meta.description.length() > 0) {
|
||||
locales.getLocale("edit_home_menu_description", MineDown.escape(meta.description))
|
||||
.ifPresent(this::add);
|
||||
}
|
||||
|
||||
if (!showServerInformation) {
|
||||
locales.getLocale("edit_home_menu_world", world.name).ifPresent(this::add);
|
||||
} else {
|
||||
locales.getLocale("edit_home_menu_world_server", world.name, server.name).ifPresent(this::add);
|
||||
}
|
||||
|
||||
locales.getLocale("edit_home_menu_coordinates",
|
||||
String.format("%.1f", x), String.format("%.1f", y), String.format("%.1f", z),
|
||||
String.format("%.2f", yaw), String.format("%.2f", pitch))
|
||||
.ifPresent(this::add);
|
||||
|
||||
final String formattedName = owner.username + "." + meta.name;
|
||||
if (showUseButtons) {
|
||||
locales.getLocale("edit_home_menu_use_buttons",
|
||||
formattedName)
|
||||
.ifPresent(this::add);
|
||||
}
|
||||
if (showManagementButtons) {
|
||||
locales.getLocale("edit_home_menu_manage_buttons",
|
||||
formattedName)
|
||||
.ifPresent(this::add);
|
||||
locales.getLocale("edit_home_menu_meta_edit_buttons",
|
||||
formattedName)
|
||||
.ifPresent(this::add);
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public class SavedPositionManager {
|
||||
*/
|
||||
public CompletableFuture<SaveResult> updateHomeMeta(@NotNull Home home, @NotNull PositionMeta newHomeMeta) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
if (database.getHome(home.owner, newHomeMeta.name).join().isPresent()) {
|
||||
if (!home.meta.name.equals(newHomeMeta.name) && database.getHome(home.owner, newHomeMeta.name).join().isPresent()) {
|
||||
return new SaveResult(SaveResult.ResultType.FAILED_DUPLICATE, Optional.empty());
|
||||
}
|
||||
final String existingHomeName = home.meta.name;
|
||||
@@ -271,7 +271,7 @@ public class SavedPositionManager {
|
||||
*/
|
||||
public CompletableFuture<SaveResult> updateWarpMeta(@NotNull Warp warp, @NotNull PositionMeta newWarpMeta) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
if (database.getWarp(newWarpMeta.name).join().isPresent()) {
|
||||
if (!warp.meta.name.equals(newWarpMeta.name) && database.getWarp(newWarpMeta.name).join().isPresent()) {
|
||||
return new SaveResult(SaveResult.ResultType.FAILED_DUPLICATE, Optional.empty());
|
||||
}
|
||||
final String existingWarpName = warp.meta.name;
|
||||
|
||||
@@ -12,7 +12,9 @@ import net.william278.huskhomes.util.MatcherUtil;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -29,6 +31,12 @@ public class TeleportManager {
|
||||
@NotNull
|
||||
protected final HuskHomes plugin;
|
||||
|
||||
/**
|
||||
* A set of user UUIDs currently on warmup countdowns for {@link TimedTeleport}
|
||||
*/
|
||||
@NotNull
|
||||
private HashSet<UUID> currentlyOnWarmup = new HashSet<>();
|
||||
|
||||
public TeleportManager(@NotNull HuskHomes implementor) {
|
||||
this.plugin = implementor;
|
||||
}
|
||||
@@ -145,6 +153,9 @@ public class TeleportManager {
|
||||
public CompletableFuture<TeleportResult> teleport(@NotNull OnlineUser onlineUser, @NotNull Position position) {
|
||||
final int teleportWarmupTime = plugin.getSettings().teleportWarmupTime;
|
||||
if (!onlineUser.hasPermission(Permission.BYPASS_TELEPORT_WARMUP.node) && teleportWarmupTime > 0) {
|
||||
if (currentlyOnWarmup.contains(onlineUser.uuid)) {
|
||||
return CompletableFuture.supplyAsync(() -> TeleportResult.FAILED_ALREADY_TELEPORTING);
|
||||
}
|
||||
return processTeleportWarmup(new TimedTeleport(onlineUser, position, teleportWarmupTime))
|
||||
.thenApply(teleport -> {
|
||||
if (!teleport.cancelled) {
|
||||
@@ -168,6 +179,8 @@ public class TeleportManager {
|
||||
switch (teleportResult) {
|
||||
case COMPLETED_LOCALLY -> plugin.getLocales().getLocale("teleporting_complete")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
case FAILED_ALREADY_TELEPORTING -> plugin.getLocales().getLocale("error_already_teleporting")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
case FAILED_INVALID_WORLD -> plugin.getLocales().getLocale("error_invalid_on_arrival")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
case FAILED_UNSAFE -> {
|
||||
@@ -216,17 +229,26 @@ public class TeleportManager {
|
||||
* @return a future, returning when the teleport has finished
|
||||
*/
|
||||
private CompletableFuture<TimedTeleport> processTeleportWarmup(@NotNull final TimedTeleport teleport) {
|
||||
// Mark the player as warming up
|
||||
currentlyOnWarmup.add(teleport.getPlayer().uuid);
|
||||
|
||||
// Create a scheduled executor to tick the timed teleport
|
||||
final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
||||
final CompletableFuture<TimedTeleport> timedTeleportFuture = new CompletableFuture<>();
|
||||
executor.scheduleAtFixedRate(() -> {
|
||||
// Display countdown action bar message
|
||||
plugin.getLocales().getLocale("teleporting_action_bar_countdown", Integer.toString(teleport.timeLeft))
|
||||
.ifPresent(message -> teleport.getPlayer().sendActionBar(message));
|
||||
if (teleport.timeLeft > 0) {
|
||||
plugin.getLocales().getLocale("teleporting_action_bar_countdown", Integer.toString(teleport.timeLeft))
|
||||
.ifPresent(message -> teleport.getPlayer().sendActionBar(message));
|
||||
} else {
|
||||
plugin.getLocales().getLocale("teleporting_complete")
|
||||
.ifPresent(message -> teleport.getPlayer().sendActionBar(message));
|
||||
}
|
||||
|
||||
// Tick (decrement) the timed teleport timer
|
||||
final Optional<TimedTeleport> result = tickTeleportWarmup(teleport);
|
||||
if (result.isPresent()) {
|
||||
currentlyOnWarmup.remove(teleport.getPlayer().uuid);
|
||||
timedTeleportFuture.complete(teleport);
|
||||
executor.shutdown();
|
||||
}
|
||||
|
||||
@@ -18,10 +18,14 @@ public enum TeleportResult {
|
||||
*/
|
||||
COMPLETED_CROSS_SERVER(true),
|
||||
|
||||
/**
|
||||
* Returns if the {@link Teleport} failed because the user is already teleporting
|
||||
*/
|
||||
FAILED_ALREADY_TELEPORTING(false),
|
||||
|
||||
/**
|
||||
* Returns if the {@link Teleport} failed because the {@link World} of the
|
||||
* target {@link Position} could not be found
|
||||
* <p>
|
||||
*/
|
||||
FAILED_INVALID_WORLD(false),
|
||||
|
||||
|
||||
@@ -1,38 +1,36 @@
|
||||
teleporting_last_position: '[Returning to your last position in](#00fb9a) [%1%](#00fb9a bold) [seconds](#00fb9a)'
|
||||
teleporting_offline_player: '[Teleporting you to where %1% last logged out...](#00fb9a)'
|
||||
teleporting_offline_player: '[Teleporting you to where %1% last logged out…](#00fb9a)'
|
||||
teleporting_countdown_start: '[You will be teleported in](#00fb9a) [%1%](#00fb9a bold) [seconds](#00fb9a)'
|
||||
teleporting_cancelled_movement: '[Teleportation cancelled; you moved!](#ff7e5e)'
|
||||
teleporting_cancelled_damage: '[Teleportation cancelled; you took damage!](#ff7e5e)'
|
||||
teleporting_complete: '[Teleportation complete!](#00fb9a)'
|
||||
teleporting_action_bar_countdown: '[Teleporting in](#00fb9a) [%1%](#00fb9a bold)[...](#00fb9a)'
|
||||
teleporting_action_bar_countdown: '[Teleporting in](#00fb9a) [%1%](#00fb9a bold)[…](#00fb9a)'
|
||||
teleporting_action_bar_cancelled: '[Teleportation cancelled!](#ff7e5e)'
|
||||
teleporting_please_stand_still: '[Teleportation will be cancelled if you move or take damage.](gray)'
|
||||
home_deleted: '[Successfully deleted the home called](#00fb9a) [%1%](#00fb9a bold)'
|
||||
home_deleted: '[Successfully deleted your home,](#00fb9a) [%1%](#00fb9a bold)'
|
||||
home_deleted_other: '[Successfully deleted %1%''s home,](#00fb9a) [%2%](#00fb9a bold)'
|
||||
warp_deleted: '[Successfully deleted the warp called](#00fb9a) [%1%](#00fb9a bold)'
|
||||
|
||||
warp_deleted: '[Successfully deleted the warp,](#00fb9a) [%1%](#00fb9a bold)'
|
||||
|
||||
edit_home_menu_title: '[Viewing home details for](#00fb9a) [%1%](#00fb9a bold)[:](#00fb9a)'
|
||||
edit_home_menu_title_other: '[Viewing details for %1%''s home,](#00fb9a) [%2%](#00fb9a bold)[:](#00fb9a)'
|
||||
edit_home_menu_metadata_private: '[⌚ %1%](#ffc43b-#f5c962 show_text=&7Set Timestamp:\n&8When the home was set) [⚡ %2%](#999999-#bcbcbc show_text=&7Home ID:\n&8%3%) [☁ Private Home](#d8ff2b show_text=&7Privacy: ☁ Private Home\n&8The home is private to the owner)'
|
||||
edit_home_menu_metadata_public: '[⌚ %1%](#999999-#bcbcbc show_text=&7Set Timestamp:\n&8When the home was set) [⚡ %2%](#62a9f5-#7ab8fa show_text=&7Home ID:\n&8%3%) [☀ Public Home](#d8ff2b show_text=&7Privacy: ☀ Public Home\n&8Anyone can teleport to the home)'
|
||||
edit_home_menu_description: '[ℹ %1%](#62a9f5-#7ab8fa show_text=&7Description:\n&8The description set for the home)\n'
|
||||
|
||||
edit_home_menu_metadata_private: '[⌚ %1%](#ffc43b-#f5c962 show_text=&7Set Timestamp:\n&8When the home was set) [⚡ %2%](#999999-#bcbcbc show_text=&7Home ID:\n&8%3%) [● Private Home](#ff9f0f show_text=&7Privacy: ● Private Home\n&8The home is private to the owner)'
|
||||
edit_home_menu_metadata_public: '[⌚ %1%](#ffc43b-#f5c962 show_text=&7Set Timestamp:\n&8When the home was set) [⚡ %2%](#999999-#bcbcbc show_text=&7Home ID:\n&8%3%) [☀ Public Home](#d8ff2b show_text=&7Privacy: ☀ Public Home\n&8Anyone can teleport to the home)'
|
||||
edit_home_menu_description: '[ℹ %1%](#62a9f5-#7ab8fa show_text=&7Home Description:\n&8%2%)\n'
|
||||
edit_home_menu_world: '[⭘ %1%](dark_aqua show_text=&7World:\n&8The world where the home is set)'
|
||||
edit_home_menu_world_server: '[⭘ %1%](dark_aqua show_text=&7World:\n&8The world where the home is set) [⧈ %2%](#36f539 show_text=&7Server:\n&8The server where the home is set)'
|
||||
edit_home_menu_world_server: '[⭘ %1%](dark_aqua show_text=&7World:\n&8The world where the home is set) [☁ %2%](#36f539 show_text=&7Server:\n&8The server where the home is set)'
|
||||
edit_home_menu_coordinates: '[⚐ x: %1%, y: %2%, z: %3%](#ffc43b-#f5c962 show_text=&#ffc43b&yaw: %4%, pitch: %5%\n&7Coordinates:\n&8Location of the home in the world)\n'
|
||||
|
||||
edit_home_menu_use_buttons: '[Use:](gray) [[⏩ Teleport…]](#00fb9a show_text=&7Click to teleport to this home run_command=/huskhomes:home %1%)'
|
||||
edit_home_menu_manage_buttons: '[Manage:](gray) [[❌ Delete…]](#ff3300 show_text=&7Click to delete this home\n&#ff3300&⚠ This cannot be undone! run_command=/huskhomes:delhome %1%) [[⚐ Relocate…]](#ffc43b show_text=&7Click to relocate this home to your position run_command=/huskhomes:edithome %1% relocate) [[☀ Public/Private…]](#d8ff2b show_text=&7Click to toggle the privacy of this home run_command=/huskhomes:edithome %1% privacy)'
|
||||
edit_home_menu_manage_buttons: '[Manage:](gray) [[❌ Delete…]](#ff3300 show_text=&7Click to delete this home\n&#ff3300&⚠ This cannot be undone! run_command=/huskhomes:delhome %1%) [[⚐ Relocate…]](#ffc43b show_text=&7Click to relocate this home to your position run_command=/huskhomes:edithome %1% relocate -m) [[☀ Public/Private…]](#d8ff2b show_text=&7Click to toggle the privacy of this home run_command=/huskhomes:edithome %1% privacy -m)'
|
||||
edit_home_menu_meta_edit_buttons: '[Edit:](gray) [[✎ Rename…]](#62a9f5 show_text=&7Click to suggest the rename command suggest_command=/huskhomes:edithome %1% rename ) [[ℹ Description…]](#7ab8fa show_text=&7Click to suggest the edit description command suggest_command=/huskhomes:edithome %1% description )'
|
||||
|
||||
edit_home_privacy_public_success: '[Successfully made the home,](#00fb9a) [%1%](#00fb9a bold)[, open to the public.](#00fb9a)'
|
||||
edit_home_privacy_private_success: '[Successfully made the home,](#00fb9a) [%1%](#00fb9a bold)[, private.](#00fb9a)'
|
||||
edit_home_privacy_public_success: '[Successfully made your home,](#00fb9a) [%1%](#00fb9a bold)[, open to the public.](#00fb9a)'
|
||||
edit_home_privacy_private_success: '[Successfully made your home,](#00fb9a) [%1%](#00fb9a bold)[, private.](#00fb9a)'
|
||||
edit_home_privacy_public_success_other: '[Successfully made %1%''s home,](#00fb9a) [%2%](#00fb9a bold)[, open to the public.](#00fb9a)'
|
||||
edit_home_privacy_private_success_other: '[Successfully made %1%''s home,](#00fb9a) [%2%](#00fb9a bold)[, private.](#00fb9a)'
|
||||
edit_home_update_location: '[Re-located](#00fb9a) [%1%](#00fb9a bold) [to your current position.](#00fb9a)'
|
||||
edit_home_update_location_other: '[Re-located %1%''s home,](#00fb9a) [%2%](#00fb9a bold)[, to your current position.](#00fb9a)'
|
||||
edit_home_update_description: '[Changed the description for](#00fb9a) [%1%](#00fb9a bold) [to "%2%"](#00fb9a)'
|
||||
edit_home_update_description: '[Successfully changed the description of your home, %1%:](#00fb9a) \n[←](white) [Original:](#00fb9a) ["%2%"](gray)\n[→](white) [New:](#00fb9a) ["%3%"](gray)'
|
||||
edit_home_update_description_other: '[Successfully changed the description of %1%''s home, %2%:](#00fb9a) \n[←](white) [Original:](#00fb9a) ["%3%"](gray)\n[→](white) [New:](#00fb9a) ["%4%"](gray)'
|
||||
edit_home_update_name: '[Successfully changed your home''s name: %1% →](#00fb9a) [%2%](#00fb9a bold)'
|
||||
edit_home_update_name_other: '[Successfully renamed %1%''s home: %2% →](#00fb9a) [%3%](#00fb9a bold)'
|
||||
edit_warp_title: '\n[Edit details for the warp](#00fb9a) [%1%](#00fb9a bold)[:](#00fb9a)'
|
||||
@@ -72,7 +70,7 @@ tpignore_toggle_on: '[You are now](#00fb9a) [ignoring](#00fb9a bold) [incoming t
|
||||
tpignore_toggle_off: '[You are now](#00fb9a) [listening](#00fb9a bold) [to any incoming teleport requests.](#00fb9a) [(Click to toggle)](gray show_text=&7Click to ignore incoming teleport requests run_command=/huskhomes:tpignore)'
|
||||
tpignore_on_reminder: '[You are currently ignoring incoming teleport requests!](gray) [(Click to toggle)](gray show_text=&7Click to listen for incoming teleport requests run_command=/huskhomes:tpignore)'
|
||||
tpaall_request_sent: '[You sent a teleport request asking everyone to teleport to you!](#00fb9a)'
|
||||
teleporting_all_players: '[Teleporting all players to your position...](#00fb9a)'
|
||||
teleporting_all_players: '[Teleporting all players to your position…](#00fb9a)'
|
||||
|
||||
page_options: '[←](gray show_text=&7View previous page run_command=%1%) [Viewing Page %2%/%3%](#00fb9a) [→](gray show_text=&7View next page run_command=%4%)'
|
||||
page_options_min: '[Viewing Page %1%/%2%](#00fb9a) [→](gray show_text=&7View next page run_command=%3%)'
|
||||
@@ -86,8 +84,20 @@ home_list_item: '[[%1%]](show_text=&7%3% run_command=/huskhomes:edithome %2%.%1%
|
||||
public_home_list_item: '[[%1%]](show_text=�fb9a&%2%: &7%3% run_command=/huskhomes:phome %2%.%1%)'
|
||||
warp_list_item: '[[%1%]](show_text=&7%2% run_command=/huskhomes:warp %1%)'
|
||||
|
||||
error_home_name_taken: '[Error:](#ff3300) [You already have a home set with that name.](#ff7e5e)'
|
||||
error_home_name_length: '[Error:](#ff3300) [Home names can only contain up to 16 characters!](#ff7e5e)'
|
||||
error_home_name_characters: '[Error:](#ff3300) [Home names must be alphanumeric (A-Z, 0-9, -_)](#ff7e5e)'
|
||||
error_warp_name_taken: '[Error:](#ff3300) [There is already a warp set with that name.](#ff7e5e)'
|
||||
error_warp_name_length: '[Error:](#ff3300) [Warp names can only contain up to 16 characters!](#ff7e5e)'
|
||||
error_warp_name_characters: '[Error:](#ff3300) [Warp names must be alphanumeric (A-Z,0-9, -_)](#ff7e5e)'
|
||||
|
||||
error_home_description_length: '[Error:](#ff3300) [Home descriptions must be less than 255 characters in length.](#ff7e5e)'
|
||||
error_home_description_characters: '[Error:](#ff3300) [Home descriptions may only contain alphanumeric (A-Z, 0-9) characters, spaces, hyphens (-) and underscores (_)](#ff7e5e)'
|
||||
error_warp_description_length: '[Error:](#ff3300) [Warp descriptions must be less than 255 characters in length.](#ff7e5e)'
|
||||
error_warp_description_characters: '[Error:](#ff3300) [Warp descriptions may only contain alphanumeric (A-Z, 0-9) characters, spaces, hyphens (-) and underscores (_)](#ff7e5e)'
|
||||
|
||||
error_no_permission: '[Error:](#ff3300) [You do not have permission to execute that command.](#ff7e5e)'
|
||||
error_already_teleporting: '[Error:](#ff3300) [Please wait for your current teleport to finish!](#ff7e5e)'
|
||||
error_no_last_position: '[Error:](#ff3300) [You have no last position to return to!](#ff7e5e)'
|
||||
error_in_game_only: '[Error:](#ff3300) [That command can only be run in-game.](#ff7e5e)'
|
||||
error_invalid_server: '[Error:](#ff3300) [Failed to finish your teleportation as the target server could not be found or was offline.](#ff7e5e)'
|
||||
@@ -97,26 +107,16 @@ error_invalid_syntax: '[Error:](#ff3300) [Incorrect syntax. Usage: %1%](#ff7e5e)
|
||||
error_edit_home_privacy_already_public: '[Error:](#ff3300) [This home is already set as public.](#ff7e5e)'
|
||||
error_edit_home_privacy_already_private: '[Error:](#ff3300) [This home is already set as private.](#ff7e5e)'
|
||||
error_edit_home_privacy_no_permission: '[Error:](#ff3300) [You do not have permission to make homes public.](#ff7e5e)'
|
||||
error_edit_home_description_length: '[Error:](#ff3300) [Home descriptions must be less than 255 characters in length.](#ff7e5e)'
|
||||
error_edit_home_description_characters: '[Error:](#ff3300) [Home descriptions may only contain alphanumeric (A-Z, 0-9) characters, hyphens (-) and underscores (_)](#ff7e5e)'
|
||||
error_edit_warp_description_length: '[Error:](#ff3300) [Warp descriptions must be less than 255 characters in length.](#ff7e5e)'
|
||||
error_edit_warp_description_characters: '[Error:](#ff3300) [Warp descriptions may only contain alphanumeric (A-Z, 0-9) characters, hyphens (-) and underscores (_)](#ff7e5e)'
|
||||
error_no_homes_set: '[Error:](#ff3300) [You have not set any homes!](#ff7e5e)'
|
||||
error_no_public_homes_set: '[Error:](#ff3300) [There are no public homes set!](#ff7e5e)'
|
||||
error_no_warps_set: '[Error:](#ff3300) [There are no warps set!](#ff7e5e)'
|
||||
error_public_home_invalid: '[Error:](#ff3300) [Could not find a public home owned by %1% called %2%.](#ff7e5e)'
|
||||
error_set_home_invalid_characters: '[Error:](#ff3300) [Home names must be alphanumeric (A-Z, 0-9, -_)](#ff7e5e)'
|
||||
error_set_home_invalid_length: '[Error:](#ff3300) [Home names can only contain up to 16 characters!](#ff7e5e)'
|
||||
error_set_warp_invalid_characters: '[Error:](#ff3300) [Warp names must be alphanumeric (A-Z,0-9, -_)](#ff7e5e)'
|
||||
error_set_warp_invalid_length: '[Error:](#ff3300) [Warp names can only contain up to 16 characters!](#ff7e5e)'
|
||||
error_set_home_maximum_homes: '[Error:](#ff3300) [You can only set a maximum of %1% homes!](#ff7e5e)'
|
||||
error_insufficient_funds: '[Error:](#ff3300) [You do not have enough money! (Cost: %1%)](#ff7e5e)'
|
||||
error_spawn_undefined: '[Error:](#ff3300) [There is no spawn position defined on this server.](#ff7e5e)'
|
||||
error_tpa_no_pending_request: '[Error:](#ff3300) [You do not have a pending teleport request.](#ff7e5e)'
|
||||
error_tpa_request_expired: '[Error:](#ff3300) [Your pending teleport request has expired.](#ff7e5e)'
|
||||
error_player_not_found: '[Error:](#ff3300) [Could not find the player %1%.](#ff7e5e)'
|
||||
error_set_home_name_taken: '[Error:](#ff3300) [You already have a home set with that name.](#ff7e5e)'
|
||||
error_set_warp_name_taken: '[Error:](#ff3300) [There is already a warp set with that name.](#ff7e5e)'
|
||||
error_tp_self: '[Error:](#ff3300) [You cannot teleport to yourself!](#ff7e5e)'
|
||||
error_rtp_invalid_dimension: '[Error:](#ff3300) [You can only randomly teleport in the overworld!](#ff7e5e)'
|
||||
error_rtp_cooldown: '[Error:](#ff3300) [You must wait %1% minutes before randomly teleporting again.](#ff7e5e)'
|
||||
|
||||
Reference in new issue
Block a user