Update
This commit is contained in:
parent
e044e1a088
commit
1441bb36b8
@ -2,6 +2,6 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="KotlinJpsPluginSettings">
|
<component name="KotlinJpsPluginSettings">
|
||||||
<option name="externalSystemId" value="Gradle" />
|
<option name="externalSystemId" value="Gradle" />
|
||||||
<option name="version" value="2.4.10" />
|
<option name="version" value="2.4.21" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
9
Jenkinsfile
vendored
9
Jenkinsfile
vendored
@ -16,17 +16,12 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
withCredentials([
|
withCredentials([
|
||||||
usernamePassword(credentialsId: 'jf-repo',
|
usernamePassword(credentialsId: 'jf-repo',
|
||||||
usernameVariable: 'REPO_USER',
|
usernameVariable: 'ORG_GRADLE_PROJECT_repoUsername',
|
||||||
passwordVariable: 'REPO_PASS')
|
passwordVariable: 'ORG_GRADLE_PROJECT_repoPassword')
|
||||||
]) {
|
]) {
|
||||||
sh '''
|
sh '''
|
||||||
echo "repoUser=$REPO_USER" > gradle.properties
|
|
||||||
echo "repoPassword=$REPO_PASS" >> gradle.properties
|
|
||||||
|
|
||||||
chmod +x ./gradlew
|
chmod +x ./gradlew
|
||||||
./gradlew clean shadowJar webDistribution
|
./gradlew clean shadowJar webDistribution
|
||||||
|
|
||||||
rm -f gradle.properties
|
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,6 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("net.kyori", "indra-common", "3.2.0")
|
implementation("net.kyori:indra-common:3.2.0")
|
||||||
implementation("com.google.code.gson", "gson", "2.15.0")
|
implementation("com.google.code.gson:gson:2.15.0")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,27 +18,28 @@ fun Project.applyJarMetadata(mainClass: String, module: String) {
|
|||||||
|
|
||||||
fun Project.applyJarMetadata(mainClass: String, module: String, preMain: String?) {
|
fun Project.applyJarMetadata(mainClass: String, module: String, preMain: String?) {
|
||||||
if ("jar" in tasks.names) {
|
if ("jar" in tasks.names) {
|
||||||
|
val git = git()
|
||||||
|
val commit = providers.provider { git?.commit()?.name }
|
||||||
|
val branch = providers.provider { git?.branchName() }
|
||||||
|
val baseVersion = version.toString()
|
||||||
tasks.named<Jar>("jar") {
|
tasks.named<Jar>("jar") {
|
||||||
manifest.attributes(
|
manifest.attributes(
|
||||||
"Main-Class" to mainClass,
|
"Main-Class" to mainClass,
|
||||||
"Automatic-Module-Name" to module,
|
"Automatic-Module-Name" to module,
|
||||||
"Implementation-Vendor" to "WCloudService",
|
"Implementation-Vendor" to "WCloudService",
|
||||||
"Implementation-Title" to Versions.wCloudCodeName,
|
"Implementation-Title" to Versions.wCloudCodeName,
|
||||||
"Implementation-Version" to project.version.toString() + "-${shortCommitHash()}")
|
"Implementation-Version" to commit.map { "$baseVersion-${it.take(8)}" }
|
||||||
|
.orElse("$baseVersion-unknown"),
|
||||||
|
"Git-Commit" to commit,
|
||||||
|
"Git-Branch" to branch)
|
||||||
// apply the pre-main class if given
|
// apply the pre-main class if given
|
||||||
if (preMain != null) {
|
if (preMain != null) {
|
||||||
manifest.attributes("Premain-Class" to preMain)
|
manifest.attributes("Premain-Class" to preMain)
|
||||||
}
|
}
|
||||||
// apply git information to manifest
|
|
||||||
git()?.applyVcsInformationToManifest(manifest)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.shortCommitHash(): String {
|
|
||||||
return git()?.commit()?.name?.substring(0, 8) ?: "unknown"
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Project.git(): IndraGitExtension? = rootProject.extensions.findByType()
|
fun Project.git(): IndraGitExtension? = rootProject.extensions.findByType()
|
||||||
|
|
||||||
fun Project.sourceSets(): SourceSetContainer = the<JavaPluginExtension>().sourceSets
|
fun Project.sourceSets(): SourceSetContainer = the<JavaPluginExtension>().sourceSets
|
||||||
|
|||||||
@ -12,7 +12,7 @@ defaultTasks("build", "test", "shadowJar")
|
|||||||
tasks.register<Zip>("webDistribution") {
|
tasks.register<Zip>("webDistribution") {
|
||||||
group = "distribution"
|
group = "distribution"
|
||||||
description = "Packages a self-contained single-master wCloud installation and its modules."
|
description = "Packages a self-contained single-master wCloud installation and its modules."
|
||||||
archiveFileName.set("wcloud-web.zip")
|
archiveFileName.set("wcloud.zip")
|
||||||
destinationDirectory.set(layout.buildDirectory.dir("distributions"))
|
destinationDirectory.set(layout.buildDirectory.dir("distributions"))
|
||||||
|
|
||||||
fun includeJar(projectPath: String, jarName: String, target: String) {
|
fun includeJar(projectPath: String, jarName: String, target: String) {
|
||||||
@ -24,17 +24,17 @@ tasks.register<Zip>("webDistribution") {
|
|||||||
includeJar(":wcloud-runnable:wcloud-master", Files.master, "dependency")
|
includeJar(":wcloud-runnable:wcloud-master", Files.master, "dependency")
|
||||||
includeJar(":wcloud-api", Files.api, "local/GLOBAL/EVERY/plugins")
|
includeJar(":wcloud-api", Files.api, "local/GLOBAL/EVERY/plugins")
|
||||||
includeJar(":wcloud-plugin", Files.plugin, "local/GLOBAL/EVERY/plugins")
|
includeJar(":wcloud-plugin", Files.plugin, "local/GLOBAL/EVERY/plugins")
|
||||||
includeJar(":wcloud-modules:wmodule-permissions", Files.permissions, "modules")
|
includeJar(":wcloud-modules:wmodule-permissions", Files.permissions, "optional-modules")
|
||||||
includeJar(":wcloud-modules:wmodule-signs", Files.signs, "modules")
|
includeJar(":wcloud-modules:wmodule-signs", Files.signs, "optional-modules")
|
||||||
includeJar(":wcloud-modules:wmodule-npc", Files.npc, "modules")
|
includeJar(":wcloud-modules:wmodule-npc", Files.npc, "optional-modules")
|
||||||
includeJar(":wcloud-modules:wmodule-syncplayer", Files.syncplayer, "modules")
|
includeJar(":wcloud-modules:wmodule-syncplayer", Files.syncplayer, "optional-modules")
|
||||||
includeJar(":wcloud-modules:wmodule-cloudflare", Files.cloudflare, "optional-modules")
|
includeJar(":wcloud-modules:wmodule-cloudflare", Files.cloudflare, "optional-modules")
|
||||||
includeJar(":wcloud-modules:wmodule-discord", Files.discord, "optional-modules")
|
includeJar(":wcloud-modules:wmodule-discord", Files.discord, "optional-modules")
|
||||||
includeJar(":wcloud-modules:wmodule-hub", Files.hub, "optional-modules")
|
includeJar(":wcloud-modules:wmodule-hub", Files.hub, "optional-modules")
|
||||||
includeJar(":wcloud-modules:wmodule-notify", Files.notify, "optional-modules")
|
includeJar(":wcloud-modules:wmodule-notify", Files.notify, "optional-modules")
|
||||||
includeJar(":wcloud-modules:wmodule-reboot", Files.reboot, "optional-modules")
|
includeJar(":wcloud-modules:wmodule-reboot", Files.reboot, "optional-modules")
|
||||||
includeJar(":wcloud-modules:wmodule-syncproxy", Files.syncproxy, "modules")
|
includeJar(":wcloud-modules:wmodule-syncproxy", Files.syncproxy, "modules")
|
||||||
includeJar(":wcloud-modules:wmodule-scoreboard", Files.scoreboard, "modules")
|
includeJar(":wcloud-modules:wmodule-scoreboard", Files.scoreboard, "optional-modules")
|
||||||
includeJar(":wcloud-modules:wmodule-moderation", Files.moderation, "optional-modules")
|
includeJar(":wcloud-modules:wmodule-moderation", Files.moderation, "optional-modules")
|
||||||
from("wcloud-launcher/src/main/dist")
|
from("wcloud-launcher/src/main/dist")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
org.gradle.warning.mode=all
|
org.gradle.warning.mode=all
|
||||||
org.gradle.logging.level=info
|
org.gradle.jvmargs=-Xmx5G -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8
|
||||||
org.gradle.jvmargs=-Xmx5G -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8
|
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
5
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,8 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionSha256Sum=a1bb7e9651ef09e4cd9a62d471564e0ee23b5757e5f21fd7358d7cfc21018fdf
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.9.1-bin.zip
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-all.zip
|
networkTimeout=10000
|
||||||
networkTimeout=60000
|
|
||||||
retries=0
|
retries=0
|
||||||
retryBackOffMs=500
|
retryBackOffMs=500
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.shadow)
|
alias(libs.plugins.shadow)
|
||||||
}
|
}
|
||||||
@ -18,6 +20,9 @@ dependencies {
|
|||||||
implementation(projects.wcloudNetworking)
|
implementation(projects.wcloudNetworking)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named("shadowJar") {
|
tasks.named<ShadowJar>("shadowJar") {
|
||||||
dependsOn(":wcloud-driver:shadowJar")
|
dependsOn(":wcloud-driver:shadowJar")
|
||||||
}
|
filesMatching("META-INF/*.kotlin_module") {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -96,7 +96,7 @@ public class EventDriver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<? extends EventAdapter> realParam = (Class<? extends EventAdapter>) param;
|
Class<? extends EventAdapter> realParam = param.asSubclass(EventAdapter.class);
|
||||||
|
|
||||||
var eventHandlersForEvent =
|
var eventHandlersForEvent =
|
||||||
this.bindings.computeIfAbsent(
|
this.bindings.computeIfAbsent(
|
||||||
|
|||||||
@ -47,11 +47,11 @@ import java.util.TimerTask;
|
|||||||
@Getter
|
@Getter
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
@Plugin(
|
@Plugin(
|
||||||
id = "metacloudplugin",
|
id = "wcloudplugin",
|
||||||
name = "metacloud-plugin",
|
name = "metacloud-plugin",
|
||||||
version = "2.0.0-SNAPSHOT",
|
version = "2.0.0-SNAPSHOT",
|
||||||
authors = "Weapie",
|
authors = "Weapie",
|
||||||
dependencies = {@Dependency(id = "metacloudapi")})
|
dependencies = {@Dependency(id = "wcloudapi")})
|
||||||
public class VelocityBootstrap {
|
public class VelocityBootstrap {
|
||||||
|
|
||||||
@Getter private static VelocityBootstrap instance;
|
@Getter private static VelocityBootstrap instance;
|
||||||
@ -90,9 +90,10 @@ public class VelocityBootstrap {
|
|||||||
this,
|
this,
|
||||||
() -> {
|
() -> {
|
||||||
var api = CloudAPI.instance();
|
var api = CloudAPI.instance();
|
||||||
if (api == null
|
var netty = NettyDriver.instance();
|
||||||
|| NettyDriver.instance().client().channel() == null
|
var client = netty == null ? null : netty.client();
|
||||||
|| !NettyDriver.instance().client().channel().isActive()) {
|
var channel = client == null ? null : client.channel();
|
||||||
|
if (api == null || channel == null || !channel.isActive()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var plugins =
|
var plugins =
|
||||||
@ -129,11 +130,17 @@ public class VelocityBootstrap {
|
|||||||
new TimerTask() {
|
new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (NettyDriver.instance().client().closed()) {
|
var netty = NettyDriver.instance();
|
||||||
|
var client = netty == null ? null : netty.client();
|
||||||
|
if (client == null || client.closed()) {
|
||||||
cancel();
|
cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!NettyDriver.instance().client().channel().isActive()) {
|
var channel = client.channel();
|
||||||
|
if (channel == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!channel.isActive()) {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import lombok.NonNull;
|
|||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
import java.lang.invoke.LambdaMetafactory;
|
import java.lang.invoke.LambdaMetafactory;
|
||||||
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.lang.invoke.MethodType;
|
import java.lang.invoke.MethodType;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@ -66,8 +67,12 @@ public final class ClassAllocationUtil {
|
|||||||
var unsafeClass = Class.forName("sun.misc.Unsafe");
|
var unsafeClass = Class.forName("sun.misc.Unsafe");
|
||||||
var unsafeField = unsafeClass.getDeclaredField("theUnsafe");
|
var unsafeField = unsafeClass.getDeclaredField("theUnsafe");
|
||||||
var theUnsafe = getInaccessibleFieldValue(unsafeField);
|
var theUnsafe = getInaccessibleFieldValue(unsafeField);
|
||||||
unsafeAllocator = makeUnsafeAlloc(theUnsafe);
|
var allocateInstance = MethodHandles.publicLookup()
|
||||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException exception) {
|
.unreflect(unsafeClass.getMethod("allocateInstance", Class.class))
|
||||||
|
.bindTo(theUnsafe);
|
||||||
|
unsafeAllocator = makeUnsafeAlloc(allocateInstance);
|
||||||
|
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException
|
||||||
|
| IllegalAccessException exception) {
|
||||||
unsafeAllocator = null;
|
unsafeAllocator = null;
|
||||||
}
|
}
|
||||||
UNSAFE_ALLOCATOR = unsafeAllocator;
|
UNSAFE_ALLOCATOR = unsafeAllocator;
|
||||||
@ -115,8 +120,9 @@ public final class ClassAllocationUtil {
|
|||||||
SUPPLIER_GET_SIGNATURE,
|
SUPPLIER_GET_SIGNATURE,
|
||||||
noArgsConstructor,
|
noArgsConstructor,
|
||||||
SUPPLIER_FACTORY_SIGNATURE);
|
SUPPLIER_FACTORY_SIGNATURE);
|
||||||
//noinspection unchecked
|
@SuppressWarnings("unchecked")
|
||||||
return (Supplier<Object>) callSite.getTarget().invokeExact();
|
var supplier = (Supplier<Object>) callSite.getTarget().invokeExact();
|
||||||
|
return supplier;
|
||||||
} catch (NoSuchMethodException exception) {
|
} catch (NoSuchMethodException exception) {
|
||||||
// unable to find a no-args constructor in the target class
|
// unable to find a no-args constructor in the target class
|
||||||
return null;
|
return null;
|
||||||
@ -131,20 +137,23 @@ public final class ClassAllocationUtil {
|
|||||||
* constructors are run when obtaining the class instance, which is fine as this is only used to obtain instances of
|
* constructors are run when obtaining the class instance, which is fine as this is only used to obtain instances of
|
||||||
* data classes (whose fields are initialized later).
|
* data classes (whose fields are initialized later).
|
||||||
*
|
*
|
||||||
* @param theUnsafe the singleton instance of sun.misc.Unsafe.
|
* @param allocateInstance the method handle bound to the Unsafe singleton.
|
||||||
* @return the allocator factory function which creates new class instances using sun.misc.Unsafe.
|
* @return the allocator factory function which creates new class instances using sun.misc.Unsafe.
|
||||||
* @throws NullPointerException if the given unsafe instance is null.
|
* @throws NullPointerException if the method handle is null.
|
||||||
*/
|
*/
|
||||||
private static @NonNull Function<Class<?>, Supplier<Object>> makeUnsafeAlloc(
|
private static @NonNull Function<Class<?>, Supplier<Object>> makeUnsafeAlloc(
|
||||||
@NonNull Object theUnsafe) {
|
@NonNull MethodHandle allocateInstance) {
|
||||||
return targetClass ->
|
return targetClass ->
|
||||||
() -> {
|
() -> {
|
||||||
try {
|
try {
|
||||||
var unsafe = (sun.misc.Unsafe) theUnsafe;
|
return (Object) allocateInstance.invokeExact(targetClass);
|
||||||
return unsafe.allocateInstance(targetClass);
|
|
||||||
} catch (InstantiationException exception) {
|
} catch (InstantiationException exception) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"unable to allocate instance class", exception);
|
"unable to allocate instance class", exception);
|
||||||
|
} catch (RuntimeException | Error exception) {
|
||||||
|
throw exception;
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
throw new AssertionError("unexpected allocation failure", throwable);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,7 +89,8 @@ public record RowedFormatter<T>(
|
|||||||
* @return the prepared columns based on the given input data.
|
* @return the prepared columns based on the given input data.
|
||||||
* @throws NullPointerException if the given input data is null.
|
* @throws NullPointerException if the given input data is null.
|
||||||
*/
|
*/
|
||||||
public @NonNull ColumnEntry[] convertToColumns(@NonNull T... input) {
|
@SafeVarargs
|
||||||
|
public final @NonNull ColumnEntry[] convertToColumns(@NonNull T... input) {
|
||||||
return this.convertToColumns(Arrays.asList(input));
|
return this.convertToColumns(Arrays.asList(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +112,8 @@ public record RowedFormatter<T>(
|
|||||||
* @return the formatted table based on the given input data.
|
* @return the formatted table based on the given input data.
|
||||||
* @throws NullPointerException if the given input data is null.
|
* @throws NullPointerException if the given input data is null.
|
||||||
*/
|
*/
|
||||||
public @NonNull Collection<String> format(@NonNull T... input) {
|
@SafeVarargs
|
||||||
|
public final @NonNull Collection<String> format(@NonNull T... input) {
|
||||||
return this.defaultFormatter.formatLines(this.convertToColumns(input));
|
return this.defaultFormatter.formatLines(this.convertToColumns(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user