Hey there, I wanted to know how I could make a section in the config, where the "world" selected by the user would be the only place in which the plugin would function. I currently have the following, however it does not work: Code:java if(p.getWorld() == JavaPlugin.getPlugin(Main.class).getConfig().get("World")) Config.yml PHP: World: world I have no errors otherwise.
I usually do this by putting permissions on the plugin, and then use PermissionsEX to manage which world allows that specific permission. In your case though, doesn't p.getWorld() return a World class, where getConfig().get("World") returns a String (I'm guessing the name of the world)? Would this work: if(p.getWorld().getName().equalsIgnoreCase(getConfig.get("World")))
Shaggy67 That is what i tried Shaggy67 Do you mean this? Code:java if(p.getWorld().getName().equalsIgnoreCase(JavaPlugin.getPlugin(Main.class).getConfig().get("World").toString())) EDIT by Moderator: merged posts, please use the edit button instead of double posting.
ProMCKingz I'm pretty sure this has already been answered, but you just go into the config and get the world name, check if it's the same as the players' world, and continue.
Googlelover1234 Thanks, but we know that, Its jsut the method you use to implement that into the code.
ProMCKingz I would try to see if the World that the player is in is equal to the World on the server that is in the config: Code: // EXAMPLE CODE! DO NOT COPY AND PASTE DIRECTLY if (p.getWorld().equals(plugin.getServer.getWorld(plugin.getConfig().getString("World")))) { // Code here } Also, why are you using the JavaPlugin method to get your main Class? Just pass it in to your other Class's constructor.
Gnat008 Sorry, I wasn't very clear on what I meant. I meant "pretty much what he did" as in "pretty much what Gnat008 did". I was talking to the OP, sorry to mislead you.