Skip to content

Instantly share code, notes, and snippets.

@aikar
Created September 14, 2018 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aikar/9b78bdf96085c53027a78ea1f77fcb92 to your computer and use it in GitHub Desktop.
Save aikar/9b78bdf96085c53027a78ea1f77fcb92 to your computer and use it in GitHub Desktop.
/*
* Copyright (c) 2018. Starlis LLC / dba Empire Minecraft
*
* This source code is proprietary software and must not be redistributed without Starlis LLC's approval
*
*/
package com.empireminecraft.items.boss;
import com.empireminecraft.features.items.CustomLingeringSplashPotionItem;
import com.empireminecraft.features.items.Items;
import com.empireminecraft.util.BukkitUtil;
import com.empireminecraft.util.Util;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.AreaEffectCloud;
import org.bukkit.entity.LingeringPotion;
import org.bukkit.event.entity.LingeringPotionSplashEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class PotionOfDragonsBreath extends CustomLingeringSplashPotionItem {
public PotionOfDragonsBreath() {
super("potionOfDragonsBreath");
Items.buildLore(this)
.setName("&cPotion of Dragon's Breath")
.add("Breath of a dragon trapped within.")
.makeShiny()
.save();
setPotionColor(Color.PURPLE);
}
public void onLingeringSplashEvent(LingeringPotionSplashEvent event, LingeringPotion potion, ItemStack item) {
AreaEffectCloud cloud = event.getAreaEffectCloud();
cloud.setParticle(Particle.DRAGON_BREATH);
//2 separate duration times, one is for effect, one is for cloud
cloud.addCustomEffect(new PotionEffect(PotionEffectType.HARM, 300, 1), false);
cloud.setDuration(300);
cloud.setRadius(5);
BukkitUtil.runTaskNextTick(() -> {
if (!event.getEntity().isValid()) {
return;
}
Location loc = event.getEntity().getLocation();
Util.findSafeGround(loc, true);
cloud.teleport(loc);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment