Package ch.njol.skript.aliases

Examples of ch.njol.skript.aliases.ItemType


      final MaterialData m = e.getCarriedMaterial();
      if (m != null) {
        final ItemStack i = m.toItemStack(1);
        if (i == null)
          return false;
        hand = new ItemType[] {new ItemType(i)};
      }
    }
    return true;
  }
View Full Code Here


  }
 
  @Override
  public void set(final Enderman entity) {
    if (hand != null) {
      final ItemType t = CollectionUtils.getRandom(hand);
      assert t != null;
      final ItemStack i = t.getBlock().getRandom();
      if (i != null)
        entity.setCarriedMaterial(i.getData());
    }
   
  }
View Full Code Here

  @Override
  public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
    final RetainingLogHandler log = SkriptLogger.startRetainingLog();
    try {
      if (!StringUtils.startsWithIgnoreCase(parseResult.expr, "the ") && !StringUtils.startsWithIgnoreCase(parseResult.expr, "event-")) {
        final ItemType item = Aliases.parseItemType("" + parseResult.regexes.get(0).group());
        log.clear();
        if (item != null) {
          log.printLog();
          return false;
        }
View Full Code Here

 
  @Override
  @Nullable
  protected Integer[] get(final Event e, final ItemType[] source) {
    if (single) {
      final ItemType t = getExpr().getSingle(e);
      if (t == null)
        return new Integer[0];
      return new Integer[] {t.getTypes().get(0).getId()};
    }
    final ArrayList<Integer> r = new ArrayList<Integer>();
    for (final ItemType t : source) {
      for (final ItemData d : t) {
        r.add(Integer.valueOf(d.getId()));
View Full Code Here

  @SuppressWarnings("deprecation")
  @Override
  public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) {
    assert delta != null;
    final int i = ((Number) delta[0]).intValue();
    final ItemType it = getExpr().getSingle(e);
    if (it == null)
      return;
    final ItemStack is = it.getRandom();
    if (is == null)
      return;
    int type = is.getTypeId();
    switch (mode) {
      case ADD:
        type += i;
        break;
      case REMOVE:
        type -= i;
        break;
      case SET:
        type = i;
        break;
      case RESET:
      case DELETE:
      case REMOVE_ALL:
      default:
        assert false;
        return;
    }
    final Material m = Material.getMaterial(type);
    if (m != null) {
      is.setType(m);
      if (changeItemStack)
        getExpr().change(e, new ItemStack[] {is}, ChangeMode.SET);
      else
        getExpr().change(e, new ItemType[] {new ItemType(is)}, ChangeMode.SET);
    }
  }
View Full Code Here

  @SuppressWarnings("null")
  @Override
  @Nullable
  public Iterator<Integer> iterator(final Event e) {
    if (single) {
      final ItemType t = getExpr().getSingle(e);
      if (t == null)
        return null;
      if (t.numTypes() == 0)
        return null;
      return new SingleItemIterator<Integer>(t.getTypes().get(0).getId());
    }
    final Iterator<? extends ItemType> iter = getExpr().iterator(e);
    if (iter == null || !iter.hasNext())
      return null;
    return new Iterator<Integer>() {
View Full Code Here

      if (o instanceof Slot)
        ((Slot) o).setItem(i);
      else if (ChangerUtils.acceptsChange(getExpr(), ChangeMode.SET, ItemStack.class))
        getExpr().change(e, new ItemStack[] {i}, ChangeMode.SET);
      else
        getExpr().change(e, new ItemType[] {new ItemType(i)}, ChangeMode.SET);
    }
  }
View Full Code Here

    } else if (o instanceof Creeper || o instanceof CreeperData) {
      type = SkullType.CREEPER;
    } else {
      return null;
    }
    @SuppressWarnings("deprecation")
    final ItemType i = new ItemType(Material.SKULL_ITEM.getId(), (short) type.ordinal());
    if (o instanceof OfflinePlayer) {
      final SkullMeta s = (SkullMeta) Bukkit.getItemFactory().getItemMeta(Material.SKULL_ITEM);
      s.setOwner(((OfflinePlayer) o).getName());
      i.setItemMeta(s);
    }
    return i;
  }
View Full Code Here

    else
      ((ItemType) i).setItemMeta(meta);
    if (ChangerUtils.acceptsChange(item, ChangeMode.SET, i.getClass())) {
      item.change(e, i instanceof ItemStack ? new ItemStack[] {(ItemStack) i} : new ItemType[] {(ItemType) i}, ChangeMode.SET);
    } else {
      item.change(e, i instanceof ItemStack ? new ItemType[] {new ItemType((ItemStack) i)} : new ItemStack[] {((ItemType) i).getRandom()}, ChangeMode.SET);
    }
    return;
  }
View Full Code Here

       
        if (o instanceof ItemStack) {
          if (changeItemStack)
            getExpr().change(e, new ItemStack[] {is}, mode);
          else
            getExpr().change(e, new ItemType[] {new ItemType(is)}, mode);
        } else {
          ((Item) o).setItemStack(is);
        }
      } else if (o instanceof Colorable) {
        ((Colorable) o).setColor(c.getWoolColor());
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.