Adjusted and created settings for Cannon Bow <@114932850507120641> #40
6 changed files with 73 additions and 24 deletions
|
@ -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:
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -92,7 +92,7 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.4</version>
|
||||
<version>3.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<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.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));
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
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);
|
||||
//TNT Spawning
|
||||
|
||||
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);
|
||||
Vector playerVector = player.getEyeLocation().getDirection().normalize();
|
||||
if (event.getForce() < minforce){
|
||||
|
||||
|
||||
|
||||
}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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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