Helpful links:
- 1.20.1+
<repository>
<id>szczurowsky-repository-releases</id>
<name>Szczurowsky Repository</name>
<url>https://repo.szczurowsky.pl/releases</url>
</repository>
maven {
url = uri("https://repo.szczurowsky.pl/releases")
}
Framework Core
<dependency>
<groupId>pl.szczurowsky</groupId>
<artifactId>loot-table-parse</artifactId>
<version>1.0.4</version>
</dependency>
implementation("pl.szczurowsky:loot-table-parse:1.0.4")
It's worth to mention that library uses NBT-API for parsing NBT data, because of that we highly advise to shade NBT-API
into your plugin.
Click here to see how to shade NBT-API into your plugin.
Fetch loot table from CDN and give player items
public class ExamplePlugin extends JavaPlugin {
private ParsedLootTable parsedLootTable;
@Override
public void onEnable() {
this.parsedLootTable = new ParsedLootTable(new URL("https://example.com/loot-table"));
try {
parsedLootTable.fetch();
} catch (Exception e) {
e.printStackTrace();
}
}
}
public class ExampleListener implements Listener {
private final ParsedLootTable parsedLootTable;
public ExampleListener(ParsedLootTable parsedLootTable) {
this.parsedLootTable = parsedLootTable;
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
this.parsedLootTable.getLoot(false).forEach(item -> player.getInventory().addItem(item));
}
}