List all instances of a certain Class

Discussion in 'Plugin Development' started by Datdenkikniet, Oct 26, 2013.

Thread Status:
Not open for further replies.
  1. So, I have my own class:
    Show Spoiler
    Code:java
    1. public class Test{
    2. public String name;
    3. public Version version;
    4. public Test(Version v, String name){
    5. this.version = v;
    6. this.name = name;
    7. }
    8. public Version getVersion(){
    9. return this.version;
    10. }
    11. public void setVersion(Version version){
    12. this.version = version;
    13. }
    14. public String getName(){
    15. return this.name;
    16. }
    17. public void ChangeVersion(){
    18. if (this.getVersion() == Version.OLD){
    19. this.setVersion(Version.NEW);
    20. } else {
    21. this.setVersion(Version.OLD);
    22. }
    23. }
    24. public int getAll(){
    25. return 14;
    26. }
    27. }
    28. private enum Version{
    29. NEW,
    30. OLD
    31. }

    and I wonderd how bukkit used .getOnlinePlayers(), and if I am able to use something like that too (for instance Test.getAll())
    thanks in advance
    Jona
     
  2. Offline

    1Rogue

    No, there isn't anything like that within java. The only way to do something along those lines would to keep track with the debugging api, and event then that would be messy.

    Bukkit doesn't do something like this for .getOnlinePlayers(), they're most likely stored in a Map or Set.
     

  3. okay, thank you! Any suggestions on how to do that?
     
Thread Status:
Not open for further replies.

Share This Page