mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
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:
1 parent
05bcad9249
commit
ffe995ef5f
162 files changed
+3890
-5730
No files matched your search
@@ -19,10 +19,12 @@
|
||||
|
||||
package net.william278.huskhomes.hook;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import net.william278.huskhomes.BukkitHuskHomes;
|
||||
import net.william278.huskhomes.user.BukkitUser;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.user.SavedUser;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -31,25 +33,38 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@PluginHook(
|
||||
name = "PlaceholderAPI",
|
||||
register = PluginHook.Register.ON_LOAD
|
||||
)
|
||||
public class PlaceholderAPIHook extends Hook {
|
||||
|
||||
public PlaceholderAPIHook(@NotNull BukkitHuskHomes plugin) {
|
||||
super(plugin, "PlaceholderAPI");
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
new HuskHomesExpansion((BukkitHuskHomes) plugin).register();
|
||||
public void load() {
|
||||
new HuskHomesExpansion(
|
||||
(BukkitHuskHomes) plugin,
|
||||
plugin.getPluginVersion().toStringWithoutMetadata()
|
||||
).register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
}
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public static class HuskHomesExpansion extends PlaceholderExpansion {
|
||||
|
||||
@NotNull
|
||||
@Getter(AccessLevel.NONE)
|
||||
private final BukkitHuskHomes plugin;
|
||||
|
||||
private HuskHomesExpansion(@NotNull BukkitHuskHomes plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
private final String version;
|
||||
private final String author = "William278";
|
||||
private final String identifier = "huskhomes";
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -59,11 +74,11 @@ public class PlaceholderAPIHook extends Hook {
|
||||
}
|
||||
|
||||
// Return the requested data
|
||||
final OnlineUser player = BukkitUser.adapt(offlinePlayer.getPlayer(), plugin);
|
||||
final OnlineUser player = plugin.getOnlineUser(offlinePlayer.getPlayer());
|
||||
return switch (params) {
|
||||
case "homes_count" -> String.valueOf(plugin.getManager().homes()
|
||||
.getUserHomes()
|
||||
.getOrDefault(player.getUsername(), List.of()).size());
|
||||
.getOrDefault(player.getName(), List.of()).size());
|
||||
case "max_homes" -> String.valueOf(plugin.getManager().homes().getMaxHomes(player));
|
||||
case "max_public_homes" -> String.valueOf(plugin.getManager().homes().getMaxPublicHomes(player));
|
||||
case "free_home_slots" -> String.valueOf(plugin.getManager().homes().getFreeHomes(player));
|
||||
@@ -72,42 +87,19 @@ public class PlaceholderAPIHook extends Hook {
|
||||
.orElse(0));
|
||||
case "homes_list" -> String.join(", ", plugin.getManager().homes()
|
||||
.getUserHomes()
|
||||
.getOrDefault(player.getUsername(), List.of()));
|
||||
.getOrDefault(player.getName(), List.of()));
|
||||
case "public_homes_count" -> String.valueOf(plugin.getManager().homes()
|
||||
.getPublicHomes()
|
||||
.getOrDefault(player.getUsername(), List.of()).size());
|
||||
.getOrDefault(player.getName(), List.of()).size());
|
||||
case "public_homes_list" -> String.join(", ", plugin.getManager().homes()
|
||||
.getPublicHomes()
|
||||
.getOrDefault(player.getUsername(), List.of()));
|
||||
.getOrDefault(player.getName(), List.of()));
|
||||
case "ignoring_tp_requests" -> getBooleanValue(plugin.getManager().requests()
|
||||
.isIgnoringRequests(player));
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getIdentifier() {
|
||||
return "huskhomes";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getAuthor() {
|
||||
return "William278";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getVersion() {
|
||||
return plugin.getVersion().toStringWithoutMetadata();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getBooleanValue(final boolean bool) {
|
||||
return bool ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
|
||||
|
||||
Reference in new issue
Block a user