Skip to content

Commit

Permalink
visual updates + rarity bonus
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksyKun committed Jan 21, 2025
1 parent d608903 commit ee91739
Show file tree
Hide file tree
Showing 37 changed files with 136 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public class GeneratorItem extends LimitedItem {
private Map<String, BonusMap> materialModifiers;
private Map<String, Map<ItemLoreStat<?>, String>> materialBonuses;
private Map<String, Map<ItemLoreStat<?>, String>> classBonuses;
private Map<String, Map<ItemLoreStat<?>, String>> rarityBonuses;

private TreeMap<Integer, String[]> reqUserLvl;
private TreeMap<Integer, String[]> reqUserClass;
Expand Down Expand Up @@ -412,6 +413,62 @@ public GeneratorItem(@NotNull Divinity plugin, @NotNull JYML cfg) {
this.classBonuses.put(group, statMap);
}

// Load Rarity bonuses
path = "generator.bonuses.rarity.";
this.rarityBonuses = new HashMap<>();
for (String group : cfg.getSection("generator.bonuses.rarity")) {
Map<ItemLoreStat<?>, String> statMap = new HashMap<>();

String path2 = path + group + ".damage-types";
for (String id : cfg.getSection(path2)) {
DamageAttribute dt = ItemStats.getDamageById(id);
if (dt == null) continue;

String sVal = cfg.getString(path2 + "." + id);
if (sVal == null) continue;

String[] split = sVal.split("%", 2);
boolean perc = split.length == 2 && split[1].isEmpty();
double val = StringUT.getDouble(split[0], 0, true);

statMap.put(dt, val + (perc ? "%" : ""));
}

path2 = path + group + ".defense-types";
for (String id : cfg.getSection(path2)) {
DefenseAttribute dt = ItemStats.getDefenseById(id);
if (dt == null) continue;

String sVal = cfg.getString(path2 + "." + id);
if (sVal == null) continue;

String[] split = sVal.split("%", 2);
boolean perc = split.length == 2 && split[1].isEmpty();
double val = StringUT.getDouble(split[0], 0, true);

statMap.put(dt, val + (perc ? "%" : ""));
}

path2 = path + group + ".item-stats";
for (String id : cfg.getSection(path2)) {
SimpleStat.Type dt = TypedStat.Type.getByName(id);
if (dt == null) continue;

ItemLoreStat<?> mainStat = (ItemLoreStat<?>) ItemStats.getStat(dt);

String sVal = cfg.getString(path2 + "." + id);
if (sVal == null) continue;

String[] split = sVal.split("%", 2);
boolean perc = split.length == 2 && split[1].isEmpty();
double val = StringUT.getDouble(split[0], 0, true);

statMap.put(mainStat, val + (perc ? "%" : ""));
}

this.rarityBonuses.put(group, statMap);
}

// Load User Requirements.
path = "generator.user-requirements-by-level.";
if (ItemRequirements.isRegisteredUser(LevelRequirement.class)) {
Expand Down Expand Up @@ -671,6 +728,23 @@ public Collection<StatBonus> getClassBonuses(ItemLoreStat<?> stat) {
return list;
}

public Collection<StatBonus> getRarityBonuses(ItemLoreStat<?> stat) {
List<StatBonus> list = new ArrayList<>();
for (Map.Entry<String, Map<ItemLoreStat<?>, String>> entry : this.rarityBonuses.entrySet()) {
for (Map.Entry<ItemLoreStat<?>, String> entry1 : entry.getValue().entrySet()) {
if (entry1.getKey().equals(stat)) {
String sVal = entry1.getValue();
String[] split = sVal.split("%", 2);
list.add(new StatBonus(
new double[]{Double.parseDouble(split[0])},
split.length == 2 && split[1].isEmpty(),
new StatBonus.Condition<>()));
}
}
}
return list;
}

@NotNull
public Set<IAttributeGenerator> getAttributeGenerators() {
return attributeGenerators;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class AmmoTypesGUI extends AbstractEditorGUI {
public AmmoTypesGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.AMMO_TYPES.getTitle(),
"Editor/" + EditorGUI.ItemType.AMMO_TYPES.getTitle(),
itemGenerator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class EditorGUI extends AbstractEditorGUI {

public EditorGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player, 5, "[&d" + itemGenerator.getId() + "&r] editor", itemGenerator);
super(player, 5, "Editor", itemGenerator);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class HandTypesGUI extends AbstractEditorGUI {
public HandTypesGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.HAND_TYPES.getTitle(),
"Editor/" + EditorGUI.ItemType.HAND_TYPES.getTitle(),
itemGenerator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ItemFlagsGUI extends AbstractEditorGUI {
public ItemFlagsGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.ITEM_FLAGS.getTitle(),
"Editor/" + EditorGUI.ItemType.ITEM_FLAGS.getTitle(),
itemGenerator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class TierGUI extends AbstractEditorGUI {
public TierGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.TIER.getTitle(),
"Editor/" + EditorGUI.ItemType.TIER.getTitle(),
itemGenerator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class UsesByLevelGUI extends AbstractEditorGUI {
public UsesByLevelGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.USES_BY_LEVEL.getTitle(),
"Editor/" + EditorGUI.ItemType.USES_BY_LEVEL.getTitle(),
itemGenerator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class BonusCategoryGUI extends AbstractEditorGUI {
public BonusCategoryGUI(Player player, ItemGeneratorReference itemGenerator, MainBonusesGUI.ItemType category) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.BONUSES.getTitle(),
"Editor/" + EditorGUI.ItemType.BONUSES.getTitle(),
itemGenerator);
this.category = category;
}
Expand Down Expand Up @@ -89,7 +89,8 @@ public void setContents() {
// Only permanent bonuses should handle these (i.e. class bonuses are applied dynamically)
switch (this.category) {
case MATERIAL_MODIFIERS:
case MATERIAL: {
case MATERIAL:
case RARITY:{
section =
bonusesSection.getConfigurationSection(key + '.' + ItemType.FABLED_ATTRIBUTE.getPath());
if (section != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class BonusStatTypeGUI extends AbstractEditorGUI {
public BonusStatTypeGUI(Player player, ItemGeneratorReference itemGenerator, String path) {
super(player,
1,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.BONUSES.getTitle(),
"Editor/" + EditorGUI.ItemType.BONUSES.getTitle(),
itemGenerator);
this.path = path;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class BonusesGUI extends AbstractEditorGUI {
public BonusesGUI(Player player, ItemGeneratorReference itemGenerator, String path) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.BONUSES.getTitle(),
"Editor/" + EditorGUI.ItemType.BONUSES.getTitle(),
itemGenerator);
this.path = path;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ public class MainBonusesGUI extends AbstractEditorGUI {
public MainBonusesGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player,
1,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.BONUSES.getTitle(),
"Editor/" + EditorGUI.ItemType.BONUSES.getTitle(),
itemGenerator);
}

@Override
public void setContents() {
setSlot(0, new Slot(createItem(Material.IRON_ORE,
"&eMaterial Modifiers",
"&7Modify the base value of the stat, based on the material group of the item",
"&7Modify the base value of the stat,",
"&7based on the material group of the ",
"&7item.",
"&6Left-Click: &eModify")) {
@Override
public void onLeftClick() {
Expand All @@ -42,12 +44,21 @@ public void onLeftClick() {
openSubMenu(new BonusCategoryGUI(player, itemGenerator, ItemType.CLASS));
}
});
/*setSlot(3, new Slot(createItem(Material.DIAMOND,
"&eRarity bonuses",
"&6Left-Click: &eModify")) {
@Override
public void onLeftClick() {
openSubMenu(new BonusCategoryGUI(player, itemGenerator, ItemType.RARITY));
}
});*/
}

public enum ItemType {
MATERIAL_MODIFIERS("material or group"),
MATERIAL("material or group"),
CLASS("class"),
RARITY("rarity"),
;

private final String description;
Expand All @@ -56,8 +67,12 @@ public enum ItemType {
this.description = description;
}

public String getPath() {return "generator.bonuses." + name().toLowerCase().replace('_', '-');}
public String getPath() {
return "generator.bonuses." + name().toLowerCase().replace('_', '-');
}

public String getDescription() {return description;}
public String getDescription() {
return description;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public NewBonusStatGUI(Player player,
BonusCategoryGUI.ItemType statType) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.MATERIALS.getTitle(),
"Editor/" + EditorGUI.ItemType.MATERIALS.getTitle(),
itemGenerator);
this.path = path;
this.statType = statType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class EnchantmentListGUI extends AbstractEditorGUI {
public EnchantmentListGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.ENCHANTMENTS.getTitle(),
"Editor/" + EditorGUI.ItemType.ENCHANTMENTS.getTitle(),
itemGenerator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class EnchantmentsGUI extends AbstractEditorGUI {
public EnchantmentsGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player,
1,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.ENCHANTMENTS.getTitle(),
"Editor/" + EditorGUI.ItemType.ENCHANTMENTS.getTitle(),
itemGenerator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class NewEnchantmentGUI extends AbstractEditorGUI {
public NewEnchantmentGUI(Player player, ItemGeneratorReference itemGenerator, List<String> missingList) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.ENCHANTMENTS.getTitle(),
"Editor/" + EditorGUI.ItemType.ENCHANTMENTS.getTitle(),
itemGenerator);
this.list = missingList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class MainMaterialsGUI extends AbstractEditorGUI {
public MainMaterialsGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player,
1,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.MATERIALS.getTitle(),
"Editor/" + EditorGUI.ItemType.MATERIALS.getTitle(),
itemGenerator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class MainModelDataGUI extends AbstractEditorGUI {
public MainModelDataGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.MATERIALS.getTitle(),
"Editor/" + EditorGUI.ItemType.MATERIALS.getTitle(),
itemGenerator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class MaterialListGUI extends AbstractEditorGUI {
public MaterialListGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.MATERIALS.getTitle(),
"Editor/" + EditorGUI.ItemType.MATERIALS.getTitle(),
itemGenerator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ModelDataGUI extends AbstractEditorGUI {
public ModelDataGUI(Player player, ItemGeneratorReference itemGenerator, String material) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.MATERIALS.getTitle(),
"Editor/" + EditorGUI.ItemType.MATERIALS.getTitle(),
itemGenerator);
this.id = material;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class MainRequirementsGUI extends AbstractEditorGUI {
public MainRequirementsGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player,
1,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.REQUIREMENTS.getTitle(),
"Editor/" + EditorGUI.ItemType.REQUIREMENTS.getTitle(),
itemGenerator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class RequirementsGUI extends AbstractEditorGUI {
public RequirementsGUI(Player player, ItemGeneratorReference itemGenerator, String path, Material material) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.REQUIREMENTS.getTitle(),
"Editor/" + EditorGUI.ItemType.REQUIREMENTS.getTitle(),
itemGenerator);
this.path = path;
this.material = material;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class MainSkillsGUI extends AbstractEditorGUI {
public MainSkillsGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player,
1,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.SKILLS.getTitle(),
"Editor/" + EditorGUI.ItemType.SKILLS.getTitle(),
itemGenerator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class NewSkillGUI extends AbstractEditorGUI {
public NewSkillGUI(Player player, ItemGeneratorReference itemGenerator, List<String> missingSkills) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.SKILLS.getTitle(),
"Editor/" + EditorGUI.ItemType.SKILLS.getTitle(),
itemGenerator);
this.list = missingSkills;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SkillGUI extends AbstractEditorGUI {
public SkillGUI(Player player, ItemGeneratorReference itemGenerator, String path) {
super(player,
1,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.SKILLS.getTitle(),
"Editor/" + EditorGUI.ItemType.SKILLS.getTitle(),
itemGenerator);
this.path = path;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class SkillListGUI extends AbstractEditorGUI {
public SkillListGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.SKILLS.getTitle(),
"Editor/" + EditorGUI.ItemType.SKILLS.getTitle(),
itemGenerator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class MainSocketsGUI extends AbstractEditorGUI {
public MainSocketsGUI(Player player, ItemGeneratorReference itemGenerator) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.SOCKETS.getTitle(),
"Editor/" + EditorGUI.ItemType.SOCKETS.getTitle(),
itemGenerator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class SocketGUI extends AbstractEditorGUI {
public SocketGUI(Player player, ItemGeneratorReference itemGenerator, String name) {
super(player,
1,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.SOCKETS.getTitle(),
"Editor/" + EditorGUI.ItemType.SOCKETS.getTitle(),
itemGenerator);
this.name = name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class SocketListGUI extends AbstractEditorGUI {
public SocketListGUI(Player player, ItemGeneratorReference itemGenerator, String name) {
super(player,
6,
"[&d" + itemGenerator.getId() + "&r] editor/" + EditorGUI.ItemType.SOCKETS.getTitle(),
"Editor/" + EditorGUI.ItemType.SOCKETS.getTitle(),
itemGenerator);
this.name = name;
this.path = EditorGUI.ItemType.SOCKETS.getPath() + '.' + this.name + ".list.";
Expand Down
Loading

0 comments on commit ee91739

Please sign in to comment.