added a crossbow check
This commit is contained in:
parent
745c7df193
commit
fc9378f422
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
build
|
Binary file not shown.
BIN
build/libs/RocketJumping-1.2-1.21.jar
Normal file
BIN
build/libs/RocketJumping-1.2-1.21.jar
Normal file
Binary file not shown.
@ -9,6 +9,8 @@ import org.bukkit.entity.Firework;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.CrossbowMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -16,6 +18,7 @@ public final class RocketJumping extends JavaPlugin implements Listener {
|
||||
|
||||
private double boostPower;
|
||||
private boolean damageShooter;
|
||||
private boolean onlyCrossbow;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@ -23,6 +26,7 @@ public final class RocketJumping extends JavaPlugin implements Listener {
|
||||
FileConfiguration config = getConfig();
|
||||
boostPower = config.getDouble("boostPower", 4.0);
|
||||
damageShooter = config.getBoolean("damageShooter", false);
|
||||
onlyCrossbow = config.getBoolean("onlyCrossbow", true);
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
}
|
||||
|
||||
@ -37,6 +41,28 @@ public final class RocketJumping extends JavaPlugin implements Listener {
|
||||
if (projectile instanceof Firework firework) {
|
||||
Entity shooter = (Entity) firework.getShooter();
|
||||
|
||||
if (onlyCrossbow && shooter instanceof Player player) {
|
||||
ItemStack itemInMainHand = player.getInventory().getItemInMainHand();
|
||||
ItemStack itemInOffHand = player.getInventory().getItemInOffHand();
|
||||
boolean shotFromCrossbow = false;
|
||||
|
||||
if (itemInMainHand.getItemMeta() instanceof CrossbowMeta meta) {
|
||||
if (meta.getChargedProjectiles().contains(firework)) {
|
||||
shotFromCrossbow = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemInOffHand.getItemMeta() instanceof CrossbowMeta meta) {
|
||||
if (meta.getChargedProjectiles().contains(firework)) {
|
||||
shotFromCrossbow = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!shotFromCrossbow) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (Entity entity : firework.getNearbyEntities(5, 5, 5)) {
|
||||
if (entity instanceof Player player) {
|
||||
Vector boostDirection = player.getLocation().toVector().subtract(firework.getLocation().toVector()).normalize();
|
||||
|
@ -3,4 +3,7 @@
|
||||
boostPower: 4.0
|
||||
|
||||
# damageShooter defines whether the shooter gets damages by their own fireworks (default: false)
|
||||
damageShooter: false
|
||||
damageShooter: false
|
||||
|
||||
# onlyCrossbow defines whether the only fireworks shot from a crossbow should launch entities or if all fireworks (default: true)
|
||||
onlyCrossbow: true
|
Loading…
Reference in New Issue
Block a user