Hallo,
da ich mir für meinen Server ein kleines Plugin welches PvP gewonnene und verlorene Kämpfe auflisten soll und gleichzeitig ein wenig Geld sowie ggf Items ausspucken soll, bin ich nun auf ein Problem gestoßen.
Und zwar möchte ich eine YAML Liste wie zB.
in der Konfiguration angeben und dann beim Laden schonmal die passenden ItemStacks erstellen.
Doch wie mach ich das nun?
Versuch 1 ( Failed ) :
Versuch 2 ( Failed ) :
Versuch 3 ( Failed ) :
Versuch 4 ( Failed ) :
da ich mir für meinen Server ein kleines Plugin welches PvP gewonnene und verlorene Kämpfe auflisten soll und gleichzeitig ein wenig Geld sowie ggf Items ausspucken soll, bin ich nun auf ein Problem gestoßen.
Und zwar möchte ich eine YAML Liste wie zB.
Code:
items:
list:
- 276 1 name:RewardSword
- 276 1 name:RewSword sharpness:3
- 403 1 protection:2
- 403 1 unbreaking:3
- 403 1 power:3
in der Konfiguration angeben und dann beim Laden schonmal die passenden ItemStacks erstellen.
Doch wie mach ich das nun?
Versuch 1 ( Failed ) :
Code:
final ConfigurationSection section = config.getConfigurationSection("pvprewards.item.list");
final ConfigurationSection newSection = new MemoryConfiguration();
for (String kitItem : section.getKeys(false))
{
ItemStack items = section.getConfigurationSection(kitItem).getItemStack(kitItem);
if(items != null) {
this.reward_items.add(items);
} else {
PvPRewards.debug("Fehler im String \"" + kitItem + "\".");
}
}
Versuch 2 ( Failed ) :
Code:
List<String> myItems = config.getStringList("pvprewards.item.list");
for (String kitItem : myItems)
{
ItemStack items = config.getItemStack(kitItem);
if(items != null) {
this.reward_items.add(items);
} else {
PvPRewards.debug("Fehler im String \"" + kitItem + "\".");
}
}
Versuch 3 ( Failed ) :
Code:
List<String> myItems = config.getStringList("pvprewards.item.list");
for (String kitItem : myItems)
{
ItemStack items = config.getConfigurationSection(kitItem).getItemStack(kitItem);
if(items != null) {
this.reward_items.add(items);
} else {
PvPRewards.debug("Fehler im String \"" + kitItem + "\".");
}
}
Versuch 4 ( Failed ) :
Code:
List<String> myItems = config.getStringList("pvprewards.item.list");
for (String kitItem : myItems)
{
ItemStack items = config.createSection(kitItem).getItemStack(kitItem);
if(items != null) {
this.reward_items.add(items);
} else {
PvPRewards.debug("Fehler im String \"" + kitItem + "\".");
}
}