Player variable

Discussion in 'Plugin Development' started by Whatshiywl, Jul 2, 2012.

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

    Whatshiywl

    Is it possible to create a new variable to a Player entity? For example, player.nickname ? If not, is it possible to attach a variable any other way to a certain player? If yes, how? :S
     
  2. Offline

    chaseoes

    player.getDisplayName?
     
  3. Offline

    Whatshiywl

    @chaseoes no no, i don't want to get the player's name. I want to create/attach a new variable to Player class/entity
    player.nickname isn't even what i'm trying to do, just an example xD
     
  4. Offline

    EnvisionRed

    You can use a hashmap that stores player names and player nicknames, then use PlayerChatEvent coupled with
    Code:
    player.setPlayerListName(nickname);
    player.setDisplayName(nickname);
    
    Don't save the player's actual instance for a hashmap because memory leaks, I'm sure you've heard it all before.
     
  5. Offline

    Whatshiywl

    @EnvisionRed ugh........... does it help if i say that i'm a kind of a noob when it comes to making plugins? :S

    idk what a hashmap is or how to set one... i think i understand the concept but i realy have no idea how to use it D:
    and i also dunno what this memory leak is about but that must be pretty bad :D

    so if u could explain it a little or just link a kind of (good) tutorial page for that it would already be awesome :D

    thanks in advance for your time \o/
     
  6. Offline

    EnvisionRed

  7. Offline

    Milkywayz

    Don't worry you will learn about Collections soon enough, they are very useful for bukkit plugins. One of the downsides of using Collections in bukkit plugins is, when the server reloads or restarts all the data stored in those Collections gets destroyed, so before disable (or every x amount of time) you should save it to a file providing that the data in the Collection is vital and should survive reloads (bans, op status, money, etc). I would suggest learning about arrays, lists, maps, sets, and all the other wonderful Collections in java, although in your case you probably don't need it right now, but I'm sure there will be a time where you will need to store some data somewhere. :D Hope i helped, if not you can always either reply to this or tag me with Milkywayz.
     
  8. Offline

    Whatshiywl

    @EnvisionRed thanks for the awesome tutorial pages! Time to get some study time it seems :p

    Milkywayz thanks for the great advice :D and yeah, looks like saving this data somewhere is a solution i won't be able to scape. But oh well, imma get to it \o/
     
Thread Status:
Not open for further replies.

Share This Page