Solved Letting players add their own lists to config, and then getting them

Discussion in 'Plugin Development' started by jetp250, Apr 5, 2016.

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

    jetp250

    Ew, I'm back, I've learned a lot since I last asked for help. This time, it feels like it'll be a bit more complicated, been googling around for ages and been trying myself, too.

    So, in (for example) MythicMobs, you can add your own mobs by typing its name, health, etc. etc. and then the plugin lists it to ingame.
    Example of what I mean:
    Code:
    Mobs:
        ExampleMob:
           Type: SKELETON
           Health: 35
           Damage: 5
           Disguise:
               Type: PIG
    That 'ExampleMob' is added by the player, not the plugin, and, eh, there must be a way to list it instead of putting an if statement for every single word in the world. If I got the name (ExampleMob) I could get the list on it, but I can't find out a way to get the custom string in config.


    I tried with
    Code:
    if (config.getString("somepath").startsWith("   "))
    But It doesn't seem to be working, or I do something wrong.
     
    Last edited: Apr 5, 2016
  2. Offline

    timtower Administrator Administrator Moderator

    @jetp250 configurationsection.getKeys(false)
     
    jetp250 likes this.
  3. Offline

    A5H73Y

    I know this doesn't provide anything productive to what you're asking. But I believe you should learn more fundamental Java before tackling Bukkit. This is something you learn almost immediately in Java and it seems like you'll just get stuck on the next thing if we help you solve this.
     
  4. Offline

    jetp250

    Meh, you may be right. I can solve most problems myself, but It seems there's some java basics I don't know about. And, I thought the config would be completely a bukkit thing, so I didn't think it'd help at all, but.. yeah.

    @timtower thanks for accepting the thread, and I'll try that out, though, I'm not sure how that'd get the strings. I'll be trying, and if I can't get it right, I'll try learn some java instead of posting here, as @A5H73Y stated.
     
  5. Offline

    A5H73Y

    It makes development much easier once you learn the fundamentals of Java, I've been on the scene since 2012 and I can safely say it's makes a significant difference when you actually understand what you are doing.

    I can help you in your problem above if you explain it a bit better, not entirely sure what you want to achieve? You want to save a String list to a yml file and retrieve it?
     
  6. Offline

    jetp250

    Well, what you explained was more than enough of help, I got it working :) Marking as solved, thanks everyone for help.
    Solution:
    Calling the method from main class:
    Code:
    if (args[0].equalsIgnoreCase("give")) {
                        <Class>.giveWand(player, args[1]);
                        return true;
                    }
    The method in the other class:
    Code:
    public static void giveWand(Player p, String args){
            Set<String> wands = config.getKeys(false);
            if (wands.contains(args)) {
            //do stuff
            }
    Thank you both very much, I'll try to not ask help anymore.
     
Thread Status:
Not open for further replies.

Share This Page