refactor: significantly refactor internals, remove Sponge (#708)

* feat: start database refactor

Adds database migrations

* refactor: refactor database system

Now supports migrations

* refactor: begin major internals rewrite

move to using provider-style interfaces similar to huskclaims
bukkit done, still need to do fabric and sponge

* refactor: remove sponge, checkstyle

Low usage and high maintenance time cost. We will examine Forge instead in the future.

* refactor: implement refactoring changes on fabric

also fix various refactor quirks on Bukkit

* refactor: tidy metrics logic

* build: bump deps
This commit is contained in:
William authored and GitHub committed 2024-10-28 20:49:57 +00:00
1 parent 05bcad9249
commit ffe995ef5f
162 files changed
+3890 -5730

No files matched your search

@@ -28,17 +28,10 @@ import net.fabricmc.fabric.api.util.TriState;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.william278.huskhomes.FabricHuskHomes;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.teleport.TeleportRequest;
import net.william278.huskhomes.user.CommandUser;
import net.william278.huskhomes.user.FabricUser;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Predicate;
import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
@@ -97,7 +90,7 @@ public class FabricCommand {
}
private com.mojang.brigadier.suggestion.SuggestionProvider<ServerCommandSource> getBrigadierSuggester() {
if (!(command instanceof TabProvider provider)) {
if (!(command instanceof TabCompletable provider)) {
return (context, builder) -> com.mojang.brigadier.suggestion.Suggestions.empty();
}
return (context, builder) -> {
@@ -118,64 +111,9 @@ public class FabricCommand {
private CommandUser resolveExecutor(@NotNull ServerCommandSource source) {
if (source.getEntity() instanceof ServerPlayerEntity player) {
return FabricUser.adapt(player, plugin);
return plugin.getOnlineUser(player);
}
return plugin.getConsole();
}
/**
* Commands available on the Fabric HuskHomes implementation.
*/
public enum Type {
HOME_COMMAND(PrivateHomeCommand::new),
SET_HOME_COMMAND(SetHomeCommand::new),
HOME_LIST_COMMAND(HomeListCommand::new),
DEL_HOME_COMMAND(DelHomeCommand::new),
EDIT_HOME_COMMAND(EditHomeCommand::new),
PUBLIC_HOME_COMMAND(PublicHomeCommand::new),
PUBLIC_HOME_LIST_COMMAND(PublicHomeListCommand::new),
WARP_COMMAND(WarpCommand::new),
SET_WARP_COMMAND(SetWarpCommand::new),
WARP_LIST_COMMAND(WarpListCommand::new),
DEL_WARP_COMMAND(DelWarpCommand::new),
EDIT_WARP_COMMAND(EditWarpCommand::new),
TP_COMMAND(TpCommand::new),
TP_HERE_COMMAND(TpHereCommand::new),
TPA_COMMAND((plugin) -> new TeleportRequestCommand(plugin, TeleportRequest.Type.TPA)),
TPA_HERE_COMMAND((plugin) -> new TeleportRequestCommand(plugin, TeleportRequest.Type.TPA_HERE)),
TPACCEPT_COMMAND((plugin) -> new TpRespondCommand(plugin, true)),
TPDECLINE_COMMAND((plugin) -> new TpRespondCommand(plugin, false)),
RTP_COMMAND(RTPCommand::new),
TP_IGNORE_COMMAND(TpIgnoreCommand::new),
TP_OFFLINE_COMMAND(TpOfflineCommand::new),
TP_ALL_COMMAND(TpAllCommand::new),
TPA_ALL_COMMAND(TpaAllCommand::new),
SPAWN_COMMAND(SpawnCommand::new),
SET_SPAWN_COMMAND(SetSpawnCommand::new),
BACK_COMMAND(BackCommand::new),
HUSKHOMES_COMMAND(HuskHomesCommand::new);
private final Function<HuskHomes, Command> supplier;
Type(@NotNull Function<HuskHomes, Command> supplier) {
this.supplier = supplier;
}
@NotNull
public Command createCommand(@NotNull HuskHomes plugin) {
return supplier.apply(plugin);
}
@NotNull
public static List<Command> getCommands(@NotNull FabricHuskHomes plugin) {
return Arrays.stream(values())
.map(type -> type.createCommand(plugin))
.map(command -> plugin.getSettings().isCommandDisabled(command) ? null : command)
.filter(Objects::nonNull)
.toList();
}
}
}