refactor: simplify Song class by removing NamespacedKey and update createDiscs method
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 31s

This commit is contained in:
Your Name
2025-03-27 10:40:34 +01:00
parent a9cbece872
commit e515022768
2 changed files with 29 additions and 16 deletions

View File

@@ -0,0 +1,19 @@
name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on: [push]
jobs:
Explore-Gitea-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ gitea.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."

View File

@@ -28,14 +28,12 @@ public class CustomMusicDiscs implements Listener {
class Song {
private String title;
private String artist;
private NamespacedKey nsk;
private int number;
private String oggFile;
public Song(String title, String artist, NamespacedKey nsk, int number, String oggFile) {
public Song(String title, String artist, int number, String oggFile) {
this.title = title;
this.artist = artist;
this.nsk = nsk;
this.number = number;
this.oggFile = oggFile;
}
@@ -48,10 +46,6 @@ public class CustomMusicDiscs implements Listener {
return artist;
}
public NamespacedKey getNsk() {
return nsk;
}
public int getNo() {
return number;
}
@@ -70,14 +64,14 @@ public class CustomMusicDiscs implements Listener {
public void createDiscs(App app) {
List<Song> songList = new ArrayList<>();
songList.add(new Song("Stairway to Heaven", "Led Zeppelin", new NamespacedKey(app, "custom_music_disc"), 1,
"stairway_to_heaven"));
songList.add(new Song("M@GICAL☆CURE! LOVE ♥ SHOT!", "Hatsune Miku",
new NamespacedKey(app, "custom_music_disc2"), 2, "magical_cure_love_shot"));
songList.add(new Song("Aishiteru Banzai!", "LoveLive!", new NamespacedKey(app, "custom_music_disc3"), 3,
"aishiteru_banzai"));
songList.add(new Song("Miku", "Anamanaguchi", new NamespacedKey(app, "custom_music_disc4"), 4, "miku"));
songList.add(new Song("Melt", "Hatsune Miku", new NamespacedKey(app, "custom_music_disc5"), 5, "melt"));
songList.add(new Song("Stairway to Heaven", "Led Zeppelin", 1,"stairway_to_heaven"));
songList.add(new Song("M@GICAL☆CURE! LOVE ♥ SHOT!", "Hatsune Miku", 2, "magical_cure_love_shot"));
songList.add(new Song("Aishiteru Banzai!", "LoveLive!", 3, "aishiteru_banzai"));
songList.add(new Song("Miku", "Anamanaguchi", 4, "miku"));
songList.add(new Song("Melt", "Hatsune Miku", 5, "melt"));
songList.add(new Song("Wurzelheim", "Gamefreak", 6, "littleroot_town"));
songList.add(new Song("Lavandia", "Gamefreak", 7, "lavandia"));
songList.add(new Song("Neuborkia", "Gamefreak", 8, "neuborkia"));
for (Song song : songList) {
ItemStack customDisc = new ItemStack(Material.MUSIC_DISC_13);
@@ -92,7 +86,7 @@ public class CustomMusicDiscs implements Listener {
customDisc.setItemMeta(meta);
}
NamespacedKey nskDisc = song.nsk;
NamespacedKey nskDisc = new NamespacedKey(app, "custom_music_disc" + song.number);
ShapelessRecipe reciped = new ShapelessRecipe(nskDisc, customDisc);
reciped.addIngredient(1, Material.DIAMOND);
reciped.addIngredient(1, Material.PAPER);