How to check if player is in a world?

Discussion in 'Plugin Development' started by SinestroWhite, Apr 19, 2015.

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

    SinestroWhite

    Hello,
    can you tell me how to check if player is in a world?
    I will provide my code:
    Code:java
    1.  
    2. public void SetUp() {
    3. Main.HubWorld = Bukkit.getServer().getWorld(plugin.getConfig().getString("HUB.World"));
    4. }
    5.  
    6. @EventHandler
    7. public void onPlayerJoin(PlayerJoinEvent event){
    8. SetUp();
    9. Player player = event.getPlayer();
    10. if (Main.HubWorld.equals(player.getPlayer().getWorld().getName())) {
    11. player.getInventory().clear();
    12. ItemStack Navigation = new ItemStack(Material.WATCH);
    13. ItemMeta m = Navigation.getItemMeta();
    14. m.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&6[&3&lNavigation&6]"));
    15. Navigation.setItemMeta(m);
    16. player.getInventory().setItem(0, Navigation);
    17. }
    18.  
    19. }
    20.  
     
  2. Offline

    nverdier

    @SinestroWhite Player#getWorld()#getName() and check if the name is something.
     
    CodePlaysMinecraft likes this.
  3. Offline

    SinestroWhite

    @nverdier But what about my code ?
     
  4. Offline

    nverdier

    It's screwed up.
     
    CodePlaysMinecraft likes this.
  5. Offline

    dsouzamatt

    @SinestroWhite
    Code:
    player.getPlayer()
    What are you hoping to achieve here?
     
  6. Offline

    SinestroWhite

    @dsouzamatt what are you trying to ask me? I have created this topic in Plugin Developmen so I try to achieve some help.
     
  7. Offline

    BrickBoy55

    CodePlaysMinecraft likes this.
  8. You checked if a World is equal to a String (world name). It will never be true
     
Thread Status:
Not open for further replies.

Share This Page