Get Rid of fire - Completely!

Discussion in 'Plugin Development' started by iamcion, Jan 7, 2014.

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

    iamcion

    Okay, so i have this unique KitPvP server.
    anyway, there is a thor kit, which can smite enemys. :)

    buuuuuuut, the only problem is, it creates fire, (fire spread is off)
    i was wondering, if there was a way to disable fire from being spawned... (so, it never appears on the server)


    i made a plugin for this, it works once.. but thats it....

    Code:
    package me.iamcion.NLF;
     
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockIgniteEvent;
    import org.bukkit.entity.*;
     
    public class Events implements Listener{
    @EventHandler
    public void onBlockignite(BlockIgniteEvent event) {
        if (event.isCancelled())
            return;
        if(event.getIgnitingEntity().getType() == EntityType.LIGHTNING){
            event.setCancelled(true);
            }
        }
    }
    Where exactly am i going wrong?
     
  2. Offline

    mydeblob

    If you just want to disable it completely just cancel the entire event, no need for if statements.
     
  3. Offline

    Wizehh

    Code:java
    1. public void onBlockignite(BlockIgniteEvent event) {
    2. event.setCancelled(true);
    3. }
     
  4. Offline

    iamcion

    Great! thanks :)
    wasn't sure :)
     
  5. Offline

    Wizehh

  6. Offline

    iamcion

    theres still fire.
    i looked into the other plugin's code "KingKits Special" that has a piece of code that allows it.
    is there a way to remove that? without re-making that plugin >_> because, i cant. its giving me alot of errorsif i do that haha

    even if it allows fire. but removes itself within 3s would be good :/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  7. Offline

    mydeblob

    iamcion
    Are you registering the event? That should cancel all fire.
     
  8. Offline

    iamcion


    Code:
    package me.iamcion.NLF;
     
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockIgniteEvent;
     
    public class Events implements Listener{
    @EventHandler
    public void onBlockignite(BlockIgniteEvent event) {
    event.setCancelled(true);
    }
    }
    
     
  9. Offline

    mydeblob

  10. Offline

    Wizehh

    iamcion You must also register the event in your Main class.
     
  11. Offline

    iamcion

    like this?
    Code:
    package me.iamcion.NLF;
     
    import me.iamcion.adventurer.Events;
     
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Main extends JavaPlugin {
       
     
        @Override
        public void onEnable(){
            Events events = new Events();
            getServer().getPluginManager().registerEvents(events, this);
            getLogger().info("NLF Plugin Enabled!");
            getLogger().info("~Plugin Created By " + getDescription().getAuthors() + "!~");
            // TODO Insert logic to be performed when the plugin is enabled
        }
     
        @Override
        public void onDisable() {
            getLogger().info("NLF Plugin Disabled!");
            // TODO Insert logic to be performed when the plugin is disabled
        }
    }
     
  12. Offline

    Wizehh

    That looks right; try adding a
    Code:java
    1. System.out.println("Works");

    right under your @EventHandler, then tell me what happens.
     
  13. Offline

    iamcion

    Syntax Error :p
     
  14. Offline

    Wizehh

  15. Offline

    iamcion

    Syntax Error in Eclipse, when i put it under the @EventHandler
     
  16. Offline

    Wizehh

    iamcion Oops, sorry; what I meant was, put under your method:
    Code:java
    1. public void onBlockignite(BlockIgniteEvent event) {
    2. System.out.println("works");
    3.  
     
  17. Offline

    _Filip

    Do @EventHandler (priority = EventPriority.HIGHEST)
    Or if you want to live on the wild side, @EventHandler (priority = EventPriority.MONITOR)
    Done.
     
  18. Offline

    Wizehh

    swampshark19 Pardon me if this is a trivial question, but why would that change anything?
     
  19. Offline

    _Filip

    Wizehh
     
    Wizehh likes this.
  20. Offline

    Garris0n

    Never change the event under priority.monitor.
     
  21. Offline

    _Filip

    Garris0n
    I never change the event under priority.monitor, nor will I recommend it for anyone, I just said that it is an option if they want to live on the wild side.
     
  22. Offline

    iamcion

    it works, cheers :)
     
  23. Offline

    Garris0n

    If you mean the side of screwing up somebody else's plugin, then yeah, the wild side...
     
  24. Offline

    _Filip

    iamcion
    That's not the solution though.
    He tried to get you to add a debug message, but there is no need for one, since I just supplied you with the solution.

    Garris0n
    Hahahaha, yes. The wild side.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  25. Offline

    Wizehh

    My bad, I didn't see that part.
     
  26. Offline

    iamcion

    swampshark19 well, it seemed to work! hahahaha.
    anyway, now the lightning wont strike down, the sky will flash, and entities will take damage, but thats that...
     
Thread Status:
Not open for further replies.

Share This Page