use of com.github.vaerys.objects.PatchObject in project DiscordSailv2 by Vaerys-Dawn.
the class PatchHandler method renameToggles.
private static void renameToggles(IGuild guild) {
PatchObject patch = getJsonConfig(guild, GuildConfig.FILE_PATH, 1.4, "RenameToggles");
if (patch == null)
return;
boolean welcome = patch.getObject().get("joinsServerMessages").getAsBoolean();
boolean initial = patch.getObject().get("welcomeMessage").getAsBoolean();
patch.getObject().remove("joinsServerMessages");
patch.getObject().remove("welcomeMessage");
patch.getObject().addProperty("welcomeMessages", welcome);
patch.getObject().addProperty("initialMessage", initial);
finalizePatch(patch);
}
use of com.github.vaerys.objects.PatchObject in project DiscordSailv2 by Vaerys-Dawn.
the class PatchHandler method refactorTrustedToInviteAllowed.
private static void refactorTrustedToInviteAllowed(IGuild guild) {
PatchObject patch = getJsonConfig(guild, GuildConfig.FILE_PATH, 1.3, "Refactor_Trusted_To_Invite_Allowed");
if (patch == null)
return;
JsonArray array = patch.getObject().get("trustedRoleIDs").getAsJsonArray();
patch.getObject().remove("trustedRoleIDs");
if (array.size() != 0) {
patch.getObject().addProperty("inviteAllowedID", array.get(0).getAsLong());
}
finalizePatch(patch);
}
use of com.github.vaerys.objects.PatchObject in project DiscordSailv2 by Vaerys-Dawn.
the class PatchHandler method changeChannelSettingsToEnum.
private static void changeChannelSettingsToEnum(IGuild guild) {
PatchObject json = getJsonConfig(guild, ChannelData.FILE_PATH, 1.2, "Change_ChannelSettings_To_Enum");
if (json == null)
return;
JsonArray channelSettings = json.getObject().getAsJsonArray("channelSettings");
for (int i = 0; i < channelSettings.size(); i++) {
JsonObject object = channelSettings.get(i).getAsJsonObject();
String type = object.get("type").getAsString();
object.remove("type");
ChannelSetting setting = ChannelSetting.get(type);
if (setting == null) {
channelSettings.remove(i);
i--;
} else {
object.addProperty("type", setting.name());
}
}
finalizePatch(json);
}
use of com.github.vaerys.objects.PatchObject in project DiscordSailv2 by Vaerys-Dawn.
the class PatchHandler method updateChannelTypesForCodeConventions.
private static void updateChannelTypesForCodeConventions(IGuild guild) {
PatchObject json = getJsonConfig(guild, ChannelData.FILE_PATH, 1.3, "");
if (json == null)
return;
JsonArray channelSettings = json.getObject().getAsJsonArray("channelSettings");
for (int i = 0; i < channelSettings.size(); i++) {
JsonObject object = channelSettings.get(i).getAsJsonObject();
String type = object.get("type").getAsString();
switch(type) {
case "CHANNEL_CC":
object.addProperty("type", ChannelSetting.CC_INFO.name());
break;
case "CHANNEL_CHARACTERS":
object.addProperty("type", ChannelSetting.CHARACTER.name());
break;
case "CREATE_CC":
object.addProperty("type", ChannelSetting.MANAGE_CC.name());
break;
case "CHANNEL_INFO":
object.addProperty("type", ChannelSetting.INFO.name());
break;
}
}
finalizePatch(json);
}
use of com.github.vaerys.objects.PatchObject in project DiscordSailv2 by Vaerys-Dawn.
the class PatchHandler method moveChannelsToChannelData.
private static void moveChannelsToChannelData(IGuild guild) {
PatchObject jsonConfig = getJsonConfig(guild, GuildConfig.FILE_PATH, 1.2, "Move_Channels_To_Channel_Data_2");
PatchObject jsonChannel = getJsonConfig(guild, ChannelData.FILE_PATH, 1.1, "Move_Channels_To_Channel_Data_1");
if (jsonConfig == null || jsonChannel == null)
return;
JsonArray array = jsonConfig.getObject().getAsJsonArray("channelSettings");
jsonChannel.getObject().add("channelSettings", array);
finalizePatch(jsonConfig);
finalizePatch(jsonChannel);
}
Aggregations