Fix various issues

This commit is contained in:
William committed 2023-03-20 23:23:06 +00:00
1 parent 503898a0ef
commit 054811676d
35 files changed
+236 -243

No files matched your search

@@ -87,6 +87,7 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
}
private void setHomeDescription(@NotNull CommandUser executor, @NotNull Home home, boolean ownerEditing, @NotNull String[] args) {
final String oldDescription = home.getMeta().getDescription();
final Optional<String> optionalDescription = parseGreedyString(args, 1);
if (optionalDescription.isEmpty()) {
plugin.getLocales().getLocale("error_invalid_syntax",
@@ -106,11 +107,11 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
}
if (ownerEditing) {
plugin.getLocales().getLocale("edit_home_update_description", home.getName(), newDescription)
plugin.getLocales().getLocale("edit_home_update_description", home.getName(), oldDescription, newDescription)
.ifPresent(executor::sendMessage);
} else {
plugin.getLocales().getLocale("edit_home_update_description_other", home.getOwner().getUsername(),
home.getName(), newDescription)
home.getName(), oldDescription, newDescription)
.ifPresent(executor::sendMessage);
}
});
@@ -64,7 +64,7 @@ public class RtpCommand extends Command {
.orElseThrow(() -> new IllegalStateException("No user data found for " + teleporter.getUsername()));
final Instant currentTime = Instant.now();
if (executor.equals(teleporter) && !currentTime.isAfter(user.getRtpCooldown()) &&
!executor.hasPermission(getPermission("bypass_cooldown"))) {
!executor.hasPermission(getPermission("bypass_cooldown"))) {
plugin.getLocales().getLocale("error_rtp_cooldown",
Long.toString(currentTime.until(user.getRtpCooldown(), ChronoUnit.MINUTES) + 1))
.ifPresent(executor::sendMessage);
@@ -74,7 +74,7 @@ public class RtpCommand extends Command {
plugin.getLocales().getLocale("teleporting_random_generation")
.ifPresent(teleporter::sendMessage);
final Optional<Position> position = plugin.getRandomTeleportEngine()
.getRandomPosition(teleporter.getPosition().getWorld(), removeFirstArg(args));
.getRandomPosition(teleporter.getPosition().getWorld(), args.length > 1 ? removeFirstArg(args) : args);
if (position.isEmpty()) {
plugin.getLocales().getLocale("error_rtp_randomization_timeout")
.ifPresent(executor::sendMessage);
@@ -31,7 +31,10 @@ public class SetHomeCommand extends SetPositionCommand {
plugin.getManager().homes().createHome(setter, event.getName(), event.getPosition());
} catch (ValidationException e) {
e.dispatchHomeError(setter, false, plugin, event.getName());
return;
}
plugin.getLocales().getLocale("set_home_success", event.getName())
.ifPresent(setter::sendMessage);
});
}
@@ -18,7 +18,10 @@ public class SetWarpCommand extends SetPositionCommand {
plugin.getManager().warps().createWarp(event.getName(), event.getPosition());
} catch (ValidationException e) {
e.dispatchWarpError(setter, plugin, event.getName());
return;
}
plugin.getLocales().getLocale("set_warp_success", event.getName())
.ifPresent(setter::sendMessage);
});
}
}
@@ -31,7 +31,7 @@ public class TpaAllCommand extends InGameCommand {
}
plugin.getManager().requests().sendTeleportAllRequest(executor);
plugin.getLocales().getLocale("teleporting_all_players")
plugin.getLocales().getLocale("tpaall_request_sent")
.ifPresent(executor::sendMessage);
}
@@ -4,6 +4,7 @@ import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.position.Warp;
import net.william278.huskhomes.teleport.Teleportable;
import net.william278.huskhomes.user.CommandUser;
import net.william278.huskhomes.user.OnlineUser;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -15,6 +16,16 @@ public class WarpCommand extends SavedPositionCommand<Warp> {
super("warp", List.of(), Warp.class, List.of(), plugin);
}
@Override
public void execute(@NotNull CommandUser executor, @NotNull String[] args) {
if (args.length == 0) {
plugin.getCommand(WarpListCommand.class)
.ifPresent(command -> command.showWarpList(executor, 1));
return;
}
super.execute(executor, args);
}
@Override
public void execute(@NotNull CommandUser executor, @NotNull Warp warp, @NotNull String[] args) {
if (plugin.getSettings().isPermissionRestrictWarps()) {
@@ -15,7 +15,7 @@ import java.util.stream.Collectors;
public class WarpListCommand extends ListCommand {
protected WarpListCommand(@NotNull HuskHomes plugin) {
super("homelist", List.of("homes"), "[player] [page]", plugin);
super("warplist", List.of("warps"), "[player] [page]", plugin);
}
@Override