Hey,
I want to present you my
throw axe plugin.
This is just a fun plugin, where you can throw an axe at mobs or players to kill them. You might know this from
shooter games like
cod .
Apparently, this plugin contains a little config, where you can manage some settings for the axe.
Feel free to download
Features:
- plug and play
- instant kill with axe
- few configurations
Spoiler: Config
Code (Text):
axeMaterial: IRON_AXE
axeVector: 1.5
killRadius: 0.6
Spoiler: Code
Code (Text):
@EventHandler
public void onInteract(PlayerInteractEvent e) {
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Player p = e.getPlayer();
try {
if(p.getInventory().getItemInHand().getType() == Material.valueOf(getConfig().getString("axeMaterial"))) {
Item axe = p.getWorld().dropItem(p.getEyeLocation(), p.getItemInHand());
axe.setVelocity(p.getEyeLocation().getDirection().multiply(getConfig().getDouble("axeVector")));
p.getItemInHand().setAmount(0);
new BukkitRunnable() {
@Override
public void run() {
for(Entity ent : axe.getNearbyEntities(getConfig().getDouble("killRadius"), getConfig().getDouble("killRadius"), getConfig().getDouble("killRadius"))) {
if(ent instanceof LivingEntity) {
LivingEntity target = (LivingEntity) ent;
if(ent == p) continue;
target.setHealth(0);
axe.setVelocity(new Vector(0, 0, 0));
cancel();
}
}
if(axe.isOnGround()) {
axe.setVelocity(new Vector(0, 0, 0));
cancel();
}
}
}.runTaskTimer(this, 0, 1);
}
}catch(Exception ex) {
}catch(AssertionError ex) {}
}
}