Adjusted Cannon Bow
Made Draw Distance smaller Made TNT launch depending on draw Have launch settings be adjustable
This commit is contained in:
parent
341fb1be2e
commit
c2389eb74c
6 changed files with 73 additions and 24 deletions
|
@ -5,16 +5,12 @@ version: 2.0.2
|
||||||
commands:
|
commands:
|
||||||
alilink:
|
alilink:
|
||||||
description: creates wireless redstone
|
description: creates wireless redstone
|
||||||
cashmob:
|
|
||||||
description: creates mobs
|
|
||||||
cb:
|
cb:
|
||||||
description: creates creative boundaries
|
description: creates creative boundaries
|
||||||
debug:
|
debug:
|
||||||
description: debug commands
|
description: debug commands
|
||||||
flaircolour:
|
flaircolour:
|
||||||
description: flaaairs
|
description: flaaairs
|
||||||
fruit:
|
|
||||||
description: fruits
|
|
||||||
gpower:
|
gpower:
|
||||||
description: powerssss
|
description: powerssss
|
||||||
insurance:
|
insurance:
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -92,7 +92,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>3.4</version>
|
<version>3.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
|
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
|
||||||
|
|
|
@ -7,11 +7,14 @@ import buttondevteam.alipresents.components.magic.tricks.AliArrowListener;
|
||||||
import buttondevteam.alipresents.components.magic.tricks.BoomBowDeathListener;
|
import buttondevteam.alipresents.components.magic.tricks.BoomBowDeathListener;
|
||||||
import buttondevteam.alipresents.components.magic.tricks.BoomBowListener;
|
import buttondevteam.alipresents.components.magic.tricks.BoomBowListener;
|
||||||
import buttondevteam.alipresents.components.magic.tricks.CannonBowListener;
|
import buttondevteam.alipresents.components.magic.tricks.CannonBowListener;
|
||||||
|
import buttondevteam.alipresents.components.magic.tricks.CannonBowSettings;
|
||||||
|
|
||||||
public class MagicComponent extends Component{
|
public class MagicComponent extends Component{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(JavaPlugin plugin) {
|
public void register(JavaPlugin plugin) {
|
||||||
|
registerCommand(plugin, new CannonBowSettings());
|
||||||
|
|
||||||
registerListener(plugin, new AliArrowListener(plugin));
|
registerListener(plugin, new AliArrowListener(plugin));
|
||||||
registerListener(plugin, new BoomBowDeathListener());
|
registerListener(plugin, new BoomBowDeathListener());
|
||||||
registerListener(plugin, new BoomBowListener(plugin));
|
registerListener(plugin, new BoomBowListener(plugin));
|
||||||
|
|
|
@ -8,6 +8,7 @@ public class AliArrowTask extends BukkitRunnable {
|
||||||
static String[] permittedUsers = {"alisolarflare", "Zanthr", "NorbiPeti"};
|
static String[] permittedUsers = {"alisolarflare", "Zanthr", "NorbiPeti"};
|
||||||
String name;
|
String name;
|
||||||
Arrow arrow;
|
Arrow arrow;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
public AliArrowTask(Arrow arrow, String name) {
|
public AliArrowTask(Arrow arrow, String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -16,7 +17,8 @@ public class AliArrowTask extends BukkitRunnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (arrow.isOnGround() || arrow.isDead()) {
|
count++;
|
||||||
|
if (count > 400 ||arrow.isOnGround() || arrow.isDead()) {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,14 @@ import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
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.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class CannonBowListener implements Listener {
|
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";
|
public final static String launchedTNTName = "CANNON BOW TNT:42170";
|
||||||
JavaPlugin plugin;
|
JavaPlugin plugin;
|
||||||
public CannonBowListener(JavaPlugin plugin){
|
public CannonBowListener(JavaPlugin plugin){
|
||||||
|
@ -24,35 +27,48 @@ public class CannonBowListener implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onProjectileLaunch(ProjectileLaunchEvent event){
|
public void onProjectileLaunch(EntityShootBowEvent event){
|
||||||
//ENTITY SANITATION
|
//Entity Sanitation
|
||||||
if(event.getEntity().getType() != EntityType.ARROW)return;
|
if(event.getProjectile().getType() != EntityType.ARROW)return;
|
||||||
|
|
||||||
//ARROW SANITATION
|
//Arrow Sanitation
|
||||||
Arrow arrow = (Arrow) event.getEntity();
|
Arrow arrow = (Arrow) event.getProjectile();
|
||||||
if (!(arrow.isCritical()) || !(arrow.getShooter() instanceof Player))return;
|
if (!(arrow.getShooter() instanceof Player))return;
|
||||||
|
|
||||||
//PLAYER SANITATION
|
//Player Sanitation
|
||||||
Player player = (Player) arrow.getShooter();
|
Player player = (Player) arrow.getShooter();
|
||||||
if (!player.getInventory().contains(Material.TNT))return;
|
if (!player.getInventory().contains(Material.TNT))return;
|
||||||
|
|
||||||
//BOW SANITATION
|
//Bow Sanitation
|
||||||
ItemStack bow;
|
ItemStack bow;
|
||||||
if (!((bow = player.getInventory().getItemInMainHand()).getType() == Material.BOW))return;
|
if (!((bow = player.getInventory().getItemInMainHand()).getType() == Material.BOW))return;
|
||||||
if (!(bow.containsEnchantment(Enchantment.PROTECTION_EXPLOSIONS)))return;
|
if (!(bow.containsEnchantment(Enchantment.PROTECTION_EXPLOSIONS)))return;
|
||||||
if (!(bow.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 10))return;
|
if (!(bow.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 10))return;
|
||||||
if (!(bow.getItemMeta().getDisplayName().toUpperCase().contains("CANNON BOW")))return;
|
if (!(bow.getItemMeta().getDisplayName().toUpperCase().contains("CANNON BOW")))return;
|
||||||
|
|
||||||
|
//TNT Spawning
|
||||||
|
|
||||||
|
Vector playerVector = player.getEyeLocation().getDirection().normalize();
|
||||||
|
if (event.getForce() < minforce){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
TNTPrimed tnt = (TNTPrimed) arrow.getWorld().spawnEntity(arrow.getLocation(), EntityType.PRIMED_TNT);
|
TNTPrimed tnt = (TNTPrimed) arrow.getWorld().spawnEntity(arrow.getLocation(), EntityType.PRIMED_TNT);
|
||||||
tnt.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(1.0));
|
|
||||||
|
tnt.setVelocity(playerVector.multiply(SpeedMultiplier).multiply(event.getForce()));
|
||||||
tnt.setCustomName(launchedTNTName);
|
tnt.setCustomName(launchedTNTName);
|
||||||
tnt.setFuseTicks(40);
|
tnt.setFuseTicks(40);
|
||||||
|
|
||||||
|
//Player Recoil
|
||||||
player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(-1));
|
player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(-1));
|
||||||
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 2.0F, 0);
|
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 2.0F, 0);
|
||||||
player.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, player.getLocation(), 2);
|
player.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, player.getLocation(), 2);
|
||||||
|
|
||||||
|
}
|
||||||
arrow.remove();
|
arrow.remove();
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue