Username string/variable

Discussion in 'Plugin Development' started by robmart, Aug 22, 2014.

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

    robmart

    so i connot make a string or variable here is my code

    Code:java
    1. @EventHandler
    2. public void playerChat(AsyncPlayerChatEvent playerChatEvent)
    3. {
    4. // does not work int NAME = playerChatEvent.getEventName();
    5. // does not work public static String Username = playerChatEvent.getEventName();
    6. }

    what is the correct code?
     
  2. Offline

    whitebradcam

    You are off by a lot, you are using
    Code:java
    1. int NAME
    which is only for numbers. You don't use
    Code:java
    1. public static
    in this case.
    Code:
    getEventName()
    is only getting playerChat. Which is the name. Here is the right code:
    Code:java
    1. @EventHandler
    2. public void playerChat(PlayerChatEvent playerChatEvent) {
    3. Player username = playerChatEvent.getPlayer().getName();
    4. }
     
  3. Offline

    mythbusterma

    robmart

    First step: Learn Java.
    Second step: Try again.
     
    Zupsub and Monkey_Swag like this.
  4. Offline

    Rocoty

    I find it funny how you were always on the right track, but still got it wrong in the end...
     
  5. Offline

    tommyhoogstra

  6. Offline

    jimbo8

    My heart just broke.
     
  7. Offline

    robmart

    well the code i used someone on the mcforum gave me :|
     
  8. Offline

    whitebradcam

    :b lol did I forget the integer? Or the async?
     
  9. Offline

    stormneo7

    Yes yes, "right code". Defining a string as a player. :mad:
     
  10. Offline

    MasterDoctor

    PEOPLE PLEASE!
    It is:
    Code:java
    1. @EventHandler
    2. public void playerChat(PlayerChatEvent playerChatEvent) {
    3. String username = playerChatEvent.getPlayer().getName();
    4. }


    1) If you are going to whinge like six year olds then at least show the correct code before doing so, also just PM each other.

    2) When you do demonstrate the code - DO IT RIGHT - All you have to do is look over it once or twice before clicking that "Post Reply" button!
     
  11. Offline

    Rocoty

    whitebradcam You assigned a String to a Player variable
     
Thread Status:
Not open for further replies.

Share This Page