public boolean addCustomBiome(Window parent, CustomBiome customBiome) { if (isBiomePresent(customBiome.getId())) { JOptionPane.showMessageDialog( parent, "The specified ID (" + customBiome.getId() + ") is already a regular biome (named " + Minecraft1_7Biomes.BIOME_NAMES[customBiome.getId()] + ")", "ID Already In Use", JOptionPane.ERROR_MESSAGE); return false; } if (customBiomes == null) { customBiomes = new ArrayList<>(); } for (CustomBiome existingCustomBiome : customBiomes) { if (existingCustomBiome.getId() == customBiome.getId()) { JOptionPane.showMessageDialog( parent, "You already configured a custom biome with that ID (named " + existingCustomBiome.getName() + ")", "ID Already In Use", JOptionPane.ERROR_MESSAGE); return false; } } customBiomes.add(customBiome); for (CustomBiomeListener listener : listeners) { listener.customBiomeAdded(customBiome); } return true; }
/** * Indicates that some aspect of a custom biome (other than the ID, which is not allowed to * change) has changed. * * @param customBiome The custom biome that has been modified. */ public void editCustomBiome(CustomBiome customBiome) { for (CustomBiome existingCustomBiome : customBiomes) { if (existingCustomBiome.getId() == customBiome.getId()) { for (CustomBiomeListener listener : listeners) { listener.customBiomeChanged(customBiome); } return; } } throw new IllegalArgumentException( "There is no custom biome installed with ID " + customBiome.getId()); }
/** * Removes a custom biome. * * @param customBiome The custom biome to remove. */ public void removeCustomBiome(CustomBiome customBiome) { for (Iterator<CustomBiome> i = customBiomes.iterator(); i.hasNext(); ) { CustomBiome existingCustomBiome = i.next(); if (existingCustomBiome.getId() == customBiome.getId()) { i.remove(); for (CustomBiomeListener listener : listeners) { listener.customBiomeRemoved(customBiome); } return; } } throw new IllegalArgumentException( "There is no custom biome installed with ID " + customBiome.getId()); }
public void setCustomBiomes(List<CustomBiome> customBiomes) { List<CustomBiome> oldCustomBiomes = this.customBiomes; this.customBiomes = customBiomes; if (oldCustomBiomes != null) { for (CustomBiome customBiome : oldCustomBiomes) { for (CustomBiomeListener listener : listeners) { listener.customBiomeRemoved(customBiome); } } } if (customBiomes != null) { for (CustomBiome customBiome : customBiomes) { for (CustomBiomeListener listener : listeners) { listener.customBiomeAdded(customBiome); } } } }