Skip to content

Instantly share code, notes, and snippets.

@Joo200
Last active January 20, 2024 20:03
Show Gist options
  • Select an option

  • Save Joo200/eb99b294ebd16a353750f83d8dcdce23 to your computer and use it in GitHub Desktop.

Select an option

Save Joo200/eb99b294ebd16a353750f83d8dcdce23 to your computer and use it in GitHub Desktop.
Dynmap API Usage

Warning

Those examples are outdated and shouldn't be used anymore.

Use the official wiki from dynmap as api reference.

Leagacy docs:

This documentation doesn't contain full api docs for dynmap. You need a fundamental knowledge from java and the general non api usage from the dynmap.

Add the Dependency

Add the dynmap api as dependency to your maven or gradle project

Gradle

repositories {
    maven { url = "https://repo.mikeprimm.com/" }
}

dependencies {
    compileOnly "us.dynmap:dynmap-api:3.4-beta-3"
}

Maven

    <repositories>
        <repository>
            <id>MikeRepo</id>
            <url>https://repo.mikeprimm.com/</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>us.dynmap</groupId>
            <artifactId>dynmap-api</artifactId>
            <version>3.4-beta-3</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

Accessing the dynmap api

Use the static method DynmapCommonAPIListener.register to register an instance of DynmapCommonAPIListener. The Dynmap plugin or mod will call the method apiEnabled(DynmapCommonAPI api) when the api becomes enabled.

Link to DynmapCommonAPIListener: https://github.com/webbukkit/dynmap/blob/v3.0/DynmapCoreAPI/src/main/java/org/dynmap/DynmapCommonAPIListener.java

Access the markerAPI:

MarkerSet markerAPI = api.getMarkerAPI();

Working with markers

To create a new marker you need a MarkerSet. You can either use an existing MarkerSet or create a new one.

Creating a new MarkerSet

MarkerSet set = markerAPI.createMarkerSet("setId", "Display Name", null, false);            

With the MarkerSet instance you can change the attributes. You can hide that set by default, set layer priorities, min and max zoom levels. For a full reference take a look in the MarkerSet interface.

Accessing an existing MarkerSet

MarkerSet set = markerAPI.getMarkerSet("setId");

Accessing marker icons

MarkerIcon icon = markerAPI.getMarkerIcon("building");

Registering new marker icons

MarkerIcon icon = markerAPI.createMarkerIcon("id", "title", inputStream);           

To receive an input stream from a .png file from your plugin you can use

plugin.getResource("myicon.png");

Creating a new marker

String htmlLabel = "<div>Hello World</div>"
Marker marker = set.createMarker("uniqueMarkerId", htmlLabel, true,               
        "world", 10, 20, 30, icon, false);
@DragonMadness

DragonMadness commented Sep 7, 2022

Copy link
Copy Markdown

This was somewhat helpful! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment