From fc9378f422052651ce09aa800403a4c67c76fdaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Miklo=C5=A1?= Date: Sat, 27 Jul 2024 14:23:20 +0200 Subject: [PATCH] added a crossbow check --- .gitignore | 1 + .gradle/file-system.probe | Bin 8 -> 8 bytes build/libs/RocketJumping-1.2-1.21.jar | Bin 0 -> 3188 bytes .../rocketJumping/RocketJumping.java | 26 ++++++++++++++++++ src/main/resources/config.yml | 5 +++- 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 build/libs/RocketJumping-1.2-1.21.jar diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c795b05 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build \ No newline at end of file diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe index 4adc39734ff4f9402dfa01839fbcdb720a520d47..f6982e50361c1468ccb3b9a7884cf3619f0b30ab 100644 GIT binary patch literal 8 PcmZQzV4Uzp@wFiU2^a#y literal 8 PcmZQzV4U!BTN4`q39bUU diff --git a/build/libs/RocketJumping-1.2-1.21.jar b/build/libs/RocketJumping-1.2-1.21.jar new file mode 100644 index 0000000000000000000000000000000000000000..7aba3fbdd2e65d94c0250ebff77fe50268a5feed GIT binary patch literal 3188 zcmai1c{r5)8lHyH*fR8yQFh8Uq)8-884_b1`_e>{Va$wWj3OmdmI`AX6)D??Y*CUV zDpMnCmO^%uJzL5*R5~+P=agKXbDsD5Eq~ni{k+e6J@56qe>O-i?!N#4Fc@%}^u-y# z4j^Y@2QPbAn%EzKnOPmx-~!nE1akYXI^VkhoZra?K-q&${{^%>Vr6#J#Liyb^60W< zOS1(MrrsflgsHT(wBJYV?S_wxkBtL2hymGRZ2r%z-0ZzS$@{m2n=z1oW5{Q40e)WO zGyWv}Z}`oXNc{m%^2gx4$mYSs0G!|N**I+D<7ow{TLFN(LI8l~|7D{#YN=xgorn=w=`{;aOZQr5GWu-OdXf5@*b?t&;fPmP&Q`Iyh6hg#1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=q0Y9;Q6>YVZ|zy(Cm8tW2>EAAFN}m&(Ci3tNqq@N0wIW#+zn%Tm=tEU z5`0YLK=NcMOEkPSwWhjK_o@K;r6{(2@8knHCy8M32Gv?4*%{lX#pJV+Uc2acmY}D< zr~R}2O+LyELv%O`7H+D3h^}1Q<`6L)H@O(blkbRiJGgy(Mq*t?Bfosn^y?LuRqu<| zvgFMCk6*O&M$4n?eWu>N&Xv70DsZ7?;_YmA&O8tIh@sEhz02G5q`winYvaS#Evqi5 zp14w9%)c02v->+s`j>;@9PzdZ8Tt(N(H^t~0N`V<7=J%3&Rac{NFXLu_%-YmFh0Yz z9>aC768SpYu4nx)C7eRAOM|$m9h12D-2in{Mm;f!!F`)-1<$nToaIv;%gokpFWN%%Kpwe6KXwiv&!G|O}4>Dm1^j=5APaA zqIT%SB|KIs!x@qAQd~-ImCl-Km!;JIzBXv_)^X0+W5?a!%cVKE%vi9?^kWZ>e+uvn z@FKwi2*KVsKTgrj$QH{7C~%W?n-y$Hr4`oLf}B+Ok8iWl?uK`QP9lQK2Iv-9hr?}a z&}O07BWPc<&~V!-wD3IxeS13*{(Zr=7Ql3lyW0Z%i|fC;N_Kj7Kmc<`IO|W3xsmoK zkI4aZB9EfXo`2FdIL?g|i}#LwVc6VN VHb@W;2LWb3eC&&bJ?BpY{0k(E9%cXl literal 0 HcmV?d00001 diff --git a/src/main/java/org/twipnetwork/rocketJumping/RocketJumping.java b/src/main/java/org/twipnetwork/rocketJumping/RocketJumping.java index 071beb3..b17aafb 100644 --- a/src/main/java/org/twipnetwork/rocketJumping/RocketJumping.java +++ b/src/main/java/org/twipnetwork/rocketJumping/RocketJumping.java @@ -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(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 47b5238..e1e7ceb 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -3,4 +3,7 @@ boostPower: 4.0 # damageShooter defines whether the shooter gets damages by their own fireworks (default: false) -damageShooter: false \ No newline at end of file +damageShooter: false + +# onlyCrossbow defines whether the only fireworks shot from a crossbow should launch entities or if all fireworks (default: true) +onlyCrossbow: true \ No newline at end of file