Skip to content

Commit

Permalink
Fix for nulls in map.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Nov 9, 2019
1 parent fdfc080 commit 6b54fc5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 30 deletions.
31 changes: 26 additions & 5 deletions src/main/java/bentobox/addon/limits/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,35 @@
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) {

Expand All @@ -25,9 +48,7 @@ public Settings(Limits addon) {
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));
Expand Down
27 changes: 2 additions & 25 deletions src/main/java/bentobox/addon/limits/commands/LimitPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 6b54fc5

Please sign in to comment.