Java Code Examples for ch.njol.util.coll.CollectionUtils#array()

The following examples show how to use ch.njol.util.coll.CollectionUtils#array() . 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: ExprMOTD.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@Override
@Nullable
public Class<?>[] acceptChange(ChangeMode mode) {
	if (!isDefault) {
		if (ScriptLoader.hasDelayBefore.isTrue()) {
			Skript.error("Can't change the MOTD anymore after the server list ping event has already passed");
			return null;
		}
		switch (mode) {
			case SET:
			case DELETE:
			case RESET:
				return CollectionUtils.array(String.class);
		}
	}
	return null;
}
 
Example 2
Source File: ExprMaxPlayers.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@Override
@Nullable
public Class<?>[] acceptChange(ChangeMode mode) {
	if (!isReal) {
		if (ScriptLoader.hasDelayBefore.isTrue()) {
			Skript.error("Can't change the fake max players count anymore after the server list ping event has already passed");
			return null;
		}
		switch (mode) {
			case SET:
			case ADD:
			case REMOVE:
			case DELETE:
			case RESET:
				return CollectionUtils.array(Number.class);
		}
	}
	return null;
}
 
Example 3
Source File: ExprRayfallOffhand.java    From skRayFall with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
    switch (mode) {
        case SET:
            return CollectionUtils.array(ItemStack.class);
        case ADD:
        case REMOVE:
        case DELETE:
        case REMOVE_ALL:
        case RESET:
        default:
            return null;
    }
}
 
Example 4
Source File: ExprHoverList.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@Override
@Nullable
public Class<?>[] acceptChange(ChangeMode mode) {
	if (ScriptLoader.hasDelayBefore.isTrue()) {
		Skript.error("Can't change the hover list anymore after the server list ping event has already passed");
		return null;
	}
	switch (mode) {
		case SET:
		case ADD:
		case REMOVE:
		case DELETE:
		case RESET:
			return CollectionUtils.array(String[].class, Player[].class);
	}
	return null;
}
 
Example 5
Source File: ExprBookAuthor.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public Class<?>[] acceptChange(Changer.ChangeMode mode) {
	if (mode == Changer.ChangeMode.SET || mode == Changer.ChangeMode.RESET || mode == Changer.ChangeMode.DELETE)
		return CollectionUtils.array(String.class);
	return null;
}
 
Example 6
Source File: ExprLastDamageCause.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
	if (mode == ChangeMode.REMOVE_ALL)
		return null;
	return CollectionUtils.array(DamageCause.class);
}
 
Example 7
Source File: ExprVelocity.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
@SuppressWarnings("null")
public Class<?>[] acceptChange(ChangeMode mode) {
	if ((mode == ChangeMode.ADD || mode == ChangeMode.REMOVE || mode == ChangeMode.SET || mode == ChangeMode.DELETE || mode == ChangeMode.RESET))
		return CollectionUtils.array(Vector.class);
	return null;
}
 
Example 8
Source File: SExprFileContents.java    From skUtilities with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Class<?>[] acceptChange(final Changer.ChangeMode mode) {
  if (mode == Changer.ChangeMode.RESET || mode == Changer.ChangeMode.SET) {
    return CollectionUtils.array(String[].class);
  }
  return null;
}
 
Example 9
Source File: ExprNoDamageTicks.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
	if (mode == ChangeMode.REMOVE_ALL)
		return null;
	return CollectionUtils.array(Number.class);
}
 
Example 10
Source File: ExprDamage.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
	if (delay != Kleenean.FALSE) {
		Skript.error("Can't change the damage anymore after the event has already passed");
		return null;
	}
	if (mode == ChangeMode.REMOVE_ALL)
		return null;
	return CollectionUtils.array(Number.class);
}
 
Example 11
Source File: ExprSpawnerType.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public Class<?>[] acceptChange(Changer.ChangeMode mode) {
	if (mode == ChangeMode.SET || mode == ChangeMode.RESET) 
		return CollectionUtils.array(EntityData.class);
	return null;
}
 
Example 12
Source File: ExprProtocolVersion.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Nullable
public Class<?>[] acceptChange(ChangeMode mode) {
	if (ScriptLoader.hasDelayBefore.isTrue()) {
		Skript.error("Can't change the protocol version anymore after the server list ping event has already passed");
		return null;
	}
	if (mode == ChangeMode.SET)
		return CollectionUtils.array(Number.class);
	return null;
}
 
Example 13
Source File: ExprEventCancelled.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
	if (delay != Kleenean.FALSE) {
		Skript.error("Can't cancel the event anymore after it has already passed");
		return null;
	}
	if (mode == ChangeMode.SET || mode == ChangeMode.DELETE)
		return CollectionUtils.array(Boolean.class);
	return null;
}
 
Example 14
Source File: ExprArrowsStuck.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
	if (mode == ChangeMode.REMOVE_ALL)
		return null;
	return CollectionUtils.array(Number.class);
}
 
Example 15
Source File: ExprRespawnLocation.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public Class<?>[] acceptChange(Changer.ChangeMode mode) {
	if (mode == ChangeMode.SET)
		return CollectionUtils.array(Location.class);
	return null;
}
 
Example 16
Source File: SExprFileOwner.java    From skUtilities with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Class<?>[] acceptChange(final Changer.ChangeMode mode) {
  if (mode == Changer.ChangeMode.SET) {
    return CollectionUtils.array(String.class);
  }
  return null;
}
 
Example 17
Source File: ExprVectorBetweenLocations.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
@SuppressWarnings("null")
protected Vector[] get(Event e) {
	Location l1 = from.getSingle(e);
	Location l2 = to.getSingle(e);
	if (l1 == null || l2 == null)
		return null;
	return CollectionUtils.array(new Vector(l2.getX() - l1.getX(), l2.getY() - l1.getY(), l2.getZ() - l1.getZ()));
}
 
Example 18
Source File: ExprServerIcon.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Nullable
public CachedServerIcon[] get(Event e) {
	CachedServerIcon icon = null;
	if ((isServerPingEvent && !isDefault) && PAPER_EVENT_EXISTS)
		icon = ((PaperServerListPingEvent) e).getServerIcon();
	else
		icon = Bukkit.getServerIcon();
	if (icon == null || icon.getData() == null)
		return null;
	return CollectionUtils.array(icon);
}
 
Example 19
Source File: ExprVersionString.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
@Nullable
public String[] get(Event e) {
	return CollectionUtils.array(((PaperServerListPingEvent) e).getVersion());
}
 
Example 20
Source File: EffColorItems.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings({"unchecked", "null"})
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
	items = (Expression<ItemType>) exprs[0];
	if (matchedPattern == 0) {
		color = (Expression<Color>) exprs[1];
	} else {
		color = new SimpleExpression<Color>() {
			
			private Expression<Number> red;
			private Expression<Number> green;
			private Expression<Number> blue;
			
			@Override
			public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
				red = (Expression<Number>) exprs[0];
				green = (Expression<Number>) exprs[1];
				blue = (Expression<Number>) exprs[2];
				return true;
			}
			
			@Nullable
			@Override
			protected Color[] get(Event e) {
				Number r = red.getSingle(e),
					g = green.getSingle(e),
					b = blue.getSingle(e);
				
				if (r == null || g == null || b == null)
					return null;
				
				return CollectionUtils.array(new ColorRGB(r.intValue(), g.intValue(), b.intValue()));
			}
			
			@Override
			public boolean isSingle() {
				return true;
			}
			
			@Override
			public Class<? extends Color> getReturnType() {
				return ColorRGB.class;
			}
			
			@Override
			public String toString(@Nullable Event e, boolean debug) {
				return "RED: " + red.toString(e, debug) + ", GREEN: " + green.toString(e, debug) + "BLUE: " + blue.toString(e, debug);
			}
		};
		color.init(CollectionUtils.array(exprs[1], exprs[2], exprs[3]), 0, isDelayed, parser);
	}
	return true;
}