Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
MythicMobs MythicMobs
  • Project overview
    • Project overview
    • Details
    • Activity
  • Issues 140
    • Issues 140
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • MythicCraft
  • MythicMobsMythicMobs
  • Issues
  • #822

Closed
Open
Created Jun 06, 2022 by wordandahalf@wordandahalfMaintainer

WorldGuard integration may cause mob spawning to fail

Due to a misplaced null check, WorldGuard integration may cause mob spawning to fail exceptionally under certain conditions. Full stacktrace can be found here. Note that while the NPE is wrapped in a java.util.concurrent.CompletionException, it was not executed asynchronously or off the main server thread. This was encountered in updating our in-house plugins from 1.16.5 to 1.18.2, so it is possible that the issue is a regression.

(Code as of Mythic-Dist-5.1.0-20220531.222700-43, decompiled)

/* (snip) */
public boolean getLocationAllowsMobSpawning(Location l) {
    World world = BukkitAdapter.adapt(l.getWorld());
    RegionManager regionManager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(world);
    WorldConfiguration worldState = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world);
    if (!worldState.blockPluginSpawning) {
        return true;
    } else {
        ApplicableRegionSet ret = regionManager.getApplicableRegions(BlockVector3.at(l.getX(), l.getY(), l.getZ()));
               // Null check does nothing; will always fail exceptionally if regionManager
               // is null due to previous line.
        return regionManager == null || ret.testState((RegionAssociable)null, new StateFlag[]{Flags.MOB_SPAWNING});

        /*
        Replace previous two lines with
        return regionManager == null ||
               regionManager.getApplicableRegions(BlockVector3.at(l.getX(), l.getY(), l.getZ()))
                            .testState(null, new StateFlag[] { Flags.MOB_SPAWNING });
        */
    }
}
/* (snip) */

The error can be avoided by refactoring the responsible method.

Edited Jun 06, 2022 by wordandahalf
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking