Add loot items configuration and RARITY enum for item rarity handling
This commit is contained in:
parent
e97a6ade73
commit
58d0b7fa19
40
src/main/java/com/alttd/hunger_games/config/LootItems.java
Normal file
40
src/main/java/com/alttd/hunger_games/config/LootItems.java
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package com.alttd.hunger_games.config;
|
||||
|
||||
import com.alttd.hunger_games.data_objects.RARITY;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class LootItems extends AbstractConfig {
|
||||
static LootItems config;
|
||||
|
||||
LootItems() {
|
||||
super(
|
||||
new File(File.separator
|
||||
+ "mnt" + File.separator
|
||||
+ "configs" + File.separator
|
||||
+ "HungerGames"),
|
||||
"loot-items.yml");
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
config = new LootItems();
|
||||
config.readConfig(LootItems.class, null);
|
||||
}
|
||||
|
||||
public static class ITEMS {
|
||||
private static final String prefix = "items.";
|
||||
|
||||
private static final HashMap<RARITY, List<Material>> ITEMS = new HashMap<>();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void load() {
|
||||
for (RARITY rarity : RARITY.values()) {
|
||||
List<String> materialList = config.getList(prefix, rarity.getConfigName(), ITEMS.get(rarity).stream().map(Material::name));
|
||||
ITEMS.put(rarity, materialList.stream().map(Material::getMaterial).toList());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.alttd.hunger_games.data_objects;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum RARITY {
|
||||
COMMON("common"),
|
||||
UNCOMMON("uncommon"),
|
||||
RARE("rare"),
|
||||
EPIC("epic");
|
||||
|
||||
private final String configName;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user