Search in sources :

Example 21 with FixedMetadataValue

use of org.bukkit.metadata.FixedMetadataValue in project EliteMobs by MagmaGuy.

the class MinorPowerPowerStance method itemEffect.

//Secondary effect particle processing
//    private void particleEffect(Entity entity, Particle particle, int particleAmount, double v, double v1, double v2, double v3) {
//        if (ConfigValues.defaultConfig.getBoolean("Turn on visual effects for natural or plugin-spawned EliteMobs")) {
//
//            if (ConfigValues.defaultConfig.getBoolean("Turn off visual effects for non-natural or non-plugin-spawned EliteMobs")
//                    && !entity.hasMetadata(MetadataHandler.NATURAL_MOB_MD)) {
//
//                return;
//
//            }
//
//            processID = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
//
//                float counter = 0;
//
//                public void run() {
//
//                    List<Location> particleLocations = powerStanceMath.cylindricalPowerStance(entity, radiusHorizontal, radiusVertical, speedHorizontal, speedVertical, counter);
//
//                    Location location1 = particleLocations.get(0);
//                    Location location2 = particleLocations.get(1);
//
//                    entity.getWorld().spawnParticle(particle, location1, particleAmount, v, v1, v2, v3);
//                    entity.getWorld().spawnParticle(particle, location2, particleAmount, v, v1, v2, v3);
//
//                    if (!entity.isValid()) {
//
//                        Bukkit.getScheduler().cancelTask(processID);
//
//                    }
//
//                    counter++;
//
//                }
//
//            }, 1L, 1L);
//
//        }
//
//    }
//    public void attackConfusing(Entity entity) {
//
//        particleEffect(entity, Particle.SPELL_MOB, 5, 0, 0, 0, 0.01);
//
//    }
//
//    public void invulnerabilityFireEffect(Entity entity) {
//
//        particleEffect(entity, Particle.FLAME, 5, 0, 0, 0, 0.01);
//
//    }
//Secondary effect item processing
public void itemEffect(Entity entity) {
    if (ConfigValues.defaultConfig.getBoolean("Turn on visual effects for natural or plugin-spawned EliteMobs")) {
        if (ConfigValues.defaultConfig.getBoolean("Turn off visual effects for non-natural or non-plugin-spawned EliteMobs") && !entity.hasMetadata(MetadataHandler.NATURAL_MOB_MD)) {
            return;
        }
        if (entity.hasMetadata(MetadataHandler.VISUAL_EFFECT_MD)) {
            return;
        }
        entity.setMetadata("VisualEffect", new FixedMetadataValue(plugin, true));
        //contains all items around a given entity
        HashMap<Integer, HashMap<Integer, List<Item>>> powerItemLocationTracker = new HashMap<>();
        new BukkitRunnable() {

            int attackArrowCounter = 0;

            int attackBlindingCounter = 0;

            int attackFireCounter = 0;

            int attackFireballCounter = 0;

            int attackFreezeCounter = 0;

            int attackGravityCounter = 0;

            int attackPoisonCounter = 0;

            int attackPushCounter = 0;

            int attackWeaknessCounter = 0;

            int attackWebCounter = 0;

            int attackWitherCounter = 0;

            int bonusLootCounter = 0;

            int doubleDamageCounter = 0;

            int doubleHealthCounter = 0;

            int invisibilityCounter = 0;

            int invulnerabilityArrowCounter = 0;

            int invulnerabilityFallDamageCounter = 0;

            int invulnerabilityKnockbackCounter = 0;

            int movementSpeedCounter = 0;

            int tauntCounter = 0;

            public void run() {
                //                    int effectQuantity = 0;
                int effectIteration = 0;
                //apply new positioning
                if (entity.hasMetadata(MetadataHandler.ATTACK_ARROW_MD)) {
                    ItemStack itemStack = new ItemStack(Material.ARROW, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackArrowCounter);
                    effectIteration++;
                    attackArrowCounter++;
                    if (attackArrowCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackArrowCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_BLINDING_MD)) {
                    ItemStack itemStack = new ItemStack(Material.EYE_OF_ENDER, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackBlindingCounter);
                    effectIteration++;
                    attackBlindingCounter++;
                    if (attackBlindingCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackBlindingCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_FIRE_MD)) {
                    ItemStack itemStack = new ItemStack(Material.LAVA_BUCKET, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackFireCounter);
                    effectIteration++;
                    attackFireCounter++;
                    if (attackFireCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackFireCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_FIREBALL_MD)) {
                    ItemStack itemStack = new ItemStack(Material.FIREBALL, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackFireballCounter);
                    effectIteration++;
                    attackFireballCounter++;
                    if (attackFireballCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackFireballCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_FREEZE_MD)) {
                    ItemStack itemStack = new ItemStack(Material.PACKED_ICE, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackFreezeCounter);
                    effectIteration++;
                    attackFreezeCounter++;
                    if (attackFreezeCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackFreezeCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_GRAVITY_MD)) {
                    ItemStack itemStack = new ItemStack(Material.ELYTRA, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackGravityCounter);
                    effectIteration++;
                    attackGravityCounter++;
                    if (attackGravityCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackGravityCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_POISON_MD)) {
                    ItemStack itemStack = new ItemStack(Material.EMERALD, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackPoisonCounter);
                    effectIteration++;
                    attackPoisonCounter++;
                    if (attackPoisonCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackPoisonCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_PUSH_MD)) {
                    ItemStack itemStack = new ItemStack(Material.PISTON_BASE, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackPushCounter);
                    effectIteration++;
                    attackPushCounter++;
                    if (attackPushCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackPushCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_WEAKNESS_MD)) {
                    ItemStack itemStack = new ItemStack(Material.TOTEM, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackWeaknessCounter);
                    effectIteration++;
                    attackWeaknessCounter++;
                    if (attackWeaknessCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackWeaknessCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_WEB_MD)) {
                    ItemStack itemStack = new ItemStack(Material.WEB, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackWebCounter);
                    effectIteration++;
                    attackWebCounter++;
                    if (attackWebCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackWebCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_WITHER_MD)) {
                    ItemStack itemStack = new ItemStack(Material.SKULL_ITEM, 1, (short) 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackWitherCounter);
                    effectIteration++;
                    attackWitherCounter++;
                    if (attackWitherCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackWitherCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.BONUS_LOOT_MD)) {
                    ItemStack itemStack = new ItemStack(Material.CHEST, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, bonusLootCounter);
                    effectIteration++;
                    bonusLootCounter++;
                    if (bonusLootCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        bonusLootCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.DOUBLE_DAMAGE_MD)) {
                    ItemStack itemStack = new ItemStack(Material.GOLD_SWORD, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, doubleDamageCounter);
                    effectIteration++;
                    doubleDamageCounter++;
                    if (doubleDamageCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        doubleDamageCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.DOUBLE_HEALTH_MD)) {
                    ItemStack itemStack = new ItemStack(Material.SHIELD, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, doubleHealthCounter);
                    effectIteration++;
                    doubleHealthCounter++;
                    if (doubleHealthCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        doubleHealthCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.INVISIBILITY_MD)) {
                    ItemStack itemStack = new ItemStack(Material.THIN_GLASS, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, invisibilityCounter);
                    effectIteration++;
                    invisibilityCounter++;
                    if (invisibilityCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        invisibilityCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.INVULNERABILITY_ARROW_MD)) {
                    ItemStack itemStack = new ItemStack(Material.SPECTRAL_ARROW, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, invulnerabilityArrowCounter);
                    effectIteration++;
                    invulnerabilityArrowCounter++;
                    if (invulnerabilityArrowCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        invulnerabilityArrowCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.INVULNERABILITY_FALL_DAMAGE_MD)) {
                    ItemStack itemStack = new ItemStack(Material.FEATHER, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, invulnerabilityFallDamageCounter);
                    effectIteration++;
                    invulnerabilityFallDamageCounter++;
                    if (invulnerabilityFallDamageCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        invulnerabilityFallDamageCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.INVULNERABILITY_KNOCKBACK_MD)) {
                    ItemStack itemStack = new ItemStack(Material.ANVIL, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, invulnerabilityKnockbackCounter);
                    effectIteration++;
                    invulnerabilityKnockbackCounter++;
                    if (invulnerabilityKnockbackCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        invulnerabilityKnockbackCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.MOVEMENT_SPEED_MD)) {
                    ItemStack itemStack = new ItemStack(Material.GOLD_BOOTS, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, movementSpeedCounter);
                    effectIteration++;
                    movementSpeedCounter++;
                    if (movementSpeedCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        movementSpeedCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.TAUNT_MD)) {
                    ItemStack itemStack = new ItemStack(Material.JUKEBOX, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, tauntCounter);
                    effectIteration++;
                    tauntCounter++;
                    if (tauntCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        tauntCounter = 0;
                    }
                }
                if (!entity.isValid() || entity.isDead()) {
                    for (int i = 0; i < powerItemLocationTracker.size(); i++) {
                        for (int j = 0; j < trackAmount; j++) {
                            for (int h = 0; h < itemsPerTrack; h++) {
                                powerItemLocationTracker.get(i).get(j).get(h).remove();
                                powerItemLocationTracker.get(i).get(j).get(h).removeMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, plugin);
                            }
                        }
                    }
                    entity.removeMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, plugin);
                    cancel();
                    return;
                }
            }
        }.runTaskTimer(plugin, 0, 5);
    }
}
Also used : Item(org.bukkit.entity.Item) HashMap(java.util.HashMap) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) ItemStack(org.bukkit.inventory.ItemStack)

Example 22 with FixedMetadataValue

use of org.bukkit.metadata.FixedMetadataValue in project EliteMobs by MagmaGuy.

the class MinorPowerPowerStance method itemInitializer.

private Item itemInitializer(ItemStack itemStack, Location location) {
    Item item = location.getWorld().dropItem(location, itemStack);
    item.setPickupDelay(Integer.MAX_VALUE);
    item.setMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, new FixedMetadataValue(plugin, 0));
    item.setGravity(false);
    return item;
}
Also used : Item(org.bukkit.entity.Item) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue)

Example 23 with FixedMetadataValue

use of org.bukkit.metadata.FixedMetadataValue in project Jobs by GamingMesh.

the class JobsPaymentListener method onCreatureSpawn.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (!(event.getEntity() instanceof LivingEntity))
        return;
    if (!event.getSpawnReason().equals(SpawnReason.SPAWNER))
        return;
    if (ConfigManager.getJobsConfiguration().payNearSpawner())
        return;
    LivingEntity creature = (LivingEntity) event.getEntity();
    creature.setMetadata(mobSpawnerMetadata, new FixedMetadataValue(plugin, true));
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) EventHandler(org.bukkit.event.EventHandler)

Example 24 with FixedMetadataValue

use of org.bukkit.metadata.FixedMetadataValue in project Minigames by AddstarMC.

the class ScoreboardSign method signCreate.

@Override
public boolean signCreate(SignChangeEvent event) {
    Sign sign = (Sign) event.getBlock().getState();
    if (sign.getType() != Material.WALL_SIGN) {
        event.getPlayer().sendMessage(ChatColor.RED + "Scoreboards must be placed on a wall!");
        return false;
    }
    // Parse minigame
    Minigame minigame;
    if (plugin.mdata.hasMinigame(event.getLine(2))) {
        minigame = plugin.mdata.getMinigame(event.getLine(2));
    } else {
        event.getPlayer().sendMessage(ChatColor.RED + "No Minigame found by the name " + event.getLine(2));
        return false;
    }
    // Parse size
    int width;
    int height;
    if (event.getLine(3).isEmpty()) {
        width = ScoreboardDisplay.defaultWidth;
        height = ScoreboardDisplay.defaultHeight;
    } else if (event.getLine(3).matches("[0-9]+x[0-9]+")) {
        String[] parts = event.getLine(3).split("x");
        width = Integer.parseInt(parts[0]);
        height = Integer.parseInt(parts[1]);
    } else {
        event.getPlayer().sendMessage(ChatColor.RED + "Invalid size. Requires nothing or (width)x(height) eg. 3x3");
        return false;
    }
    // So we dont have to deal with even size scoreboards
    if (width % 2 == 0) {
        event.getPlayer().sendMessage(ChatColor.RED + "Length must not be an even number!");
        return false;
    }
    BlockFace facing = ((Directional) sign.getData()).getFacing();
    // Add our display
    ScoreboardDisplay display = new ScoreboardDisplay(minigame, width, height, event.getBlock().getLocation(), facing);
    display.placeSigns();
    minigame.getScoreboardData().addDisplay(display);
    // Reformat this sign for the next part
    event.setLine(1, ChatColor.GREEN + "Scoreboard");
    event.setLine(2, minigame.getName(false));
    event.getBlock().setMetadata("Minigame", new FixedMetadataValue(plugin, minigame));
    return true;
}
Also used : ScoreboardDisplay(au.com.mineauz.minigames.minigame.ScoreboardDisplay) BlockFace(org.bukkit.block.BlockFace) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) Sign(org.bukkit.block.Sign) Minigame(au.com.mineauz.minigames.minigame.Minigame) Directional(org.bukkit.material.Directional)

Example 25 with FixedMetadataValue

use of org.bukkit.metadata.FixedMetadataValue in project Minigames by AddstarMC.

the class ScoreboardDisplay method placeRootSign.

public void placeRootSign() {
    // For external calls
    if (settings == null) {
        settings = minigame.getSettings(stat);
    }
    Block root = rootBlock.getBlock();
    Sign sign = (Sign) root.getState();
    sign.setLine(0, ChatColor.BLUE + minigame.getName(true));
    sign.setLine(1, ChatColor.GREEN + settings.getDisplayName());
    sign.setLine(2, ChatColor.GREEN + field.getTitle());
    sign.setLine(3, "(" + WordUtils.capitalize(order.toString()) + ")");
    sign.update();
    sign.setMetadata("MGScoreboardSign", new FixedMetadataValue(Minigames.plugin, true));
    sign.setMetadata("Minigame", new FixedMetadataValue(Minigames.plugin, minigame));
}
Also used : Block(org.bukkit.block.Block) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) Sign(org.bukkit.block.Sign)

Aggregations

FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)52 MinorPowerPowerStance (com.magmaguy.elitemobs.powerstances.MinorPowerPowerStance)22 Entity (org.bukkit.entity.Entity)9 EventHandler (org.bukkit.event.EventHandler)8 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)7 LivingEntity (org.bukkit.entity.LivingEntity)6 Player (org.bukkit.entity.Player)5 ItemStack (org.bukkit.inventory.ItemStack)5 MajorPowerPowerStance (com.magmaguy.elitemobs.powerstances.MajorPowerPowerStance)4 Item (org.bukkit.entity.Item)4 Zombie (org.bukkit.entity.Zombie)4 Vector (org.bukkit.util.Vector)4 IronGolem (org.bukkit.entity.IronGolem)3 PotionEffect (org.bukkit.potion.PotionEffect)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Random (java.util.Random)2 Location (org.bukkit.Location)2 World (org.bukkit.World)2 Block (org.bukkit.block.Block)2