Java Code Examples for org.bukkit.event.Event

The following examples show how to use org.bukkit.event.Event. These examples are extracted from open source projects.
Example 1
Project: skRayFall   File: EffTabTitlesV1_9.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void execute(Event evt) {
    IChatBaseComponent header =
            ChatSerializer.a("{\"text\": \"" + coreHeader.getSingle(evt).replace("\"", "") + "\"}");
    IChatBaseComponent footer =
            ChatSerializer.a("{\"text\": \"" + coreFooter.getSingle(evt).replace("\"", "") + "\"}");
    PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();
    try {
        Field headerField = packet.getClass().getDeclaredField("a");
        headerField.setAccessible(true);
        headerField.set(packet, header);
        headerField.setAccessible(!headerField.isAccessible());

        Field footerField = packet.getClass().getDeclaredField("b");
        footerField.setAccessible(true);
        footerField.set(packet, footer);
        footerField.setAccessible(!footerField.isAccessible());
    } catch (Exception exception) {
        exception.printStackTrace();
    }
    ((CraftPlayer) player.getSingle(evt)).getHandle().playerConnection.sendPacket(packet);
}
 
Example 2
Project: skUtilities   File: ExprFromBin.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
@Nullable
protected String[] get(Event e) {
  String bin = str.getSingle(e);
  String binV = bin.trim();
  for (char character : binV.toCharArray()) {
    if (character != '0' && character != '1' && character != ' ') {
      skUtilities.prSysE("Binary Strings can only contain 1's, 0's or spaces!", getClass().getSimpleName());
      return null;
    }
  }
  if (ty == 0) {
    StringBuilder sb = new StringBuilder();
    for (String s : bin.split(" ")) {
      sb.append((char) Integer.parseInt(s, 2));
    }
    return new String[]{sb.toString()};
  } else if (ty == 1) {
    return new String[]{Integer.toString(Integer.parseInt(bin, 2))};
  } else if (ty == 2) {
    return new String[]{Integer.toHexString(Integer.parseInt(bin, 2))};
  } else {
    return new String[]{Integer.toOctalString(Integer.parseInt(bin, 2))};
  }
}
 
Example 3
Project: Skript   File: Variable.java    License: GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Nullable
private Object get(final Event e) {
	final Object val = getRaw(e);
	if (!list)
		return val;
	if (val == null)
		return Array.newInstance(types[0], 0);
	final List<Object> l = new ArrayList<>();
	final String name = StringUtils.substring(this.name.toString(e), 0, -1);
	for (final Entry<String, ?> v : ((Map<String, ?>) val).entrySet()) {
		if (v.getKey() != null && v.getValue() != null) {
			Object o;
			if (v.getValue() instanceof Map)
				o = ((Map<String, ?>) v.getValue()).get(null);
			else
				o = v.getValue();	
			l.add(convertIfOldPlayer(name + v.getKey(), e, o));
		}
	}
	return l.toArray();
}
 
Example 4
Project: skUtilities   File: ExprUrlResponseCode.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
@Nullable
protected Integer[] get(Event e) {
  try {
    HttpURLConnection.setFollowRedirects(false);
    HttpURLConnection c = (HttpURLConnection) new URL(url.getSingle(e)).openConnection();
    c.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11");
    c.setRequestMethod("HEAD");
    int r = c.getResponseCode();
    c.disconnect();
    return new Integer[]{r};
  } catch (Exception x) {
    skUtilities.prSysE("Error Reading from: '" + url.getSingle(e) + "' Is the site down?", getClass().getSimpleName(), x);
  }
  return null;
}
 
Example 5
Project: Skript   File: ExprSpectatorTarget.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void change(Event e, @Nullable Object[] delta, Changer.ChangeMode mode) {
	for (Player player : getExpr().getArray(e)) {
		if (player.getGameMode() == GameMode.SPECTATOR) {
			switch (mode) {
				case SET:
					assert delta != null;
					player.setSpectatorTarget((Entity) delta[0]);
					break;
				case RESET:
				case DELETE:
					player.setSpectatorTarget(null);
			}
		}
	}
}
 
Example 6
Project: Kettle   File: SimplePluginManager.java    License: GNU General Public License v3.0 5 votes vote down vote up
private Class<? extends Event> getRegistrationClass(Class<? extends Event> clazz) {
    try {
        clazz.getDeclaredMethod("getHandlerList");
        return clazz;
    } catch (NoSuchMethodException e) {
        if (clazz.getSuperclass() != null
                && !clazz.getSuperclass().equals(Event.class)
                && Event.class.isAssignableFrom(clazz.getSuperclass())) {
            return getRegistrationClass(clazz.getSuperclass().asSubclass(Event.class));
        } else {
            throw new IllegalPluginAccessException("Unable to find handler list for event " + clazz.getName() + ". Static getHandlerList method required!");
        }
    }
}
 
Example 7
Project: Skript   File: CondIsEnchanted.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean check(final Event e) {
	if (enchs != null)
		return items.check(e, item -> enchs.check(e, ench -> item.hasEnchantments(ench)), isNegated());
	else
		return items.check(e, ItemType::hasEnchantments, isNegated());
	
}
 
Example 8
Project: skUtilities   File: CondYamlExists.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean check(Event e) {
  File pth = new File(skUtilities.getDefaultPath(path.getSingle(e)));
  FileConfiguration con = YamlConfiguration.loadConfiguration(pth);
  Boolean v = con.contains(yaml.getSingle(e));
  return (isNegated() ? !v : v);
}
 
Example 9
Project: VoxelGamesLibv2   File: EventHandler.java    License: MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public <T extends Event> void callEvent(@Nonnull T event) {
    Class<Event> eventClass = (Class<Event>) event.getClass();
    while (!eventClass.equals(Object.class)) {
        if (activeEvents.containsKey(eventClass)) {
            activeEvents.get(eventClass).forEach(registeredListener -> {
                Optional<User> user = Optional.empty();
                boolean tried = false;
                for (EventFilter filter : registeredListener.getFilters()) {
                    if (!user.isPresent() && !tried) {
                        user = figureOutUser(event);
                        tried = true;
                    }
                    if (!filter.filter(event, registeredListener, user)) {
                        return;
                    }
                }

                try {
                    if (registeredListener.getMethod().getParameterCount() == 2) {
                        registeredListener.getMethod().invoke(registeredListener.getListener(), event, user.orElse(null));
                    } else {
                        registeredListener.getMethod().invoke(registeredListener.getListener(), event);
                    }
                } catch (IllegalAccessException | InvocationTargetException e) {
                    log.log(Level.SEVERE, "Error while calling eventhandler!", e);
                }
            });
            break;
        } else {
            eventClass = (Class<Event>) eventClass.getSuperclass();
        }
    }
}
 
Example 10
Project: skRayFall   File: EffParticlesV1_8_4.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void execute(Event evt) {
    float hx = 0f;
    float hy = 0f;
    float hz = 0f;
    float id = 0;
    int[] array = new int[0];
    if (xoffset != null) {
        hx = xoffset.getSingle(evt).floatValue();
    }
    if (yoffset != null) {
        hy = yoffset.getSingle(evt).floatValue();
    }
    if (zoffset != null) {
        hz = zoffset.getSingle(evt).floatValue();
    }
    String core = type.getSingle(evt);
    if (core.toUpperCase().replace(" ", "_").contains("BLOCK_CRACK")
            || core.toUpperCase().replace(" ", "_").contains("BLOCK_DUST")) {
        int index = type.getSingle(evt).lastIndexOf("_");
        try {
            id = Integer.parseInt(type.getSingle(evt).substring(index + 1));
        } catch (Exception exception) {
            Skript.error("Could not parse datavalue!");
            id = 0;
        }
        core = core.substring(0, index);
        array = new int[1];
    }
    EnumParticle part = PacketParticleGetterV1_8_4.get(core);

    PacketPlayOutWorldParticles packet =
            new PacketPlayOutWorldParticles(part, true, (float) location.getSingle(evt).getX(),
                    (float) location.getSingle(evt).getY(), (float) location.getSingle(evt).getZ(), hx, hy,
                    hz, id, partNum.getSingle(evt).intValue(), array);
    ((CraftPlayer) player.getSingle(evt)).getHandle().playerConnection.sendPacket(packet);
}
 
Example 11
Project: PerWorldInventory   File: WorldInventoriesDupingPatch.java    License: GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onCreativeSlotChange(InventoryCreativeEvent event) {
    if (timeouts.isEmpty()) {
        return; // Saves performance for most common case
    }
    InventoryHolder holder = event.getInventory().getHolder();
    if (holder instanceof Player && timeouts.containsKey(((Player) holder).getUniqueId())) {
        event.setResult(Event.Result.DENY);
    }
}
 
Example 12
Project: skUtilities   File: ExprFileDirSize.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
@Nullable
protected String[] get(Event e) {
  Path pth = Paths.get(skUtilities.getDefaultPath(path.getSingle(e)));
  try {
    if (ty == 0) {
      return new String[]{skUtilities.getFileSize(Files.size(pth))};
    } else {
      return new String[]{skUtilities.getFileSize(FileUtils.sizeOfDirectory(pth.toFile()))};
    }
  } catch (Exception x) {
    skUtilities.prSysE("'" + pth + "' doesn't exist!", getClass().getSimpleName());
  }
  return null;
}
 
Example 13
Project: skript-yaml   File: CondYamlIsLoaded.java    License: MIT License 5 votes vote down vote up
@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
Project: Skript   File: CondCanBuild.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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 15
Project: Skript   File: ExprDifficulty.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
	if (delta == null)
		return;
	
	Difficulty difficulty = (Difficulty) delta[0];
	for (World world : getExpr().getArray(e)) {
		world.setDifficulty(difficulty);
	}
}
 
Example 16
Project: skRayFall   File: EffCitizenAttack.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void execute(Event evt) {
    NPCRegistry registry = CitizensAPI.getNPCRegistry();
    NPC attacker = registry.getById(id.getSingle(evt).intValue());
    if (attacker != null) {
        attacker.getNavigator().setTarget(toBeAttacked.getSingle(evt), true);
    }
}
 
Example 17
Project: skRayFall   File: EvtUnscope.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean check(Event evt) {
    if (evt instanceof WeaponScopeEvent && !((WeaponScopeEvent) evt).isZoomIn()) {
        return true;
    } else {
        return false;
    }
}
 
Example 18
Project: skUtilities   File: CondIsFile.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean check(Event e) {
  Path pth = Paths.get(skUtilities.getDefaultPath(path.getSingle(e)));
  if (!Files.exists(pth)) return false;
  Boolean b = !Files.isRegularFile(pth);
  return (isNegated() ? !b : b);
}
 
Example 19
Project: skRayFall   File: ExprCitizenIdFromEntity.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
@Nullable
protected Number[] get(Event evt) {
    if (entity.getSingle(evt) != null && entity.getSingle(evt).hasMetadata("NPC")) {
        NPCRegistry registry = CitizensAPI.getNPCRegistry();
        return new Number[]{registry.getNPC(entity.getSingle(evt)).getId()};
    }
    return null;
}
 
Example 20
Project: Skript   File: EffMakeFly.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void execute(Event e) {
	for (Player player : players.getArray(e)) {
		player.setAllowFlight(flying);
		player.setFlying(flying);
	}
}
 
Example 21
Project: ce   File: Gooey.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void effect(Event e, ItemStack item, final int level) {
	final EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;

	new BukkitRunnable() {

		@Override
		public void run() {
			event.getEntity().setVelocity(event.getEntity().getVelocity().setY((strength * level * 0.05) + 0.75));
			event.getEntity().getWorld().playEffect(event.getEntity().getLocation(), Effect.SMOKE, 60);
		}
	}.runTaskLater(getPlugin(), 1l);
}
 
Example 22
Project: Skript   File: ExprEnchantmentLevel.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
	if (delta == null)
		return;
	
	ItemType[] source = items.getArray(e);
	Enchantment[] enchantments = enchants.getArray(e);
	int newLevel = ((Number) delta[0]).intValue();
	
	for (ItemType item : source) {
		if (!item.hasAnyEnchantments(enchantments))
			continue;
		
		EnchantmentType[] enchants = item.getEnchantmentTypes();
		assert enchants != null; // Can't be null at this point due to the above check
		for (EnchantmentType enchant : enchants) {
			item.removeEnchantments(enchant);
			Enchantment type = enchant.getType();
			int changed = newLevel;
			assert type != null;
			
			if (mode == ChangeMode.ADD)
				changed = Math.max(0, enchant.getLevel() + changed);
			else if (mode == ChangeMode.REMOVE)
				changed = Math.max(0, enchant.getLevel() - changed);
			
			if (changed > 0)
				item.addEnchantments(new EnchantmentType(type, newLevel));
		}
	}
}
 
Example 23
Project: skript-yaml   File: SimpleExpressionFork.java    License: MIT License 5 votes vote down vote up
protected final boolean setTime(final int time, final Class<? extends Event> applicableEvent, final Expression<?>... mustbeDefaultVars) {
	if (ScriptLoader.hasDelayBefore == Kleenean.TRUE && time != 0) {
		Skript.error("Can't use time states after the event has already passed");
		return false;
	}
	if (!ScriptLoader.isCurrentEvent(applicableEvent))
		return false;
	for (final Expression<?> var : mustbeDefaultVars) {
		if (!var.isDefault()) {
			return false;
		}
	}
	this.time = time;
	return true;
}
 
Example 24
Project: Skript   File: ExprBlocksInRegion.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
@NonNull
public Iterator<Block> iterator(final Event e) {
	final Region[] rs = regions.getArray(e);
	if (rs.length == 0)
		return EmptyIterator.get();
	return new Iterator<Block>() {
		private Iterator<Block> current = rs[0].getBlocks();
		private final Iterator<Region> iter = new ArrayIterator<>(rs, 1);
		
		@Override
		public boolean hasNext() {
			while (!current.hasNext() && iter.hasNext()) {
				final Region r = iter.next();
				if (r != null)
					current = r.getBlocks();
			}
			return current.hasNext();
		}
		
		@SuppressWarnings("null")
		@Override
		public Block next() {
			if (!hasNext())
				throw new NoSuchElementException();
			return current.next();
		}
		
		@Override
		public void remove() {
			throw new UnsupportedOperationException();
		}
	};
}
 
Example 25
Project: Skript   File: ExprLocationVectorOffset.java    License: GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("null")
@Override
protected Location[] get(Event e) {
	Location l = location.getSingle(e);
	if (l == null)
		return null;
	Location clone = l.clone();
	for (Vector v : vectors.getArray(e))
		clone.add(v);
	return CollectionUtils.array(clone);
}
 
Example 26
Project: Skript   File: ExprCreeperMaxFuseTicks.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) {
	int d = delta == null ? 0 : ((Number) delta[0]).intValue();
	for (LivingEntity le : getExpr().getArray(e)) {
		if (le instanceof Creeper) {
			Creeper c = (Creeper) le;
			switch (mode) {
				case ADD:
					int r1 = c.getMaxFuseTicks() + d;
					if (r1 < 0) r1 = 0;
					c.setMaxFuseTicks(r1);
					break;
				case SET:
					c.setMaxFuseTicks(d);
					break;
				case DELETE:
					c.setMaxFuseTicks(0);
					break;
				case RESET:
					c.setMaxFuseTicks(30); //Seems to be the same for powered creepers?
					break;
				case REMOVE:
					int r2 = c.getMaxFuseTicks() - d;
					if (r2 < 0) r2 = 0;
					c.setMaxFuseTicks(r2);
					break;
				case REMOVE_ALL:
					assert false;		
			}
		}
	}
}
 
Example 27
Project: HeavySpleef   File: PlayerPostActionHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
public <T extends Event> void addPostAction(SpleefPlayer player, Class<T> event, PostActionCallback<T> callback, Object cookie) {
	Validate.notNull(player, "player cannot be null");
	Validate.notNull(event, "event class cannot be null");
	Validate.notNull(callback, "callback cannot be null");
	
	PostDataContainer<T> container = new PostDataContainer<T>(event, callback, cookie);
	awaitingPostAction.put(player, container);
}
 
Example 28
Project: skRayFall   File: EffEffectLibWave.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void execute(Event evt) {
    Object tar = target.getSingle(evt);
    WaveEffect effect = new WaveEffect(Core.effectManager);
    if (tar instanceof Entity) {
        effect.setDynamicOrigin(new DynamicLocation((Entity) tar));
        if (particle != null) {
            effect.particle = particle.getSingle(evt);
        }
        effect.infinite();
        effect.start();
        Boolean check = Core.rayfallEffectManager.setEffect(effect, id.getSingle(evt).replace("\"", ""));
        if (!check) {
            effect.cancel();
        }
    } else if (tar instanceof Location) {
        effect.setDynamicOrigin(new DynamicLocation((Location) tar));
        effect.infinite();
        if (particle != null) {
            effect.particle = particle.getSingle(evt);
        }
        effect.start();
        Boolean check = Core.rayfallEffectManager.setEffect(effect, id.getSingle(evt).replace("\"", ""));
        if (!check) {
            effect.cancel();
        }
    } else {
        assert false;
    }
}
 
Example 29
Project: Skript   File: ExprSpawn.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) {
	assert mode == ChangeMode.SET;
	assert delta != null;
	
	final Location l = (Location) delta[0];
	final int x = l.getBlockX(), y = l.getBlockY(), z = l.getBlockZ();
	for (final World w : getExpr().getArray(e)) {
		w.setSpawnLocation(x, y, z);
	}
}
 
Example 30
Project: ProjectAres   File: DamageMatchModule.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Query the custom damage filters with the given damage event
 */
public Filter.QueryResponse queryRules(Event event, ParticipantState victim, DamageInfo damageInfo) {
    IQuery query = getQuery(event, victim, damageInfo);

    for(Filter filter : filters) {
        Filter.QueryResponse response = filter.query(query);
        if(response != Filter.QueryResponse.ABSTAIN) return response;
    }

    return Filter.QueryResponse.ABSTAIN;
}
 
Example 31
Project: Skript   File: ExprAbsorbedBlocks.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
@Nullable
public Iterator<BlockStateBlock> iterator(Event e) {
	List<BlockState> bs = ((SpongeAbsorbEvent) e).getBlocks();
	return bs.stream()
		.map(BlockStateBlock::new)
		.iterator();
}
 
Example 32
Project: skRayFall   File: EffChangeBossBarColor.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void execute(Event evt) {
    Core.bossbarManager.changeColor(id.getSingle(evt).replace("\"", ""),
            color.getSingle(evt).getKey());
}
 
Example 33
Project: skUtilities   File: CondIsExecutable.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean check(Event e) {
  Boolean pth = Files.isExecutable(Paths.get(skUtilities.getDefaultPath(path.getSingle(e))));
  return (isNegated() ? !pth : pth);
}
 
Example 34
Project: Skript   File: EffCancelEvent.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public String toString(final @Nullable Event e, final boolean debug) {
	return (cancel ? "" : "un") + "cancel event";
}
 
Example 35
Project: ProjectAres   File: BlockEventQuery.java    License: GNU Affero General Public License v3.0 4 votes vote down vote up
public BlockEventQuery(Event event, World world, int x, int y, int z, @Nullable BlockState block) {
    super(world, x, y, z, block);
    this.event = checkNotNull(event);
}
 
Example 36
Project: Skript   File: ExprAttacker.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public String toString(final @Nullable Event e, final boolean debug) {
	if (e == null)
		return "the attacker";
	return Classes.getDebugMessage(getSingle(e));
}
 
Example 37
Project: skRayFall   File: EffSetBossBar.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public String toString(@Nullable Event arg0, boolean arg1) {
    return null;
}
 
Example 38
Project: Skript   File: ExprNamed.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public String toString(final @Nullable Event e, final boolean debug) {
	return getExpr().toString(e, debug) + " named " + name;
}
 
Example 39
Project: Skript   File: ExprEntities.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
@Nullable
@SuppressWarnings("null")
public Iterator<? extends Entity> iterator(Event e) {
	if (isUsingRadius) {
		assert center != null;
		Location l = center.getSingle(e);
		if (l == null)
			return null;
		assert radius != null;
		Number n = radius.getSingle(e);
		if (n == null)
			return null;
		double d = n.doubleValue();

		Collection<Entity> es = l.getWorld().getNearbyEntities(l, d, d, d);
		double radiusSquared = d * d * Skript.EPSILON_MULT;
		EntityData<?>[] ts = types.getAll(e);
		return new CheckedIterator<>(es.iterator(), e1 -> {
				if (e1 == null || e1.getLocation().distanceSquared(l) > radiusSquared)
					return false;
				for (EntityData<?> t : ts) {
					if (t.isInstance(e1))
						return true;
				}
				return false;
			});
	} else {
		if (worlds == null && returnType == Player.class)
			return super.iterator(e);

		return new NonNullIterator<Entity>() {
				private World[] ws = worlds == null ? Bukkit.getWorlds().toArray(new World[0]) : worlds.getArray(e);
				private EntityData<?>[] ts = types.getAll(e);
				private int w = -1;
				@Nullable
				private Iterator<? extends Entity> curIter = null;

				@Override
				@Nullable
				protected Entity getNext() {
					while (true) {
						while (curIter == null || !curIter.hasNext()) {
							w++;
							if (w == ws.length)
								return null;
							curIter = ws[w].getEntitiesByClass(returnType).iterator();
						}
						while (curIter.hasNext()) {
							Entity current = curIter.next();
							for (EntityData<?> t : ts) {
								if (t.isInstance(current))
									return current;
							}
						}
					}
				}};
	}
}
 
Example 40
Project: Skript   File: ExprItemWithLore.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public String toString(@Nullable Event e, boolean debug) {
	return getExpr().toString(e, debug) + " with lore " + lore.toString(e, debug);
}