Java 类org.bukkit.entity.TippedArrow 实例源码

项目:RedProtect    文件:RPMine19.java   
@EventHandler
public void onShootBow(EntityShootBowEvent e){
    if (e.isCancelled() || !(e.getEntity() instanceof Player)){
        return;
    }

    Player p = (Player) e.getEntity();      
    Entity proj = e.getProjectile();
    List<String> Pots = RPConfig.getStringList("server-protection.deny-potions");

    if (proj != null && (proj instanceof TippedArrow)){
        TippedArrow arr = (TippedArrow) proj;
        if (Pots.contains(arr.getBasePotionData().getType().name())){
            RPLang.sendMessage(p, "playerlistener.denypotion");
            e.setCancelled(true);
        }
    }
}
项目:QuarSK    文件:SExprThrownPotionEffects.java   
@Nullable
@Override
protected PotionEffect[] get(Event e) {
    Entity ent = entity.getSingle(e);
    if (ent == null) {
        return null;
    }
    if (ent instanceof ThrownPotion) {
        return ((ThrownPotion) ent).getEffects().stream().toArray(PotionEffect[]::new);
    } else if (ent instanceof TippedArrow) {
        return ((TippedArrow) ent).getCustomEffects().stream().toArray(PotionEffect[]::new);
    }
    return null;
}
项目:ProjectAres    文件:PotionUtils.java   
public static Collection<PotionEffect> effects(TippedArrow arrow) {
    return effects(arrow.getBasePotionData(), arrow.getCustomEffects());
}
项目:QuarSK    文件:SExprThrownPotionEffects.java   
@Override
public void change(Event e, Object[] delta, @NotNull Changer.ChangeMode mode) {
    Entity ent = entity.getSingle(e);
    if (ent == null) {
        return;
    }
    if (PotionUtils.isEntityThrownPotion(ent)) {
        ItemStack item = ((ThrownPotion) ent).getItem();
        PotionMeta potionMeta = ((PotionMeta) ((ThrownPotion) ent).getItem().getItemMeta());
        switch (mode) {
            case ADD:
                Arrays.asList((PotionEffect[]) delta).forEach(eff -> potionMeta.addCustomEffect(eff, true));
                break;
            case SET:
                potionMeta.clearCustomEffects();
                Arrays.asList((PotionEffect[]) delta).forEach(eff -> potionMeta.addCustomEffect(eff, true));
                break;
            case REMOVE:
                potionMeta.removeCustomEffect((PotionEffectType) delta[0]);
                break;
            case DELETE:
                potionMeta.clearCustomEffects();
                break;
        }
        item.setItemMeta(potionMeta);
        ((ThrownPotion) ent).setItem(item);
    } else if (ent.getType() == EntityType.TIPPED_ARROW) {
        TippedArrow tippedArrow = (TippedArrow) ent;
        switch (mode) {
            case ADD:
                Arrays.asList(((PotionEffect[]) delta)).forEach(eff -> tippedArrow.addCustomEffect(eff, true));
                break;
            case SET:
                tippedArrow.clearCustomEffects();
                Arrays.asList(((PotionEffect[]) delta)).forEach(eff -> tippedArrow.addCustomEffect(eff, true));
                break;
            case REMOVE:
                tippedArrow.removeCustomEffect((PotionEffectType) delta[0]);
                break;
            case DELETE:
                tippedArrow.clearCustomEffects();
                break;
        }
    }
}