@TraitConfigurationNeeded( fields = { @TraitConfigurationField( fieldName = "range", classToExpect = Integer.class, optional = true), @TraitConfigurationField(fieldName = "time", classToExpect = Integer.class, optional = true) }) @Override public void setConfiguration(TraitConfiguration configMap) throws TraitConfigurationFailedException { super.setConfiguration(configMap); if (configMap.containsKey("range")) range = configMap.getAsInt("range"); if (configMap.containsKey("time")) seconds = configMap.getAsInt("time"); }
@TraitConfigurationNeeded( fields = { @TraitConfigurationField( fieldName = "blocks", classToExpect = Integer.class, optional = true), @TraitConfigurationField(fieldName = "up", classToExpect = Boolean.class, optional = true), @TraitConfigurationField( fieldName = "targetParticles", classToExpect = String.class, optional = true) }) @Override public void setConfiguration(TraitConfiguration configMap) throws TraitConfigurationFailedException { super.setConfiguration(configMap); if (configMap.containsKey("blocks")) { this.blocks = configMap.getAsInt("blocks"); } if (configMap.containsKey("up")) { this.up = configMap.getAsBool("up"); } if (configMap.containsKey("targetParticles")) { this.targetParticles = configMap.getAsParticleContainer("targetParticles"); } }
@TraitConfigurationNeeded( fields = { @TraitConfigurationField(classToExpect = List.class, fieldName = "drops", optional = false), @TraitConfigurationField( classToExpect = String.class, fieldName = "monstername", optional = false), @TraitConfigurationField( classToExpect = Material.class, fieldName = "material", optional = false), @TraitConfigurationField( classToExpect = Integer.class, fieldName = "damage", optional = true), @TraitConfigurationField(classToExpect = String.class, fieldName = "name", optional = true), @TraitConfigurationField(classToExpect = List.class, fieldName = "lore", optional = true), }) @Override public void setConfiguration(TraitConfiguration configMap) throws TraitConfigurationFailedException { super.setConfiguration(configMap); Material mat = configMap.getAsMaterial("material", Material.STONE); this.item = new ItemStack(mat); // Add item damage: if (configMap.containsKey("damage")) { this.item.setDurability((short) configMap.getAsInt("damage", 0)); } // Add item Name: if (configMap.containsKey("name")) { String itemName = ChatColor.translateAlternateColorCodes('&', configMap.getAsString("name")); ItemMetaUtils.setDisplayNameOfItem(item, itemName); } // Add item Lore: if (configMap.containsKey("lore")) { List<String> lore = CollectionUtils.translateChatColors(configMap.getAsStringList("lore")); ItemMeta meta = item.getItemMeta(); meta.setLore(lore); item.setItemMeta(meta); } // Parse monster stuff: if (configMap.containsKey("drops")) { List<String> drops = configMap.getAsStringList("drops"); this.dropChances.clear(); this.dropChances.putAll(convertToDropMap(drops)); } // Set the monster name. if (configMap.containsKey("monstername")) { this.neededName = configMap.getAsString("monstername", ""); } }