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; } }
double x = plugin.getConfig().getDouble ("Hub.X"); Do the same for y and z and make a new location using those values
maybe just save a whole Vector or Location in the config :/ seems to be easier to read that from a config
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
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
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
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.
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?
@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.