mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-05-11 21:56:55 +00:00
config is now an util class
This commit is contained in:
@@ -23,7 +23,7 @@ public class EnchantioBootstrap implements PluginBootstrap {
|
|||||||
@Override
|
@Override
|
||||||
public void bootstrap(@NotNull BootstrapContext context) {
|
public void bootstrap(@NotNull BootstrapContext context) {
|
||||||
try {
|
try {
|
||||||
new EnchantioConfig(context.getDataDirectory(), logger);
|
EnchantioConfig.init(context.getDataDirectory());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package me.youhavetrouble.enchantio;
|
|||||||
|
|
||||||
import io.papermc.paper.registry.RegistryKey;
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
import io.papermc.paper.registry.TypedKey;
|
import io.papermc.paper.registry.TypedKey;
|
||||||
import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
|
|
||||||
import io.papermc.paper.registry.keys.tags.ItemTypeTagKeys;
|
import io.papermc.paper.registry.keys.tags.ItemTypeTagKeys;
|
||||||
import io.papermc.paper.registry.tag.TagKey;
|
import io.papermc.paper.registry.tag.TagKey;
|
||||||
import io.papermc.paper.tag.TagEntry;
|
import io.papermc.paper.tag.TagEntry;
|
||||||
@@ -19,17 +18,18 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
public class EnchantioConfig {
|
public class EnchantioConfig {
|
||||||
|
|
||||||
public static final Map<Key, EnchantioEnchant> ENCHANTS = new HashMap<>();
|
public static final Map<Key, EnchantioEnchant> ENCHANTS = new HashMap<>();
|
||||||
private final Logger logger;
|
private static boolean initialized = false;
|
||||||
|
|
||||||
protected EnchantioConfig(Path filePath, Logger logger) throws IOException {
|
|
||||||
this.logger = logger;
|
|
||||||
|
|
||||||
|
protected static void init(Path filePath) throws IOException {
|
||||||
|
if (initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
initialized = true;
|
||||||
File file = filePath.toFile();
|
File file = filePath.toFile();
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.mkdirs();
|
file.mkdirs();
|
||||||
|
|||||||
Reference in New Issue
Block a user