How to get the world name when the player is in?

Discussion in 'Spigot Plugin Development' started by CluelessCat, Jun 3, 2018.

  1. I'm having some trouble with bukkit and I need some help finding the world name.
     
    • Like Like x 1
  2. Choco

    Moderator

    If you have an instance of Player, it has a method, #getWorld(). From there, World has a #getName() method. This is some very, very basic Java and you should have either looked around on Google (literally the exact same question) or even the Javadocs which would have provided you an answer fairly quickly
     
    • Agree Agree x 1
  3. Code (Java):
    player.getWorld()
     
  4. I'm just not sure where to put it. How do I execute it?
     
  5. Choco

    Moderator

    Again, very basic Java. You're expected to know how to program in Java before delving into the Bukkit API. We're not here to show you how code should be written. You should be capable enough of doing so on your own after being shown what methods are required. See Oracle's official Java tutorial and read through until you have a basic understanding of the language
     
    • Agree Agree x 1
  6. To get the World name a player is in:

    player.getWorld().getName();