Solved get the world from the sender

Discussion in 'Plugin Development' started by UnknownDeveloper, Aug 30, 2015.

Thread Status:
Not open for further replies.
  1. So i am coding a Report Plugin for my Server

    my question is how to get the world from the command sender for the staff broadcast because i want it like that

    p.sendMessage("prefix + §7New Report!");
    p.sendMessage("§cTarget:" + t.getName);
    p.sendMessage("§cAuthor:" + p.getName);
    p.sendMessage("§cWorld:" + world.get(p));

    so basicly how to get the world from the Sender i cant take a look now into Eclipse because im bot on my Main Computer

    Call me Stupid or whatever its just a question
     
  2. Offline

    CrystallFTW

    @UnknownDeveloper cast the sender to a player and after that just do
    Code:
    player.getWorld()
    but i'm guessing that you want to get the world's name. Just do
    Code:
    player.getWorld().getName()
     
  3. Offline

    caderape

    Player player = (Player) sender;
    this is how to cast.
     
  4. Offline

    CrystallFTW

    @caderape you have to check first if the sender is instance of player.
     
  5. Offline

    xMrPoi

    First, check if the sender is an instance of a Player. Next, create a new player object by casting the sender to a Player. From there, you can use all the Player methods.
     
Thread Status:
Not open for further replies.

Share This Page