Java Code Examples for ch.njol.skript.classes.Changer.ChangeMode#ADD
The following examples show how to use
ch.njol.skript.classes.Changer.ChangeMode#ADD .
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: ExprSpeed.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override @Nullable public Class<?>[] acceptChange(final ChangeMode mode) { if (mode == ChangeMode.SET || mode == ChangeMode.RESET || mode == ChangeMode.ADD || mode == ChangeMode.REMOVE) return new Class[] {Number.class}; return null; }
Example 2
Source File: ExprCoordinate.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override @Nullable public Class<?>[] acceptChange(final ChangeMode mode) { if ((mode == ChangeMode.SET || mode == ChangeMode.ADD || mode == ChangeMode.REMOVE) && getExpr().isSingle() && ChangerUtils.acceptsChange(getExpr(), ChangeMode.SET, Location.class)) return new Class[] {Number.class}; return null; }
Example 3
Source File: ExprVelocity.java From Skript with GNU General Public License v3.0 | 5 votes |
@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 4
Source File: ExprYawPitch.java From Skript with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings({"null"}) @Override public Class<?>[] acceptChange(final ChangeMode mode) { if (mode == ChangeMode.SET || mode == ChangeMode.ADD || mode == ChangeMode.REMOVE) return CollectionUtils.array(Number.class); return null; }
Example 5
Source File: ExprVectorXYZ.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override @SuppressWarnings("null") public Class<?>[] acceptChange(ChangeMode mode) { if ((mode == ChangeMode.ADD || mode == ChangeMode.REMOVE || mode == ChangeMode.SET) && getExpr().isSingle() && Changer.ChangerUtils.acceptsChange(getExpr(), ChangeMode.SET, Vector.class)) return CollectionUtils.array(Number.class); return null; }
Example 6
Source File: ExprVectorYawPitch.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override @SuppressWarnings("null") public Class<?>[] acceptChange(ChangeMode mode) { if ((mode == ChangeMode.SET || mode == ChangeMode.ADD || mode == ChangeMode.REMOVE) && getExpr().isSingle() && Changer.ChangerUtils.acceptsChange(getExpr(), ChangeMode.SET, Vector.class)) return CollectionUtils.array(Number.class); return null; }
Example 7
Source File: ExprVectorLength.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override @SuppressWarnings("null") public Class<?>[] acceptChange(ChangeMode mode) { if (mode == ChangeMode.ADD || mode == ChangeMode.REMOVE || mode == ChangeMode.SET) return CollectionUtils.array(Number.class); return null; }
Example 8
Source File: ExprYaml.java From skript-yaml with MIT License | 4 votes |
@Override public void change(Event event, Object[] delta, Changer.ChangeMode mode) { final String name = this.file.getSingle(event); final String path = this.node.getSingle(event); if (!SkriptYaml.YAML_STORE.containsKey(name)) { SkriptYaml.warn("No yaml by the name '" + name + "' has been loaded"); return; } YAMLProcessor config = SkriptYaml.YAML_STORE.get(name); if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) { config.removeProperty(path); return; } if (state == YamlState.VALUE) { if (mode == ChangeMode.SET) config.setProperty(path, parseString(delta[0])); } else if (state == YamlState.NODE_KEYS) { if (mode == ChangeMode.ADD) config.setProperty(path + (delta[0] == null ? "" : "." + delta[0]), null); //config.addNode(path + (delta[0] == null ? "" : "." + delta[0])); else if (mode == ChangeMode.REMOVE) config.removeProperty(path + (delta[0] == null ? "" : "." + delta[0])); //config.setProperty(path + (delta[0] == null ? "" : "." + delta[0]), null); } else if (state == YamlState.LIST) { List<Object> objects = config.getList(path); if (mode == ChangeMode.ADD) { if (objects == null) config.setProperty(path, arrayToList(new LinkedList<Object>(), delta)); else config.setProperty(path, arrayToList(objects, delta)); } else if (mode == ChangeMode.REMOVE) { for (Object o : delta) objects.remove(parseString(o)); } else if (mode == ChangeMode.SET) { if (objects == null) { config.setProperty(path, arrayToList(new LinkedList<Object>(), delta)); } else { objects.clear(); config.setProperty(path, arrayToList(objects, delta)); } } } }