Java Code Examples for ch.njol.skript.classes.ClassInfo#getChanger()

The following examples show how to use ch.njol.skript.classes.ClassInfo#getChanger() . 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: SimpleExpressionFork.java    From skript-yaml with MIT License 5 votes vote down vote up
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
	ClassInfo<?> rti = returnTypeInfo;
	if (rti == null)
		returnTypeInfo = rti = Classes.getSuperClassInfo(getReturnType());
	final Changer<?> c = rti.getChanger();
	if (c == null)
		return null;
	return c.acceptChange(mode);
}
 
Example 2
Source File: SimpleExpressionFork.java    From skript-yaml with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) {
	final ClassInfo<?> rti = returnTypeInfo;
	if (rti == null)
		throw new UnsupportedOperationException();
	final Changer<?> c = rti.getChanger();
	if (c == null)
		throw new UnsupportedOperationException();
	((Changer<T>) c).change(getArray(e), delta, mode);
}
 
Example 3
Source File: SimpleExpression.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
	ClassInfo<?> rti = returnTypeInfo;
	if (rti == null)
		returnTypeInfo = rti = Classes.getSuperClassInfo(getReturnType());
	final Changer<?> c = rti.getChanger();
	if (c == null)
		return null;
	return c.acceptChange(mode);
}
 
Example 4
Source File: SimpleExpression.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) {
	final ClassInfo<?> rti = returnTypeInfo;
	if (rti == null)
		throw new UnsupportedOperationException();
	final Changer<?> c = rti.getChanger();
	if (c == null)
		throw new UnsupportedOperationException();
	((Changer<T>) c).change(getArray(e), delta, mode);
}
 
Example 5
Source File: ConvertedExpression.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
	final Class<?>[] r = source.acceptChange(mode);
	if (r == null) {
		ClassInfo<? super T> rti = returnTypeInfo;
		returnTypeInfo = rti = Classes.getSuperClassInfo(getReturnType());
		final Changer<?> c = rti.getChanger();
		return c == null ? null : c.acceptChange(mode);
	}
	return r;
}
 
Example 6
Source File: ConvertedExpression.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) {
	final ClassInfo<? super T> rti = returnTypeInfo;
	if (rti != null) {
		final Changer<? super T> c = rti.getChanger();
		if (c != null)
			c.change(getArray(e), delta, mode);
	} else {
		source.change(e, delta, mode);
	}
}
 
Example 7
Source File: SimpleLiteral.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
	ClassInfo<? super T> rti = returnTypeInfo;
	if (rti == null)
		returnTypeInfo = rti = Classes.getSuperClassInfo(getReturnType());
	final Changer<? super T> c = rti.getChanger();
	return c == null ? null : c.acceptChange(mode);
}
 
Example 8
Source File: SimpleLiteral.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) throws UnsupportedOperationException {
	final ClassInfo<? super T> rti = returnTypeInfo;
	if (rti == null)
		throw new UnsupportedOperationException();
	final Changer<? super T> c = rti.getChanger();
	if (c == null)
		throw new UnsupportedOperationException();
	c.change(getArray(), delta, mode);
}