Search in sources :

Example 1 with TippedArrow

use of org.bukkit.entity.TippedArrow in project RedProtect by FabioZumbi12.

the class RPMine19 method onShootBow.

@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);
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) TippedArrow(org.bukkit.entity.TippedArrow) EventHandler(org.bukkit.event.EventHandler)

Example 2 with TippedArrow

use of org.bukkit.entity.TippedArrow in project Glowstone by GlowstoneMC.

the class NormalTippedArrowStore method save.

@Override
public void save(GlowArrow entity, CompoundTag tag) {
    super.save(entity, tag);
    if (entity instanceof TippedArrow) {
        PotionData potion = ((TippedArrow) entity).getBasePotionData();
        if (potion != null) {
            tag.putString(POTION, GlowMetaPotion.dataToString(potion));
        }
        tag.putCompoundList(CUSTOM_POTION_EFFECTS, ((TippedArrow) entity).getCustomEffects().stream().map(GlowMetaPotion::toNbt).collect(Collectors.toList()));
    }
}
Also used : PotionData(org.bukkit.potion.PotionData) TippedArrow(org.bukkit.entity.TippedArrow) GlowTippedArrow(net.glowstone.entity.projectile.GlowTippedArrow) GlowMetaPotion(net.glowstone.inventory.GlowMetaPotion)

Example 3 with TippedArrow

use of org.bukkit.entity.TippedArrow in project Glowstone by GlowstoneMC.

the class NormalTippedArrowStore method load.

@Override
public void load(GlowArrow entity, CompoundTag tag) {
    super.load(entity, tag);
    if (entity instanceof TippedArrow) {
        TippedArrow tippedArrow = (TippedArrow) entity;
        tag.readInt(COLOR, rgb -> tippedArrow.setColor(Color.fromRGB(rgb)));
        // TODO: POTION
        tag.readCompoundList(CUSTOM_POTION_EFFECTS, list -> list.stream().map(GlowMetaPotion::fromNbt).forEach(effect -> tippedArrow.addCustomEffect(effect, false)));
    }
}
Also used : CompoundTag(net.glowstone.util.nbt.CompoundTag) Location(org.bukkit.Location) TippedArrow(org.bukkit.entity.TippedArrow) GlowTippedArrow(net.glowstone.entity.projectile.GlowTippedArrow) GlowMetaPotion(net.glowstone.inventory.GlowMetaPotion) Color(org.bukkit.Color) Collectors(java.util.stream.Collectors) PotionData(org.bukkit.potion.PotionData) GlowArrow(net.glowstone.entity.projectile.GlowArrow) TippedArrow(org.bukkit.entity.TippedArrow) GlowTippedArrow(net.glowstone.entity.projectile.GlowTippedArrow) GlowMetaPotion(net.glowstone.inventory.GlowMetaPotion)

Aggregations

TippedArrow (org.bukkit.entity.TippedArrow)3 GlowTippedArrow (net.glowstone.entity.projectile.GlowTippedArrow)2 GlowMetaPotion (net.glowstone.inventory.GlowMetaPotion)2 PotionData (org.bukkit.potion.PotionData)2 Collectors (java.util.stream.Collectors)1 GlowArrow (net.glowstone.entity.projectile.GlowArrow)1 CompoundTag (net.glowstone.util.nbt.CompoundTag)1 Color (org.bukkit.Color)1 Location (org.bukkit.Location)1 Entity (org.bukkit.entity.Entity)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1