Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion config/Config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default {
import { loadConfig } from "../src/ConfigLoader.js"
const defaultConfig = {
/**
* Manual chat routing is needed for chat utilities such as custom brackets or finish counter.
* Enabling it makes the chat a bit slower, as all input has to go through the controller first.
Expand Down Expand Up @@ -100,6 +101,13 @@ export default {
matchStringCacheSize: 10000,
/** If haystack size exceeds this threshold `matchString()` will skip expensive haystack processing to optimize performance */
matchStringReduxModeThreshold: 5000,
/**
* Additional plugin module files to load at startup.
* Paths are resolved from the Trakman working directory unless absolute.
*/
externalPlugins: [],
/** Custom map environments. If a map has an environment that is not in this list, it will be marked as "Stadium" */
customEnvironments: ["Highlands", "NewSnowCar"]
}

export default await loadConfig(defaultConfig, import.meta.url)
7 changes: 5 additions & 2 deletions config/Messages.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { loadConfig } from "../src/ConfigLoader.js"
import prefixes from './PrefixesAndPalette.js'

const p = prefixes.palette

export default {
const defaultConfig = {
/** Message sent to the player attempting to use a command they do not have the permission for */
noPermission: `${p.error} You have no permission to use this command.`,
/** Message sent to the muted player attempting to use a command that is disabled for muted players */
Expand All @@ -25,4 +26,6 @@ export default {
noPlayer: `${p.error}Player ${p.highlight}#{name}${p.error} is not on the server.`,
/** Message sent to the player if the specified login is not found in the database */
unknownPlayer: `${p.error}Unknown player ${p.highlight}#{name}${p.error}.`
}
}

export default await loadConfig(defaultConfig, import.meta.url)
58 changes: 33 additions & 25 deletions config/PrefixesAndPalette.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,61 @@
import colours from '../src/data/Colours.js'
import { loadConfig } from "../src/ConfigLoader.js"

export const prefixes = {
const defaultConfig = {
prefixes: {
/** Default chat message format when manual chat routing is enabled. This can be overwritten by tm.chat.setMessageStyle() method */
manualChatRoutingMessageStyle: `$g[#{name}$z$s$g] `,
manualChatRoutingMessageStyle: `$g[#{name}$z$s$g] `,
/** Characters with which every message sent to individual players will be prefixed (e.g. ChatSendServerMessageToLogin) */
serverToPlayer: `${colours.yellow}» `,
serverToPlayer: `${colours.yellow}» `,
/** Characters with which every message sent in public will be prefixed (e.g. ChatSendServerMessage) */
serverToAll: `${colours.yellow}»» `
}
serverToAll: `${colours.yellow}»» `
},

/** Controller messages palette object */
export const palette = {
/** Controller messages palette object */
/** All admin commands */
admin: colours.erin,
palette: {
admin: colours.erin,
/** Dedi record messages */
dedirecord: colours.darkpastelgreen,
dedirecord: colours.darkpastelgreen,
/** Dedi misc messages */
dedimessage: colours.kellygreen,
dedimessage: colours.kellygreen,
/** Donation messages */
donation: colours.brilliantrose,
donation: colours.brilliantrose,
/** Error messages */
error: colours.red,
error: colours.red,
/** General highlighting colour */
highlight: colours.white,
highlight: colours.white,
/** Karma messages */
karma: colours.greenyellow,
karma: colours.greenyellow,
/** Server messages */
servermsg: colours.erin,
servermsg: colours.erin,
/** Misc messages */
message: colours.lightseagreen,
message: colours.lightseagreen,
/** Rank highlighting colour */
rank: colours.icterine,
rank: colours.icterine,
/** Record messages */
record: colours.erin,
record: colours.erin,
/** Server message prefix colour */
server: colours.yellow,
server: colours.yellow,
/** Voting messages */
vote: colours.chartreuse,
vote: colours.chartreuse,
/** Green */
green: 'af4',
green: 'af4',
/** Red */
red: 'e22',
red: 'e22',
/** Yellow */
yellow: 'fc1',
yellow: 'fc1',
/** Purple */
purple: '4af'
purple: '4af'
}
}

const loadedConfig = await loadConfig(defaultConfig, import.meta.url)

export const prefixes = loadedConfig.prefixes
export const palette = loadedConfig.palette

export default {
prefixes,
palette
}
}
40 changes: 25 additions & 15 deletions config/Titles.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
import { loadConfig } from "../src/ConfigLoader.js"

// Player titles are assigned in order: logins, nations, privileges
export const titles = {
const defaultConfig = {
titles: {
/** Pairs of login and title where the title is assigned to the specified login */
logins: {
'login': 'title'
},
logins: {
'login': 'title'
},
/** Pairs of country and title where the title is assigned to every player from the specified country (country codes work too) */
countries: {
'country': 'title',
'CODE': 'title' // country code
},
countries: {
'country': 'title',
'CODE': 'title' // country code
},
/** Pairs of privilege and title where the title is assigned to every player with the specified privilege level */
privileges: {
0: 'Player',
1: 'Operator',
2: 'Admin',
3: 'Masteradmin',
4: 'Server Owner'
privileges: {
0: 'Player',
1: 'Operator',
2: 'Admin',
3: 'Masteradmin',
4: 'Server Owner'
}
}
}
}

const loadedConfig = await loadConfig(defaultConfig, import.meta.url)

export const titles = loadedConfig.titles

export default loadedConfig
5 changes: 4 additions & 1 deletion plugins/actions/Config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { loadConfig } from "../../src/ConfigLoader.js"
const p = tm.utils.palette
import icons from '../ui/config/Icons.js'

export default {
const defaultConfig = {
noPermission: `${p.error}You have no permission to perform this action.`,
addVote: {
voteTexts: {
Expand Down Expand Up @@ -139,3 +140,5 @@ export default {
public: true
}
}

export default await loadConfig(defaultConfig, import.meta.url)
5 changes: 4 additions & 1 deletion plugins/betting/Config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { loadConfig } from "../../src/ConfigLoader.js"
const p = tm.utils.palette

export default {
const defaultConfig = {
// If false plugin cant be activated
isEnabled: false, // This can be changed using an ingame command
isActive: false,
Expand Down Expand Up @@ -46,3 +47,5 @@ export default {
alreadyNotActive: `${p.error}Betting plugin is already disabled.`
}
}

export default await loadConfig(defaultConfig, import.meta.url)
8 changes: 6 additions & 2 deletions plugins/betting/ui/BetInfoWidget.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { icons, raceConfig } from '../../ui/UI.js'
import { loadConfig } from "../../../src/ConfigLoader.js"
import icons from '../../ui/config/Icons.js'
import raceConfig from '../../ui/config/RaceUi.js'

export default {
const defaultConfig = {
posX: raceConfig.rightPosition,
side: true, // If true overrides posY prop and places the widget as last component
placeAsLastComponent: true,
Expand All @@ -14,3 +16,5 @@ export default {
topBorder: raceConfig.topBorder, // used for Y positioning
marginBig: raceConfig.marginBig
}

export default await loadConfig(defaultConfig, import.meta.url)
8 changes: 6 additions & 2 deletions plugins/betting/ui/BetPlaceWindow.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { raceConfig, StaticHeader } from '../../ui/UI.js'
import { loadConfig } from "../../../src/ConfigLoader.js"
import raceConfig from '../../ui/config/RaceUi.js'
import StaticHeader from '../../ui/utils/StaticHeader.js'

const p = tm.utils.palette

const width = 10
export default {
const defaultConfig = {
posX: raceConfig.rightPosition - (width + raceConfig.marginBig),
headerText: `Bet`, // To position the widget next to side ui widgets set these properties and keep staticPos props null
relativePos: {
Expand Down Expand Up @@ -43,3 +45,5 @@ export default {
topBorder: raceConfig.topBorder, // used for Y positioning
marginBig: raceConfig.marginBig
}

export default await loadConfig(defaultConfig, import.meta.url)
5 changes: 4 additions & 1 deletion plugins/chat_routing_additions/CustomBracket.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { loadConfig } from "../../src/ConfigLoader.js"
const p = tm.utils.palette

export default {
const defaultConfig = {
isEnabled: true,
brackets: [{
logins: ['login1'],
Expand All @@ -13,3 +14,5 @@ export default {
}], // If there is another function modifying chat nickname with higher importance it will overwrite this one
importance: 1
}

export default await loadConfig(defaultConfig, import.meta.url)
5 changes: 4 additions & 1 deletion plugins/chat_routing_additions/FinishCounter.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { loadConfig } from "../../src/ConfigLoader.js"
const p = tm.utils.palette

export default {
const defaultConfig = {
isEnabled: false,
colours: [{
amount: 0,
Expand All @@ -20,3 +21,5 @@ export default {
} // Gradient
]
}

export default await loadConfig(defaultConfig, import.meta.url)
5 changes: 4 additions & 1 deletion plugins/chat_routing_additions/UrlFixer.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export default {
import { loadConfig } from "../../src/ConfigLoader.js"
const defaultConfig = {
isEnabled: true,
matchRegex: /(http:\/\/|https:\/\/)/gi,
importance: 1
}

export default await loadConfig(defaultConfig, import.meta.url)
5 changes: 4 additions & 1 deletion plugins/checkpoint_records/Config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { loadConfig } from "../../src/ConfigLoader.js"
import { palette as p } from '../../config/PrefixesAndPalette.js'

export default {
const defaultConfig = {
isEnabled: true, // Using DB client makes the plugin a bit faster due to high amount of database queries
// Program can run only run limited amount of clients, the process will hang otherwise
useDBClient: true,
Expand All @@ -24,3 +25,5 @@ export default {
}
}
}

export default await loadConfig(defaultConfig, import.meta.url)
8 changes: 6 additions & 2 deletions plugins/checkpoint_records/ui/CheckpointRecords.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { componentIds as ids, icons } from '../../ui/UI.js'
import { loadConfig } from "../../../src/ConfigLoader.js"
import ids from '../../ui/config/ComponentIds.js'
import icons from '../../ui/config/Icons.js'

export default {
const defaultConfig = {
title: ' Checkpoint Records ',
icon: icons.clock,
entries: 14,
Expand Down Expand Up @@ -48,3 +50,5 @@ export default {
noTimeText: '--:--.-',
stuntsNoTimeText: '--'
}

export default await loadConfig(defaultConfig, import.meta.url)
7 changes: 5 additions & 2 deletions plugins/commands/config/AdminCommands.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { loadConfig } from "../../../src/ConfigLoader.js"
const p = tm.utils.palette
const priv = tm.admin.privileges

export default {
const defaultConfig = {
kick: {
privilege: priv.kick,
aliases: ['k', 'kick'],
Expand Down Expand Up @@ -101,4 +102,6 @@ export default {
privilege: 2,
public: true
}
}
}

export default await loadConfig(defaultConfig, import.meta.url)
5 changes: 4 additions & 1 deletion plugins/commands/config/ChatCommands.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { loadConfig } from "../../../src/ConfigLoader.js"
const p = tm.utils.palette
const prefix = `$i` // Prefix all "fake" player messages with this (eg. $i, $t, etc)

export default {
const defaultConfig = {
defaultValue: `everyone`, // This value will be used for the name if you don't specify anything in e.g. /hi
hi: {
text: `$g[#{nickname}$z$s$g] ${prefix}Hello, #{name}$g!`,
Expand Down Expand Up @@ -182,3 +183,5 @@ export default {
help: `Check the amount of coppers the server account currently has.`
}
}

export default await loadConfig(defaultConfig, import.meta.url)
5 changes: 4 additions & 1 deletion plugins/commands/config/GameCommands.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { loadConfig } from "../../../src/ConfigLoader.js"
const p = tm.utils.palette

export default {
const defaultConfig = {
setgamemode: {
text: `${p.admin}#{title} ${p.highlight}#{adminName} ${p.admin}has set the gamemode to ${p.highlight}#{mode}${p.admin}.`,
public: true,
Expand Down Expand Up @@ -117,3 +118,5 @@ export default {
help: `Set whether checkpoint respawning is enabled.`
}
}

export default await loadConfig(defaultConfig, import.meta.url)
7 changes: 5 additions & 2 deletions plugins/commands/config/JukeboxCommands.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { loadConfig } from "../../../src/ConfigLoader.js"
const p = tm.utils.palette

export default {
const defaultConfig = {
dropjukebox: {
text: `${p.admin}#{title} ${p.highlight}#{adminName} ${p.admin}has removed ${p.highlight}#{name} ${p.admin}from the queue.`,
error: `${p.error}No such index in the queue.`,
Expand Down Expand Up @@ -31,4 +32,6 @@ export default {
aliases: ['ch', 'clearhistory'],
help: `Clear the map history.`
}
}
}

export default await loadConfig(defaultConfig, import.meta.url)
7 changes: 5 additions & 2 deletions plugins/commands/config/KarmaCommands.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export default {
import { loadConfig } from "../../../src/ConfigLoader.js"
const defaultConfig = {
aliases: ['+++', '++', '+', '-', '--', '---'], // DONT TOUCH THIS OR YOU DIE
help: `Vote for a map.`
}
}

export default await loadConfig(defaultConfig, import.meta.url)
Loading