Skip to content

Repository files navigation

Minecraft map item

maps

maps is a simple Spigot plugin and api for creating clientside maps and map screens. It is the successor of packet-maps.


Made with ♥ by Cerus


Navigation

Features
Quick start for developers
Building
FAQ
Contributing
Sources


Features

Please note: This is not a standalone plugin, it is a toolkit for other plugins. You will only be able to create and manage map screens with this plugin.

• Clientside maps
• Map screens (arrangement of clientside maps)
• Simple and reasonably lightweight
• Easy to use developer api
• Advanced engine features like alpha compositing (Image)
• Efficient click handling
• Supports 1.16.5 - 1.21.11

What is the point of the plugin module?
See FAQ


Quick start for developers

Please take a look at the wiki for an in-depth explanation of the api.

Maven setup

Warning

I'm unable to deploy the latest version to Maven Central at this time. There have been zero changes to the api, so you can still use the old version (3.8.12) until I've found a fix.

<dependencies>
<dependency>
<groupId>dev.cerus.maps</groupId>
<artifactId>common</artifactId>
<version>3.8.12</version>
<scope>provided</scope> <!-- "provided" if the maps plugin is on the server, "compile" if not -->
</dependency>
<!-- You need the plugin module to access the map screen registry of the plugin. --><!-- Don't add this dependency if you have your own storage solution. -->
<dependency>
<groupId>dev.cerus.maps</groupId>
<artifactId>plugin</artifactId>
<version>3.8.12</version>
<scope>provided</scope>
</dependency>
</dependencies>

Quickstart

importdev.cerus.maps.api.ClientsideMap;
importdev.cerus.maps.api.MapScreen;
importdev.cerus.maps.api.graphics.ClientsideMapGraphics;
importdev.cerus.maps.api.graphics.ColorCache;
importdev.cerus.maps.api.graphics.MapGraphics;
importdev.cerus.maps.plugin.map.MapScreenRegistry;
importdev.cerus.maps.version.VersionAdapterFactory;
importorg.bukkit.Bukkit;
importorg.bukkit.command.Command;
importorg.bukkit.command.CommandSender;
importorg.bukkit.entity.Player;
importorg.bukkit.inventory.ItemStack;
importorg.bukkit.inventory.meta.MapMeta;
importorg.bukkit.map.MinecraftFont;
importorg.bukkit.plugin.java.JavaPlugin;
publicclassMyPluginextendsJavaPlugin {
@OverridepublicvoidonEnable() {
// This example depends on the "common" and "plugin" dependency.for (finalMapScreenscreen : MapScreenRegistry.getScreens()) {
finalMapGraphics<?, ?> graphics = screen.getGraphics();
graphics.fillComplete(ColorCache.rgbToMap(255, 255, 255)); // Convert rgb(255, 255, 255) to map color and fill the screengraphics.drawText(5, 5, "There are " + Bukkit.getOnlinePlayers().size() + " players on the server", ColorCache.rgbToMap(0, 0, 0), 2);
screen.spawnFrames(Bukkit.getOnlinePlayers().toArray(newPlayer[0])); // Send the screen frames to all online playersscreen.sendMaps(true); // Send map data to all online players
}
getCommand("mapstest").setExecutor(this);
}
@OverridepublicbooleanonCommand(finalCommandSendersender, finalCommandcommand, finalStringlabel, finalString[] args) {
// It's been ages since I've used the normal Bukkit command system // so please forgive me if I use any bad practices hereif (!(senderinstanceofPlayerplayer)) {
returntrue;
}
if (!command.getName().equals("mapstest")) {
returntrue;
}
// This is really unsafe. Always do proper checks before casting // things, but this will do for the sake of this quick start.finalItemStackitem = player.getInventory().getItemInMainHand();
finalMapMetamapMeta = (MapMeta) item.getItemMeta();
finalintmapId = mapMeta.getMapView().getId();
finalClientsideMapclientsideMap = newClientsideMap(mapId); // Create clientside map with given idfinalClientsideMapGraphicsgraphics = newClientsideMapGraphics(); // Create graphics buffergraphics.fillComplete(ColorCache.rgbToMap(0, 0, 0)); // Fill with rgb(0, 0, 0)graphics.drawText(5, 5, "Hello,", ColorCache.rgbToMap(255, 255, 255), 1); // Draw textgraphics.drawText(5, 5 + MinecraftFont.Font.getHeight() + 5, player.getName(), ColorCache.rgbToMap(255, 255, 255), 2);
clientsideMap.draw(graphics); // Draw the buffer onto the mapclientsideMap.sendTo(newVersionAdapterFactory().makeAdapter(), player); // Send the map to the playerreturntrue;
}
}

Building

Requirements: Java 21, Git, Maven, CraftBukkit 1.16.5, 1.17.1, 1.18.1, 1.18.2, 1.19.1, 1.19.3, 1.19.4, 1.20, 1.20.2, 1.20.4, 1.20.6 and 1.21 installed in local Maven repo

Simply clone the repository, navigate into the directory and run mvn clean package. The plugin will be in plugin/target and the api in common/target.


FAQ

Why is there a plugin module if maps is not a standalone plugin?
The plugin handles the creation, management and storage of map screens. You do not need the plugin if you make your own creation, management and storage solution.

Please feel free to open an issue or contact me if you have any questions that were not answered here.


Contributing

Thank you for your interest in contributing to this project! Before you do anything though please read the contribution guidelines thoroughly. Contributions that do not conform to the guidelines might be rejected.


Sources

Lots of graphics features were implemented with the help of the following resources:

About

maps is a simple Spigot plugin and api for creating clientside maps and map screens.

Topics

Resources

Contributing

Stars

53 stars

Watchers

6 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages