Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Builds EZdebugPlus and runs its test suite on a clean machine.
#
# "on:" lists the events that start this workflow.
name: Build

on:
push:
branches: [main] # every push to main
pull_request:
branches: [main] # every pull request targeting main
workflow_dispatch: # lets you run it by hand from the Actions tab

jobs:
build:
name: Build and test
runs-on: ubuntu-latest # a fresh throwaway Linux machine, per run

steps:
# Copy the repository onto the machine.
- name: Check out the repository
uses: actions/checkout@v4

# Install Java 21 and cache the Maven dependency downloads, so later
# runs do not re-download paper-api and the EZvac API every time.
- name: Set up Java 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
cache: maven

# -B is "batch mode": no interactive prompts, cleaner logs.
# "verify" runs the full lifecycle including the test suite.
- name: Build and run tests
run: mvn -B clean verify

# Keep the built jar so you can download it from the run's summary page.
# Useful for testing a contributor's pull request without building it
# yourself. Retained for 30 days.
- name: Upload the built jar
uses: actions/upload-artifact@v4
with:
name: EZdebugPlus-jar
path: target/EZdebugPlus-*.jar
if-no-files-found: error
retention-days: 30
100 changes: 100 additions & 0 deletions .github/workflows/modrinth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Publishes each GitHub release to Modrinth, so the Modrinth page never falls
# behind GitHub.
#
# It uploads the jar attached to the release (the one the Build workflow
# made) with the release notes as its changelog. Prereleases such as the
# pilots go up as "beta", everything else as "release". A version Modrinth
# already has is skipped, so running it twice is harmless.
#
# Needs the repository variable MODRINTH_PROJECT (the Modrinth project's id) and
# the repository secret MODRINTH_TOKEN: a Modrinth personal access token
# with the Create versions, Read versions and Read projects scopes, from an
# account allowed to upload versions to the project. The token is only ever
# sent to Modrinth's own API.
name: Publish to Modrinth

on:
release:
types: [published] # whenever a release is published on GitHub
workflow_dispatch: # or by hand, e.g. for a release made before this existed
inputs:
tag:
description: Release tag to publish, e.g. 0.1.0
required: true

permissions:
contents: read # enough to read releases and download their jars

env:
MODRINTH_PROJECT: ${{ vars.MODRINTH_PROJECT }}
EZVAC_PROJECT: dCv4gYwb # modrinth.com/plugin/ezvac-plugin, which EZdebug+ needs
GAME_VERSIONS: '["1.21", "1.21.1"]'
LOADERS: '["paper", "purpur"]'
# Modrinth asks API clients to say who they are.
USER_AGENT: EZvac-Plugin/EZdebugPlus release publisher (github.com/EZvac-Plugin/EZdebugPlus)

jobs:
publish:
name: Publish to Modrinth
runs-on: ubuntu-latest
# Does nothing until the Modrinth project exists and its id is set as a repository variable.
if: vars.MODRINTH_PROJECT != ''

steps:
# The release's own jar, so Modrinth gets exactly the file GitHub has.
- name: Download the release and its jar
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.event.release.tag_name || inputs.tag }}
run: |
mkdir dist
# The jar can arrive a moment after the release is published; retry briefly.
for attempt in 1 2 3 4 5 6; do
gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --pattern 'EZdebugPlus-*.jar' \
--dir dist --clobber && break
sleep 10
done
count=$(ls dist/EZdebugPlus-*.jar 2>/dev/null | wc -l)
if [ "$count" -ne 1 ]; then
echo "::error::Release $TAG should have exactly one EZdebugPlus jar attached; found $count."
exit 1
fi
gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json name,body,isPrerelease > dist/release.json
echo "TAG=$TAG" >> "$GITHUB_ENV"

- name: Skip if Modrinth already has this version
run: |
if curl -fsS -A "$USER_AGENT" "https://api.modrinth.com/v2/project/$MODRINTH_PROJECT/version" \
| jq -e --arg tag "$TAG" 'any(.[]; .version_number == $tag)' > /dev/null; then
echo "Modrinth already has $TAG; nothing to do."
echo "SKIP=true" >> "$GITHUB_ENV"
fi

- name: Upload to Modrinth
if: env.SKIP != 'true'
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: |
jar=$(ls dist/EZdebugPlus-*.jar)
jq -n --slurpfile release dist/release.json --arg tag "$TAG" --arg project "$MODRINTH_PROJECT" --arg ezvac "$EZVAC_PROJECT" \
--argjson games "$GAME_VERSIONS" --argjson loaders "$LOADERS" '{
name: $release[0].name,
version_number: $tag,
changelog: $release[0].body,
version_type: (if $release[0].isPrerelease then "beta" else "release" end),
game_versions: $games,
loaders: $loaders,
dependencies: [{project_id: $ezvac, dependency_type: "required"}],
featured: false,
status: "listed",
project_id: $project,
file_parts: ["file"],
primary_file: "file"
}' > dist/version.json
curl -sS --fail-with-body -A "$USER_AGENT" \
-H "Authorization: $MODRINTH_TOKEN" \
-F "data=<dist/version.json;type=application/json" \
-F "file=@$jar;type=application/java-archive" \
https://api.modrinth.com/v2/version
echo
echo "Published $TAG to Modrinth project $MODRINTH_PROJECT"
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Changelog

All notable changes to EZdebug+ are recorded here.

## 0.1.0

The first release: the Debug Potion. Needs EZvac ALPHA 2.2 or newer (API 1.2).

### Added

- **`/ezdb debug [player]`** gives a Debug Potion (`ezdebug.use`, ops).
- **Drinking it** gives 8 minutes of debug vision, seen only by that player:
- a coloured frame around every EZvac sign, coloured by kind;
- glowing outlines on all equipment, visible through walls: grey stopped,
cyan cooling, orange heating;
- small clouds on the vents of systems that are cooling or heating, and on
running equipment.
- **Ending it:** milk, death, the timer, or `/ezdb off`. The remaining time
carries over a relog. Night Vision shows the countdown (`effect:` in
config.yml).
- **config.yml:** the duration, radius, refresh rate, countdown effect and
every colour.
34 changes: 34 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Contributing to EZdebug+

Bug reports, ideas and pull requests are welcome.

## Requirements

- Paper 1.21.1 (or a fork such as Purpur) with EZvac ALPHA 2.1 Pilot 4 or newer
- Java 21
- Maven 3.9 or newer

## Build and test

```shell
mvn clean package
```

This compiles, runs the tests, and writes `target/EZdebugPlus-<version>.jar`.
Every push and pull request is built and tested by GitHub Actions.

## How it fits together

- **The code only touches EZvac through its public API** (`ezvac-api`, from JitPack). Never reach into EZvac's internals: that is what keeps EZdebug+ working across EZvac releases.
- **The pure, unit-tested logic is in `model/`:**
- `Palette` picks the colour for a device and what it's doing;
- `SignFrame` places the specks around a sign's board;
- `Activity` says which vents and equipment are at work;
- `DebugSettings` reads and checks config.yml.

Add tests there when you change them.
- **The Bukkit side:**
- `DebugPotion`: the item, drinking it, milk, death, relogs, and EZvac's device events;
- `DebugVision`: who has debug vision and the redraw task;
- `Outlines`: equipment's glowing block displays, shown only to debug players;
- `Commands`.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# EZdebug+

**See EZvac at work.** An addon for [EZvac](https://github.com/EZvac-Plugin/EZvac),
the realistic HVAC and indoor-climate plugin for Paper and Purpur.

`/ezdb debug` gives you a **Debug Potion**. Drink it, and for 8 minutes:
- **every EZvac sign gets a coloured frame:** a ring of specks around its
board, in a colour for its kind;
- **every piece of equipment glows** with an outline you can see through
walls, so equipment hidden in a casing is easy to find: grey while it's
stopped, cyan while it cools, orange while it heats;
- **working vents puff a little cloud,** cyan or orange, while their system
cools or heats, and so does running equipment.

Only you see any of it: other players see nothing. Night Vision shows the
countdown and helps in dark plant rooms. **Milk** ends it, like any potion,
and so does dying.

> **Requires** EZvac ALPHA 2.2 or newer (EZvac API 1.2), on Paper or Purpur
> 1.21.1 with Java 21.

## Colours

| Device | Colour |
| --- | --- |
| Thermostats | aqua |
| Thermometers, hygrometers, thermo-hygrometers | white |
| RPM monitors | yellow |
| Settings panels | pink |
| Sensor hubs | green |
| Dehumidifier and humidifier signs | blue |
| Equipment | grey when stopped, cyan cooling, orange heating |

Clouds are cyan for cooling and orange for heating. Every colour can be
changed in config.yml. Signs get a frame rather than a glow: Minecraft draws
sign boards in a way a glowing copy can't trace.

## Commands and permissions

| Command | Does |
| --- | --- |
| `/ezdb debug [player]` | Gives a Debug Potion, to you or to someone else |
| `/ezdb off [player]` | Ends debug vision at once |
| `/ezdb reload` | Reloads config.yml |

All need `ezdebug.use` (ops by default). `/ezdebug` works too.

## Configuration

`plugins/EZdebugPlus/config.yml`, explained line by line:
- `duration-minutes` (8);
- `radius`: how close devices must be (32 blocks);
- `refresh-ticks`: how often the view is redrawn (10, twice a second);
- `effect`: the countdown effect (`night_vision`, or `none`);
- `colors`.

A bad value warns in the console and that part uses its defaults.

## How it works

EZdebug+ is built only on EZvac's public API: `devices(world)` lists every
device with its position, the equipment and thermostat views say what's
running, and the device events keep the outlines in step. Equipment outlines
are block displays that only debug players are shown; they're never saved
with the world. Frames and clouds are particles sent to debug players only.
See [EZvac's API guide](https://github.com/EZvac-Plugin/EZvac/blob/main/docs/api.md).

## Building

```shell
mvn clean package
```

The jar is written to `target/EZdebugPlus-<version>.jar`.

## License

MIT; see [LICENSE](LICENSE).
111 changes: 111 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.github.blade</groupId>
<artifactId>ezdebugplus</artifactId>
<version>0.1.0</version>
<packaging>jar</packaging>

<name>EZdebugPlus</name>
<description>EZdebug+: a Debug Potion that shows EZvac's devices at work. An addon for EZvac.</description>

<licenses>
<license>
<name>MIT License</name>
<url>https://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>

<properties>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- EZvac API 1.2, first in EZvac ALPHA 2.2. -->
<ezvac.api.version>ALPHA-2.2</ezvac.api.version>
</properties>

<repositories>
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<!-- EZvac's API is published from its release tags by JitPack. -->
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Provided: EZvac carries the API's classes at runtime. -->
<dependency>
<groupId>com.github.EZvac-Plugin.EZvac</groupId>
<artifactId>ezvac-api</artifactId>
<version>${ezvac.api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.11.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.11.4</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<defaultGoal>clean package</defaultGoal>
<finalName>EZdebugPlus-${project.version}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>${project.basedir}</directory>
<targetPath>META-INF</targetPath>
<includes>
<include>LICENSE</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<release>21</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
</plugin>
</plugins>
</build>
</project>
Loading
Loading