mirror of https://github.com/kami-blue/client
Feature/rpcusers (#369)
* update rpc to use different images * fuck around until it works idk * add debugging code * make everything work now! * fix image names and descriptions * add case 3 and 4 * fix typo
This commit is contained in:
parent
e8b68f195c
commit
403219901d
|
@ -19,14 +19,13 @@ import me.zeroeightsix.kami.module.Module;
|
||||||
import me.zeroeightsix.kami.module.ModuleManager;
|
import me.zeroeightsix.kami.module.ModuleManager;
|
||||||
import me.zeroeightsix.kami.module.modules.bewwawho.capes.Capes;
|
import me.zeroeightsix.kami.module.modules.bewwawho.capes.Capes;
|
||||||
import me.zeroeightsix.kami.module.modules.bewwawho.misc.BlueDiscordRPC;
|
import me.zeroeightsix.kami.module.modules.bewwawho.misc.BlueDiscordRPC;
|
||||||
import me.zeroeightsix.kami.module.modules.bewwawho.player.AntiChunkLoadPatch;
|
|
||||||
import me.zeroeightsix.kami.module.modules.zeroeightysix.misc.CustomChat;
|
import me.zeroeightsix.kami.module.modules.zeroeightysix.misc.CustomChat;
|
||||||
import me.zeroeightsix.kami.module.modules.zeroeightysix.render.TabFriends;
|
import me.zeroeightsix.kami.module.modules.zeroeightysix.render.TabFriends;
|
||||||
import me.zeroeightsix.kami.setting.Setting;
|
import me.zeroeightsix.kami.setting.Setting;
|
||||||
import me.zeroeightsix.kami.setting.Settings;
|
import me.zeroeightsix.kami.setting.Settings;
|
||||||
import me.zeroeightsix.kami.setting.SettingsRegister;
|
import me.zeroeightsix.kami.setting.SettingsRegister;
|
||||||
import me.zeroeightsix.kami.setting.config.Configuration;
|
import me.zeroeightsix.kami.setting.config.Configuration;
|
||||||
import me.zeroeightsix.kami.util.bewwawho.Donator;
|
import me.zeroeightsix.kami.util.bewwawho.RichPresence;
|
||||||
import me.zeroeightsix.kami.util.zeroeightysix.Friends;
|
import me.zeroeightsix.kami.util.zeroeightysix.Friends;
|
||||||
import me.zeroeightsix.kami.util.zeroeightysix.LagCompensator;
|
import me.zeroeightsix.kami.util.zeroeightysix.LagCompensator;
|
||||||
import me.zeroeightsix.kami.util.zeroeightysix.Wrapper;
|
import me.zeroeightsix.kami.util.zeroeightysix.Wrapper;
|
||||||
|
@ -49,6 +48,7 @@ import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,10 +106,41 @@ public class KamiMod {
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void postInit(FMLPostInitializationEvent event) {
|
public void postInit(FMLPostInitializationEvent event) {
|
||||||
for (Donator.DonatorUser user : Donator.INSTANCE.donatorUsers) {
|
if (RichPresence.INSTANCE.customUsers != null) {
|
||||||
if (user.uuid.equalsIgnoreCase(Minecraft.getMinecraft().session.getProfile().getId().toString())) {
|
for (RichPresence.CustomUser user : RichPresence.INSTANCE.customUsers) {
|
||||||
DiscordPresence.presence.smallImageKey = "donator2";
|
if (user.uuid.equalsIgnoreCase(Minecraft.getMinecraft().session.getProfile().getId().toString())) {
|
||||||
DiscordPresence.presence.smallImageText = "donator uwu";
|
switch (Integer.parseInt(user.type)) {
|
||||||
|
case 0: {
|
||||||
|
DiscordPresence.presence.smallImageKey = "booster";
|
||||||
|
DiscordPresence.presence.smallImageText = "booster uwu";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
DiscordPresence.presence.smallImageKey = "inviter";
|
||||||
|
DiscordPresence.presence.smallImageText = "inviter owo";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
DiscordPresence.presence.smallImageKey = "giveaway";
|
||||||
|
DiscordPresence.presence.smallImageText = "giveaway winner";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: {
|
||||||
|
DiscordPresence.presence.smallImageKey = "contest";
|
||||||
|
DiscordPresence.presence.smallImageText = "contest winner";
|
||||||
|
}
|
||||||
|
case 4: {
|
||||||
|
DiscordPresence.presence.smallImageKey = "nine";
|
||||||
|
DiscordPresence.presence.smallImageText = "900th member";
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
DiscordPresence.presence.smallImageKey = "donator2";
|
||||||
|
DiscordPresence.presence.smallImageText = "donator <3";
|
||||||
|
System.out.println("oof rpc failed. type: " + user.type.getClass().getSimpleName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,8 +173,8 @@ public class KamiMod {
|
||||||
new Capes();
|
new Capes();
|
||||||
KamiMod.log.info("Capes init!\n");
|
KamiMod.log.info("Capes init!\n");
|
||||||
|
|
||||||
new Donator();
|
new RichPresence();
|
||||||
KamiMod.log.info("Donators init!\n");
|
KamiMod.log.info("Rich Presence Users init!\n");
|
||||||
|
|
||||||
// After settings loaded, we want to let the enabled modules know they've been enabled (since the setting is done through reflection)
|
// After settings loaded, we want to let the enabled modules know they've been enabled (since the setting is done through reflection)
|
||||||
ModuleManager.getModules().stream().filter(Module::isEnabled).forEach(Module::enable);
|
ModuleManager.getModules().stream().filter(Module::isEnabled).forEach(Module::enable);
|
||||||
|
|
|
@ -10,25 +10,26 @@ import java.net.URL;
|
||||||
/***
|
/***
|
||||||
* @author S-B99
|
* @author S-B99
|
||||||
*/
|
*/
|
||||||
public class Donator {
|
public class RichPresence {
|
||||||
|
|
||||||
public static Donator INSTANCE;
|
public static RichPresence INSTANCE;
|
||||||
public DonatorUser[] donatorUsers;
|
public CustomUser[] customUsers;
|
||||||
|
|
||||||
public class DonatorUser {
|
public class CustomUser {
|
||||||
public String uuid;
|
public String uuid;
|
||||||
|
public String type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Donator() {
|
public RichPresence() {
|
||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
try {
|
try {
|
||||||
HttpsURLConnection connection = (HttpsURLConnection) new URL(KamiMod.DONATORS_JSON).openConnection();
|
HttpsURLConnection connection = (HttpsURLConnection) new URL(KamiMod.DONATORS_JSON).openConnection();
|
||||||
connection.connect();
|
connection.connect();
|
||||||
this.donatorUsers = new Gson().fromJson(new InputStreamReader(connection.getInputStream()), DonatorUser[].class);
|
this.customUsers = new Gson().fromJson(new InputStreamReader(connection.getInputStream()), CustomUser[].class);
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
KamiMod.log.error("Failed to load donators");
|
KamiMod.log.error("Failed to load donators");
|
||||||
// e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue