Package ch.njol.skript.util

Examples of ch.njol.skript.util.Color


  }
 
  @Override
  public void set(final Sheep entity) {
    if (colors != null) {
      final Color c = CollectionUtils.getRandom(colors);
      assert c != null;
      entity.setColor(c.getWoolColor());
    }
  }
View Full Code Here


 
  @Override
  protected void execute(final Event e) {
    final org.bukkit.Color c;
    if (color != null) {
      final Color cl = color.getSingle(e);
      if (cl == null)
        return;
      c = cl.getBukkitColor();
    } else {
      final Expression<Number>[] rgb = this.rgb;
      assert rgb != null;
      final Number r = rgb[0].getSingle(e), g = rgb[1].getSingle(e), b = rgb[2].getSingle(e);
      if (r == null || g == null || b == null)
View Full Code Here

  @Override
  public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) throws UnsupportedOperationException {
    assert mode == ChangeMode.SET;
    assert delta != null;
   
    final Color c = (Color) delta[0];
    final Object[] os = getExpr().getArray(e);
    if (os.length == 0)
      return;
   
    for (final Object o : os) {
      if (o instanceof ItemStack || o instanceof Item) {
        final ItemStack is = o instanceof ItemStack ? (ItemStack) o : ((Item) o).getItemStack();
        final MaterialData d = is.getData();
        if (d instanceof Colorable)
          ((Colorable) d).setColor(c.getWoolColor());
        else
          continue;
       
        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.util.Color

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.