Java Code Examples for ch.njol.skript.classes.Changer.ChangeMode#RESET
The following examples show how to use
ch.njol.skript.classes.Changer.ChangeMode#RESET .
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: EffChange.java From Skript with GNU General Public License v3.0 | 6 votes |
@Override protected void execute(final Event e) { final Expression<?> changer = this.changer; Object[] delta = changer == null ? null : changer.getArray(e); delta = changer == null ? delta : changer.beforeChange(changed, delta); if (delta != null && delta.length == 0) return; if (delta == null && (mode != ChangeMode.DELETE && mode != ChangeMode.RESET)) return; changed.change(e, delta, mode); // Trigger beforeChanged hook // REMIND use a random element out of delta if changed only supports changing a single instance // changed.change(e, new Changer2<Object>() { // @Override // public Object change(Object o) { // return delta; // } // }, mode); }
Example 2
Source File: ExprName.java From Skript with GNU General Public License v3.0 | 6 votes |
@Override @Nullable public Class<?>[] acceptChange(ChangeMode mode) { if (mode == ChangeMode.DELETE && (type.acceptChange & ~PLAYER) != 0 || mode == ChangeMode.RESET) return new Class[0]; if (mode != ChangeMode.SET) return null; if ((type.acceptChange & PLAYER) != 0 && Player.class.isAssignableFrom(getExpr().getReturnType())) { changeType = PLAYER; } else if ((type.acceptChange & INVENTORY) != 0 && Inventory.class.isAssignableFrom(getExpr().getReturnType())) { changeType = INVENTORY; } else if ((type.acceptChange & ITEM) != 0 && (getExpr().isSingle() && ChangerUtils.acceptsChange(getExpr(), ChangeMode.SET, ItemStack.class, ItemType.class) || Slot.class.isAssignableFrom(getExpr().getReturnType()))) { changeType = ITEM; } else if ((type.acceptChange & ENTITY) != 0 && Entity.class.isAssignableFrom(getExpr().getReturnType())) { if (type == NameType.NAME && Player.class.isAssignableFrom(getExpr().getReturnType())) { Skript.error("Can't change the Minecraft name of a player. Change the 'display name' or 'tab list name' instead."); return null; } changeType = ENTITY; } return changeType == 0 ? null : CollectionUtils.array(String.class); }
Example 3
Source File: ExprItem.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override @Nullable public Class<?>[] acceptChange(final ChangeMode mode) { if (mode == ChangeMode.RESET) return null; item = new EventValueExpression<>(Item.class); if (item.init()) return new Class[] {ItemType.class}; item = null; slot = new EventValueExpression<>(Slot.class); if (slot.init()) return new Class[] {ItemType.class}; slot = null; return null; }
Example 4
Source File: ExprGlidingState.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) return new Class[] {Boolean.class}; return null; }
Example 5
Source File: ExprGameMode.java From Skript with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") @Override @Nullable public Class<?>[] acceptChange(final ChangeMode mode) { if (mode == ChangeMode.SET || mode == ChangeMode.RESET) return CollectionUtils.array(GameMode.class); return null; }
Example 6
Source File: ExprCompassTarget.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) return new Class[] {Location.class}; return null; }
Example 7
Source File: ExprHoverList.java From Skript with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("null") @Override public void change(Event e, @Nullable Object[] delta, ChangeMode mode) { List<PlayerProfile> values = new ArrayList<>(); if (mode != ChangeMode.DELETE && mode != ChangeMode.RESET) { for (Object o : delta) { if (o instanceof Player) { Player player = ((Player) o); values.add(Bukkit.createProfile(player.getUniqueId(), player.getName())); } else { values.add(Bukkit.createProfile(UUID.randomUUID(), (String) o)); } } } List<PlayerProfile> sample = ((PaperServerListPingEvent) e).getPlayerSample(); switch (mode){ case SET: sample.clear(); sample.addAll(values); break; case ADD: sample.addAll(values); break; case REMOVE: sample.removeAll(values); break; case DELETE: case RESET: sample.clear(); } }
Example 8
Source File: ExprServerIcon.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override @Nullable public Class<?>[] acceptChange(ChangeMode mode) { if (isServerPingEvent && !isDefault) { if (ScriptLoader.hasDelayBefore.isTrue()) { Skript.error("Can't change the server icon anymore after the server list ping event has already passed"); return null; } if (mode == ChangeMode.SET || mode == ChangeMode.RESET) return CollectionUtils.array(CachedServerIcon.class); } return null; }
Example 9
Source File: ExprPlayerWeather.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override @Nullable public Class<?>[] acceptChange(final ChangeMode mode) { if (mode == ChangeMode.RESET || mode == ChangeMode.SET) return CollectionUtils.array(WeatherType.class); return null; }
Example 10
Source File: ExprEntityTamer.java From Skript with GNU General Public License v3.0 | 5 votes |
@Nullable @Override public Class<?>[] acceptChange(ChangeMode mode) { if (mode == ChangeMode.SET || mode == ChangeMode.DELETE || mode == ChangeMode.RESET) return CollectionUtils.array(OfflinePlayer.class); return null; }
Example 11
Source File: ExprGravity.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) return new Class[] {Boolean.class}; return null; }
Example 12
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 13
Source File: ExprSpawnerType.java From Skript with GNU General Public License v3.0 | 5 votes |
@Nullable @Override public Class<?>[] acceptChange(Changer.ChangeMode mode) { if (mode == ChangeMode.SET || mode == ChangeMode.RESET) return CollectionUtils.array(EntityData.class); return null; }
Example 14
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 15
Source File: ExprChunk.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override @Nullable public Class<?>[] acceptChange(final ChangeMode mode) { if (mode == ChangeMode.RESET) return new Class[0]; return null; }
Example 16
Source File: ExprGlowing.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) return new Class[] {Boolean.class}; return null; }
Example 17
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)); } } } }