Java Code Examples for ch.njol.skript.Skript#checkAcceptRegistrations()
The following examples show how to use
ch.njol.skript.Skript#checkAcceptRegistrations() .
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: Classes.java From Skript with GNU General Public License v3.0 | 6 votes |
/** * @param info info about the class to register */ public static <T> void registerClass(final ClassInfo<T> info) { try { Skript.checkAcceptRegistrations(); if (classInfosByCodeName.containsKey(info.getCodeName())) throw new IllegalArgumentException("Can't register " + info.getC().getName() + " with the code name " + info.getCodeName() + " because that name is already used by " + classInfosByCodeName.get(info.getCodeName())); if (exactClassInfos.containsKey(info.getC())) throw new IllegalArgumentException("Can't register the class info " + info.getCodeName() + " because the class " + info.getC().getName() + " is already registered"); if (info.getCodeName().length() > DatabaseStorage.MAX_CLASS_CODENAME_LENGTH) throw new IllegalArgumentException("The codename '" + info.getCodeName() + "' is too long to be saved in a database, the maximum length allowed is " + DatabaseStorage.MAX_CLASS_CODENAME_LENGTH); exactClassInfos.put(info.getC(), info); classInfosByCodeName.put(info.getCodeName(), info); tempClassInfos.add(info); } catch (RuntimeException e) { if (SkriptConfig.apiSoftExceptions.value()) Skript.warning("Ignored an exception due to user configuration: " + e.getMessage()); else throw e; } }
Example 2
Source File: EventValues.java From Skript with GNU General Public License v3.0 | 5 votes |
/** * Same as {@link #registerEventValue(Class, Class, Getter, int)} * * @param e * @param c * @param g * @param time * @param excludes Subclasses of the event for which this event value should not be registered for */ public static <T, E extends Event> void registerEventValue(final Class<E> e, final Class<T> c, final Getter<T, E> g, final int time, final @Nullable String excludeErrorMessage, final @Nullable Class<? extends E>... excludes) { Skript.checkAcceptRegistrations(); final List<EventValueInfo<?, ?>> eventValues = getEventValuesList(time); for (int i = 0; i < eventValues.size(); i++) { final EventValueInfo<?, ?> info = eventValues.get(i); if (info.event != e ? info.event.isAssignableFrom(e) : info.c.isAssignableFrom(c)) { eventValues.add(i, new EventValueInfo<E, T>(e, c, g, excludeErrorMessage, excludes)); return; } } eventValues.add(new EventValueInfo<E, T>(e, c, g, excludeErrorMessage, excludes)); }
Example 3
Source File: Converters.java From Skript with GNU General Public License v3.0 | 5 votes |
public static <F, T> void registerConverter(final Class<F> from, final Class<T> to, final Converter<F, T> converter, final int options) { Skript.checkAcceptRegistrations(); final ConverterInfo<F, T> info = new ConverterInfo<>(from, to, converter, options); for (int i = 0; i < converters.size(); i++) { final ConverterInfo<?, ?> info2 = converters.get(i); if (info2.from.isAssignableFrom(from) && to.isAssignableFrom(info2.to)) { converters.add(i, info); return; } } converters.add(info); }
Example 4
Source File: Functions.java From Skript with GNU General Public License v3.0 | 5 votes |
/** * Registers a function written in Java. * @param function * @return The passed function */ public static JavaFunction<?> registerFunction(JavaFunction<?> function) { Skript.checkAcceptRegistrations(); String name = function.getName(); if (!name.matches(functionNamePattern)) throw new SkriptAPIException("Invalid function name '" + name + "'"); javaNamespace.addSignature(function.getSignature()); javaNamespace.addFunction(function); globalFunctions.put(function.getName(), javaNamespace); return function; }
Example 5
Source File: Comparators.java From Skript with GNU General Public License v3.0 | 3 votes |
/** * Registers a {@link Comparator}. * * @param t1 * @param t2 * @param c * @throws IllegalArgumentException if any given class is equal to <code>Object.class</code> */ public static <T1, T2> void registerComparator(final Class<T1> t1, final Class<T2> t2, final Comparator<T1, T2> c) { Skript.checkAcceptRegistrations(); if (t1 == Object.class && t2 == Object.class) throw new IllegalArgumentException("You must not add a comparator for Objects"); comparators.add(new ComparatorInfo<T1, T2>(t1, t2, c)); }