org.bukkit.entity.Minecart Java Examples

The following examples show how to use org.bukkit.entity.Minecart. 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: MinecartData.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("null")
@Override
protected boolean init(final @Nullable Class<? extends Minecart> c, final @Nullable Minecart e) {
	final MinecartType[] ts = MinecartType.values();
	for (int i = ts.length - 1; i >= 0; i--) {
		final Class<?> mc = ts[i].c;
		if (mc == null)
			continue;
		if (e == null ? mc.isAssignableFrom(c) : mc.isInstance(e)) {
			type = ts[i];
			return true;
		}
	}
	assert false;
	return false;
}
 
Example #2
Source File: MinecartData.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean match(final Minecart entity) {
	if (type == MinecartType.NORMAL && type.c == Minecart.class) // pre-1.5
		return !(entity.getClass().equals(Utils.classForName("org.bukkit.entity.StorageMinecart"))
				|| entity.getClass().equals(Utils.classForName("org.bukkit.entity.PoweredMinecart")));
	return type.c != null && type.c.isInstance(entity);
}
 
Example #3
Source File: MinecartData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
MinecartType(final @Nullable Class<? extends Minecart> c, final String codeName) {
	this.c = c;
	this.codeName = codeName;
}
 
Example #4
Source File: MinecartData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void set(final Minecart entity) {}
 
Example #5
Source File: MinecartData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends Minecart> getType() {
	return type.c != null ? type.c : Minecart.class;
}