當前位置: 首頁>>代碼示例>>Java>>正文


Java Color.fromRGB方法代碼示例

本文整理匯總了Java中org.bukkit.Color.fromRGB方法的典型用法代碼示例。如果您正苦於以下問題:Java Color.fromRGB方法的具體用法?Java Color.fromRGB怎麽用?Java Color.fromRGB使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.Color的用法示例。


在下文中一共展示了Color.fromRGB方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseColor

import org.bukkit.Color; //導入方法依賴的package包/類
public static Color parseColor(String s) {
    String[] parts = s.split(";");
    if (parts.length != 3) {
        Color color;
        if (s.charAt(0) == '#' && s.length() >= 7) {//Hex color
            try {
                color = Color.fromRGB(Integer.parseUnsignedInt(s.substring(1, 7), 16));
            } catch (IllegalArgumentException e) {
                color = null;
            }
        } else
            color = COLOR_BY_NAME.get(s.toUpperCase());
        if (color == null)
            throw new InvalidConfigException("Invalid color \"" + s + "\", use \"R;G;B\", \"#RRGGBB\" or color name!");
        else return color;
    } else
        return Color.fromRGB(parseInt(parts[0]), parseInt(parts[1]), parseInt(parts[2]));
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:19,代碼來源:ConfigUtil.java

示例2: read

import org.bukkit.Color; //導入方法依賴的package包/類
@Override
public void read(DataInputStream input) throws IOException {
    PotionEffectType type = PotionEffectType.getById(input.readInt());
    int duration = input.readInt();
    int amplifier = input.readInt();
    boolean aimbient = input.readBoolean();
    boolean particles = input.readBoolean();
    int r = input.readInt();
    int g = input.readInt();
    int b = input.readInt();
    Color color = Color.fromRGB(r, g, b);
    
    setValue(new PotionEffect(
            type,
            duration, amplifier,
            aimbient, particles, color
    ));
}
 
開發者ID:OrigamiDream,項目名稱:Leveled-Storage,代碼行數:19,代碼來源:PotionEffectStorage.java

示例3: getColorAll

import org.bukkit.Color; //導入方法依賴的package包/類
public static Color getColorAll(ChatColor color) {
    switch (color) {
        case BLACK:
            return Color.fromRGB(0, 0, 0);
        case DARK_BLUE:
            return Color.fromRGB(0, 0, 170);
        case DARK_GREEN:
            return Color.fromRGB(0, 170, 0);
        case DARK_AQUA:
            return Color.fromRGB(0, 170, 170);
        case DARK_RED:
            return Color.fromRGB(170, 0, 0);
        case DARK_PURPLE:
            return Color.fromRGB(170, 0, 170);
        case GOLD:
            return Color.fromRGB(255, 170, 0);
        case GRAY:
            return Color.fromRGB(170, 170, 170);
        case DARK_GRAY:
            return Color.fromRGB(85, 85, 85);
        case BLUE:
            return Color.fromRGB(85, 85, 255);
        case GREEN:
            return Color.fromRGB(85, 255, 85);
        case AQUA:
            return Color.fromRGB(85, 255, 255);
        case RED:
            return Color.fromRGB(255, 85, 85);
        case LIGHT_PURPLE:
            return Color.fromRGB(255, 85, 255);
        case YELLOW:
            return Color.fromRGB(255, 255, 85);
        case WHITE:
            return Color.fromRGB(255, 255, 255);
    }

    return Color.WHITE;
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:39,代碼來源:ColorConverter.java

示例4: CraftMetaLeatherArmor

import org.bukkit.Color; //導入方法依賴的package包/類
CraftMetaLeatherArmor(net.minecraft.nbt.NBTTagCompound tag) {
    super(tag);
    if (tag.hasKey(DISPLAY.NBT)) {
        net.minecraft.nbt.NBTTagCompound display = tag.getCompoundTag(DISPLAY.NBT);
        if (display.hasKey(COLOR.NBT)) {
            color = Color.fromRGB(display.getInteger(COLOR.NBT));
        }
    }
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:10,代碼來源:CraftMetaLeatherArmor.java

示例5: decodeColor

import org.bukkit.Color; //導入方法依賴的package包/類
public static Color decodeColor(String object) {
    object = object.replace("#", "");
    return Color.fromRGB(
            Integer.valueOf(object.substring(0, 2), 16),
            Integer.valueOf(object.substring(2, 4), 16),
            Integer.valueOf(object.substring(4, 6), 16));
}
 
開發者ID:redraskal,項目名稱:GhostScavengerHunt,代碼行數:8,代碼來源:ConfigUtils.java

示例6: spawnRandomFirework

import org.bukkit.Color; //導入方法依賴的package包/類
/**
 * Spawn a firework with a randomized meta at the location.
 * @param loc The location to spawn at.
 */
public static Firework spawnRandomFirework(Location loc) {
    Firework fw = (Firework) loc.getWorld().spawnEntity(loc, EntityType.FIREWORK);
    FireworkMeta fwm = fw.getFireworkMeta();
    FireworkEffect.Type type = FireworkEffect.Type.values()[(int) (Math.random() * FireworkEffect.Type.values().length - 1)];
    Color c1 = Color.fromRGB(RMath.randInt(0, 255), RMath.randInt(0, 255), RMath.randInt(0, 255));
    Color c2 = Color.fromRGB(RMath.randInt(0, 255), RMath.randInt(0, 255), RMath.randInt(0, 255));
    FireworkEffect effect = FireworkEffect.builder().flicker(Math.random() > 0.5).withColor(c1).withFade(c2).with(type).trail(Math.random() > 0.5).build();
    fwm.addEffect(effect);
    fwm.setPower(RMath.randInt(1, 2));
    fw.setFireworkMeta(fwm);
    return fw;
}
 
開發者ID:edasaki,項目名稱:ZentrelaCore,代碼行數:17,代碼來源:RParticles.java

示例7: fromChatColor

import org.bukkit.Color; //導入方法依賴的package包/類
/**
 * Create Color for use from ChatColor.
 *
 * @param c ChatColor to translate
 * @return Color to use in twinkles
 */
public static Color fromChatColor(ChatColor c) {
    switch (c) {
        case AQUA:
            return Color.fromRGB(0, 255, 255);
        case BLACK:
            return Color.fromRGB(0, 0, 0);
        case BLUE:
            return Color.fromRGB(0, 0, 255);
        case DARK_AQUA:
            return Color.fromRGB(0, 127, 127);
        case DARK_BLUE:
            return Color.fromRGB(0, 0, 127);
        case DARK_GRAY:
            return Color.fromRGB(85, 85, 85);
        case DARK_GREEN:
            return Color.fromRGB(0, 127, 0);
        case DARK_PURPLE:
            return Color.fromRGB(127, 0, 127);
        case DARK_RED:
            return Color.fromRGB(127, 0, 0);
        case GOLD:
            return Color.fromRGB(255, 127, 0);
        case GRAY:
            return Color.fromRGB(170, 170, 170);
        case GREEN:
            return Color.fromRGB(0, 255, 0);
        case LIGHT_PURPLE:
            return Color.fromRGB(255, 0, 255);
        case RED:
            return Color.fromRGB(255, 0, 0);
        case YELLOW:
            return Color.fromRGB(255, 255, 0);
        default:
            return Color.fromRGB(255, 255, 255);
    }
}
 
開發者ID:BurnyDaKath,項目名稱:OMGPI,代碼行數:43,代碼來源:MovingTwinkle.java

示例8: display

import org.bukkit.Color; //導入方法依賴的package包/類
@Override
public void display()
{
    List<ItemStack> flowers = new ArrayList<>();
    flowers.add(new ItemStack(Material.YELLOW_FLOWER, 1));
    flowers.add(new ItemStack(Material.LEAVES, 1));
    flowers.add(new ItemStack(Material.LONG_GRASS, 1));

    for (byte i = 0; i < 9; i++)
        flowers.add(new ItemStack(Material.RED_ROSE, 1, i));

    Color green = Color.fromRGB(100, 165, 120);
    this.player.getInventory().setHelmet(this.colorArmor(new ItemStack(Material.LEATHER_HELMET, 1), green));
    this.player.getInventory().setLeggings(this.colorArmor(new ItemStack(Material.LEATHER_LEGGINGS, 1), green));
    this.player.getInventory().setBoots(this.colorArmor(new ItemStack(Material.LEATHER_BOOTS, 1), green));

    this.loopTask = this.hub.getServer().getScheduler().runTaskTimer(this.hub, new Runnable()
    {
        int timer = 0;

        @Override
        public void run()
        {
            this.timer++;

            final Firework fw = (Firework) player.getLocation().getWorld().spawnEntity(player.getLocation(), EntityType.FIREWORK);
            FireworkMeta fwm = fw.getFireworkMeta();

            FireworkEffect effect = FireworkEffect.builder().flicker(true).withColor(Color.GREEN).withFade(Color.LIME).with(FireworkEffect.Type.BURST).trail(false).build();
            fwm.addEffect(effect);
            fwm.setPower(2);
            fw.setFireworkMeta(fwm);

            hub.getServer().getScheduler().scheduleSyncDelayedTask(hub, () ->
            {
                Location fwLocation = fw.getLocation();
                fw.detonate();

                for (int i = 0; i < 32; i++)
                {
                    ItemStack flower = flowers.get(RANDOM.nextInt(flowers.size())).clone();
                    Item item = player.getWorld().dropItemNaturally(fwLocation, flower);

                    item.setMetadata("flower-swag-level", new FixedMetadataValue(hub, UUID.randomUUID().toString()));

                    try
                    {
                        GadgetManager.AGE_FIELD.set((((CraftItem) item).getHandle()), 5860);
                    }
                    catch (IllegalAccessException e)
                    {
                        e.printStackTrace();
                    }
                }
            }, 20L);

            if (this.timer == 10)
            {
                callback();
                end();
            }
        }
    }, 20L, 20L);
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:65,代碼來源:ExpressBotaniaDisplayer.java

示例9: getOriginal

import org.bukkit.Color; //導入方法依賴的package包/類
@Override
public Object getOriginal() {
    return Color.fromRGB(red,green,blue);
}
 
開發者ID:DevCrafters,項目名稱:SaveableSerializing,代碼行數:5,代碼來源:RGBColor.java

示例10: onEntityDamage

import org.bukkit.Color; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onEntityDamage(EntityDamageByEntityEvent event)
{
    Entity entity = event.getEntity();
    Entity damager = event.getDamager();
    if (((entity instanceof Player)) && ((damager instanceof Arrow)))
    {
        Arrow arrow = (Arrow)damager;
        ProjectileSource source = arrow.getShooter();
        if ((source instanceof Player))
        {
            Player damaged = (Player)event.getEntity();
            Player shooter = (Player)source;
            PvpClass equipped = this.plugin.getPvpClassManager().getEquippedClass(shooter);
            if ((equipped == null) || (!equipped.equals(this))) {
                return;
            }
            if ((this.plugin.getTimerManager().archerTimer.getRemaining((Player)entity) == 0L) || (this.plugin.getTimerManager().archerTimer.getRemaining((Player)entity) < TimeUnit.SECONDS.toMillis(5L)))
            {
                if ((this.plugin.getPvpClassManager().getEquippedClass(damaged) != null) && (this.plugin.getPvpClassManager().getEquippedClass(damaged).equals(this))) {
                    return;
                }
                double distance = shooter.getLocation().distance(damaged.getLocation());
                shooter.sendMessage(ChatColor.translateAlternateColorCodes('&',"&e[&9Arrow Range &e(&c" + String.format("%.1f", new Object[] { Double.valueOf(distance) }) + "&e)] " + "&6Marked " + damaged.getName() + " &6for 6 seconds. &9&l(1 heart)"));

                damaged.sendMessage(ChatColor.GOLD + "You were archer tagged by " + ChatColor.RED + shooter.getName() + ChatColor.GOLD + " from " + ChatColor.RED + String.format("%.1f", new Object[] { Double.valueOf(distance) }) + ChatColor.GOLD + " blocks away.");

                LeatherArmorMeta helmMeta = (LeatherArmorMeta)shooter.getInventory().getHelmet().getItemMeta();
                LeatherArmorMeta chestMeta = (LeatherArmorMeta)shooter.getInventory().getChestplate().getItemMeta();
                LeatherArmorMeta leggingsMeta = (LeatherArmorMeta)shooter.getInventory().getLeggings().getItemMeta();
                LeatherArmorMeta bootsMeta = (LeatherArmorMeta)shooter.getInventory().getBoots().getItemMeta();
                Color green = Color.fromRGB(6717235);

                double r = random.nextDouble();
                r = random.nextDouble();
                if ((r <= 0.5D) && (helmMeta.getColor().equals(green)) && (chestMeta.getColor().equals(green)) && (leggingsMeta.getColor().equals(green)) && (bootsMeta.getColor().equals(green)))
                {
                    damaged.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 120, 0));
                    shooter.sendMessage(ChatColor.GRAY + "Since your armor is green, you gave " + damaged.getName() + " the poison effect for 6 seconds...");
                    damaged.sendMessage(ChatColor.GRAY + "Since " + shooter.getName() + "'s armor is green, you were given the poison effect for 6 seconds...");
                }
                Color blue = Color.fromRGB(3361970);
                if ((r <= 0.5D) && (helmMeta.getColor().equals(blue)) && (chestMeta.getColor().equals(blue)) && (leggingsMeta.getColor().equals(blue)) && (bootsMeta.getColor().equals(blue)))
                {
                    damaged.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 120, 0));
                    shooter.sendMessage(ChatColor.GRAY + "Since your armor is blue, you gave " + damaged.getName() + " the slowness effect for 6 seconds...");
                    damaged.sendMessage(ChatColor.GRAY + "Since " + shooter.getName() + "'s armor is blue, you were given the slowness effect for 6 seconds...");
                }
                Color gray = Color.fromRGB(5000268);
                if ((r <= 0.5D) && (helmMeta.getColor().equals(gray)) && (chestMeta.getColor().equals(gray)) && (leggingsMeta.getColor().equals(gray)) && (bootsMeta.getColor().equals(gray)))
                {
                    damaged.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 120, 0));
                    shooter.sendMessage(ChatColor.GRAY + "Since your armor is gray, you gave " + damaged.getName() + " the blindness effect for 6 seconds...");
                    damaged.sendMessage(ChatColor.GRAY + "Since " + shooter.getName() + "'s armor is gray, you were given the blindness effect for 6 seconds...");
                }
                Color black = Color.fromRGB(1644825);
                if ((r <= 0.2D) && (helmMeta.getColor().equals(black)) && (chestMeta.getColor().equals(black)) && (leggingsMeta.getColor().equals(black)) && (bootsMeta.getColor().equals(black)))
                {
                    damaged.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 120, 0));
                    shooter.sendMessage(ChatColor.GRAY + "Since your armor is black, you gave " + damaged.getName() + " the wither effect for 6 seconds...");
                    damaged.sendMessage(ChatColor.GRAY + "Since " + shooter.getName() + "'s armor is black, you were given the wither effect for 6 seconds...");
                }
            }
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:67,代碼來源:ArcherClass.java

示例11: getDefaultLeatherColor

import org.bukkit.Color; //導入方法依賴的package包/類
@Override
public Color getDefaultLeatherColor() {
    return Color.fromRGB( 0xA06540 );
}
 
開發者ID:lukas81298,項目名稱:FlexMC,代碼行數:5,代碼來源:FlexItemFactory.java


注:本文中的org.bukkit.Color.fromRGB方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。