-
Notifications
You must be signed in to change notification settings - Fork 0
What is the correct usage for this situation? #2
Copy link
Copy link
Closed
Description
Let's say I want to load a list of the same type of object, but with different data.
For example, I have a Foo object:
class Foo {
long price;
String identifier;
String permission;
public Foo(int price, String identifier, String permission) {
// assign to variables
}
}In my config file:
foos:
myFoo: # identifier
price: 100 #price
permission: 'perm.myFoo' #permission
myAnotherFoo:
price: 200
permission: 'perm.myAnotherFoo'If I want to load in a traditional way, I just loop through all foos keys then create each individual Foo objects.
for(String key : config.getConfigurationSection("foos").getKeys(false) {
String identifier = key;
String permission = config.getString("foos." + key + ".permission");
long price = config.getLong("foos." + key + ".price");
Foo foo = new Foo(price, identifier, permission);
// proceed to store Foo somewhere else
}So what is the correct usage for this situation with your plugin? Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels