9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-28 03:19:12 +00:00

Added debug command

This commit is contained in:
XiaoMoMi
2024-07-10 19:40:47 +08:00
parent c2b8392f58
commit d5eea4cdb7
16 changed files with 219 additions and 7 deletions

View File

@@ -40,6 +40,8 @@ import org.incendo.cloud.exception.handling.ExceptionContext;
import org.incendo.cloud.minecraft.extras.MinecraftExceptionHandler;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -138,6 +140,11 @@ public abstract class AbstractCommandManager<C> implements CustomFishingCommandM
@Override
public void registerDefaultFeatures() {
YamlDocument document = plugin.getConfigManager().loadConfig(commandsFile);
try {
document.save(new File(plugin.getDataDirectory().toFile(), "commands.yml"));
} catch (IOException e) {
throw new RuntimeException(e);
}
this.getFeatures().values().forEach(feature -> {
CommandConfig<C> config = getCommandConfig(document, feature.getFeatureID());
if (config.isEnable()) {

View File

@@ -75,6 +75,9 @@ public interface MessageConstants {
TranslatableComponent.Builder COMMAND_STATISTICS_RESET_SUCCESS = Component.translatable().key("command.statistics.reset.success");
TranslatableComponent.Builder COMMAND_STATISTICS_QUERY_AMOUNT = Component.translatable().key("command.statistics.query.amount");
TranslatableComponent.Builder COMMAND_STATISTICS_QUERY_SIZE = Component.translatable().key("command.statistics.query.size");
TranslatableComponent.Builder COMMAND_DEBUG_LOOT_FAILURE_ROD = Component.translatable().key("command.debug.loot.failure.rod");
TranslatableComponent.Builder COMMAND_DEBUG_LOOT_SUCCESS = Component.translatable().key("command.debug.loot.success");
TranslatableComponent.Builder COMMAND_DEBUG_LOOT_FAILURE_NO_LOOT = Component.translatable().key("command.debug.loot.failure.no_loot");
// TranslatableComponent.Builder GUI_SELECT_FILE = Component.translatable().key("gui.select_file");
// TranslatableComponent.Builder GUI_SELECT_ITEM = Component.translatable().key("gui.select_item");

View File

@@ -26,6 +26,7 @@ import net.momirealms.customfishing.common.plugin.CustomFishingPlugin;
import net.momirealms.customfishing.common.util.Pair;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -37,7 +38,7 @@ import java.util.stream.Stream;
public class TranslationManager {
public static final Locale DEFAULT_LOCALE = Locale.ENGLISH;
private static final List<String> locales = List.of("en");
private static final List<String> locales = List.of("en", "zh_cn");
private static TranslationManager instance;
private final CustomFishingPlugin plugin;
@@ -57,7 +58,6 @@ public class TranslationManager {
MiniMessageTranslator.translator().removeSource(this.registry);
this.installed.clear();
}
for (String lang : locales) {
this.plugin.getConfigManager().saveResource("translations/" + lang + ".yml");
}
@@ -158,6 +158,11 @@ public class TranslationManager {
Map<String, String> bundle = new HashMap<>();
YamlDocument document = plugin.getConfigManager().loadConfig("translations" + "\\" + translationFile.getFileName(), '@');
try {
document.save(new File(plugin.getDataDirectory().toFile(), "translations" + "\\" + translationFile.getFileName()));
} catch (IOException e) {
throw new IllegalStateException("Could not update translation file: " + translationFile.getFileName(), e);
}
Map<String, Object> map = document.getStringRouteMappedValues(false);
map.remove("config-version");
for (Map.Entry<String, Object> entry : map.entrySet()) {