@Override protected boolean deserialize(final String s) { final String[] split = s.split(","); if (split.length != 3) return false; try { variant = split[0].isEmpty() ? null : Variant.valueOf(split[0]); color = split[1].isEmpty() ? null : Color.valueOf(split[1]); style = split[2].isEmpty() ? null : Style.valueOf(split[2]); } catch (final IllegalArgumentException e) { return false; } return true; }
@Override public LivingEntity spawnHorse(Location loc, HorseType type, Color color, Style style, boolean tame, boolean chest) { Horse horse = (Horse) loc.getWorld().spawnEntity(loc, type.getEntity()); horse.setColor(color); horse.setStyle(style); horse.setTamed(tame); if (chest && horse instanceof ChestedHorse) ((ChestedHorse) horse).setCarryingChest(true); return horse; }
@Override public LivingEntity spawnHorse(Location loc, HorseType type, Color color, Style style, boolean tame, boolean chest) { Horse horse = (Horse) loc.getWorld().spawnEntity(loc, EntityType.HORSE); horse.setVariant(type.getVariant()); horse.setColor(color); horse.setStyle(style); horse.setTamed(tame); horse.setCarryingChest(chest); return horse; }
@Override public void deserialize(IDataNode dataNode) throws DeserializeException { _color = dataNode.getEnum("color", Color.WHITE, Color.class); _variant = dataNode.getEnum("variant", Variant.HORSE, Variant.class); _style = dataNode.getEnum("style", Style.NONE, Style.class); _domestication = dataNode.getInteger("dom"); _maxDomestication = dataNode.getInteger("max-dom"); _hasChest = dataNode.getBoolean("chest"); _jumpStrength = dataNode.getDouble("jump", 1.0D); }
@Override public void deserialize(LoreMetaMap metaMap) { LoreMetaItem colorItem = metaMap.get("color"); if (colorItem != null) _color = colorItem.enumValue(Color.class); LoreMetaItem variantItem = metaMap.get("variant"); if (variantItem != null) _variant = variantItem.enumValue(Variant.class); LoreMetaItem styleItem = metaMap.get("style"); if (styleItem != null) _style = styleItem.enumValue(Style.class); LoreMetaItem domItem = metaMap.get("dom"); if (domItem != null) _domestication = domItem.intValue(); LoreMetaItem maxDomItem = metaMap.get("max-dom"); if (maxDomItem != null) _maxDomestication = maxDomItem.intValue(); LoreMetaItem chestItem = metaMap.get("chest"); if (chestItem != null) _hasChest = chestItem.booleanValue(); LoreMetaItem jumpItem = metaMap.get("jump"); if (jumpItem != null) _jumpStrength = jumpItem.doubleValue(); }
@Override public void loadData(ConfigurationSection section) { this.colour = Color.valueOf(section.getString("color", Color.BLACK.name())); this.style = Style.valueOf(section.getString("style", Style.NONE.name())); this.variant = Variant.valueOf(section.getString("variant", Variant.HORSE.name())); super.loadData(section); }
@Override public void setColor(Color color){ ((IEntityHorsePet) getEntityPet()).setColor(color); this.color = color; }
@Override public Color getColor(){ return this.color; }
LivingEntity spawnHorse(Location loc, HorseType type, Horse.Color color, Horse.Style style, boolean tame, boolean chest);
public Color getHorseColor() { return colour; }
/** * Spawns a Horse at a given location with the given properties. * @param loc Location to spawn at * @param variant Horse Variant, null if random * @param color Horse Color, null if random * @param style Horse Style, null if random * @param tame Whether or not the Horse is tamed * @param chest Whether or not the Horse is carrying a chest * @return The Horse */ public static LivingEntity spawnHorse(Location loc, HorseType type, Horse.Color color, Horse.Style style, boolean tame, boolean chest) { if (type == null) type = randomElement(HorseType.values()); if (color == null) color = randomElement(Horse.Color.values()); if (style == null) style = randomElement(Horse.Style.values()); return provider.spawnHorse(loc, type, color, style, tame, chest); }
Horse.Color getColor();
void setColor(Horse.Color color);