Skip to content
Open

26.2 #43

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
52 changes: 25 additions & 27 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
name: Build and Release
name: Build and Release.

on:
push:
tags: [ '*' ] # Запуск при создании тега
branches: [ 'master' ]
tags: [ '*' ]
workflow_dispatch:

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
- uses: actions/checkout@v4
- name: Set up JDK 25
uses: actions/setup-java@v5
with:
java-version: '11'
java-version: '25'
distribution: 'temurin'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build with Gradle
uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7
with:
arguments: build
run: ./gradlew build --no-daemon
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
Expand All @@ -25,35 +31,27 @@ jobs:
build/libs/MusicBox*-all.jar

release:
if: startsWith(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: musicbox
path: build/libs/
- name: Get Artifact Filename
id: get_filename
run: echo "FILENAME=$(basename build/libs/MusicBox*-all.jar)" >> $GITHUB_ENV
run: echo "FILENAME=$(basename build/libs/MusicBox*-all.jar)" >> "$GITHUB_ENV"
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
files: build/libs/${{ env.FILENAME }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/libs/${{ env.FILENAME }}
asset_name: ${{ env.FILENAME }}
asset_content_type: application/java-archive
prerelease: false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

[![](http://img.youtube.com/vi/uwygwHRrvkA/0.jpg)](http://www.youtube.com/watch?v=uwygwHRrvkA "")

[Ссылка на spigot](https://www.spigotmc.org/resources/musicbox-music-on-discs.67949/)
[Ссылка на spigot](https://www.spigotmc.org/resources/musicbox-music-on-discs.67949/)
11 changes: 7 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
`java-library`
id("io.github.goooler.shadow") version "8.1.7"
id("io.freefair.lombok") version "8.6"
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
id("io.papermc.paperweight.userdev") version "1.7.1" apply false
id("com.gradleup.shadow") version "9.6.1"
id("io.freefair.lombok") version "9.5.0"
id("de.eldoria.plugin-yml.bukkit") version "0.9.0"
id("io.papermc.paperweight.userdev") version "2.0.0-beta.21" apply false
}

bukkit {
Expand Down Expand Up @@ -69,4 +69,7 @@ dependencies {
api(project(":nms:versions:20_5", "reobf"))
api(project(":nms:versions:21", "reobf"))
api(project(":nms:versions:21_2", "reobf"))
// 26.1+ dev bundles (data version 8) no longer provide reobf mappings,
// so the module is consumed as its default (mojang-mapped) jar
api(project(":nms:versions:26_2"))
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ public class NMSUtils {
public static int parseMajorVersion(String raw) {
int firstDotIndex = raw.indexOf(".");

raw = raw.substring(firstDotIndex + 1);
String first = raw.substring(0, firstDotIndex);

int secondDotIndex = raw.indexOf(".");
// Legacy scheme: 1.19.2 -> major version is 19 (the second segment)
// New scheme: 26.2 -> major version is 26 (the first segment)
if (first.equals("1")) {
raw = raw.substring(firstDotIndex + 1);

if (secondDotIndex != -1)
raw = raw.substring(0, secondDotIndex);
int secondDotIndex = raw.indexOf(".");

return Integer.parseInt(raw);
if (secondDotIndex != -1)
raw = raw.substring(0, secondDotIndex);

return Integer.parseInt(raw);
}

return Integer.parseInt(first);
}

public static String getRawVersion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ public class JukeboxFactory {
int iV = NMSUtils.parseMajorVersion(raw);

String className;
if (iV == 21) {
if (iV == 26) {
switch (raw) {
case "26.2":
className = START_PATH + "V26_2";
break;
default:
className = null;
break;
}
} else if (iV == 21) {
switch (raw) {
case "1.21":
case "1.21.1":
Expand Down
10 changes: 10 additions & 0 deletions nms/versions/26_2/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
id("io.papermc.paperweight.userdev")
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
}
dependencies {
// Paper 26.2 (new versioning scheme, dev bundle data version 8 requires paperweight 2.x)
paperweight.paperDevBundle("26.2.build.112-stable")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ru.spliterash.musicbox.minecraft.nms.jukebox.versions;

import net.minecraft.world.level.block.entity.JukeboxBlockEntity;
import org.bukkit.block.Jukebox;
import org.bukkit.craftbukkit.block.CraftJukebox;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import ru.spliterash.musicbox.minecraft.nms.jukebox.IJukebox;

public class V26_2 implements IJukebox {
private final JukeboxBlockEntity tileEntity;

public V26_2(Jukebox jukebox) {
CraftJukebox craft = (CraftJukebox) jukebox;
tileEntity = craft.getBlockEntity();
}

public void setJukebox(ItemStack item) {
net.minecraft.world.item.ItemStack converted = CraftItemStack.asNMSCopy(item);
tileEntity.setSongItemWithoutPlaying(converted, 0);

}

public ItemStack getJukebox() {
net.minecraft.world.item.ItemStack nmsItem = tileEntity.getTheItem();
if (nmsItem.isEmpty())
return null;

return CraftItemStack.asBukkitCopy(nmsItem);
}
}
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ include "nms:versions:20_2"
include "nms:versions:20_3"
include "nms:versions:20_5"
include "nms:versions:21"
include "nms:versions:21_2"
include "nms:versions:21_2"
include "nms:versions:26_2"