mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-13 12:54:36 +01:00
41 lines
1.1 KiB
Java
41 lines
1.1 KiB
Java
package emu.nebula.data.resources;
|
|
|
|
import emu.nebula.data.BaseDef;
|
|
import emu.nebula.data.ResourceType;
|
|
import emu.nebula.util.Utils;
|
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
|
import it.unimi.dsi.fastutil.ints.IntList;
|
|
import lombok.Getter;
|
|
|
|
@Getter
|
|
@ResourceType(name = "DropPkg.json")
|
|
public class DropPkgDef extends BaseDef {
|
|
private int PkgId;
|
|
private int ItemId;
|
|
|
|
private static Int2ObjectMap<IntList> PACKAGES = new Int2ObjectOpenHashMap<>();
|
|
|
|
@Override
|
|
public int getId() {
|
|
return PkgId;
|
|
}
|
|
|
|
@Override
|
|
public void onLoad() {
|
|
var packageList = PACKAGES.computeIfAbsent(this.PkgId, i -> new IntArrayList());
|
|
packageList.add(this.ItemId);
|
|
}
|
|
|
|
public static int getRandomDrop(int packageId) {
|
|
var packageList = PACKAGES.get(packageId);
|
|
|
|
if (packageList == null) {
|
|
return 0;
|
|
}
|
|
|
|
return Utils.randomElement(packageList);
|
|
}
|
|
}
|