Skip to content

Commit 671fe10

Browse files
committed
fix: actually replace placeholders in certain place + fix some warnings
1 parent d3dfd2d commit 671fe10

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

bukkit/src/main/java/me/anutley/dislink/bukkit/DisLinkBukkitLoader.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import me.anutley.dislink.common.DisLink;
2828
import org.bukkit.plugin.java.JavaPlugin;
2929

30-
import java.io.File;
31-
3230
public class DisLinkBukkitLoader extends JavaPlugin {
3331
@Override
3432
public void onEnable() {

common/src/main/java/me/anutley/dislink/common/delivery/sender/MessageSender.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void execute() {
143143
messages = getMessagesSplit(getPlaceholderReplacedMessage(messageSettingKey()), Strategy.ANYWHERE);
144144
}
145145

146-
if (StringUtil.isEmpty(message.getContentRaw()) && message.getEmbeds().size() == 0) { // only a file has been sent, needs slightly different logic
146+
if (StringUtil.isEmpty(message.getContentRaw()) && message.getEmbeds().isEmpty()) { // only a file has been sent, needs slightly different logic
147147
sendOnlyFiles(d);
148148
return;
149149
}
@@ -212,7 +212,7 @@ private void sendOnlyFiles(D deliveryMethod) {
212212
private void editAttachments(M messageBuilder, D deliveryMethod, long messageId) {
213213
AtomicReference<Map<String, List<InputStream>>> attachments = new AtomicReference<>(new HashMap<>());
214214

215-
if (getAttachments().size() == 0) return;
215+
if (getAttachments().isEmpty()) return;
216216

217217
CompletableFuture.runAsync(() -> {
218218

@@ -251,7 +251,7 @@ public AllowedMentionsBuilder getAllowedMentions() {
251251

252252
protected List<MessageEmbed> getEmbeds() {
253253
if (disLink.settingsUtil().getBoolean(pairConfig, "ignore.embeds")) {
254-
if (message.getEmbeds().size() > 0) {
254+
if (!message.getEmbeds().isEmpty()) {
255255
disLink.debug("Embeds in the original message were found, but are not being forwarded due to being ignored");
256256
}
257257
return null;
@@ -263,7 +263,7 @@ protected List<MessageEmbed> getEmbeds() {
263263
protected List<Message.Attachment> getAttachments() {
264264

265265
if (disLink.settingsUtil().getBoolean(pairConfig, "ignore.attachments")) {
266-
if (message.getAttachments().size() > 0) {
266+
if (!message.getAttachments().isEmpty()) {
267267
disLink.debug("Attachments in the original message were found, but are not being forwarded due to being ignored");
268268
}
269269
return Collections.emptyList();
@@ -309,10 +309,10 @@ protected String replaceDefaultMessagePlaceholders(String format) {
309309
}
310310
}
311311

312-
format = format.replaceAll("author_nickname", memberNull ? author.getName() : member.getEffectiveName())
313-
.replaceAll("author_guild_avatar", memberNull ? author.getEffectiveAvatarUrl() : member.getEffectiveAvatarUrl())
314-
.replaceAll("author_toprole_name", topRole == null ? "" : topRole.getName())
315-
.replaceAll("author_toprole_mention", topRole == null ? "" : topRole.getAsMention());
312+
format = format.replaceAll("%author_nickname%", memberNull ? author.getName() : member.getEffectiveName())
313+
.replaceAll("%author_guild_avatar%", memberNull ? author.getEffectiveAvatarUrl() : member.getEffectiveAvatarUrl())
314+
.replaceAll("%author_toprole_name%", topRole == null ? "" : topRole.getName())
315+
.replaceAll("%author_toprole_mention%", topRole == null ? "" : topRole.getAsMention());
316316

317317

318318
format = replaceChannelPlaceholders(format, "origin", originChannel());

common/src/main/java/me/anutley/dislink/common/util/StringUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727
public class StringUtil {
2828

2929
public static boolean isEmpty(String string) {
30-
return string == null || string.trim().equals("");
30+
return string == null || string.trim().isEmpty();
3131
}
3232
}

0 commit comments

Comments
 (0)