Package ch.njol.skript.util

Examples of ch.njol.skript.util.Slot


    if (o instanceof String)
      return ((String) o).isEmpty();
    if (o instanceof Inventory)
      return !((Inventory) o).iterator().hasNext();
    if (o instanceof Slot) {
      final Slot s = (Slot) o;
      final ItemStack i = s.getItem();
      return i == null || i.getType() == Material.AIR;
    }
    return false;
  }
View Full Code Here


  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)
          i.remove();
        break;
      case RESET:
        assert false;
    }
    if (i != null)
      i.setItemStack(is);
    else if (s != null)
      s.setItem(is);
    else
      assert false;
  }
View Full Code Here

TOP

Related Classes of ch.njol.skript.util.Slot

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.