NOT A COMMAND How to make sure its the right world before trying call the code. This will be called from a config. World: Nether Nether as a example. //something try{ //code } Thanks for your time
IM NOT SURE IF THIS WILL WORK .... but atleast give it a shot Code:java if(cmd.getName().equalsIgnoreCase("CheckIfWorldIsRight")){ Player player = (Player)sender; Location loc = player.getLocation(); World pworld = loc.getWorld(); String Worldname = pworld.getName(); if(Worldname == "YourWorldsNameHere"){ } else{ } }
Its not meant to be a command. The plugin is meant to check if its right before issuing call the code.
XKnucklesX You mean comparing the current world to a world in config? Code: World cur = something.getWorld(); if(cur.getName().equals(getConfig().getString("path.to.world"))) { //stuff } In your config: Code: path: to: world: nether
So when the plugin is starting up it makes sure that everything from the code is from the world selected in the config. 1. Checks config 2. Make sure world is true 3. Try{ //code . . . bump still need help EDIT by Moderator: merged posts, please use the edit button instead of double posting.
XKnucklesX ? PHP: @EventHandlerpublic void onWorldChange(PlayerChangedWorldEvent event) { final Player player = event.getPlayer(); World world = Bukkit.getWorld(getConfig().getString("path.to.world")); if (player.getWorld().equals(world)) { // code } }
bump I need help. EDIT by Moderator: merged posts, please use the edit button instead of double posting.