Skip to content

Commit

Permalink
start fishing user storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Oribuin committed Sep 16, 2024
1 parent 0d8fad9 commit d3d4cc4
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/main/java/xyz/oribuin/fishing/api/economy/Currency.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ public enum Currency {
VAULT, // Vault economy plugin
ENTROPY, // Entropy
FISH_EXP, // Fish experience
PLAYER_XP // Player experience
PLAYER_XP, // Player experience
SKILL_POINTS, // Skill points
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package xyz.oribuin.fishing.manager;

import xyz.oribuin.fishing.FishingPlugin;
import dev.rosewood.rosegarden.RosePlugin;
import dev.rosewood.rosegarden.config.CommentedFileConfiguration;
import dev.rosewood.rosegarden.config.RoseSetting;
import dev.rosewood.rosegarden.manager.AbstractConfigurationManager;
import xyz.oribuin.fishing.FishingPlugin;

public class ConfigurationManager extends AbstractConfigurationManager {

public enum Setting implements RoseSetting {
;
REQUIRED_XP_FORMULA("required-xp-formula", "%level% * 625", "The formula to calculate the required experience to level up per level"),
;

private final String key;
private final Object defaultValue;
Expand Down
71 changes: 71 additions & 0 deletions src/main/java/xyz/oribuin/fishing/storage/FishingUser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package xyz.oribuin.fishing.storage;

import dev.rosewood.rosegarden.utils.StringPlaceholders;
import xyz.oribuin.fishing.manager.ConfigurationManager.Setting;
import xyz.oribuin.fishing.util.FishUtils;

import java.util.UUID;

public class FishingUser {

private final UUID uuid;
private int entropy;
private int level;
private int experience;
private int skillPoints;

public FishingUser(UUID uuid) {
this.uuid = uuid;
this.entropy = 0;
this.level = 1;
this.experience = 0;
this.skillPoints = 0;
}

/**
* Check the required experience to level up based on the current level
*
* @return The required experience to level up
*/
public int getXpToNextLevel() {
StringPlaceholders placeholders = StringPlaceholders.of("level", this.level);
return (int) FishUtils.evaluate(placeholders.apply(Setting.REQUIRED_XP_FORMULA.getString()));
}

public UUID uuid() {
return this.uuid;
}

public int entropy() {
return this.entropy;
}

public void entropy(int entropy) {
this.entropy = entropy;
}

public int level() {
return this.level;
}

public void level(int level) {
this.level = level;
}

public int experience() {
return this.experience;
}

public void experience(int experience) {
this.experience = experience;
}

public int skillCaught() {
return this.skillPoints;
}

public void skillCaught(int skillCaught) {
this.skillPoints = skillCaught;
}

}

0 comments on commit d3d4cc4

Please sign in to comment.