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


Java PotionEffectType类代码示例

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


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

示例1: onPotionSplash

import org.bukkit.potion.PotionEffectType; //导入依赖的package包/类
@EventHandler
public void onPotionSplash(PotionSplashEvent event)
{
    PotionEffect actual = null;

    for (PotionEffect potionEffect : event.getPotion().getEffects())
    {
        if (potionEffect.getType().getName().equals("POISON"))
        {
            actual = potionEffect;
            break;
        }
    }

    if (actual != null)
    {
        event.setCancelled(true);
        event.getAffectedEntities().forEach(entity -> entity.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 8 * 20, 0)));
    }
}
 
开发者ID:SamaGames,项目名称:DoubleRunner,代码行数:21,代码来源:DoubleRunnerGameLoop.java

示例2: CraftMetaPotion

import org.bukkit.potion.PotionEffectType; //导入依赖的package包/类
CraftMetaPotion(net.minecraft.nbt.NBTTagCompound tag) {
    super(tag);

    if (tag.hasKey(POTION_EFFECTS.NBT)) {
        net.minecraft.nbt.NBTTagList list = tag.getTagList(POTION_EFFECTS.NBT, 10);
        int length = list.tagCount();
        if (length > 0) {
            customEffects = new ArrayList<PotionEffect>(length);

            for (int i = 0; i < length; i++) {
                net.minecraft.nbt.NBTTagCompound effect = list.getCompoundTagAt(i);
                PotionEffectType type = PotionEffectType.getById(effect.getByte(ID.NBT));
                int amp = effect.getByte(AMPLIFIER.NBT);
                int duration = effect.getInteger(DURATION.NBT);
                boolean ambient = effect.getBoolean(AMBIENT.NBT);
                customEffects.add(new PotionEffect(type, duration, amp, ambient));
            }
        }
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:21,代码来源:CraftMetaPotion.java

示例3: getEffectsFromDamage

import org.bukkit.potion.PotionEffectType; //导入依赖的package包/类
public Collection<PotionEffect> getEffectsFromDamage(int damage) {
    if (cache.containsKey(damage))
        return cache.get(damage);

    List<?> mcEffects = net.minecraft.potion.PotionHelper.getPotionEffects(damage, false);
    List<PotionEffect> effects = new ArrayList<PotionEffect>();
    if (mcEffects == null)
        return effects;

    for (Object raw : mcEffects) {
        if (raw == null || !(raw instanceof net.minecraft.potion.PotionEffect))
            continue;
        net.minecraft.potion.PotionEffect mcEffect = (net.minecraft.potion.PotionEffect) raw;
        PotionEffect effect = new PotionEffect(PotionEffectType.getById(mcEffect.getPotionID()),
                mcEffect.getDuration(), mcEffect.getAmplifier());
        // Minecraft PotionBrewer applies duration modifiers automatically.
        effects.add(effect);
    }

    cache.put(damage, effects);

    return effects;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:24,代码来源:CraftPotionBrewer.java

示例4: equipEffectsTask

import org.bukkit.potion.PotionEffectType; //导入依赖的package包/类
public void equipEffectsTask() {
    RScheduler.schedule(plugin, new Runnable() {
        public void run() {
            if (isValid()) {
                Player p = getPlayer();
                EntityEquipment ee = p.getEquipment();
                if (ee.getHelmet() != null && ItemManager.isItem(ee.getHelmet(), "miner_helmet")) {
                    if (!equipStates.contains("miner_helmet")) {
                        p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, true, false), true);
                        equipStates.add("miner_helmet");
                    }
                } else {
                    if (equipStates.contains("miner_helmet")) {
                        equipStates.remove("miner_helmet");
                        p.removePotionEffect(PotionEffectType.NIGHT_VISION);
                    }
                }
                RScheduler.schedule(plugin, this, RTicks.seconds(1));
            }
        }
    });
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:23,代码来源:PlayerDataRPG.java

示例5: giveSlow

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

示例6: castSpell

import org.bukkit.potion.PotionEffectType; //导入依赖的package包/类
public void castSpell(final LivingEntity caster, final MobData md, Player target) {
    ArrayList<Location> locs = RLocation.findCastableLocs(caster.getLocation(), range, count);
    for (Location loc : locs) {
        FreezeSpellEffect effect = new FreezeSpellEffect(EffectFactory.em(), loc.add(0, 0.15, 0), 3);
        effect.setEntity(caster);
        effect.start();
        RScheduler.schedule(Spell.plugin, () -> {
            Entity activator = null;
            for (Entity e : RMath.getNearbyEntities(loc, 1)) {
                if (e instanceof Player && Spell.canDamage(e, false)) {
                    ((Player) e).addPotionEffect(new PotionEffect(PotionEffectType.JUMP, RTicks.seconds(durationSec), -100), false);
                    ((Player) e).addPotionEffect(new PotionEffect(PotionEffectType.SPEED, RTicks.seconds(durationSec), -100), false);
                    activator = e;
                }
            }
            if (activator != null) {
                FreezeSpellEndEffect end = new FreezeSpellEndEffect(EffectFactory.em(), loc, durationSec);
                end.setEntity(activator);
                end.start();
            }
        }, RTicks.seconds(3));
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:24,代码来源:FreezeSpell.java

示例7: craftPotionEffect

import org.bukkit.potion.PotionEffectType; //导入依赖的package包/类
public static PotionEffect craftPotionEffect(String name, ConfigurationSection section) {
	if(section == null){
		Error.MISSING.add();
		return null;
	}
	PotionEffectType effect = PotionEffectType.getByName(name);
	if( effect == null ) {
		ErrorLogger.addError(name + " is not a valid potion effect type !");
		return null;
	}
	int duration = section.getInt(Node.DURATION.get(), 120)*20;
	int amplifier = section.getInt(Node.LEVEL.get(), 1) - 1;
	boolean ambient = section.getBoolean(Node.AMBIANT.get(), true);
	boolean particles = section.getBoolean(Node.PARTICLE.get(), true);
	return new PotionEffect(effect, duration, amplifier, ambient, particles);
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:17,代码来源:MinecraftUtils.java

示例8: onPotionSplash

import org.bukkit.potion.PotionEffectType; //导入依赖的package包/类
/**
 * Patching witch's potions
 *
 * @param event Event
 */
@EventHandler
public void onPotionSplash(PotionSplashEvent event)
{
    ThrownPotion potion = event.getPotion();

    if (potion.getShooter() instanceof Witch)
    {
        event.setCancelled(true);

        List<PotionEffectType> potionEffects = new ArrayList<>();
        potionEffects.add(PotionEffectType.SLOW_DIGGING);
        potionEffects.add(PotionEffectType.CONFUSION);
        potionEffects.add(PotionEffectType.NIGHT_VISION);
        potionEffects.add(PotionEffectType.HUNGER);
        potionEffects.add(PotionEffectType.BLINDNESS);

        PotionEffect selected = new PotionEffect(potionEffects.get(new Random().nextInt(potionEffects.size())), 20 * 15, 1);

        for (LivingEntity ent : event.getAffectedEntities())
            ent.addPotionEffect(selected);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:28,代码来源:NaturalListener.java

示例9: onPlayerMove

import org.bukkit.potion.PotionEffectType; //导入依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
	final Gamer g = Gamer.get(event.getPlayer());

	if (g.getVariable("spectator") != null)
		return;
	
	if (g.getVariable("kit") != Kit.get("tank"))
		return;
	
	g.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1, 100), true);
	
	if (g.getPlayer().isSprinting()) {
		new BukkitRunnable() {
			public void run() {
				g.getPlayer().setSprinting(false);
			}
		}.runTaskLater(Nexus.getPlugin(), 1);
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:21,代码来源:KitEvents.java

示例10: buildFromJson

import org.bukkit.potion.PotionEffectType; //导入依赖的package包/类
@Override
public Map<String, Object> buildFromJson(Map<String, JsonElement> configuration) throws Exception
{
    if (configuration.containsKey("effects"))
    {
        JsonArray potionEffectsJson = configuration.get("effects").getAsJsonArray();

        for (int i = 0; i < potionEffectsJson.size(); i++)
        {
            JsonObject potionEffectJson = potionEffectsJson.get(i).getAsJsonObject();
            this.addPotionEffect(PotionEffectType.getByName(potionEffectJson.get("effect").getAsString()), potionEffectJson.get("level").getAsInt());
        }
    }

    return this.build();
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:17,代码来源:ConstantPotionModule.java

示例11: create

import org.bukkit.potion.PotionEffectType; //导入依赖的package包/类
public static Pig create(Location l) {
	Pig hov = (Pig) l.getWorld().spawnEntity(l, EntityType.PIG);
	
	hov.setSaddle(true);
	hov.setCustomName("HoverBike");
	hov.addScoreboardTag("speed:10");
	hov.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 30, true, false));
	hov.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, true, false));
	//hov.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 1, true, false));
	hov.setAI(false);
	hov.setGravity(true);
	hov.setSilent(true);
	
	hov.setMaxHealth(100);
	hov.setHealth(100);
	
	return hov;
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:19,代码来源:HoverBike.java

示例12: onAttack

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

示例13: onEntityDamage

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

示例14: parseCompactPotionEffect

import org.bukkit.potion.PotionEffectType; //导入依赖的package包/类
public static PotionEffect parseCompactPotionEffect(Node node, String text) throws InvalidXMLException {
    String[] parts = text.split(":");

    if(parts.length == 0) throw new InvalidXMLException("Missing potion effect", node);
    PotionEffectType type = parsePotionEffectType(node, parts[0]);
    Duration duration = TimeUtils.INF_POSITIVE;
    int amplifier = 0;
    boolean ambient = false;

    if(parts.length >= 2) {
        duration = parseTickDuration(node, parts[1]);
        if(parts.length >= 3) {
            amplifier = parseNumber(node, parts[2], Integer.class);
            if(parts.length >= 4) {
                ambient = parseBoolean(node, parts[3]);
            }
        }
    }

    return createPotionEffect(node, type, duration, amplifier, ambient);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:22,代码来源:XMLUtils.java

示例15: checkAscension

import org.bukkit.potion.PotionEffectType; //导入依赖的package包/类
public void checkAscension(Player player, double y1, double y2) {
    int max = MagicNumbers.ASCENSION_COUNT_MAX;
    if(player.hasPotionEffect(PotionEffectType.JUMP)) {
        max += 12;
    }
    Block block = player.getLocation().getBlock();
    if(!isMovingExempt(player) && !Utilities.isInWater(player) && !player.isFlying() && !Utilities
            .isClimbableBlock(player.getLocation().getBlock()) && !player.isInsideVehicle() && !MOVE_UP_BLOCKS
            .contains(player.getLocation().add(0,-1,0).getBlock().getType()) && !MOVE_UP_BLOCKS.contains(player
            .getLocation().add(0,-1.5,0).getBlock().getType())) {
        if(y1 < y2) {
            if(!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid() && !block.getRelative(BlockFace.EAST).isLiquid() && !block.getRelative(BlockFace.WEST).isLiquid()) {
                incrementOld(player,ascensionCount,max);
                if(ascensionCount.get(player) > max) {
                    for(Player pla : DynamicAC.instance.onlinestaff) {
                        pla.sendMessage(DynamicAC.prefix + player.getName() + " ascended Y Axis too fast!");
                    }
                    DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName
                            ()),"Climbed too fast");
                }
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:25,代码来源:BackendChecks.java


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