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
24 changes: 4 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,34 +105,20 @@ jobs:
fi

- name: Build (package)
run: mvn -B -s $GITHUB_WORKSPACE/settings.xml package
run: mvn -B -s $GITHUB_WORKSPACE/settings.xml -DskipTests -Pwith-shade package

- name: Deploy Release to GitHub Packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn -B -s $GITHUB_WORKSPACE/settings.xml -DskipTests deploy

- name: Verify built artifacts
run: |
set -e
echo "Contents of target/:"
ls -1 target
# Capture a primary jar (non sources/javadoc) for convenience
MAIN_JAR=$(ls target/*.jar | grep -v '\-sources\.jar$' | grep -v '\-javadoc\.jar$' | head -n1 || true)
if [[ -z "$MAIN_JAR" ]]; then
echo "ERROR: No main artifact jar found."
exit 1
fi
cp "$MAIN_JAR" main-artifact.jar
echo "Selected main artifact: $MAIN_JAR"

- name: Create & Push Git Tag
run: |
set -e
TAG="${{ steps.version.outputs.version }}"
if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then
echo "Tag ${TAG} already exists unexpectedly (race condition?)."
exit 1
echo "Tag ${TAG} already exists unexpectedly (race condition?)."
exit 1
Comment on lines +120 to +121
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is inconsistent. The closing fi statement should be aligned with the opening if statement. This should be:

if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then
  echo "Tag ${TAG} already exists unexpectedly (race condition?)."
  exit 1
fi
Suggested change
echo "Tag ${TAG} already exists unexpectedly (race condition?)."
exit 1
echo "Tag ${TAG} already exists unexpectedly (race condition?)."
exit 1

Copilot uses AI. Check for mistakes.
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
Expand All @@ -146,9 +132,7 @@ jobs:
name: "SingularityLib ${{ steps.version.outputs.version }}"
generate_release_notes: true
files: |
target/*-sources.jar
target/*-javadoc.jar
main-artifact.jar
`target/*.jar`
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file path pattern should use glob pattern syntax, not backticks. In YAML, backticks don't have special meaning for pattern matching. This should be:

files: |
  target/*.jar

Without the backticks, the glob pattern will work correctly to match all JAR files in the target directory.

Suggested change
`target/*.jar`
target/*.jar

Copilot uses AI. Check for mistakes.

- name: Summary
run: |
Expand Down
71 changes: 45 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.pinont</groupId>
<artifactId>singularitylib</artifactId>
<version>1.3.3-SNAPSHOT</version>
<version>1.3.3</version>
<packaging>jar</packaging>

<name>SingularityLib</name>
Expand Down Expand Up @@ -38,6 +38,50 @@
</developer>
</developers>

<profiles>
<profile>
<id>with-shade</id>
<!-- Optional: still allow activation by property 'shade' if you prefer -Dshade=true -->
<activation>
<property>
<name>shade</name>
</property>
</activation>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<configuration>
<!-- Attach shaded artifact instead of replacing the main jar -->
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>shaded</shadedClassifierName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>org.reflections:reflections</artifact>
<includes>
<include>org/reflections/**</include>
</includes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<scm>
<url>https://github.com/Pinont/SingularityLib</url>
<connection>scm:git:https://github.com/Pinont/SingularityLib.git</connection>
Expand Down Expand Up @@ -131,31 +175,6 @@
</executions>
</plugin>

<!-- Shade -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<configuration>
<filters>
<filter>
<artifact>org.reflections:reflections</artifact>
<includes>
<include>org/reflections/**</include>
</includes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Explicit deploy plugin version -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.github.pinont.singularitylib.api.utils;

import com.github.pinont.singularitylib.api.enums.PlayerInventorySlotType;
import com.github.pinont.singularitylib.api.manager.ConfigManager;
import com.github.pinont.singularitylib.plugin.CorePlugin;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -28,6 +30,17 @@ public class Common {
public Common() {
}

/**
* Gets the current API version.
*
* @return the API version string
*/
public static String getAPIVersion() {
ConfigManager apiConfig = new ConfigManager(CorePlugin.getInstance(), "api-version.yml");
String version = apiConfig.getConfig().getString("api-version", "1.0.0");
return "V-" + version;
}
Comment on lines +38 to +42
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ConfigManager creates an empty file when the configuration doesn't exist (see lines 32-36 in ConfigManager.java), but it doesn't copy the default content from src/main/resources/api-version.yml. This means when getAPIVersion() is first called, it will create an empty api-version.yml file in the plugin's data folder, and the version will default to "1.0.0" instead of the actual version specified in the resource file.

To properly load the resource file with Maven-filtered version, you should either:

  1. Use plugin.saveResource("api-version.yml", false) before creating the ConfigManager to copy the resource file
  2. Or read the version directly from the plugin's JAR resources using plugin.getResource("api-version.yml")

Example fix:

public static String getAPIVersion() {
    try (InputStream is = CorePlugin.getInstance().getResource("api-version.yml")) {
        if (is != null) {
            YamlConfiguration config = YamlConfiguration.loadConfiguration(new InputStreamReader(is));
            String version = config.getString("api-version", "1.0.0");
            return "V-" + version;
        }
    } catch (IOException e) {
        // Log error
    }
    return "V-1.0.0";
}

Copilot uses AI. Check for mistakes.

/**
* Colorizes a string message using MiniMessage format.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.pinont.singularitylib.plugin;

import com.github.pinont.singularitylib.api.utils.Common;
import com.github.pinont.singularitylib.plugin.listener.PlayerListener;
import com.github.pinont.singularitylib.api.command.SimpleCommand;
import com.github.pinont.singularitylib.api.manager.ConfigManager;
Expand Down Expand Up @@ -93,16 +94,6 @@ public static void sendConsoleMessage(String message) {

private final List<Listener> listeners = new ArrayList<>();

/**
* Gets the current API version.
*
* @return the API version string
*/
public static String getAPIVersion() {
String version = "1.3.0";
return "V-" + version;
}

private ConfigManager pluginConfig;

/**
Expand Down Expand Up @@ -174,7 +165,7 @@ public final void onEnable() {
}

// Initialize API To Plugin.
sendConsoleMessage(ChatColor.WHITE + "" + ChatColor.ITALIC + "Hooked " + ChatColor.YELLOW + ChatColor.ITALIC + this.getName() + ChatColor.WHITE + ChatColor.ITALIC + " into " + ChatColor.LIGHT_PURPLE + ChatColor.ITALIC + "SingularityAPI! " + getAPIVersion());
sendConsoleMessage(ChatColor.WHITE + "" + ChatColor.ITALIC + "Hooked " + ChatColor.YELLOW + ChatColor.ITALIC + this.getName() + ChatColor.WHITE + ChatColor.ITALIC + " into " + ChatColor.LIGHT_PURPLE + ChatColor.ITALIC + "SingularityAPI! " + Common.getAPIVersion());
onPluginStart();
registerAPIListener(this, new PlayerListener());
// new CommandManager().register(this, this.simpleCommands);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/api-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
api-version: ${version}