From 2ed245753d1a31a7c05b7735035a0effa97ba0a8 Mon Sep 17 00:00:00 2001 From: BenCodez <17074231+BenCodez@users.noreply.github.com> Date: Wed, 18 Nov 2026 00:08:24 +0000 Subject: [PATCH 1/6] Give fresh NeoForge installs supported reward defaults --- .../neoforge/NeoForgeRewardConfiguration.java | 2 +- .../neoforge/NeoForgeRuntime.java | 16 +- .../src/main/resources/neoforge/Config.yml | 23 +++ .../resources/neoforge/SpecialRewards.yml | 16 ++ .../src/main/resources/neoforge/VoteSites.yml | 17 ++ .../NeoForgeFirstRunConfigurationTest.java | 164 ++++++++++++++++++ .../tests/packaging/PackagedArtifactTest.java | 3 + docs/neoforge-bootstrap.md | 12 +- 8 files changed, 248 insertions(+), 5 deletions(-) create mode 100644 VotingPlugin/src/main/resources/neoforge/Config.yml create mode 100644 VotingPlugin/src/main/resources/neoforge/SpecialRewards.yml create mode 100644 VotingPlugin/src/main/resources/neoforge/VoteSites.yml create mode 100644 VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java diff --git a/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeRewardConfiguration.java b/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeRewardConfiguration.java index e5de5e9d53..420988bb2d 100644 --- a/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeRewardConfiguration.java +++ b/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeRewardConfiguration.java @@ -82,7 +82,7 @@ private static NeoForgeRewardPlan.Action expand(NeoForgeRewardPlan.Action action .replace("%ServiceSite%", serviceSite).replace("%servicesite%", serviceSite)); } - private String unsupportedGlobalBehavior() { + String unsupportedGlobalBehavior() { if (node(config, ignoreCase, "CloseInventoryOnVote").getBoolean(true)) { return "CloseInventoryOnVote is not supported by NeoForge replay yet"; } diff --git a/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeRuntime.java b/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeRuntime.java index d9d9b30c1b..baa276843e 100644 --- a/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeRuntime.java +++ b/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeRuntime.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.logging.Logger; import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.yaml.YamlConfigurationLoader; @@ -98,6 +99,13 @@ private static NeoForgeRuntime start(Path directory, Clock clock, Object server) ConfigurationNode voteSites = YamlConfigurationLoader.builder().path(voteSitesFile).build().load(); ConfigurationNode specialRewards = YamlConfigurationLoader.builder().path(specialRewardsFile).build().load(); ConfigurationNode bungeeSettings = YamlConfigurationLoader.builder().path(bungeeSettingsFile).build().load(); + String rewardBlocker = new NeoForgeRewardConfiguration(config, voteSites, specialRewards) + .unsupportedGlobalBehavior(); + if (rewardBlocker != null) { + Logger.getLogger(NeoForgeRuntime.class.getName()).warning("NeoForge reward configuration: " + + rewardBlocker + "; affected votes remain pending. Review the NeoForge setup guide;" + + " existing configuration files are not changed."); + } NeoForgeVoteConfiguration voteConfiguration = NeoForgeVoteConfiguration.load(config, voteSites); NeoForgeProxySocketConfiguration proxyConfiguration; try { @@ -136,8 +144,12 @@ private static List storageKeys() { private static Path installDefault(Path directory, String name) throws IOException { Path target = directory.resolve(name); if (Files.notExists(target)) { - try (InputStream resource = NeoForgeRuntime.class.getClassLoader().getResourceAsStream(name)) { - if (resource == null) throw new IOException("Missing packaged configuration: " + name); + String resourceName = switch (name) { + case "Config.yml", "VoteSites.yml", "SpecialRewards.yml" -> "neoforge/" + name; + default -> name; + }; + try (InputStream resource = NeoForgeRuntime.class.getClassLoader().getResourceAsStream(resourceName)) { + if (resource == null) throw new IOException("Missing packaged configuration: " + resourceName); try { Files.copy(resource, target); } catch (FileAlreadyExistsException ignored) { diff --git a/VotingPlugin/src/main/resources/neoforge/Config.yml b/VotingPlugin/src/main/resources/neoforge/Config.yml new file mode 100644 index 0000000000..537051ae29 --- /dev/null +++ b/VotingPlugin/src/main/resources/neoforge/Config.yml @@ -0,0 +1,23 @@ +# NeoForge first-run settings for Minecraft 1.21.1 / Java 21. +# Existing files are never replaced. Changes take effect after a server restart. +# See docs/neoforge-bootstrap.md for proxy authentication and reward limitations. +DataStorage: SQLITE +AllowUnjoined: false +AllowUnJoinedCheckServer: true +AddTotals: true +AddTotalsOffline: true +CountFakeVotes: true +ProcessRewards: true +PointsOnVote: 1 +LimitVotePoints: -1 + +# These Bukkit features are not supported by NeoForge reward replay. +# Enabling them retains affected votes instead of silently omitting their effects. +CloseInventoryOnVote: false +UseVoteStreaks: false +PerSiteCoolDownEvents: false +LimitMonthlyVotes: false +OfflineVotesLimit: + Enabled: false +VoteBroadcast: + Type: NONE diff --git a/VotingPlugin/src/main/resources/neoforge/SpecialRewards.yml b/VotingPlugin/src/main/resources/neoforge/SpecialRewards.yml new file mode 100644 index 0000000000..5df36c0bc4 --- /dev/null +++ b/VotingPlugin/src/main/resources/neoforge/SpecialRewards.yml @@ -0,0 +1,16 @@ +# NeoForge does not yet execute special reward trees. +# Leave these empty/disabled to permit the supported per-site reward to complete. +# Existing installations keep their configured rewards and pending votes. +VoteParty: + Enabled: false +AnySiteRewards: {} +VoteCoolDownEndedReward: {} +VoteMilestones: {} +VoteStreaks: {} +VoteStreak: {} +Cumulative: {} +MileStones: {} +FirstVote: {} +FirstVoteToday: {} +AllSites: {} +AlmostAllSites: {} diff --git a/VotingPlugin/src/main/resources/neoforge/VoteSites.yml b/VotingPlugin/src/main/resources/neoforge/VoteSites.yml new file mode 100644 index 0000000000..db38353cb7 --- /dev/null +++ b/VotingPlugin/src/main/resources/neoforge/VoteSites.yml @@ -0,0 +1,17 @@ +# Configure ServiceSite to match your proxy vote service, then enable the site. +# NeoForge supports ONE plain player message OR console command per vote. +# Do not combine actions, Bukkit formatting, items or special reward trees. +VoteSites: + ExampleVoteSite: + Enabled: false + Name: ExampleVoteSite + ServiceSite: PlanetMinecraft.com + VoteURL: https://example.org/vote + VoteDelay: 24h + WaitUntilVoteDelay: false + # This console command can run while the player is offline. + GiveOffline: true + Rewards: + Commands: + - 'say %player% voted on %SiteName%' +EverySiteReward: {} diff --git a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java new file mode 100644 index 0000000000..5d2fc52b0d --- /dev/null +++ b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java @@ -0,0 +1,164 @@ +package com.bencodez.votingplugin.tests.neoforge; + +import static org.junit.jupiter.api.Assertions.*; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Handler; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.spongepowered.configurate.yaml.YamlConfigurationLoader; + +import com.bencodez.votingplugin.core.vote.SharedVoteIdentity; +import com.bencodez.votingplugin.neoforge.*; + +class NeoForgeFirstRunConfigurationTest { + @TempDir Path directory; + + @Test + void freshConfigurationCanCompleteOneSupportedRewardAcrossRestart() throws Exception { + try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(directory)) { + assertFalse(runtime.config().node("CloseInventoryOnVote").getBoolean(true)); + assertFalse(runtime.config().node("UseVoteStreaks").getBoolean(true)); + assertEquals("NONE", runtime.config().node("VoteBroadcast", "Type").getString()); + assertTrue(runtime.voteConfiguration().voteSites().stream().noneMatch(NeoForgeVoteSite::enabled)); + } + Path sitesFile = directory.resolve("VoteSites.yml"); + var loader = YamlConfigurationLoader.builder().path(sitesFile).build(); + var sites = loader.load(); + sites.node("VoteSites", "ExampleVoteSite", "Enabled").set(true); + loader.save(sites); + UUID player = UUID.randomUUID(); + UUID vote = UUID.randomUUID(); + try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(directory)) { + NeoForgePlayerDirectoryAccess.joined(runtime.players(), new SharedVoteIdentity(player, "Alex", true)); + assertEquals(NeoForgeVoteResult.Status.DEFERRED, runtime.voteProcessor().process( + new NeoForgeVoteRequest(vote, player, "Alex", "PlanetMinecraft.com", 100L, + true, true, true, NeoForgeVoteRequest.Scope.COMPLETE)).status()); + assertEquals(vote, runtime.deferredVotes().pending(player).get(0).voteId()); + } + AtomicInteger actions = new AtomicInteger(); + try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(directory); + NeoForgeRewardReplayService replay = NeoForgeRewardReplayServiceAccess.create( + runtime.voteConfiguration(), new NeoForgeRewardConfigurationAccess(runtime.config(), + runtime.voteSites(), runtime.specialRewards()), runtime.accounting(), + runtime.deferredVotes(), runtime.players(), (occurrence, plan) -> { + assertEquals(vote, occurrence.voteId()); + assertEquals(1, plan.actions().size()); + assertEquals(NeoForgeRewardPlan.ActionType.CONSOLE_COMMAND, plan.actions().get(0).type()); + actions.incrementAndGet(); + return CompletableFuture.completedFuture(null); + })) { + assertEquals(NeoForgeRewardReplayService.Status.COMPLETED, + replay.replayOnce().get(5, TimeUnit.SECONDS).get(0).status()); + assertEquals(1, actions.get()); + assertEquals(1, runtime.accounting().load(player).orElseThrow().allTimeTotal()); + assertEquals(1, runtime.accounting().load(player).orElseThrow().points()); + assertTrue(runtime.deferredVotes().pending(player).isEmpty()); + } + try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(directory)) { + assertEquals(NeoForgeVoteResult.Status.ALREADY_COMPLETED, runtime.voteProcessor().process( + new NeoForgeVoteRequest(vote, player, "Alex", "PlanetMinecraft.com", 100L, + true, true, true, NeoForgeVoteRequest.Scope.COMPLETE)).status()); + assertEquals(1, runtime.accounting().load(player).orElseThrow().allTimeTotal()); + } + } + + @Test + void preservesEveryExistingFileByteForByteAndStillBlocksUnsupportedSettings() throws Exception { + String config = "# Operator configuration\nDataStorage: SQLITE\nCloseInventoryOnVote: true\n"; + Files.writeString(directory.resolve("Config.yml"), config); + Files.writeString(directory.resolve("VoteSites.yml"), "# Existing sites\nVoteSites: {}\n"); + Files.writeString(directory.resolve("SpecialRewards.yml"), "# Existing rewards\nFirstVote: {}\n"); + List files = List.of(directory.resolve("Config.yml"), directory.resolve("VoteSites.yml"), + directory.resolve("SpecialRewards.yml")); + List before = files.stream().map(path -> { + try { return Files.readString(path); } catch (Exception e) { throw new RuntimeException(e); } + }).toList(); + for (int restart = 0; restart < 2; restart++) { + try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(directory)) { + assertTrue(runtime.config().node("CloseInventoryOnVote").getBoolean()); + assertTrue(runtime.specialRewards().node("VoteMilestones").virtual()); + } + } + for (int i = 0; i < files.size(); i++) assertEquals(before.get(i), Files.readString(files.get(i))); + } + + @Test + void existingUnsupportedSettingKeepsPendingVoteAndExplainsWhyAfterRestart() throws Exception { + try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(directory)) { } + Path configFile = directory.resolve("Config.yml"); + var configLoader = YamlConfigurationLoader.builder().path(configFile).build(); + var config = configLoader.load(); + config.node("CloseInventoryOnVote").set(true); + configLoader.save(config); + Path sitesFile = directory.resolve("VoteSites.yml"); + var sitesLoader = YamlConfigurationLoader.builder().path(sitesFile).build(); + var sites = sitesLoader.load(); + sites.node("VoteSites", "ExampleVoteSite", "Enabled").set(true); + sitesLoader.save(sites); + UUID player = UUID.randomUUID(); + UUID vote = UUID.randomUUID(); + AtomicInteger warnings = new AtomicInteger(); + Logger logger = Logger.getLogger(NeoForgeRuntime.class.getName()); + Handler handler = new Handler() { + @Override public void publish(LogRecord record) { + if (record.getMessage().contains("CloseInventoryOnVote") + && record.getMessage().contains("remain pending")) warnings.incrementAndGet(); + } + @Override public void flush() { } + @Override public void close() { } + }; + logger.addHandler(handler); + try { + try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(directory)) { + NeoForgePlayerDirectoryAccess.joined(runtime.players(), new SharedVoteIdentity(player, "Alex", true)); + assertEquals(NeoForgeVoteResult.Status.DEFERRED, runtime.voteProcessor().process( + new NeoForgeVoteRequest(vote, player, "Alex", "PlanetMinecraft.com", 100L, + true, true, true, NeoForgeVoteRequest.Scope.COMPLETE)).status()); + } + try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(directory); + NeoForgeRewardReplayService replay = NeoForgeRewardReplayServiceAccess.create( + runtime.voteConfiguration(), new NeoForgeRewardConfigurationAccess(runtime.config(), + runtime.voteSites(), runtime.specialRewards()), runtime.accounting(), + runtime.deferredVotes(), runtime.players(), (occurrence, plan) -> { + fail("Unsupported configuration must not execute a reward"); + return CompletableFuture.completedFuture(null); + })) { + var result = replay.replayOnce().get(5, TimeUnit.SECONDS).get(0); + assertEquals(NeoForgeRewardReplayService.Status.BLOCKED_UNSUPPORTED, result.status()); + assertTrue(result.detail().contains("CloseInventoryOnVote")); + assertEquals(vote, runtime.deferredVotes().pending(player).get(0).voteId()); + assertEquals(0, runtime.accounting().load(player).map(NeoForgeVoteAccount::allTimeTotal).orElse(0)); + } + assertEquals(2, warnings.get()); + } finally { + logger.removeHandler(handler); + } + } + + @Test + void sharedBukkitResourcesKeepTheirEstablishedDefaults() throws Exception { + Path bukkitConfig = directory.resolve("bukkit.yml"); + Path bukkitRewards = directory.resolve("bukkit-rewards.yml"); + try (var config = getClass().getClassLoader().getResourceAsStream("Config.yml"); + var rewards = getClass().getClassLoader().getResourceAsStream("SpecialRewards.yml")) { + Files.copy(config, bukkitConfig); + Files.copy(rewards, bukkitRewards); + } + var config = YamlConfigurationLoader.builder().path(bukkitConfig).build().load(); + var rewards = YamlConfigurationLoader.builder().path(bukkitRewards).build().load(); + assertTrue(config.node("CloseInventoryOnVote").getBoolean()); + assertTrue(config.node("UseVoteStreaks").getBoolean()); + assertEquals("EVERY_VOTE", config.node("VoteBroadcast", "Type").getString()); + assertTrue(rewards.node("VoteMilestones", "FirstVoteAllTime", "Enabled").getBoolean()); + } +} diff --git a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/packaging/PackagedArtifactTest.java b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/packaging/PackagedArtifactTest.java index 4c83036010..02eda6d6b2 100644 --- a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/packaging/PackagedArtifactTest.java +++ b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/packaging/PackagedArtifactTest.java @@ -33,6 +33,9 @@ void containsOneRelocatedRuntimeWithoutUnusedHttpCrypto() throws Exception { assertNotNull(artifact.getEntry("com/bencodez/votingplugin/VotingPluginMain.class")); assertNotNull(artifact.getEntry("plugin.yml")); assertNotNull(artifact.getEntry("META-INF/neoforge.mods.toml")); + for (String name : java.util.List.of("Config.yml", "VoteSites.yml", "SpecialRewards.yml")) { + assertNotNull(artifact.getEntry("neoforge/" + name)); + } String modMetadata = new String(artifact.getInputStream( artifact.getEntry("META-INF/neoforge.mods.toml")).readAllBytes(), StandardCharsets.UTF_8); assertTrue(modMetadata.contains("modId=\"votingplugin\"")); diff --git a/docs/neoforge-bootstrap.md b/docs/neoforge-bootstrap.md index 15a2ec9e8e..ffc944bd04 100644 --- a/docs/neoforge-bootstrap.md +++ b/docs/neoforge-bootstrap.md @@ -2,7 +2,7 @@ The single `VotingPlugin.jar` contains an experimental NeoForge 21.1 entry point for Minecraft 1.21.1. Native vote ingress remains disabled. Bukkit and proxy behavior remains on its existing paths. -On server start, the entry point creates `config/votingplugin/`, installs the packaged `Config.yml`, `VoteSites.yml`, and `SpecialRewards.yml` only when missing, reads them, and opens the existing AdvancedCore SQLite user backend in `VotingPlugin.db`. The bootstrap currently accepts `DataStorage: SQLITE` only. Its separate `VotingPlugin_NeoForgeUsers` table stores the player name, all-time/monthly/daily/weekly totals, points, and per-site last-vote timestamps needed by the shared accounting step. Existing UUID-only bootstrap tables are extended in place. The accounting adapter is a storage foundation and is not wired to live vote ingress. The runtime closes the backend and clears queued tasks and online player identities on server stop. +On server start, the entry point creates `config/votingplugin/`, installs NeoForge-specific `Config.yml`, `VoteSites.yml`, and `SpecialRewards.yml` only when each file is missing, reads them, and opens the existing AdvancedCore SQLite user backend in `VotingPlugin.db`. The bootstrap currently accepts `DataStorage: SQLITE` only. Its separate `VotingPlugin_NeoForgeUsers` table stores the player name, all-time/monthly/daily/weekly totals, points, and per-site last-vote timestamps needed by the shared accounting step. Existing UUID-only bootstrap tables are extended in place. The accounting adapter is a storage foundation and is not wired to live vote ingress. The runtime closes the backend and clears queued tasks and online player identities on server stop. The NeoForge bridge tracks login/logout identity and runs submitted bootstrap tasks on server ticks. Player identity access uses reflection because NeoForge's published universal Maven JAR does not include Minecraft classes on Maven's compile path; these method names were checked against the installed 1.21.1 server JAR. @@ -10,6 +10,14 @@ An internal synthetic vote boundary now supports identity and enabled-site resol Native Votifier ingress remains disabled. VotifierPlus's hardened packet handling is currently packaged with its Bukkit, BungeeCord, and Velocity plugin runtime rather than as a platform-neutral API that this single VotingPlugin artifact can reuse. Depending on that full plugin would pull unrelated platform code into VotingPlugin, while copying its security-sensitive protocol implementation would create a second implementation. +## First-run configuration + +A new NeoForge installation receives its own starter files. Bukkit and proxy defaults are unchanged. The starter disables inventory closing, streaks, local vote broadcasts, cooldown events, monthly vote limits, offline vote limits and special reward trees. Its example site starts disabled and contains one plain console command, which can run while the player is offline. Configure its `ServiceSite` to match the vote service, replace the example URL, and enable the site. Configure authenticated proxy delivery as described below; installation alone does not enable a listener. + +Keep `DataStorage: SQLITE`. Use at most one plain `Commands` action or one plain `Messages.Player` action per vote across the site and `EverySiteReward`. A player message waits for the player to be online. Bukkit formatting, item rewards and multiple actions remain unsupported. Configuration edits take effect after a server restart. + +Upgrades preserve every existing file, including comments and explicitly enabled settings. No rewards, pending votes or completion receipts are removed. If an existing file enables unsupported global behavior, startup names the first blocking setting and explains that affected votes remain pending. Review that setting and the reward limitations before changing it; disabling unsupported settings does not retry quarantined uncertain actions. No native player or administrator commands are added by this configuration change. + ## Proxy vote delivery NeoForge can receive real votes from ordinary VotingPlugin installations on BungeeCord and Velocity through the existing encrypted `SOCKETS` transport. Both proxy platforms use the same VotingPlugin proxy runtime and wire protocol. The backend durably retains a COMPLETE vote before sending its delivery acknowledgement; a duplicate stable vote ID is acknowledged idempotently and cannot create another pending occurrence or repeat an already completed vote. @@ -64,7 +72,7 @@ Current transport support is: Only the reward subset described below can complete. Votes requiring unsupported reward or post-vote semantics remain durable and observable instead of being acknowledged as fully processed and lost. -Deferred votes can now be claimed in memory and completed through one SQLite transaction that writes a completion receipt and removes the pending payload. An abandoned claim leaves the durable payload pending, while a committed transaction leaves no pending-without-receipt window. Completion receipts are bounded to 4,096 per player and 262,144 across the runtime. They are not evicted by age because no native ingress acknowledgement can yet prove that a sender has stopped retrying. If either receipt limit is full, completion stops and keeps the original pending payload. A later ingress handshake may add safe receipt release with a bounded post-release tombstone, following the existing proxy delivery pattern. A bounded replay worker now processes at most 16 retained votes per scan. It supports one existing inline `Messages.Player` or `Commands` action per vote. Player messages and console commands run on the NeoForge server tick lane; SQLite scans and completion writes remain on the replay worker. The worker validates the entire reward tree before running any action. A vote stays pending with an observable blocked or waiting result if it requires multiple or unsupported reward actions, `AnySiteRewards`, an offline player message, vote broadcasts, vote party, streaks, milestones, monthly vote limiting, cooldown events, `CloseInventoryOnVote`, or `WaitUntilVoteDelay` processing. An ambiguous external action or completion-write result is durably quarantined and remains fenced across restart for operator reconciliation. Legacy retained rows without an accepted accounting snapshot also remain blocked instead of being recalculated with newer configuration. The packaged defaults enable some unsupported features, so administrators must explicitly disable them before retained votes can complete. Configuration changes currently take effect after a server restart. +Deferred votes can now be claimed in memory and completed through one SQLite transaction that writes a completion receipt and removes the pending payload. An abandoned claim leaves the durable payload pending, while a committed transaction leaves no pending-without-receipt window. Completion receipts are bounded to 4,096 per player and 262,144 across the runtime. They are not evicted by age because no native ingress acknowledgement can yet prove that a sender has stopped retrying. If either receipt limit is full, completion stops and keeps the original pending payload. A later ingress handshake may add safe receipt release with a bounded post-release tombstone, following the existing proxy delivery pattern. A bounded replay worker now processes at most 16 retained votes per scan. It supports one existing inline `Messages.Player` or `Commands` action per vote. Player messages and console commands run on the NeoForge server tick lane; SQLite scans and completion writes remain on the replay worker. The worker validates the entire reward tree before running any action. A vote stays pending with an observable blocked or waiting result if it requires multiple or unsupported reward actions, `AnySiteRewards`, an offline player message, vote broadcasts, vote party, streaks, milestones, monthly vote limiting, cooldown events, `CloseInventoryOnVote`, or `WaitUntilVoteDelay` processing. An ambiguous external action or completion-write result is durably quarantined and remains fenced across restart for operator reconciliation. Legacy retained rows without an accepted accounting snapshot also remain blocked instead of being recalculated with newer configuration. Fresh NeoForge files disable unsupported global behavior and special rewards. Existing files are never rewritten; their configured unsupported behavior continues to keep affected votes pending. Configuration changes currently take effect after a server restart. Before a supported external action is dispatched, replay durably fences the pending occurrence. After the action succeeds, accounting, the completion receipt, and pending removal commit in one SQLite transaction. A completed vote ID remains fenced across restart and cannot rerun accounting. If the JVM or completion write fails after the pre-dispatch fence, automatic replay stays stopped for operator reconciliation, so it cannot blindly repeat a command or message. A crash between writing that fence and executing the action is indistinguishable from a crash immediately after execution and can therefore leave an action omitted unless an operator retries it; a manual retry after an uncertain outcome can instead duplicate it. The current reward APIs cannot make a Minecraft command and SQLite commit atomic, so this version does not claim exactly-once external side effects. From de59e7486d14b699298287cb7eb2dab28b19b020 Mon Sep 17 00:00:00 2001 From: BenCodez <17074231+BenCodez@users.noreply.github.com> Date: Wed, 18 Nov 2026 00:52:05 +0000 Subject: [PATCH 2/6] Reuse shared configuration and keep offline rewards waiting by default --- .../NeoForgeConfigurationDefaults.java | 49 ++++++++++ .../neoforge/NeoForgeRuntime.java | 12 ++- .../src/main/resources/neoforge/Config.yml | 23 ----- .../resources/neoforge/SpecialRewards.yml | 16 ---- .../src/main/resources/neoforge/VoteSites.yml | 17 ---- .../NeoForgeFirstRunConfigurationTest.java | 89 +++++++++++++++++++ .../tests/packaging/PackagedArtifactTest.java | 2 +- docs/neoforge-bootstrap.md | 6 +- 8 files changed, 147 insertions(+), 67 deletions(-) create mode 100644 VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeConfigurationDefaults.java delete mode 100644 VotingPlugin/src/main/resources/neoforge/Config.yml delete mode 100644 VotingPlugin/src/main/resources/neoforge/SpecialRewards.yml delete mode 100644 VotingPlugin/src/main/resources/neoforge/VoteSites.yml diff --git a/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeConfigurationDefaults.java b/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeConfigurationDefaults.java new file mode 100644 index 0000000000..5843462743 --- /dev/null +++ b/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeConfigurationDefaults.java @@ -0,0 +1,49 @@ +package com.bencodez.votingplugin.neoforge; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; +import java.nio.charset.StandardCharsets; +import java.util.List; + +import org.spongepowered.configurate.yaml.YamlConfigurationLoader; + +/** Derives missing-file defaults from the shared Bukkit templates, not a second schema. */ +final class NeoForgeConfigurationDefaults { + private NeoForgeConfigurationDefaults() { } + + static byte[] fromShared(String name, byte[] template) throws IOException { + if (!List.of("Config.yml", "VoteSites.yml", "SpecialRewards.yml").contains(name)) return template; + var node = YamlConfigurationLoader.builder().source(() -> new BufferedReader( + new StringReader(new String(template, StandardCharsets.UTF_8)))).build().load(); + switch (name) { + case "Config.yml" -> { + for (String key : List.of("CloseInventoryOnVote", "UseVoteStreaks", "PerSiteCoolDownEvents", + "LimitMonthlyVotes")) node.node(key).set(false); + node.node("OfflineVotesLimit", "Enabled").set(false); + node.node("VoteBroadcast", "Type").set("NONE"); + } + case "SpecialRewards.yml" -> { + node.node("VoteParty", "Enabled").set(false); + for (String key : List.of("AnySiteRewards", "VoteCoolDownEndedReward", "VoteMilestones", + "VoteStreaks", "VoteStreak", "Cumulative", "MileStones", "FirstVote", + "FirstVoteToday", "AllSites", "AlmostAllSites")) node.node(key).set(java.util.Map.of()); + } + case "VoteSites.yml" -> { + // The shared examples combine unsupported actions. Keep their site settings, + // but offer only one supported action, without opting into offline execution. + for (var site : node.node("VoteSites").childrenMap().values()) { + site.node("ForceOffline").set(false); + site.node("GiveOffline").set(false); + site.node("Rewards").set(java.util.Map.of("Commands", List.of("say %player% voted"))); + } + } + default -> throw new IllegalStateException("Unexpected default template"); + } + StringWriter rendered = new StringWriter(); + YamlConfigurationLoader.builder().sink(() -> new BufferedWriter(rendered)).build().save(node); + return rendered.toString().getBytes(StandardCharsets.UTF_8); + } +} diff --git a/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeRuntime.java b/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeRuntime.java index baa276843e..ef35a12e9f 100644 --- a/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeRuntime.java +++ b/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeRuntime.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.io.InputStream; +import java.io.ByteArrayInputStream; import java.nio.file.FileAlreadyExistsException; import java.nio.file.Files; import java.nio.file.Path; @@ -144,14 +145,11 @@ private static List storageKeys() { private static Path installDefault(Path directory, String name) throws IOException { Path target = directory.resolve(name); if (Files.notExists(target)) { - String resourceName = switch (name) { - case "Config.yml", "VoteSites.yml", "SpecialRewards.yml" -> "neoforge/" + name; - default -> name; - }; - try (InputStream resource = NeoForgeRuntime.class.getClassLoader().getResourceAsStream(resourceName)) { - if (resource == null) throw new IOException("Missing packaged configuration: " + resourceName); + try (InputStream resource = NeoForgeRuntime.class.getClassLoader().getResourceAsStream(name)) { + if (resource == null) throw new IOException("Missing packaged configuration: " + name); + byte[] initial = NeoForgeConfigurationDefaults.fromShared(name, resource.readAllBytes()); try { - Files.copy(resource, target); + Files.copy(new ByteArrayInputStream(initial), target); } catch (FileAlreadyExistsException ignored) { // Another bootstrap installed the same file; load the installed file below. } diff --git a/VotingPlugin/src/main/resources/neoforge/Config.yml b/VotingPlugin/src/main/resources/neoforge/Config.yml deleted file mode 100644 index 537051ae29..0000000000 --- a/VotingPlugin/src/main/resources/neoforge/Config.yml +++ /dev/null @@ -1,23 +0,0 @@ -# NeoForge first-run settings for Minecraft 1.21.1 / Java 21. -# Existing files are never replaced. Changes take effect after a server restart. -# See docs/neoforge-bootstrap.md for proxy authentication and reward limitations. -DataStorage: SQLITE -AllowUnjoined: false -AllowUnJoinedCheckServer: true -AddTotals: true -AddTotalsOffline: true -CountFakeVotes: true -ProcessRewards: true -PointsOnVote: 1 -LimitVotePoints: -1 - -# These Bukkit features are not supported by NeoForge reward replay. -# Enabling them retains affected votes instead of silently omitting their effects. -CloseInventoryOnVote: false -UseVoteStreaks: false -PerSiteCoolDownEvents: false -LimitMonthlyVotes: false -OfflineVotesLimit: - Enabled: false -VoteBroadcast: - Type: NONE diff --git a/VotingPlugin/src/main/resources/neoforge/SpecialRewards.yml b/VotingPlugin/src/main/resources/neoforge/SpecialRewards.yml deleted file mode 100644 index 5df36c0bc4..0000000000 --- a/VotingPlugin/src/main/resources/neoforge/SpecialRewards.yml +++ /dev/null @@ -1,16 +0,0 @@ -# NeoForge does not yet execute special reward trees. -# Leave these empty/disabled to permit the supported per-site reward to complete. -# Existing installations keep their configured rewards and pending votes. -VoteParty: - Enabled: false -AnySiteRewards: {} -VoteCoolDownEndedReward: {} -VoteMilestones: {} -VoteStreaks: {} -VoteStreak: {} -Cumulative: {} -MileStones: {} -FirstVote: {} -FirstVoteToday: {} -AllSites: {} -AlmostAllSites: {} diff --git a/VotingPlugin/src/main/resources/neoforge/VoteSites.yml b/VotingPlugin/src/main/resources/neoforge/VoteSites.yml deleted file mode 100644 index db38353cb7..0000000000 --- a/VotingPlugin/src/main/resources/neoforge/VoteSites.yml +++ /dev/null @@ -1,17 +0,0 @@ -# Configure ServiceSite to match your proxy vote service, then enable the site. -# NeoForge supports ONE plain player message OR console command per vote. -# Do not combine actions, Bukkit formatting, items or special reward trees. -VoteSites: - ExampleVoteSite: - Enabled: false - Name: ExampleVoteSite - ServiceSite: PlanetMinecraft.com - VoteURL: https://example.org/vote - VoteDelay: 24h - WaitUntilVoteDelay: false - # This console command can run while the player is offline. - GiveOffline: true - Rewards: - Commands: - - 'say %player% voted on %SiteName%' -EverySiteReward: {} diff --git a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java index 5d2fc52b0d..16cdea0ed6 100644 --- a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java +++ b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java @@ -30,6 +30,8 @@ void freshConfigurationCanCompleteOneSupportedRewardAcrossRestart() throws Excep assertFalse(runtime.config().node("UseVoteStreaks").getBoolean(true)); assertEquals("NONE", runtime.config().node("VoteBroadcast", "Type").getString()); assertTrue(runtime.voteConfiguration().voteSites().stream().noneMatch(NeoForgeVoteSite::enabled)); + assertTrue(runtime.voteConfiguration().voteSites().stream().noneMatch(NeoForgeVoteSite::giveOfflineRewards)); + assertFalse(runtime.voteSites().node("VoteSites", "ExampleVoteSite", "GiveOffline").getBoolean(true)); } Path sitesFile = directory.resolve("VoteSites.yml"); var loader = YamlConfigurationLoader.builder().path(sitesFile).build(); @@ -45,6 +47,19 @@ void freshConfigurationCanCompleteOneSupportedRewardAcrossRestart() throws Excep true, true, true, NeoForgeVoteRequest.Scope.COMPLETE)).status()); assertEquals(vote, runtime.deferredVotes().pending(player).get(0).voteId()); } + try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(directory); + NeoForgeRewardReplayService replay = NeoForgeRewardReplayServiceAccess.create( + runtime.voteConfiguration(), new NeoForgeRewardConfigurationAccess(runtime.config(), + runtime.voteSites(), runtime.specialRewards()), runtime.accounting(), + runtime.deferredVotes(), runtime.players(), (occurrence, plan) -> { + fail("The default console reward must wait while the player is offline"); + return CompletableFuture.completedFuture(null); + })) { + assertEquals(NeoForgeRewardReplayService.Status.WAITING_FOR_PLAYER, + replay.replayOnce().get(5, TimeUnit.SECONDS).get(0).status()); + assertEquals(vote, runtime.deferredVotes().pending(player).get(0).voteId()); + assertEquals(0, runtime.accounting().load(player).map(NeoForgeVoteAccount::allTimeTotal).orElse(0)); + } AtomicInteger actions = new AtomicInteger(); try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(directory); NeoForgeRewardReplayService replay = NeoForgeRewardReplayServiceAccess.create( @@ -57,6 +72,7 @@ void freshConfigurationCanCompleteOneSupportedRewardAcrossRestart() throws Excep actions.incrementAndGet(); return CompletableFuture.completedFuture(null); })) { + NeoForgePlayerDirectoryAccess.joined(runtime.players(), new SharedVoteIdentity(player, "Alex", true)); assertEquals(NeoForgeRewardReplayService.Status.COMPLETED, replay.replayOnce().get(5, TimeUnit.SECONDS).get(0).status()); assertEquals(1, actions.get()); @@ -161,4 +177,77 @@ void sharedBukkitResourcesKeepTheirEstablishedDefaults() throws Exception { assertEquals("EVERY_VOTE", config.node("VoteBroadcast", "Type").getString()); assertTrue(rewards.node("VoteMilestones", "FirstVoteAllTime", "Enabled").getBoolean()); } + + @Test + void freshFilesReuseSupportedSharedTemplateValues() throws Exception { + Path sharedFile = directory.resolve("shared.yml"); + try (var resource = getClass().getClassLoader().getResourceAsStream("Config.yml")) { + Files.copy(resource, sharedFile); + } + var shared = YamlConfigurationLoader.builder().path(sharedFile).build().load(); + var overridden = java.util.Set.of("CloseInventoryOnVote", "UseVoteStreaks", "PerSiteCoolDownEvents", + "LimitMonthlyVotes", "OfflineVotesLimit", "VoteBroadcast"); + try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(directory)) { + for (var entry : shared.childrenMap().entrySet()) { + if (!overridden.contains(String.valueOf(entry.getKey()))) { + assertEquals(entry.getValue().raw(), runtime.config().node(entry.getKey()).raw(), + "Shared supported setting: " + entry.getKey()); + } + } + assertEquals(shared.node("OfflineVotesLimit", "Amount").raw(), + runtime.config().node("OfflineVotesLimit", "Amount").raw()); + assertEquals(shared.node("VoteBroadcast", "Format").raw(), + runtime.config().node("VoteBroadcast", "Format").raw()); + } + } + + @Test + void copiedBukkitFilesAndExplicitOfflineChoicesArePreserved() throws Exception { + for (String name : List.of("Config.yml", "VoteSites.yml", "SpecialRewards.yml")) { + try (var resource = getClass().getClassLoader().getResourceAsStream(name)) { + Files.copy(resource, directory.resolve(name)); + } + } + Path sitesFile = directory.resolve("VoteSites.yml"); + var loader = YamlConfigurationLoader.builder().path(sitesFile).build(); + var sites = loader.load(); + sites.node("VoteSites", "ExampleVoteSite", "ForceOffline").set(true); + sites.node("VoteSites", "ExampleVoteSite", "GiveOffline").set(false); + loader.save(sites); + var originals = new java.util.HashMap(); + for (String name : List.of("Config.yml", "VoteSites.yml", "SpecialRewards.yml")) { + originals.put(name, Files.readString(directory.resolve(name))); + } + for (int restart = 0; restart < 2; restart++) { + try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(directory)) { + var site = runtime.voteConfiguration().voteSites().stream() + .filter(value -> value.key().equals("ExampleVoteSite")).findFirst().orElseThrow(); + assertTrue(site.giveOfflineRewards(), "Explicit canonical key takes precedence over legacy alias"); + for (var entry : originals.entrySet()) { + assertEquals(entry.getValue(), Files.readString(directory.resolve(entry.getKey()))); + } + } + } + } + + @Test + void omittedOfflineKeysDefaultFalseAndLegacyAliasMatchesBukkitPrecedence() throws Exception { + String[] options = { "", " GiveOffline: false\n", " GiveOffline: true\n", + " GiveOffline: true\n ForceOffline: false\n", + " GiveOffline: false\n ForceOffline: true\n" }; + boolean[] expected = { false, false, true, false, true }; + for (int i = 0; i < options.length; i++) { + Path installation = directory.resolve("case" + i); + Files.createDirectories(installation); + String yaml = "VoteSites:\n ExampleVoteSite:\n Enabled: true\n ServiceSite: PlanetMinecraft.com\n" + + options[i]; + Files.writeString(installation.resolve("VoteSites.yml"), yaml); + try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(installation)) { + var site = runtime.voteConfiguration().resolveEnabledSite("PlanetMinecraft.com").orElseThrow(); + assertEquals(expected[i], site.giveOfflineRewards()); + assertEquals(expected[i], runtime.voteConfiguration().policyFor(site).giveOfflineRewards()); + } + assertEquals(yaml, Files.readString(installation.resolve("VoteSites.yml"))); + } + } } diff --git a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/packaging/PackagedArtifactTest.java b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/packaging/PackagedArtifactTest.java index 02eda6d6b2..f0eb656a37 100644 --- a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/packaging/PackagedArtifactTest.java +++ b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/packaging/PackagedArtifactTest.java @@ -34,7 +34,7 @@ void containsOneRelocatedRuntimeWithoutUnusedHttpCrypto() throws Exception { assertNotNull(artifact.getEntry("plugin.yml")); assertNotNull(artifact.getEntry("META-INF/neoforge.mods.toml")); for (String name : java.util.List.of("Config.yml", "VoteSites.yml", "SpecialRewards.yml")) { - assertNotNull(artifact.getEntry("neoforge/" + name)); + assertNotNull(artifact.getEntry(name)); } String modMetadata = new String(artifact.getInputStream( artifact.getEntry("META-INF/neoforge.mods.toml")).readAllBytes(), StandardCharsets.UTF_8); diff --git a/docs/neoforge-bootstrap.md b/docs/neoforge-bootstrap.md index ffc944bd04..1b1a924016 100644 --- a/docs/neoforge-bootstrap.md +++ b/docs/neoforge-bootstrap.md @@ -2,7 +2,7 @@ The single `VotingPlugin.jar` contains an experimental NeoForge 21.1 entry point for Minecraft 1.21.1. Native vote ingress remains disabled. Bukkit and proxy behavior remains on its existing paths. -On server start, the entry point creates `config/votingplugin/`, installs NeoForge-specific `Config.yml`, `VoteSites.yml`, and `SpecialRewards.yml` only when each file is missing, reads them, and opens the existing AdvancedCore SQLite user backend in `VotingPlugin.db`. The bootstrap currently accepts `DataStorage: SQLITE` only. Its separate `VotingPlugin_NeoForgeUsers` table stores the player name, all-time/monthly/daily/weekly totals, points, and per-site last-vote timestamps needed by the shared accounting step. Existing UUID-only bootstrap tables are extended in place. The accounting adapter is a storage foundation and is not wired to live vote ingress. The runtime closes the backend and clears queued tasks and online player identities on server stop. +On server start, the entry point creates `config/votingplugin/`, installs `Config.yml`, `VoteSites.yml`, and `SpecialRewards.yml` from the shared Bukkit templates only when each file is missing, reads them, and opens the existing AdvancedCore SQLite user backend in `VotingPlugin.db`. The bootstrap currently accepts `DataStorage: SQLITE` only. Its separate `VotingPlugin_NeoForgeUsers` table stores the player name, all-time/monthly/daily/weekly totals, points, and per-site last-vote timestamps needed by the shared accounting step. Existing UUID-only bootstrap tables are extended in place. The accounting adapter is a storage foundation and is not wired to live vote ingress. The runtime closes the backend and clears queued tasks and online player identities on server stop. The NeoForge bridge tracks login/logout identity and runs submitted bootstrap tasks on server ticks. Player identity access uses reflection because NeoForge's published universal Maven JAR does not include Minecraft classes on Maven's compile path; these method names were checked against the installed 1.21.1 server JAR. @@ -12,9 +12,9 @@ Native Votifier ingress remains disabled. VotifierPlus's hardened packet handlin ## First-run configuration -A new NeoForge installation receives its own starter files. Bukkit and proxy defaults are unchanged. The starter disables inventory closing, streaks, local vote broadcasts, cooldown events, monthly vote limits, offline vote limits and special reward trees. Its example site starts disabled and contains one plain console command, which can run while the player is offline. Configure its `ServiceSite` to match the vote service, replace the example URL, and enable the site. Configure authenticated proxy delivery as described below; installation alone does not enable a listener. +A new NeoForge installation uses the same file names, keys and shared templates as Bukkit. Supported settings keep their shared values and parsing; only unsupported fresh-install behavior and example reward trees are adjusted. Bukkit and proxy defaults are unchanged. The starter disables inventory closing, streaks, local vote broadcasts, cooldown events, monthly vote limits, offline vote limits and special reward trees. The shared example sites remain disabled and contain one plain console command instead of a multi-action reward tree. Site-level `ForceOffline` and its legacy `GiveOffline` alias are explicitly `false`; an offline console reward remains pending until the player joins. Configure its `ServiceSite` to match the vote service, replace the example URL, and enable the site. Configure authenticated proxy delivery as described below; installation alone does not enable a listener. -Keep `DataStorage: SQLITE`. Use at most one plain `Commands` action or one plain `Messages.Player` action per vote across the site and `EverySiteReward`. A player message waits for the player to be online. Bukkit formatting, item rewards and multiple actions remain unsupported. Configuration edits take effect after a server restart. +Keep `DataStorage: SQLITE`. Use at most one plain `Commands` action or one plain `Messages.Player` action per vote across the site and `EverySiteReward`. A player message always waits for the player to be online. As on Bukkit, site-level `ForceOffline` takes precedence over legacy `GiveOffline`, and omitting both defaults to `false`. An explicit administrator opt-in is preserved. These site settings are distinct from similarly named reward-level settings; no reward-level execution support is added here. Bukkit formatting, item rewards and multiple actions remain unsupported. Configuration edits take effect after a server restart. Upgrades preserve every existing file, including comments and explicitly enabled settings. No rewards, pending votes or completion receipts are removed. If an existing file enables unsupported global behavior, startup names the first blocking setting and explains that affected votes remain pending. Review that setting and the reward limitations before changing it; disabling unsupported settings does not retry quarantined uncertain actions. No native player or administrator commands are added by this configuration change. From 3103f7f33c53bf4b51541adf3bac8b9b6d9366fa Mon Sep 17 00:00:00 2001 From: BenCodez <17074231+BenCodez@users.noreply.github.com> Date: Wed, 18 Nov 2026 01:27:31 +0000 Subject: [PATCH 3/6] Preserve supported shared commands in NeoForge starter defaults --- .../neoforge/NeoForgeConfigurationDefaults.java | 4 +++- .../NeoForgeFirstRunConfigurationTest.java | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeConfigurationDefaults.java b/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeConfigurationDefaults.java index 5843462743..269d338292 100644 --- a/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeConfigurationDefaults.java +++ b/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeConfigurationDefaults.java @@ -37,7 +37,9 @@ static byte[] fromShared(String name, byte[] template) throws IOException { for (var site : node.node("VoteSites").childrenMap().values()) { site.node("ForceOffline").set(false); site.node("GiveOffline").set(false); - site.node("Rewards").set(java.util.Map.of("Commands", List.of("say %player% voted"))); + var commands = site.node("Rewards", "Commands").copy(); + site.node("Rewards").set(java.util.Map.of()); + site.node("Rewards", "Commands").set(commands); } } default -> throw new IllegalStateException("Unexpected default template"); diff --git a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java index 16cdea0ed6..e2fcdfda3c 100644 --- a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java +++ b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java @@ -185,6 +185,11 @@ void freshFilesReuseSupportedSharedTemplateValues() throws Exception { Files.copy(resource, sharedFile); } var shared = YamlConfigurationLoader.builder().path(sharedFile).build().load(); + Path sharedSitesFile = directory.resolve("shared-sites.yml"); + try (var resource = getClass().getClassLoader().getResourceAsStream("VoteSites.yml")) { + Files.copy(resource, sharedSitesFile); + } + var sharedSites = YamlConfigurationLoader.builder().path(sharedSitesFile).build().load(); var overridden = java.util.Set.of("CloseInventoryOnVote", "UseVoteStreaks", "PerSiteCoolDownEvents", "LimitMonthlyVotes", "OfflineVotesLimit", "VoteBroadcast"); try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(directory)) { @@ -198,6 +203,18 @@ void freshFilesReuseSupportedSharedTemplateValues() throws Exception { runtime.config().node("OfflineVotesLimit", "Amount").raw()); assertEquals(shared.node("VoteBroadcast", "Format").raw(), runtime.config().node("VoteBroadcast", "Format").raw()); + for (var entry : sharedSites.node("VoteSites").childrenMap().entrySet()) { + var actual = runtime.voteSites().node("VoteSites", entry.getKey()); + assertEquals(entry.getValue().node("Rewards", "Commands").raw(), + actual.node("Rewards", "Commands").raw(), "Preserve supported shared commands"); + assertEquals(java.util.Set.of("Commands"), actual.node("Rewards").childrenMap().keySet()); + for (var field : entry.getValue().childrenMap().entrySet()) { + if (!java.util.Set.of("Rewards", "ForceOffline", "GiveOffline").contains(field.getKey())) { + assertEquals(field.getValue().raw(), actual.node(field.getKey()).raw(), + "Preserve shared site field: " + field.getKey()); + } + } + } } } From ac9e8a375baaf2da2e861f780c378d3b9123d826 Mon Sep 17 00:00:00 2001 From: BenCodez <17074231+BenCodez@users.noreply.github.com> Date: Wed, 18 Nov 2026 02:27:17 +0000 Subject: [PATCH 4/6] Disable unsupported monthly awards in fresh NeoForge defaults --- .../neoforge/NeoForgeConfigurationDefaults.java | 1 + .../tests/neoforge/NeoForgeFirstRunConfigurationTest.java | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeConfigurationDefaults.java b/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeConfigurationDefaults.java index 269d338292..380b9cbe71 100644 --- a/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeConfigurationDefaults.java +++ b/VotingPlugin/src/main/java/com/bencodez/votingplugin/neoforge/NeoForgeConfigurationDefaults.java @@ -27,6 +27,7 @@ static byte[] fromShared(String name, byte[] template) throws IOException { } case "SpecialRewards.yml" -> { node.node("VoteParty", "Enabled").set(false); + node.node("EnableMonthlyAwards").set(false); for (String key : List.of("AnySiteRewards", "VoteCoolDownEndedReward", "VoteMilestones", "VoteStreaks", "VoteStreak", "Cumulative", "MileStones", "FirstVote", "FirstVoteToday", "AllSites", "AlmostAllSites")) node.node(key).set(java.util.Map.of()); diff --git a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java index e2fcdfda3c..5006d83400 100644 --- a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java +++ b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/neoforge/NeoForgeFirstRunConfigurationTest.java @@ -28,6 +28,7 @@ void freshConfigurationCanCompleteOneSupportedRewardAcrossRestart() throws Excep try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(directory)) { assertFalse(runtime.config().node("CloseInventoryOnVote").getBoolean(true)); assertFalse(runtime.config().node("UseVoteStreaks").getBoolean(true)); + assertFalse(runtime.specialRewards().node("EnableMonthlyAwards").getBoolean(true)); assertEquals("NONE", runtime.config().node("VoteBroadcast", "Type").getString()); assertTrue(runtime.voteConfiguration().voteSites().stream().noneMatch(NeoForgeVoteSite::enabled)); assertTrue(runtime.voteConfiguration().voteSites().stream().noneMatch(NeoForgeVoteSite::giveOfflineRewards)); @@ -93,7 +94,8 @@ void preservesEveryExistingFileByteForByteAndStillBlocksUnsupportedSettings() th String config = "# Operator configuration\nDataStorage: SQLITE\nCloseInventoryOnVote: true\n"; Files.writeString(directory.resolve("Config.yml"), config); Files.writeString(directory.resolve("VoteSites.yml"), "# Existing sites\nVoteSites: {}\n"); - Files.writeString(directory.resolve("SpecialRewards.yml"), "# Existing rewards\nFirstVote: {}\n"); + Files.writeString(directory.resolve("SpecialRewards.yml"), + "# Existing rewards\nEnableMonthlyAwards: true\nFirstVote: {}\n"); List files = List.of(directory.resolve("Config.yml"), directory.resolve("VoteSites.yml"), directory.resolve("SpecialRewards.yml")); List before = files.stream().map(path -> { @@ -103,6 +105,7 @@ void preservesEveryExistingFileByteForByteAndStillBlocksUnsupportedSettings() th try (NeoForgeRuntime runtime = NeoForgeRuntimeAccess.start(directory)) { assertTrue(runtime.config().node("CloseInventoryOnVote").getBoolean()); assertTrue(runtime.specialRewards().node("VoteMilestones").virtual()); + assertTrue(runtime.specialRewards().node("EnableMonthlyAwards").getBoolean()); } } for (int i = 0; i < files.size(); i++) assertEquals(before.get(i), Files.readString(files.get(i))); @@ -176,6 +179,7 @@ void sharedBukkitResourcesKeepTheirEstablishedDefaults() throws Exception { assertTrue(config.node("UseVoteStreaks").getBoolean()); assertEquals("EVERY_VOTE", config.node("VoteBroadcast", "Type").getString()); assertTrue(rewards.node("VoteMilestones", "FirstVoteAllTime", "Enabled").getBoolean()); + assertTrue(rewards.node("EnableMonthlyAwards").getBoolean()); } @Test From 4b18495752bfd61c398acbf7eb0e44b9b00139fc Mon Sep 17 00:00:00 2001 From: BenCodez <17074231+BenCodez@users.noreply.github.com> Date: Wed, 18 Nov 2026 02:32:38 +0000 Subject: [PATCH 5/6] Clarify NeoForge monthly award and startup warning limits --- docs/neoforge-bootstrap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/neoforge-bootstrap.md b/docs/neoforge-bootstrap.md index 1b1a924016..929f83cd65 100644 --- a/docs/neoforge-bootstrap.md +++ b/docs/neoforge-bootstrap.md @@ -16,7 +16,7 @@ A new NeoForge installation uses the same file names, keys and shared templates Keep `DataStorage: SQLITE`. Use at most one plain `Commands` action or one plain `Messages.Player` action per vote across the site and `EverySiteReward`. A player message always waits for the player to be online. As on Bukkit, site-level `ForceOffline` takes precedence over legacy `GiveOffline`, and omitting both defaults to `false`. An explicit administrator opt-in is preserved. These site settings are distinct from similarly named reward-level settings; no reward-level execution support is added here. Bukkit formatting, item rewards and multiple actions remain unsupported. Configuration edits take effect after a server restart. -Upgrades preserve every existing file, including comments and explicitly enabled settings. No rewards, pending votes or completion receipts are removed. If an existing file enables unsupported global behavior, startup names the first blocking setting and explains that affected votes remain pending. Review that setting and the reward limitations before changing it; disabling unsupported settings does not retry quarantined uncertain actions. No native player or administrator commands are added by this configuration change. +Upgrades preserve every existing file, including comments and explicitly enabled settings. No rewards, pending votes or completion receipts are removed. For unsupported settings that block replay, startup names the first blocking setting and explains that affected votes remain pending. Review that setting and the reward limitations before changing it; disabling unsupported settings does not retry quarantined uncertain actions. Monthly awards are a separate unsupported feature: fresh files set `EnableMonthlyAwards: false`, but an existing `true` value is preserved and does not itself block replay or produce this warning. NeoForge does not issue monthly awards even when that existing setting is enabled. No native player or administrator commands are added by this configuration change. ## Proxy vote delivery From 5cff131b4070508a157e796f33627fe9f5866750 Mon Sep 17 00:00:00 2001 From: BenCodez <17074231+BenCodez@users.noreply.github.com> Date: Wed, 18 Nov 2026 02:39:27 +0000 Subject: [PATCH 6/6] Scope NeoForge startup diagnostics to global replay blockers --- docs/neoforge-bootstrap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/neoforge-bootstrap.md b/docs/neoforge-bootstrap.md index 929f83cd65..052772d905 100644 --- a/docs/neoforge-bootstrap.md +++ b/docs/neoforge-bootstrap.md @@ -16,7 +16,7 @@ A new NeoForge installation uses the same file names, keys and shared templates Keep `DataStorage: SQLITE`. Use at most one plain `Commands` action or one plain `Messages.Player` action per vote across the site and `EverySiteReward`. A player message always waits for the player to be online. As on Bukkit, site-level `ForceOffline` takes precedence over legacy `GiveOffline`, and omitting both defaults to `false`. An explicit administrator opt-in is preserved. These site settings are distinct from similarly named reward-level settings; no reward-level execution support is added here. Bukkit formatting, item rewards and multiple actions remain unsupported. Configuration edits take effect after a server restart. -Upgrades preserve every existing file, including comments and explicitly enabled settings. No rewards, pending votes or completion receipts are removed. For unsupported settings that block replay, startup names the first blocking setting and explains that affected votes remain pending. Review that setting and the reward limitations before changing it; disabling unsupported settings does not retry quarantined uncertain actions. Monthly awards are a separate unsupported feature: fresh files set `EnableMonthlyAwards: false`, but an existing `true` value is preserved and does not itself block replay or produce this warning. NeoForge does not issue monthly awards even when that existing setting is enabled. No native player or administrator commands are added by this configuration change. +Upgrades preserve every existing file, including comments and explicitly enabled settings. No rewards, pending votes or completion receipts are removed. Startup checks unsupported global replay settings and names the first global blocker, explaining that affected votes remain pending. This is not a complete configuration check: site-specific settings such as `WaitUntilVoteDelay` and unsupported reward actions are checked during replay and may block a retained vote without a startup warning. Review that setting and the reward limitations before changing it; disabling unsupported settings does not retry quarantined uncertain actions. Monthly awards are a separate unsupported feature: fresh files set `EnableMonthlyAwards: false`, but an existing `true` value is preserved and does not itself block replay or produce this warning. NeoForge does not issue monthly awards even when that existing setting is enabled. No native player or administrator commands are added by this configuration change. ## Proxy vote delivery