Lightning strike block problem

Discussion in 'Plugin Development' started by desup, Jan 5, 2012.

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

    desup

    Hello, I've got this piece of code, in player listener, but i cant get it to work.

    Code:
        public void giver(PlayerInteractEvent event) {
            if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
        Block b = event.getClickedBlock();
        Player p = event.getPlayer();
        ItemStack holding = p.getItemInHand();
        if(holding.getType() == Material.ARROW && p.hasPermission("light.bl")){
            b.getWorld().strikeLightning(b.getLocation());
            p.sendMessage("juchuu");
        } else {
            p.sendMessage("Sorry");
        }
        }
        }
    DO you know where is problem?
    By the way, event is registered.
    Thank you.
     
  2. public void giver(PlayerInteractEvent event) {
    has to be:
    public void onPlayerInteract(PlayerInteractEvent event) {
     
    r3Fuze likes this.
  3. Offline

    knightidus

    This is the way to do it, i think! (I use it and it works fine)

    Code:
     public void strikeLightning(Player p){
            Block block = p.getTargetBlock(null, 300);
            Location coords = block.getLocation();
            coords.getWorld().strikeLightning(coords);
    
        }
    Simply call this method in at the interact event!
     
  4. Offline

    edocsyl

    How can u get the cordiantes from a arrow / snowball who hits someting ?
     
  5. Offline

    Father Of Time

    edocsyl likes this.
  6. Offline

    edocsyl

    I get many errors

    PHP:


          
    if (instanceof EntityDamageByEntityEvent) {
     
             
    Entity attacker = ((EntityDamageByEntityEvente).getDamager();

    if(
    attacker instanceof Projectile){
                 if(
    attacker instanceof Arrow){

                    
    Arrow arr = (Arrowattacker.getLocation();

                    
    arr.getWorld().createExplosion(arr.getLocation(), 15);

                 }
             }
    }
    2012-01-07 09:31:44 [SEVERE] Could not pass event ENTITY_DAMAGE to DontHitMe
    java.lang.ClassCastException: org.bukkit.Location cannot be cast to org.bukkit.entity.Arrow
    at me.edocsyl.DontHitMe.DontHitMeEntityListener.onEntityDamage(DontHitMeEntityListener.java:106)
    at org.bukkit.plugin.java.JavaPluginLoader$64.execute(JavaPluginLoader.java:711)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:339)
    at net.minecraft.server.EntityArrow.w_(EntityArrow.java:196)
    at net.minecraft.server.World.entityJoinedWorld(World.java:1253)
    at net.minecraft.server.WorldServer.entityJoinedWorld(WorldServer.java:107)
    at net.minecraft.server.World.playerJoinedWorld(World.java:1235)
    at net.minecraft.server.World.tickEntities(World.java:1142)
    at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:518)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)

    Btw: is there a way to download the Docs as html files (http://jd.bukkit.org/doxygen) ?
     
  7. Code:java
    1. Arrow arr = (Arrow) attacker;
     
  8. Offline

    edocsyl

    Thxx, this is rly funny

    Destroy the whole world with a arrow

    But how can jeck if a player fires the arrow.
     
Thread Status:
Not open for further replies.

Share This Page