[ABANDONED] Getting Multiple Commands

Discussion in 'Spigot Plugin Development' started by dyenxunit, Jun 9, 2015.

  1. What im trying to do is get multiple commands from a config.yml but the way that i have it currently setup it requires me to do it 1 by 1 but i want it to get it from a List.

    Example of what i want to do:
    Code (Text):
    Commands:
    - say hello
    - who
    - list
    Heres my current code setup
    Code (Text):
            if(!getConfig().getString("Command1").equals("")){
                Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "" + getConfig().getString("Command1"));
            }
    Here is how my config is setup currently:
    Code (Text):
    Command1:say hi
     
     
  2. You get the list of strings rather than the single string saved at the key "commands".

    Configuration#getStringList (key)

    And iterate through it doing as you please :)
     
  3. How do i use it i added it to my code and its giving me an error

    Code (Text):
    [13:56:26 ERROR]: [SimpleJoinEvents] Cannot load configuration from jar
    org.bukkit.configuration.InvalidConfigurationException: while scanning a quoted scalar
    in 'string', line 12, column 5:
            'Say Hi"
            ^
    found unexpected end of stream
    in 'string', line 13, column 1:
       
        ^

        at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:57) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.bukkit.plugin.java.JavaPlugin.reloadConfig(JavaPlugin.java:214) [spigot.jar:git-Spigot-044d928-e8c6403]
        at org.bukkit.plugin.java.JavaPlugin.getConfig(JavaPlugin.java:162) [spigot.jar:git-Spigot-044d928-e8c6403]
        at me.dyenxunit.SJE.Main.Main.onEnable(Main.java:19) [SJE.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) [spigot.jar:git-Spigot-044d928-e8c6403]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot.jar:git-Spigot-044d928-e8c6403]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-044d928-e8c6403]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:356) [spigot.jar:git-Spigot-044d928-e8c6403]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:316) [spigot.jar:git-Spigot-044d928-e8c6403]
        at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:418) [spigot.jar:git-Spigot-044d928-e8c6403]
        at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:382) [spigot.jar:git-Spigot-044d928-e8c6403]
        at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:337) [spigot.jar:git-Spigot-044d928-e8c6403]
        at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:256) [spigot.jar:git-Spigot-044d928-e8c6403]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:528) [spigot.jar:git-Spigot-044d928-e8c6403]
        at java.lang.Thread.run(Thread.java:745) [?:1.7.0_65]
    Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning a quoted scalar
    in 'string', line 12, column 5:
            'Say Hi"
            ^
    found unexpected end of stream
    in 'string', line 13, column 1:
       
        ^

        at org.yaml.snakeyaml.scanner.ScannerImpl.scanFlowScalarSpaces(ScannerImpl.java:1929) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.scanner.ScannerImpl.scanFlowScalar(ScannerImpl.java:1845) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchFlowScalar(ScannerImpl.java:1029) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchSingle(ScannerImpl.java:1004) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:392) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:226) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(ParserImpl.java:586) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:143) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:132) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:229) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:155) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:122) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:105) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:120) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:450) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.yaml.snakeyaml.Yaml.load(Yaml.java:369) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:55) ~[spigot.jar:git-Spigot-044d928-e8c6403]
        ... 14 more
     

    Code (Text):
        if(!getConfig().getString("Commands").equals("")){
                Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "" + getConfig().getStringList("Commands"));
            }

    Code (Text):
    Commands:
        -List
        -Who
     
     
  4. Use this: http://yaml-online-parser.appspot.com
     
  5. Ok i checked it and its working fine but it doesnt run the 2 commands when i join. This is what it says
    when i join " Unknown command. Type "/help" for help. "
     
  6. What? Im having the server run the command when a player joins
     
  7. You should learn about collections, more specifically lists. It is clear you dont have an understanding of them. After a few tutorials come back and reread my first post. It should become a lot clearer.
     
  8. First i came here for help because i dont have much time to look some of these things up and second of all im a newbie dev that is trying to learn as i go
     
    • Optimistic Optimistic x 1
  9. If you don't have time to look things up, I don't think you have enough time to try to make plugins.

    You want help, then let us help you. We will NOT spoon feed you everything, you need to be willing to learn this.

    I think that if you don't have time to look things up, then we don't have time to help you.
     
    • Agree Agree x 2
  10. Already have that setup all i need to do is find a way for the console to register the commands and run multiple of them
     
  11. I give up on this i will re vist this at a later time when people are not being rude and not providing help but ty all that have tried helping :).
     
  12. Im just not feeling like deving anymore since that guy was being awfully rude towards a new dev that is trying to become a better coder :(. I will maybe come back to this if i have time in the future :).
     
  13. Okay, if I understand what you're trying to do this code will do it.
    [​IMG]
     
  14. Thank you. I will try my best to look further more into the java lan :)