Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/us/ajg0702/leaderboards/formatting/PlaceholderFormatter.java
#	src/main/java/us/ajg0702/leaderboards/formatting/formats/Time.java
#	src/test/java/us/ajg0702/leaderboards/formatting/formats/TimeTest.java
  • Loading branch information
ajgeiss0702 committed Jun 9, 2024
2 parents 7b4c566 + 55434b5 commit 287b361
Show file tree
Hide file tree
Showing 47 changed files with 1,794 additions and 260 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/javadocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ jobs:
with:
# Path of the directory containing the static assets.
path: build/docs/javadoc
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
47 changes: 31 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy Release to Polymart
name: Build, Publish to Updater, and Publish API Package

on:
push:
Expand All @@ -9,7 +9,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
environment: polymart_deploy
environment: updater
if: ${{ !github.event.pull_request.head.repo.fork }}
steps:
- uses: actions/checkout@v2
Expand All @@ -32,22 +32,37 @@ jobs:
# The desired behavior if no files are found using the provided path.
if-no-files-found: error
retention-days: 2
- name: Download changelogs
run: |
curl "https://ajg0702.us/pl/updater/changelogs.php?project=${{ github.repository }}" > changelogs.bb
curl "https://ajg0702.us/pl/updater/changelogs.php?project=${{ github.repository }}&format=html" > changelogs.html
- name: Deploy to Polymart
# - name: Download changelogs
# run: |
# curl "https://ajg0702.us/pl/updater/changelogs.php?project=${{ github.repository }}" > changelogs.bb
# curl "https://ajg0702.us/pl/updater/changelogs.php?project=${{ github.repository }}&format=html" > changelogs.html
# - name: Deploy to Polymart
# env:
# POLYMART_TOKEN: ${{ secrets.POLYMART_TOKEN }}
# MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
# run: |
# export VERSION=`cat build.gradle.kts | grep "version " | awk -F'"' '{print $2}'`
# file build/libs/ajLeaderboards-$VERSION.jar
# curl --no-progress-meter -F "file=@build/libs/ajLeaderboards-$VERSION.jar" -F api_key=$POLYMART_TOKEN -F resource_id="2726" -F version="$VERSION" -F title="v$VERSION" -F message="$(cat changelogs.bb)" "https://api.polymart.org/v1/postUpdate"
# curl --no-progress-meter -A "AJUPDATER/1.0" -H "Authorization: $MODRINTH_TOKEN" -F data="{\"project_id\": \"C9BKEl8Y\", \"version_number\": \"$VERSION\", \"name\": \"v$VERSION\", \"changelog\": \"$(cat changelogs.html)\", \"file_parts\": [\"file\"], \"version_type\": \"release\", \"loaders\": [\"paper\", \"spigot\"], \"featured\": true, \"game_versions\": $(curl https://ajg0702.us/pl/updater/mc-versions.php), \"dependencies\": [], \"primary_file\": \"file\"}" -F "file=@build/libs/ajLeaderboards-$VERSION.jar" "https://api.modrinth.com/v2/version"
# curl -v --no-progress-meter -H "Content-Type: application/json" --request POST -d "{\"content\": \"<@&861713403080999003>\", \"embeds\": [{\"title\": \"${{ github.event.repository.name }} v$VERSION\", \"description\": \"Changelogs\n\n$(curl "https://ajg0702.us/pl/updater/changelogs.php?project=${{ github.repository }}&format=markdown")\n\n[Modrinth](https://modrinth.com/plugin/ajleaderboards/version/$VERSION)\n[Polymart](https://polymart.org/resource/ajleaderboards.2726/updates)\", \"color\": 14845503, \"thumbnail\": {\"url\": \"https://ajg0702.us/pl/icons/${{ github.event.repository.name }}.png\"}}]}" "$DISCORD_WEBHOOK"
- name: Upload to updater (plugin-updates)
env:
POLYMART_TOKEN: ${{ secrets.POLYMART_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
export VERSION=`cat build.gradle.kts | grep "version " | awk -F'"' '{print $2}'`
file build/libs/ajLeaderboards-$VERSION.jar
curl --no-progress-meter -F "file=@build/libs/ajLeaderboards-$VERSION.jar" -F api_key=$POLYMART_TOKEN -F resource_id="2726" -F version="$VERSION" -F title="v$VERSION" -F message="$(cat changelogs.bb)" "https://api.polymart.org/v1/postUpdate"
curl --no-progress-meter -A "AJUPDATER/1.0" -H "Authorization: $MODRINTH_TOKEN" -F data="{\"project_id\": \"C9BKEl8Y\", \"version_number\": \"$VERSION\", \"name\": \"v$VERSION\", \"changelog\": \"$(cat changelogs.html)\", \"file_parts\": [\"file\"], \"version_type\": \"release\", \"loaders\": [\"paper\", \"spigot\"], \"featured\": true, \"game_versions\": $(curl https://ajg0702.us/pl/updater/mc-versions.php), \"dependencies\": [], \"primary_file\": \"file\"}" -F "file=@build/libs/ajLeaderboards-$VERSION.jar" "https://api.modrinth.com/v2/version"
curl -v --no-progress-meter -H "Content-Type: application/json" --request POST -d "{\"content\": \"<@&861713403080999003>\", \"embeds\": [{\"title\": \"${{ github.event.repository.name }} v$VERSION\", \"description\": \"Changelogs\n\n$(curl "https://ajg0702.us/pl/updater/changelogs.php?project=${{ github.repository }}&format=markdown")\n\n[Modrinth](https://modrinth.com/plugin/ajleaderboards/version/$VERSION)\n[Polymart](https://polymart.org/resource/ajleaderboards.2726/updates)\", \"color\": 14845503, \"thumbnail\": {\"url\": \"https://ajg0702.us/pl/icons/${{ github.event.repository.name }}.png\"}}]}" "$DISCORD_WEBHOOK"
- name: Upload to repo
VERSION=`cat build.gradle.kts | grep "version " | awk -F'"' '{print $2}'`
cd build/libs/
echo -n "{ \"message\": \"Plugin Update: $(echo ajLeaderboards-*.jar) (jar)\", \"content\": \"" > file_upload.json
base64 ajLeaderboards-*.jar >> file_upload.json
echo -n "\" }" >> file_upload.json
curl -X PUT -H "Authorization: Bearer $GH_TOKEN" -H "Content-Type: application/json" -d @file_upload.json "https://api.github.com/repos/ajgeiss0702/plugin-updates/contents/jars/free/$(echo ajLeaderboards*.jar)"
SHA=`curl -H "Authorization: Bearer $GH_TOKEN" -s "https://api.github.com/repos/ajgeiss0702/plugin-updates/contents/plugins/ajLeaderboards.json" | jq -r '.sha'`
NEW_JSON="{ \"latest\": \"$VERSION\", \"premium\": false }"
curl -X PUT -H "Authorization: Bearer $GH_TOKEN" -H "Content-Type: application/json" -d "{ \"message\": \"Plugin Update: $(echo ajLeaderboards-*.jar) (json)\", \"content\": \"$(echo $NEW_JSON | base64)\", \"sha\": \"$SHA\" }" "https://api.github.com/repos/ajgeiss0702/plugin-updates/contents/plugins/ajLeaderboards.json"
- name: Publish API to repo
env:
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7
Expand Down
22 changes: 17 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "us.ajg0702"
version = "2.8.0"
version = "2.9.0"

repositories {
mavenCentral()
Expand All @@ -20,6 +20,9 @@ repositories {
maven { url = uri("https://repo.citizensnpcs.co/") }
maven { url = uri("https://oss.sonatype.org/content/groups/public/") }
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") }
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }

mavenLocal()
}

dependencies {
Expand All @@ -32,18 +35,20 @@ dependencies {
compileOnly("org.xerial:sqlite-jdbc:3.32.3.2")
compileOnly("org.spongepowered:configurate-yaml:4.0.0")

implementation("org.bstats:bstats-bukkit:1.7")

implementation("net.kyori:adventure-api:4.12.0")
implementation("net.kyori:adventure-text-minimessage:4.12.0")
implementation("net.kyori:adventure-platform-bukkit:4.3.0")
implementation("net.kyori:adventure-platform-bukkit:4.3.3")

implementation("us.ajg0702:ajUtils:1.2.12")
implementation("us.ajg0702:ajUtils:1.2.27")
implementation("us.ajg0702.commands.platforms.bukkit:bukkit:1.0.0")
implementation("us.ajg0702.commands.api:api:1.0.0")

implementation("com.squareup.okhttp3:okhttp:4.11.0")

compileOnly("net.luckperms:api:5.4")

implementation("io.papermc:paperlib:1.0.7")

implementation(project(":nms:nms-legacy"))
implementation(project(":nms:nms-19"))

Expand Down Expand Up @@ -83,6 +88,13 @@ tasks.shadowJar {
relocate("org.spongepowered", "us.ajg0702.leaderboards.libs")
relocate("org.yaml", "us.ajg0702.leaderboards.libs")
relocate("io.leangen", "us.ajg0702.leaderboards.libs")
relocate("io.papermc.lib", "us.ajg0702.leaderboards.libs.paperlib")
relocate("com.squareup", "us.ajg0702.leaderboards.libs")
relocate("okhttp3", "us.ajg0702.leaderboards.libs.okhttp3")
relocate("okio", "us.ajg0702.leaderboards.libs.okio")
relocate("org.intellij", "us.ajg0702.leaderboards.libs.intellij")
relocate("org.jetbrains", "us.ajg0702.leaderboards.libs.jetbrains")
relocate("kotlin", "us.ajg0702.leaderboards.kotlin")

archiveBaseName.set("ajLeaderboards")
archiveClassifier.set("")
Expand Down
2 changes: 1 addition & 1 deletion nms/nms-19/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
compileOnly(project(":nms:nms-legacy"))
compileOnly("us.ajg0702:ajUtils:1.1.36")
compileOnly("us.ajg0702:ajUtils:1.2.27")
compileOnly("net.skinsrestorer:skinsrestorer-api:14.1.10")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,39 @@

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Skull;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.profile.PlayerProfile;
import us.ajg0702.leaderboards.nms.legacy.DebugWrapper;
import us.ajg0702.leaderboards.nms.legacy.VersionedHeadUtils;
import us.ajg0702.utils.foliacompat.CompatScheduler;

import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class HeadUtils19 implements VersionedHeadUtils {

private final DebugWrapper debug;

private final CompatScheduler scheduler;

private final Logger logger;

public HeadUtils19(DebugWrapper debug, CompatScheduler scheduler, Logger logger) {
this.debug = debug;
this.scheduler = scheduler;
this.logger = logger;
}

@Override
public ItemStack getHeadItem(UUID uuid, String name) {
ItemStack stack = new ItemStack(Material.PLAYER_HEAD);
Expand All @@ -24,7 +45,9 @@ public ItemStack getHeadItem(UUID uuid, String name) {

SkullMeta meta = (SkullMeta) itemMeta;

meta.setOwnerProfile(Bukkit.createPlayerProfile(uuid, name));
PlayerProfile profile = getProfile(uuid, name);

meta.setOwnerProfile(profile);

stack.setItemMeta(meta);

Expand All @@ -33,14 +56,39 @@ public ItemStack getHeadItem(UUID uuid, String name) {

@Override
public void setHeadBlock(Block block, UUID uuid, String name) {
BlockState blockState = block.getState();

if(!(blockState instanceof Skull)) throw new IllegalArgumentException("Block is not a skull!");
PlayerProfile profile = getProfile(uuid, name);

scheduler.runSync(block.getLocation(), () -> {
BlockState blockState = block.getState();

if(!(blockState instanceof Skull)) throw new IllegalArgumentException("Block is not a skull! " + block);

Skull skull = (Skull) blockState;

skull.setOwnerProfile(profile);
skull.update();
});
}

private PlayerProfile getProfile(UUID uuid, String name) {
PlayerProfile profile = Bukkit.getOfflinePlayer(uuid).getPlayerProfile();

Skull skull = (Skull) blockState;
if(profile.getTextures().isEmpty()) {
debug.infoW("Fetching textures for " + profile + " because they were empty");
if(Bukkit.isPrimaryThread()) {
Exception stack = new Exception("Texture fetch on the server thread! Contact aj!");
logger.log(Level.WARNING, "Texture fetch on the server thread! This shouldn't happen!", stack);
}
try {
profile = profile.update().get(5, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
throw new RuntimeException(e);
}
}

skull.setOwnerProfile(Bukkit.createPlayerProfile(uuid, name));
debug.infoW("Got profile for " + name + ": " + profile + " with textures" + profile.getTextures());

skull.update();
return profile;
}
}
3 changes: 2 additions & 1 deletion nms/nms-legacy/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ dependencies {
compileOnly(group = "org.spigotmc", name = "spigot", version = "1.19-R0.1-SNAPSHOT")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
compileOnly("us.ajg0702:ajUtils:1.1.36")
compileOnly("us.ajg0702:ajUtils:1.2.27")
compileOnly("net.skinsrestorer:skinsrestorer-api:14.1.10")
compileOnly("com.squareup.okhttp3:okhttp:4.11.0")
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package us.ajg0702.leaderboards.nms.legacy;

public interface DebugWrapper {

void infoW(String message);
boolean isDebugW();
}
Loading

0 comments on commit 287b361

Please sign in to comment.