Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

stylextv/gsigns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation



🚩 Source code of the GSigns spigot plugin, made with love in Java.

stars Codacy Badge Code size GitHub repo size Lines of Code

What is it?

GSigns is a spigot plugin that allows the creation of item frames that hold images and gifs.

The spigotmc page, including a download link, can be found here.

Map Sending

Instead of sending a huge packet containing all the map data every time the sign is updated, the map data is sent once to the player as he approaches the sign. Custom entity metadata packets are then sent for the item frames, telling the client which of the previously received maps must be displayed. Sending the maps is also optimized because the images are not rendered to the map via MapCanvas#drawImage, which would use the very slow MapPalette#matchColor function. Instead, the r, g and b values are pre-converted to the corresponding byte colors, which are then transferred to the map packet:

PacketPlayOutMap packet = new PacketPlayOutMap(mapId, (byte) 0, false, false, new ArrayList<>(), bytes, 0, 0, 128, 128);

GSIGN-Format

When saving a whole sign to a single file, for example when the server gets restarted, a special format is used. First a file with the smallest unused number (starting with 0) as a name is created. Then a header consisting of 45 bytes is placed at the beginning of the file:

# πŸ“Ž SIGN_UUID (16 bytes)
The UUID of the sign. Every sign has a different UUID.
This is used e.g. when teleporting to a sign with a given UUID as command argument.

# 🌎 WORLD_UUID (16 bytes)
The UUID of the world.

# 🧭 FACING (1 byte)
The direction the item frames are facing.

# πŸ“„ AMOUNT OF ITEM FRAMES (4 bytes)
The number of item frames that make up this sign.

# πŸ“ WIDTH & HEIGHT (2 * 4 bytes)
The width and height of the sign in item frames.

Afterwards the file is filled with the item frames of the sign and their images. Every item frame has a 16 bytes long header that is put at the beginning of the chunk in the file that is reserved for this particular item frame:

# πŸ“ X,Y,Z (3 * 4 bytes)
The x-, y-, and z-coordinate.

# πŸ“„ AMOUNT OF IMAGES (4 bytes)
The number of images that make up this item frame.

The actual data of the images are placed at the end of the chunk. Each image (or each frame in a gif) is saved in sequence:

  1. the delay is stored as 4 bytes. This is the number of milliseconds between frames. If the map is a still image, the value is 0.
  2. the pixel data is stored as a byte array of length 16384, since each frame has a width and height of 128.

When each item frame and its data has been stored the entire file data will be compressed using the Deflater to reduce file size:

Deflater compressor = new Deflater();
compressor.setLevel(Deflater.BEST_SPEED);

.GSIGN files in the "signs" folder that do not conform to this format are deleted on loading because they are outdated or damaged.

API

If you are a developer and want to use GSigns inside your plugin, for example to automatically create a sign, you can find the GSigns-API here.

Project Layout

Here you can see the current structure of the project.

β”œβ”€ πŸ“‚ showcase/       # ✨ Showcase (eg. for spigot)
β”œβ”€ πŸ“‚ src/            # 🌟 Source Files
β”‚  β”œβ”€ πŸ“‚ assets/          # βœ’οΈ Plugin Assets
β”‚  β”‚  └─ πŸ“‚ color_tables/ # πŸ“¦ Color Tables
β”‚  β”‚  └─ πŸ“‚ languages/    # πŸ“¦ Language Files
β”‚  β”œβ”€ πŸ“‚ de/stylextv/gs/  # βœ‰οΈ Source Code
β”‚  └─ πŸ“„ plugin.yml       # πŸ“Œ Plugin-YML
β”œβ”€ πŸ“‚ version/        # πŸ“¬ Versions (used by the auto-updater)
└─ πŸ“ƒ readme.md       # πŸ“– Read Me!

About

πŸš©πŸ€ A simple gamemode map signs plugin for your server.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages