Help me With Plugin

Discussion in 'Plugin Development' started by Beans54321, May 3, 2016.

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

    Beans54321

    Hello I am making a plugin that says welcome to the newest player who joined the server. the command is /wnp
    every thing works but I don't know if its saying it globaly and its saying my player name please help me.
    Again thanks,
    Beans54321
     
    Last edited: May 3, 2016
  2. Offline

    pingpong1999

    Bukkit.getServer().broadcastMessage(Message);
     
  3. Offline

    Lordloss

    @pingpong1999 That is not what he asked for, please read the thread first...

    @Beans54321 to say that, show us your code.
     
  4. Offline

    pingpong1999

    You think I didnt read the text in the first place? ofc I read it, that is what i got out of it. I'm sorry if I read it wrong but you can't just make the assumption that I didn't read it
     
  5. Offline

    Lordloss

    @pingpong1999
    How could you get this wrong? At least you read it not properly..
     
  6. Offline

    Beans54321

    No how do I make it so that when a new player joins all of the outher players can do /wnp and then it will say welcome to the new player @pingpong1999 and @Lordloss
     
  7. Offline

    Caedus

    You need to store the player in a HashMap, and update the HashMap everytime a new player joins. Then upon executing the command "/wnp", find the most recently joined player through the HashMap and use that as a means of sending them a direct message, or including their name in a broadcast, whichever you want to do.

    If you want to do this such that only new players who have never joined can have this welcome, then you'd need a way of tracking old users to recognize when a new user has joined, a config storing player UUIDs is probably your best shout.
     
  8. Offline

    pingpong1999

    ah, okay. I recommend doing what Caedus said. I did not understand your post. It was very unclear.
     
  9. Offline

    I Al Istannen

    @Caedus @Beans54321

    To Caedus last point:

    To check if a player has played before you can use OfflinePlayer#hasPlayedBefore(). To get the first time they played, you should be able to use OfflinePlayer#getFirstPlayed(). There is also OfflinePlayer#getLastPlayed() but i don't know when that gets updated and if it is of any use for you. Just for the sake of completion :D

    If the hasPlayedBefore() already returns true in the onLogin, you can check if getFirstPlayed() is nearly equal to the System time and if so he is new.
     
  10. Offline

    Firestar311

    There are methods within the Player object. So if you have a player variable, player.hasPlayedBefore() etc...
     
  11. Offline

    Beans54321

    So if I do that I shuld be good?
     
  12. Offline

    Caedus

Thread Status:
Not open for further replies.

Share This Page