A Kotlin library for parsing Myth II film files and extracting complete game information.
- Parse complete Myth II film files
- Extract game options, player information, plugins, and commands
- Clean API for both Kotlin and Java developers
- Comprehensive documentation with KDoc
- No complex internal data structures exposed
import net.bagrada.filmparser2.FilmParser
val parser = FilmParser()
val film = parser.parse("path/to/film.m2r")
// Basic film information
println("Film: ${film.name}")
println("Map: ${film.mapName}")
println("Players: ${film.players.size}")
// Game options
val options = film.gameOptions
println("Game Type: ${options.gameType}")
println("Time Limit: ${options.timeLimit} seconds")
println("Cooperative: ${options.isCooperative}")
// Player information
for (player in film.players) {
println("Player: ${player.name} (Team: ${player.teamName})")
println(" Team Index: ${player.teamIndex}")
println(" Player ID: ${player.playerId}")
println(" Game Version: ${player.gameVersion}")
println(" Checked In: ${player.isCheckedIn}")
}
// Plugins
for (plugin in film.plugins) {
println("Plugin: ${plugin.name}")
println(" URL: ${plugin.url}")
println(" Checksum: ${plugin.checksum}")
}
// Chat messages
val chatMessages = film.getChatMessages()
for (message in chatMessages) {
println("${message.playerName}: ${message.message}")
}
// Players by team
val playersByTeam = film.getPlayersByTeam()
for ((teamIndex, teamPlayers) in playersByTeam) {
println("Team $teamIndex: ${teamPlayers.map { it.name }}")
}import net.bagrada.filmparser2.FilmParser;
import net.bagrada.filmparser2.FilmInfo;
import net.bagrada.filmparser2.PlayerInfo;
import net.bagrada.filmparser2.GameOptionsInfo;
import net.bagrada.filmparser2.PluginInfo;
FilmParser parser = new FilmParser();
FilmInfo film = parser.parse("path/to/film.m2r");
// Basic film information
System.out.println("Film: " + film.getName());
System.out.println("Map: " + film.getMapName());
System.out.println("Players: " + film.getPlayers().size());
// Game options
GameOptionsInfo options = film.getGameOptions();
System.out.println("Game Type: " + options.getGameType());
System.out.println("Time Limit: " + options.getTimeLimit() + " seconds");
System.out.println("Cooperative: " + options.isCooperative());
// Player information
for (PlayerInfo player : film.getPlayers()) {
System.out.println("Player: " + player.getName() + " (Team: " + player.getTeamName() + ")");
System.out.println(" Team Index: " + player.getTeamIndex());
System.out.println(" Player ID: " + player.getPlayerId());
System.out.println(" Game Version: " + player.getGameVersion());
System.out.println(" Checked In: " + player.isCheckedIn());
}
// Plugins
for (PluginInfo plugin : film.getPlugins()) {
System.out.println("Plugin: " + plugin.getName());
System.out.println(" URL: " + plugin.getUrl());
System.out.println(" Checksum: " + plugin.getChecksum());
}
// Chat messages
List<ChatMessage> chatMessages = film.getChatMessages();
for (ChatMessage message : chatMessages) {
System.out.println(message.getPlayerName() + ": " + message.getMessage());
}Main entry point for parsing film files.
parse(filePath: String): FilmInfo- Parse a film file from pathparse(source: BufferedSource): FilmInfo- Parse a film from buffered source
Complete film information with the following properties:
name: String- Film namemapName: String- Map/scenario namegameOptions: GameOptionsInfo- Game configurationplugins: List<PluginInfo>- List of plugins usedplayers: List<PlayerInfo>- List of playerscommands: List<GameCommandInfo>- List of game commands
Methods:
getChatMessages(): List<ChatMessage>- Extract chat messages with player infogetPlayersByTeam(): Map<Int, List<PlayerInfo>>- Group players by team
Game configuration and settings:
gameType: String- Game type (Body Count, Capture the Flag, etc.)scoring: Int- Scoring systemtimeLimit: Int- Game time limit in secondsplanningTime: Int- Planning time limit in secondsdifficulty: Int- Game difficulty levelmaxPlayers: Int- Maximum number of playersmaxTeams: Int- Maximum number of teamsrandomSeed: Long- Random seed usedisCooperative: Boolean- Whether cooperative gameallowTeams: Boolean- Whether teams allowedallowUnitTrading: Boolean- Whether unit trading allowedallowVeterans: Boolean- Whether veterans allowedallowAlliances: Boolean- Whether alliances allowedoverheadMap: Boolean- Whether overhead map enableddeathmatch: Boolean- Whether deathmatch gamevtfl: Boolean- Whether VTFL enabledantiClump: Boolean- Whether anti-clumping enabled
Player information:
name: String- Player's display nameteamName: String- Player's team nameteamIndex: Int- Team index (0-based)playerId: Long- Unique player identifiermetaserverUserId: Long- Metaserver user IDgameVersion: Int- Game versiongameBuild: Int- Build numberisCheckedIn: Boolean- Whether player checked inisTeamLocked: Boolean- Whether player's team lockedprimaryColor: ByteArray- Primary color as RGB bytessecondaryColor: ByteArray- Secondary color as RGB bytes
Plugin information:
name: String- Plugin nameurl: String- Plugin download URLchecksum: String- Plugin checksum as hex string
Game command information:
type: String- Command type (CHAT, MOVE, ATTACK, etc.)senderId: Int- ID of player who sent commandtic: Int- Game tick when command executeddata: String- Additional command data
Chat message with context:
playerName: String- Name of player who sent messagemessage: String- Chat message contenttimestamp: Int- Game tick when message sent
- Kotlin 2.2.0+
- Okio 3.14.0+
- Koin 4.0.3+ (for dependency injection)
./gradlew build./gradlew publishToMavenLocalAdd to your pom.xml:
<dependency>
<groupId>net.bagrada</groupId>
<artifactId>film-parser-2</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>See JavaExample.java for a complete Java example demonstrating all features of the API.