ch.njol.util.Checker Java Examples
The following examples show how to use
ch.njol.util.Checker.
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: SkriptEventBQ.java From BetonQuest with GNU General Public License v3.0 | 6 votes |
@Override public boolean check(Event e) { if (e instanceof BQEventSkript.CustomEventForSkript) { final BQEventSkript.CustomEventForSkript event = (BQEventSkript.CustomEventForSkript) e; return literal.check(e, new Checker<Object>() { @Override public boolean check(Object o) { if (o instanceof String) { String id = (String) o; return (event.getID().equals(id)); } return false; } }); } return false; }
Example #2
Source File: EvtWeatherChange.java From Skript with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("null") @Override public boolean check(final Event e) { if (types == null) return true; if (!(e instanceof WeatherChangeEvent || e instanceof ThunderChangeEvent)) return false; final boolean rain = e instanceof WeatherChangeEvent ? ((WeatherChangeEvent) e).toWeatherState() : ((ThunderChangeEvent) e).getWorld().hasStorm(); final boolean thunder = e instanceof ThunderChangeEvent ? ((ThunderChangeEvent) e).toThunderState() : ((WeatherChangeEvent) e).getWorld().isThundering(); return types.check(e, new Checker<WeatherType>() { @Override public boolean check(final WeatherType t) { return t.isWeather(rain, thunder); } }); }
Example #3
Source File: SimpleExpressionFork.java From skript-yaml with MIT License | 6 votes |
public final static <T> boolean check(final @Nullable T[] all, final Checker<? super T> c, final boolean invert, final boolean and) { if (all == null) return false; boolean hasElement = false; for (final T t : all) { if (t == null) continue; hasElement = true; final boolean b = c.check(t); if (and && !b) return invert ^ false; if (!and && b) return invert ^ true; } if (!hasElement) return false; return invert ^ and; }
Example #4
Source File: SimpleExpression.java From Skript with GNU General Public License v3.0 | 6 votes |
public static <T> boolean check(final @Nullable T[] all, final Checker<? super T> c, final boolean invert, final boolean and) { if (all == null) return invert; boolean hasElement = false; for (final T t : all) { if (t == null) continue; hasElement = true; final boolean b = c.check(t); if (and && !b) return invert; if (!and && b) return !invert; } if (!hasElement) return invert; return invert ^ and; }
Example #5
Source File: CondIsOfType.java From Skript with GNU General Public License v3.0 | 6 votes |
@Override public boolean check(final Event e) { return what.check(e, (Checker<Object>) o1 -> types.check(e, (Checker<Object>) o2 -> { if (o2 instanceof ItemType && o1 instanceof ItemType) { return ((ItemType) o2).isSupertypeOf((ItemType) o1); } else if (o2 instanceof EntityData && o1 instanceof Entity) { return ((EntityData<?>) o2).isInstance((Entity) o1); } else if (o2 instanceof ItemType && o1 instanceof Entity) { return Relation.EQUAL.is(DefaultComparators.entityItemComparator.compare(EntityData.fromEntity((Entity) o1), (ItemType) o2)); } else { return false; } }), isNegated()); }
Example #6
Source File: ExpressionList.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public boolean check(final Event e, final Checker<? super T> c) { for (final Expression<? extends T> expr : expressions) { final Boolean b = expr.check(e, c); if (and && !b) return false; if (!and && b) return true; } return and; }
Example #7
Source File: EvtGameMode.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public boolean check(final Event e) { if (mode != null) { return mode.check(e, new Checker<GameMode>() { @Override public boolean check(final GameMode m) { return ((PlayerGameModeChangeEvent) e).getNewGameMode().equals(m); } }); } return true; }
Example #8
Source File: ConvertedExpression.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public boolean check(final Event e, final Checker<? super T> c) { return source.check(e, new Checker<F>() { @Override public boolean check(final F f) { final T t = conv.convert(f); if (t == null) { return false; } return c.check(t); } }); }
Example #9
Source File: CondNodeHasList.java From skript-yaml with MIT License | 5 votes |
@Override public boolean check(final Event event) { return path.check(event, new Checker<String>() { @Override public boolean check(final String s) { if (!SkriptYaml.YAML_STORE.containsKey(file.getSingle(event))) return false; Object o = SkriptYaml.YAML_STORE.get(file.getSingle(event)).getProperty(path.getSingle(event)); return o != null ? (o instanceof List) : false; } }, isNegated()); }
Example #10
Source File: CondIsMember.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public boolean check(final Event e) { return players.check(e, new Checker<OfflinePlayer>() { @Override public boolean check(final OfflinePlayer p) { return regions.check(e, new Checker<Region>() { @Override public boolean check(final Region r) { return owner ? r.isOwner(p) : r.isMember(p); } }, isNegated()); } }); }
Example #11
Source File: CondCanBuild.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public boolean check(final Event e) { return players.check(e, new Checker<Player>() { @Override public boolean check(final Player p) { return locations.check(e, new Checker<Location>() { @Override public boolean check(final Location l) { return RegionsPlugin.canBuild(p, l); } }, isNegated()); } }); }
Example #12
Source File: CondYamlIsEmpty.java From skript-yaml with MIT License | 5 votes |
@Override public boolean check(final Event event) { return file.check(event, new Checker<String>() { @Override public boolean check(final String s) { if (!SkriptYaml.YAML_STORE.containsKey(file.getSingle(event))) return false; return (SkriptYaml.YAML_STORE.get(file.getSingle(event)).getAllKeys().isEmpty()); } }, isNegated()); }
Example #13
Source File: CondYamlIsLoaded.java From skript-yaml with MIT License | 5 votes |
@Override public boolean check(final Event event) { return file.check(event, new Checker<String>() { @Override public boolean check(final String s) { if (!SkriptYaml.YAML_STORE.containsKey(file.getSingle(event))) return false; return true; } }, isNegated()); }
Example #14
Source File: EndermanData.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public boolean match(final Enderman entity) { return hand == null || SimpleExpression.check(hand, new Checker<ItemType>() { @SuppressWarnings("null") @Override public boolean check(final @Nullable ItemType t) { // TODO {Block/Material}Data -> Material conversion is not 100% accurate, needs a better solution if (useBlockData) return t != null && t.isOfType(entity.getCarriedBlock().getMaterial()); else return t != null && t.isOfType(entity.getCarriedMaterial().getItemType()); } }, false, false); }
Example #15
Source File: CondCompare.java From Skript with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public boolean check(final Event e) { final Expression<?> third = this.third; return first.check(e, (Checker<Object>) o1 -> second.check(e, (Checker<Object>) o2 -> { if (third == null) return relation.is(comp != null ? comp.compare(o1, o2) : Comparators.compare(o1, o2)); return third.check(e, (Checker<Object>) o3 -> relation == Relation.NOT_EQUAL ^ (Relation.GREATER_OR_EQUAL.is(comp != null ? comp.compare(o1, o2) : Comparators.compare(o1, o2)) && Relation.SMALLER_OR_EQUAL.is(comp != null ? comp.compare(o1, o3) : Comparators.compare(o1, o3)))); }), isNegated()); }
Example #16
Source File: CondRegionContains.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public boolean check(final Event e) { return regions.check(e, new Checker<Region>() { @Override public boolean check(final Region r) { return locs.check(e, new Checker<Location>() { @Override public boolean check(final Location l) { return r.contains(l); } }, isNegated()); } }); }
Example #17
Source File: SimpleExpression.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public final boolean check(final Event e, final Checker<? super T> c, final boolean negated) { return check(get(e), c, negated, getAnd()); }
Example #18
Source File: Variable.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public boolean check(final Event e, final Checker<? super T> c, final boolean negated) { return SimpleExpression.check(getAll(e), c, negated, getAnd()); }
Example #19
Source File: SimpleExpressionFork.java From skript-yaml with MIT License | 4 votes |
@Override public final boolean check(final Event e, final Checker<? super T> c) { return check(e, c, false); }
Example #20
Source File: EvtEntityBlockChange.java From Skript with GNU General Public License v3.0 | 4 votes |
private ChangeEvent(final String pattern, final Checker<EntityChangeBlockEvent> c) { this.pattern = pattern; checker = c; }
Example #21
Source File: SimpleLiteral.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public boolean check(final Event e, final Checker<? super T> c) { return SimpleExpression.check(data, c, false, getAnd()); }
Example #22
Source File: SimpleLiteral.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public boolean check(final Event e, final Checker<? super T> c, final boolean negated) { return SimpleExpression.check(data, c, negated, getAnd()); }
Example #23
Source File: SimpleExpressionFork.java From skript-yaml with MIT License | 4 votes |
@Override public final boolean check(final Event e, final Checker<? super T> c, final boolean negated) { return check(get(e), c, negated, getAnd()); }
Example #24
Source File: ConvertedExpression.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public boolean check(final Event e, final Checker<? super T> c, final boolean negated) { return negated ^ check(e, c); }
Example #25
Source File: Variable.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public boolean check(final Event e, final Checker<? super T> c) { return SimpleExpression.check(getAll(e), c, false, getAnd()); }
Example #26
Source File: VariableString.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public boolean check(final Event e, final Checker<? super String> c) { return SimpleExpression.check(getAll(e), c, false, false); }
Example #27
Source File: SimpleExpression.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public final boolean check(final Event e, final Checker<? super T> c) { return check(e, c, false); }
Example #28
Source File: ConvertedLiteral.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public boolean check(final Event e, final Checker<? super T> c, final boolean negated) { return SimpleExpression.check(data, c, negated, getAnd()); }
Example #29
Source File: ConvertedLiteral.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public boolean check(final Event e, final Checker<? super T> c) { return SimpleExpression.check(data, c, false, getAnd()); }
Example #30
Source File: UnparsedLiteral.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public boolean check(final Event e, final Checker<? super Object> c, final boolean negated) { throw invalidAccessException(); }