Development Assistance Firework arrows problem does not extend JavaPlugin..

Discussion in 'Plugin Help/Development/Requests' started by MaestroSwagger, Mar 16, 2015.

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

    MaestroSwagger

    Hello,

    I just started programming and i'm having some issue's with my code.
    I now have this code:
    Code:
    import net.minecraft.server.v1_8_R1.EntityFireworks;
    import net.minecraft.server.v1_8_R1.PacketPlayOutEntityStatus;
    import net.minecraft.server.v1_8_R1.World;
    
    import org.bukkit.Color;
    import org.bukkit.FireworkEffect;
    import org.bukkit.Location;
    import org.bukkit.craftbukkit.v1_8_R1.CraftWorld;
    import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
    import org.bukkit.entity.Firework;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Projectile;
    import org.bukkit.event.entity.ProjectileHitEvent;
    import org.bukkit.inventory.meta.FireworkMeta;
    
    public class FirstPlugin extends EntityFireworks {
        Player[] players = null;
    
        public FirstPlugin(World world, Player... p) {
            super(world);
            players = p;
            this.a(0.25F, 0.25F);
        }
    
        boolean gone = false;
    
        @Override
        public void s_() {
            if (gone) {
                return;
            }
    
            if (!this.world.isStatic) {
                gone = true;
    
                if (players != null)
                    if (players.length > 0)
                        for (Player player : players)
                            (((CraftPlayer) player).getHandle()).playerConnection.sendPacket(new PacketPlayOutEntityStatus(this, (byte) 17));
                    else
                        world.broadcastEntityEffect(this, (byte) 17);
                this.die();
            }
        }
    
        public static void spawn(Location location, FireworkEffect effect, Player... players) {
            try {
                FirstPlugin firework = new FirstPlugin(((CraftWorld) location.getWorld()).getHandle(), players);
                FireworkMeta meta = ((Firework) firework.getBukkitEntity()).getFireworkMeta();
                meta.addEffect(effect);
                ((Firework) firework.getBukkitEntity()).setFireworkMeta(meta);
                firework.setPosition(location.getX(), location.getY(), location.getZ());
    
                if ((((CraftWorld) location.getWorld()).getHandle()).addEntity(firework)) {
                    firework.setInvisible(true);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    public void onHit(ProjectileHitEvent e){
        Projectile p = e.getEntity(); //Getting the projectile
        FireworkEffect.Builder builder = FireworkEffect.builder();
        FireworkEffect effect = builder.flicker(false).trail(false).with(FireworkEffect.Type.BALL).withColor(Color.RED).withFade(Color.BLUE).build(); //Build the firework to suit your liking
        FirstPlugin.spawn(p.getLocation(), effect); //Spawning the firework
    }
    }
    and im getting this error:
    Code:
    [15-03 18:19:30 ] [Server] ERROR Could not load 'plugins/FirstPlugin.jar' in folder 'plugins'
    [15-03 18:19:30 ] [Server] [Informatie] org.bukkit.plugin.InvalidPluginException: main class `me.MaestroSwagger.firstplugin.FirstPlugin' does not extend JavaPlugin
    [15-03 18:19:30 ] [Server] [Informatie] at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:73) ~[spigot1.8.new.jar:git-Spigot-bf0ac55-3ee97a3]
    [15-03 18:19:30 ] [Server] [Informatie] at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot1.8.new.jar:git-Spigot-bf0ac55-3ee97a3]
    [15-03 18:19:30 ] [Server] [Informatie] at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot1.8.new.jar:git-Spigot-bf0ac55-3ee97a3]
    [15-03 18:19:30 ] [Server] [Informatie] at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot1.8.new.jar:git-Spigot-bf0ac55-3ee97a3]
    [15-03 18:19:30 ] [Server] [Informatie] at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugins(CraftServer.java:291) [spigot1.8.new.jar:git-Spigot-bf0ac55-3ee97a3]
    [15-03 18:19:30 ] [Server] [Informatie] at net.minecraft.server.v1_8_R1.DedicatedServer.init(DedicatedServer.java:152) [spigot1.8.new.jar:git-Spigot-bf0ac55-3ee97a3]
    [15-03 18:19:30 ] [Server] [Informatie] at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:505) [spigot1.8.new.jar:git-Spigot-bf0ac55-3ee97a3]
    [15-03 18:19:30 ] [Server] [Informatie] at java.lang.Thread.run(Thread.java:722) [?:1.7.0_21]
    [15-03 18:19:30 ] [Server] [Informatie] Caused by: java.lang.ClassCastException: class me.MaestroSwagger.firstplugin.FirstPlugin
    [15-03 18:19:30 ] [Server] [Informatie] at java.lang.Class.asSubclass(Class.java:3046) ~[?:1.7.0_21]
    [15-03 18:19:30 ] [Server] [Informatie] at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:71) ~[spigot1.8.new.jar:git-Spigot-bf0ac55-3ee97a3]
    [15-03 18:19:30 ] [Server] [Informatie] ... 7 more
    I dont know how to fix this can somebody help me?
    sorry if this is a stupid question i just started programming! :p
    Thanks in advance!
     
  2. Online

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives
    @MaestroSwagger If this is your only class: not possible
    Your main class has to extend JavaPlugin
     
Thread Status:
Not open for further replies.

Share This Page