Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
* text=auto eol=lf
*.bat text eol=crlf
*.cmd text eol=crlf
*.jar binary
*.zip binary
*.png binary
*.jpg binary
*.jpeg binary
*.webp binary
16 changes: 10 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ jobs:
with:
distribution: temurin
java-version: '21'
cache: maven
cache-dependency-path: '**/pom.xml'

- name: Verify API and core
run: mvn -B -ntp -pl headdb-api,headdb-core -am verify
Expand Down Expand Up @@ -79,11 +77,17 @@ jobs:
with:
distribution: temurin
java-version: '25'
cache: maven
cache-dependency-path: '**/pom.xml'

- name: Package Paper plugin
run: mvn -B -ntp -pl headdb-platforms/headdb-paper -am package
shell: bash
run: |
set -euo pipefail

mvn -B -ntp -U -pl headdb-platforms/headdb-paper -am package || {
echo "Initial Maven build failed. Clearing potentially corrupted Maven Resolver artifact and retrying once."
rm -rf "$HOME/.m2/repository/org/apache/maven/resolver/maven-resolver-named-locks/1.9.18"
mvn -B -ntp -U -pl headdb-platforms/headdb-paper -am package
}

- name: Inspect packaged plugin
shell: bash
Expand Down Expand Up @@ -242,4 +246,4 @@ jobs:
check_reachable(artifact_url(manifest, resource_id))

print(f"Validated manifest revision {manifest['revision']} from {manifest_url}")
PY
PY
6 changes: 6 additions & 0 deletions headdb-platforms/headdb-paper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import io.github.silentdevelopment.headdb.paper.runtime.RuntimeDiagnostics;
import io.github.silentdevelopment.headdb.paper.runtime.StartupChecks;
import io.github.silentdevelopment.headdb.paper.service.PaperHeadDBService;
import io.github.silentdevelopment.headdb.paper.updater.UpdateService;
import io.github.silentdevelopment.hermes.id.LocaleId;
import io.github.silentdevelopment.hermes.paper.core.Hermes;
import io.github.silentdevelopment.hermes.paper.messenger.PaperMessenger;
Expand All @@ -59,6 +60,7 @@ public final class HeadDBPlugin extends JavaPlugin {
private FavoriteHeadService favoriteHeadService;
private CustomCategoryService customCategoryService;
private EconomyService economyService;
private UpdateService updateService;

@Override
public void onEnable() {
Expand All @@ -74,6 +76,8 @@ public void onEnable() {
getServer().getPluginManager().registerEvents(new HeadEditListener(this), this);

registerCommands();
cleanupSuccessfulUpdateBackup();
startUpdater();

} catch (ConfigException exception) {
getSLF4JLogger().error("HeadDB config could not be loaded.", exception);
Expand All @@ -98,10 +102,17 @@ public void onDisable() {
promptInputService.shutdown();
}

if (updateService != null) {
updateService.close();
}

HeadDBMetrics.unregister(this);

adminModes.clear();
favoriteHeadService = null;
customCategoryService = null;
economyService = null;
updateService = null;
runtime = null;
config = null;
guiConfig = null;
Expand Down Expand Up @@ -131,6 +142,7 @@ public synchronized void reload() throws ConfigException {
CustomCategoryService createdCustomCategoryService = new CustomCategoryService(localStoreDatabase);
EconomyService createdEconomyService = EconomyService.create(this, loadedEconomyConfig);
GuiService createdGuiService = new GuiService(this, createdItemFactory);
UpdateService createdUpdateService = new UpdateService(this, loadedConfig);

RuntimeDiagnostics.logConfig(this, loadedConfig);

Expand All @@ -141,6 +153,7 @@ public synchronized void reload() throws ConfigException {
createdRuntime.start();

PluginRuntime previousRuntime = this.runtime;
UpdateService previousUpdateService = this.updateService;

this.config = loadedConfig;
this.guiConfig = loadedGuiConfig;
Expand All @@ -152,10 +165,15 @@ public synchronized void reload() throws ConfigException {
this.favoriteHeadService = createdFavoriteHeadService;
this.customCategoryService = createdCustomCategoryService;
this.economyService = createdEconomyService;
this.updateService = createdUpdateService;

clearItemCache();
clearSearchCache();

if (previousUpdateService != null) {
previousUpdateService.close();
}

if (previousRuntime != null) {
previousRuntime.close();
}
Expand All @@ -167,6 +185,27 @@ public synchronized void reload() throws ConfigException {
HeadDBMetrics.register(this);
}


public synchronized void startUpdater() {
UpdateService currentUpdateService = updateService;

if (currentUpdateService == null) {
throw new IllegalStateException("HeadDB update service is not initialized");
}

currentUpdateService.start();
}

public synchronized void cleanupSuccessfulUpdateBackup() {
UpdateService currentUpdateService = updateService;

if (currentUpdateService == null) {
throw new IllegalStateException("HeadDB update service is not initialized");
}

currentUpdateService.cleanupBackupAfterSuccessfulLoad();
}

public @NotNull HeadItemFactory itemFactory() {
HeadItemFactory currentItemFactory = itemFactory;

Expand Down Expand Up @@ -271,6 +310,14 @@ public synchronized void reloadGuiConfigOnly() throws ConfigException {
return currentEconomyService;
}

public @NotNull UpdateService updater() {
UpdateService currentUpdateService = updateService;
if (currentUpdateService == null) {
throw new IllegalStateException("HeadDB update service is not initialized");
}
return currentUpdateService;
}

public @NotNull Messages messages() {
Messages currentMessages = messages;

Expand Down Expand Up @@ -387,4 +434,4 @@ public boolean isPaper() {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import io.github.silentdevelopment.headdb.paper.command.subcommand.ReloadCommand;
import io.github.silentdevelopment.headdb.paper.command.subcommand.StatusCommand;
import io.github.silentdevelopment.headdb.paper.command.subcommand.TagsCommand;
import io.github.silentdevelopment.headdb.paper.command.subcommand.UpdateCommand;
import io.github.silentdevelopment.headdb.paper.command.subcommand.VerifyCommand;
import io.github.silentdevelopment.headdb.paper.command.subcommand.VersionCommand;
import io.github.silentdevelopment.headdb.paper.command.subcommand.search.SearchCommand;
import io.github.silentdevelopment.headdb.paper.permission.Permissions;
import io.github.silentdevelopment.relay.command.CommandDefinition;
Expand All @@ -42,11 +44,13 @@ public RootCommand(@NotNull HeadDBPlugin plugin) {
this.plugin = Objects.requireNonNull(plugin, "plugin");
this.children = List.of(
new HelpCommand(plugin),
new VersionCommand(plugin),
new StatusCommand(plugin),
new DebugCommand(plugin),
new VerifyCommand(plugin),
new RefreshCommand(plugin),
new ReloadCommand(plugin),
new UpdateCommand(plugin),
new GiveCommand(plugin),
new PlayerCommand(plugin),
new CustomCommand(plugin),
Expand Down Expand Up @@ -94,4 +98,4 @@ protected void handle(@NotNull PaperCommandContext context) {
.suggestAliases(true)
.noArgs();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private HelpFormatter() {

addSection(lines, sender, new HelpSection("General", List.of(
new HelpEntry(List.of("help"), "h", List.of(), "/hdb help", "Show this command reference.", Permissions.HELP),
new HelpEntry(List.of("version"), null, List.of(), "/hdb version", "Show version and build information.", Permissions.VERSION),
new HelpEntry(List.of("open"), "o", List.of(), "/hdb open", "Open the main HeadDB GUI.", Permissions.OPEN)
)));

Expand Down Expand Up @@ -79,6 +80,7 @@ private HelpFormatter() {
)));

addSection(lines, sender, new HelpSection("Admin", List.of(
new HelpEntry(List.of("update"), null, List.of(), "/hdb update", "Check for and download the latest version.", Permissions.UPDATE),
new HelpEntry(List.of("itemcache", "clear"), "ic clear", List.of(), "/hdb itemcache clear", "Clear generated item cache.", Permissions.ITEM_CACHE)
)));

Expand Down Expand Up @@ -234,4 +236,4 @@ private enum ArgumentKind {
REQUIRED,
OPTIONAL
}
}
}
Loading
Loading