当前位置: 首页>>代码示例>>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;未经允许,请勿转载。