Skip to content

Commit

Permalink
Add better description handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Oribuin committed Oct 5, 2024
1 parent 64c3953 commit bbc84be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/java/xyz/oribuin/fishing/augment/Augment.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void saveSettings(@NotNull CommentedConfigurationSection config) {
config.set("enabled", this.enabled);
config.set("max-level", this.maxLevel);
config.set("required-level", this.requiredLevel);
config.set("description", this.description);
config.set("description", List.of(this.description.split("\n")));

CommentedConfigurationSection section = config.getConfigurationSection("display-item");
if (section == null) section = config.createSection("display-item");
Expand All @@ -86,7 +86,7 @@ public void loadSettings(@NotNull CommentedConfigurationSection config) {
this.enabled = config.getBoolean("enabled", true);
this.maxLevel = config.getInt("max-level", 1);
this.requiredLevel = config.getInt("required-level", 1);
this.description = config.getString("description", this.description);
this.description = String.join("\n", config.getStringList("description"));

ItemConstruct construct = ItemConstruct.deserialize(config.getConfigurationSection("display-item"));
if (construct == null) {
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/xyz/oribuin/fishing/manager/TierManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public TierManager(RosePlugin rosePlugin) {

@Override
public void reload() {
File tierFolder = FishUtils.createFile(this.rosePlugin, new File(this.rosePlugin.getDataFolder(), "tiers"));
File tierFolder = new File(this.rosePlugin.getDataFolder(), "tiers");

// Load all the tiers from the config files in the folder
File[] content = tierFolder.listFiles();
Expand All @@ -38,11 +38,13 @@ public void reload() {
if (content == null) return;

for (File file : content) {
if (file.isDirectory()) return; // we're not subdirectoring
if (file.isDirectory()) return; // we're not subdirectories
if (!file.getName().endsWith(".yml")) return; // it's not a yml file

CommentedFileConfiguration tierConfig = CommentedFileConfiguration.loadConfiguration(file);

Tier tier = new Tier(file.getName().replace(".yml", ""));
tier.reload(); // Load the tier settings
tier.loadSettings(tierConfig); // Load the tier settings

this.tiers.put(tier.name(), tier);
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/xyz/oribuin/fishing/skill/Skill.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import xyz.oribuin.fishing.api.event.FishEventHandler;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public abstract class Skill extends FishEventHandler implements Configurable {

Expand Down Expand Up @@ -90,7 +92,8 @@ public String name() {
*/
@Override
public void loadSettings(@NotNull CommentedConfigurationSection config) {
this.description = config.getString("description", "No Description");
this.description = String.join("\n", config.getStringList("description"));

}

/**
Expand All @@ -100,7 +103,8 @@ public void loadSettings(@NotNull CommentedConfigurationSection config) {
*/
@Override
public void saveSettings(@NotNull CommentedConfigurationSection config) {
config.set("description", this.description);
config.addComments(this.comments().toArray(new String[0]));
config.set("description", List.of(this.description.split("\n")));
}

}

0 comments on commit bbc84be

Please sign in to comment.