Skip to content

Commit 0ac0d36

Browse files
committed
Fix excessive append usage
1 parent bd2e146 commit 0ac0d36

31 files changed

Lines changed: 265 additions & 266 deletions

File tree

SilverstoneGlobal/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>net.silverstonemc</groupId>
88
<artifactId>SilverstoneGlobal</artifactId>
9-
<version>7.7.1</version>
9+
<version>7.7.2</version>
1010

1111
<properties>
1212
<maven.compiler.source>21</maven.compiler.source>

SilverstoneGlobal/src/main/java/net/silverstonemc/silverstoneglobal/commands/Effects.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
3434

3535
for (PotionEffect effect : player.getActivePotionEffects())
3636
sender.sendMessage(Component.text(
37-
effect.getType().getKey().value()
38-
.toUpperCase() + " " + (effect.getAmplifier() + 1),
39-
NamedTextColor.AQUA).append(Component.text(" | ", NamedTextColor.DARK_AQUA))
40-
.append(Component.text((effect.getDuration() / 20) + "s", NamedTextColor.AQUA)));
37+
effect.getType().getKey().value().toUpperCase() + " " + (effect.getAmplifier() + 1),
38+
NamedTextColor.AQUA).append(
39+
Component.text(" | ", NamedTextColor.DARK_AQUA),
40+
Component.text((effect.getDuration() / 20) + "s", NamedTextColor.AQUA)));
4141

4242
} else sender.sendMessage(Component.text("Please provide an online player!", NamedTextColor.RED));
4343
return true;

SilverstoneGlobal/src/main/java/net/silverstonemc/silverstoneglobal/commands/Help.java

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,44 +23,41 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
2323
switch (plugin.getConfig().getString("server").toLowerCase()) {
2424
case "minigames" -> plugin.getServer().dispatchCommand(sender, "htp");
2525

26-
case "creative" -> sender.sendMessage(Component.empty().append(Component.text(
27-
"\nCommands:",
28-
NamedTextColor.GREEN,
29-
TextDecoration.BOLD))
26+
case "creative" -> sender.sendMessage(Component.empty().append(
27+
Component.text("\nCommands:", NamedTextColor.GREEN, TextDecoration.BOLD),
3028

31-
.append(Component.text("\n/p claim ", NamedTextColor.AQUA)
32-
.clickEvent(ClickEvent.runCommand("/p claim"))).append(Component.text("on an unclaimed plot to get started",
33-
NamedTextColor.GREEN))
29+
Component.text("\n/p claim ", NamedTextColor.AQUA)
30+
.clickEvent(ClickEvent.runCommand("/p claim")),
31+
Component.text("on an unclaimed plot to get started", NamedTextColor.GREEN),
3432

35-
.append(Component.text("\n/p home [#] ", NamedTextColor.AQUA)
36-
.clickEvent(ClickEvent.suggestCommand("/p home "))).append(Component.text("to teleport to your plot(s)",
37-
NamedTextColor.GREEN))
33+
Component.text("\n/p home [#] ", NamedTextColor.AQUA)
34+
.clickEvent(ClickEvent.suggestCommand("/p home ")),
35+
Component.text("to teleport to your plot(s)", NamedTextColor.GREEN),
3836

39-
.append(Component.text("\n/p set ", NamedTextColor.AQUA)
40-
.clickEvent(ClickEvent.suggestCommand("/p set "))).append(Component.text("to see multiple plot options",
41-
NamedTextColor.GREEN))
37+
Component.text("\n/p set ", NamedTextColor.AQUA)
38+
.clickEvent(ClickEvent.suggestCommand("/p set ")),
39+
Component.text("to see multiple plot options", NamedTextColor.GREEN),
4240

43-
.append(Component.text("\n/p merge all ", NamedTextColor.AQUA)
44-
.clickEvent(ClickEvent.suggestCommand("/p merge all"))).append(Component.text("to merge all your plots together",
45-
NamedTextColor.GREEN))
41+
Component.text("\n/p merge all ", NamedTextColor.AQUA)
42+
.clickEvent(ClickEvent.suggestCommand("/p merge all")),
43+
Component.text("to merge all your plots together", NamedTextColor.GREEN),
4644

47-
.append(Component.text("\n/p clear ", NamedTextColor.AQUA)
48-
.clickEvent(ClickEvent.suggestCommand("/p clear"))).append(Component.text("to clear your plot",
49-
NamedTextColor.GREEN))
45+
Component.text("\n/p clear ", NamedTextColor.AQUA)
46+
.clickEvent(ClickEvent.suggestCommand("/p clear")),
47+
Component.text("to clear your plot", NamedTextColor.GREEN),
5048

51-
.append(Component.text("\n/p delete ", NamedTextColor.AQUA)
52-
.clickEvent(ClickEvent.suggestCommand("/p delete"))).append(Component.text("to delete your plot",
53-
NamedTextColor.GREEN))
49+
Component.text("\n/p delete ", NamedTextColor.AQUA)
50+
.clickEvent(ClickEvent.suggestCommand("/p delete")),
51+
Component.text("to delete your plot", NamedTextColor.GREEN),
5452

55-
.append(Component.text("\n/stuck ", NamedTextColor.AQUA)
56-
.clickEvent(ClickEvent.runCommand("/stuck")))
57-
.append(Component.text("if trapped in a plot", NamedTextColor.GREEN))
53+
Component.text("\n/stuck ", NamedTextColor.AQUA).clickEvent(ClickEvent.runCommand("/stuck")),
54+
Component.text("if trapped in a plot", NamedTextColor.GREEN),
5855

59-
.append(Component.text("\n/wesui toggle ", NamedTextColor.AQUA)
60-
.clickEvent(ClickEvent.runCommand("/wesui toggle")))
61-
.append(Component.text("to toggle the selection particles", NamedTextColor.GREEN))
56+
Component.text("\n/wesui toggle ", NamedTextColor.AQUA)
57+
.clickEvent(ClickEvent.runCommand("/wesui toggle")),
6258

63-
.append(Component.text(
59+
Component.text("to toggle the selection particles", NamedTextColor.GREEN),
60+
Component.text(
6461
"\nLow-effort plots are deleted after 60 days of inactivity.",
6562
NamedTextColor.RED,
6663
TextDecoration.BOLD)));

SilverstoneGlobal/src/main/java/net/silverstonemc/silverstoneglobal/commands/Restart.java

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ public void run() {
7171
plugin.getLogger().info("Server restarting in: " + sec[0]);
7272

7373
TextComponent evacuate = Component.text(
74-
"Click ",
75-
NamedTextColor.RED,
76-
TextDecoration.BOLD).append(Component
77-
.text("here", NamedTextColor.GRAY, TextDecoration.UNDERLINED)
78-
.clickEvent(ClickEvent.runCommand("/server " + finalServer)))
79-
.append(Component.text(" to evacuate!", NamedTextColor.RED));
74+
"Click ",
75+
NamedTextColor.RED,
76+
TextDecoration.BOLD).append(
77+
Component.text("here", NamedTextColor.GRAY, TextDecoration.UNDERLINED)
78+
.clickEvent(ClickEvent.runCommand("/server " + finalServer)),
79+
Component.text(" to evacuate!", NamedTextColor.RED));
8080

8181
switch (sec[0]) {
8282
case 10 -> {
@@ -183,16 +183,12 @@ public void run() {
183183

184184
case "schedulerestart" -> {
185185
for (Player player : Bukkit.getOnlinePlayers()) {
186-
player.sendMessage(Component.text().append(Component.text(
187-
"WARNING",
188-
NamedTextColor.RED,
189-
TextDecoration.BOLD)).append(Component.text(
190-
" > ",
191-
NamedTextColor.AQUA,
192-
TextDecoration.BOLD)).append(Component.text(
193-
"The server is scheduled to restart in ",
194-
NamedTextColor.GREEN)).append(Component.text("5", NamedTextColor.AQUA))
195-
.append(Component.text(" minutes!", NamedTextColor.GREEN)));
186+
player.sendMessage(Component.text().append(
187+
Component.text("WARNING", NamedTextColor.RED, TextDecoration.BOLD),
188+
Component.text(" > ", NamedTextColor.AQUA, TextDecoration.BOLD),
189+
Component.text("The server is scheduled to restart in ", NamedTextColor.GREEN),
190+
Component.text("5", NamedTextColor.AQUA),
191+
Component.text(" minutes!", NamedTextColor.GREEN)));
196192

197193
player.playSound(
198194
player.getLocation(),
@@ -208,15 +204,14 @@ public void run() {
208204
@Override
209205
public void run() {
210206
for (Player player : Bukkit.getOnlinePlayers()) {
211-
player.sendMessage(Component.text().append(Component.text(
212-
"WARNING",
213-
NamedTextColor.RED,
214-
TextDecoration.BOLD)).append(Component.text(
215-
" > ",
216-
NamedTextColor.AQUA,
217-
TextDecoration.BOLD)).append(Component.text("The server is scheduled to restart in ",
218-
NamedTextColor.GREEN)).append(Component.text("1", NamedTextColor.AQUA))
219-
.append(Component.text(" minute!", NamedTextColor.GREEN)));
207+
player.sendMessage(Component.text().append(
208+
Component.text("WARNING", NamedTextColor.RED, TextDecoration.BOLD),
209+
Component.text(" > ", NamedTextColor.AQUA, TextDecoration.BOLD),
210+
Component.text(
211+
"The server is scheduled to restart in ",
212+
NamedTextColor.GREEN),
213+
Component.text("1", NamedTextColor.AQUA),
214+
Component.text(" minute!", NamedTextColor.GREEN)));
220215

221216
player.playSound(
222217
player.getLocation(),

SilverstoneGlobal/src/main/java/net/silverstonemc/silverstoneglobal/commands/UpdateCommands.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
4545
if (cooldowns.containsKey(player.getName()))
4646
if (cooldowns.get(player.getName()) > System.currentTimeMillis()) {
4747
// Still on cooldown
48-
player.sendMessage(Component.text(
49-
"You may update your commands again in ",
50-
NamedTextColor.RED)
51-
.append(Component.text(
52-
(cooldowns.get(player.getName()) - System.currentTimeMillis()) / 1000,
53-
NamedTextColor.GRAY)).append(Component.text(" seconds.", NamedTextColor.RED)));
48+
player.sendMessage(Component
49+
.text("You may update your commands again in ", NamedTextColor.RED).append(
50+
Component.text(
51+
(cooldowns.get(player.getName()) - System.currentTimeMillis()) / 1000,
52+
NamedTextColor.GRAY), Component.text(" seconds.", NamedTextColor.RED)));
53+
5454
return true;
5555
}
5656

SilverstoneGlobal/src/main/java/net/silverstonemc/silverstoneglobal/commands/guis/BuyGUI.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class BuyGUI implements CommandExecutor, Listener {
2727
public BuyGUI(JavaPlugin plugin) {
2828
this.plugin = plugin;
2929
}
30-
30+
3131
private final JavaPlugin plugin;
3232

3333
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String @NotNull [] args) {
@@ -100,7 +100,11 @@ private Gui inventory() {
100100
}
101101

102102
private enum Rank {
103-
MEMBER("Member"), VIP("VIP"), VIP_PLUS("VIP+"), MVP("MVP"), DONATE("Donate");
103+
MEMBER("Member"),
104+
VIP("VIP"),
105+
VIP_PLUS("VIP+"),
106+
MVP("MVP"),
107+
DONATE("Donate");
104108

105109
private final String name;
106110

@@ -131,10 +135,10 @@ private List<Component> getItemLore(Rank rank) {
131135
}
132136

133137
private void sendMessage(Player player, String rank, String url, ClickContext context) {
134-
player.sendMessage(Component.text("\nPurchase the ", NamedTextColor.GREEN)
135-
.append(Component.text(rank + " ", NamedTextColor.AQUA))
136-
.append(Component.text("rank ", NamedTextColor.GREEN))
137-
.append(Component.text("here", NamedTextColor.AQUA).clickEvent(ClickEvent.openUrl(url))));
138+
player.sendMessage(Component.text("\nPurchase the ", NamedTextColor.GREEN).append(
139+
Component.text(rank + " ", NamedTextColor.AQUA),
140+
Component.text("rank ", NamedTextColor.GREEN),
141+
Component.text("here", NamedTextColor.AQUA).clickEvent(ClickEvent.openUrl(url))));
138142

139143
context.guiView().close();
140144
}

SilverstoneGlobal/src/main/java/net/silverstonemc/silverstoneglobal/discord/Errors.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.silverstonemc.silverstoneglobal.discord;
22

3+
import net.dv8tion.jda.api.utils.MarkdownUtil;
34
import net.silverstonemc.silverstoneglobal.SilverstoneGlobal;
45
import org.apache.logging.log4j.Level;
56
import org.apache.logging.log4j.LogManager;
@@ -64,12 +65,12 @@ public void remove() {
6465
public void dumpQueue() {
6566
if (errorQueue.isEmpty()) return;
6667

67-
StringBuilder builder = new StringBuilder("```accesslog\n");
68+
StringBuilder builder = new StringBuilder();
6869
List<String> finalErrorQueue = new ArrayList<>(errorQueue);
6970
for (String error : finalErrorQueue) {
7071
if (builder.length() + error.length() >= 1997) {
7172
if (canSendMessage()) sendDiscordMessage(builder);
72-
builder = new StringBuilder("```accesslog\n");
73+
builder = new StringBuilder();
7374
}
7475

7576
builder.append(error).append("\n");
@@ -105,9 +106,8 @@ private boolean canSendMessage() {
105106
}
106107

107108
private void sendDiscordMessage(StringBuilder builder) {
108-
builder.append("```");
109109
//noinspection DataFlowIssue
110-
SilverstoneGlobal.jda.getTextChannelById(1076713224612880404L).sendMessage(builder.toString())
111-
.queue();
110+
SilverstoneGlobal.jda.getTextChannelById(1076713224612880404L).sendMessage(MarkdownUtil.codeblock("accesslog",
111+
builder.toString())).queue();
112112
}
113113
}

SilverstoneMain/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>net.silverstonemc</groupId>
88
<artifactId>SilverstoneMain</artifactId>
9-
<version>4.0.6</version>
9+
<version>4.0.7</version>
1010

1111
<properties>
1212
<maven.compiler.source>21</maven.compiler.source>

SilverstoneMain/src/main/java/net/silverstonemc/silverstonemain/commands/GettingStarted.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,30 @@ public boolean onCommand(CommandSender sender, @NotNull Command cmd, @NotNull St
2222
NamedTextColor.DARK_GRAY,
2323
TextDecoration.STRIKETHROUGH));
2424

25-
sender.sendMessage(Component.text("/htp", TextColor.fromHexString("#305abf"))
26-
.clickEvent(ClickEvent.suggestCommand("/htp"))
27-
28-
.append(Component.text(" - Open the How to Play menu\n", TextColor.fromHexString("#18c1c7")))
29-
.append(Component.text("/warp", TextColor.fromHexString("#305abf"))
30-
.clickEvent(ClickEvent.runCommand("/warp"))).append(Component.text(" - List all available warps\n",
31-
TextColor.fromHexString("#18c1c7")))
32-
33-
.append(Component.text("/server", TextColor.fromHexString("#305abf"))
34-
.clickEvent(ClickEvent.runCommand("/server"))).append(Component.text(" - List all available servers\n",
35-
TextColor.fromHexString("#18c1c7")))
36-
37-
.append(Component.text("/tips", TextColor.fromHexString("#305abf"))
38-
.clickEvent(ClickEvent.runCommand("/tips"))).append(Component.text(" - View tips about the network\n",
39-
TextColor.fromHexString("#18c1c7")))
40-
41-
.append(Component.text("/game", TextColor.fromHexString("#305abf"))
42-
.clickEvent(ClickEvent.runCommand("/game"))).append(Component.text(" - Get a random minigame to play\n",
43-
TextColor.fromHexString("#18c1c7")))
44-
45-
.append(Component.text("/prefixes", TextColor.fromHexString("#305abf"))
46-
.clickEvent(ClickEvent.runCommand("/prefixes"))).append(Component.text(
47-
" - Display what the prefix emojis mean\n",
48-
TextColor.fromHexString("#18c1c7"))));
25+
sender.sendMessage(Component.empty().append(
26+
Component.text("/htp", TextColor.fromHexString("#305abf"))
27+
.clickEvent(ClickEvent.suggestCommand("/htp")),
28+
Component.text(" - Open the How to Play menu\n", TextColor.fromHexString("#18c1c7")),
29+
30+
Component.text("/warp", TextColor.fromHexString("#305abf"))
31+
.clickEvent(ClickEvent.runCommand("/warp")),
32+
Component.text(" - List all available warps\n", TextColor.fromHexString("#18c1c7")),
33+
34+
Component.text("/server", TextColor.fromHexString("#305abf"))
35+
.clickEvent(ClickEvent.runCommand("/server")),
36+
Component.text(" - List all available servers\n", TextColor.fromHexString("#18c1c7")),
37+
38+
Component.text("/tips", TextColor.fromHexString("#305abf"))
39+
.clickEvent(ClickEvent.runCommand("/tips")),
40+
Component.text(" - View tips about the network\n", TextColor.fromHexString("#18c1c7")),
41+
42+
Component.text("/game", TextColor.fromHexString("#305abf"))
43+
.clickEvent(ClickEvent.runCommand("/game")),
44+
Component.text(" - Get a random minigame to play\n", TextColor.fromHexString("#18c1c7")),
45+
46+
Component.text("/prefixes", TextColor.fromHexString("#305abf"))
47+
.clickEvent(ClickEvent.runCommand("/prefixes")),
48+
Component.text(" - Display what the prefix emojis mean\n", TextColor.fromHexString("#18c1c7"))));
4949
return true;
5050
}
5151
}

SilverstoneMinigames/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>net.silverstonemc</groupId>
88
<artifactId>SilverstoneMinigames</artifactId>
9-
<version>4.2.1</version>
9+
<version>4.2.2</version>
1010

1111
<properties>
1212
<maven.compiler.source>21</maven.compiler.source>

0 commit comments

Comments
 (0)