[1.16.5] Spawn Mob Command doesent work

Discussion in 'Plugin Development' started by Kopflos, Jul 2, 2021.

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

    Kopflos

    Ingame it says "An iternal error occurred while attempting to perform this command"

    heres the error
    cmd (open)

    Code:
    [01:21:05 ERROR]: Error occurred while enabling Projectlostintime v1.0 (Is it up to date?)
    java.lang.IllegalArgumentException: Plugin already initialized!
            at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:183) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:60) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
            at de.skyflamme.projectlostintime.Projectlostintime.<init>(Projectlostintime.java:21) ~[?:?]
            at de.skyflamme.projectlostintime.commands.lit.<init>(lit.java:13) ~[?:?]
            at de.skyflamme.projectlostintime.Projectlostintime.onEnable(Projectlostintime.java:29) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [spigot.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403) [spigot.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381) [spigot.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330) [spigot.jar:git-Spigot-dcd1643-e60fc34]
            at net.minecraft.server.v1_12_R1.MinecraftServer.t(MinecraftServer.java:422) [spigot.jar:git-Spigot-dcd1643-e60fc34]
            at net.minecraft.server.v1_12_R1.MinecraftServer.l(MinecraftServer.java:383) [spigot.jar:git-Spigot-dcd1643-e60fc34]
            at net.minecraft.server.v1_12_R1.MinecraftServer.a(MinecraftServer.java:338) [spigot.jar:git-Spigot-dcd1643-e60fc34]
            at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:272) [spigot.jar:git-Spigot-dcd1643-e60fc34]
            at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545) [spigot.jar:git-Spigot-dcd1643-e60fc34]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
    Caused by: java.lang.IllegalStateException: Initial initialization
            at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:186) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:60) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
            at de.skyflamme.projectlostintime.Projectlostintime.<init>(Projectlostintime.java:21) ~[?:?]
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_291]
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_291]
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_291]
            at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_291]
            at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_291]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:90) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:327) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:248) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.craftbukkit.v1_12_R1.CraftServer.loadPlugins(CraftServer.java:305) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
            at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:205) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
            ... 2 more


    heres the command executor

    command executor (open)

    Code:
    Main main = new Main();
    
        @Override
        public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
            if (label.equalsIgnoreCase("mydebug")) {
                if (sender instanceof Player) {
                    Player p = (Player) sender;
                    if (args.length > 0) {
                        if (args[0].equalsIgnoreCase("help")) {
                            p.sendMessage(ChatColor.YELLOW + "Help for lit:");
                            p.sendMessage(ChatColor.YELLOW + "witherknight: spawns wither knight");
                        } else {
                            if (args[0].equalsIgnoreCase("witherknight")) {
                                main.spawnWitherKnight(p.getWorld().getName(), p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(),
                                        p.getLocation().getPitch(), p.getLocation().getYaw());
                            }
                        }
                    }
                }
            }
            return false;
        }


    heres the method from the main calss:

    main class method (open)

    Code:
        public WitherSkeleton spawnWitherKnight(String worldname, double x, double y, double z, float pitch, float yaw) {
            World w = Bukkit.getWorld(worldname);
            Location loc = new Location(w, x, y, z, pitch, yaw);
            WitherSkeleton witherknight = (WitherSkeleton) w.spawnEntity(loc.add(0, 1, 1), EntityType.ZOMBIE);
    
            ItemStack dagger = new ItemStack(Material.DIAMOND_SWORD);
            ItemMeta dagger_meta = dagger.getItemMeta();
            dagger_meta.setCustomModelData(1);
            dagger_meta.setDisplayName(ChatColor.RESET + "Diamantkurzschwert");
            dagger_meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
            AttributeModifier daggerAttackDamage = new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", 5.0, AttributeModifier.Operation.ADD_NUMBER);
            dagger_meta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, daggerAttackDamage);
            AttributeModifier daggerAttackSpeed = new AttributeModifier(UUID.randomUUID(), "generic.attackSpeed", -1.8, AttributeModifier.Operation.ADD_NUMBER);
            dagger_meta.addAttributeModifier(Attribute.GENERIC_ATTACK_SPEED, daggerAttackSpeed);
            AttributeModifier daggerMovementSpeed = new AttributeModifier(UUID.randomUUID(), "generic.movementSpeed", 0.05, AttributeModifier.Operation.ADD_NUMBER);
            dagger_meta.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, daggerMovementSpeed);
            dagger_meta.setLore(Arrays.asList(" ",ChatColor.GRAY + "When in Main Hand:",ChatColor.DARK_GREEN + " 6 Attack Damage", ChatColor.DARK_GREEN + " 2.2 Attack Speed"));
            dagger.setItemMeta(dagger_meta);
    
            witherknight.getEquipment().setItemInMainHand(dagger);
    
            ItemStack leatherhelmet = new ItemStack(Material.LEATHER_CHESTPLATE);
            LeatherArmorMeta leatherhelmetmeta = (LeatherArmorMeta) leatherhelmet.getItemMeta();
            leatherhelmetmeta.setColor(Color.BLACK);
            leatherhelmet.setItemMeta(leatherhelmetmeta);
    
            ItemStack leathertunic = new ItemStack(Material.LEATHER_CHESTPLATE);
            LeatherArmorMeta leathertunicmeta = (LeatherArmorMeta) leathertunic.getItemMeta();
            leathertunicmeta.setColor(Color.BLACK);
            leathertunic.setItemMeta(leathertunicmeta);
    
            ItemStack leatherleggings = new ItemStack(Material.LEATHER_CHESTPLATE);
            LeatherArmorMeta leatherleggingsmeta = (LeatherArmorMeta) leatherleggings.getItemMeta();
            leathertunicmeta.setColor(Color.BLACK);
            leatherleggings.setItemMeta(leatherleggingsmeta);
    
            ItemStack leatherboots = new ItemStack(Material.LEATHER_CHESTPLATE);
            LeatherArmorMeta leatherbootsmeta = (LeatherArmorMeta) leatherboots.getItemMeta();
            leatherbootsmeta.setColor(Color.BLACK);
            leatherboots.setItemMeta(leatherbootsmeta);
    
            witherknight.getEquipment().setHelmet(leatherhelmet);
            witherknight.getEquipment().setChestplate(leathertunic);
            witherknight.getEquipment().setLeggings(leatherleggings);
            witherknight.getEquipment().setBoots(leatherboots);
    
    
            return witherknight;
        }
     
  2. Offline

    davidclue

    Code:
    Main main = new Main();
    You cannot make a new instance of your plugin... Your error literally says that the plugin is already initialized.
     
Thread Status:
Not open for further replies.

Share This Page