Solved [PluginDevelopment] GunWarFare

Discussion in 'Plugin Development' started by ShearsSheep, Dec 28, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    ShearsSheep

    Hey guys , I need your help , you see , at the moment i'm trying to code a gun Warfare Plugin..but..its very glitchy. I need abit of help in this. The gun (Stick Shooter) Works..and the other plugin..the fireWorkKill (FireWork Effect When player get's killed). I kind seem to merge them in.
    Here is the code.

    ============Gun Shooter =======================

    public void onPlayerInteract(PlayerInteractEvent e) {
    if (!(e.getAction() == Action.RIGHT_CLICK_AIR)) return;
    if (!(e.getAction() == Action.RIGHT_CLICK_BLOCK)) return;
    if (!(e.getItem().getType() == Material.STICK)) return;
    Arrow a = e.getPlayer().launchProjectile(Arrow.class);
    a.setFallDistance(100);
    Player shooter = e.getPlayer();
    a.getWorld().playEffect(a.getLocation(), Effect.MOBSPAWNER_FLAMES, 100);
    shooter.playSound(shooter.getLocation(), Sound.LAVA_POP, 500, 1);
    }

    ============FireKill===============

    import org.bukkit.Color;
    import org.bukkit.FireworkEffect;
    import org.bukkit.FireworkEffect.Type;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Firework;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDeathEvent;
    import org.bukkit.inventory.meta.FireworkMeta;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Main extends JavaPlugin implements Listener{
    public void onEnable() {
    getLogger().info("BetaPlugin has been enabled!");
    getServer().getPluginManager().registerEvents(this, this);
    }
    public void onDisable() {
    getLogger().info("BetaPlugin has been disabled!");
    }
    @EventHandler
    public void onDeath(EntityDeathEvent event) {
    if(event.getEntity() instanceof Player && event.getEntity().getKiller() instanceof Player) {
    Player player = event.getEntity().getKiller();
    Firework fw = (Firework) player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREWORK);
    FireworkMeta fwm = fw.getFireworkMeta();
    Type type = Type.BALL;
    Color c1 = Color.AQUA;
    Color c2 = Color.BLUE;
    FireworkEffect effect = FireworkEffect.builder().withFlicker().withColor(c1).withFade(c2).with(type).withTrail().build();
    fwm.addEffect(effect);
    fwm.setPower(o);
    fw.setFireworkMeta(fwm);
    }
    }
    }


    If anyone founds a soulution. Please reply back ASAP
    ~ShearsSheep/Deasertman
     
  2. Offline

    sgavster

    You never said your problem..

    If you want it to instantly explode, just do:

    firework.detonate();
     
  3. Offline

    ShearsSheep

    Oh i meant how do i merge them both together . mean that when the arrow hit the player and die, the killer would have a firework at their heads.
     
  4. Offline

    deasertman

    Basically, we want the firework effect to happen only for killers who use the stick against other players. Oh and, not when the victim is killed by the stick, but by the arrow shot from it.
     
  5. Offline

    ShearsSheep

    I have tried to seperate them into 2 plugins..but it still would not work..when the arrow that is launched by the stick won't have the effect of fireworks :/
     
  6. Offline

    xTigerRebornx

    ShearsSheep It wont work because the Entity killing the player is an arrow, but you are checking if they are both players. You can just check if the Entity dieing is a player, then play the firework if it is, or check if the arrow launched was launched by a Player
     
  7. Offline

    deasertman

    xTigerRebornx I have tried that but for some reason it did not work. I checked if the killer is an instance of Arrow and if the shooter is a player however it did not work. The reason I showed this code is so that it is easier to edit for anyone willing to help.
     
  8. Offline

    xTigerRebornx

    deasertman Did you register your event properly (and remember the @EventHandler)

    EDIT: Can I see the code you tried to do this?
     
  9. Offline

    ShearsSheep

    All added to skype chat, talk there :p

    Solved! :D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page