Java 类org.bukkit.potion.PotionEffect 实例源码

项目:SurvivalAPI    文件:CookieHeadModule.java   
/**
 * Drop player head on kill
 *
 * @param event Event
 */
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
    ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);

    SkullMeta skullMeta = (SkullMeta)head.getItemMeta();
    skullMeta.setOwner(event.getEntity().getName());
    skullMeta.setDisplayName(ChatColor.AQUA + "Tête de " + event.getEntity().getName());

    head.setItemMeta(skullMeta);
    event.getDrops().add(head);

    List<PotionEffect> effectList = new ArrayList<>();
    effectList.addAll(event.getEntity().getActivePotionEffects());

    this.effects.put(event.getEntity().getName(), effectList);
}
项目:Leveled-Storage    文件:PotionEffectStorage.java   
@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
    ));
}
项目:ProjectAres    文件:ProjectileDefinition.java   
public ProjectileDefinitionImpl(@Nullable String name,
                                @Nullable Double damage,
                                double velocity,
                                ClickAction clickAction,
                                Class<? extends Entity> entity,
                                List<PotionEffect> potion,
                                Filter destroyFilter,
                                Duration coolDown,
                                boolean throwable) {
    this.name = name;
    this.damage = damage;
    this.velocity = velocity;
    this.clickAction = clickAction;
    this.projectile = entity;
    this.potion = potion;
    this.destroyFilter = destroyFilter;
    this.coolDown = coolDown;
    this.throwable = throwable;
}
项目:Chambers    文件:VillagerManager.java   
/**
 * Spawns a Villager of the given VillagerType at the provided Location
 * 
 * @param type - the Type of the Villager you wish to Spawn
 * @param location - the Location at which you want the Villager to be
 * @return Villager - the Villager that you had set at the provided Location if you wish to use it
 */
public Villager spawnVillager(VillagerType type, Location location) {
    if (!location.getChunk().isLoaded()) {
        location.getChunk().load();
    }
    Villager villager = (Villager) location.getWorld().spawnEntity(location, EntityType.VILLAGER);
    villager.setAdult();
    villager.setAgeLock(true);
    villager.setProfession(Profession.FARMER);
    villager.setRemoveWhenFarAway(false);
    villager.setCustomName(type.getColor() + type.getName());
    villager.setCustomNameVisible(true);
    villager.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, -6, true), true);
    villager.teleport(location, TeleportCause.PLUGIN);
    villager.setHealth(20.0D);
    return villager;
}
项目:Uranium    文件:CraftMetaPotion.java   
@Override
void applyToItem(net.minecraft.nbt.NBTTagCompound tag) {
    super.applyToItem(tag);
    if (hasCustomEffects()) {
        net.minecraft.nbt.NBTTagList effectList = new net.minecraft.nbt.NBTTagList();
        tag.setTag(POTION_EFFECTS.NBT, effectList);

        for (PotionEffect effect : customEffects) {
            net.minecraft.nbt.NBTTagCompound effectData = new net.minecraft.nbt.NBTTagCompound();
            effectData.setByte(ID.NBT, (byte) effect.getType().getId());
            effectData.setByte(AMPLIFIER.NBT, (byte) effect.getAmplifier());
            effectData.setInteger(DURATION.NBT, effect.getDuration());
            effectData.setBoolean(AMBIENT.NBT, effect.isAmbient());
            effectList.appendTag(effectData);
        }
    }
}
项目:Uranium    文件:CraftMetaPotion.java   
public boolean addCustomEffect(PotionEffect effect, boolean overwrite) {
    Validate.notNull(effect, "Potion effect must not be null");

    int index = indexOfEffect(effect.getType());
    if (index != -1) {
        if (overwrite) {
            PotionEffect old = customEffects.get(index);
            if (old.getAmplifier() == effect.getAmplifier() && old.getDuration() == effect.getDuration() && old.isAmbient() == effect.isAmbient()) {
                return false;
            }
            customEffects.set(index, effect);
            return true;
        } else {
            return false;
        }
    } else {
        if (customEffects == null) {
            customEffects = new ArrayList<PotionEffect>();
        }
        customEffects.add(effect);
        return true;
    }
}
项目:AsgardAscension    文件:RuneManager.java   
private void handleSlowdown(Player player, Rune rune) {
    new BukkitRunnable() {
        int iterations = 0;
        public void run() {
            if(!player.isOnline() || iterations / 2 >= rune.getDuration()) {
                finish(player, true);
                this.cancel();
                return;
            }

            for(Entity entity : player.getNearbyEntities(3D, 3D, 3D)) {
                if(!(entity instanceof Player)) {
                    continue;
                }
                Player target = (Player) entity;

                if(Utility.canAttack(player, target)) {
                    target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 40, 0));
                }
            }
            iterations++;
        }
    }.runTaskTimer(plugin, 0L, 10L);
}
项目:ZentrelaRPG    文件:PlayerDataRPG.java   
public void giveSlow(int durationSeconds, int tier) {
    int highestTier = tier;
    int remaining = 0;
    Player p = getPlayer();
    if (p == null)
        return;
    for (PotionEffect pe : p.getActivePotionEffects()) {
        if (pe.getType().equals(PotionEffectType.SLOW)) {
            remaining = pe.getDuration();
            int temp = pe.getAmplifier();
            if (temp > highestTier)
                highestTier = temp;
        }
    }

    p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, RTicks.seconds(durationSeconds) + (remaining / 2), highestTier), true);
}
项目:SurvivalPlus    文件:Survival.java   
public void ObsidianMace()
{
    getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
           public void run() {
               for(Player player : getServer().getOnlinePlayers())
               {
                   if(player.getInventory().getItemInMainHand().getType() == Material.GOLD_SPADE)
                   {
                       player.removePotionEffect(PotionEffectType.SLOW);
                       player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, 1, false));
                       Location particleLoc = player.getLocation();
                       particleLoc.setY(particleLoc.getY() + 1);
                       ParticleEffect.CRIT.display(0.5f, 0.5f, 0.5f, 0.5f, 10, particleLoc, 64);
                       ParticleEffect.PORTAL.display(0.5f, 0.5f, 0.5f, 0.5f, 20, particleLoc, 64);
                   }
               }
           }
       }, 1L, 10L);
}
项目:OpenUHC    文件:BlastMining.java   
/**
 * Spawns a creeper or primed TNT when a player breaks an ore block, by chance.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
  Block block = event.getBlock();
  if (ORES.contains(block.getType())) {
    double chance = Math.random();
    Location location = block.getLocation().add(0.5, 0.5, 0.5);
    if (0.05 > chance) {
      TNTPrimed tnt = location.getWorld().spawn(location, TNTPrimed.class);
      tnt.setFuseTicks(80);
    } else if (0.1 > chance) {
      Creeper creeper = location.getWorld().spawn(location, Creeper.class);
      creeper.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 2));
    }
  }
}
项目:mczone    文件:Kit.java   
public static void giveKit(final Player p) {
    Kit k = getKit(p);

    p.getInventory().clear();
    p.getInventory().setArmorContents(null);

    for (ItemStack i : k.getItems()) {
        int id = i.getType().getId();
        if ((id < 298) || (317 < id))
               p.getInventory().addItem(i);
        else if ((id == 298) || (id == 302)     || (id == 306) || (id == 310)   || (id == 314))
                p.getInventory().setHelmet(new ItemStack(id, 1));
        else if ((id == 299) || (id == 303)     || (id == 307) || (id == 311) || (id == 315))
                p.getInventory().setChestplate(new ItemStack(id, 1));
        else if ((id == 300) || (id == 304) || (id == 308) || (id == 312) || (id == 316))
                p.getInventory().setLeggings(new ItemStack(id, 1));
        else if ((id == 301) || (id == 305) || (id == 309) || (id == 313) || (id == 317))
                p.getInventory().setBoots(new ItemStack(id, 1));
    }
    p.getInventory().addItem(new ItemStack(Material.COMPASS));
    for (PotionEffect potion : p.getActivePotionEffects())
        p.removePotionEffect(potion.getType());
}
项目:Arcadia-Spigot    文件:Utils.java   
public static void resetPlayer(Player player) {
    player.setLevel(0);
    player.setExp(0);
    player.setFoodLevel(20);
    player.setHealth(20);
    player.setHealthScale(20);
    player.setExhaustion(0);
    player.getInventory().clear();
    ItemStack blankItem = new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) 15);
    ItemMeta blankMeta = blankItem.getItemMeta();
    blankMeta.setDisplayName("" + ChatColor.RED);
    blankItem.setItemMeta(blankMeta);
    for(int i=9; i<=35; i++) {
        player.getInventory().setItem(i, blankItem);
    }
    player.getInventory().setHelmet(new ItemStack(Material.AIR, 1));
    player.getInventory().setChestplate(new ItemStack(Material.AIR, 1));
    player.getInventory().setLeggings(new ItemStack(Material.AIR, 1));
    player.getInventory().setBoots(new ItemStack(Material.AIR, 1));
    for(PotionEffect potionEffect : player.getActivePotionEffects()) {
        player.removePotionEffect(potionEffect.getType());
    }
    player.setFireTicks(0);
}
项目:ZorahPractice    文件:MatchListener.java   
@EventHandler
public void onEat(PlayerItemConsumeEvent event) {
    Player player = event.getPlayer();
    PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);

    if (profile.getStatus() != PlayerStatus.PLAYING) {
        return;
    }

    if (!event.getItem().getItemMeta().hasDisplayName()) {
        return;
    }

    if (event.getItem().getItemMeta().getDisplayName().equals(ChatColor.GOLD + "Golden Head")) {
        player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 240, 0));
        player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 100, 2));
    }
}
项目:SurvivalAPI    文件:CookieHeadModule.java   
/**
 * Give old player enchants on head eating
 *
 * @param event Event
 */
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
    if (event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM || event.getItem().getDurability() != 3
            || (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK))
        return;

    SkullMeta skullMeta = (SkullMeta)event.getItem().getItemMeta();
    List<PotionEffect> effectList = this.effects.get(skullMeta.getOwner());

    if (effectList != null)
    {
        effectList.forEach(event.getPlayer()::addPotionEffect);
        this.effects.remove(skullMeta.getOwner());
        event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.BURP, 1F, 1F);
    }
}
项目:SurvivalPlus    文件:StarBattleaxeWither.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
    if(event.isCancelled()) return;
    if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
    {
        Player player = (Player)event.getDamager();
        ItemStack mainItem = player.getInventory().getItemInMainHand();
        LivingEntity enemy = (LivingEntity)event.getEntity();

        Random rand = new Random();

        if(mainItem.getType() == Material.GOLD_AXE)
        {
            enemy.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 480, 2, false));
            enemy.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 480, 0, false));
            enemy.getLocation().getWorld().playSound(enemy.getLocation(), Sound.ENTITY_WITHER_SPAWN, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
        }
    }
}
项目:AsgardAscension    文件:CustomEnchantsListener.java   
@EventHandler
public void onEntityDamage(EntityDamageByEntityEvent event) {
    if(event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
        Player damager = (Player) event.getDamager();
        if(damager.getInventory().getItemInMainHand() == null)
            return;
        if(!damager.getInventory().getItemInMainHand().hasItemMeta())
            return;
        if(damager.getInventory().getItemInMainHand().getItemMeta().getLore() == null)
            return;
        Player victim = (Player) event.getEntity();
        if(!Utility.canAttack(damager, victim)) 
            return;
        List<String> lore = damager.getInventory().getItemInMainHand().getItemMeta().getLore();
        if(contains(lore, "Wither Damage")) {
            victim.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 200, 1));
        }
        if(contains(lore,"Fire Damage")) {
            victim.setFireTicks(100);
        }
        if(contains(lore,"Poison Damage")) {
            victim.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 200, 0));
        }
    }
}
项目:KingdomFactions    文件:Confuse.java   
@Override
public void execute(KingdomFactionsPlayer player) {

    setLocation(player.getPlayer().getTargetBlock((Set<Material>) null, 80).getLocation());

    SpellExecuteEvent event = new SpellExecuteEvent(executeLocation, this, player);
    if (event.isCancelled())
        return;
    playEffect(executeLocation);
    for (Entity e : Utils.getInstance().getNearbyEntities(executeLocation, 3)) {
        if (e instanceof LivingEntity) {
            LivingEntity en = (LivingEntity) e;

            if (e instanceof Player) {
                Player p = (Player) e;
                if (PlayerModule.getInstance().getPlayer(p).isVanished()) continue;
                en.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 5 * 20, 1));
                en.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 5 * 20, 1));
                en.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 5 * 20, 1));
            }
        }
    }

}
项目:AgarMC    文件:AgarGame.java   
@Override
public void handleLogin(Player p)
{
    super.handleLogin(p);
    p.setGameMode(GameMode.ADVENTURE);
    p.setLevel(0);
    p.setExp(0);
    p.setFoodLevel(20);
    p.setSaturation(20);

    Location spec = new Location(AgarMC.get().getWorld(), origin.getX() + dimensions / 2, origin.getY() + 20, origin.getZ() + dimensions / 2);
    spec.setPitch(90);
    p.teleport(spec);
    p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1));
    if (gamePlayers.size() >= SamaGamesAPI.get().getGameManager().getGameProperties().getMaxSlots())
        this.status = Status.IN_GAME;
    Titles.sendTabTitle(p, ChatColor.GREEN + "Bienvenue sur " + ChatColor.AQUA + "SamaGames" + ChatColor.GREEN + " !\n",
            ChatColor.AQUA + "\nTeamSpeak : " + ChatColor.GREEN + "ts.samagames.net");
}
项目:QuarSK    文件:SExprItemEffectTypeDuration.java   
@Nullable
@Override
protected Timespan[] get(Event e) {
    ItemStack i = item.getSingle(e);
    if (i == null) {
        return null;
    }
    if (PotionUtils.isPotionItem(i)) {
        PotionMeta meta = (PotionMeta) i.getItemMeta();
        PotionEffect eff = PotionUtils.getEffectByEffectType(meta, effectType.getSingle(e));
        if (eff == null) {
            return null;
        }
        return new Timespan[]{Timespan.fromTicks_i(eff.getDuration())};
    }
    return null;
}
项目:HCFCore    文件:AssassinClass.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.hasItem() && event.getItem().getType() == Material.GOLDEN_CARROT) {
        Player player = event.getPlayer();
        if (plugin.getPvpClassManager().getEquippedClass(player) == this) {
            long timestamp = cooldowns.get(player.getUniqueId());
            long millis = System.currentTimeMillis();
            long remaining = timestamp == cooldowns.getNoEntryValue() ? 0L : timestamp - millis;
            if (remaining > 0L) {
                player.sendMessage(ChatColor.RED + "Cooldown still for " + DurationFormatUtils.formatDurationWords(remaining, true, true) + ".");
                return;
            }

            cooldowns.put(player.getUniqueId(), millis + 15000L);
            plugin.getEffectRestorer().setRestoreEffect(player, new PotionEffect(PotionEffectType.SPEED, 100, 4));
            plugin.getEffectRestorer().setRestoreEffect(player, new PotionEffect(PotionEffectType.INVISIBILITY, 100, 0));
        }
    }
}
项目:mczone    文件:Kit.java   
public static void giveKit(final Player p) {
    Gamer g = Gamer.get(p.getName());
    g.clearInventory();
    Kit k = (Kit) g.getVariable("kit");

    if (k == null) {
        g.setVariable("kit", Kit.get("bruiser"));
        k = Kit.get("bruiser");
    }

    List<ItemStack> items = k.getItems();
    for (ItemStack i : items)
        g.giveItem(i);

    g.removePotionEffects();

    for (PotionEffect effect : k.getEffects())
        g.addPotionEffect(effect, false);
}
项目:ProjectAres    文件:GhostSquadronMatchModule.java   
public void spideySense(final MatchPlayer player) {
    UserId userId = player.getPlayerId();

    Date when = this.spideySenses.get(userId);
    Date now = new Date();

    if(when == null || now.getTime() > when.getTime() + GhostSquadron.SPIDEY_SENSE_COOLDOWN) {
        this.spideySenses.put(userId, now);

        player.getBukkit().addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 4 * 20, 0), true);
        player.getBukkit().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 4 * 20, 1), true);

        player.getBukkit().playSound(player.getBukkit().getLocation(), Sound.ENTITY_SPIDER_AMBIENT, 5, 0);
        player.getBukkit().playSound(player.getBukkit().getLocation(), Sound.ENTITY_SPIDER_AMBIENT, 5, 0.25f);
        player.getBukkit().playSound(player.getBukkit().getLocation(), Sound.ENTITY_SPIDER_AMBIENT, 5, 0.5f);
    }
}
项目:Arc-v2    文件:Speed17.java   
/**
 * Return our base move speed.
 *
 * @param player the player
 * @return players move speed
 */
private double getBaseMoveSpeed(Player player) {
    double baseSpeed = 0.2873;

    for (PotionEffect ef : player.getActivePotionEffects()) {
        if (ef.getType().equals(PotionEffectType.SPEED)) {
            baseSpeed *= 1.0 + 0.2 * ef.getAmplifier() + 1;
        }
    }

    return baseSpeed;
}
项目:uppercore    文件:PotionCustomItem.java   
public PotionCustomItem(Material material, Config config, PlaceholderRegistry placeholders) {
    super(material, config, placeholders);
    type = config.getEnum("potion-type", PotionType.class);
    customColor = PlaceholderValue.colorValue(config.getString("color"));
    customEffects = new ArrayList<>();
    Collection<Map<String, Object>> rawEffects = (Collection<Map<String, Object>>) config.getCollection("effects");
    if(rawEffects != null) {
        for (Map<String, Object> e : rawEffects)
            customEffects.add(new PotionEffect(e));
    }
}
项目:HCFCore    文件:ArcherClass.java   
public ArcherClass(HCF plugin)
{
    super("Archer", TimeUnit.SECONDS.toMillis(5L));
    this.plugin = plugin;
    this.passiveEffects.add(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 1));
    this.passiveEffects.add(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 2));
}
项目:SaveableSerializing    文件:PotionMeta.java   
@Override
public SubMeta setFrom(ItemMeta meta) {
    if(meta instanceof org.bukkit.inventory.meta.PotionMeta) {
        org.bukkit.inventory.meta.PotionMeta metar = (org.bukkit.inventory.meta.PotionMeta) meta;
        for(PotionEffect ef : metar.getCustomEffects())
            data.add(new PotionEffects(ef));
    }
    return this;
}
项目:Warzone    文件:InfectionModule.java   
private void refresh(PlayerContext playerContext, MatchTeam matchTeam) {
    Players.reset(playerContext.getPlayer(), true);

    matchTeam.getKits().forEach(kit -> kit.apply(playerContext.getPlayer(), matchTeam));
    playerContext.getPlayer().updateInventory();
    playerContext.getPlayer().teleport(matchTeam.getSpawnPoints().get(0).getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
    playerContext.getPlayer().setGameMode(GameMode.ADVENTURE);
    playerContext.getPlayer().addPotionEffects(Collections.singleton(new PotionEffect(PotionEffectType.JUMP, 10000, 2, true, false)));

}
项目:Warzone    文件:InfectionModule.java   
public void unfreeze(Player player) {
    player.removePotionEffect(PotionEffectType.JUMP);
    player.removePotionEffect(PotionEffectType.SLOW);
    player.removePotionEffect(PotionEffectType.BLINDNESS);

    player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 50000, 1, true, false));
}
项目:SurvivalPlus    文件:RawMeatHunger.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsume(PlayerItemConsumeEvent event)
{
    if(event.isCancelled()) return;
    Random rand = new Random();
    Player player = event.getPlayer();
    switch(event.getItem().getType())
    {
        case RAW_BEEF:
        case PORK:
        case MUTTON:
        case RAW_FISH:
        case RAW_CHICKEN:
        case ROTTEN_FLESH:
            int hungerChance = rand.nextInt(10) + 1;
            if(hungerChance >= 1 && hungerChance <= 8)
            {
                int dur = 600;
                for (PotionEffect effect : player.getActivePotionEffects())
                {
                    if(effect.getType().equals(PotionEffectType.HUNGER))
                    {
                        dur += effect.getDuration();
                        player.removePotionEffect(effect.getType());
                    }
                }
                player.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, dur, 0, false));
            }
            break;
        default:
    }
}
项目:SurvivalAPI    文件:GameListener.java   
/**
 * Increase the Regeneration boost when a golden apple is eaten
 *
 * @param event Event
 */
@EventHandler
public void onItemConsume(PlayerItemConsumeEvent event)
{
    if (this.game instanceof RunBasedGame && event.getItem().getType() == Material.GOLDEN_APPLE)
        event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 10 * 20, 1));
}
项目:PA    文件:Fantasma.java   
public void play(TOAUser u) {
    if (!canUse(u)) return;
    if (isInCooldown(u, getName())) return;

    u.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 100, 0, true, false));
    u.getPlayer().setWalkSpeed(0.4f);
    plugin.getServer().getScheduler().runTaskLater(plugin, () -> Race.parseRace(getRace().getId()).addEffects(u), 100);
    cool.setOnCooldown(getName());
}
项目:BlockBall    文件:CustomRabbit.java   
void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    this.getSpigotEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    this.getSpigotEntity().setCustomNameVisible(false);
    this.getSpigotEntity().setCustomName("MyBallsIdentifier");
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
项目:ProjectAres    文件:PotionClassificationTest.java   
@Test
public void classifyByMostEffects() throws Exception {
    assertEquals(BENEFICIAL, classify(ImmutableList.of(
        new PotionEffect(SPEED, 1, 0),
        new PotionEffect(HARM, 1, 0),
        new PotionEffect(LUCK, 1, 0)
    )));

    assertEquals(HARMFUL, classify(ImmutableList.of(
        new PotionEffect(SLOW, 1, 0),
        new PotionEffect(HEAL, 1, 0),
        new PotionEffect(UNLUCK, 1, 0)
    )));
}
项目:ZentrelaRPG    文件:PlayerDataRPG.java   
/**
* Runs after data has been loaded from SQL database
*/
@Override
public void postLoad(final Player p) {
    if (p != null && isValid()) {
        if (!PunishmentManager.ips_byUUID.containsKey(p.getUniqueId().toString())) {
            String ip = PunishmentManager.parseIP(p.getAddress());
            PunishmentManager.registerIP(p.getUniqueId(), ip);
        } else {
            knownIPs.add(PunishmentManager.ips_byUUID.get(p.getUniqueId().toString()));
        }
        dead = false;
        baseMaxHP = getBaseMaxHP();
        updateEquipmentStats();
        for (PotionEffect pe : p.getActivePotionEffects())
            p.removePotionEffect(pe.getType());
        manaRegenTask();
        hpDisplayAndRegenTask();
        specialEffectsTask();
        everySecondTask();
        equipEffectsTask();
        saveTask();
        statusEffectTask();
        updateHealthManaDisplay();
        RegionManager.checkRegion(p, this);
        checkBuycraft(true);
        p.getInventory().clear();
        p.setGameMode(loadedGamemode);
        for (Entry<Integer, ItemStack> e : loadedInventory.entrySet()) {
            p.getInventory().setItem(e.getKey(), e.getValue());
        }
        updateEquipmentStats();
        hp = loadedHP;
        p.teleport(loadedLocation);
        RMessages.sendTitle(p, " ", " ", 1, 1, 1);
        checkBuycraft(false); // not in lobby
        RegionManager.checkRegion(p, this);
    }
}
项目:BlockBall    文件:CustomRabbit.java   
void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    this.getSpigotEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    this.getSpigotEntity().setCustomNameVisible(false);
    this.getSpigotEntity().setCustomName("MyBallsIdentifier");
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
项目:ZentrelaRPG    文件:PlayerDataRPG.java   
public void removeStealth() {
    if (!isStealthed())
        return;
    stealthCounter++;
    stealthed = false;
    Player p = getPlayer();
    if (p != null && p.isValid()) {
        StealthManager.removeStealth(p);
        for (PotionEffect pe : p.getActivePotionEffects())
            p.removePotionEffect(pe.getType());
    }
}
项目:Leveled-Storage    文件:PotionEffectStorage.java   
@Override
public StorageObject delegate() {
    return new PotionEffectStorage(new PotionEffect(
            effect.getType(),
            effect.getDuration(), effect.getAmplifier(),
            effect.isAmbient(), effect.hasParticles(), effect.getColor()
    ));
}
项目:ProjectAres    文件:PotionClassificationTest.java   
@Test
public void classifyByAmplifier() throws Exception {
    assertEquals(BENEFICIAL, classify(ImmutableList.of(
        new PotionEffect(HEAL, 1, 1),
        new PotionEffect(HARM, 1, 0)
    )));

    assertEquals(HARMFUL, classify(ImmutableList.of(
        new PotionEffect(HEAL, 1, 0),
        new PotionEffect(HARM, 1, 1)
    )));
}
项目:Arcadia-Spigot    文件:DeadEndGame.java   
@Override
public void onPreStart() {
    Location spawnLocation = Utils.parseLocation((String) this.getGameMap().fetchSetting("startPosition"));
    PotionEffect potionEffect = new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 199);
    PotionEffect potionEffect2 = new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 2);
    for(Player player : Bukkit.getOnlinePlayers()) {
        if(!this.getAPI().getGameManager().isAlive(player)) continue;
        player.teleport(spawnLocation);
        player.setGameMode(GameMode.ADVENTURE);
        player.addPotionEffect(potionEffect, true);
        player.addPotionEffect(potionEffect2, true);
    }
}
项目:PetBlocks    文件:CustomZombie.java   
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_8_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}