Fix startup issue with potion providers (#6055)

The LegacyPotionMetaProvider was initializing a map with enums that
don't exist on modern versions. Since this was a static variable, this
map got initialized when the test method was called, leading to a
NoSuchFieldError.

Also improved resilience of these provider-type issues again by catching
a Throwable rather than an Exception in the ProviderFactory.

Fixes #6054
This commit is contained in:
Josh Roy 2025-02-19 15:58:00 -05:00 committed by GitHub
parent 69ed07a536
commit 196a2a19c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -68,7 +68,7 @@ public class ProviderFactory {
highestProvider = provider;
highestProviderData = providerData;
}
} catch (final Exception e) {
} catch (final Throwable e) {
essentials.getLogger().log(Level.SEVERE, "Failed to initialize provider " + provider.getName(), e);
}
}

View File

@ -16,7 +16,7 @@ import java.util.Map;
@ProviderData(description = "1.9-1.20.4 Potion Meta Provider", weight = 1)
public class LegacyPotionMetaProvider implements PotionMetaProvider {
private static final Map<Integer, PotionType> damageValueToType = ImmutableMap.<Integer, PotionType>builder()
private final Map<Integer, PotionType> damageValueToType = ImmutableMap.<Integer, PotionType>builder()
.put(1, PotionType.REGEN)
.put(2, PotionType.SPEED)
.put(3, PotionType.FIRE_RESISTANCE)