diff --git a/plugin.yml b/plugin.yml
index 3e396be..32b153e 100644
--- a/plugin.yml
+++ b/plugin.yml
@@ -5,16 +5,12 @@ version: 2.0.2
commands:
alilink:
description: creates wireless redstone
- cashmob:
- description: creates mobs
cb:
description: creates creative boundaries
debug:
description: debug commands
flaircolour:
description: flaaairs
- fruit:
- description: fruits
gpower:
description: powerssss
insurance:
diff --git a/pom.xml b/pom.xml
index fe6a070..ab68ed4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -92,7 +92,7 @@
org.apache.commons
commons-lang3
- 3.4
+ 3.5
com.github.TBMCPlugins.ButtonCore
diff --git a/src/buttondevteam/alipresents/components/magic/MagicComponent.java b/src/buttondevteam/alipresents/components/magic/MagicComponent.java
index 4dd2389..228d82b 100644
--- a/src/buttondevteam/alipresents/components/magic/MagicComponent.java
+++ b/src/buttondevteam/alipresents/components/magic/MagicComponent.java
@@ -7,11 +7,14 @@ import buttondevteam.alipresents.components.magic.tricks.AliArrowListener;
import buttondevteam.alipresents.components.magic.tricks.BoomBowDeathListener;
import buttondevteam.alipresents.components.magic.tricks.BoomBowListener;
import buttondevteam.alipresents.components.magic.tricks.CannonBowListener;
+import buttondevteam.alipresents.components.magic.tricks.CannonBowSettings;
public class MagicComponent extends Component{
@Override
public void register(JavaPlugin plugin) {
+ registerCommand(plugin, new CannonBowSettings());
+
registerListener(plugin, new AliArrowListener(plugin));
registerListener(plugin, new BoomBowDeathListener());
registerListener(plugin, new BoomBowListener(plugin));
diff --git a/src/buttondevteam/alipresents/components/magic/tricks/AliArrowTask.java b/src/buttondevteam/alipresents/components/magic/tricks/AliArrowTask.java
index cd4dd0b..f607210 100644
--- a/src/buttondevteam/alipresents/components/magic/tricks/AliArrowTask.java
+++ b/src/buttondevteam/alipresents/components/magic/tricks/AliArrowTask.java
@@ -8,6 +8,7 @@ public class AliArrowTask extends BukkitRunnable {
static String[] permittedUsers = {"alisolarflare", "Zanthr", "NorbiPeti"};
String name;
Arrow arrow;
+ int count = 0;
public AliArrowTask(Arrow arrow, String name) {
this.name = name;
@@ -16,7 +17,8 @@ public class AliArrowTask extends BukkitRunnable {
@Override
public void run() {
- if (arrow.isOnGround() || arrow.isDead()) {
+ count++;
+ if (count > 400 ||arrow.isOnGround() || arrow.isDead()) {
this.cancel();
}
diff --git a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java
index 83eebb2..719f3fd 100644
--- a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java
+++ b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java
@@ -12,11 +12,14 @@ import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
-import org.bukkit.event.entity.ProjectileLaunchEvent;
+import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
+import org.bukkit.util.Vector;
public class CannonBowListener implements Listener {
+ public static double SpeedMultiplier = 1.5;
+ public static double minforce = 0.2;
public final static String launchedTNTName = "CANNON BOW TNT:42170";
JavaPlugin plugin;
public CannonBowListener(JavaPlugin plugin){
@@ -24,35 +27,48 @@ public class CannonBowListener implements Listener {
}
@EventHandler
- public void onProjectileLaunch(ProjectileLaunchEvent event){
- //ENTITY SANITATION
- if(event.getEntity().getType() != EntityType.ARROW)return;
+ public void onProjectileLaunch(EntityShootBowEvent event){
+ //Entity Sanitation
+ if(event.getProjectile().getType() != EntityType.ARROW)return;
- //ARROW SANITATION
- Arrow arrow = (Arrow) event.getEntity();
- if (!(arrow.isCritical()) || !(arrow.getShooter() instanceof Player))return;
+ //Arrow Sanitation
+ Arrow arrow = (Arrow) event.getProjectile();
+ if (!(arrow.getShooter() instanceof Player))return;
- //PLAYER SANITATION
+ //Player Sanitation
Player player = (Player) arrow.getShooter();
if (!player.getInventory().contains(Material.TNT))return;
- //BOW SANITATION
+ //Bow Sanitation
ItemStack bow;
if (!((bow = player.getInventory().getItemInMainHand()).getType() == Material.BOW))return;
if (!(bow.containsEnchantment(Enchantment.PROTECTION_EXPLOSIONS)))return;
if (!(bow.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 10))return;
if (!(bow.getItemMeta().getDisplayName().toUpperCase().contains("CANNON BOW")))return;
+
+ //TNT Spawning
+
+ Vector playerVector = player.getEyeLocation().getDirection().normalize();
+ if (event.getForce() < minforce){
- TNTPrimed tnt = (TNTPrimed) arrow.getWorld().spawnEntity(arrow.getLocation(), EntityType.PRIMED_TNT);
- tnt.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(1.0));
- tnt.setCustomName(launchedTNTName);
- tnt.setFuseTicks(40);
-
- player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(-1));
- player.getWorld().playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 2.0F, 0);
- player.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, player.getLocation(), 2);
-
+
+
+ }else{
+ TNTPrimed tnt = (TNTPrimed) arrow.getWorld().spawnEntity(arrow.getLocation(), EntityType.PRIMED_TNT);
+
+ tnt.setVelocity(playerVector.multiply(SpeedMultiplier).multiply(event.getForce()));
+ tnt.setCustomName(launchedTNTName);
+ tnt.setFuseTicks(40);
+
+ //Player Recoil
+ player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(-1));
+ player.getWorld().playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 2.0F, 0);
+ player.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, player.getLocation(), 2);
+
+ }
arrow.remove();
+
+
return;
}
diff --git a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowSettings.java b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowSettings.java
new file mode 100644
index 0000000..e657375
--- /dev/null
+++ b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowSettings.java
@@ -0,0 +1,32 @@
+package buttondevteam.alipresents.components.magic.tricks;
+
+import org.apache.commons.lang3.math.NumberUtils;
+import org.bukkit.entity.Player;
+
+import buttondevteam.alipresents.architecture.commands.ModCommand;
+
+public class CannonBowSettings extends ModCommand {
+
+ @Override
+ public boolean OnCommand(Player player, String alias, String[] args) {
+ switch(args[0].toLowerCase()){
+ case "speedmultiplier":
+ CannonBowListener.SpeedMultiplier = NumberUtils.toDouble(args[1], CannonBowListener.SpeedMultiplier);
+ break;
+ case "minforce":
+ CannonBowListener.minforce = NumberUtils.toDouble(args[1], CannonBowListener.SpeedMultiplier);
+ break;
+ default:
+ player.sendMessage("That isn't a valid setting!");
+ player.sendMessage("Valid Settings are: ");
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String GetCommandPath(){
+ return "magic cannonbow";
+ }
+
+}