Search in sources :

Example 1 with YamlBukkitConfigurer

use of eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer in project FunnyGuilds by FunnyGuilds.

the class ConfigurationFactory method createTablistConfiguration.

public TablistConfiguration createTablistConfiguration(File tablistConfigurationFile) {
    return ConfigManager.create(TablistConfiguration.class, (it) -> {
        it.withConfigurer(new OkaeriValidator(new YamlBukkitConfigurer(), true), new SerdesCommons());
        it.withSerdesPack(registry -> {
            registry.register(new NumberRangeTransformer());
            registry.register(new TablistPageSerializer());
            registry.register(new SkinTextureSerializer());
        });
        it.withBindFile(tablistConfigurationFile);
        it.saveDefaults();
        it.load(true);
        it.migrate(new T0001_Update_player_list_animated());
    });
}
Also used : YamlBukkitConfigurer(eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer) T0001_Update_player_list_animated(net.dzikoysk.funnyguilds.config.migration.T0001_Update_player_list_animated) SkinTextureSerializer(net.dzikoysk.funnyguilds.config.serdes.SkinTextureSerializer) SerdesCommons(eu.okaeri.configs.serdes.commons.SerdesCommons) NumberRangeTransformer(net.dzikoysk.funnyguilds.config.serdes.NumberRangeTransformer) TablistPageSerializer(net.dzikoysk.funnyguilds.config.tablist.TablistPageSerializer) OkaeriValidator(eu.okaeri.configs.validator.okaeri.OkaeriValidator)

Example 2 with YamlBukkitConfigurer

use of eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer in project FunnyGuilds by FunnyGuilds.

the class ConfigurationFactory method createPluginConfiguration.

public PluginConfiguration createPluginConfiguration(File pluginConfigurationFile) {
    return ConfigManager.create(PluginConfiguration.class, (it) -> {
        it.withConfigurer(new OkaeriValidator(new YamlBukkitConfigurer(), true), new SerdesCommons());
        it.withSerdesPack(registry -> {
            registry.register(new RawStringTransformer());
            registry.register(new MaterialTransformer());
            registry.register(new ItemStackTransformer());
            registry.register(new EntityTypeTransformer());
            registry.register(new FunnyTimeTransformer());
            registry.register(new RangeFormattingTransformer());
            registry.register(new VectorSerializer());
        });
        it.withBindFile(pluginConfigurationFile);
        it.withLogger(FunnyGuilds.getInstance().getLogger());
        it.saveDefaults();
        it.load(true);
        it.migrate(new P0001_Fix_freecam_compensation_key_case(), new P0002_Migrate_old_heart_configuration(), new P0003_Migrate_old_tnt_protection_configuration(), new P0004_Migrate_tablist_into_separate_file(), new P0005_Fix_heart_configuration_centery_key());
    });
}
Also used : ItemStackTransformer(net.dzikoysk.funnyguilds.config.serdes.ItemStackTransformer) SerdesCommons(eu.okaeri.configs.serdes.commons.SerdesCommons) P0004_Migrate_tablist_into_separate_file(net.dzikoysk.funnyguilds.config.migration.P0004_Migrate_tablist_into_separate_file) FunnyTimeTransformer(net.dzikoysk.funnyguilds.config.serdes.FunnyTimeTransformer) RawStringTransformer(net.dzikoysk.funnyguilds.config.serdes.RawStringTransformer) YamlBukkitConfigurer(eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer) P0001_Fix_freecam_compensation_key_case(net.dzikoysk.funnyguilds.config.migration.P0001_Fix_freecam_compensation_key_case) P0003_Migrate_old_tnt_protection_configuration(net.dzikoysk.funnyguilds.config.migration.P0003_Migrate_old_tnt_protection_configuration) EntityTypeTransformer(net.dzikoysk.funnyguilds.config.serdes.EntityTypeTransformer) RangeFormattingTransformer(net.dzikoysk.funnyguilds.config.serdes.RangeFormattingTransformer) VectorSerializer(net.dzikoysk.funnyguilds.config.serdes.VectorSerializer) P0002_Migrate_old_heart_configuration(net.dzikoysk.funnyguilds.config.migration.P0002_Migrate_old_heart_configuration) MaterialTransformer(net.dzikoysk.funnyguilds.config.serdes.MaterialTransformer) P0005_Fix_heart_configuration_centery_key(net.dzikoysk.funnyguilds.config.migration.P0005_Fix_heart_configuration_centery_key) OkaeriValidator(eu.okaeri.configs.validator.okaeri.OkaeriValidator)

Example 3 with YamlBukkitConfigurer

use of eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer in project FunnyGuilds by FunnyGuilds.

the class ConfigurationFactory method createMessageConfiguration.

public MessageConfiguration createMessageConfiguration(File messageConfigurationFile) {
    return ConfigManager.create(MessageConfiguration.class, (it) -> {
        it.withConfigurer(new YamlBukkitConfigurer());
        it.withSerdesPack(registry -> {
            registry.register(new DecolorTransformer());
            registry.register(new SimpleDateFormatTransformer());
        });
        it.withBindFile(messageConfigurationFile);
        it.saveDefaults();
        it.load(true);
    });
}
Also used : YamlBukkitConfigurer(eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer) SimpleDateFormatTransformer(net.dzikoysk.funnyguilds.config.serdes.SimpleDateFormatTransformer) DecolorTransformer(net.dzikoysk.funnyguilds.config.serdes.DecolorTransformer)

Example 4 with YamlBukkitConfigurer

use of eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer in project okaeri-platform by OkaeriPoland.

the class OkaeriBukkitPlugin method plan.

@Override
public void plan(@NonNull ExecutionPlan plan) {
    plan.add(PRE_SETUP, new InjectorSetupTask());
    plan.add(PRE_SETUP, (ExecutionTask<OkaeriBukkitPlugin>) platform -> {
        platform.registerInjectable("server", platform.getServer());
        platform.registerInjectable("dataFolder", platform.getDataFolder());
        platform.registerInjectable("jarFile", platform.getFile());
        platform.registerInjectable("logger", platform.getLogger());
        platform.registerInjectable("plugin", platform);
        platform.registerInjectable("placeholders", BukkitPlaceholders.create(true));
        platform.registerInjectable("scheduler", new PlatformScheduler(platform, platform.getServer().getScheduler()));
        platform.registerInjectable("tasker", BukkitTasker.newPool(platform));
        platform.registerInjectable("pluginManager", platform.getServer().getPluginManager());
        platform.registerInjectable("defaultConfigurerProvider", (ConfigurerProvider) YamlBukkitConfigurer::new);
        platform.registerInjectable("defaultConfigurerSerdes", new Class[] { SerdesCommons.class, SerdesBukkit.class });
        platform.registerInjectable("defaultPlaceholdersFactory", new SimplePlaceholdersFactory());
        platform.registerInjectable("i18nLocaleProvider", new PlayerLocaleProvider());
        platform.registerInjectable("guardian", ReflectGuardian.create(ReflectPlaceholders.create()));
    });
    plan.add(SETUP, new BukkitCommandsSetupTask());
    plan.add(SETUP, new CreatorSetupTask(BukkitComponentCreator.class, BukkitCreatorRegistry.class));
    plan.add(POST_SETUP, new BukkitExternalResourceProviderSetupTask());
    plan.add(POST_SETUP, new BeanManifestCreateTask());
    plan.add(POST_SETUP, new BukkitCommandsI18nManifestTask());
    plan.add(POST_SETUP, new BeanManifestExecuteTask());
    plan.add(POST_SETUP, new CommandsI18nSetupTask());
    plan.add(SHUTDOWN, new PersistenceShutdownTask());
}
Also used : Setter(lombok.Setter) Arrays(java.util.Arrays) BukkitExternalResourceProviderSetupTask(eu.okaeri.platform.bukkit.plan.BukkitExternalResourceProviderSetupTask) Getter(lombok.Getter) ExecutionPlan(eu.okaeri.platform.core.plan.ExecutionPlan) Injector(eu.okaeri.injector.Injector) ReflectPlaceholders(eu.okaeri.placeholders.reflect.ReflectPlaceholders) BukkitComponentCreator(eu.okaeri.platform.bukkit.component.BukkitComponentCreator) BukkitPlaceholders(eu.okaeri.placeholders.bukkit.BukkitPlaceholders) SerdesCommons(eu.okaeri.configs.serdes.commons.SerdesCommons) OkaeriPlatform(eu.okaeri.platform.core.OkaeriPlatform) ExecutionResult(eu.okaeri.platform.core.plan.ExecutionResult) BukkitTasker(eu.okaeri.tasker.bukkit.BukkitTasker) ReflectGuardian(eu.okaeri.acl.reflect.ReflectGuardian) PlatformScheduler(eu.okaeri.platform.bukkit.scheduler.PlatformScheduler) ExecutionTask(eu.okaeri.platform.core.plan.ExecutionTask) SimplePlaceholdersFactory(eu.okaeri.platform.core.placeholder.SimplePlaceholdersFactory) BukkitCreatorRegistry(eu.okaeri.platform.bukkit.component.BukkitCreatorRegistry) NonNull(lombok.NonNull) PlayerLocaleProvider(eu.okaeri.platform.bukkit.i18n.PlayerLocaleProvider) YamlBukkitConfigurer(eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer) SerdesBukkit(eu.okaeri.configs.yaml.bukkit.serdes.SerdesBukkit) File(java.io.File) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) BukkitCommandsI18nManifestTask(eu.okaeri.platform.bukkit.plan.BukkitCommandsI18nManifestTask) ComponentCreator(eu.okaeri.platform.core.component.creator.ComponentCreator) JavaPluginLoader(org.bukkit.plugin.java.JavaPluginLoader) eu.okaeri.platform.core.plan.task(eu.okaeri.platform.core.plan.task) CommandsI18nSetupTask(eu.okaeri.platform.minecraft.task.CommandsI18nSetupTask) ConfigurerProvider(eu.okaeri.persistence.document.ConfigurerProvider) BukkitCommandsSetupTask(eu.okaeri.platform.bukkit.plan.BukkitCommandsSetupTask) PluginDescriptionFile(org.bukkit.plugin.PluginDescriptionFile) ExecutionPhase(eu.okaeri.platform.core.plan.ExecutionPhase) BukkitExternalResourceProviderSetupTask(eu.okaeri.platform.bukkit.plan.BukkitExternalResourceProviderSetupTask) ConfigurerProvider(eu.okaeri.persistence.document.ConfigurerProvider) SimplePlaceholdersFactory(eu.okaeri.platform.core.placeholder.SimplePlaceholdersFactory) SerdesCommons(eu.okaeri.configs.serdes.commons.SerdesCommons) PlayerLocaleProvider(eu.okaeri.platform.bukkit.i18n.PlayerLocaleProvider) YamlBukkitConfigurer(eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer) BukkitComponentCreator(eu.okaeri.platform.bukkit.component.BukkitComponentCreator) BukkitCommandsI18nManifestTask(eu.okaeri.platform.bukkit.plan.BukkitCommandsI18nManifestTask) CommandsI18nSetupTask(eu.okaeri.platform.minecraft.task.CommandsI18nSetupTask) SerdesBukkit(eu.okaeri.configs.yaml.bukkit.serdes.SerdesBukkit) BukkitCommandsSetupTask(eu.okaeri.platform.bukkit.plan.BukkitCommandsSetupTask) BukkitCreatorRegistry(eu.okaeri.platform.bukkit.component.BukkitCreatorRegistry) PlatformScheduler(eu.okaeri.platform.bukkit.scheduler.PlatformScheduler)

Example 5 with YamlBukkitConfigurer

use of eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer in project FunnyGuilds by FunnyGuilds.

the class FunnybinRequest method execute.

@Override
public void execute() throws Exception {
    List<FunnybinResponse> sentPastes = new ArrayList<>();
    for (int i = 0; i < files.size(); i++) {
        String fileName = files.get(i);
        File file;
        String content = null;
        PasteType type = PasteType.OTHER;
        sender.sendMessage(ChatColor.GREEN + "Wysylam plik: " + ChatColor.AQUA + (i + 1) + ChatColor.GREEN + "/" + ChatColor.AQUA + files.size() + ChatColor.GREEN + "...");
        if ("log".equals(fileName)) {
            file = new File("logs/latest.log");
            type = PasteType.LOGS;
        } else if ("config".equals(fileName)) {
            file = null;
            type = PasteType.CONFIG;
            PluginConfiguration config = ConfigManager.create(PluginConfiguration.class, (it) -> {
                it.withConfigurer(new YamlBukkitConfigurer(), new SerdesCommons());
                it.withBindFile(FunnyGuilds.getInstance().getPluginConfigurationFile());
                it.load();
            });
            config.mysql.hostname = "<CUT>";
            config.mysql.database = "<CUT>";
            config.mysql.user = "<CUT>";
            config.mysql.password = "<CUT>";
            content = config.saveToString();
        } else {
            file = new File(fileName);
        }
        if (content == null) {
            try {
                content = Files.asCharSource(file, StandardCharsets.UTF_8).read();
            } catch (FileNotFoundException e) {
                sender.sendMessage(ChatColor.RED + "Podany plik: " + fileName + " nie istnieje");
                continue;
            } catch (IOException e) {
                sender.sendMessage(ChatColor.RED + "Podany plik: " + fileName + " nie mogl być otworzony (szczegoly w konsoli)");
                FunnyGuilds.getPluginLogger().error("Failed to open a file: " + fileName, e);
                continue;
            }
        }
        try {
            sentPastes.add(FunnyTelemetry.postToFunnybin(content, type, fileName));
        } catch (IOException e) {
            sender.sendMessage(ChatColor.RED + "Podany plik: " + fileName + " nie mogl byc wyslany (szczegoly w konsoli)");
            FunnyGuilds.getPluginLogger().error("Failed to submit a paste: " + fileName, e);
        }
    }
    if (sentPastes.size() == 1) {
        sender.sendMessage(ChatColor.GREEN + "Plik wyslany. Link: " + ChatColor.AQUA + sentPastes.get(0).getShortUrl());
        return;
    }
    sender.sendMessage(ChatColor.GREEN + "Tworze paczke z wyslanych plikow...");
    try {
        FunnybinResponse response = FunnyTelemetry.createBundle(sentPastes.stream().map(FunnybinResponse::getUuid).collect(Collectors.toList()));
        sender.sendMessage(ChatColor.GREEN + "Paczka wyslana. Link: " + ChatColor.AQUA + response.getShortUrl());
    } catch (IOException e) {
        sender.sendMessage(ChatColor.RED + "Wystapil blad podczas tworzenia paczki. ");
        FunnyGuilds.getPluginLogger().error("Failed to submit a bundle. Files: " + files, e);
    }
}
Also used : Arrays(java.util.Arrays) CommandSender(org.bukkit.command.CommandSender) IOException(java.io.IOException) YamlBukkitConfigurer(eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer) Collectors(java.util.stream.Collectors) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) StandardCharsets(java.nio.charset.StandardCharsets) ArrayList(java.util.ArrayList) DefaultConcurrencyRequest(net.dzikoysk.funnyguilds.concurrency.util.DefaultConcurrencyRequest) List(java.util.List) PasteType(net.dzikoysk.funnyguilds.telemetry.PasteType) SerdesCommons(eu.okaeri.configs.serdes.commons.SerdesCommons) FunnyGuilds(net.dzikoysk.funnyguilds.FunnyGuilds) Files(com.google.common.io.Files) PluginConfiguration(net.dzikoysk.funnyguilds.config.PluginConfiguration) Optional(java.util.Optional) ChatColor(org.bukkit.ChatColor) ConfigManager(eu.okaeri.configs.ConfigManager) FunnybinResponse(net.dzikoysk.funnyguilds.telemetry.FunnybinResponse) Collections(java.util.Collections) FunnyTelemetry(net.dzikoysk.funnyguilds.telemetry.FunnyTelemetry) FunnybinResponse(net.dzikoysk.funnyguilds.telemetry.FunnybinResponse) PasteType(net.dzikoysk.funnyguilds.telemetry.PasteType) ArrayList(java.util.ArrayList) SerdesCommons(eu.okaeri.configs.serdes.commons.SerdesCommons) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) YamlBukkitConfigurer(eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer) PluginConfiguration(net.dzikoysk.funnyguilds.config.PluginConfiguration) File(java.io.File)

Aggregations

YamlBukkitConfigurer (eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer)5 SerdesCommons (eu.okaeri.configs.serdes.commons.SerdesCommons)4 OkaeriValidator (eu.okaeri.configs.validator.okaeri.OkaeriValidator)2 File (java.io.File)2 Arrays (java.util.Arrays)2 Files (com.google.common.io.Files)1 ReflectGuardian (eu.okaeri.acl.reflect.ReflectGuardian)1 ConfigManager (eu.okaeri.configs.ConfigManager)1 SerdesBukkit (eu.okaeri.configs.yaml.bukkit.serdes.SerdesBukkit)1 Injector (eu.okaeri.injector.Injector)1 ConfigurerProvider (eu.okaeri.persistence.document.ConfigurerProvider)1 BukkitPlaceholders (eu.okaeri.placeholders.bukkit.BukkitPlaceholders)1 ReflectPlaceholders (eu.okaeri.placeholders.reflect.ReflectPlaceholders)1 BukkitComponentCreator (eu.okaeri.platform.bukkit.component.BukkitComponentCreator)1 BukkitCreatorRegistry (eu.okaeri.platform.bukkit.component.BukkitCreatorRegistry)1 PlayerLocaleProvider (eu.okaeri.platform.bukkit.i18n.PlayerLocaleProvider)1 BukkitCommandsI18nManifestTask (eu.okaeri.platform.bukkit.plan.BukkitCommandsI18nManifestTask)1 BukkitCommandsSetupTask (eu.okaeri.platform.bukkit.plan.BukkitCommandsSetupTask)1 BukkitExternalResourceProviderSetupTask (eu.okaeri.platform.bukkit.plan.BukkitExternalResourceProviderSetupTask)1 PlatformScheduler (eu.okaeri.platform.bukkit.scheduler.PlatformScheduler)1