Package ch.njol.skript.aliases

Examples of ch.njol.skript.aliases.ItemType


      if ((Converters.convert((ItemType[]) exprs[0].getAll(), ItemType.class, new Converter<ItemType, ItemType>() {
        @SuppressWarnings("deprecation")
        @Override
        @Nullable
        public ItemType convert(final ItemType t) {
          ItemType r = null;
          for (final ItemData d : t.getTypes()) {
            if (d.getId() == Material.POTION.getId()) {
              if (r == null)
                r = new ItemType(d);
              else
                r.add(d);
            }
          }
          return r;
        }
      })).length == 0) {
View Full Code Here


  protected boolean init(final @Nullable Class<? extends ThrownPotion> c, final @Nullable ThrownPotion e) {
    if (e != null) {
      final ItemStack i = e.getItem();
      if (i == null)
        return false;
      types = new ItemType[] {new ItemType(i)};
    }
    return true;
  }
View Full Code Here

  }
 
  @Override
  public void set(final ThrownPotion entity) {
    if (types != null) {
      final ItemType t = CollectionUtils.getRandom(types);
      assert t != null;
      entity.setItem(t.getRandom());
    }
  }
View Full Code Here

 
  @SuppressWarnings("deprecation")
  @Override
  protected boolean init(final @Nullable Class<? extends FallingBlock> c, final @Nullable FallingBlock e) {
    if (e != null)
      types = new ItemType[] {new ItemType(e.getBlockId(), e.getBlockData())};
    return true;
  }
View Full Code Here

  }
 
  @Override
  @Nullable
  public FallingBlock spawn(final Location loc) {
    final ItemType t = CollectionUtils.getRandom(types);
    assert t != null;
    final ItemStack i = t.getRandom();
    if (i == null || i.getType() == Material.AIR || !i.getType().isBlock()) {
      assert false : i;
      return null;
    }
    return loc.getWorld().spawnFallingBlock(loc, i.getType(), (byte) i.getDurability());
View Full Code Here

            for (final Node n : node) {
              if (!(n instanceof EntryNode)) {
                Skript.error("invalid line in aliases section");
                continue;
              }
              final ItemType t = Aliases.parseAlias(((EntryNode) n).getValue());
              if (t == null)
                continue;
              currentAliases.put(((EntryNode) n).getKey().toLowerCase(), t);
            }
            continue;
View Full Code Here

 
  @Override
  public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) {
    assert mode != ChangeMode.RESET;
   
    final ItemType t = delta == null ? null : (ItemType) delta[0];
    final Item i = item != null ? item.getSingle(e) : null;
    final Slot s = slot != null ? slot.getSingle(e) : null;
    if (i == null && s == null)
      return;
    ItemStack is = i != null ? i.getItemStack() : s != null ? s.getItem() : null;
    switch (mode) {
      case SET:
        assert t != null;
        is = t.getRandom();
        break;
      case ADD:
      case REMOVE:
      case REMOVE_ALL:
        assert t != null;
        if (t.isOfType(is)) {
          if (mode == ChangeMode.ADD)
            is = t.addTo(is);
          else if (mode == ChangeMode.REMOVE)
            is = t.removeFrom(is);
          else
            is = t.removeAll(is);
        }
        break;
      case DELETE:
        is = null;
        if (i != null)
View Full Code Here

            if (delta instanceof Inventory) {
              for (final ItemStack is : new IteratorIterable<ItemStack>(((Inventory) delta).iterator())) {
                if (is == null)
                  continue;
                if (mode == ChangeMode.REMOVE)
                  new ItemType(is).removeFrom(drops);
                else
                  new ItemType(is).removeAll(drops);
              }
            } else {
              if (mode == ChangeMode.REMOVE)
                ((ItemType) delta).removeFrom(drops);
              else
View Full Code Here

  protected boolean init(final @Nullable Class<? extends Item> c, final @Nullable Item e) {
    if (e != null) {
      final ItemStack i = e.getItemStack();
      if (i == null)
        return false;
      types = new ItemType[] {new ItemType(i)};
    }
    return true;
  }
View Full Code Here

    }
  }
 
  @Override
  public void set(final Item entity) {
    final ItemType t = CollectionUtils.getRandom(types);
    assert t != null;
    entity.setItemStack(t.getItem().getRandom());
  }
View Full Code Here

TOP

Related Classes of ch.njol.skript.aliases.ItemType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.