Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make GitHub Actions working again #259

Merged
merged 2 commits into from
Jul 8, 2024
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
18 changes: 13 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,31 @@ name: Build
on:
push:
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
project: [ 'admin', 'bedtime', 'core', 'enchantments', 'permissions', 'portals', 'regions', 'trifles', 'waterfall', 'velocity' ]
project: [ 'admin', 'bedtime', 'core', 'enchantments', 'permissions', 'portals', 'regions', 'trifles', 'velocity' ]

steps:
- uses: actions/checkout@v3.0.0
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3.0.0
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'


- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'

- name: Gradle build
run: |
cd vane-${{ matrix.project }}
Expand All @@ -29,8 +37,8 @@ jobs:
echo "git_hash=$git_hash" >> $GITHUB_ENV

- name: Upload JAR
if: ${{ github.event_name == 'push' }}
uses: actions/upload-artifact@v3
if: ${{ github.event_name != 'pull_request'}}
uses: actions/upload-artifact@v4
with:
name: vane-${{ matrix.project }}-${{ env.git_hash }}.jar
path: target/vane-${{ matrix.project }}-*.jar
13 changes: 13 additions & 0 deletions vane-proxy-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
plugins {
id("io.github.goooler.shadow") version "8.1.7"
id("net.kyori.blossom") version "1.2.0"
}

blossom {
replaceToken("\$VERSION", project.version)
}

dependencies {
implementation(group = "com.electronwill.night-config", name = "toml", version = "3.6.4")
implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.30")
implementation(rootProject.project(":vane-core"))
compileOnly(group = "org.json", name = "json", version = "20200518")
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

tasks {
Expand All @@ -15,5 +27,6 @@ tasks {
}

relocate("com.electronwill.night-config", "org.oddlama.vane.vane_velocity.external.night-config")
relocate("org.json", "org.oddlama.vane.external.json")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;

import static org.oddlama.vane.util.TimeUtil.format_time;
import static org.oddlama.vane.proxycore.util.TimeUtil.format_time;

public class Maintenance {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.oddlama.vane.proxycore.ProxyPlayer;
import org.oddlama.vane.proxycore.VaneProxyPlugin;

import static org.oddlama.vane.util.TimeUtil.parse_time;
import static org.oddlama.vane.proxycore.util.TimeUtil.parse_time;

public class ProxyMaintenanceCommand extends ProxyCommand {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.logging.Level;

import static org.oddlama.vane.proxycore.Util.add_uuid;
import static org.oddlama.vane.util.Resolve.resolve_uuid;
import static org.oddlama.vane.proxycore.util.Resolve.resolve_uuid;

public abstract class PreLoginEvent implements ProxyEvent, ProxyCancellableEvent {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.oddlama.vane.proxycore.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;

import org.json.JSONException;
import org.json.JSONObject;

public class IOUtil {
private static String read_all(Reader rd) throws IOException {
final var sb = new StringBuilder();
int cp;
while ((cp = rd.read()) != -1) {
sb.append((char) cp);
}
return sb.toString();
}

public static JSONObject read_json_from_url(String url) throws IOException, JSONException, URISyntaxException {
try (final var rd = new BufferedReader(
new InputStreamReader(new URI(url).toURL().openStream(), StandardCharsets.UTF_8))) {
return new JSONObject(read_all(rd));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.oddlama.vane.proxycore.util;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.UUID;

import org.json.JSONException;

public class Resolve {
public static class Skin {

public String texture;
public String signature;
}

public static Skin resolve_skin(UUID id) throws IOException, JSONException, URISyntaxException {
final var url = "https://sessionserver.mojang.com/session/minecraft/profile/" + id + "?unsigned=false";

final var json = IOUtil.read_json_from_url(url);
final var skin = new Skin();
final var obj = json.getJSONArray("properties").getJSONObject(0);
skin.texture = obj.getString("value");
skin.signature = obj.getString("signature");
return skin;
}

public static UUID resolve_uuid(String name) throws IOException, JSONException, URISyntaxException {
final var url = "https://api.mojang.com/users/profiles/minecraft/" + name;

final var json = IOUtil.read_json_from_url(url);
final var id_str = json.getString("id");
final var uuid_str = id_str.replaceFirst(
"(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)",
"$1-$2-$3-$4-$5");
return UUID.fromString(uuid_str);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.oddlama.vane.proxycore.util;

import java.util.HashMap;
import java.util.Map;

public class TimeUtil {
private static Map<Character, Long> time_multiplier;

static {
Map<Character, Long> mult = new HashMap<>();
mult.put('s', 1000L); // seconds
mult.put('m', 60000L); // minutes
mult.put('h', 3600000L); // hours
mult.put('d', 86400000L); // days
mult.put('w', 604800000L); // weeks
mult.put('y', 31536000000L); // years
time_multiplier = mult;
}

public static long parse_time(String input) throws NumberFormatException {
long ret = 0;

for (String time : input.split("(?<=[^0-9])(?=[0-9])")) {
String content[] = time.split("(?=[^0-9])");

if (content.length != 2) {
throw new NumberFormatException("missing multiplier");
}

Long mult = time_multiplier.get(content[1].replace("and", "").replaceAll("[,+\\.\\s]+", "").charAt(0));
if (mult == null) {
throw new NumberFormatException("\"" + content[1] + "\" is not a valid multiplier");
}

ret += Long.parseLong(content[0]) * mult;
}

return ret;
}

public static String format_time(long millis) {
String ret = "";

long days = millis / 86400000L;
long hours = (millis / 3600000L) % 24;
long minutes = (millis / 60000L) % 60;
long seconds = (millis / 1000L) % 60;

if (days > 0) {
ret += days + "d";
}

if (hours > 0) {
ret += hours + "h";
}

if (minutes > 0) {
ret += minutes + "m";
}

if (seconds > 0 || ret.length() == 0) {
ret += seconds + "s";
}

return ret;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.oddlama.vane.proxycore.util;

public final class Version {

public static final String VERSION = "$VERSION";

}
19 changes: 6 additions & 13 deletions vane-velocity/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ dependencies {
implementation(rootProject.project(":vane-proxy-core"))
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

tasks.create<Copy>("copyJar") {
from(tasks.shadowJar)
into("${project.rootProject.projectDir}/target")
Expand All @@ -27,19 +33,6 @@ tasks {
include(dependency("org.bstats:bstats-base"))
include(dependency("org.json:json"))
include(dependency(rootProject.project(":vane-proxy-core")))

// Utilities to include from vane-core.util
val includedUtils = listOf(
"Resolve",
"TimeUtil",
"IOUtil"
)

from(rootProject.project(":vane-core").sourceSets.main.get().output) {
for (i in includedUtils) {
include("org/oddlama/vane/util/$i*.class")
}
}
}

relocate("org.json", "org.oddlama.vane.vane_velocity.external.json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.bstats.velocity.Metrics;
import org.oddlama.vane.proxycore.VaneProxyPlugin;
import org.oddlama.vane.proxycore.log.slf4jCompatLogger;
import org.oddlama.vane.util.Version;
import org.oddlama.vane.proxycore.util.Version;
import org.oddlama.velocity.commands.Maintenance;
import org.oddlama.velocity.commands.Ping;
import org.oddlama.velocity.compat.VelocityCompatProxyServer;
Expand Down
Loading