config.yml

Discussion in 'Plugin Development' started by Blares, Oct 19, 2017.

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

    Blares

    Hi so I'm making a hub plugin. And I want the player to be able to set locations for /hub and etc.

    how do I reference the x y z they entered in config.yml to my IntelliJ
    by the way I'm making it in a different class not in the main class so... Help me out
    Thanks - Blares
    Code:
    config.yml:
    
    Hub:
    X: 0
    Y: 0
    Z: 0
    
    Hub class:
    @SuppressWarnings("unused")
    public class Hub implements CommandExecutor {
    
    public boolean onCommand(CommandSender sender, Command cmd, String Label, String[] args) {
    
    if (cmd.getName().equalsIgnoreCase("hub")) {
    
    Player player = (Player) sender; 
    
    //how to tp them to the coords they set in config.yml
    
    }
    
    return false;
        }
    
    }
     
  2. double x = plugin.getConfig().getDouble ("Hub.X");
    Do the same for y and z and make a new location using those values
     
  3. Offline

    MightyOne

    maybe just save a whole Vector or Location in the config :/ seems to be easier to read that from a config
     
  4. Offline

    Blares

    how
     
  5. Location test = new Location(world, x, y, z);
     
  6. Offline

    Blares

    I'm getting so many errors can u format it I get what you're saying but it's just fucking up. I'm not in my main class so the getConfig() is error

    Somehow I fixed it by adding || Plugin plugin = Core.getPlugin || Main class:

    public static Plugin getPlugin() {


    return null;

    Code:
    
    Plugin plugin = Core.getPlugin();
    
    Location test = new Location( double x = plugin.getConfig().getDouble ("Hub.X"));
    
    Could you help me out what's wrong? Also when I did world it said expression expected I'm rlly confused
    Ok, so I've been on this for 3 days. I don't get it. I was having errors for getConfig() since I'm in a different class. But I fixed it by doing

    Code:
    Main:
    public static Plugin getPlugin() {
    
    
    return null;
    
    HubClass:
    
    Plugin plugin = Core.getPlugin();
    
    
    
    Can someone help me I want people to be able to set coords in the config file. SO when they do /hub they teleport to them coords.

    Code:
    
    config: 
    
    Hub:
    X: 0
    Y: 0
    Z: 0
    
    
    I really don't get this I need some exact instructions this is driving me crazy. Make a new location that get's the coords in config. SO I can just do p.teleport(hub) PLEASE URGENT AF
     
    Last edited by a moderator: Oct 23, 2017
  7. getConfig ().getDouble("Hub.X");
    What this does is gets the value of x in your config. Do the same for y and z. Use this in creating a new location. Then do p.teleport (Location);
    If you dont understand this idk what else to tell you :/
    Theres many tutorials on how to use the config and locations etc.

    You declare the variable out side

    double x = plugin.getConfig().getDouble("Hub.X");
    Do the same for Y and Z. Otherwise you cannot make a location. Then do
    Location hub = new Location (world,x,y,z);
    If you dont understand then learn more. We're not just going to write this for you. This is not how it works
     
    Last edited by a moderator: Oct 23, 2017
  8. Offline

    Blares

    dude can you just give me the code as in like
    Code:
     how the fuck to do it . Im stressing over this and I know what you're saying im just asking can u do the location for me so I know how to do it I understand what ur saying tho
     
  9. No... we're not going to write the code for you. Anyone here will tell you the same thing. You have to learn. If you do not understand then you need to learn more about bukkit instead of coming here on the forums expecting people to write it for you. Also dont be rude im trying to help

    You know how to get a world variable right? You know how to make doubles just like the way i showed you right? Then you know how to make a location.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  10. Offline

    Blares

    Code:
    
    double x = plugin.getConfig().getDouble("Hub.X");
    double y = plugin.getConfig().getDouble("Hub.Y");
    double z = plugin.getConfig().getDouble("Hub.Z");
    
    Location location = new Location(w, x, y, z)
    
    w comes up with an error what variable do I make for world?
     
  11. Offline

    mine2012craft

    @Blares You need to define the name of the world in the configuration. Then you can use
    Code:
    Bukkit.getWorld(string);
    to get the world.
     
  12. Online

    timtower Administrator Administrator Moderator

    Merged 2 threads about the same thing.
     
Thread Status:
Not open for further replies.

Share This Page