use of org.bukkit.Color in project Denizen-For-Bukkit by DenizenScript.
the class MapDot method render.
@Override
public void render(MapView mapView, MapCanvas mapCanvas, dPlayer player, UUID uuid) {
int baseX = getX(player, uuid);
int baseY = getY(player, uuid);
int radius = (int) aH.getDoubleFrom(tag(radiusTag, player));
Color color = dColor.valueOf(tag(colorTag, player)).getColor();
for (int x = -radius; x < radius; x++) {
int finalX = baseX + x;
if (finalX >= 128) {
continue;
}
for (int y = -radius; y < radius; y++) {
int finalY = baseY + y;
if (finalY >= 128) {
continue;
}
if (((x + 0.5) * (x + 0.5)) + ((y + 0.5) * (y + 0.5)) <= (radius * radius)) {
mapCanvas.setPixel(finalX, finalY, MapPalette.matchColor(color.getRed(), color.getGreen(), color.getBlue()));
}
}
}
}
use of org.bukkit.Color in project Glowstone by GlowstoneMC.
the class GlowChargeFadeMatcher method getResult.
@Override
public ItemStack getResult(ItemStack[] matrix) {
ItemStack charge = null;
List<Color> colors = new ArrayList<>();
for (ItemStack item : matrix) {
if (item == null)
continue;
switch(item.getType()) {
case INK_SACK:
Dye dye = (Dye) item.getData();
colors.add(dye.getColor().getFireworkColor());
break;
case FIREWORK_CHARGE:
charge = item;
break;
default:
// Wrong item on matrix
return null;
}
}
// No charge, or no colors
if (charge == null || colors.isEmpty())
return null;
FireworkEffectMeta meta = (FireworkEffectMeta) charge.getItemMeta();
FireworkEffect old = meta.getEffect();
FireworkEffect newEffect = FireworkEffect.builder().with(old.getType()).withColor(old.getColors()).flicker(old.hasFlicker()).trail(old.hasTrail()).withFade(colors).build();
meta.setEffect(newEffect);
ItemStack ret = charge.clone();
ret.setItemMeta(meta);
return ret;
}
use of org.bukkit.Color in project Glowstone by GlowstoneMC.
the class GlowChargeMatcher method getResult.
@Override
public ItemStack getResult(ItemStack[] matrix) {
boolean hasGunpowder = false;
boolean trail = false;
boolean twinkle = false;
List<Color> colors = new ArrayList<>();
Type type = Type.BALL;
for (ItemStack item : matrix) {
if (item == null)
continue;
switch(item.getType()) {
case SULPHUR:
// Only 1 gunpowder allowed
if (hasGunpowder)
return null;
hasGunpowder = true;
break;
case INK_SACK:
Dye dye = (Dye) item.getData();
colors.add(dye.getColor().getFireworkColor());
break;
case DIAMOND:
// Only 1 diamond allowed
if (trail)
return null;
trail = true;
break;
case GLOWSTONE_DUST:
// Only 1 dust allowed
if (twinkle)
return null;
twinkle = true;
break;
case FIREBALL:
if (type != Type.BALL)
return null;
type = Type.BALL_LARGE;
break;
case GOLD_NUGGET:
if (type != Type.BALL)
return null;
type = Type.STAR;
break;
case FEATHER:
if (type != Type.BALL)
return null;
type = Type.BURST;
break;
case SKULL_ITEM:
if (type != Type.BALL)
return null;
type = Type.CREEPER;
break;
default:
// Non firework item on matrix
return null;
}
}
// Not enough ingredients
if (!hasGunpowder || colors.isEmpty())
return null;
FireworkEffect effect = FireworkEffect.builder().withColor(colors).trail(trail).flicker(twinkle).with(type).build();
ItemStack charge = new ItemStack(Material.FIREWORK_CHARGE, 1);
FireworkEffectMeta meta = (FireworkEffectMeta) charge.getItemMeta();
meta.setEffect(effect);
charge.setItemMeta(meta);
return charge;
}
use of org.bukkit.Color in project Prism-Bukkit by prism.
the class ItemStackAction method setItem.
/**
*
* @param action_type
* @param block
* @param player
*/
public void setItem(ItemStack item, int quantity, int slot, Map<Enchantment, Integer> enchantments) {
actionData = new ItemStackActionData();
if (enchantments != null) {
this.enchantments = enchantments;
}
if (item == null || item.getAmount() <= 0) {
this.setCanceled(true);
return;
}
this.item = item;
if (enchantments == null) {
this.enchantments = item.getEnchantments();
}
// Set basics
this.block_id = item.getTypeId();
this.block_subid = item.getDurability();
actionData.amt = quantity;
if (slot >= 0) {
actionData.slot = slot;
}
// Set additional data all items may have
final ItemMeta meta = item.getItemMeta();
if (meta != null && meta.getDisplayName() != null) {
actionData.name = meta.getDisplayName();
}
// Leather Coloring
if (meta != null && item.getType().name().contains("LEATHER_")) {
final LeatherArmorMeta lam = (LeatherArmorMeta) meta;
if (lam.getColor() != null) {
actionData.color = lam.getColor().asRGB();
}
} else // Skull Owner
if (meta != null && item.getType().equals(Material.SKULL_ITEM)) {
final SkullMeta skull = (SkullMeta) meta;
if (skull.hasOwner()) {
actionData.owner = skull.getOwner();
}
}
// Written books
if (meta != null && meta instanceof BookMeta) {
final BookMeta bookMeta = (BookMeta) meta;
actionData.by = bookMeta.getAuthor();
actionData.title = bookMeta.getTitle();
actionData.content = bookMeta.getPages().toArray(new String[0]);
}
// Lore
if (meta != null && meta.getLore() != null) {
actionData.lore = meta.getLore().toArray(new String[0]);
}
// Enchantments
if (!this.enchantments.isEmpty()) {
final String[] enchs = new String[this.enchantments.size()];
int i = 0;
for (final Entry<Enchantment, Integer> ench : this.enchantments.entrySet()) {
enchs[i] = ench.getKey().getId() + ":" + ench.getValue();
i++;
}
actionData.enchs = enchs;
} else // Book enchantments
if (meta != null && item.getType().equals(Material.ENCHANTED_BOOK)) {
final EnchantmentStorageMeta bookEnchantments = (EnchantmentStorageMeta) meta;
if (bookEnchantments.hasStoredEnchants()) {
if (bookEnchantments.getStoredEnchants().size() > 0) {
final String[] enchs = new String[bookEnchantments.getStoredEnchants().size()];
int i = 0;
for (final Entry<Enchantment, Integer> ench : bookEnchantments.getStoredEnchants().entrySet()) {
enchs[i] = ench.getKey().getId() + ":" + ench.getValue();
i++;
}
actionData.enchs = enchs;
}
}
}
// Fireworks
if (meta != null && block_id == 402) {
final FireworkEffectMeta fireworkMeta = (FireworkEffectMeta) meta;
if (fireworkMeta.hasEffect()) {
final FireworkEffect effect = fireworkMeta.getEffect();
if (!effect.getColors().isEmpty()) {
final int[] effectColors = new int[effect.getColors().size()];
int i = 0;
for (final Color effectColor : effect.getColors()) {
effectColors[i] = effectColor.asRGB();
i++;
}
actionData.effectColors = effectColors;
}
if (!effect.getFadeColors().isEmpty()) {
final int[] fadeColors = new int[effect.getColors().size()];
final int i = 0;
for (final Color fadeColor : effect.getFadeColors()) {
fadeColors[i] = fadeColor.asRGB();
}
actionData.fadeColors = fadeColors;
}
if (effect.hasFlicker()) {
actionData.hasFlicker = true;
}
if (effect.hasTrail()) {
actionData.hasTrail = true;
}
}
}
}
use of org.bukkit.Color in project Denizen-For-Bukkit by DenizenScript.
the class ItemFirework method getFireworkData.
public dList getFireworkData() {
List<FireworkEffect> effects;
dList list = new dList();
if (item.getItemStack().getItemMeta() instanceof FireworkMeta) {
effects = ((FireworkMeta) item.getItemStack().getItemMeta()).getEffects();
int power = ((FireworkMeta) item.getItemStack().getItemMeta()).getPower();
if (power != 0) {
list.add(String.valueOf(power));
}
} else {
effects = Arrays.asList(((FireworkEffectMeta) item.getItemStack().getItemMeta()).getEffect());
}
if (effects != null) {
for (FireworkEffect effect : effects) {
if (effect == null) {
continue;
}
Color ColOne = effect.getColors() != null && effect.getColors().size() > 0 ? effect.getColors().get(0) : Color.BLUE;
Color ColTwo = effect.getFadeColors() != null && effect.getFadeColors().size() > 0 ? effect.getFadeColors().get(0) : ColOne;
list.add(effect.hasTrail() + "," + effect.hasFlicker() + "," + effect.getType().name() + "," + ColOne.getRed() + "," + ColOne.getGreen() + "," + ColOne.getBlue() + "," + ColTwo.getRed() + "," + ColTwo.getGreen() + "," + ColTwo.getBlue());
}
}
return list;
}
Aggregations