tried to patch some bugs

This commit is contained in:
unurled 2024-07-03 15:42:21 +02:00
parent 92fd2242b3
commit ce0ffdbdfc
9 changed files with 128 additions and 89 deletions

View file

@ -110,6 +110,8 @@ public class EntityManager extends Manager {
public void addEntityType(@NotNull SREntityType type) {
types.add(type);
// save to db type
saveType(type);
}
public List<SREntityType> getTypes() {

View file

@ -1,12 +1,9 @@
package me.unurled.sacredrealms.sr.components.entity;
import com.google.gson.annotations.Expose;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import me.unurled.sacredrealms.sr.components.attributes.Attribute;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
@ -147,7 +144,7 @@ public class SREntityType {
}
public ItemStack getItem() {
return item;
return item == null ? new ItemStack(Material.BONE) : item;
}
public void setItem(ItemStack item) {
@ -155,6 +152,12 @@ public class SREntityType {
}
public List<ItemStack> getArmor() {
if (armor.isEmpty()) {
armor.add(new ItemStack(Material.AIR));
armor.add(new ItemStack(Material.AIR));
armor.add(new ItemStack(Material.AIR));
armor.add(new ItemStack(Material.AIR));
}
return armor;
}
@ -164,7 +167,7 @@ public class SREntityType {
}
public ItemStack getHandItem() {
return handItem;
return handItem == null ? new ItemStack(Material.AIR) : handItem;
}
@SuppressWarnings("unused")
@ -173,7 +176,7 @@ public class SREntityType {
}
public ItemStack getSecondHandItem() {
return secondHandItem;
return secondHandItem == null ? new ItemStack(Material.AIR) : secondHandItem;
}
@SuppressWarnings("unused")

View file

@ -26,6 +26,8 @@ public enum Rarity {
private final Double weight;
private final TextColor color;
private static final Random random = new Random();
Rarity(String name, String id, Double weight, TextColor color) {
this.name = name;
this.id = id;
@ -46,7 +48,6 @@ public enum Rarity {
@NotNull
public static Rarity getRandomRarity(double luck) {
// more weight equals less chance to get it
Random random = new Random();
double randomValue = random.nextDouble() * (1.0 / (luck == 0 ? 1 : luck));
double cumulativeProbability = 0.0;