// Path: src/com/hpspells/core/util/SVPBypass.java
// public static Method getMethod(Class<?> cl, String method) {
//     for (Method m : cl.getMethods()) {
//         if (m.getName().equals(method)) {
//             return m;
//         }
//     }
//     return null;
// }


import static com.hpspells.core.util.SVPBypass.getMethod;
import java.lang.reflect.Method;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.inventory.meta.FireworkMeta;
package com.hpspells.core.util;




/**
 * FireworkEffectPlayer v1.0
 * <p/>
 * FireworkEffectPlayer provides a thread-safe and (reasonably) version independant way to instantly explode a FireworkEffect at a given location.
 * You are welcome to use, redistribute, modify and destroy your own copies of this source with the following conditions:
 * <p/>
 * 1. No warranty is given or implied.
 * 2. All damage is your own responsibility.
 * 3. You provide credit publicly to the original source should you release the plugin.
 *
 * @author codename_B
 */
public class FireworkEffectPlayer {

    /*
     * Example use:
     *
     * public class FireWorkPlugin implements Listener {
     *
     * FireworkEffectPlayer fplayer = new FireworkEffectPlayer();
     *
     * @EventHandler
     * public void onPlayerLogin(PlayerLoginEvent event) {
     *   fplayer.playFirework(event.getPlayer().getWorld(), event.getPlayer.getLocation(), Util.getRandomFireworkEffect());
     * }
     *
     * }
     */

    // internal references, performance improvements
    private static Method world_getHandle = null, nms_world_broadcastEntityEffect = null, firework_getHandle = null;

    /**
     * Play a pretty firework at the location with the FireworkEffect when called
     *
     * @param world
     * @param loc
     * @param fe
     * @throws Exception
     */
    public static void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
        // Bukkity load (CraftFirework)
        Firework fw = (Firework) world.spawn(loc, Firework.class);
        // the net.minecraft.server.World
        Object nms_world = null;
        Object nms_firework = null;
        /*
         * The reflection part, this gives us access to funky ways of messing around with things
         */
        if (world_getHandle == null) {
            // get the methods of the craftbukkit objects
// Path: src/com/hpspells/core/util/SVPBypass.java
// public static Method getMethod(Class<?> cl, String method) {
//     for (Method m : cl.getMethods()) {
//         if (m.getName().equals(method)) {
//             return m;
//         }
//     }
//     return null;
// }


// Path: src/com/hpspells/core/util/FireworkEffectPlayer.java
import static com.hpspells.core.util.SVPBypass.getMethod;
import java.lang.reflect.Method;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.inventory.meta.FireworkMeta;

package com.hpspells.core.util;




/**
 * FireworkEffectPlayer v1.0
 * <p/>
 * FireworkEffectPlayer provides a thread-safe and (reasonably) version independant way to instantly explode a FireworkEffect at a given location.
 * You are welcome to use, redistribute, modify and destroy your own copies of this source with the following conditions:
 * <p/>
 * 1. No warranty is given or implied.
 * 2. All damage is your own responsibility.
 * 3. You provide credit publicly to the original source should you release the plugin.
 *
 * @author codename_B
 */
public class FireworkEffectPlayer {

    /*
     * Example use:
     *
     * public class FireWorkPlugin implements Listener {
     *
     * FireworkEffectPlayer fplayer = new FireworkEffectPlayer();
     *
     * @EventHandler
     * public void onPlayerLogin(PlayerLoginEvent event) {
     *   fplayer.playFirework(event.getPlayer().getWorld(), event.getPlayer.getLocation(), Util.getRandomFireworkEffect());
     * }
     *
     * }
     */

    // internal references, performance improvements
    private static Method world_getHandle = null, nms_world_broadcastEntityEffect = null, firework_getHandle = null;

    /**
     * Play a pretty firework at the location with the FireworkEffect when called
     *
     * @param world
     * @param loc
     * @param fe
     * @throws Exception
     */
    public static void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
        // Bukkity load (CraftFirework)
        Firework fw = (Firework) world.spawn(loc, Firework.class);
        // the net.minecraft.server.World
        Object nms_world = null;
        Object nms_firework = null;
        /*
         * The reflection part, this gives us access to funky ways of messing around with things
         */
        if (world_getHandle == null) {
            // get the methods of the craftbukkit objects
            world_getHandle = getMethod(world.getClass(), "getHandle");