Search in sources :

Example 6 with PotionEffect

use of org.bukkit.potion.PotionEffect in project GameCore by Warvale.

the class Bosses method BossWizard.

private void BossWizard(Location bossLocation) {
    Skeleton Wizard = (Skeleton) bossLocation.getWorld().spawnEntity(bossLocation, EntityType.SKELETON);
    Wizard.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 200, 100));
    Wizard.setCustomName(ChatColor.translateAlternateColorCodes('&', "&eWizard"));
    Wizard.setCustomNameVisible(true);
    Wizard.setCanPickupItems(true);
    ItemStack chestplate = new ItemStack(Material.IRON_CHESTPLATE);
    chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
    Wizard.getEquipment().setChestplate(chestplate);
    Wizard.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(30);
    Wizard.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 1000000, 1, false, false, Color.RED));
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect) ItemStack(org.bukkit.inventory.ItemStack)

Example 7 with PotionEffect

use of org.bukkit.potion.PotionEffect in project GameCore by Warvale.

the class Bosses method BossGrometator.

/* Thanks CommandFox for all of the names below. */
private void BossGrometator(Location bossLocation) {
    IronGolem Grometator = (IronGolem) bossLocation.getWorld().spawnEntity(bossLocation, EntityType.IRON_GOLEM);
    Grometator.setCustomName(ChatColor.translateAlternateColorCodes('&', "&eGrometator"));
    Grometator.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 1000000, 1, false, false, Color.RED));
    Grometator.setPlayerCreated(false);
    Grometator.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.5);
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect)

Example 8 with PotionEffect

use of org.bukkit.potion.PotionEffect in project GameCore by Warvale.

the class Bosses method BossCruitionator.

private void BossCruitionator(Location bossLocation) {
    Spider Cruitionator = (Spider) bossLocation.getWorld().spawnEntity(bossLocation, EntityType.SPIDER);
    Cruitionator.setCustomNameVisible(true);
    Cruitionator.setCustomName(ChatColor.translateAlternateColorCodes('&', "&eCruitionator"));
    Cruitionator.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(20);
    Cruitionator.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.5);
    Cruitionator.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 1000000, 1, false, false, Color.RED));
    Cruitionator.getEquipment().setItemInMainHand(new ItemStack(Material.WOOD_SWORD));
    Cruitionator.getEquipment().setItemInOffHandDropChance(0);
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect) ItemStack(org.bukkit.inventory.ItemStack)

Example 9 with PotionEffect

use of org.bukkit.potion.PotionEffect in project GameCore by Warvale.

the class AbilityManager method Medic.

private void Medic(Player p) {
    List<Entity> entities = p.getNearbyEntities(10, 10, 10);
    for (Entity e : entities) {
        if (!(e instanceof Player))
            return;
        Player nbp = (Player) e;
        if (Main.getTeams().getSpectatorTeam().getEntries().contains(nbp.getName()))
            return;
        Set<String> BlueTeam = Main.getTeams().getBlueTeam().getEntries();
        Set<String> RedTeam = Main.getTeams().getRedTeam().getEntries();
        Set<String> teammates = ((BlueTeam.contains(p.getName())) ? BlueTeam : RedTeam);
        if (!teammates.contains(nbp.getName()))
            return;
        nbp.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 100, 7));
    }
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect)

Example 10 with PotionEffect

use of org.bukkit.potion.PotionEffect in project Minigames by AddstarMC.

the class PlayerData method quitMinigame.

public void quitMinigame(MinigamePlayer player, boolean forced) {
    Minigame minigame = player.getMinigame();
    boolean isWinner = false;
    if (GameOverModule.getMinigameModule(minigame).getWinners().contains(player))
        isWinner = true;
    QuitMinigameEvent event = new QuitMinigameEvent(player, minigame, forced, isWinner);
    Bukkit.getServer().getPluginManager().callEvent(event);
    if (!event.isCancelled()) {
        if (!minigame.isSpectator(player)) {
            if (player.getEndTime() == 0)
                player.setEndTime(System.currentTimeMillis());
            if (isWinner)
                GameOverModule.getMinigameModule(minigame).getWinners().remove(player);
            else
                GameOverModule.getMinigameModule(minigame).getLosers().remove(player);
            if (!isWinner) {
                if (!minigame.canSaveCheckpoint() && minigame.isEnabled()) {
                    StoredGameStats saveData = new StoredGameStats(minigame, player);
                    saveData.addStat(MinigameStats.Attempts, 1);
                    for (DynamicMinigameStat stat : MinigameStats.getDynamicStats()) {
                        if (stat.doesApply(minigame, player, false)) {
                            saveData.addStat(stat, stat.getValue(minigame, player, false));
                        }
                    }
                    saveData.applySettings(minigame.getStatSettings(saveData));
                    plugin.queueStatSave(saveData, false);
                }
            }
            //Call Types quit.
            mdata.minigameType(minigame.getType()).quitMinigame(player, minigame, forced);
            //Call Mechanic quit.
            minigame.getMechanic().quitMinigame(minigame, player, forced);
            //Prepare player for quit
            if (player.getPlayer().getVehicle() != null) {
                Vehicle vehicle = (Vehicle) player.getPlayer().getVehicle();
                vehicle.eject();
            }
            player.getPlayer().closeInventory();
            if (player.getLoadout() != null) {
                player.getLoadout().removeLoadout(player);
            }
            player.removeMinigame();
            minigame.removePlayer(player);
            for (PotionEffect potion : player.getPlayer().getActivePotionEffects()) {
                player.getPlayer().removePotionEffect(potion.getType());
            }
            player.getPlayer().setFallDistance(0);
            player.getPlayer().setNoDamageTicks(60);
            final MinigamePlayer fplayer = player;
            Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {

                @Override
                public void run() {
                    fplayer.getPlayer().setFireTicks(0);
                }
            });
            player.resetAllStats();
            if (!player.isDead()) {
                player.restorePlayerData();
                if (!isWinner)
                    player.teleport(minigame.getQuitPosition());
                else
                    player.teleport(minigame.getEndPosition());
            } else {
                if (!isWinner)
                    player.setQuitPos(minigame.getQuitPosition());
                else
                    player.setQuitPos(minigame.getEndPosition());
                player.setRequiredQuit(true);
            }
            //Reward Player
            if (isWinner) {
                player.claimTempRewardItems();
            }
            player.claimRewards();
            //Reset Minigame
            if (minigame.getPlayers().size() == 0) {
                if (minigame.getMinigameTimer() != null) {
                    minigame.getMinigameTimer().stopTimer();
                    minigame.setMinigameTimer(null);
                }
                if (minigame.getFloorDegenerator() != null) {
                    minigame.getFloorDegenerator().stopDegenerator();
                }
                minigame.setState(MinigameState.IDLE);
                if (minigame.getBlockRecorder().hasData()) {
                    minigame.getBlockRecorder().restoreBlocks();
                    minigame.getBlockRecorder().restoreEntities();
                    minigame.getBlockRecorder().setCreatedRegenBlocks(false);
                }
                if (minigame.getMpTimer() != null) {
                    minigame.getMpTimer().pauseTimer();
                    minigame.getMpTimer().removeTimer();
                    minigame.setMpTimer(null);
                }
                if (minigame.getMpBets() != null) {
                    minigame.setMpBets(null);
                }
                mdata.clearClaimedScore(minigame);
                WeatherTimeModule.getMinigameModule(minigame).stopTimeLoop();
                GameOverModule.getMinigameModule(minigame).stopEndGameTimer();
                for (Team team : TeamsModule.getMinigameModule(minigame).getTeams()) {
                    team.setScore(0);
                }
            }
            minigame.getScoreboardManager().resetScores(player.getName());
            for (MinigamePlayer pl : minigame.getSpectators()) {
                player.getPlayer().showPlayer(pl.getPlayer());
            }
            if (minigame.getPlayers().size() == 0 && !minigame.isRegenerating()) {
                HandlerList.unregisterAll(minigame.getBlockRecorder());
            }
            //Send out messages
            if (!forced) {
                mdata.sendMinigameMessage(minigame, MinigameUtils.formStr("player.quit.plyMsg", player.getName(), minigame.getName(true)), "error", player);
            }
            plugin.getLogger().info(player.getName() + " quit " + minigame);
            player.updateInventory();
        } else {
            if (player.getPlayer().getVehicle() != null) {
                Vehicle vehicle = (Vehicle) player.getPlayer().getVehicle();
                vehicle.eject();
            }
            player.getPlayer().setFallDistance(0);
            player.getPlayer().setNoDamageTicks(60);
            final Player fplayer = player.getPlayer();
            for (PotionEffect potion : player.getPlayer().getActivePotionEffects()) {
                player.getPlayer().removePotionEffect(potion.getType());
            }
            Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {

                @Override
                public void run() {
                    fplayer.setFireTicks(0);
                }
            });
            player.getPlayer().closeInventory();
            if (!player.isDead()) {
                player.restorePlayerData();
            }
            player.teleport(minigame.getQuitPosition());
            player.removeMinigame();
            minigame.removeSpectator(player);
            for (MinigamePlayer pl : minigame.getPlayers()) {
                pl.getPlayer().showPlayer(player.getPlayer());
            }
            player.sendMessage(MinigameUtils.formStr("player.spectate.quit.plyMsg", minigame.getName(true)), "error");
            mdata.sendMinigameMessage(minigame, MinigameUtils.formStr("player.spectate.quit.minigameMsg", player.getName(), minigame.getName(true)), "error", player);
        }
        if (player.getPlayer().getGameMode() != GameMode.CREATIVE)
            player.setCanFly(false);
        if (!forced) {
            minigame.getScoreboardData().reload();
        }
    }
}
Also used : Vehicle(org.bukkit.entity.Vehicle) QuitMinigameEvent(au.com.mineauz.minigames.events.QuitMinigameEvent) Player(org.bukkit.entity.Player) StoredGameStats(au.com.mineauz.minigames.stats.StoredGameStats) PotionEffect(org.bukkit.potion.PotionEffect) Team(au.com.mineauz.minigames.minigame.Team) Minigame(au.com.mineauz.minigames.minigame.Minigame) DynamicMinigameStat(au.com.mineauz.minigames.stats.DynamicMinigameStat)

Aggregations

PotionEffect (org.bukkit.potion.PotionEffect)224 Player (org.bukkit.entity.Player)61 PotionEffectType (org.bukkit.potion.PotionEffectType)39 Location (org.bukkit.Location)37 LivingEntity (org.bukkit.entity.LivingEntity)37 EventHandler (org.bukkit.event.EventHandler)36 ItemStack (org.bukkit.inventory.ItemStack)34 ArrayList (java.util.ArrayList)31 Entity (org.bukkit.entity.Entity)23 PotionMeta (org.bukkit.inventory.meta.PotionMeta)18 Vector (org.bukkit.util.Vector)16 Random (java.util.Random)14 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)11 ItemMeta (org.bukkit.inventory.meta.ItemMeta)10 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)9 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)9 Material (org.bukkit.Material)7 Enchantment (org.bukkit.enchantments.Enchantment)7 Projectile (org.bukkit.entity.Projectile)7 PotionData (org.bukkit.potion.PotionData)7