Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
MessageBuilder: add settings to disable features
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Aug 28, 2023
1 parent 04c715c commit e4dad19
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main/java/net/flectone/messages/MessageBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ public MessageBuilder(@NotNull String command, @NotNull String text, @Nullable C

word = replacePattern(word);

if (itemStack != null && word.equalsIgnoreCase("%item%")) {
if (itemStack != null && word.equalsIgnoreCase("%item%") && config.getBoolean("chat.tooltip.enable")) {
wordParams.setItem(true);
wordParams.setText(itemStack.getItemMeta() != null && !itemStack.getItemMeta().getDisplayName().isEmpty()
? net.md_5.bungee.api.ChatColor.ITALIC + itemStack.getItemMeta().getDisplayName()
: itemStack.getType().name());
return wordParams;
}

if (word.startsWith(pingPrefix)) {
if (word.startsWith(pingPrefix) && config.getBoolean("chat.ping.enable")) {
String playerName = word.replaceFirst(pingPrefix, "");

FPlayer fPlayer = FPlayerManager.getPlayerFromName(playerName);
Expand All @@ -89,7 +89,7 @@ public MessageBuilder(@NotNull String command, @NotNull String text, @Nullable C
}
}

if (word.startsWith("||") && word.endsWith("||") && !word.replace("||", "").isEmpty()) {
if (word.startsWith("||") && word.endsWith("||") && !word.replace("||", "").isEmpty() && config.getBoolean("chat.hide.enable")) {
word = word.replace("||", "");

wordParams.setHideMessage(word);
Expand All @@ -100,7 +100,7 @@ public MessageBuilder(@NotNull String command, @NotNull String text, @Nullable C
}

Matcher urlMatcher = urlPattern.matcher(word);
if (urlMatcher.find()) {
if (urlMatcher.find() && config.getBoolean("chat.url.enable")) {
wordParams.setUrl(word.substring(urlMatcher.start(0), urlMatcher.end(0)));

word = locale.getString("chat.url.message")
Expand All @@ -111,6 +111,7 @@ public MessageBuilder(@NotNull String command, @NotNull String text, @Nullable C

switch (word) {
case "%cords%" -> {
if (!config.getBoolean("chat.cords.enable")) break;
wordParams.setCords(true);

Location location = player.getLocation();
Expand All @@ -123,9 +124,9 @@ public MessageBuilder(@NotNull String command, @NotNull String text, @Nullable C
.replace("<block_z>", String.valueOf(location.getBlockZ()));
}
case "%stats%" -> {
wordParams.setStats(true);

if (!config.getBoolean("chat.stats.enable")) break;

wordParams.setStats(true);

AttributeInstance armor = player.getAttribute(Attribute.GENERIC_ARMOR);
AttributeInstance damage = player.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE);
Expand Down
13 changes: 13 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ chat:
- ":angry: , (╯°□°)╯︵ ┻━┻"
- ":happy: , \(^O^)/"

cords:
enable: true
stats:
enable: true
hide:
enable: true
url:
enable: true
tooltip:
enable: true
ping:
enable: true

death:
message:
enable: true
Expand Down

0 comments on commit e4dad19

Please sign in to comment.