Skip to content
This repository was archived by the owner on Sep 17, 2026. It is now read-only.

Commit 04a9581

Browse files
authored
UltraStaffChat - Version 5.1.3
2 parents 003cef4 + 66cac37 commit 04a9581

6 files changed

Lines changed: 91 additions & 46 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
build:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2.3.5
9+
- uses: actions/checkout@v2.4.0
1010
- name: Set up JDK 1.8
1111
uses: actions/setup-java@v2
1212
with:

‎pom.xml‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<groupId>dev.hypera</groupId>
2626
<artifactId>UltraStaffChat</artifactId>
27-
<version>5.1.2</version>
27+
<version>5.1.3</version>
2828
<packaging>jar</packaging>
2929

3030
<name>UltraStaffChat</name>
@@ -57,6 +57,14 @@
5757
<pattern>org.bstats</pattern>
5858
<shadedPattern>dev.hypera.ultrastaffchat.metrics</shadedPattern>
5959
</relocation>
60+
<relocation>
61+
<pattern>net.kyori.adventure</pattern>
62+
<shadedPattern>dev.hypera.ultrastaffchat.adventure</shadedPattern>
63+
</relocation>
64+
<relocation>
65+
<pattern>net.kyori.examination</pattern>
66+
<shadedPattern>dev.hypera.ultrastaffchat.examination</shadedPattern>
67+
</relocation>
6068
</relocations>
6169
</configuration>
6270
<executions>
@@ -105,21 +113,21 @@
105113
<dependency>
106114
<groupId>dev.hypera</groupId>
107115
<artifactId>UpdateLib</artifactId>
108-
<version>3.1.2</version>
116+
<version>4.0.0</version>
109117
</dependency>
110118

111119
<!-- Reflections for automatic registry -->
112120
<dependency>
113121
<groupId>org.reflections</groupId>
114122
<artifactId>reflections</artifactId>
115-
<version>0.9.12</version>
123+
<version>0.10.2</version>
116124
</dependency>
117125

118126
<!-- Adventure for advanced messages -->
119127
<dependency>
120128
<groupId>net.kyori</groupId>
121129
<artifactId>adventure-api</artifactId>
122-
<version>4.9.1</version>
130+
<version>4.9.3</version>
123131
</dependency>
124132
<dependency>
125133
<groupId>net.kyori</groupId>

‎src/main/java/dev/hypera/ultrastaffchat/UltraStaffChat.java‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import dev.hypera.ultrastaffchat.utils.Debug;
2727
import dev.hypera.ultrastaffchat.utils.Discord;
2828
import dev.hypera.updatelib.UpdateLib;
29-
import dev.hypera.updatelib.UpdateLibBuilder;
3029
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
3130
import net.md_5.bungee.api.plugin.Plugin;
3231
import org.bstats.bungeecord.Metrics;
@@ -65,10 +64,13 @@ public void onEnable() {
6564
}
6665

6766
adventure = BungeeAudiences.create(this);
68-
updateLib = UpdateLibBuilder.create(getDescription().getVersion(), Common.getResourceId()).setCompleteAction(status -> {
69-
if(status.isAvailable())
70-
Common.logPrefix("&cAn update is available! " + getDescription().getVersion() + " -> " + status.getDistributedVersion());
71-
}).setErrorHandler(error -> {}).build();
67+
updateLib = UpdateLib.builder()
68+
.version(getDescription().getVersion())
69+
.resource(Common.getResourceId())
70+
.handler(status -> {
71+
if (status.isAvailable())
72+
Common.logPrefix("&cAn update is available! " + getDescription().getVersion() + " -> " + status.getDistributedVersion());
73+
}).build();
7274

7375
ListenerManager.setup();
7476
CommandManager.setup();

‎src/main/java/dev/hypera/ultrastaffchat/commands/impl/UltraStaffChatCommand.java‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import net.kyori.adventure.text.format.TextDecoration;
3333
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
3434
import net.md_5.bungee.api.CommandSender;
35+
import net.md_5.bungee.api.connection.ProxiedPlayer;
3536

3637
import java.io.File;
3738
import java.io.FileWriter;
@@ -81,12 +82,12 @@ private void reload(CommandSender sender, Audience audience) {
8182
return;
8283
}
8384

84-
audience.sendMessage(Component.text().append(Component.text().content("[").color(NamedTextColor.GRAY), Component.text().content("UltraStaffChat").color(NamedTextColor.RED).decorate(TextDecoration.BOLD), Component.text().content("] ").color(NamedTextColor.GRAY), Component.text().content("Reloading configuration files...").color(NamedTextColor.GREEN)));
85+
audience.sendMessage(Common.getLogPrefixAdventure().append(Component.text("Reloading configuration files...").color(NamedTextColor.GREEN)));
8586

8687
UltraStaffChat.getConfig().reload();
8788
Discord.reload();
8889

89-
audience.sendMessage(Component.text().append(Component.text().content("[").color(NamedTextColor.GRAY), Component.text().content("UltraStaffChat").color(NamedTextColor.RED).decorate(TextDecoration.BOLD), Component.text().content("] ").color(NamedTextColor.GRAY), Component.text().content("Successfully reloaded configuration files").color(NamedTextColor.GREEN)));
90+
audience.sendMessage(Common.getLogPrefixAdventure().append(Component.text("Successfully reloaded configuration files").color(NamedTextColor.GREEN)));
9091
}
9192

9293
private void debug(CommandSender sender, String[] args, Audience audience) {
@@ -95,6 +96,7 @@ private void debug(CommandSender sender, String[] args, Audience audience) {
9596
return;
9697
}
9798

99+
boolean isPlayer = sender instanceof ProxiedPlayer;
98100
String log;
99101

100102
boolean advanced = false;
@@ -108,17 +110,17 @@ private void debug(CommandSender sender, String[] args, Audience audience) {
108110
}
109111

110112
if(advanced) {
111-
audience.sendMessage(Component.text().append(Component.text().content("[").color(NamedTextColor.GRAY), Component.text().content("UltraStaffChat").color(NamedTextColor.RED).decorate(TextDecoration.BOLD), Component.text().content("] ").color(NamedTextColor.GRAY), Component.text().content("Generating advanced debug log...").color(NamedTextColor.WHITE)));
113+
audience.sendMessage(Common.getLogPrefixAdventure().append(Component.text("Generating advanced debug log...").color(NamedTextColor.WHITE)));
112114
log = generateAdvancedDebugLog();
113115
} else {
114-
audience.sendMessage(Component.text().append(Component.text().content("[").color(NamedTextColor.GRAY), Component.text().content("UltraStaffChat").color(NamedTextColor.RED).decorate(TextDecoration.BOLD), Component.text().content("] ").color(NamedTextColor.GRAY), Component.text().content("Generating debug log...").color(NamedTextColor.WHITE)));
116+
audience.sendMessage(Common.getLogPrefixAdventure().append(Component.text("Generating debug log...").color(NamedTextColor.WHITE)));
115117
log = generateDebugLog();
116118
}
117119

118-
logDebug(audience, log, advanced);
120+
logDebug(audience, isPlayer, log, advanced);
119121
}
120122

121-
private void logDebug(Audience audience, String log, boolean advanced) {
123+
private void logDebug(Audience audience, boolean isPlayer, String log, boolean advanced) {
122124
try {
123125
String filename = "USC-" + TimeUtils.formatFileDateTime(Date.from(Instant.now())) + "-Debug.txt";
124126
File logFolder = new File(UltraStaffChat.getInstance().getDataFolder() + "/logs");
@@ -137,14 +139,20 @@ private void logDebug(Audience audience, String log, boolean advanced) {
137139
String pasteURL = PasteUtils.createPaste(log);
138140
if(pasteURL == null)
139141
throw new Exception();
140-
if(advanced) {
141-
audience.sendMessage(Component.text().append(Component.text().content("[").color(NamedTextColor.GRAY), Component.text().content("UltraStaffChat").color(NamedTextColor.RED).decorate(TextDecoration.BOLD), Component.text().content("] ").color(NamedTextColor.GRAY), Component.text().content("Successfully generated debug log ").color(NamedTextColor.GREEN), Component.text().content("[View]").color(NamedTextColor.GRAY).clickEvent(ClickEvent.openUrl(pasteURL)).hoverEvent(HoverEvent.showText(Component.text().content(pasteURL)))));
142+
143+
Component component;
144+
if (advanced) {
145+
component = Common.getLogPrefixAdventure().append(Component.text("Successfully generated debug log").color(NamedTextColor.GREEN));
146+
if (isPlayer) component = component.append(Component.text(" [View]").color(NamedTextColor.GRAY).clickEvent(ClickEvent.openUrl(pasteURL)).hoverEvent(HoverEvent.showText(Component.text(pasteURL))));
142147
} else {
143-
audience.sendMessage(Component.text().append(LegacyComponentSerializer.legacy('&').deserialize(log).clickEvent(ClickEvent.openUrl(pasteURL))));
148+
component = Common.adventurise(log);
149+
if (isPlayer) component = component.clickEvent(ClickEvent.openUrl(pasteURL));
144150
}
151+
audience.sendMessage(component);
152+
if (!isPlayer) audience.sendMessage(Common.getLogPrefixAdventure().append(Component.text(pasteURL).color(NamedTextColor.GRAY)));
145153
} catch (Exception e) {
146154
Common.logPrefix("Failed to generate debug log!");
147-
audience.sendMessage(Component.text().append(Component.text().content("[").color(NamedTextColor.GRAY), Component.text().content("UltraStaffChat").color(NamedTextColor.RED).decorate(TextDecoration.BOLD), Component.text().content("] ").color(NamedTextColor.GRAY), Component.text().content("Failed to generate debug log").color(NamedTextColor.RED)));
155+
audience.sendMessage(Common.getLogPrefixAdventure().append(Component.text("Failed to generate debug log").color(NamedTextColor.RED)));
148156
}
149157
}
150158

‎src/main/java/dev/hypera/ultrastaffchat/utils/Common.java‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public class Common {
3737

3838
private static final String logPrefix = "&7[&c&lUltraStaffChat&7] &f";
3939
private static final String errorPrefix = "&7[&4&lError&7] &4";
40+
private static final Component logPrefixAdventure = adventurise(logPrefix);
41+
private static final Component errorPrefixAdventure = adventurise(errorPrefix);
4042

4143
private static final int bStatsId = 5040;
4244
private static final long resourceId = 68956;
@@ -164,6 +166,42 @@ public static Component message(String key) {
164166
return adventurise(messageRaw(key));
165167
}
166168

169+
/**
170+
* Get the legacy ampersand log prefix
171+
*
172+
* @return (String) prefix.
173+
*/
174+
public static String getLogPrefix() {
175+
return logPrefix;
176+
}
177+
178+
/**
179+
* Get the legacy ampersand error prefix
180+
*
181+
* @return (String) error prefix.
182+
*/
183+
public static String getErrorPrefix() {
184+
return errorPrefix;
185+
}
186+
187+
/**
188+
* Get the component log prefix
189+
*
190+
* @return (Component) prefix.
191+
*/
192+
public static Component getLogPrefixAdventure() {
193+
return logPrefixAdventure;
194+
}
195+
196+
/**
197+
* Get the component error prefix
198+
*
199+
* @return (Component) error prefix.
200+
*/
201+
public static Component getErrorPrefixAdventure() {
202+
return errorPrefixAdventure;
203+
}
204+
167205
/**
168206
* Turns a message into an Adventure Component.
169207
*

‎src/main/java/dev/hypera/ultrastaffchat/utils/Discord.java‎

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import dev.hypera.ultrastaffchat.UltraStaffChat;
2222
import dev.hypera.ultrastaffchat.utils.DiscordWebhook.EmbedObject;
23-
import net.md_5.bungee.api.ChatColor;
2423
import net.md_5.bungee.api.CommandSender;
2524
import net.md_5.bungee.api.ProxyServer;
2625
import net.md_5.bungee.api.connection.ProxiedPlayer;
@@ -37,35 +36,25 @@ public class Discord {
3736
private static String hookURL = "";
3837

3938
public static void setup() {
40-
if(!UltraStaffChat.getConfig().getBoolean("discord-enabled").equals(true))
39+
Configuration config = UltraStaffChat.getConfig().getConfiguration();
40+
if(!config.getBoolean("discord-enabled"))
4141
return;
42-
if(UltraStaffChat.getConfig().getString("discord-webhook") == null || UltraStaffChat.getConfig().getString("discord-webhook").contains("XXXXXXXXXXXXXXXXXX")) {
42+
if(config.getString("discord-webhook") == null || config.getString("discord-webhook").contains("XXXXXXXXXXXXXXXXXX")) {
4343
Common.logPrefix("&cError: Discord messages are enabled but the webhook URL has not been configured!");
4444
return;
4545
}
4646

47-
Configuration config = UltraStaffChat.getConfig().getConfiguration();
48-
if (config.getSection("discord-format.embed.fields").getKeys().size() > 25) {
49-
Common.logPrefix("&cError: You can have a max of 25 fields in an embed.");
50-
return;
51-
} else if (config.getSection("discord-join-format.embed.fields").getKeys().size() > 25) {
52-
Common.logPrefix("&cError: You can have a max of 25 fields in an embed.");
53-
return;
54-
} else if (config.getSection("discord-leave-format.embed.fields").getKeys().size() > 25) {
55-
Common.logPrefix("&cError: You can have a max of 25 fields in an embed.");
56-
return;
57-
} else if (config.getSection("discord-switch-format.embed.fields").getKeys().size() > 25) {
58-
Common.logPrefix("&cError: You can have a max of 25 fields in an embed.");
59-
return;
60-
} else if (config.getSection("discord-afk-enable-format.embed.fields").getKeys().size() > 25) {
61-
Common.logPrefix("&cError: You can have a max of 25 fields in an embed.");
62-
return;
63-
} else if (config.getSection("discord-afk-disable-format.embed.fields").getKeys().size() > 25) {
47+
if (config.getSection("discord-format.embed.fields").getKeys().size() > 25
48+
|| config.getSection("discord-join-format.embed.fields").getKeys().size() > 25
49+
|| config.getSection("discord-leave-format.embed.fields").getKeys().size() > 25
50+
|| config.getSection("discord-switch-format.embed.fields").getKeys().size() > 25
51+
|| config.getSection("discord-afk-enable-format.embed.fields").getKeys().size() > 25
52+
|| config.getSection("discord-afk-disable-format.embed.fields").getKeys().size() > 25) {
6453
Common.logPrefix("&cError: You can have a max of 25 fields in an embed.");
6554
return;
6655
}
6756

68-
hookURL = UltraStaffChat.getConfig().getString("discord-webhook");
57+
hookURL = config.getString("discord-webhook");
6958
enabled = true;
7059
}
7160

@@ -79,7 +68,7 @@ public static boolean isEnabled() {
7968
}
8069

8170
public static void broadcastDiscordJoin(ProxiedPlayer p) {
82-
if(!isEnabled())
71+
if(!isEnabled() && UltraStaffChat.getConfig().getConfiguration().getBoolean("discord-join-messages"))
8372
return;
8473
ProxyServer.getInstance().getScheduler().runAsync(UltraStaffChat.getInstance(), () -> {
8574
try {
@@ -113,7 +102,7 @@ public static void broadcastDiscordJoin(ProxiedPlayer p) {
113102
}
114103

115104
public static void broadcastDiscordLeave(ProxiedPlayer p) {
116-
if(!isEnabled())
105+
if(!isEnabled() && UltraStaffChat.getConfig().getConfiguration().getBoolean("discord-leave-messages"))
117106
return;
118107
ProxyServer.getInstance().getScheduler().runAsync(UltraStaffChat.getInstance(), () -> {
119108
try {
@@ -148,7 +137,7 @@ public static void broadcastDiscordLeave(ProxiedPlayer p) {
148137
}
149138

150139
public static void broadcastDiscordSwitch(ProxiedPlayer p, String from, String to) {
151-
if(!isEnabled())
140+
if(!isEnabled() && UltraStaffChat.getConfig().getConfiguration().getBoolean("discord-switch-messages"))
152141
return;
153142
ProxyServer.getInstance().getScheduler().runAsync(UltraStaffChat.getInstance(), () -> {
154143
try {
@@ -226,7 +215,7 @@ public static void broadcastDiscordStaffChatMessage(CommandSender s, String mess
226215
}
227216

228217
public static void broadcastDiscordAFKEnable(ProxiedPlayer p) {
229-
if(!isEnabled())
218+
if(!isEnabled() && UltraStaffChat.getConfig().getConfiguration().getBoolean("discord-afk-enable-messages"))
230219
return;
231220
ProxyServer.getInstance().getScheduler().runAsync(UltraStaffChat.getInstance(), () -> {
232221
try {
@@ -261,7 +250,7 @@ public static void broadcastDiscordAFKEnable(ProxiedPlayer p) {
261250
}
262251

263252
public static void broadcastDiscordAFKDisable(ProxiedPlayer p) {
264-
if(!isEnabled())
253+
if(!isEnabled() && UltraStaffChat.getConfig().getConfiguration().getBoolean("discord-afk-disable-messages"))
265254
return;
266255
ProxyServer.getInstance().getScheduler().runAsync(UltraStaffChat.getInstance(), () -> {
267256
try {

0 commit comments

Comments
 (0)