use of com.almightyalpaca.jetbrains.plugins.discord.data.FileInfo in project Intellij-Discord-Integration by Almighty-Alpaca.
the class PresenceRenderer method apply.
@Nullable
@Override
public DiscordRichPresence apply(@NotNull PresenceRenderContext context) {
LOG.trace("DiscordRichPresence#apply({})", context);
if (context.isEmpty())
return null;
InstanceInfo instance = context.getInstance();
ProjectInfo project = context.getProject();
FileInfo file = context.getFile();
DiscordRichPresence presence = new DiscordRichPresence();
if (instance != null) {
InstanceInfo.DistributionInfo distribution = instance.getDistribution();
if (project != null) {
presence.details = "Working on " + project.getName();
presence.startTimestamp = project.getTimeOpened() / 1000;
if (project.getSettings().getDescription() != null) {
presence.state = project.getSettings().getDescription();
} else if (file != null && instance.getSettings().isShowFiles()) {
presence.state = (file.isReadOnly() && instance.getSettings().isShowReadingInsteadOfWriting() ? "Reading " : "Editing ") + (instance.getSettings().isShowFileExtensions() ? file.getName() : file.getBaseName());
presence.largeImageKey = file.getAssetName(instance.getSettings().isShowUnknownImageFile()) + "-large";
presence.largeImageText = file.getLanguageName();
presence.smallImageKey = distribution.getAssetName(instance.getSettings().isShowUnknownImageIDE()) + "-small";
presence.smallImageText = "Using " + distribution.getName() + " version " + distribution.getVersion();
}
}
if (presence.largeImageKey == null || presence.largeImageKey.equals("none-large")) {
presence.largeImageKey = distribution.getAssetName(instance.getSettings().isShowUnknownImageIDE()) + "-large";
presence.largeImageText = "Using " + distribution.getName() + " version " + distribution.getVersion();
presence.smallImageKey = null;
presence.smallImageText = null;
}
}
return presence;
}
Aggregations