类org.bukkit.potion.PotionEffectType源码实例Demo

下面列出了怎么用org.bukkit.potion.PotionEffectType的API类实例代码及写法,或者点击链接到github查看源代码。

@Test
public void serializePotionEffectWithParticlesAndColor() {
    // given
    ArrayList<PotionEffect> effects = new ArrayList<>();
    PotionEffect effect = new PotionEffect(PotionEffectType.CONFUSION, 30, 1, true, true, Color.AQUA);
    effects.add(effect);

    // when
    JsonArray serialized = PotionEffectSerializer.serialize(effects);

    // then
    JsonObject json = serialized.get(0).getAsJsonObject();
    assertTrue(json.get("type").getAsString().equals("CONFUSION"));
    assertTrue(json.get("amp").getAsInt() == 1);
    assertTrue(json.get("duration").getAsInt() == 30);
    assertTrue(json.get("ambient").getAsBoolean());
    assertTrue(json.get("particles").getAsBoolean());
    assertTrue(Color.fromRGB(json.get("color").getAsInt()) == Color.AQUA);
}
 
源代码2 项目: Sentinel   文件: SentinelUtilities.java
/**
 * Returns whether an entity is invisible (when invisible targets are ignorable).
 */
public static boolean isInvisible(LivingEntity entity) {
    if (!SentinelPlugin.instance.ignoreInvisible
            || !entity.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
        return false;
    }
    EntityEquipment eq = entity.getEquipment();
    if (eq == null) {
        return true;
    }
    if (SentinelVersionCompat.v1_9) {
        if (!isAir(eq.getItemInMainHand()) || !isAir(eq.getItemInOffHand())) {
            return false;
        }
    }
    else {
        if (!isAir(eq.getItemInHand())) {
            return false;
        }
    }
    return isAir(eq.getBoots()) && isAir(eq.getLeggings()) && isAir(eq.getChestplate()) && isAir(eq.getHelmet());
}
 
源代码3 项目: HeavySpleef   文件: FlagInvisibleSpectate.java
@SuppressWarnings("deprecation")
@Subscribe
public void onSpectateGame(FlagSpectate.SpectateEnteredEvent event) {
	SpleefPlayer player = event.getPlayer();
	Player bukkitPlayer = player.getBukkitPlayer();
	
	team.addPlayer(bukkitPlayer);
	
	PotionEffect effect = new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, true);
	bukkitPlayer.addPotionEffect(effect, true);
	
	for (SpleefPlayer ingamePlayer : game.getPlayers()) {
		if (!ingamePlayer.getBukkitPlayer().canSee(bukkitPlayer)) {
			continue;
		}
		
		ingamePlayer.getBukkitPlayer().hidePlayer(bukkitPlayer);
	}
	
	bukkitPlayer.setScoreboard(scoreboard);
}
 
源代码4 项目: MineTinker   文件: Scotopic.java
@EventHandler(ignoreCancelled = true)
public void onMoveImmune(PlayerMoveEvent event) {
	if (!this.givesImmunity) return;

	Player player = event.getPlayer();
	if (!player.hasPermission("minetinker.modifiers.scotopic.use")) {
		return;
	}

	ItemStack armor = player.getInventory().getHelmet();
	if (armor == null) return;

	if (!modManager.hasMod(armor, this)) return;
	if (player.hasPotionEffect(PotionEffectType.BLINDNESS)) {
		player.removePotionEffect(PotionEffectType.BLINDNESS);
		ChatWriter.logModifier(player, event, this, armor, "RemoveBlindness");
	}
}
 
源代码5 项目: ProjectAres   文件: GhostSquadronMatchModule.java
private void reveal(Player player, int ticks) {
    RevealEntry entry = this.revealMap.get(player);
    if(entry == null) entry = new RevealEntry();

    entry.revealTicks = ticks;

    for(PotionEffect e : player.getActivePotionEffects()) {
        if(e.getType().equals(PotionEffectType.INVISIBILITY)) {
            entry.potionTicks = e.getDuration();
        }
    }

    player.removePotionEffect(PotionEffectType.INVISIBILITY);

    this.revealMap.put(player, entry);
}
 
源代码6 项目: ZombieEscape   文件: ServerListener.java
@EventHandler
public void onHit(ProjectileHitEvent event) {
    Projectile projectile = event.getEntity();

    if (projectile instanceof Arrow) {
        projectile.remove();
    } else if (projectile instanceof Snowball && event.getEntity() instanceof Player) {
        ((Player) event.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 2, 1));
    } else if (projectile instanceof Egg && projectile.getShooter() instanceof Player) {
        projectile.getWorld().createExplosion(projectile.getLocation(), 0.0F);

        for (Entity entity : projectile.getNearbyEntities(5, 5, 5)) {
            if (entity instanceof Player) {
                Player player = (Player) entity;
                if (plugin.getGameArena().isZombie(player)) {
                    player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20 * 5, 1));
                    player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 5, 1));
                }
            }
        }
    }
}
 
源代码7 项目: CloudNet   文件: MobSelector.java
@Deprecated
public void unstableEntity(Entity entity) {
    try {
        Class<?> nbt = ReflectionUtil.reflectNMSClazz(".NBTTagCompound");
        Class<?> entityClazz = ReflectionUtil.reflectNMSClazz(".Entity");
        Object object = nbt.newInstance();

        Object nmsEntity = entity.getClass().getMethod("getHandle", new Class[] {}).invoke(entity);
        try {
            entityClazz.getMethod("e", nbt).invoke(nmsEntity, object);
        } catch (Exception ex) {
            entityClazz.getMethod("save", nbt).invoke(nmsEntity, object);
        }

        object.getClass().getMethod("setInt", String.class, int.class).invoke(object, "NoAI", 1);
        object.getClass().getMethod("setInt", String.class, int.class).invoke(object, "Silent", 1);
        entityClazz.getMethod("f", nbt).invoke(nmsEntity, object);
    } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        e.printStackTrace();
        System.out.println("[CLOUD] Disabling NoAI and Silent support for " + entity.getEntityId());
        ((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 100));
    }
}
 
源代码8 项目: BetonQuest   文件: DelEffectEvent.java
public DelEffectEvent(Instruction instruction) throws InstructionParseException {
    super(instruction, true);
    String next = instruction.next();

    if (next.equalsIgnoreCase("any")) {
        any = true;
        effects = Collections.emptyList();
    } else {
        any = false;
        effects = instruction.getList(next, (type -> {
            PotionEffectType effect = PotionEffectType.getByName(type.toUpperCase());
            if (effect == null) throw new InstructionParseException("Effect type '" + type + "' does not exist");
            else return effect;
        }));
    }
}
 
源代码9 项目: Kettle   文件: CraftMetaPotion.java
public boolean removeCustomEffect(PotionEffectType type) {
    Validate.notNull(type, "Potion effect type must not be null");

    if (!hasCustomEffects()) {
        return false;
    }

    boolean changed = false;
    Iterator<PotionEffect> iterator = customEffects.iterator();
    while (iterator.hasNext()) {
        PotionEffect effect = iterator.next();
        if (type.equals(effect.getType())) {
            iterator.remove();
            changed = true;
        }
    }
    if (customEffects.isEmpty()) {
        customEffects = null;
    }
    return changed;
}
 
源代码10 项目: Slimefun4   文件: MagicSugar.java
@Override
public ItemUseHandler getItemHandler() {
    return e -> {
        // Check if it is being placed into an ancient altar.
        if (e.getClickedBlock().isPresent()) {
            Material block = e.getClickedBlock().get().getType();

            if (block == Material.DISPENSER || block == Material.ENCHANTING_TABLE) {
                return;
            }
        }

        Player p = e.getPlayer();
        if (p.getGameMode() != GameMode.CREATIVE) {
            ItemUtils.consumeItem(e.getItem(), false);
        }

        p.playSound(p.getLocation(), Sound.ENTITY_GENERIC_EAT, 1, 1);
        p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 600, 3));
    };
}
 
源代码11 项目: ce   文件: Paralyze.java
@Override
public void effect(Event e, ItemStack item, int level) {
	if(e instanceof EntityDamageByEntityEvent) {
	EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;
	LivingEntity target = (LivingEntity) event.getEntity();
	target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, duration + (level-1)*20, strength + level-1), true);
	target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, duration + (level-1)*20, 1), true);
	target.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, duration + (level-1)*20, strength + level-1), true);
	}
}
 
源代码12 项目: AACAdditionPro   文件: AveragePattern.java
@Override
public int process(User user, BlockPlaceEvent event)
{
    // Ladders are prone to false positives as they can be used to place blocks immediately after placing them,
    // therefore almost doubling the placement speed. However they can only be placed one at a time, which allows
    // simply ignoring them.
    if (event.getBlockPlaced().getType() != Material.LADDER
        // Should check average?
        // Buffer the ScaffoldBlockPlace
        && user.getScaffoldData().getScaffoldBlockPlaces().bufferObject(new ScaffoldBlockPlace(
            event.getBlockPlaced(),
            event.getBlockPlaced().getFace(event.getBlockAgainst()),
            // Speed-Effect
            PotionUtil.getAmplifier(PotionUtil.getPotionEffect(user.getPlayer(), PotionEffectType.SPEED)),
            user.getPlayer().getLocation().getYaw(),
            user.hasSneakedRecently(175))))
    {
        /*
        Indices:
        [0] -> Expected time
        [1] -> Real time
         */
        final double[] results = user.getScaffoldData().calculateTimes();

        // delta-times are too low -> flag
        if (results[1] < results[0]) {
            // Calculate the vl
            final int vlIncrease = (int) (4 * Math.min(Math.ceil((results[0] - results[1]) / 15D), 6));

            message = "Scaffold-Verbose | Player: " + user.getPlayer().getName() + " enforced delay: " + results[0] + " | real: " + results[1] + " | vl increase: " + vlIncrease;
            return vlIncrease;
        }
    }

    return 0;
}
 
源代码13 项目: BetonQuest   文件: EffectCondition.java
public EffectCondition(Instruction instruction) throws InstructionParseException {
    super(instruction, true);
    String string = instruction.next();
    type = PotionEffectType.getByName(string);
    if (type == null) {
        throw new InstructionParseException("Effect " + string + " does not exist");
    }
}
 
源代码14 项目: AuthMeReloaded   文件: ProcessSyncPlayerLogout.java
private void applyLogoutEffect(Player player) {
    // dismount player
    player.leaveVehicle();
    teleportationService.teleportOnJoin(player);

    // Apply Blindness effect
    if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
        int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
        player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2));
    }

    // Set player's data to unauthenticated
    limboService.createLimboPlayer(player, true);
}
 
源代码15 项目: PGM   文件: XMLUtils.java
public static PotionEffectType parsePotionEffectType(Node node, String text)
    throws InvalidXMLException {
  PotionEffectType type = PotionEffectType.getByName(text.toUpperCase().replace(" ", "_"));
  if (type == null) type = NMSHacks.getPotionEffectType(text);
  if (type == null) {
    throw new InvalidXMLException("Unknown potion type '" + node.getValue() + "'", node);
  }
  return type;
}
 
源代码16 项目: Slimefun4   文件: ArmorTask.java
public ArmorTask() {
    Set<PotionEffect> effects = new HashSet<>();
    effects.add(new PotionEffect(PotionEffectType.WITHER, 400, 2));
    effects.add(new PotionEffect(PotionEffectType.BLINDNESS, 400, 3));
    effects.add(new PotionEffect(PotionEffectType.CONFUSION, 400, 3));
    effects.add(new PotionEffect(PotionEffectType.WEAKNESS, 400, 2));
    effects.add(new PotionEffect(PotionEffectType.SLOW, 400, 1));
    effects.add(new PotionEffect(PotionEffectType.SLOW_DIGGING, 400, 1));
    radiationEffects = Collections.unmodifiableSet(effects);
}
 
源代码17 项目: StaffPlus   文件: VanishHandler.java
private void applyVanish(Player player, VanishType vanishType, boolean shouldMessage)
{
	String message = "";
	
	switch(vanishType)
	{
		case TOTAL:
			for(Player p : Bukkit.getOnlinePlayers())
			{
				if(permission.has(p, options.permissionVanishTotal))
				{
					continue;
				}
				
				p.hidePlayer(player);
			}
			
			player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0));
			message = messages.totalVanish.replace("%status%", "enabled");
			break;
		case LIST:
			if(options.vanishTabList)
			{
				versionProtocol.listVanish(player, true);
			}
			
			message = messages.listVanish.replace("%status%", "enabled");
			break;
		default:
			break;
	}
	
	if(shouldMessage && !message.isEmpty())
	{
		this.message.send(player, message, messages.prefixGeneral);
	}
}
 
源代码18 项目: Slimefun4   文件: IcyBow.java
@Override
public BowShootHandler onShoot() {
    return (e, n) -> {
        n.getWorld().playEffect(n.getLocation(), Effect.STEP_SOUND, Material.ICE);
        n.getWorld().playEffect(n.getEyeLocation(), Effect.STEP_SOUND, Material.ICE);
        n.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 2, 10));
        n.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 20 * 2, -10));
    };
}
 
源代码19 项目: Crazy-Crates   文件: ItemBuilder.java
private PotionType getPotionType(PotionEffectType type) {
    if (type != null) {
        if (type.equals(PotionEffectType.FIRE_RESISTANCE)) {
            return PotionType.FIRE_RESISTANCE;
        } else if (type.equals(PotionEffectType.HARM)) {
            return PotionType.INSTANT_DAMAGE;
        } else if (type.equals(PotionEffectType.HEAL)) {
            return PotionType.INSTANT_HEAL;
        } else if (type.equals(PotionEffectType.INVISIBILITY)) {
            return PotionType.INVISIBILITY;
        } else if (type.equals(PotionEffectType.JUMP)) {
            return PotionType.JUMP;
        } else if (type.equals(PotionEffectType.getByName("LUCK"))) {
            return PotionType.valueOf("LUCK");
        } else if (type.equals(PotionEffectType.NIGHT_VISION)) {
            return PotionType.NIGHT_VISION;
        } else if (type.equals(PotionEffectType.POISON)) {
            return PotionType.POISON;
        } else if (type.equals(PotionEffectType.REGENERATION)) {
            return PotionType.REGEN;
        } else if (type.equals(PotionEffectType.SLOW)) {
            return PotionType.SLOWNESS;
        } else if (type.equals(PotionEffectType.SPEED)) {
            return PotionType.SPEED;
        } else if (type.equals(PotionEffectType.INCREASE_DAMAGE)) {
            return PotionType.STRENGTH;
        } else if (type.equals(PotionEffectType.WATER_BREATHING)) {
            return PotionType.WATER_BREATHING;
        } else if (type.equals(PotionEffectType.WEAKNESS)) {
            return PotionType.WEAKNESS;
        }
    }
    return null;
}
 
源代码20 项目: Slimefun4   文件: SlimefunItemStack.java
public SlimefunItemStack(String id, Color color, PotionEffect effect, String name, String... lore) {
    super(Material.POTION, im -> {
        if (name != null) {
            im.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
        }

        if (lore.length > 0) {
            List<String> lines = new ArrayList<>();

            for (String line : lore) {
                lines.add(ChatColor.translateAlternateColorCodes('&', line));
            }

            im.setLore(lines);
        }

        if (im instanceof PotionMeta) {
            ((PotionMeta) im).setColor(color);
            ((PotionMeta) im).addCustomEffect(effect, true);

            if (effect.getType().equals(PotionEffectType.SATURATION)) {
                im.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
            }
        }
    });

    setItemId(id);
}
 
@Test
public void shouldPerformUnregister() {
    // given
    Player player = mock(Player.class);
    String name = "Frank21";
    given(player.getName()).willReturn(name);
    given(player.isOnline()).willReturn(true);
    PlayerAuth auth = mock(PlayerAuth.class);
    given(playerCache.getAuth(name)).willReturn(auth);
    HashedPassword password = new HashedPassword("password", "in_auth_obj");
    given(auth.getPassword()).willReturn(password);
    String userPassword = "pass";
    given(passwordSecurity.comparePassword(userPassword, password, name)).willReturn(true);
    given(dataSource.removeAuth(name)).willReturn(true);
    given(service.getProperty(RegistrationSettings.FORCE)).willReturn(true);
    given(service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)).willReturn(true);
    given(service.getProperty(RestrictionSettings.TIMEOUT)).willReturn(21);
    setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask(bukkitService);

    // when
    asynchronousUnregister.unregister(player, userPassword);

    // then
    verify(service).send(player, MessageKey.UNREGISTERED_SUCCESS);
    verify(passwordSecurity).comparePassword(userPassword, password, name);
    verify(dataSource).removeAuth(name);
    verify(playerCache).removePlayer(name);
    verify(teleportationService).teleportOnJoin(player);
    verifyCalledUnregisterEventFor(player);
    verify(commandManager).runCommandsOnUnregister(player);
    verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name);
    verify(player).addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 21 * 20, 2));
}
 
源代码22 项目: PGM   文件: NightVisionTool.java
public void toggleNightVision(MatchPlayer player) {
  if (hasNightVision(player)) {
    player.getBukkit().removePotionEffect(PotionEffectType.NIGHT_VISION);
  } else {
    player
        .getBukkit()
        .addPotionEffect(
            new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, true, false));
  }
}
 
源代码23 项目: SuperVanish   文件: NightVision.java
@EventHandler
public void onWorldChange(PlayerChangedWorldEvent e) {
    Player p = e.getPlayer();
    if (!plugin.getVanishStateMgr().isVanished(p.getUniqueId()))
        return;
    sendAddPotionEffect(p, new PotionEffect(PotionEffectType.NIGHT_VISION,
            INFINITE_POTION_EFFECT_LENGTH, 0));
}
 
源代码24 项目: QualityArmory   文件: QAMain.java
public static void toggleNightvision(Player player, Gun g, boolean add) {
	if (add) {
		if (g.getZoomWhenIronSights() > 0) {
			currentlyScoping.add(player.getUniqueId());
			player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1200, g.getZoomWhenIronSights()));
		}
		if (g.hasnightVision()) {
			currentlyScoping.add(player.getUniqueId());
			player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1200, 3));
		}
	} else {
		if (currentlyScoping.contains(player.getUniqueId())) {
			if (player.hasPotionEffect(PotionEffectType.SLOW) && (g == null || g.getZoomWhenIronSights() > 0))
				player.removePotionEffect(PotionEffectType.SLOW);
			boolean potionEff = false;
			try {
				potionEff = player.hasPotionEffect(PotionEffectType.NIGHT_VISION)
						&& (g == null || g.hasnightVision())
						&& player.getPotionEffect(PotionEffectType.NIGHT_VISION).getAmplifier() == 3;
			} catch (Error | Exception e3452) {
				for (PotionEffect pe : player.getActivePotionEffects())
					if (pe.getType() == PotionEffectType.NIGHT_VISION)
						potionEff = (g == null || g.hasnightVision()) && pe.getAmplifier() == 3;
			}
			if (potionEff)
				player.removePotionEffect(PotionEffectType.NIGHT_VISION);
			currentlyScoping.remove(player.getUniqueId());
		}
	}

}
 
源代码25 项目: EliteMobs   文件: NPCEntity.java
/**
 * Sets the NPCEntity's ability to move
 *
 * @param canMove Sets if the NPCEntity can move
 */
public void setCanMove(boolean canMove) {
    this.canMove = canMove;
    this.villager.setAI(canMove);
    if (!canMove)
        villager.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 3));
}
 
源代码26 项目: MineTinker   文件: ShadowDive.java
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onSneak(PlayerToggleSneakEvent event) {
	Player player = event.getPlayer();
	if (!player.hasPermission("minetinker.modifiers.shadowdive.use")) return;

	ItemStack boots = player.getInventory().getBoots();
	if (!modManager.isArmorViable(boots)) return;
	if (!modManager.hasMod(boots, this)) return;

	if (event.isSneaking() && !player.isGliding()) { //enable
		Location loc = player.getLocation();
		byte lightlevel = player.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()).getLightLevel();
		boolean combatTagged = PlayerInfo.isCombatTagged(player);
		ChatWriter.logModifier(player, event, this, boots,
				String.format("LightLevel(%d/%d)", lightlevel, this.requiredLightLevel),
				String.format("InCombat(%b)", combatTagged));
		if (lightlevel > this.requiredLightLevel || player.hasPotionEffect(PotionEffectType.GLOWING)) {
			ChatWriter.sendActionBar(player, ChatColor.RED + this.getName() + ": "
					+ LanguageManager.getString("Modifier.Shadow-Dive.LightToHigh", player));
			return;
		}

		if (combatTagged) {
			ChatWriter.sendActionBar(player, ChatColor.RED + this.getName() + ": "
					+ LanguageManager.getString("Modifier.Shadow-Dive.InCombat", player));
			return;
		}

		hidePlayer(player);

	} else { //disable
		if (!activePlayers.contains(player)) return;
		showPlayer(player);
	}
}
 
源代码27 项目: askyblock   文件: AcidEffect.java
/**
 * Check if player is safe from rain
 * @param player
 * @return true if they are safe
 */
private boolean isSafeFromRain(Player player) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: safe from acid rain");
    if (!player.getWorld().equals(ASkyBlock.getIslandWorld())) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: wrong world");
        return true;
    }
    // Check if player has a helmet on and helmet protection is true
    if (Settings.helmetProtection && (player.getInventory().getHelmet() != null
            && player.getInventory().getHelmet().getType().name().contains("HELMET"))) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: wearing helmet.");
        return true;
    }
    // Check potions
    Collection<PotionEffect> activePotions = player.getActivePotionEffects();
    for (PotionEffect s : activePotions) {
        if (s.getType().equals(PotionEffectType.WATER_BREATHING)) {
            // Safe!
            if (DEBUG)
                plugin.getLogger().info("DEBUG: potion");
            return true;
        }
    }
    // Check if all air above player
    for (int y = player.getLocation().getBlockY() + 2; y < player.getLocation().getWorld().getMaxHeight(); y++) {
        if (!player.getLocation().getWorld().getBlockAt(player.getLocation().getBlockX(), y, player.getLocation().getBlockZ()).getType().equals(Material.AIR)) {
            if (DEBUG)
                plugin.getLogger().info("DEBUG: something other than air above player");
            return true;
        }
    }
    if (DEBUG)
        plugin.getLogger().info("DEBUG: acid rain damage");
    return false;
}
 
源代码28 项目: TabooLib   文件: Items.java
public static PotionEffectType asPotionEffectType(String potion) {
    try {
        PotionEffectType type = PotionEffectType.getByName(potion);
        return type != null ? type : PotionEffectType.getById(NumberConversions.toInt(potion));
    } catch (Throwable e) {
        return null;
    }
}
 
源代码29 项目: QuickShop-Reremake   文件: MsgUtil.java
public static void loadPotioni18n() {
    plugin.getLogger().info("Starting loading potions translation...");
    File potioni18nFile = new File(plugin.getDataFolder(), "potioni18n.yml");
    if (!potioni18nFile.exists()) {
        plugin.getLogger().info("Creating potioni18n.yml");
        plugin.saveResource("potioni18n.yml", false);
    }
    // Store it
    potioni18n = YamlConfiguration.loadConfiguration(potioni18nFile);
    potioni18n.options().copyDefaults(false);
    YamlConfiguration potioni18nYAML =
            YamlConfiguration.loadConfiguration(
                    new InputStreamReader(Objects.requireNonNull(plugin.getResource("potioni18n.yml"))));
    potioni18n.setDefaults(potioni18nYAML);
    Util.parseColours(potioni18n);
    for (PotionEffectType potion : PotionEffectType.values()) {
        String potionI18n = potioni18n.getString("potioni18n." + potion.getName().trim());
        if (potionI18n != null && !potionI18n.isEmpty()) {
            continue;
        }
        String potionName = gameLanguage.getPotion(potion);
        plugin.getLogger().info("Found new potion [" + potionName + "] , adding it to the config...");
        potioni18n.set("potioni18n." + potion.getName(), potionName);
    }
    try {
        potioni18n.save(potioni18nFile);
    } catch (IOException e) {
        e.printStackTrace();
        plugin
                .getLogger()
                .log(
                        Level.WARNING,
                        "Could not load/save transaction potionname from potioni18n.yml. Skipping.");
    }
    plugin.getLogger().info("Complete to load potions effect translation.");
}
 
源代码30 项目: Slimefun4   文件: Rag.java
@Override
public ItemUseHandler getItemHandler() {
    return e -> {
        Player p = e.getPlayer();

        // Player is neither burning nor injured
        if (p.getFireTicks() <= 0 && p.getHealth() >= p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) {
            return;
        }

        if (p.getGameMode() != GameMode.CREATIVE) {
            ItemUtils.consumeItem(e.getItem(), false);
        }

        p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, Material.WHITE_WOOL);
        p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0));
        p.setFireTicks(0);

        e.cancel();
    };
}
 
 类所在包
 同包方法