bloodmc / GriefDefender

Defend your servers from grief.
https://www.spigotmc.org/resources/griefdefender.68900/
MIT License
110 stars 96 forks source link

[BLOCKING] Claims failing to fully load with specific API usages #273

Open Sir-Will opened 4 years ago

Sir-Will commented 4 years ago

If a plugin calls the following method for all worlds GD fails to fully load all claims resulting in no active protection and visualization tools not working.

@Listener
public void onServerStart(GameStartedServerEvent event) {
    for (WorldProperties world : Sponge.getServer().getAllWorldProperties()) {
        Set<Claim> claims = GriefDefender.getCore().getClaimManager(world.getUniqueId()).getWorldClaims();
    }
}

After some more testing this seems to happen when calling getClaimManager() on an unloaded or not existing world.

Sir-Will commented 4 years ago

The easiest way to reproduce the issue is to just call GriefDefender.getCore().getClaimManager(UUID.randomUUID());

bloodmc commented 3 years ago

GD does not support claims in unloaded worlds. You should be using

https://github.com/SpongePowered/SpongeAPI/blob/stable-7/src/main/java/org/spongepowered/api/Server.java#L92

Sir-Will commented 3 years ago

GD does not support claims in unloaded worlds.

This is still a big issue, you are expecting everyone who is using the API to check if the world is loaded before calling getClaimManager(). With worlds being loaded and unloaded frequently, this will most likely cause the protection to fail at some point.

You should be using

That's what I'm using as workaround but I need to handle claims of unloaded worlds too.

bloodmc commented 3 years ago

OK, I'll label this as enhancement.

bloodmc commented 3 years ago

Please provide a use case of accessing unloaded world claims. Currently, GD only loads claims when a world loads.

Sir-Will commented 3 years ago

Checking the owners activity of all claims on startup to remove and handle inactive ones.