Solved Home plugin, config help.

Discussion in 'Plugin Development' started by Axanite, Aug 27, 2013.

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

    Axanite

    So, I am developing a simple home plugin just for fun (I might do something with it in the future) right now and I have the part where you set your home and it stores your location at which you ran the /sethome command in a config.yml file but its came to the part where if they don't have a home set, I want it to make them stay where they are and not get teleported anywhere and have a message saying they don't have a home set so they know why they are not getting teleported. However, when I do this, it just teleports me into the void and doesn't give me the message I want which I set.

    I think this is because I am not grabbing the name of the player from the config correctly thus why it is not working properly. Any help will be greatly appreciated. :)

    Code:java
    1. if(cmd.getName().equalsIgnoreCase("home")) {
    2. Player player = (Player) sender;
    3. int x = getConfig().getInt(player.getName() + ".x");
    4. int y = getConfig().getInt(player.getName() + ".y");
    5. int z = getConfig().getInt(player.getName() + ".z");
    6. player.teleport(new Location(player.getWorld(), x, y, z));
    7. } else {
    8. Player player = (Player) sender;
    9. if (this.getConfig().getPath(player.getName() == null)) {
    10. sender.sendMessage(ChatColor.DARK_PURPLE + "There is no home set for your player in this world.");
    11. return true;
    12. }


    Anyone help? I am pretty stuck right now.

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

    etaxi341

    rf2minecraft Do only bump if the last post is 24 Hours ago!

    rf2minecraft Try this:
    Code:java
    1. if(cmd.getName().equalsIgnoreCase("home")) {
    2. if (sender instanceof Player){
    3. Player player = (Player) sender;
    4. if (this.getConfig().getPath(player.getName() != null)) {
    5. int x = getConfig().getInt(player.getName() + ".x");
    6. int y = getConfig().getInt(player.getName() + ".y");
    7. int z = getConfig().getInt(player.getName() + ".z");
    8. player.teleport(new Location(player.getWorld(), x, y, z));
    9. } else {
    10. sender.sendMessage(ChatColor.DARK_PURPLE + "There is no home set for your player in this world.");
    11. return true;
    12. }
    13. }
    14. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
    Axanite likes this.
  3. Offline

    Axanite

    Okay. Sorry. :)


    Nope. Gives me error "The method getPath(boolean) is undefined for the type FileConfiguration" and it says its on Line 34...

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

    etaxi341

    rf2minecraft Sry my fault. Change it to this:
    Code:java
    1. if(cmd.getName().equalsIgnoreCase("home")) {
    2. if (sender instanceof Player){
    3. Player player = (Player) sender;
    4. if (this.getConfig().getPath(player.getName()) != null) {
    5. int x = getConfig().getInt(player.getName() + ".x");
    6. int y = getConfig().getInt(player.getName() + ".y");
    7. int z = getConfig().getInt(player.getName() + ".z");
    8. player.teleport(new Location(player.getWorld(), x, y, z));
    9. } else {
    10. sender.sendMessage(ChatColor.DARK_PURPLE + "There is no home set for your player in this world.");
    11. return true;
    12. }
    13. }
    14. }
     
  5. Offline

    Axanite


    The method getPath(String) is undefined for the type FileConfiguration.
    Line 34 still... ;/ No clue as to why this is doing this. ;/
     
  6. Offline

    etaxi341

  7. Offline

    Axanite

    After doing this change, Eclipse is giving me no errors. I am going to test the plugin on my local server now. :)

    EDIT: It worked, thanks. :)
     
Thread Status:
Not open for further replies.

Share This Page