当前位置: 首页>>代码示例>>Java>>正文


Java PotionEffect类代码示例

本文整理汇总了Java中org.bukkit.potion.PotionEffect的典型用法代码示例。如果您正苦于以下问题:Java PotionEffect类的具体用法?Java PotionEffect怎么用?Java PotionEffect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PotionEffect类属于org.bukkit.potion包,在下文中一共展示了PotionEffect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resetPlayer

import org.bukkit.potion.PotionEffect; //导入依赖的package包/类
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);
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:25,代码来源:Utils.java

示例2: onPlayerDeath

import org.bukkit.potion.PotionEffect; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:23,代码来源:CookieHeadModule.java

示例3: read

import org.bukkit.potion.PotionEffect; //导入依赖的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

示例4: ProjectileDefinitionImpl

import org.bukkit.potion.PotionEffect; //导入依赖的package包/类
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;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:20,代码来源:ProjectileDefinition.java

示例5: spawnVillager

import org.bukkit.potion.PotionEffect; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:24,代码来源:VillagerManager.java

示例6: applyToItem

import org.bukkit.potion.PotionEffect; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:18,代码来源:CraftMetaPotion.java

示例7: addCustomEffect

import org.bukkit.potion.PotionEffect; //导入依赖的package包/类
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;
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:24,代码来源:CraftMetaPotion.java

示例8: handleSlowdown

import org.bukkit.potion.PotionEffect; //导入依赖的package包/类
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);
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:25,代码来源:RuneManager.java

示例9: giveSlow

import org.bukkit.potion.PotionEffect; //导入依赖的package包/类
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);
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:18,代码来源:PlayerDataRPG.java

示例10: ObsidianMace

import org.bukkit.potion.PotionEffect; //导入依赖的package包/类
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);
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:20,代码来源:Survival.java

示例11: onBlockBreak

import org.bukkit.potion.PotionEffect; //导入依赖的package包/类
/**
 * 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));
    }
  }
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:21,代码来源:BlastMining.java

示例12: giveKit

import org.bukkit.potion.PotionEffect; //导入依赖的package包/类
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());
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:24,代码来源:Kit.java

示例13: onEat

import org.bukkit.potion.PotionEffect; //导入依赖的package包/类
@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));
    }
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:19,代码来源:MatchListener.java

示例14: onPlayerInteract

import org.bukkit.potion.PotionEffect; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:23,代码来源:CookieHeadModule.java

示例15: onAttack

import org.bukkit.potion.PotionEffect; //导入依赖的package包/类
@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);
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:21,代码来源:StarBattleaxeWither.java


注:本文中的org.bukkit.potion.PotionEffect类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。