From c5cef72a2b481f25e7a51a6f3fe2655ebbb4adea Mon Sep 17 00:00:00 2001 From: Firepup Sixfifty Date: Mon, 5 May 2025 07:39:45 -0500 Subject: [PATCH] git squash: Indenting, more flexible icon support bump actions runner version bump plugin version --- .github/workflows/build.yml | 2 +- BetterChannelIcons/build.gradle.kts | 5 +++-- .../plugins/betterchannelicons/Utils.java | 21 ++++++++++++------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0106a5b0..3ed41724 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ on: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@master diff --git a/BetterChannelIcons/build.gradle.kts b/BetterChannelIcons/build.gradle.kts index 67b2528c..6a808c45 100644 --- a/BetterChannelIcons/build.gradle.kts +++ b/BetterChannelIcons/build.gradle.kts @@ -1,11 +1,12 @@ -version = "1.3.7" +version = "1.3.8" description = "Adds an array of new channel icons" aliucord.changelog.set( """ Improved {improved marginTop} ====================== + * Added support for startswith:, endswith:, and contains: for channel name matching. -firepup650 * Discord v126.18 """.trimIndent() -) \ No newline at end of file +) diff --git a/BetterChannelIcons/src/main/java/xyz/wingio/plugins/betterchannelicons/Utils.java b/BetterChannelIcons/src/main/java/xyz/wingio/plugins/betterchannelicons/Utils.java index 3432c955..244dfc1e 100644 --- a/BetterChannelIcons/src/main/java/xyz/wingio/plugins/betterchannelicons/Utils.java +++ b/BetterChannelIcons/src/main/java/xyz/wingio/plugins/betterchannelicons/Utils.java @@ -47,11 +47,16 @@ public static Integer getChannelIcon(ChannelWrapper channel) throws Throwable { if(icons.containsKey(name)) return com.aliucord.Utils.getResId(icons.get(name), "drawable"); if(name.endsWith("-logs") || name.endsWith("-log")) return R.e.ic_channels_24dp; if(name.endsWith("-support") || name.endsWith("-help")) return R.e.ic_help_24dp; + for (String key : icons.keySet()) { + if (key.startsWith("startswith:") && name.startsWith(key.split(":", 2)[1])) return com.aliucord.Utils.getResId(icons.get(key), "drawable"); + if (key.startsWith("endswith:") && name.endsWith(key.split(":", 2)[1])) return com.aliucord.Utils.getResId(icons.get(key), "drawable"); + if (key.startsWith("contains:") && name.contains(key.split(":", 2)[1])) return com.aliucord.Utils.getResId(icons.get(key), "drawable"); + } if(channel.getId() == 824357609778708580L) return R.e.ic_theme_24dp; if(channel.getType() == Channel.GUILD_VOICE) { - if(name.startsWith("discord.gg/") || name.startsWith(".gg/") || name.startsWith("gg/") || name.startsWith("dsc.gg/")) return R.e.ic_diag_link_24dp; - if(name.startsWith("member count") || name.startsWith("members") || name.startsWith("member count")) return R.e.ic_people_white_24dp; - return voiceChannelIcons.get(name); + if(name.startsWith("discord.gg/") || name.startsWith(".gg/") || name.startsWith("gg/") || name.startsWith("dsc.gg/")) return R.e.ic_diag_link_24dp; + if(name.startsWith("member count") || name.startsWith("members") || name.startsWith("member count")) return R.e.ic_people_white_24dp; + return voiceChannelIcons.get(name); } return channelIcons.get(name); } @@ -115,11 +120,11 @@ public static Map convertToNewFormat(Map icons) Map newIcons = new HashMap<>(); Map iconNameMap = Constants.getIconNameMap(); List keys = new ArrayList<>(icons.keySet()); - for(String key : keys){ - Integer iconIndex = icons.get(key); - Integer icon = Constants.getIcons().get(iconIndex); - newIcons.put(key, iconNameMap.get(icon)); + for(String key : keys) { + Integer iconIndex = icons.get(key); + Integer icon = Constants.getIcons().get(iconIndex); + newIcons.put(key, iconNameMap.get(icon)); } return newIcons; } -} \ No newline at end of file +}