Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
fix ipc
Browse files Browse the repository at this point in the history
  • Loading branch information
CubeWhy committed Aug 27, 2023
1 parent 010d18b commit 890ebe5
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 38 deletions.
88 changes: 59 additions & 29 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ configurations {
}

repositories {
maven { url = "https://repo.lunarcn.top/repository/maven-public/" }
maven { url = "https://repo.spongepowered.org/repository/maven-public/" }
maven { url = "https://jitpack.io/" }
mavenCentral()
Expand Down Expand Up @@ -51,7 +50,6 @@ dependencies {
include('com.jagrosh:DiscordIPC:0.4') {
exclude module: "gson"
exclude module: "log4j"
exclude module: "json"
}

implementation 'org.jetbrains:annotations:24.0.1'
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/cubewhy/lunarcn/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ public void onInit() {

AccountConfigFile.getInstance().load(); // Accounts

discordIPC = DiscordIPC.startIPC();

// load pinned servers
try {
Call call = HttpUtils.get(pinnedServerApi);
Expand All @@ -97,6 +95,7 @@ public void onInit() {
}

public void onStart() {
discordIPC = DiscordIPC.startIPC(); // Init IPC
MinecraftInstance.fontRenderer = mc.fontRendererObj;
SplashProgress.setProgress(4, "Initializing " + clientName);
Display.setTitle(clientName + " " + clientVersion + " (" + GitUtils.gitBranch + "/" + GitUtils.gitInfo.getProperty("git.commit.id.abbrev") + ")");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.cubewhy.lunarcn.gui.altmanager;

import net.minecraft.client.gui.GuiScreen;
import org.cubewhy.lunarcn.utils.RenderUtils;

import java.awt.*;
import java.util.ArrayList;

import static org.cubewhy.lunarcn.utils.MinecraftInstance.fontRenderer;


public class GuiSkinManager extends GuiScreen {
private int rightX = 0;
private int skinX;
private int skinY;
public final ArrayList<Skin> skins = new ArrayList<>();

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground(); // render bg
// init right x
rightX = this.width / 4;
// render line
this.drawVerticalLine(rightX, 0, this.height, new Color(255, 255, 255).getRGB());
// render the skin list
for (Skin skin : skins) {
renderItem(skin);
skinY += 30; // skull height
}
super.drawScreen(mouseX, mouseY, partialTicks);
}

private void renderItem(Skin skin) {
this.drawString(fontRenderer, skin.getName(), skinX, skinY, new Color(255, 255, 255).getRGB());

}
}
54 changes: 54 additions & 0 deletions src/main/java/org/cubewhy/lunarcn/gui/altmanager/Skin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.cubewhy.lunarcn.gui.altmanager;

import java.io.File;
import java.util.Objects;

public class Skin {
private String name;
private File localFile;

public Skin() {
}

public Skin(String name, File localFile) {
this.name = name;
this.localFile = localFile;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public File getLocalFile() {
return localFile;
}

public void setLocalFile(File localFile) {
this.localFile = localFile;
}

@Override
public String toString() {
return "Skin{" +
"name='" + name + '\'' +
", localFile=" + localFile +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Skin skin = (Skin) o;
return Objects.equals(name, skin.name) && Objects.equals(localFile, skin.localFile);
}

@Override
public int hashCode() {
return Objects.hash(name, localFile);
}
}
12 changes: 7 additions & 5 deletions src/main/java/org/cubewhy/lunarcn/ipc/DiscordIPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.io.FileNotFoundException;
import java.time.OffsetDateTime;

import static org.cubewhy.lunarcn.utils.ClientUtils.logger;
import static org.cubewhy.lunarcn.utils.MinecraftInstance.mc;

public class DiscordIPC {
Expand All @@ -22,18 +23,19 @@ public class DiscordIPC {
@Override
public void onReady(IPCClient client) {
RichPresence.Builder builder = new RichPresence.Builder();
builder.setState("Playing on " + mc.getSession().getUsername() + (UserUtils.isOffline() ? " (Genuine)" : " (Offline)"))
.setDetails("Minecraft 1.8.9")
builder.setState("Loading client")
.setDetails(Client.clientName)
.setStartTimestamp(OffsetDateTime.now())
.setLargeImage("large", "LiqLC")
.setSpectateSecret("look");
.setLargeImage("logo", "ICON")
.setSpectateSecret("Join");
client.sendRichPresence(builder.build());
}
});

client.connect();
return client;
} catch (Throwable ignored) {
} catch (Throwable e) {
logger.catching(e);
return null;
}
}
Expand Down

0 comments on commit 890ebe5

Please sign in to comment.