Good Explosion Method.

Discussion in 'Plugin Development' started by TheGamesHawk2001, Apr 11, 2015.

Thread Status:
Not open for further replies.
  1. Hey all I was thinking about making a decent explosion method that returns blocks to an inv smelted or not smelted e.t.c

    I have this so far but have no clue how to get the drops of the createExplosion thing so erm yer :D

        public void explode(BlockBreakEvent e, String world, Location loc, int power, boolean goToInv, boolean smelt) {
            Bukkit.getServer().getWorld(world).createExplosion(e.getBlock().getLocation(), power);
  2. Make an EntityExplodeEvent:
    1. @EventHandler
    2. public void onExplode(EntityExplodeEvent e) {
    3. List<Block> blocks = new ArrayList<Block>(e.blockList());
    4. e.blockList().clear();
    6. //Do stuff with the blocks list
    7. }
  3. How would I check the instanceof the Explosion?
  4. Add the Location of the explosion (when you create it) to a List<Location>.
    Check in the event if the List contains the Location (e.getLocation) and then remove it.
  5. "Check in the event" what event. if I create a bunch of lists for no rason inside an entityexplodeevent I can't then access that somewhere else where I actually need it can i?
  6. You only need one list OUTSIDE of any method but inside the class.
    When you create the explosion, add the Location of the explosion to the list.
    In the event, check if the list contains the Location of the explosion and remove it.

    I suggest you learning more java if you don't know that variables inside a method can't be accessed somewhere else.
    The easiest way is to put the variable directly in the class somewhere
  7. You're a very bad explainer. Thanks for your help...

    And also don't tell me what to do. Tell me why.
  8. Offline


    @TheGamesHawk2001 Just saying, if you were proficient in Java you wouldn't need explaining why. Or how.
  9. Im talking about the logic of it :) Adding a location to a list and then removing it, that has no benefit to what I am trying to do.
  10. English is not my native language..

    And why you should use it:
    Because you can make it only run the event for the explosions you created and not for other explosions like a creeper or an explosion created by an other plugin.
Thread Status:
Not open for further replies.

Share This Page