mirror of
https://github.com/BentoBoxWorld/Limits.git
synced 2024-09-27 14:12:57 +02:00
Fix for nulls in map.
https://github.com/BentoBoxWorld/Limits/issues/50
This commit is contained in:
parent
fdfc080307
commit
6b54fc5b8e
@ -8,12 +8,35 @@ import java.util.Map;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import bentobox.addon.limits.commands.LimitPanel;
|
||||
|
||||
public class Settings {
|
||||
|
||||
private final Map<EntityType, Integer> limits = new EnumMap<>(EntityType.class);
|
||||
private final List<String> gameModes;
|
||||
private static final List<EntityType> DISALLOWED = Arrays.asList(
|
||||
EntityType.PRIMED_TNT,
|
||||
EntityType.EVOKER_FANGS,
|
||||
EntityType.LLAMA_SPIT,
|
||||
EntityType.DRAGON_FIREBALL,
|
||||
EntityType.AREA_EFFECT_CLOUD,
|
||||
EntityType.ENDER_SIGNAL,
|
||||
EntityType.SMALL_FIREBALL,
|
||||
EntityType.FIREBALL,
|
||||
EntityType.THROWN_EXP_BOTTLE,
|
||||
EntityType.EXPERIENCE_ORB,
|
||||
EntityType.SHULKER_BULLET,
|
||||
EntityType.WITHER_SKULL,
|
||||
EntityType.TRIDENT,
|
||||
EntityType.ARROW,
|
||||
EntityType.SPECTRAL_ARROW,
|
||||
EntityType.SNOWBALL,
|
||||
EntityType.EGG,
|
||||
EntityType.LEASH_HITCH,
|
||||
EntityType.GIANT,
|
||||
EntityType.ENDER_CRYSTAL,
|
||||
EntityType.ENDER_PEARL,
|
||||
EntityType.ENDER_DRAGON,
|
||||
EntityType.ITEM_FRAME,
|
||||
EntityType.PAINTING);
|
||||
|
||||
public Settings(Limits addon) {
|
||||
|
||||
@ -25,9 +48,7 @@ public class Settings {
|
||||
for (String key : el.getKeys(false)) {
|
||||
EntityType type = getType(key);
|
||||
if (type != null) {
|
||||
if (!type.equals(EntityType.PAINTING) &&
|
||||
!type.equals(EntityType.ITEM_FRAME) &&
|
||||
(!type.isSpawnable() || (LimitPanel.E2M.containsKey(type) && LimitPanel.E2M.get(type) == null))) {
|
||||
if (DISALLOWED.contains(type)) {
|
||||
addon.logError("Entity type: " + key + " is not supported - skipping...");
|
||||
} else {
|
||||
limits.put(type, el.getInt(key, 0));
|
||||
|
@ -30,7 +30,7 @@ public class LimitPanel {
|
||||
private final Limits addon;
|
||||
// This maps the entity types to the icon that should be shown in the panel
|
||||
// If the icon is null, then the entity type is not covered by the addon
|
||||
public static final Map<EntityType, Material> E2M = ImmutableMap.<EntityType, Material>builder()
|
||||
private static final Map<EntityType, Material> E2M = ImmutableMap.<EntityType, Material>builder()
|
||||
.put(EntityType.PIG_ZOMBIE, Material.ZOMBIE_PIGMAN_SPAWN_EGG)
|
||||
.put(EntityType.MUSHROOM_COW, Material.MOOSHROOM_SPAWN_EGG)
|
||||
.put(EntityType.SNOWMAN, Material.SNOW_BLOCK)
|
||||
@ -48,32 +48,9 @@ public class LimitPanel {
|
||||
.put(EntityType.MINECART_FURNACE, Material.FURNACE_MINECART)
|
||||
.put(EntityType.MINECART_HOPPER, Material.HOPPER_MINECART)
|
||||
.put(EntityType.MINECART_MOB_SPAWNER, Material.MINECART)
|
||||
// Disallowed
|
||||
.put(EntityType.PRIMED_TNT, null)
|
||||
.put(EntityType.EVOKER_FANGS, null)
|
||||
.put(EntityType.LLAMA_SPIT, null)
|
||||
.put(EntityType.DRAGON_FIREBALL, null)
|
||||
.put(EntityType.AREA_EFFECT_CLOUD, null)
|
||||
.put(EntityType.ENDER_SIGNAL, null)
|
||||
.put(EntityType.SMALL_FIREBALL, null)
|
||||
.put(EntityType.FIREBALL, null)
|
||||
.put(EntityType.THROWN_EXP_BOTTLE, null)
|
||||
.put(EntityType.EXPERIENCE_ORB, null)
|
||||
.put(EntityType.SHULKER_BULLET, null)
|
||||
.put(EntityType.WITHER_SKULL, null)
|
||||
.put(EntityType.TRIDENT, null)
|
||||
.put(EntityType.ARROW, null)
|
||||
.put(EntityType.SPECTRAL_ARROW, null)
|
||||
.put(EntityType.SNOWBALL, null)
|
||||
.put(EntityType.EGG, null)
|
||||
.put(EntityType.LEASH_HITCH, null)
|
||||
.put(EntityType.GIANT, null)
|
||||
.put(EntityType.ENDER_CRYSTAL, null)
|
||||
.put(EntityType.ENDER_PEARL, null)
|
||||
.put(EntityType.ENDER_DRAGON, null)
|
||||
.build();
|
||||
// This is a map of blocks to Material
|
||||
public static final Map<Material, Material> B2M;
|
||||
private static final Map<Material, Material> B2M;
|
||||
static {
|
||||
ImmutableMap.Builder<Material, Material> builder = ImmutableMap.<Material, Material>builder()
|
||||
.put(Material.POTATOES, Material.POTATO)
|
||||
|
Loading…
Reference in New Issue
Block a user