Skip to main content
 Warning: Unmaintained Version
Version: 0.4.2

Creating an Adapter

Introduction

TypeWriter is a dynamic platform that supports the development of adapters, which are modular components enhancing the overall functionality. Adapters are self-contained, easily shareable, and integrate smoothly into the TypeWriter system. This guide is tailored to guide you through the process of creating an adapter, suitable for both beginners and experienced developers.

Prerequisites

  • Java Development Kit (JDK) 17 or higher.
  • An Integrated Development Environment (IDE) such as IntelliJ IDEA or Eclipse.
  • A basic understanding of Gradle and the Spigot API.

Step 1: Setting Up a Gradle Project

Begin by establishing a Gradle project for your TypeWriter adapter. Below is a comprehensive setup for your build.gradle.kts:

build.gradle.kts
plugins {
kotlin("jvm") version "1.8.20"
id("com.github.johnrengelman.shadow") version "8.1.1"
}

// Replace with your own information
group = "me.yourusername"
version = "0.0.1"

repositories {
maven("https://jitpack.io")
mavenCentral()
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://oss.sonatype.org/content/groups/public/")
maven("https://libraries.minecraft.net/")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.codemc.io/repository/maven-snapshots/")
maven("https://repo.opencollab.dev/maven-snapshots/")

// Add other necessary repositories
}

dependencies {
compileOnly(kotlin("stdlib"))
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
compileOnly("com.github.gabber235:typewriter:main-SNAPSHOT") // Latest release version

// Already included in the TypeWriter plugin but still needed for compilation
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.0-RC")
compileOnly("com.github.dyam0:LirandAPI:96cc59d4fb")
compileOnly("net.kyori:adventure-api:4.13.1")
compileOnly("net.kyori:adventure-text-minimessage:4.13.1")

// Add other dependencies as needed
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

Ensure to replace placeholders like me.yourusername with your project details.

Choosing the TypeWriter Version

Select the appropriate TypeWriter dependency version: For stable and tested features, use the latest release version:

compileOnly("com.github.gabber235:typewriter:main-SNAPSHOT")

This is suitable for most development needs and is recommended for general adapter creation.

If you need the latest features and improvements (which might be unstable), use the latest development version:

compileOnly("com.github.gabber235:typewriter:develop-SNAPSHOT")

Note that this version may include changes that are not yet fully tested or documented.

If you need a specific version, visit the JitPack page and select the version you need.

Step 2: Creating an Adapter Class

After setting up your project, create an adapter class. Here's an example: kotlin title="ExampleAdapter.kt"

import me.gabber235.typewriter.adapters.Adapter
import me.gabber235.typewriter.adapters.TypewriteAdapter

@Adapter("Example", "An example adapter for documentation purposes", "0.0.1")
object ExampleAdapter : TypewriteAdapter() {
override fun initialize() {
// Any initializations needed to run the adapter.
}
}

Step 3: Building the Adapter

After creating the adapter class, build the adapter. This can be done by running the shadowJar Gradle task. This will generate a JAR file in the build/libs directory. This JAR file can be used as an adapter in TypeWriter. Place the JAR file in the plugins/TypeWriter/adapters directory and restart the server. Typewriter will automatically load the adapter and run it.

If any problems occur, check the console for errors and ensure that the adapter is properly configured. If you need help, join the Discord server and ask for help.

What's Next?

After creating an adapter, you can start adding features to it. Check out the Creating Entries guide to learn how to add entries to your adapter.