Skip to content

Commit ade3215

Browse files
feat: update build configuration and add sidebar event handling
1 parent 9794b39 commit ade3215

File tree

7 files changed

+161
-4
lines changed

7 files changed

+161
-4
lines changed

.github/workflows/release.yaml.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Gradle Publish to Private Maven
2+
on:
3+
push:
4+
tags:
5+
- '[0-9]+.[0-9]+.[0-9]+'
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v5
12+
- name: Set up JDK 23
13+
uses: actions/setup-java@v5
14+
with:
15+
distribution: 'temurin'
16+
java-version: 23
17+
- name: Setup Gradle
18+
uses: gradle/actions/setup-gradle@v4
19+
- name: Publish to Maven
20+
env:
21+
TAG_VERSION: ${{ github.ref_name }}
22+
run: |
23+
./gradlew publishAllPublicationsToReleaseRepository
24+
echo "Version: ${TAG_VERSION}" >> $GITHUB_STEP_SUMMARY

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 BridgeSplash
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

build.gradle.kts

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ plugins {
44
id("checkstyle")
55
id("com.github.spotbugs") version "6.2.2"
66
`java-library`
7+
`maven-publish`
78
}
89

910
group = "net.bridgesplash.sidebar"
10-
version = "1.0.0"
11+
version = System.getenv("TAG_VERSION")?: "dev"
1112

1213
repositories {
1314
mavenCentral()
@@ -44,6 +45,13 @@ configurations.checkstyle {
4445
}
4546
}
4647

48+
java{
49+
withSourcesJar()
50+
withJavadocJar()
51+
52+
toolchain.languageVersion = JavaLanguageVersion.of(21)
53+
}
54+
4755
tasks{
4856
withType<Jar> { duplicatesStrategy = DuplicatesStrategy.EXCLUDE }
4957

@@ -70,4 +78,59 @@ tasks{
7078
test {
7179
useJUnitPlatform()
7280
}
73-
}
81+
}
82+
83+
publishing{
84+
85+
repositories{
86+
maven {
87+
name = "release"
88+
url = uri("https://repo.tesseract.club/private")
89+
credentials {
90+
username = System.getenv("MAVEN_USERNAME")
91+
password = System.getenv("MAVEN_SECRET")
92+
}
93+
}
94+
}
95+
96+
publications{
97+
create<MavenPublication>("maven"){
98+
groupId = "net.bridgesplash"
99+
artifactId = "sidebar-api"
100+
version = project.version as String
101+
from(components["java"])
102+
103+
pom{
104+
name.set(project.name)
105+
description.set("A sidebar library that feels uses state to handle updates")
106+
url.set("https://github.com/BridgeSplash/SidebarAPI")
107+
108+
developers{
109+
developer {
110+
id.set("tropicalshadow")
111+
name.set("TropicalShadow")
112+
email.set("me@tesseract.club")
113+
}
114+
}
115+
116+
issueManagement{
117+
system.set("GitHub")
118+
url.set("https://github.com/BridgeSplash/SidebarAPI/issues")
119+
}
120+
121+
scm{
122+
connection.set("scm:git:git://github.com/BridgeSplash/SidebarAPI.git")
123+
developerConnection.set("scm:git:ssh://github.com/BridgeSplash/SidebarAPI.git")
124+
url.set("https://github.com/BridgeSplash/SidebarAPI")
125+
tag.set("HEAD")
126+
}
127+
128+
ciManagement {
129+
system.set("Github Actions")
130+
url.set("https://github.com/BridgeSplash/SidebarAPI/actions")
131+
}
132+
}
133+
134+
}
135+
}
136+
}

demo/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ dependencies {
1818
implementation("net.logstash.logback:logstash-logback-encoder:8.0")
1919
}
2020

21+
java{
22+
toolchain.languageVersion = JavaLanguageVersion.of(21)
23+
}
24+
2125
application {
2226
mainClass.set("net.minestom.demo.Main")
2327
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Sat Sep 27 08:51:38 BST 2025
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package net.bridgesplash.sidebar.event;
2+
3+
import net.bridgesplash.sidebar.SidebarAPI;
4+
import net.minestom.server.event.Event;
5+
import net.minestom.server.event.EventNode;
6+
import net.minestom.server.event.player.PlayerDisconnectEvent;
7+
import org.jetbrains.annotations.NotNull;
8+
9+
/**
10+
* Event class for handling sidebar events.
11+
*
12+
* @author TropicalShadow
13+
*/
14+
public final class SidebarEvents {
15+
16+
private static final EventNode<@NotNull Event> EVENT_NODE = EventNode.all("sidebar-api-events");
17+
18+
private SidebarEvents() {
19+
20+
}
21+
22+
/**
23+
* Registers all events for the sidebar API.
24+
*
25+
* @param eventNode the event node to register the events to
26+
*/
27+
public static void registerEvents(EventNode<@NotNull Event> eventNode) {
28+
EVENT_NODE.addListener(PlayerDisconnectEvent.class, event -> {
29+
// Remove the sidebar when the player disconnects
30+
SidebarAPI.getSidebarManager().removeSidebar(event.getPlayer());
31+
});
32+
33+
eventNode.addChild(EVENT_NODE);
34+
}
35+
36+
/**
37+
* Unregisters all events for the sidebar API.
38+
*
39+
* @param eventNode parent event node
40+
*/
41+
private static void unregisterEvents(EventNode<@NotNull Event> eventNode) {
42+
eventNode.removeChild(EVENT_NODE);
43+
}
44+
45+
}

0 commit comments

Comments
 (0)