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());
});
}
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());
});
}
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);
});
}
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());
}
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);
}
}
Aggregations