-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7eefb89
Showing
6 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>net.awesomepowered</groupId> | ||
<artifactId>MobArrows</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>MobArrows</name> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<build> | ||
<defaultGoal>clean package</defaultGoal> | ||
<finalName>${project.name}</finalName> | ||
<plugins> | ||
<plugin> | ||
<version>3.6.1</version> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
|
||
<repositories> | ||
<repository> | ||
<id>spigotmc-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url> | ||
</repository> | ||
<repository> | ||
<id>sonatype</id> | ||
<url>https://oss.sonatype.org/content/groups/public/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.12.2-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
43 changes: 43 additions & 0 deletions
43
src/main/java/net/awesomepowered/mobarrows/EntityArrow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package net.awesomepowered.mobarrows; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.Sound; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.LivingEntity; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
|
||
public class EntityArrow extends BukkitRunnable { | ||
|
||
private Entity proj; | ||
private Player player; | ||
private float damage; | ||
private MobArrows plugin; | ||
|
||
public EntityArrow(Entity projectile, Player p, float damage, MobArrows plugin) { | ||
this.proj = projectile; | ||
this.player = p; | ||
this.damage = damage; | ||
this.plugin = plugin; | ||
} | ||
|
||
|
||
@Override | ||
public void run() { | ||
if ((proj.isOnGround()) || (proj.isDead()) || proj.getLocation().getBlockY() > 300) { | ||
cancel(); | ||
proj.remove(); | ||
return; | ||
} | ||
|
||
for (Entity e : proj.getLocation().getChunk().getEntities()) { | ||
if (e.getLocation().distance(proj.getLocation()) < plugin.getConfig().getDouble("hitbox", 2) && e instanceof LivingEntity && !(e == player) && !(e == proj)) { | ||
((LivingEntity)e).damage(plugin.getConfig().getDouble("baseDamage", 5)*damage, player); | ||
cancel(); | ||
proj.remove(); | ||
return; | ||
} | ||
} | ||
proj.getWorld().playSound(proj.getLocation(), Sound.valueOf(plugin.getConfig().getString("types."+proj.getType().toString()+".sound", "ENTITY_GHAST_HURT")), 1, 1); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/net/awesomepowered/mobarrows/EventShootBow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package net.awesomepowered.mobarrows; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.Material; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.entity.SpectralArrow; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.entity.EntityShootBowEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.SpawnEggMeta; | ||
|
||
public class EventShootBow implements Listener { | ||
|
||
@EventHandler | ||
public void onShot(EntityShootBowEvent ev) { | ||
if (ev.getEntity() instanceof Player && ev.getProjectile() instanceof SpectralArrow) { | ||
Player p = (Player) ev.getEntity(); | ||
for (int i = 0; i < 35; i++) { | ||
ItemStack item = p.getInventory().getItem(i); | ||
if (item != null && item.getType() == Material.MONSTER_EGG) { | ||
SpawnEggMeta meta = (SpawnEggMeta) item.getItemMeta(); | ||
Entity ent = ev.getProjectile().getWorld().spawnEntity(ev.getProjectile().getLocation(), meta.getSpawnedType()); | ||
ent.setVelocity(ev.getProjectile().getVelocity()); | ||
ev.getProjectile().remove(); | ||
startTask(ent, p, ev.getForce(), MobArrows.instance); | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
|
||
public void startTask(Entity projectile, Player p, float damage, MobArrows plugin) { | ||
EntityArrow ea = new EntityArrow(projectile, p, damage, MobArrows.instance); | ||
ea.runTaskTimer(plugin,1,1); | ||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, ea::cancel, plugin.getConfig().getLong("runTime", 5) * 20); //cancel the task if it's been running for 5 secs. | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package net.awesomepowered.mobarrows; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public final class MobArrows extends JavaPlugin { | ||
|
||
public static MobArrows instance; | ||
|
||
@Override | ||
public void onEnable() { | ||
instance = this; | ||
Bukkit.getPluginManager().registerEvents(new EventShootBow(), this); | ||
saveDefaultConfig(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
baseDamage: 5 #Gets multiplied by the bow force which is 0.1:1.0 | ||
hitBox: 2 #Hit box of the entity in blocks. | ||
runTime: 5 #This will stop the sound and cancel the task after x seconds | ||
types: | ||
PIG: | ||
sound: 'ENTITY_PIG_DEATH' #Default sound is always ENTITY_GHAST_HURT | ||
PIG_ZOMBIE: | ||
sound: 'ENTITY_PIG_DEATH' | ||
CREEPER: | ||
sound: 'ENTITY_CREEPER_PRIMED' | ||
SHEEP: | ||
sound: 'ENTITY_SHEEP_AMBIENT' | ||
GHAST: | ||
sound: 'ENTITY_GHAST_HURT' | ||
COW: | ||
sound: 'ENTITY_COW_DEATH' | ||
HORSE: | ||
sound: 'ENTITY_HORSE_ANGRY' | ||
LLAMA: | ||
sound: 'ENTITY_LLAMA_SWAG' #No idea what it is but why the hell not | ||
ENDERMAN: | ||
sound: 'ENTITY_PARROT_IMITATE_ENDERMAN' | ||
TURTLE: | ||
sound: 'ENTITY_COW_DEATH' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name: MobArrows | ||
version: ${project.version} | ||
main: net.awesomepowered.mobarrows.MobArrows | ||
authors: [LaxWasHere] |