From af1778ac7b5a2d389d97f121e707acdf4251fac7 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sun, 9 Apr 2023 22:20:48 -0500 Subject: [PATCH] add smaller version of server banner --- Plugins/ScriptPlugins/ServerBanner.js | 298 +++++++++++++++++--------- 1 file changed, 202 insertions(+), 96 deletions(-) diff --git a/Plugins/ScriptPlugins/ServerBanner.js b/Plugins/ScriptPlugins/ServerBanner.js index 3094332d..0beb3da1 100644 --- a/Plugins/ScriptPlugins/ServerBanner.js +++ b/Plugins/ScriptPlugins/ServerBanner.js @@ -81,8 +81,9 @@ const plugin = { interactionData.interactionType = 1; interactionData.source = plugin.name; - interactionData.scriptAction = (sourceId, targetId, game, meta, token) => { - const serverId = meta['serverId']; + interactionData.scriptAction = (sourceId, targetId, game, meta, _) => { + const serverId = meta.serverId; + const isSmall = meta.size !== undefined && meta.size === 'small'; let server; let colorLeft = 'color: #f5f5f5; text-shadow: -1px 1px 8px #000000cc;'; @@ -145,97 +146,185 @@ const plugin = { colorRight = colorMappingOverride[gameCode]?.right || colorRight; const font = 'Noto Sans Mono'; - let status = '
ONLINE
'; + let status = isSmall ? '
' : '
ONLINE
'; if (server.throttled) { - status = '
OFFLINE
'; + status = isSmall ? '
' : '
OFFLINE
'; } const displayIp = server.resolvedIpEndPoint.address.isInternal() ? plugin.manager.externalIPAddress : server.resolvedIpEndPoint.toString().split(':')[0]; - return ` - - - - - -
-
-
-
-
${server.serverName.stripColors()}
-
${displayIp}:${server.listenPort}
-
-
${server.throttled ? '-' : server.clientNum}/${server.maxClients} Players
- ${serverLocationCache[server.listenAddress]} + const head = ` + + + ${displayIp}:${server.listenPort} + `; + + + if (isSmall) { + return ` + ${head} + +
+
+
+
${server.serverName.stripColors()}
+
+ ${status} +
${displayIp}:${server.listenPort}
+
+
+ ${serverLocationCache[server.listenAddress]} +
+ ${server.throttled ? '-' : server.clientNum}/${server.maxClients} + • + ${server.map.alias} + • + ${server.gametypeName} +
+
-
-
${server.map.alias}
-
${server.gametypeName}
- ${status} -
-
+ + `; + } + + return ` + ${head} + +
+
+
+
+
${server.serverName.stripColors()}
+
${displayIp}:${server.listenPort}
+
+
${server.throttled ? '-' : server.clientNum}/${server.maxClients} Players
+ ${serverLocationCache[server.listenAddress]} +
+
+
+
${server.map.alias}
+
${server.gametypeName}
+ ${status} +
+
+ `; }; @@ -269,23 +358,40 @@ const plugin = { const servers = serverOrderCache[key]; servers.forEach(eachServer => { response += `
-
-
${eachServer.gameCode}
${eachServer.serverName.stripColors()}
+
+
+
${eachServer.gameCode}
+ ${eachServer.serverName.stripColors()} +
-
- -
-
Show Embed
- -
`; +
+ +
+
Show Embed
+ +
+ +
+
Show Embed
+ +
+
`; }); }); response += '
'; - response += '' return response; };