Skip to content

Commit

Permalink
Added chat formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
778b committed Nov 21, 2022
1 parent 6154407 commit e7e3832
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 114 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.lofrol.UselessClan.ClanObjects;

import io.github.lofrol.UselessClan.Utils.ChatSender;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
Expand Down Expand Up @@ -237,15 +238,16 @@ public Clan(String ClanPrefix, String CreatorName) {

public void SendMessageForOnlinePlayers(String Message) {
for (Player tempPlayer : OnlineMembers.keySet()) {
tempPlayer.sendMessage(String.format("[%s] %s", PrefixClan, Message));
ChatSender.MessageTo(tempPlayer, PrefixClan, Message);
}
}

public void SendMessageForOnlineOfficers(String Message) {
String FormattedPrefix = "&9" + PrefixClan;
for (Player tempPlayer : OnlineMembers.keySet()) {
ClanRole tempRole = OnlineMembers.get(tempPlayer).getMemberRole();
if (tempRole == ClanRole.OFFICER || tempRole == ClanRole.LEADER) {
tempPlayer.sendMessage(String.format("[%s] %s", PrefixClan, Message));
ChatSender.MessageTo(tempPlayer, FormattedPrefix, Message);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

public class ChatSender {
public static void MessageTo(Player recipient, String prefix, String message) {
recipient.sendMessage(ChatColor.translateAlternateColorCodes('&', String.format("&f[%s&f] %s%s", prefix, DefaultColor, message)));
recipient.sendMessage(ChatColor.translateAlternateColorCodes('&', String.format("&f[&8%s&f] &b%s", prefix, message)));
}

public static String DefaultColor = "&b";
}
Loading

0 comments on commit e7e3832

Please sign in to comment.