Right World?

Discussion in 'Plugin Development' started by XKnucklesX, Jul 14, 2013.

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

    XKnucklesX

    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
     
  2. IM NOT SURE IF THIS WILL WORK .... but atleast give it a shot
    Code:java
    1. if(cmd.getName().equalsIgnoreCase("CheckIfWorldIsRight")){
    2. Player player = (Player)sender;
    3. Location loc = player.getLocation();
    4. World pworld = loc.getWorld();
    5. String Worldname = pworld.getName();
    6. if(Worldname == "YourWorldsNameHere"){
    7.  
    8. }
    9. else{
    10.  
    11. }
    12. }
     
  3. Offline

    XKnucklesX

    Its not meant to be a command.

    The plugin is meant to check if its right before issuing call the code.
     

  4. 'well you should have specified that before.
     
  5. Offline

    Woobie

    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
    
     
    xTrollxDudex likes this.
  6. Offline

    XKnucklesX

    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.
     
    Last edited by a moderator: Jun 3, 2016
  7. Offline

    Henzz

    XKnucklesX
    ?
    PHP:
    @EventHandler
    public void onWorldChange(PlayerChangedWorldEvent event) {
        final 
    Player player event.getPlayer();
        
    World world Bukkit.getWorld(getConfig().getString("path.to.world"));
           
        if (
    player.getWorld().equals(world)) {
            
    // code
        
    }
           
    }
     
  8. Offline

    XKnucklesX

    bump

    I need help.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
Thread Status:
Not open for further replies.

Share This Page