Skip to content

Commit 3af3f27

Browse files
committed
Replace use of deprecated code
1 parent ab01e75 commit 3af3f27

56 files changed

Lines changed: 324 additions & 334 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Plan/bukkit/src/main/java/com/djrapitops/plan/commands/use/BukkitPartBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public MessageBuilder hover(String... lines) {
8989
@Override
9090
public MessageBuilder hover(Collection<String> lines) {
9191
ComponentBuilder hoverMsg = new ComponentBuilder("");
92-
hoverMsg.append(new TextStringBuilder().appendWithSeparators(lines, "\n").build());
92+
hoverMsg.append(new TextStringBuilder().appendWithSeparators(lines, "\n").get());
9393
part.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverMsg.create()));
9494
return this;
9595
}

Plan/bungeecord/src/main/java/com/djrapitops/plan/command/use/BungeePartBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public MessageBuilder hover(String... lines) {
8181
@Override
8282
public MessageBuilder hover(Collection<String> lines) {
8383
ComponentBuilder hoverMsg = new ComponentBuilder("");
84-
hoverMsg.append(new TextStringBuilder().appendWithSeparators(lines, "\n").build());
84+
hoverMsg.append(new TextStringBuilder().appendWithSeparators(lines, "\n").get());
8585
part.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(hoverMsg.create())));
8686
return this;
8787
}

Plan/common/src/main/java/com/djrapitops/plan/commands/use/AdventureMessageBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public MessageBuilder hover(String... strings) {
9292
@Override
9393
public MessageBuilder hover(Collection<String> lines) {
9494
TextComponent.Builder hoverText = Component.text();
95-
hoverText.append(Component.text(new TextStringBuilder().appendWithSeparators(lines, "\n").build()));
95+
hoverText.append(Component.text(new TextStringBuilder().appendWithSeparators(lines, "\n").get()));
9696
previousComponent = previousComponent.hoverEvent(HoverEvent.showText(hoverText.build()));
9797
return this;
9898
}

Plan/common/src/main/java/com/djrapitops/plan/commands/use/Arguments.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public Arguments removeFirst() {
8080
}
8181

8282
public String concatenate(String separator) {
83-
return new TextStringBuilder().appendWithSeparators(args, separator).build();
83+
return new TextStringBuilder().appendWithSeparators(args, separator).get();
8484
}
8585

8686
public boolean isEmpty() {

Plan/common/src/main/java/com/djrapitops/plan/delivery/export/NetworkPageExporter.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.djrapitops.plan.storage.database.Database;
2828
import com.djrapitops.plan.storage.file.PlanFiles;
2929
import org.apache.commons.lang3.StringUtils;
30+
import org.apache.commons.lang3.Strings;
3031
import org.apache.commons.text.StringEscapeUtils;
3132

3233
import javax.inject.Inject;
@@ -62,6 +63,21 @@ public NetworkPageExporter(
6263
this.jsonHandler = jsonHandler;
6364
}
6465

66+
public static String[] getRedirections() {
67+
return new String[]{
68+
"network",
69+
"network/overview",
70+
"network/serversOverview",
71+
"network/sessions",
72+
"network/playerbase",
73+
"network/join-addresses",
74+
"network/retention",
75+
"network/players",
76+
"network/geolocations",
77+
"network/plugins-overview",
78+
};
79+
}
80+
6581
/**
6682
* Perform export for a network page.
6783
*
@@ -80,21 +96,6 @@ public void export(Path toDirectory, Server server) throws IOException {
8096
exportReactRedirects(toDirectory);
8197
}
8298

83-
public static String[] getRedirections() {
84-
return new String[]{
85-
"network",
86-
"network/overview",
87-
"network/serversOverview",
88-
"network/sessions",
89-
"network/playerbase",
90-
"network/join-addresses",
91-
"network/retention",
92-
"network/players",
93-
"network/geolocations",
94-
"network/plugins-overview",
95-
};
96-
}
97-
9899
private void exportReactRedirects(Path toDirectory) throws IOException {
99100
exportReactRedirects(toDirectory, files, config, getRedirections());
100101
}
@@ -177,7 +178,7 @@ private String toRelativePathFromRoot(String resourceName) {
177178
}
178179

179180
private String toNonRelativePath(String resourceName) {
180-
return StringUtils.remove(StringUtils.remove(resourceName, "../"), "./");
181+
return Strings.CI.remove(Strings.CI.remove(resourceName, "../"), "./");
181182
}
182183

183184
}

Plan/common/src/main/java/com/djrapitops/plan/delivery/export/PlayerPageExporter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.djrapitops.plan.storage.database.queries.PlayerFetchQueries;
2828
import com.djrapitops.plan.storage.file.PlanFiles;
2929
import org.apache.commons.lang3.StringUtils;
30+
import org.apache.commons.lang3.Strings;
3031

3132
import javax.inject.Inject;
3233
import javax.inject.Singleton;
@@ -135,7 +136,7 @@ private String toRelativePathFromRoot(String resourceName) {
135136
}
136137

137138
private String toNonRelativePath(String resourceName) {
138-
return StringUtils.remove(StringUtils.remove(resourceName, "../"), "./");
139+
return Strings.CI.remove(Strings.CI.remove(resourceName, "../"), "./");
139140
}
140141

141142
}

Plan/common/src/main/java/com/djrapitops/plan/delivery/export/PlayersPageExporter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.djrapitops.plan.storage.database.Database;
2828
import com.djrapitops.plan.storage.file.PlanFiles;
2929
import org.apache.commons.lang3.StringUtils;
30+
import org.apache.commons.lang3.Strings;
3031

3132
import javax.inject.Inject;
3233
import javax.inject.Singleton;
@@ -43,14 +44,13 @@
4344
@Singleton
4445
public class PlayersPageExporter extends FileExporter {
4546

47+
private static final String PLAYERS_TABLE = "playersTable";
4648
private final PlanFiles files;
4749
private final PlanConfig config;
4850
private final DBSystem dbSystem;
4951
private final RootJSONResolver jsonHandler;
5052
private final ServerInfo serverInfo;
51-
5253
private final ExportPaths exportPaths;
53-
private static final String PLAYERS_TABLE = "playersTable";
5454

5555
@Inject
5656
public PlayersPageExporter(
@@ -91,7 +91,7 @@ private void exportJSON(Path toDirectory) throws IOException {
9191

9292
export(toDirectory.resolve("data").resolve(jsonResourceName),
9393
// Replace ../player in urls to fix player page links
94-
StringUtils.replace(response.getAsString(), "../player", toRelativePathFromRoot("player"))
94+
Strings.CI.replace(response.getAsString(), "../player", toRelativePathFromRoot("player"))
9595
);
9696
exportPaths.put("./v1/" + PLAYERS_TABLE, toRelativePathFromRoot("data/" + jsonResourceName));
9797
}
@@ -115,7 +115,7 @@ private String toRelativePathFromRoot(String resourceName) {
115115
}
116116

117117
private String toNonRelativePath(String resourceName) {
118-
return StringUtils.remove(resourceName, "../");
118+
return Strings.CI.remove(resourceName, "../");
119119
}
120120

121121
}

Plan/common/src/main/java/com/djrapitops/plan/delivery/export/ServerPageExporter.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.djrapitops.plan.storage.database.Database;
3030
import com.djrapitops.plan.storage.file.PlanFiles;
3131
import org.apache.commons.lang3.StringUtils;
32+
import org.apache.commons.lang3.Strings;
3233
import org.apache.commons.text.StringEscapeUtils;
3334

3435
import javax.inject.Inject;
@@ -71,24 +72,6 @@ public ServerPageExporter(
7172
exportPaths = new ExportPaths();
7273
}
7374

74-
/**
75-
* Perform export for a server page.
76-
*
77-
* @param toDirectory Path to Export directory
78-
* @param server Server to export
79-
* @throws IOException If a template can not be read from jar/disk or the result written
80-
* @throws NotFoundException If a file or resource that is being exported can not be found
81-
*/
82-
public void export(Path toDirectory, Server server) throws IOException {
83-
Database.State dbState = dbSystem.getDatabase().getState();
84-
if (dbState == Database.State.CLOSED || dbState == Database.State.CLOSING) return;
85-
86-
exportPaths.put("../network", toRelativePathFromRoot("network"));
87-
exportJSON(toDirectory, server);
88-
exportReactRedirects(toDirectory, server.getUuid());
89-
exportPaths.clear();
90-
}
91-
9275
public static String[] getRedirections(ServerUUID serverUUID) {
9376
String server = "server/";
9477
return new String[]{
@@ -108,6 +91,24 @@ public static String[] getRedirections(ServerUUID serverUUID) {
10891
};
10992
}
11093

94+
/**
95+
* Perform export for a server page.
96+
*
97+
* @param toDirectory Path to Export directory
98+
* @param server Server to export
99+
* @throws IOException If a template can not be read from jar/disk or the result written
100+
* @throws NotFoundException If a file or resource that is being exported can not be found
101+
*/
102+
public void export(Path toDirectory, Server server) throws IOException {
103+
Database.State dbState = dbSystem.getDatabase().getState();
104+
if (dbState == Database.State.CLOSED || dbState == Database.State.CLOSING) return;
105+
106+
exportPaths.put("../network", toRelativePathFromRoot("network"));
107+
exportJSON(toDirectory, server);
108+
exportReactRedirects(toDirectory, server.getUuid());
109+
exportPaths.clear();
110+
}
111+
111112
private void exportReactRedirects(Path toDirectory, ServerUUID serverUUID) throws IOException {
112113
exportReactRedirects(toDirectory, files, config, getRedirections(serverUUID));
113114
}
@@ -167,7 +168,7 @@ private void exportJSON(Path toDirectory, String resource) throws IOException {
167168

168169
export(toDirectory.resolve("data").resolve(jsonResourceName),
169170
// Replace ../player in urls to fix player page links
170-
StringUtils.replace(
171+
Strings.CI.replace(
171172
response.getAsString(),
172173
StringEscapeUtils.escapeJson("../player"),
173174
StringEscapeUtils.escapeJson(toRelativePathFromRoot("player"))
@@ -195,7 +196,7 @@ private String toRelativePathFromRoot(String resourceName) {
195196
}
196197

197198
private String toNonRelativePath(String resourceName) {
198-
return StringUtils.remove(StringUtils.remove(resourceName, "../"), "./");
199+
return Strings.CI.remove(Strings.CI.remove(resourceName, "../"), "./");
199200
}
200201

201202
}

Plan/common/src/main/java/com/djrapitops/plan/delivery/formatting/time/TimeAmountFormatter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import com.djrapitops.plan.delivery.formatting.Formatter;
2020
import com.djrapitops.plan.settings.config.PlanConfig;
2121
import com.djrapitops.plan.settings.config.paths.FormatSettings;
22-
import org.apache.commons.lang3.StringUtils;
22+
import org.apache.commons.lang3.Strings;
2323

2424
/**
2525
* Formatter for time amount in milliseconds.
@@ -74,7 +74,7 @@ public String apply(Long ms) {
7474
appendMinutes(builder, minutes, hours, hourFormat, minuteFormat);
7575
appendSeconds(builder, seconds, minutes, hours, hourFormat, minuteFormat, secondFormat);
7676

77-
String formattedTime = StringUtils.remove(builder.toString(), ZERO_PH);
77+
String formattedTime = Strings.CS.remove(builder.toString(), ZERO_PH);
7878
if (formattedTime.isEmpty()) {
7979
return config.get(FormatSettings.ZERO_SECONDS);
8080
}

Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/BundleAddressCorrection.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.djrapitops.plan.settings.config.PlanConfig;
2121
import com.djrapitops.plan.settings.config.paths.WebserverSettings;
2222
import org.apache.commons.lang3.StringUtils;
23+
import org.apache.commons.lang3.Strings;
2324
import org.jetbrains.annotations.Nullable;
2425

2526
import javax.inject.Inject;
@@ -92,7 +93,7 @@ private String correctAddressInHtml(String content, String basePath) {
9293

9394
private String correctAddressInCss(String content, String basePath) {
9495
String endingSlash = basePath.endsWith("/") ? "" : "/";
95-
return StringUtils.replace(content, "/static", basePath + endingSlash + STATIC);
96+
return Strings.CS.replace(content, "/static", basePath + endingSlash + STATIC);
9697
}
9798

9899
private String correctAddressInJavascript(String content, String basePath) {
@@ -134,7 +135,7 @@ private String correctAddressInJavascript(String content, String basePath) {
134135
// "./Filename-hash.js" -> "./Filename-hash.js" or "/plan/static/Filename-hash.js"
135136
// "/static/Filename-hash.js" -> "/static/Filename-hash.js" or "/plan/static/Filename-hash.js"
136137
// "static/Filename-hash.js" -> "static/Filename-hash.js" or "plan/static/Filename-hash.js"
137-
String replacementAddress = StringUtils.equalsAny(addressStart, "/static", STATIC)
138+
String replacementAddress = Strings.CS.equalsAny(addressStart, "/static", STATIC)
138139
? staticReplacement
139140
: relativeReplacement;
140141
String replacement = '"' + replacementAddress + file + '.' + extension + '"';

0 commit comments

Comments
 (0)