diff --git a/src/api.ts b/src/api.ts index 1c7963e..ce31c6f 100644 --- a/src/api.ts +++ b/src/api.ts @@ -39,10 +39,7 @@ import {useStore} from "@/store"; function buildServerConfig(response: any): DynmapServerConfig { return { version: response.dynmapversion || '', - allowChat: response.allowwebchat || false, grayHiddenPlayers: response.grayplayerswhenhidden || false, - chatRequiresLogin: response['webchat-requires-login'] || false, - chatInterval: response['webchat-interval'] || 5, defaultMap: response.defaultmap || undefined, defaultWorld: response.defaultworld || undefined, defaultZoom: response.defaultzoom || 0, @@ -52,7 +49,6 @@ function buildServerConfig(response: any): DynmapServerConfig { showLayerControl: response.showlayercontrol || true, title: response.title || 'Dynmap', loginEnabled: response['login-enabled'] || false, - loginRequired: response.loginrequired || false, maxPlayers: response.maxcount || 0, hash: response.confighash || 0, }; @@ -189,6 +185,16 @@ function buildComponents(response: any): DynmapComponentConfig { }); break; + case "chat": + if(response.allowwebchat) { + components.chatSending = { + loginRequired: response['webchat-requires-login'] || false, + maxLength: response['chatlengthlimit'] || 256, + cooldown: response['webchat-interval'] || 5, + } + } + break; + case "chatbox": components.chatBox = { allowUrlName: component.allowurlname || false, diff --git a/src/dynmap.d.ts b/src/dynmap.d.ts index af1c2f5..85ddaf9 100644 --- a/src/dynmap.d.ts +++ b/src/dynmap.d.ts @@ -43,9 +43,6 @@ type DynmapUrlConfig = { interface DynmapServerConfig { version: string; - allowChat: boolean; - chatRequiresLogin: boolean; - chatInterval: number; defaultMap?: string; defaultWorld?: string; defaultZoom: number; @@ -55,7 +52,6 @@ interface DynmapServerConfig { showLayerControl: boolean; title: string; loginEnabled: boolean; - loginRequired: boolean; maxPlayers: number; grayHiddenPlayers: boolean; hash: number; @@ -80,7 +76,8 @@ interface DynmapComponentConfig { clockControl ?: ClockControlOptions; linkControl: boolean; logoControls: Array; - chatBox?: DynmapChatConfig; + chatBox?: DynmapChatBoxConfig; + chatSending?: DynmapChatSendingConfig; chatBalloons: boolean; } @@ -98,13 +95,19 @@ interface DynmapPlayerMarkersConfig { smallFaces: boolean; } -interface DynmapChatConfig { +interface DynmapChatBoxConfig { allowUrlName: boolean; showPlayerFaces: boolean; messageLifetime: number; messageHistory: number; } +interface DynmapChatSendingConfig { + loginRequired: boolean; + maxLength: number; + cooldown: number; +} + interface DynmapWorld { seaLevel: number; name: string; diff --git a/src/store/state.ts b/src/store/state.ts index c17fe84..1768525 100644 --- a/src/store/state.ts +++ b/src/store/state.ts @@ -69,9 +69,6 @@ export const state: State = { configuration: { version: '', - allowChat: false, - chatRequiresLogin: false, - chatInterval: 5000, defaultMap: '', defaultWorld: '', defaultZoom: 0, @@ -81,7 +78,6 @@ export const state: State = { showLayerControl: true, title: '', loginEnabled: false, - loginRequired: false, maxPlayers: 0, grayHiddenPlayers: false, hash: 0, @@ -135,6 +131,9 @@ export const state: State = { //Optional "logo" controls. logoControls: [], + //Chat message sending functionality + chatSending: undefined, + //Chat box chatBox: undefined,