Search in sources :

Example 51 with FixedMetadataValue

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

the class ScoreboardDisplay method load.

@SuppressWarnings("deprecation")
public static ScoreboardDisplay load(Minigame minigame, ConfigurationSection section) {
    int width = section.getInt("width");
    int height = section.getInt("height");
    Location location = MinigameUtils.loadShortLocation(section.getConfigurationSection("location"));
    BlockFace facing = BlockFace.valueOf(section.getString("dir"));
    // from invalid world
    if (location == null) {
        return null;
    }
    ScoreboardDisplay display = new ScoreboardDisplay(minigame, width, height, location, facing);
    display.setOrder(ScoreboardOrder.valueOf(section.getString("order")));
    // Convert type to new stat
    if (section.contains("type")) {
        ScoreboardType type = ScoreboardType.valueOf(section.getString("type"));
        switch(type) {
            case BEST_KILLS:
                display.setStat(MinigameStats.Kills, StatValueField.Max);
                break;
            case BEST_SCORE:
                display.setStat(MinigameStats.Score, StatValueField.Max);
                break;
            case COMPLETIONS:
                display.setStat(MinigameStats.Wins, StatValueField.Total);
                break;
            case FAILURES:
                display.setStat(MinigameStats.Losses, StatValueField.Total);
                break;
            case LEAST_DEATHS:
                display.setStat(MinigameStats.Deaths, StatValueField.Min);
                break;
            case LEAST_REVERTS:
                display.setStat(MinigameStats.Reverts, StatValueField.Min);
                break;
            case LEAST_TIME:
                display.setStat(MinigameStats.CompletionTime, StatValueField.Min);
                break;
            case TOTAL_DEATHS:
                display.setStat(MinigameStats.Deaths, StatValueField.Total);
                break;
            case TOTAL_KILLS:
                display.setStat(MinigameStats.Kills, StatValueField.Total);
                break;
            case TOTAL_REVERTS:
                display.setStat(MinigameStats.Reverts, StatValueField.Total);
                break;
            case TOTAL_SCORE:
                display.setStat(MinigameStats.Score, StatValueField.Total);
                break;
            case TOTAL_TIME:
                display.setStat(MinigameStats.CompletionTime, StatValueField.Total);
                break;
            default:
                break;
        }
        section.set("type", null);
    // Load stat
    } else {
        MinigameStat stat = MinigameStats.getStat(section.getString("stat", "wins"));
        StatValueField field = StatValueField.valueOf(section.getString("field", "Total"));
        display.setStat(stat, field);
    }
    Block block = location.getBlock();
    block.setMetadata("MGScoreboardSign", new FixedMetadataValue(Minigames.plugin, true));
    block.setMetadata("Minigame", new FixedMetadataValue(Minigames.plugin, minigame));
    return display;
}
Also used : StatValueField(au.com.mineauz.minigames.stats.StatValueField) MinigameStat(au.com.mineauz.minigames.stats.MinigameStat) BlockFace(org.bukkit.block.BlockFace) Block(org.bukkit.block.Block) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) Location(org.bukkit.Location)

Example 52 with FixedMetadataValue

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

the class SpawnEntityAction method executeNodeAction.

@Override
public void executeNodeAction(MinigamePlayer player, Node node) {
    if (player == null || !player.isInMinigame())
        return;
    final Entity ent = node.getLocation().getWorld().spawnEntity(node.getLocation(), EntityType.valueOf(type.getFlag()));
    final double vx = Double.valueOf(settings.get("velocityx"));
    final double vy = Double.valueOf(settings.get("velocityy"));
    final double vz = Double.valueOf(settings.get("velocityz"));
    Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getPlugin(), new Runnable() {

        @Override
        public void run() {
            ent.setVelocity(new Vector(vx, vy, vz));
        }
    });
    if (ent instanceof LivingEntity) {
        LivingEntity lent = (LivingEntity) ent;
        if (settings.containsKey("displayname")) {
            lent.setCustomName(settings.get("displayname"));
            lent.setCustomNameVisible(Boolean.getBoolean(settings.get("displaynamevisible")));
        }
    }
    ent.setMetadata("MinigameEntity", new FixedMetadataValue(Minigames.plugin, true));
    player.getMinigame().getBlockRecorder().addEntity(ent, player, true);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) Vector(org.bukkit.util.Vector)

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