Skip to content

Commit

Permalink
migrate config/message.yml stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ryderbelserion committed Sep 8, 2024
1 parent bf79c6e commit 3f18c05
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ch.jalu.configme.properties.Property;
import com.badbones69.crazycrates.CrazyCrates;
import com.badbones69.crazycrates.api.enums.misc.State;
import com.badbones69.crazycrates.api.utils.MiscUtils;
import com.ryderbelserion.vital.common.utils.StringUtil;
import com.ryderbelserion.vital.paper.api.enums.Support;
import com.ryderbelserion.vital.paper.util.AdvUtil;
Expand Down Expand Up @@ -231,6 +232,16 @@ public void sendRichMessage(final CommandSender sender) {
sender.sendRichMessage(msg);
}

public void migrate() {
if (this.isList) {
this.config.setProperty(this.properties, MiscUtils.fromComponent(MiscUtils.toComponent(this.config.getProperty(this.properties))));

return;
}

this.config.setProperty(this.property, MiscUtils.fromComponent(MiscUtils.toComponent(this.config.getProperty(this.property))));
}

private @NotNull String parse(@NotNull final CommandSender sender, @NotNull final Map<String, String> placeholders) {
String message;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public abstract class ICrateMigrator {

protected final SettingsManager config = ConfigManager.getConfig();

protected final SettingsManager messages = ConfigManager.getMessages();

protected final FileManager fileManager = this.plugin.getFileManager();

protected final CommandSender sender;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.badbones69.crazycrates.commands.crates.types.admin.crates.migrator.types.deprecation;

import com.badbones69.crazycrates.api.enums.Messages;
import com.badbones69.crazycrates.api.utils.MiscUtils;
import com.badbones69.crazycrates.commands.crates.types.admin.crates.migrator.ICrateMigrator;
import com.badbones69.crazycrates.commands.crates.types.admin.crates.migrator.enums.MigrationType;
import com.badbones69.crazycrates.config.impl.ConfigKeys;
import com.ryderbelserion.vital.paper.api.files.CustomFile;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

Expand All @@ -24,6 +27,28 @@ public void run() {
final List<String> failed = new ArrayList<>();
final List<String> success = new ArrayList<>();

this.config.setProperty(ConfigKeys.command_prefix, MiscUtils.fromComponent(MiscUtils.toComponent(this.config.getProperty(ConfigKeys.command_prefix))));
this.config.setProperty(ConfigKeys.inventory_name, MiscUtils.fromComponent(MiscUtils.toComponent(this.config.getProperty(ConfigKeys.inventory_name))));

this.config.setProperty(ConfigKeys.menu_button_name, MiscUtils.fromComponent(MiscUtils.toComponent(this.config.getProperty(ConfigKeys.menu_button_name))));
this.config.setProperty(ConfigKeys.menu_button_lore, MiscUtils.fromComponent(MiscUtils.toComponent(this.config.getProperty(ConfigKeys.menu_button_lore))));

this.config.setProperty(ConfigKeys.next_button_name, MiscUtils.fromComponent(MiscUtils.toComponent(this.config.getProperty(ConfigKeys.next_button_name))));
this.config.setProperty(ConfigKeys.next_button_lore, MiscUtils.fromComponent(MiscUtils.toComponent(this.config.getProperty(ConfigKeys.next_button_lore))));

this.config.setProperty(ConfigKeys.back_button_name, MiscUtils.fromComponent(MiscUtils.toComponent(this.config.getProperty(ConfigKeys.back_button_name))));
this.config.setProperty(ConfigKeys.back_button_lore, MiscUtils.fromComponent(MiscUtils.toComponent(this.config.getProperty(ConfigKeys.back_button_lore))));

this.config.setProperty(ConfigKeys.filler_name, MiscUtils.fromComponent(MiscUtils.toComponent(this.config.getProperty(ConfigKeys.filler_name))));
this.config.setProperty(ConfigKeys.filler_lore, MiscUtils.fromComponent(MiscUtils.toComponent(this.config.getProperty(ConfigKeys.filler_lore))));

for (Messages message : Messages.values()) {
message.migrate();
}

this.config.reload();
this.messages.reload();

customFiles.forEach(customFile -> {
try {
final YamlConfiguration configuration = customFile.getConfiguration();
Expand Down

0 comments on commit 3f18c05

Please sign in to comment.