Skip to content

Commit

Permalink
feat: minimessage support
Browse files Browse the repository at this point in the history
  • Loading branch information
JiveOff committed Sep 13, 2024
1 parent dec740f commit 2024723
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
28 changes: 19 additions & 9 deletions src/realms/rest/endpoints/services/Party.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ApiError } from "../../helpers/Error"
import { sendMessageToPlayer } from "../../helpers/SendMessage"
import RedisClient from "../../../../clients/Redis"
import PlayerService from "./Player.service"
import { ampersandColorToName } from "../../helpers/Colors"

@Service()
export default class PartyService {
Expand All @@ -26,12 +27,17 @@ export default class PartyService {
private static sendMessageToPlayer(
proxyServer: string,
uuid: string,
message: string
message: string,
mini = false
) {
return sendMessageToPlayer(proxyServer, "PARTY", uuid, message)
return sendMessageToPlayer(proxyServer, "PARTY", uuid, message, mini)
}

public static async sendMessageToParty(partyId: number, message: string) {
public static async sendMessageToParty(
partyId: number,
message: string,
mini = false
) {
const party = await prisma.party.findUnique({
where: {
id: partyId
Expand Down Expand Up @@ -66,7 +72,8 @@ export default class PartyService {
await PartyService.sendMessageToPlayer(
party.owner.server.template.parentTemplateName,
allPlayerUUIDs.join(","),
message
message,
mini
)
}

Expand Down Expand Up @@ -180,14 +187,17 @@ export default class PartyService {
" &7a été invité dans le groupe !"
)

const miniMessage = `<${ampersandColorToName[owner.permGroups[0].color]}>${
owner.username
} <green>t'a invité dans son groupe ! <gray>Cliquez <yellow><hover:show_text:'<yellow>Rejoindre le groupe'><click:run_command:/party join ${
owner.username
}>ici</click></hover> <gray>pour rejoindre le groupe !`

await PartyService.sendMessageToPlayer(
player.server.template.parentTemplateName,
playerUuid,
owner.permGroups[0].color +
owner.username +
"&a t'a invité dans son groupe ! &7Faites &e/party join " +
owner.username +
" &7pour rejoindre le groupe !"
miniMessage,
true
)

await prisma.party.update({
Expand Down
18 changes: 18 additions & 0 deletions src/realms/rest/helpers/Colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const ampersandColorToName = {
"&0": "black",
"&1": "dark_blue",
"&2": "dark_green",
"&3": "dark_aqua",
"&4": "dark_red",
"&5": "dark_purple",
"&6": "gold",
"&7": "gray",
"&8": "dark_gray",
"&9": "blue",
"&a": "green",
"&b": "aqua",
"&c": "red",
"&d": "light_purple",
"&e": "yellow",
"&f": "white"
} as const
5 changes: 3 additions & 2 deletions src/realms/rest/helpers/SendMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ const sendMessageToPlayer = (
proxyServer: string,
prefix: string,
uuid: string,
message: string
message: string,
mini = false
) => {
return RedisClient.getInstance().publishToPlugin(
proxyServer,
"Vicarius",
"sendMessage",
mini ? "sendMiniMessage" : "sendMessage",
prefix,
message,
uuid
Expand Down

0 comments on commit 2024723

Please sign in to comment.