@Override public Iterator<Block> iterator(Event e) { Location p1 = pos1.getSingle(e); Location p2 = pos2.getSingle(e); if (p1 == null || p2 == null) return new EmptyIterator<>(); return new CuboidIterator(p1, p2); }
@Override protected JSONMessage[] get(Event event) { JSONMessage j = json.getSingle(event); String a = append.getSingle(event); if (j == null || a == null) return null; return Collect.asArray(j.link(a)); }
@SuppressWarnings("deprecation") @Override protected void execute(Event e) { Location pos1 = location1.getSingle(e); Location pos2 = location2.getSingle(e); EditSession session = editSession.getSingle(e); ItemStack[] blocks = blockList.getAll(e); RandomPattern random = new RandomPattern(); if (session == null) return; for (ItemStack b : blocks) { if (b.getType().isBlock()) { random.add(new BlockPattern(new BaseBlock(b.getTypeId(), b.getDurability())), 50); } } try { session.makeWalls( new CuboidRegion( (World) BukkitUtil.getLocalWorld(pos1.getWorld()), BukkitUtil.toVector(pos1), BukkitUtil.toVector(pos2)), Patterns.wrap(random)); session.flushQueue(); } catch (WorldEditException ex) { if (ex instanceof MaxChangedBlocksException) return; else ex.printStackTrace(); } }
@Override protected void execute(Event event) { Player player = eplayer.getSingle(event); String path = epath.getSingle(event); String line1 = eline1.getSingle(event); String line2 = eline2.getSingle(event); String line3 = eline3.getSingle(event); ImgInChat.ShowImgFromURL(player, path, line1, line2, line3); }
@Override protected Block[] get(Event event) { Location p1 = pos1.getSingle(event); Location p2 = pos2.getSingle(event); if (p1 == null || p2 == null) return null; List<Block> list = new ArrayList<>(); for (Block b : new IteratorIterable<>(iterator(event))) { list.add(b); } return list.toArray(new Block[list.size()]); }
@Override protected void execute(Event event) { String u = url.getSingle(event); if (u == null) return; for (Player p : target.getAll(event)) { p.setResourcePack(u); } }
@Override protected void execute(Event event) { Location l = location.getSingle(event); Player p = player.getSingle(event); if (l == null) { return; } else if (p == null) { return; } Location loc = p.getLocation().clone(); Inventory inv = p.getInventory(); for (ItemStack item : inv.getContents()) { if (item != null) { loc.getWorld().dropItem(l, item.clone()); } } inv.clear(); }
@Override protected ItemStack[] get(Event e) { PotionEffectType p = effect.getSingle(e); if (p == null) return null; ItemStack potion = new Potion(PotionType.getByEffect(p)).toItemStack(1); PotionMeta meta = ((PotionMeta) potion.getItemMeta()); meta.addCustomEffect(new PotionEffect(p, 0, 0), true); potion.setItemMeta(meta); return Collect.asArray(potion); }
@Override protected Boolean[] get(Event e) { Comparator.Relation r = Comparators.compare(first.getSingle(e), second.getSingle(e)); switch (match) { case 0: return Collect.asArray(Comparator.Relation.EQUAL.is(r)); case 1: return Collect.asArray((first.getSingle(e) + "").equals(second.getSingle(e) + "")); case 2: return Collect.asArray(Comparator.Relation.GREATER.is(r)); case 3: return Collect.asArray(Comparator.Relation.SMALLER.is(r)); case 4: return Collect.asArray(Comparator.Relation.GREATER_OR_EQUAL.is(r)); case 5: return Collect.asArray(Comparator.Relation.SMALLER_OR_EQUAL.is(r)); } return null; }
@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 e) { e.printStackTrace(); } ((CraftPlayer) player.getSingle(evt)).getHandle().playerConnection.sendPacket(packet); }
@Override @javax.annotation.Nullable protected Entity[] get(Event arg0) { Entity returnEnt = null; for (World w : Bukkit.getWorlds()) { for (Entity e : w.getEntities()) { if (e.getUniqueId().toString() == uuid.getSingle(arg0)) { return new Entity[] {e}; } } } return null; }
@Override protected void execute(Event event) { ParticleEnum particlename = particleName.getSingle(event); Number offx = this.offx.getSingle(event); Number offy = this.offy.getSingle(event); Number offz = this.offz.getSingle(event); Number speed = this.speed.getSingle(event); Location[] loc = this.locations.getAll(event); Integer count = this.count.getSingle(event).intValue(); Integer data = this.data.getSingle(event).intValue(); Integer secondaryData = this.secondaryData.getSingle(event).intValue(); if (particlename == null) { return; } ParticleFunction.spawnParticle( count, particlename, speed, offx, offy, offz, loc, data, secondaryData); }
@Override public boolean check(Event event) { return isNegated() ? !item.getSingle(event).hasBlock() : item.getSingle(event).hasBlock(); }
@Override public String toString(Event event, boolean b) { return json.getSingle(event).toOldMessageFormat(); }