Add support for 1.19 paper
All checks were successful
continuous-integration/drone/tag Build is passing

This commit is contained in:
Jonttuuu 2022-07-27 17:38:32 +03:00
parent 3db153e360
commit 50c386951a

View File

@ -55,21 +55,53 @@ public final class FlexConnect extends JavaPlugin {
// Check paper config // Check paper config
boolean paperConfigModified = false; boolean paperConfigModified = false;
final YamlConfiguration paperConfig = this.getServer().spigot().getPaperConfig(); final YamlConfiguration paperConfig = this.getServer().spigot().getPaperConfig();
if (!paperConfig.getBoolean("settings.velocity-support.enabled")) {
paperConfig.set("settings.velocity-support.enabled", true); // Legacy paper configs (1.18 or older)
paperConfigModified = true; if (paperConfig.contains("settings.velocity-support.enabled")) {
if (!paperConfig.getBoolean("settings.velocity-support.enabled")) {
paperConfig.set("settings.velocity-support.enabled", true);
paperConfigModified = true;
}
} }
if (!paperConfig.getBoolean("settings.velocity-support.enabled")) { if (paperConfig.contains("settings.velocity-support.online-mode")) {
paperConfig.set("settings.velocity-support.online-mode", true); if (!paperConfig.getBoolean("settings.velocity-support.online-mode")) {
paperConfigModified = true; paperConfig.set("settings.velocity-support.online-mode", true);
paperConfigModified = true;
}
} }
if (!paperConfig.getString("settings.velocity-support.secret").equals("flexplex")) { if (paperConfig.contains("settings.velocity-support.secret")) {
paperConfig.set("settings.velocity-support.secret", "flexplex"); if (!paperConfig.getString("settings.velocity-support.secret").equals("flexplex")) {
paperConfigModified = true; paperConfig.set("settings.velocity-support.secret", "flexplex");
paperConfigModified = true;
}
} }
if (paperConfig.getBoolean("settings.unsupported-settings.perform-username-validation")) {
paperConfig.set("settings.unsupported-settings.perform-username-validation", false); // Current paper configurations 1.19+
paperConfigModified = true; if (paperConfig.contains("proxies.velocity.enabled")) {
if (!paperConfig.getBoolean("proxies.velocity.enabled")) {
paperConfig.set("proxies.velocity.enabled", true);
paperConfigModified = true;
}
}
if (paperConfig.contains("proxies.velocity.online-mode")) {
if (!paperConfig.getBoolean("proxies.velocity.online-mode")) {
paperConfig.set("proxies.velocity.online-mode", true);
paperConfigModified = true;
}
}
if (paperConfig.contains("proxies.velocity.secret")) {
if (!paperConfig.getString("proxies.velocity.secret").equals("flexplex")) {
paperConfig.set("proxies.velocity.secret", "flexplex");
paperConfigModified = true;
}
}
// In both configurations
if (paperConfig.contains("settings.unsupported-settings.perform-username-validation")) {
if (paperConfig.getBoolean("settings.unsupported-settings.perform-username-validation")) {
paperConfig.set("settings.unsupported-settings.perform-username-validation", false);
paperConfigModified = true;
}
} }
if (paperConfigModified) { if (paperConfigModified) {