org.bukkit.entity.Horse.Variant Java Examples

The following examples show how to use org.bukkit.entity.Horse.Variant. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HorseData.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected boolean init(final Literal<?>[] exprs, final int matchedPattern, final ParseResult parseResult) {
	switch (matchedPattern) { // If Variant ordering is changed, will not break
		case 0:
			variant = Variant.HORSE;
			break;
		case 1:
			variant = Variant.DONKEY;
			break;
		case 2:
			variant = Variant.MULE;
			break;
		case 3:
			variant = Variant.UNDEAD_HORSE;
			break;
		case 4:
			variant = Variant.SKELETON_HORSE;
			break;
	}
	
	return true;
}
 
Example #2
Source File: HorseData.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example #3
Source File: ClassesTest.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void test() {
	final Object[] random = {
			// Java
			(byte) 127, (short) 2000, -1600000, 1L << 40, -1.5f, 13.37,
			"String",
			
			// Skript
			SkriptColor.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, InventoryType.CHEST, 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
	}
}
 
Example #4
Source File: CraftDonkey.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Variant getVariant() {
    return Variant.DONKEY;
}
 
Example #5
Source File: CraftSkeletonHorse.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Variant getVariant() {
    return Variant.SKELETON_HORSE;
}
 
Example #6
Source File: CraftZombieHorse.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Variant getVariant() {
    return Variant.UNDEAD_HORSE;
}
 
Example #7
Source File: CraftMule.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Variant getVariant() {
    return Variant.MULE;
}
 
Example #8
Source File: HorseData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
public HorseData(final @Nullable Variant variant) {
	this.variant = variant;
}