What's wrong with my plugin? :(

Discussion in 'Plugin Help/Development/Requests' started by Just_Niico, May 29, 2015.

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

    Just_Niico

    Hello Bukkit Community! So today I finished coding my plugin called "AstroNetwork" and exported it and all and uploaded it to my test server. But when I did /pl it didn't show up and none of the commands worked. Can someone tell me what went wrong? Thanks.

    Main:
    Code:
    package com.astronetwork.effects;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    public class Effects extends JavaPlugin {
      
    
      
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            Player p = (Player) sender;
            if (cmd.getName().equalsIgnoreCase("speed")) {
                if (!p.hasPermission("astroeffects.speed")) {
                    p.sendMessage(ChatColor.RED + "You do not have permission!");
                } else {
                    p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 3000, 1));
                    p.sendMessage(ChatColor.GREEN + "You have received SPEED for 5 minutes!");
                    return true;
            }
            }
                if (cmd.getName().equalsIgnoreCase("strength")) {
                    if (!p.hasPermission("astroeffects.strength")) {
                        p.sendMessage(ChatColor.RED + "You do not have permission!");
                    } else {
                        p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 3000, 1));
                        p.sendMessage(ChatColor.GREEN + "You have received STRENGTH for 5 minutes!");
                        return true;
                    }
                }
                if (cmd.getName().equalsIgnoreCase("invis")) {
                    if (!p.hasPermission("astroeffects.invis")) {
                    p.sendMessage(ChatColor.RED + "You do not have permission!");  
                    } else {
                        p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 3000, 1));
                        p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 3000, 1));
                        p.sendMessage(ChatColor.GREEN + "You have received INVISIBILITY for 5 minutes!");
                        return true;
                    }
                }
                return true;
        }
          
      
    }
    Plugin.yml:
    Code:
    name: AstroEffects
    version: 1.1
    main: com.astronetwork.effects.Effects
    authors: [JustNiico, Lexuss]
    commands:
        speed:
            description: Get speed for 5 minutes.
        strength:
            description: Get strength for 5 minutes.
        invis:
            description: Get invisibility for 5 minutes.
     
  2. @Just_Niico Do not use unsafe casting. A CommandSender isn't always a Player. Please post full startup log.
     
  3. Offline

    Just_Niico

  4. Offline

    Just_Niico

    @AdamQpzm I'm not sure where to put it... do I put it after my onCommand?
     
  5. @Just_Niico You'll want to place it in such a fashion that, should instanceof Player return false, you don't try to cast it to one. If you can't work out where or how you'd do that, then you probably need to learn more about Java :)
     
  6. Offline

    Just_Jitse

  7. Offline

    Just_Niico

    @Just_Jitse I don't have one

    @AdamQpzm
    So

    if (sender instanceof Player) {
    //code goes here
    }

    } else {
    //code goes here for console
    }
    ?

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

    Just_Jitse

    AdamQpzm likes this.
  9. Offline

    Defman21

    Code:
    package com.astronetwork.effects;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    public class Effects extends JavaPlugin {
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            if (!(sender instanceof Player)) return false;
            Player p = (Player) sender;
            if (cmd.getName().equalsIgnoreCase("speed")) {
                if (!p.hasPermission("astroeffects.speed")) {
                    p.sendMessage(ChatColor.RED + "You do not have permission!");
                } else {
                    p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 3000, 1));
                    p.sendMessage(ChatColor.GREEN + "You have received SPEED for 5 minutes!");
                    return true;
            }
            }
                if (cmd.getName().equalsIgnoreCase("strength")) {
                    if (!p.hasPermission("astroeffects.strength")) {
                        p.sendMessage(ChatColor.RED + "You do not have permission!");
                    } else {
                        p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 3000, 1));
                        p.sendMessage(ChatColor.GREEN + "You have received STRENGTH for 5 minutes!");
                        return true;
                    }
                }
                if (cmd.getName().equalsIgnoreCase("invis")) {
                    if (!p.hasPermission("astroeffects.invis")) {
                    p.sendMessage(ChatColor.RED + "You do not have permission!"); 
                    } else {
                        p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 3000, 1));
                        p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 3000, 1));
                        p.sendMessage(ChatColor.GREEN + "You have received INVISIBILITY for 5 minutes!");
                        return true;
                    }
                }
                return true;
        }
        
    }
     
  10. Offline

    westjet

    Post the test server startup log.
     
  11. Offline

    Just_Niico

    @westjet @Defman21 @AdamQpzm @Just_Jitse
    Log:
    Code:
    [19:32:29] [Server thread/INFO]: Starting minecraft server version 1.7.10
    [19:32:30] [Server thread/INFO]: Loading properties
    [19:32:30] [Server thread/INFO]: Default game type: SURVIVAL
    [19:32:31] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-1554 (MC: 1.7.10) (Implementing API version 1.7.10-R0.1-SNAPSHOT)
    [19:32:36] [Server thread/INFO]: Server Ping Player Sample Count: 12
    [19:32:36] [Server thread/INFO]: Using 4 threads for Netty based IO
    [19:32:36] [Server thread/INFO]: Generating keypair
    [19:32:37] [Server thread/INFO]: Starting Minecraft server on 192.168.1.73:25565
    [19:32:38] [Server thread/ERROR]: Could not load 'plugins\AstroEffectsNewV.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
        at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:162) ~[craftbukkit.jar:git-Spigot-1554]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [craftbukkit.jar:git-Spigot-1554]
        at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugins(CraftServer.java:369) [craftbukkit.jar:git-Spigot-1554]
        at net.minecraft.server.v1_7_R4.DedicatedServer.init(DedicatedServer.java:152) [craftbukkit.jar:git-Spigot-1554]
        at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:458) [craftbukkit.jar:git-Spigot-1554]
        at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Spigot-1554]
    Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token; found character      '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation);  in 'reader', line 6, column 1:
            speed:
        ^
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:420) ~[craftbukkit.jar:git-Spigot-1554]
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:226) ~[craftbukkit.jar:git-Spigot-1554]
        at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(ParserImpl.java:586) ~[craftbukkit.jar:git-Spigot-1554]
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158) ~[craftbukkit.jar:git-Spigot-1554]
        at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:143) ~[craftbukkit.jar:git-Spigot-1554]
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:132) ~[craftbukkit.jar:git-Spigot-1554]
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:237) ~[craftbukkit.jar:git-Spigot-1554]
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:159) ~[craftbukkit.jar:git-Spigot-1554]
        at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:122) ~[craftbukkit.jar:git-Spigot-1554]
        at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:105) ~[craftbukkit.jar:git-Spigot-1554]
        at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:120) ~[craftbukkit.jar:git-Spigot-1554]
        at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:481) ~[craftbukkit.jar:git-Spigot-1554]
        at org.yaml.snakeyaml.Yaml.load(Yaml.java:412) ~[craftbukkit.jar:git-Spigot-1554]
        at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.java:232) ~[craftbukkit.jar:git-Spigot-1554]
        at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:157) ~[craftbukkit.jar:git-Spigot-1554]
        ... 5 more
    [19:32:38] [Server thread/INFO]: Set PluginClassLoader as parallel capable
    [19:32:38] [Server thread/ERROR]: Could not load 'plugins\AstroRagequit.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.Error: Unresolved compilation problem:
        Syntax error on token "}", { expected after this token
    
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[craftbukkit.jar:git-Spigot-1554]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[craftbukkit.jar:git-Spigot-1554]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [craftbukkit.jar:git-Spigot-1554]
        at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugins(CraftServer.java:369) [craftbukkit.jar:git-Spigot-1554]
        at net.minecraft.server.v1_7_R4.DedicatedServer.init(DedicatedServer.java:152) [craftbukkit.jar:git-Spigot-1554]
        at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:458) [craftbukkit.jar:git-Spigot-1554]
        at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Spigot-1554]
    Caused by: java.lang.Error: Unresolved compilation problem:
        Syntax error on token "}", { expected after this token
    
        at com.nico.ragequit.Ragequit.<init>(Ragequit.java:21) ~[?:?]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_31]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_31]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_31]
        at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_31]
        at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_31]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:73) ~[craftbukkit.jar:git-Spigot-1554]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[craftbukkit.jar:git-Spigot-1554]
        ... 6 more
    [19:32:38] [Server thread/INFO]: [FeatherBoard] Loading FeatherBoard v1.14.0
    [19:32:38] [Server thread/INFO]: [HelpMe] Loading HelpMe v1.0
    [19:32:38] [Server thread/INFO]: **** Beginning UUID conversion, this may take A LONG time ****
    [19:32:38] [Server thread/INFO]: Preparing level "world"
    [19:32:38] [Server thread/INFO]: -------- World Settings For [world] --------
    [19:32:38] [Server thread/INFO]: View Distance: 10
    [19:32:38] [Server thread/INFO]: Chunks to Grow per Tick: 650
    [19:32:38] [Server thread/INFO]: Clear tick list: false
    [19:32:38] [Server thread/INFO]: Experience Merge Radius: 3.0
    [19:32:38] [Server thread/INFO]: Item Despawn Rate: 6000
    [19:32:38] [Server thread/INFO]: Item Merge Radius: 2.5
    [19:32:38] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [19:32:38] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [19:32:38] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [19:32:38] [Server thread/INFO]: Alternative Hopper Ticking: false
    [19:32:38] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 8 Hopper Amount: 1
    [19:32:38] [Server thread/INFO]: Anti X-Ray: true
    [19:32:38] [Server thread/INFO]:     Engine Mode: 1
    [19:32:38] [Server thread/INFO]:     Hidden Blocks: [14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
    [19:32:38] [Server thread/INFO]:     Replace Blocks: [1, 5]
    [19:32:38] [Server thread/INFO]: Mob Spawn Range: 4
    [19:32:38] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [19:32:38] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [19:32:38] [Server thread/INFO]: Cane Growth Modifier: 100%
    [19:32:38] [Server thread/INFO]: Melon Growth Modifier: 100%
    [19:32:38] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [19:32:38] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [19:32:38] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [19:32:38] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [19:32:38] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [19:32:38] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [19:32:38] [Server thread/INFO]: Random Lighting Updates: false
    [19:32:38] [Server thread/INFO]: Structure Info Saving: true
    [19:32:38] [Server thread/INFO]: Sending up to 5 chunks per packet
    [19:32:38] [Server thread/INFO]: Max Entity Collisions: 8
    [19:32:38] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617
    [19:32:39] [Server thread/INFO]: -------- World Settings For [world_nether] --------
    [19:32:39] [Server thread/INFO]: View Distance: 10
    [19:32:39] [Server thread/INFO]: Chunks to Grow per Tick: 650
    [19:32:39] [Server thread/INFO]: Clear tick list: false
    [19:32:39] [Server thread/INFO]: Experience Merge Radius: 3.0
    [19:32:39] [Server thread/INFO]: Item Despawn Rate: 6000
    [19:32:39] [Server thread/INFO]: Item Merge Radius: 2.5
    [19:32:39] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [19:32:39] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [19:32:39] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [19:32:39] [Server thread/INFO]: Alternative Hopper Ticking: false
    [19:32:39] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 8 Hopper Amount: 1
    [19:32:39] [Server thread/INFO]: Anti X-Ray: true
    [19:32:39] [Server thread/INFO]:     Engine Mode: 1
    [19:32:39] [Server thread/INFO]:     Hidden Blocks: [14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
    [19:32:39] [Server thread/INFO]:     Replace Blocks: [1, 5]
    [19:32:39] [Server thread/INFO]: Mob Spawn Range: 4
    [19:32:39] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [19:32:39] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [19:32:39] [Server thread/INFO]: Cane Growth Modifier: 100%
    [19:32:39] [Server thread/INFO]: Melon Growth Modifier: 100%
    [19:32:39] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [19:32:39] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [19:32:39] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [19:32:39] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [19:32:39] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [19:32:39] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [19:32:39] [Server thread/INFO]: Random Lighting Updates: false
    [19:32:39] [Server thread/INFO]: Structure Info Saving: true
    [19:32:39] [Server thread/INFO]: Sending up to 5 chunks per packet
    [19:32:39] [Server thread/INFO]: Max Entity Collisions: 8
    [19:32:39] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617
    [19:32:39] [Server thread/INFO]: -------- World Settings For [world_the_end] --------
    [19:32:39] [Server thread/INFO]: View Distance: 10
    [19:32:39] [Server thread/INFO]: Chunks to Grow per Tick: 650
    [19:32:39] [Server thread/INFO]: Clear tick list: false
    [19:32:39] [Server thread/INFO]: Experience Merge Radius: 3.0
    [19:32:39] [Server thread/INFO]: Item Despawn Rate: 6000
    [19:32:39] [Server thread/INFO]: Item Merge Radius: 2.5
    [19:32:39] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [19:32:39] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [19:32:39] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [19:32:39] [Server thread/INFO]: Alternative Hopper Ticking: false
    [19:32:39] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 8 Hopper Amount: 1
    [19:32:39] [Server thread/INFO]: Anti X-Ray: true
    [19:32:39] [Server thread/INFO]:     Engine Mode: 1
    [19:32:39] [Server thread/INFO]:     Hidden Blocks: [14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
    [19:32:39] [Server thread/INFO]:     Replace Blocks: [1, 5]
    [19:32:39] [Server thread/INFO]: Mob Spawn Range: 4
    [19:32:39] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [19:32:39] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [19:32:39] [Server thread/INFO]: Cane Growth Modifier: 100%
    [19:32:39] [Server thread/INFO]: Melon Growth Modifier: 100%
    [19:32:39] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [19:32:39] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [19:32:39] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [19:32:39] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [19:32:39] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [19:32:39] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [19:32:39] [Server thread/INFO]: Random Lighting Updates: false
    [19:32:39] [Server thread/INFO]: Structure Info Saving: true
    [19:32:39] [Server thread/INFO]: Sending up to 5 chunks per packet
    [19:32:39] [Server thread/INFO]: Max Entity Collisions: 8
    [19:32:39] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617
    [19:32:39] [Server thread/INFO]: Preparing start region for level 0 (Seed: 0)
    [19:32:40] [Server thread/INFO]: Preparing spawn area: 44%
    [19:32:41] [Server thread/INFO]: Preparing spawn area: 57%
    [19:32:42] [Server thread/INFO]: Preparing spawn area: 80%
    [19:32:43] [Server thread/INFO]: Preparing spawn area: 94%
    [19:32:43] [Server thread/INFO]: Preparing start region for level 1 (Seed: 6713677136878292608)
    [19:32:44] [Server thread/INFO]: Preparing spawn area: 31%
    [19:32:45] [Server thread/INFO]: Preparing spawn area: 42%
    [19:32:46] [Server thread/INFO]: Preparing spawn area: 48%
    [19:32:47] [Server thread/INFO]: Preparing spawn area: 51%
    [19:32:48] [Server thread/INFO]: Preparing spawn area: 53%
    [19:32:49] [Server thread/INFO]: Preparing spawn area: 61%
    [19:32:50] [Server thread/INFO]: Preparing spawn area: 63%
    [19:32:51] [Server thread/INFO]: Preparing spawn area: 70%
    [19:32:52] [Server thread/INFO]: Preparing spawn area: 75%
    [19:32:53] [Server thread/INFO]: Preparing spawn area: 81%
    [19:32:54] [Server thread/INFO]: Preparing spawn area: 86%
    [19:32:55] [Server thread/INFO]: Preparing spawn area: 94%
    [19:32:57] [Server thread/INFO]: Preparing spawn area: 97%
    [19:32:57] [Server thread/INFO]: Preparing start region for level 2 (Seed: 0)
    [19:32:58] [Server thread/INFO]: Preparing spawn area: 6%
    [19:32:59] [Server thread/INFO]: Preparing spawn area: 12%
    [19:33:00] [Server thread/INFO]: Preparing spawn area: 50%
    [19:33:27] [Server thread/INFO]: [HelpMe] Enabling HelpMe v1.0
    [19:33:27] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [19:33:27] [Server thread/INFO]: Done (48.803s)! For help, type "help" or "?"
    
    I see the error but don't know what it means... I also have no errors in my Eclipse.
     
  12. Offline

    SuperOriginal

    There's the answer.
     
    Konato_K likes this.
  13. Offline

    2008Choco

    Basically, what he's trying to say is you used tab in your plugin.yml. NEVER use the tab key in your plugin.yml. Use spaces instead
     
  14. Offline

    Just_Niico

  15. Offline

    Defman21

    Show us your plugin.yml (use upload a file)
     
Thread Status:
Not open for further replies.

Share This Page