Solved How to add all classes to an array

Discussion in 'Spigot Plugin Development' started by dyenxunit, Jun 28, 2016.

Thread Status:
Not open for further replies.
  1. Hi, i was wondering if there is a quick method that will allow me to add all the classes inside of a package to an arraylist ?
  2. This is a bad idea, but you could do:
    Code (Text):
    List<Object> list = new ArrayList<>();
    Edit: Wait, did you mean like Reflection classes?
  3. There is none. You'd have to scan jars.
  4. Like what im trying to do is add all my kit classes which contain the information of the kits to the arraylist so i can do array.get(1) to access the kit class
  5. You should've asked that, then. :p
    All of the kits must extend an abstract 'Kit'
    Code (Text):
    List<Kit> kits = new ArrayList<>();
    kits.add(new WarriorKit());
  6. Just register them manually.
  7. yea but with like 50 + kits wouldnt it be insufficient ?
  8. No, just simply adding them to a list is not inefficient, especially compared to the alternatives which would be really complicated and hacky.
  9. Okay, thx for answering that question
Thread Status:
Not open for further replies.