use of eu.okaeri.configs.serdes.commons.SerdesCommons 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.serdes.commons.SerdesCommons 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.serdes.commons.SerdesCommons 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