Skip to content

feat: per-gamemode mob spawn replacement rules#19

Merged
tastybento merged 3 commits into
developfrom
copilot/add-config-for-gamemode
May 30, 2026
Merged

feat: per-gamemode mob spawn replacement rules#19
tastybento merged 3 commits into
developfrom
copilot/add-config-for-gamemode

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 30, 2026

ExtraMobs previously applied one set of global spawn chances uniformly across every BentoBox GameMode. This adds a gamemode-settings config block that lets admins define per-gamemode, per-environment replacement rules that override the global defaults.

Changes

  • config/MobSpawnReplacement.java (new) — POJO for a single replacement rule (old, new, chance); resolves string names to EntityType at runtime so the YAML layer stays Map-based.

  • config/Settings.java — adds Map<String, Object> gamemodeSettings at path gamemode-settings; getReplacements(gameModeName, environment) parses the raw YAML structure into typed MobSpawnReplacement lists, never returning null.

  • listeners/MobsSpawnListener.java — each environment branch (nether/end/world) calls applyGameModeReplacements() before the global-chance fallback. When per-gamemode rules match, global defaults are skipped for that event.

  • config.yml — adds gamemode-settings: {} with inline documentation and a worked example.

Example config

gamemode-settings:
  BSkyBlock:
    nether:
      - old: ZOMBIFIED_PIGLIN
        new: WITHER_SKELETON
        chance: 0.05
      - old: ZOMBIFIED_PIGLIN
        new: BLAZE
        chance: 0.10
    end:
      - old: ENDERMAN
        new: SHULKER
        chance: 0.30
  AcidIsland:
    end:
      - old: ENDERMAN
        new: SHULKER
        chance: 0.50

Fully backward-compatible — omitting gamemode-settings (or leaving it empty) preserves existing global behaviour unchanged.

Copilot AI linked an issue May 30, 2026 that may be closed by this pull request
2 tasks
Copilot AI added 2 commits May 30, 2026 01:17
- New config/MobSpawnReplacement.java: POJO for a single mob
  replacement rule (old EntityType name, new EntityType name, chance).
  Provides resolveOldEntityType() / resolveNewEntityType() helpers.

- Settings.java: add Map<String, Object> gamemodeSettings field at path
  "gamemode-settings" with full @ConfigComment documentation.
  Add getGamemodeSettings() / setGamemodeSettings() pair.
  Add getReplacements(gameModeName, environment) which parses the raw
  YAML map structure into typed MobSpawnReplacement lists; returns
  List.of() (never null) when no overrides are configured.

- MobsSpawnListener.java: extract applyGameModeReplacements() helper
  that checks per-gamemode rules before each global-fallback branch
  (nether, end, world). When per-gamemode rules fire, global settings
  are skipped for that event.

- config.yml: document new gamemode-settings section with commented
  multi-gamemode example (BSkyBlock, AcidIsland).

- ExtraMobsAddonTest.java: include gamemode-settings: {} in config
  constant; add testGamemodeSettingsEmptyByDefault and
  testGetReplacementsEmptyWhenNoPerGamemodeConfig tests.

- MobsSpawnListenerTest.java: default-stub getReplacements() to
  Collections.emptyList(); add 9 new tests covering per-gamemode
  nether/end/world paths, fallback on entity mismatch / chance=0,
  invalid mob name skipping, and Settings.getReplacements() unit tests.
- Settings.java: remove redundant field initializer on gamemodeSettings;
  setter null-guard and getReplacements() null-check are sufficient.
- MobsSpawnListenerTest.java: add comment explaining why HashMap.put()
  is required instead of Map.of() for the raw gamemode-settings test.
Copilot AI changed the title [WIP] Add configuration file for gamemode versions feat: per-gamemode mob spawn replacement rules May 30, 2026
Copilot AI requested a review from tastybento May 30, 2026 01:20
@tastybento tastybento marked this pull request as ready for review May 30, 2026 01:26
@sonarqubecloud
Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@tastybento tastybento merged commit efe39b8 into develop May 30, 2026
1 check failed
@tastybento tastybento deleted the copilot/add-config-for-gamemode branch May 30, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add | up | edit

2 participants