@Test public void test() { final Object[] random = { // Java (byte) 127, (short) 2000, -1600000, 1L << 40, -1.5f, 13.37, "String", // Skript Color.BLACK, StructureType.RED_MUSHROOM, WeatherType.THUNDER, new Date(System.currentTimeMillis()), new Timespan(1337), new Time(12000), new Timeperiod(1000, 23000), new Experience(15), new Direction(0, Math.PI, 10), new Direction(new double[] {0, 1, 0}), new EntityType(new SimpleEntityData(HumanEntity.class), 300), new CreeperData(), new SimpleEntityData(Snowball.class), new HorseData(Variant.SKELETON_HORSE), new WolfData(), new XpOrbData(50), // Bukkit - simple classes only GameMode.ADVENTURE, Biome.EXTREME_HILLS, DamageCause.FALL, // there is also at least one variable for each class on my test server which are tested whenever the server shuts down. }; for (final Object o : random) { Classes.serialize(o); // includes a deserialisation test } }
@Override protected boolean init(final Literal<?>[] exprs, final int matchedPattern, final ParseResult parseResult) { variant = Variant.values()[matchedPattern]; // if (variant == Variant.HORSE) { // // TODO color and style // rem: toString // } return true; }
@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; }
public void MobApocalypyse(BlockBreakEvent event){ int j,k,l,notUse=0,Quantity; Location loc = event.getBlock().getLocation(); World world = loc.getWorld(); event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,20*60,1)); event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION,20*60,1)); int X = (event.getBlock().getX())+2; int Y = event.getBlock().getY(); int Z = (event.getBlock().getZ())-2; for (j=X;j>X-5;j--){ for (k=Z;k<Z+5;k++){ for (l=Y+2;l<Y+3;l++){ if (notUse==0 || notUse==2 || notUse==4 || notUse==10 || notUse==12 || notUse==14 || notUse==20 || notUse==22 || notUse==24){ Location loc2 = new Location(world,j,l,k); for (Quantity=0;Quantity<1;Quantity++){ world.spawnEntity(loc2,EntityType.CREEPER); world.spawnEntity(loc2,EntityType.ZOMBIE); Horse undead = (Horse) world.spawnEntity(loc,EntityType.HORSE); undead.setVariant(Variant.UNDEAD_HORSE); Horse SKELETON = (Horse) world.spawnEntity(loc,EntityType.HORSE); SKELETON.setVariant(Variant.SKELETON_HORSE); } } } notUse++; } } }
@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); }
public HorseData(final @Nullable Variant variant) { this.variant = variant; }
public Variant getHorseVariant() { return variant; }
Horse.Variant getVariant();
void setVariant(Horse.Variant variant);