Commit Graph

7072 Commits

Author SHA1 Message Date
ff2b335af4 Handle Paper world-layout migration for region data
Fixes #5290
2026-06-01 15:56:15 -07:00
ae76eed87b Stabilize database manager tests via ExperienceConfig mocking
Mock ExperienceConfig.getInstance() in FlatFileDatabaseManagerTest and SQLDatabaseManagerTest with diminished returns disabled so test setup does not depend on global singleton state.

Close static mocks in tearDown to avoid leakage across test classes.
2026-05-31 22:40:23 -07:00
30c7126986 Fix WorldBlacklist startup null-pointer path
Initialize blacklist eagerly and guard isWorldBlacklisted for null world / null-or-empty blacklist so enable/disable world loops cannot throw during early plugin lifecycle.

Add WorldBlacklistTest coverage for null blacklist field, null world, case-insensitive match, and non-match behavior.
2026-05-31 22:40:19 -07:00
73d6c49a7e Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO 2026-05-31 11:00:50 -07:00
75c6c39d20 Add option to toggle receiving conflicting enchants from magic hunter (#5282) 2026-05-31 10:58:10 -07:00
95a87afdb4 Fix traveling block metadata leaking on folia (#5294) 2026-05-31 10:57:38 -07:00
21bc081518 Fix entities keeping their health bars after unload (#5295) 2026-05-31 10:57:02 -07:00
dcf0526ac8 update changelog 2026-05-31 10:06:17 -07:00
2ec35ed0cc Fix test environment writing config files to project root
BukkitConfig calls mcMMO.p.getDataFolder() in its constructor to
determine where to write config files. When tests mock mcMMO.p but
don't stub getDataFolder(), it returns null, which Java resolves to
the current working directory (the project root), causing files like
experience.yml to be created there.

Fix by stubbing mcMMO.p.getDataFolder() with a fresh temporary
directory in every test setup that mocks mcMMO.p:
- MMOTestEnvironment.mockBaseEnvironment(): creates testDataFolder
  in temp and deletes it in cleanUpStaticMocks()
- SQLDatabaseManagerTest.setUpAll(): same pattern, cleaned in tearDownAll()
- FlatFileDatabaseManagerTest.initBeforeAll(): same pattern, cleaned
  in the new tearDownAll() method

Also remove the .gitignore band-aid entries that were added to paper
over the symptom.
2026-05-30 22:58:37 -07:00
3a69634a33 Fix pre-existing test failures and improve Docker test skip mechanism
- FishingTreasureConfig.fixMooshroomEntityId was a public static method that
  called mcMMO.p.getLogger() directly, causing NPE when tests invoked it without
  a live plugin instance. Add a private static Logger field and use it in the
  static method instead.
- TridentsTest.impaleDamageBonusShouldMatchRankOneBaseDamage had a stale expected
  value (1.0) left over from before commit 71868d9d fixed the Impale formula to
  use rank * multiplier. The correct expectation for rank 1 is
  base + 1 * multiplier = 1.5. Rename the test to match the new semantic.
- Add @Tag(docker) to FlatFileDatabaseManagerTest so the existing
  skip-docker-tests Maven profile (-DskipDockerTests=true) excludes it alongside
  SQLDatabaseManagerTest.
- Add generated config file names (experience.yml, config.yml, etc.) to
  .gitignore to prevent accidental staging when tests run without a properly
  mocked getDataFolder().
2026-05-30 21:42:30 -07:00
3fb1369444 Refactor diminished returns tracking into DiminishedReturnsCache/State
Extracts per-player DR data out of PlayerProfile into two new classes:
- DiminishedReturnsState: thread-safe XP gain queue and rolling totals
- DiminishedReturnsCache: UUID-keyed server-side cache that keeps DR
  state alive across disconnect/reconnect to prevent window bypass

Fixes a bug where evictExpired() would remove fresh states that had
never registered any XP, orphaning the PlayerProfile reference and
allowing reconnects to bypass the DR window.

DR tracking is now skipped entirely (no state mutation) when the
diminished returns config option is disabled.

Fixes #3475. Fixes #3814.
2026-05-30 21:12:30 -07:00
8e1b6deaa5 Fix melee attack strength scale after Paper fixed attack cooldown bug in 26.1.2
Paper 26.1.2 fixed a bug where the player attack cooldown ticker was not
resetting at the correct point during melee hits. mcMMO relied on the old
(incorrect) order, reading the cooldown during the damage event, which
always returned near-zero after Paper's fix. Attack strength scale is
now back-derived from the raw event damage divided by the player's
GENERIC_ATTACK_DAMAGE attribute value and clamped to [0.0, 1.0].

AttributeMapper now survives test environments where Bukkit registries
are absent (catch Throwable in the registry reflection path).

Fixes #5287.
2026-05-30 21:12:20 -07:00
71868d9d2e Fix Impale damage formula: use rank * multiplier instead of (rank - 1) * multiplier 2026-05-25 10:14:42 -07:00
c838a69e7e Rename underscore test method names to camelCase in WoodcuttingTest; clean up 2.2.053 changelog entries 2026-05-25 10:12:37 -07:00
8ff047d5a1 Fix KnockOnWood XP orbs never spawning on nether tree cap blocks during Tree Feller
Nether_Wart_Block and Warped_Wart_Block both have woodcutting XP in
experience.yml AND are in the treeFellerDestructibleWhiteList. The
drop routing in dropTreeFellerLootFromBlocks used an if/else-if
structure, so blocks with woodcutting XP always took the first branch
and never reached the else-if where the KnockOnWood orb logic lived.

Fix: extract the orb spawning block into a standalone if-check that
runs after the drop routing, so it fires for any isNonWoodPartOfTree
block regardless of whether it also has woodcutting XP.

Fixes #5288
2026-05-25 10:06:19 -07:00
e6c28b6fc8 remove dead locale keys that are not used anywhere 2026-05-14 14:31:21 -07:00
cd5cd497c2 start removing some dead code related to locale colors 2026-05-14 14:21:04 -07:00
e64cc3f44f back to snapshots (fixed lol) 2026-05-14 14:18:37 -07:00
4703746dff 2.2.052 2026-05-14 13:40:36 -07:00
4098e415e3 use correct cow name for shake
fixes #5284
2026-05-14 13:40:02 -07:00
8352b3a006 use metadata 2026-05-13 17:59:44 -07:00
47cebf2cc2 Fix excavation treasure drops broken by BlockDropItemEvent refactor
block.getType() returns AIR by the time BlockDropItemEvent fires because
the block is removed before the event is dispatched. Capture the pre-break
material from event.getBlockState().getType() and thread it through to
affectedByGigaDrillBreaker and rollAndCollectTreasureDrops so treasure
lookups use the correct material instead of AIR.
2026-05-13 17:23:29 -07:00
eaf8bffb63 Wire up Verdant Bounty triple drop passive for Herbalism 2026-05-11 18:48:38 -07:00
807b3e2999 Update Changelog.txt for block cracker whitelist fix 2026-05-11 18:24:27 -07:00
c457d3a180 Fix block cracker whitelist missing 4 crackable block types
deepslate_bricks, deepslate_tiles, polished_blackstone_bricks, and
nether_bricks were handled in blockCrackerCheck() but were absent from
fillBlockCrackerWhiteList(). The listener gates on affectedByBlockCracker()
which reads the whitelist, so those blocks could never be cracked.
2026-05-11 18:24:27 -07:00
366a512b5f Fix incorrect Tricky Trials potion durations via UpgradeManager migration
Warriorrrr's commit (fb6aebcaa) corrected the default potions.yml shipped
with the plugin (splash: 2500->3600, lingering: 3000->900), but existing
server installs still had the old incorrect values.

This adds a one-time UpgradeManager migration (FIX_TRICKY_TRIALS_SPLASH_POTION_DURATIONS)
that auto-patches existing potions.yml on first server startup after updating.
The migration only corrects exact-match bad values; user-customized durations
are intentionally left untouched. Absent potion keys are silently skipped.

- Add UpgradeType.FIX_TRICKY_TRIALS_SPLASH_POTION_DURATIONS
- Implement PotionConfig.fixTrickyTrialsPotionDurations() + patchTrickyTrialsDurations()
- Gate migration in PotionConfig.loadPotions() via shouldUpgrade()
- Add 13 unit tests covering all migration paths in PotionConfigTest
2026-05-11 12:14:15 -07:00
a79cf7d450 don't run tests redundantly during nexus deployment 2026-05-10 15:15:28 -07:00
ef6ddf0331 Bump api-version in plugin.yml from 1.13 to 1.20.5 2026-05-08 13:11:22 -07:00
11225a2f55 Fix Minecraft version detection failing on Spigot servers
The old regex required a trailing [-_] after the version digits, which worked
for getBukkitVersion() strings (e.g. '1.21.4-R0.1-SNAPSHOT') but silently
failed on Spigot's Bukkit.getVersion() format ('git-Spigot-12345-abcdef
(MC: 1.21.4)') since '1.21.4)' has no trailing dash or underscore. Version
resolved to 0.0.0, causing Tricky Trials potions (isAtLeast 1.21.0 check)
to be incorrectly skipped on every Spigot server.

MinecraftGameVersionFactory now uses two patterns:
- Primary: extracts from the '(MC: X.Y.Z)' segment that CraftBukkit always
  embeds in Bukkit.getVersion() — handles Spigot, old Paper, and Paper 26+
- Fallback: original regex for strings without '(MC: ...)' such as
  getBukkitVersion()-style strings

Tests updated with @Nested classes covering both paths, including explicit
Spigot format cases and Paper 26+ versioning (26.1.2-60-b4682bf format).
2026-05-07 20:01:38 -07:00
ce021dbe12 Fix Woodcutting/Excavation bonus drops bypassing BlockDropItemEvent
Woodcutting (Harvest Lumber, Clean Cuts) and Excavation treasure drops
previously spawned items directly via world.dropItem(), bypassing
BlockDropItemEvent entirely. This made them invisible to Telekinesis-style
enchant plugins (ExcellentEnchants, EcoEnchants, etc.).

Woodcutting fix: processBonusDropCheck() now calls BlockUtils.markDropsAsBonus()
for normal breaks, routing bonus drops through the existing BlockDropItemEvent
metadata pipeline. Tree Feller retains the direct-spawn path since it sets
blocks to AIR without firing BlockDropItemEvent.

Excavation fix: treasure rolls are now performed inside onBlockDropItemEvent()
via ExcavationManager.rollAndCollectTreasureDrops(). The returned ItemStacks
are spawned and injected into event.getItems(), exposing them to the full
Bukkit event pipeline. GigaDrillBreaker's 3x roll count is preserved. The
old processExcavationBonusesOnBlock(treasure, location) path is kept as a
deprecated fallback for external API callers.
2026-05-07 19:21:32 -07:00
397d6de36c Add -DskipDockerTests=true flag to skip Testcontainers SQL tests 2026-05-06 18:46:02 -07:00
b32c64b5ac Reorder changelog entry for URL bar removal 2026-05-06 18:43:27 -07:00
d4da897a34 Remove Patreon and language links from URL bar 2026-05-06 18:39:03 -07:00
1c88d3619f Add color support for JSON components
Fixes #5179 Fixes #5218
2026-05-06 18:34:02 -07:00
451ec158a5 Add missing key for graceful roll and some unit test coverage 2026-05-03 21:04:14 -07:00
dbae9c6bb8 Fixed a bunch of mob health display bugs
Fixes #5240 Fixes #5127 Fixes #3780 Fixes #5255
2026-05-03 18:18:01 -07:00
bd7ac8c655 fix smelting config bug Fixes #5140 2026-05-03 15:26:35 -07:00
22b044ce06 avoid visual desync for salvage Fixes #5252 2026-05-03 15:03:01 -07:00
bff2e079e8 update changelog 2026-05-03 13:23:20 -07:00
8f411f901c Update Simplfied Chinese translation (#5274) 2026-05-03 13:17:21 -07:00
fb6aebcaae Fix potion lengths being shorter/longer for newer potion types (#5277) 2026-05-02 17:48:58 -07:00
f6cc7c5a5e Fishing updated to work with offhand and not just main hand only
May address #5226
2026-04-28 13:54:55 -07:00
8602f4797e Use modern APIs for durability handling
May address #5167
2026-04-28 13:21:15 -07:00
cc70269cad update changelog 2026-04-28 13:18:03 -07:00
98ea089a3e fix WG crossbow interaction Fixes #5074 2026-04-27 21:11:51 -07:00
e070d527ae use official API for crossbow detection instead of our metadata 2026-04-27 16:13:21 -07:00
a5236446b4 Change mcMMO behavior around immature crop drops Fixes #5234 2026-04-27 15:59:51 -07:00
e51d72e5fd Fix bug with replanting Fixes #5253 2026-04-27 14:43:02 -07:00
6cb8daf254 Add more granular control for enchantments Fixes #5245 2026-04-27 13:51:29 -07:00
91d01c7e9e Expand config surface for newer skills Fixes #5275 2026-04-26 13:52:19 -07:00