How to get a player name out of a config

Discussion in 'Plugin Development' started by Creeoer, Aug 29, 2014.

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


    I'm using bukkit version 1.2.5 since this is a tekkit plugin:

    So bascially what I did was when a player bought a factory I put his name in the config under the factory like so:
                            player.sendMessage(ChatColor.DARK_AQUA + "[EMP-FACTORY]" + ChatColor.GREEN + " Congratulations, you've purchased your reinstone factory");
                            //Adds player's name below the factory name so it can be referenced later once the player tries to place it
                            EMPFactories.getInstance().getConfig().set("Factories.ReinforcedStone", name);
    All I'm trying to do now is to check if the player's name is in the config giving them permission to paste the factory:
    //Obviousy this if statement won't work but just to give you an idea:
    if(args[1].equalsIgnoreCase("reinstone") && EMPFactories.getInstance().getConfig().getString("Factories.ReinforcedStone", name)))){
    Help would be appreicated!
  2. Offline


    You should be using UUIDs... but for obvious reasons you can't, since you're using a vastly outdated version.

    I don't think Tekkit is supported here. Correct me if I'm wrong.
  3. Offline


    TheHandfish Tekkit is just a modpack, I'm still using bukkit to code it
  4. Offline


    Creeoer no you are not. You are coding for an unofficial build. Seek support where you got your mod.
  5. Offline


    Necrodoom, more evidence that you're always being negative for no good reason. He's using Bukkit to code it, so we help.

    I believe you would use this:
    String name = (String)EMPFactories.getInstance().getConfig().get(Factories.ReinforcedStone");
    I may have the casting wrong, I'm doing this on my phone.
  6. Offline


  7. Offline


    Necrodoom More than likely you are right, actually it's probally definite but I figured this was still bukkit so :/ The technic pack forums doesn't really have a section for plugin developement either, since it is indeed bukkit. Obviously if this was a problem from let's say, spigot. I would go to the spigot forums since it is indeed it's own mod.
  8. Offline


    Creeoer forge platform is not bukkit. The mod you are running is just another unofficial build, and does not belong here.
  9. Offline


    Necrodoom EDIT: I'll drop it, you've been on this site since 2011 so you obviosuly are very dedicated and know what you are talking about, if you're kind enough to redirect me somewhere else that'll be nice.

    I went on the forge forums and it doesn't offer any plugin support. Forge is a modding api, obviously you know that. I can't ask for support anywhere else because it doesn't offer any. There isn't a forum I can go to besides bukkit, forge forums only offers support for mod developement.
    Quoted from the site:
    Tekkit uses Bukkit

    That’s right, the self-contained Tekkit server is Bukkit at its core, allowing you the entire Bukkit plugin catalog to be run with Tekkit. Many thanks to the minds over at MC Port Central for their devotion in porting vanilla SMP mods to the Bukkit platform.

    If you are friendly enough to direct me to where am I supposed to find help for this

    [edit by JaguarJo: removed link to unofficial builds.]
  10. Offline


    Creeoer MC Port Central's forums would be the proper place, as I would assume you are either running MCPC+ or Cauldron.
    Also, that quote from the site is partially incorrect. Tekkit does not use Bukkit, Tekkit uses MCPC+/Cauldron, which is a unofficial build of Bukkit
  11. Offline


    Ignoring the fact that your using MCPC+ or whatever (since its completely irrelevant) I would store the data for each player in their own config incase they "purchase multiple factories" if I understand this correctly.

    So when they join (or when they buy a factory) you would check if their playerfile exists and if not, create a new one.

    1. @EventHandler
    2. public void playerJoinEvent(PlayerJoinEvent e){
    3. String playername = e.getPlayer().getName().toString();
    4. //insert line of code to create a playerfile with a string playername parameter here
    5. }

    which would then create a playerfile for each person upon joining (the proper place for these files would be something sililar to ./plugins/<datafolder>/userdata/
    but that is not necessary

    then to access the config lets say they bought a cobblestone factory and it is named cobble in the configs. So the contents of Dazedndconfused.yml looks like:
    cobble: 2
    So since we will be using it as a check, ill make it a bool.
    2. public boolean checkCobble(string playername){
    3. FileConfiguration config = null;
    4. File playerconfig = new File("." + File.separator + "plugins" + File.separator + "<insertDataFolderNameHere>" + File.separator + "users" + File.separator + playername + ".yml");
    5. config = YamlConfiguration.loadConfiguration(playerconfig);
    6. int amount = 0;
    7. if(config.getInt("cobble") > 0){
    8. amount = config.getInt("cobble");
    9. }
    10. config = null;
    11. if(amount > 0){
    12. return true;
    13. } else {
    14. return false;
    15. }
    16. }

    That should help steer you in the right direction. If you need anymore help feel free to pm me as people will refuse to help you make a bukkit plugin if you mention MCPC. I feel this is due to a lack of knowledge and fear of the unknown

    For anyone who may know the answer to this, but what does getConfig().getInt
  12. Offline


    getConfig().getInt() retrieves an integer from the path specified in getInt's parameters. Is that what you mean?
  13. Offline


    Locked. These forums are for CraftBukkit support only. Using other server software can have unexpected effects on Bukkit plugins. It is not our responsibility to provide support for these other platforms, nor should we be required to pick up the slack when other server software does not adequately support its users.
    Jaaakee224 likes this.
Thread Status:
Not open for further replies.

Share This Page