mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 22:17:17 +00:00
Merge remote-tracking branch 'origin/big-refactor' into big-refactor
This commit is contained in:
61 files changed
+1113
-733
No files matched your search
@@ -11,8 +11,8 @@ import java.util.List;
|
||||
|
||||
public class DelHomeCommand extends SavedPositionCommand<Home> {
|
||||
|
||||
public DelHomeCommand(@NotNull HuskHomes implementor) {
|
||||
super("delhome", List.of(), Home.class, List.of(), implementor);
|
||||
public DelHomeCommand(@NotNull HuskHomes plugin) {
|
||||
super("delhome", List.of(), Home.class, List.of(), plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,8 +10,8 @@ import java.util.List;
|
||||
|
||||
public class DelWarpCommand extends SavedPositionCommand<Warp> {
|
||||
|
||||
public DelWarpCommand(@NotNull HuskHomes implementor) {
|
||||
super("delwarp", List.of(), Warp.class, List.of(), implementor);
|
||||
public DelWarpCommand(@NotNull HuskHomes plugin) {
|
||||
super("delwarp", List.of(), Warp.class, List.of(), plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -88,7 +88,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);
|
||||
final Optional<String> optionalDescription = parseGreedyArguments(args);
|
||||
if (optionalDescription.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
"/edithome " + home.getName() + " description <text>")
|
||||
@@ -166,7 +166,7 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
|
||||
home.setPublic(privacyArg.get().equals("public"));
|
||||
plugin.fireEvent(plugin.getHomeEditEvent(home, executor), (event) -> {
|
||||
try {
|
||||
plugin.getManager().homes().setHomePrivacy(home, home.isPublic());
|
||||
plugin.getManager().homes().setHomePrivacy(event.getHome(), home.isPublic());
|
||||
} catch (ValidationException e) {
|
||||
int maxHomes = executor instanceof OnlineUser user ?
|
||||
user.getMaxPublicHomes(plugin.getSettings().getMaxPublicHomes(),
|
||||
|
||||
@@ -67,7 +67,7 @@ public class EditWarpCommand extends SavedPositionCommand<Warp> {
|
||||
}
|
||||
|
||||
private void setWarpDescription(@NotNull CommandUser executor, @NotNull Warp warp, @NotNull String[] args) {
|
||||
final Optional<String> optionalDescription = parseGreedyString(args, 1);
|
||||
final Optional<String> optionalDescription = parseGreedyArguments(args);
|
||||
if (optionalDescription.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
"/editwarp " + warp.getName() + " description <text>")
|
||||
@@ -99,7 +99,7 @@ public class EditWarpCommand extends SavedPositionCommand<Warp> {
|
||||
warp.update(user.getPosition());
|
||||
plugin.fireEvent(plugin.getWarpEditEvent(warp, executor), (event) -> {
|
||||
try {
|
||||
plugin.getManager().warps().relocateWarp(warp, warp);
|
||||
plugin.getManager().warps().setWarpPosition(warp, warp);
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchWarpError(executor, plugin, warp.getName());
|
||||
return;
|
||||
|
||||
@@ -114,15 +114,15 @@ public abstract class Node implements Executable {
|
||||
return Optional.of(plugin.getWorlds().stream()
|
||||
.filter(world -> world.getName().equalsIgnoreCase(worldName))
|
||||
.findFirst()
|
||||
.orElse(new World(worldName, new UUID(0, 0), environment)));
|
||||
.orElse(World.from(worldName, new UUID(0, 0), environment)));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
protected Optional<String> parseGreedyString(@NotNull String[] args, int startIndex) {
|
||||
if (args.length > startIndex) {
|
||||
protected Optional<String> parseGreedyArguments(@NotNull String[] args) {
|
||||
if (args.length > 1) {
|
||||
final StringJoiner sentence = new StringJoiner(" ");
|
||||
for (int i = startIndex; i < args.length; i++) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
sentence.add(args[i]);
|
||||
}
|
||||
return Optional.of(sentence.toString().trim());
|
||||
@@ -132,7 +132,7 @@ public abstract class Node implements Executable {
|
||||
|
||||
protected Position getBasePosition(@NotNull CommandUser executor) {
|
||||
return executor instanceof OnlineUser user ? user.getPosition() : plugin.getSpawn()
|
||||
.orElse(new Position(0, 0, 0, 0, 0, plugin.getWorlds().get(0), plugin.getServerName()));
|
||||
.orElse(Position.at(0, 0, 0, 0, 0, plugin.getWorlds().get(0), plugin.getServerName()));
|
||||
}
|
||||
|
||||
protected Optional<Position> parsePositionArgs(@NotNull Position basePosition, @NotNull String[] args, int startIndex) {
|
||||
@@ -153,7 +153,7 @@ public abstract class Node implements Executable {
|
||||
final Optional<Float> yaw = parseFloatArg(args, startIndex + angleStartIndex);
|
||||
final Optional<Float> pitch = parseFloatArg(args, startIndex + angleStartIndex + 1);
|
||||
|
||||
return Optional.of(new Position(x.get(), y.get(), z.get(),
|
||||
return Optional.of(Position.at(x.get(), y.get(), z.get(),
|
||||
yaw.orElse(basePosition.getYaw()), pitch.orElse(basePosition.getPitch()),
|
||||
world.orElse(basePosition.getWorld()), server.orElse(basePosition.getServer())));
|
||||
}
|
||||
|
||||
@@ -64,13 +64,14 @@ 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);
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate a random position
|
||||
plugin.getLocales().getLocale("teleporting_random_generation")
|
||||
.ifPresent(teleporter::sendMessage);
|
||||
final Optional<Position> position = plugin.getRandomTeleportEngine()
|
||||
|
||||
@@ -14,8 +14,8 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class TpCommand extends Command implements TabProvider {
|
||||
|
||||
protected TpCommand(@NotNull HuskHomes implementor) {
|
||||
super("tp", List.of("tpo"), "[<player|position>] [target]", implementor);
|
||||
protected TpCommand(@NotNull HuskHomes plugin) {
|
||||
super("tp", List.of("tpo"), "[<player|position>] [target]", plugin);
|
||||
setOperatorCommand(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user