Skip to content

Commit

Permalink
Modularize Codex (#39)
Browse files Browse the repository at this point in the history
* Modularize Codex for easier updates

* Reorganize some other stuff

* Get javadocs aggregating properly

* Add Nexo support in new code

* Code cleanup

* Add setKiller to NMSProvider for Fabled

* Add 1.21.4

* Remove VersionManager in favor of everything located in NMSProvider

Add some other NMS methods to get Divinity and Fabled building

* Slight organization tweaks

* Split bungee into separate module

* Oops

* Ignore build directories

* Fix some NMS-related issues

* Move armor trims to version specific classes

* Move other methods to NMS

* Create EntityDamageByEntity via version-specific invocations

* For testing, we can't actually compile against 1.16... This will be fun

* More cleanup

* Add some Attribute stuff to compatibility layers

* De-Reflection InventoryUtil

* Move event interfaces and event definitions to -api

* Move other enums/interfaces to -api

* Centralize fix/remove colors

* Clean up

* Fix testing issues

* Work out a couple of kinks

* Update nexo

* Update nexo

* Update version updating script

* Update workflows

* Can I use sdkman to run build tools?

* Maybe this will work

* More info

* More info

* Rearrange

* Let's build spigot for release builds only

* Don't update the nms version automatically
  • Loading branch information
Travja authored Dec 12, 2024
1 parent 0fe3745 commit 5fb06c3
Show file tree
Hide file tree
Showing 431 changed files with 5,854 additions and 3,345 deletions.
10 changes: 5 additions & 5 deletions .github/notify_published.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

is_dev = len(sys.argv) >= 3 and bool(sys.argv[2])
search_string = \
r'Uploaded to (ossrh|central): (https:\/\/s01\.oss\.sonatype\.org(:443)?\/.*?\/studio\/magemonkey\/(.*?)\/(.*?)\/(' \
r'Uploaded to (ossrh|central): (https:\/\/s01\.oss\.sonatype\.org(:443)?\/.*?\/studio\/magemonkey\/(codex)\/(.*?)\/(' \
r'.*?)(?<!sources|javadoc)\.jar(?!\.asc)) '


def get_info():
with open('log.txt', 'r') as file:
content = file.read()
data = re.findall(search_string, content, re.MULTILINE)
found_version = data[0][5]
artifact_id = data[0][3]
artifact_url = data[0][1]
found_version = data[-1][5]
artifact_id = data[-1][3]
artifact_url = data[-1][1]
return found_version, artifact_id, artifact_url


Expand All @@ -32,7 +32,7 @@ def get_info():
'username': 'Dev Mage',
'author': {
'name': 'New ' + ('Dev ' if is_dev else '') + 'Build Available!',
'url': 'https://github.com/promcteam/' + name
'url': 'https://github.com/magemonkeystudios/' + name
},
'image': {
'url': 'https://fabled.magemonkey.studio/' + ('dev_build.gif' if is_dev else 'release_build.gif')
Expand Down
42 changes: 29 additions & 13 deletions .github/update_version.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,56 @@
import os
import re
import sys

is_dev = len(sys.argv) >= 2 and eval(sys.argv[1].lower().capitalize())
prep = not is_dev and len(sys.argv) >= 3 and bool(sys.argv[2])


def replace_version():
regex = r'^[ ]{4}<version>((((\d+\.?)+)((-R(\d+)\.?)(\d+)?)?)(-SNAPSHOT)?)<\/version>$'
with open('pom.xml', 'r') as pom:
def replace_version(pom_path):
regex = r'(<artifactId>.*codex.*<\/artifactId>\s*)<version>((((\d+\.?)+)((-R(\d+)\.?)(\d+)?)?)(-SNAPSHOT)?)<\/version>$'
with open(pom_path, 'r') as pom:
contents = pom.read()
ver = re.findall(regex, contents, re.MULTILINE)
version = ver[0][0]
bare_version = ver[0][2]
version = ver[0][1]
bare_version = ver[0][3]
if is_dev:
if not '-R' in version:
new_version = version + '-R0.1-SNAPSHOT'
elif not '-SNAPSHOT' in version:
new_version = version + '.1-SNAPSHOT'
else:
r_version = ver[0][5]
patch = int(ver[0][7]) + 1
r_version = ver[0][6]
patch = int(ver[0][8]) + 1
new_version = bare_version + r_version + str(patch) + '-SNAPSHOT'
elif prep:
r_version = int(ver[0][6]) + 1
r_version = int(ver[0][7]) + 1
new_version = bare_version + '-R' + str(r_version)
else:
version = ver[0][2]
minor = int(ver[0][3])
version = ver[0][3]
minor = int(ver[0][4])
new_version = version[:-(len(str(minor)))] + str(minor + 1)
contents = re.sub(regex,
' <version>' + new_version + '</version>',
ver[0][0] + '<version>' + new_version + '</version>',
contents,
1,
re.MULTILINE)
with open('pom.xml', 'w') as pom:
with open(pom_path, 'w') as pom:
pom.write(contents)


replace_version()
def find_pom_files(directory):
pom_files = []
for root, dirs, files in os.walk(directory):
for file in files:
if file == 'pom.xml':
pom_files.append(os.path.join(root, file))
return pom_files

if __name__ == "__main__":
directory = os.getcwd()
pom_files = find_pom_files(directory)
for pom_file in pom_files:
# NMS versions should be updated manually when NMS is actually changed
if '-nms' in pom_file: continue
print(f'Updating version in {pom_file}')
replace_version(pom_file)
5 changes: 4 additions & 1 deletion .github/workflows/devbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ jobs:
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
mvn clean deploy -P gpg,publish -DcreateChecksum=true 2>&1 | tee log.txt
mvn clean deploy -pl \!codex-nms,\!codex-nms/codex-nms-v1_16_5,\!codex-nms/codex-nms-v1_17_1,\
\!codex-nms/codex-nms-v1_18_2,\!codex-nms/codex-nms-v1_19_4,\!codex-nms/codex-nms-v1_20_2,\
\!codex-nms/codex-nms-v1_20_4,\!codex-nms/codex-nms-v1_20_6,\!codex-nms/codex-nms-v1_21_1,\
\!codex-nms/codex-nms-v1_21_2,\!codex-nms/codex-nms-v1_21_4 -P gpg,publish -DcreateChecksum=true 2>&1 | tee log.txt
result_code=${PIPESTATUS[0]}
exit $result_code
- name: Tag release version
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,25 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
java-version: |
11
17
21
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- uses: actions/checkout@v4
- name: 'Create settings.xml'
uses: s4u/[email protected]
with:
githubServer: false
- name: Build with Maven
run: mvn clean package -e
run: mvn clean package -e -pl \!codex-nms,\!codex-nms/codex-nms-v1_16_5,\!codex-nms/codex-nms-v1_17_1,\
\!codex-nms/codex-nms-v1_18_2,\!codex-nms/codex-nms-v1_19_4,\!codex-nms/codex-nms-v1_20_2,\
\!codex-nms/codex-nms-v1_20_4,\!codex-nms/codex-nms-v1_20_6,\!codex-nms/codex-nms-v1_21_1,\
\!codex-nms/codex-nms-v1_21_2,\!codex-nms/codex-nms-v1_21_4
35 changes: 30 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,47 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.ACTIONS_PAT }}
- name: Configure git
run: |
git config user.name "Build Monkey"
git config user.email "<>"
- name: Set up JDK 17
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
java-version: |
11
17
21
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Download BuildTools
run: wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
- name: Build Spigot 1.16.5
run: $JAVA_HOME_11_X64/bin/java -jar BuildTools.jar --rev 1.16.5
- name: Build Spigot 1.17.1
run: $JAVA_HOME_17_X64/bin/java -jar BuildTools.jar --rev 1.17.1
- name: Build Spigot 1.18.2
run: $JAVA_HOME_17_X64/bin/java -jar BuildTools.jar --rev 1.18.2
- name: Build Spigot 1.19.4
run: $JAVA_HOME_17_X64/bin/java -jar BuildTools.jar --rev 1.19.4
- name: Build Spigot 1.20.2
run: java -jar BuildTools.jar --rev 1.20.2
- name: Build Spigot 1.20.4
run: java -jar BuildTools.jar --rev 1.20.4
- name: Build Spigot 1.20.6
run: java -jar BuildTools.jar --rev 1.20.6
- name: Build Spigot 1.21.1
run: java -jar BuildTools.jar --rev 1.21.1
- name: Build Spigot 1.21.2
run: java -jar BuildTools.jar --rev 1.21.2
- name: Build Spigot 1.21.4
run: java -jar BuildTools.jar --rev 1.21.4
- uses: actions/checkout@v4
with:
token: ${{ secrets.ACTIONS_PAT }}
- name: 'Create settings.xml'
uses: s4u/[email protected]
with:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ target/
*.iml
/.idea/
gh-pages/
apidocs/
settings.xml
toolchains.xml
log.txt
logs/
logs/
**/build/*.jar
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[![Build](https://github.com/promcteam/codex/actions/workflows/release.yml/badge.svg?branch=main)](https://s01.oss.sonatype.org/content/repositories/releases/studio/magemonkey/codex/1.0.1-R0.18-SNAPSHOT)
[![Build](https://github.com/promcteam/codex/actions/workflows/devbuild.yml/badge.svg?branch=dev)](https://s01.oss.sonatype.org/content/repositories/snapshots/studio/magemonkey/codex/1.0.1-R0.18-SNAPSHOT)
[![Build](https://github.com/magemonkeystudios/codex/actions/workflows/release.yml/badge.svg?branch=main)](https://s01.oss.sonatype.org/content/repositories/releases/studio/magemonkey/codex/1.1.0-R0.1-SNAPSHOT)
[![Build](https://github.com/magemonkeystudios/codex/actions/workflows/devbuild.yml/badge.svg?branch=dev)](https://s01.oss.sonatype.org/content/repositories/snapshots/studio/magemonkey/codex/1.1.0-R0.1-SNAPSHOT)
[![Discord](https://dcbadge.vercel.app/api/server/6UzkTe6RvW?style=flat)](https://discord.gg/6UzkTe6RvW)

# CodexCore (Formerly ProMCCore)
# Codex (Formerly ProMCCore)

If you wish to use CodexCore as a dependency in your projects, CodexCore is available through Maven Central
If you wish to use Codex as a dependency in your projects, Codex is available through Maven Central
or snapshots through Sonatype.

```xml
Expand All @@ -16,12 +16,12 @@ or snapshots through Sonatype.
<dependency>
<groupId>studio.magemonkey</groupId>
<artifactId>codex</artifactId>
<version>1.0.1-R0.18-SNAPSHOT</version>
<version>1.1.0-R0.1-SNAPSHOT</version>
</dependency>
```

### A huge thanks to our contributors

<a href="https://github.com/promcteam/codex/graphs/contributors">
<img src="https://contrib.rocks/image?repo=promcteam/codex" />
<a href="https://github.com/magemonkeystudios/codex/graphs/contributors">
<img src="https://contrib.rocks/image?repo=magemonkeystudios/codex" />
</a>
File renamed without changes.
108 changes: 108 additions & 0 deletions codex-api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>studio.magemonkey</groupId>
<artifactId>codex-parent</artifactId>
<version>1.1.0-R0.1-SNAPSHOT</version>
</parent>

<artifactId>codex-api</artifactId>

<repositories>
<repository>
<id>nexo</id>
<name>Nexo Repository</name>
<url>https://repo.nexomc.com/snapshots/</url>
</repository>
<repository>
<id>oraxen</id>
<name>Oraxen Repository</name>
<url>https://repo.oraxen.com/releases</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
</dependency>


<dependency>
<groupId>studio.magemonkey</groupId>
<artifactId>codex-bungee</artifactId>
<version>1.1.0-R0.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.nexomc</groupId>
<artifactId>nexo</artifactId>
<version>0.5.0-dev.14</version>
<classifier>dev</classifier>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.th0rgal</groupId>
<artifactId>oraxen</artifactId>
<version>1.173.0</version>
<classifier>dev</classifier>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>me.gabytm.util</groupId>
<artifactId>actions-spigot</artifactId>
</exclusion>
<exclusion>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.ticxo</groupId>
<artifactId>PlayerAnimator</artifactId>
</exclusion>
<exclusion>
<groupId>com.github.stefvanschie.inventoryframework</groupId>
<artifactId>IF</artifactId>
</exclusion>
<exclusion>
<groupId>io.th0rgal</groupId>
<artifactId>protectionlib</artifactId>
</exclusion>
<exclusion>
<groupId>dev.triumphteam</groupId>
<artifactId>triumph-gui</artifactId>
</exclusion>
<exclusion>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
</exclusion>
<exclusion>
<groupId>com.jeff-media</groupId>
<artifactId>custom-block-data</artifactId>
</exclusion>
<exclusion>
<groupId>com.jeff-media</groupId>
<artifactId>persistent-data-serializer</artifactId>
</exclusion>
<exclusion>
<groupId>com.jeff_media</groupId>
<artifactId>MorePersistentDataTypes</artifactId>
</exclusion>
<exclusion>
<groupId>gs.mclo</groupId>
<artifactId>java</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
33 changes: 33 additions & 0 deletions codex-api/src/main/java/studio/magemonkey/codex/Codex.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package studio.magemonkey.codex;

import lombok.Setter;
import org.bukkit.plugin.java.JavaPlugin;

public class Codex {
@Setter
public static JavaPlugin plugin;

public static JavaPlugin getPlugin() {
if (plugin == null) {
throw new IllegalStateException("Codex has not been initialized");
}

return plugin;
}

public static void info(String message) {
getPlugin().getLogger().info(message);
}

public static void warn(String message) {
getPlugin().getLogger().warning(message);
}

public static void error(String message) {
getPlugin().getLogger().severe(message);
}

public static void trace(String message) {
getPlugin().getLogger().fine(message);
}
}
Loading

0 comments on commit 5fb06c3

Please sign in to comment.