From 03a3905bb0876d07495431146651f29a4eb62eea Mon Sep 17 00:00:00 2001 From: Aso <53526710+AsoDesu@users.noreply.github.com> Date: Sat, 20 Apr 2024 19:07:54 +0100 Subject: [PATCH] fix: remove faction from discord presence --- .../discord/DiscordPresenceUpdator.java | 17 -------------- .../mixins/cosmetics/FontLoaderMixin.java | 15 ------------- .../mixins/network/PacketListenerMixin.java | 20 ----------------- .../options/categories/DiscordOptions.java | 8 ------- .../islandutils/state/MccIslandState.java | 12 ---------- .../islandutils/state/faction/Faction.java | 22 ------------------- .../state/faction/FactionComponents.java | 22 ------------------- 7 files changed, 116 deletions(-) delete mode 100644 src/main/java/net/asodev/islandutils/state/faction/Faction.java delete mode 100644 src/main/java/net/asodev/islandutils/state/faction/FactionComponents.java diff --git a/src/main/java/net/asodev/islandutils/discord/DiscordPresenceUpdator.java b/src/main/java/net/asodev/islandutils/discord/DiscordPresenceUpdator.java index 7d4cae0..824f864 100644 --- a/src/main/java/net/asodev/islandutils/discord/DiscordPresenceUpdator.java +++ b/src/main/java/net/asodev/islandutils/discord/DiscordPresenceUpdator.java @@ -75,20 +75,6 @@ public static void updateTimeLeft(Long endTimestamp) { updateActivity(); } - public static int lastLevel = -1; - public static void setLevel(int level) { - if (activity == null) return; - if (!IslandOptions.getDiscord().showFactionLevel) return; - - lastLevel = level; - String faction = ""; - if (MccIslandState.getFaction() != null) - faction = " (" + MccIslandState.getFaction().getTitle() + ")"; - - try { activity.assets().setSmallText("Level " + level + faction); } - catch (Exception e) { e.printStackTrace(); } - } - public static void updatePlace(Game game) { if (activity == null) return; if (!IslandOptions.getDiscord().showGame) return; @@ -238,9 +224,6 @@ public static void updateFromConfig(DiscordOptions options) { activity.timestamps().setEnd(Instant.ofEpochSecond(0)); } else updatePlace(MccIslandState.getGame()); - if (!options.showFactionLevel) activity.assets().setSmallText(""); - else setLevel(lastLevel); - if (!options.showGameInfo) activity.setState(""); else updatePlace(MccIslandState.getGame()); diff --git a/src/main/java/net/asodev/islandutils/mixins/cosmetics/FontLoaderMixin.java b/src/main/java/net/asodev/islandutils/mixins/cosmetics/FontLoaderMixin.java index 01648ba..cb3b4e7 100644 --- a/src/main/java/net/asodev/islandutils/mixins/cosmetics/FontLoaderMixin.java +++ b/src/main/java/net/asodev/islandutils/mixins/cosmetics/FontLoaderMixin.java @@ -5,8 +5,6 @@ import net.asodev.islandutils.modules.plobby.PlobbyJoinCodeCopy; import net.asodev.islandutils.modules.scavenging.Scavenging; import net.asodev.islandutils.modules.splits.LevelTimer; -import net.asodev.islandutils.state.faction.Faction; -import net.asodev.islandutils.state.faction.FactionComponents; import net.minecraft.client.gui.font.providers.BitmapProvider; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Style; @@ -17,7 +15,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import static net.asodev.islandutils.modules.cosmetics.CosmeticState.MCC_ICONS; -import static net.asodev.islandutils.state.faction.FactionComponents.MCC_ICONS_19; @Mixin(BitmapProvider.Definition.class) public class FontLoaderMixin { @@ -32,7 +29,6 @@ private void init(ResourceLocation file, int i, int j, int[][] chars, CallbackIn String character = builder.toString(); Component comp = Component.literal(character).setStyle(Style.EMPTY.withFont(MCC_ICONS)); - Component factionComp = Component.literal(character).setStyle(Style.EMPTY.withFont(MCC_ICONS_19)); switch (file.getPath()) { case "_fonts/body/blueprint_assembly.png" -> CraftingUI.setAssemblerCharacter(character); case "_fonts/body/fusion_forge.png" -> CraftingUI.setForgeCharacter(character); @@ -46,17 +42,6 @@ private void init(ResourceLocation file, int i, int j, int[][] chars, CallbackIn case "_fonts/medals.png" -> LevelTimer.medalCharacter = character; case "_fonts/split_up.png" -> LevelTimer.splitUpComponent = comp; case "_fonts/split_down.png" -> LevelTimer.splitDownComponent = comp; - - case "_fonts/team/aqua_big.png" -> FactionComponents.setComponent(Faction.AQUA, factionComp); - case "_fonts/team/blue_big.png" -> FactionComponents.setComponent(Faction.BLUE, factionComp); - case "_fonts/team/cyan_big.png" -> FactionComponents.setComponent(Faction.CYAN, factionComp); - case "_fonts/team/green_big.png" -> FactionComponents.setComponent(Faction.GREEN, factionComp); - case "_fonts/team/lime_big.png" -> FactionComponents.setComponent(Faction.LIME, factionComp); - case "_fonts/team/orange_big.png" -> FactionComponents.setComponent(Faction.ORANGE, factionComp); - case "_fonts/team/pink_big.png" -> FactionComponents.setComponent(Faction.PINK, factionComp); - case "_fonts/team/purple_big.png" -> FactionComponents.setComponent(Faction.PURPLE, factionComp); - case "_fonts/team/red_big.png" -> FactionComponents.setComponent(Faction.RED, factionComp); - case "_fonts/team/yellow_big.png" -> FactionComponents.setComponent(Faction.YELLOW, factionComp); } } } diff --git a/src/main/java/net/asodev/islandutils/mixins/network/PacketListenerMixin.java b/src/main/java/net/asodev/islandutils/mixins/network/PacketListenerMixin.java index 2ceb2bf..92431d9 100644 --- a/src/main/java/net/asodev/islandutils/mixins/network/PacketListenerMixin.java +++ b/src/main/java/net/asodev/islandutils/mixins/network/PacketListenerMixin.java @@ -16,7 +16,6 @@ import net.asodev.islandutils.state.Game; import net.asodev.islandutils.modules.cosmetics.CosmeticSlot; import net.asodev.islandutils.modules.cosmetics.CosmeticState; -import net.asodev.islandutils.state.faction.FactionComponents; import net.asodev.islandutils.modules.splits.LevelTimer; import net.asodev.islandutils.util.ChatUtils; import net.asodev.islandutils.util.MusicUtil; @@ -61,25 +60,6 @@ protected PacketListenerMixin(Minecraft minecraft, Connection connection, Common super(minecraft, connection, commonListenerCookie); } - @Inject(method = "handleSetExperience", at = @At("TAIL")) // Get our faction level - public void handleSetExperience(ClientboundSetExperiencePacket clientboundSetExperiencePacket, CallbackInfo ci) { - if (!MccIslandState.isOnline()) return; // We must be online! - DiscordPresenceUpdator.setLevel(clientboundSetExperiencePacket.getExperienceLevel()); // Set our faction level on discord to our XP - } - - String lastCheckedActionBar = ""; - @Inject(method = "setActionBarText", at = @At("TAIL")) // Get our faction! - public void handleSetExperience(ClientboundSetActionBarTextPacket clientboundSetActionBarTextPacket, CallbackInfo ci) { - if (!MccIslandState.isOnline()) return; // Me must be on the island! - String text = clientboundSetActionBarTextPacket.getText().getString(); // Get the string version of our actionbar - if (Objects.equals(lastCheckedActionBar, text)) return; // If the action bar is the same as the last, ignore it - lastCheckedActionBar = text; - - FactionComponents.comps.forEach((faction, component) -> { // Loop over the faction icon characters - if (text.contains(component.getString())) MccIslandState.setFaction(faction); // If we contain it, that's our faction!! - }); - } - // Patterns for the Map & Modifier options on scoreboard final Map scoreboardPatterns = Map.of( "MAP", Pattern.compile("MAP: (?\\w+(?:,? \\w+)*)"), diff --git a/src/main/java/net/asodev/islandutils/options/categories/DiscordOptions.java b/src/main/java/net/asodev/islandutils/options/categories/DiscordOptions.java index 76455c8..5d86f7b 100644 --- a/src/main/java/net/asodev/islandutils/options/categories/DiscordOptions.java +++ b/src/main/java/net/asodev/islandutils/options/categories/DiscordOptions.java @@ -17,7 +17,6 @@ public class DiscordOptions implements OptionsCategory { public boolean showGameInfo = true; public boolean showTimeRemaining = true; public boolean showTimeElapsed = true; - public boolean showFactionLevel = true; @Override public ConfigCategory getCategory() { @@ -51,12 +50,6 @@ public ConfigCategory getCategory() { .controller(TickBoxControllerBuilder::create) .binding(defaults.showTimeElapsed, () -> showTimeElapsed, value -> this.showTimeElapsed = value) .build(); - Option showFactionOption = Option.createBuilder() - .name(Component.translatable("text.autoconfig.islandutils.option.showFactionLevel")) - .description(OptionDescription.of(Component.translatable("text.autoconfig.islandutils.option.showFactionLevel.@Tooltip"))) - .controller(TickBoxControllerBuilder::create) - .binding(defaults.showFactionLevel, () -> showFactionLevel, value -> this.showFactionLevel = value) - .build(); return ConfigCategory.createBuilder() .name(Component.literal("Discord Presence")) @@ -68,7 +61,6 @@ public ConfigCategory getCategory() { .option(showGameInfoOption) .option(showTimeRemainOption) .option(showTimeElapsedOption) - .option(showFactionOption) .build()) .build(); } diff --git a/src/main/java/net/asodev/islandutils/state/MccIslandState.java b/src/main/java/net/asodev/islandutils/state/MccIslandState.java index b439149..a88abfa 100644 --- a/src/main/java/net/asodev/islandutils/state/MccIslandState.java +++ b/src/main/java/net/asodev/islandutils/state/MccIslandState.java @@ -1,8 +1,6 @@ package net.asodev.islandutils.state; import net.asodev.islandutils.IslandUtilsEvents; -import net.asodev.islandutils.discord.DiscordPresenceUpdator; -import net.asodev.islandutils.state.faction.Faction; import net.asodev.islandutils.util.ChatUtils; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; @@ -15,7 +13,6 @@ public class MccIslandState { private static Game game = Game.HUB; private static String modifier = "INACTIVE"; private static String map = "UNKNOWN"; - private static Faction faction; public static String getModifier() { return modifier; @@ -80,15 +77,6 @@ public static String getMap() { return map; } - public static Faction getFaction() { - return faction; - } - public static void setFaction(Faction faction) { - //ChatUtils.debug("Detected Faction: " + faction); - DiscordPresenceUpdator.setLevel(DiscordPresenceUpdator.lastLevel); - MccIslandState.faction = faction; - } - public static boolean isOnline() { ServerData currentServer = Minecraft.getInstance().getCurrentServer(); if (currentServer == null) return false; diff --git a/src/main/java/net/asodev/islandutils/state/faction/Faction.java b/src/main/java/net/asodev/islandutils/state/faction/Faction.java deleted file mode 100644 index 887645a..0000000 --- a/src/main/java/net/asodev/islandutils/state/faction/Faction.java +++ /dev/null @@ -1,22 +0,0 @@ -package net.asodev.islandutils.state.faction; - -public enum Faction { - AQUA("Aqua Axolotls"), - BLUE("Blue Bats"), - CYAN("Cyan Coyotes"), - GREEN("Green Geckos"), - LIME("Lime Llamas"), - ORANGE("Orange Ocelots"), - PINK("Pink Parrots"), - PURPLE("Purple Pandas"), - RED("Red Rabbits"), - YELLOW("Yellow Yaks"); - - private final String title; - Faction(String title) { - this.title = title; - } - public String getTitle() { - return title; - } -} diff --git a/src/main/java/net/asodev/islandutils/state/faction/FactionComponents.java b/src/main/java/net/asodev/islandutils/state/faction/FactionComponents.java deleted file mode 100644 index 0e14dfc..0000000 --- a/src/main/java/net/asodev/islandutils/state/faction/FactionComponents.java +++ /dev/null @@ -1,22 +0,0 @@ -package net.asodev.islandutils.state.faction; - -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; - -import java.util.HashMap; -import java.util.Map; - -public class FactionComponents { - - public final static ResourceLocation MCC_ICONS_19 = new ResourceLocation("mcc", "icon_offset_19"); - public final static Map comps = new HashMap(); - - public static void setComponent(Faction faction, Component component) { - comps.put(faction, component); - } - - public static Component getComponent(Faction faction) { - return comps.get(faction); - } - -}