aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2024-10-20 09:17:06 +0100
committerLuck <git@lucko.me>2024-10-20 14:21:05 +0100
commit4face768621e459335f2e8e23f8db2fac017b834 (patch)
treee59c709881a817fc8d210593c5723ae0065492ff
parent6effd0d018db25c53c042a88d50e5b43dfca56bd (diff)
downloadspark-4face768621e459335f2e8e23f8db2fac017b834.tar.gz
spark-4face768621e459335f2e8e23f8db2fac017b834.tar.bz2
spark-4face768621e459335f2e8e23f8db2fac017b834.zip
Move some platform implementations to new repo
-rw-r--r--settings.gradle15
-rw-r--r--spark-common/build.gradle32
-rw-r--r--spark-minestom/build.gradle51
-rw-r--r--spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomClassSourceLookup.java49
-rw-r--r--spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomCommandSender.java68
-rw-r--r--spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomPlatformInfo.java47
-rw-r--r--spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomPlayerPingProvider.java41
-rw-r--r--spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomSparkPlugin.java195
-rw-r--r--spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomTickHook.java47
-rw-r--r--spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomTickReporter.java48
-rw-r--r--spark-minestom/src/main/resources/extension.json5
-rw-r--r--spark-nukkit/build.gradle47
-rw-r--r--spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitClassSourceLookup.java38
-rw-r--r--spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitCommandSender.java59
-rw-r--r--spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlatformInfo.java57
-rw-r--r--spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlayerPingProvider.java45
-rw-r--r--spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitSparkPlugin.java118
-rw-r--r--spark-nukkit/src/main/resources/plugin.yml10
-rw-r--r--spark-sponge/build.gradle (renamed from spark-sponge8/build.gradle)2
-rw-r--r--spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeClassSourceLookup.java (renamed from spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8ClassSourceLookup.java)4
-rw-r--r--spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeCommandSender.java (renamed from spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8CommandSender.java)8
-rw-r--r--spark-sponge/src/main/java/me/lucko/spark/sponge/SpongePlatformInfo.java (renamed from spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8PlatformInfo.java)4
-rw-r--r--spark-sponge/src/main/java/me/lucko/spark/sponge/SpongePlayerPingProvider.java (renamed from spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8PlayerPingProvider.java)4
-rw-r--r--spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java (renamed from spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java)28
-rw-r--r--spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeTickHook.java (renamed from spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8TickHook.java)4
-rw-r--r--spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeWorldInfoProvider.java (renamed from spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8WorldInfoProvider.java)4
-rw-r--r--spark-sponge/src/main/resources/META-INF/sponge_plugins.json (renamed from spark-sponge8/src/main/resources/META-INF/sponge_plugins.json)4
-rw-r--r--spark-sponge7/build.gradle46
-rw-r--r--spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7ClassSourceLookup.java43
-rw-r--r--spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7CommandSender.java59
-rw-r--r--spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7PlatformInfo.java58
-rw-r--r--spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7PlayerPingProvider.java45
-rw-r--r--spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7SparkPlugin.java232
-rw-r--r--spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7TickHook.java50
-rw-r--r--spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7WorldInfoProvider.java123
-rw-r--r--spark-velocity4/build.gradle52
-rw-r--r--spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4ClassSourceLookup.java61
-rw-r--r--spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4CommandSender.java64
-rw-r--r--spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4PlatformInfo.java57
-rw-r--r--spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4PlayerPingProvider.java45
-rw-r--r--spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4SparkPlugin.java161
-rw-r--r--spark-waterdog/build.gradle56
-rw-r--r--spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogClassSourceLookup.java61
-rw-r--r--spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogCommandSender.java59
-rw-r--r--spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogPlatformInfo.java52
-rw-r--r--spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogPlayerPingProvider.java45
-rw-r--r--spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogSparkPlugin.java139
-rw-r--r--spark-waterdog/src/main/resources/plugin.yml6
48 files changed, 66 insertions, 2482 deletions
diff --git a/settings.gradle b/settings.gradle
index 6931c9f..d3e1b45 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -23,18 +23,13 @@ plugins {
rootProject.name = 'spark'
include (
'spark-api',
- 'spark-common',
'spark-bukkit',
- 'spark-paper',
'spark-bungeecord',
- 'spark-velocity',
- 'spark-velocity4',
- 'spark-sponge7',
- 'spark-sponge8',
+ 'spark-common',
+ 'spark-fabric',
'spark-forge',
'spark-neoforge',
- 'spark-fabric',
- 'spark-nukkit',
- 'spark-waterdog',
- //'spark-minestom', // disabled until minestom publish their maven artifacts to a proper repo
+ 'spark-paper',
+ 'spark-sponge',
+ 'spark-velocity',
)
diff --git a/spark-common/build.gradle b/spark-common/build.gradle
index 5bc4bda..ba3d2b4 100644
--- a/spark-common/build.gradle
+++ b/spark-common/build.gradle
@@ -1,5 +1,6 @@
plugins {
id 'com.google.protobuf' version '0.9.4'
+ id 'maven-publish'
}
license {
@@ -14,7 +15,7 @@ dependencies {
implementation 'com.github.jvm-profiling-tools:async-profiler:v2.8.3'
implementation 'org.ow2.asm:asm:9.7'
implementation 'net.bytebuddy:byte-buddy-agent:1.14.17'
- implementation 'com.google.protobuf:protobuf-javalite:4.27.1'
+ implementation 'com.google.protobuf:protobuf-javalite:4.28.2'
implementation('me.lucko:bytesocks-java-client:1.0-20230828.145440-5') {
exclude(module: 'slf4j-api')
@@ -60,7 +61,7 @@ dependencies {
protobuf {
protoc {
- artifact = 'com.google.protobuf:protoc:4.27.1'
+ artifact = 'com.google.protobuf:protoc:4.28.2'
}
generateProtoTasks {
all().each { task ->
@@ -77,3 +78,30 @@ test {
useJUnitPlatform {}
systemProperty('net.kyori.ansi.colorLevel', 'indexed16')
}
+
+publishing {
+ //repositories {
+ // maven {
+ // url = 'https://oss.sonatype.org/content/repositories/snapshots'
+ // credentials {
+ // username = sonatypeUsername
+ // password = sonatypePassword
+ // }
+ // }
+ //}
+ //repositories {
+ // maven {
+ // url = 'https://nexus.lucko.me/repository/maven-snapshots/'
+ // credentials {
+ // username = luckoNexusUsername
+ // password = luckoNexusPassword
+ // }
+ // }
+ //}
+ publications {
+ maven(MavenPublication) {
+ from components.java
+ version = "${project.pluginVersion}-SNAPSHOT"
+ }
+ }
+}
diff --git a/spark-minestom/build.gradle b/spark-minestom/build.gradle
deleted file mode 100644
index 6e0d7e6..0000000
--- a/spark-minestom/build.gradle
+++ /dev/null
@@ -1,51 +0,0 @@
-plugins {
- id 'com.gradleup.shadow' version '8.3.0'
-}
-
-tasks.withType(JavaCompile) {
- // override, compile targeting J17
- options.release = 17
-}
-
-dependencies {
- implementation project(':spark-common')
- compileOnly 'com.github.Minestom.Minestom:Minestom:master-SNAPSHOT'
- implementation 'com.google.guava:guava:19.0'
-}
-
-processResources {
- from(sourceSets.main.resources.srcDirs) {
- expand (
- 'pluginVersion': project.pluginVersion,
- 'pluginDescription': project.pluginDescription
- )
- include 'extension.json'
- }
-}
-
-shadowJar {
- archiveFileName = "spark-${project.pluginVersion}-minestom.jar"
-
- dependencies {
- exclude(dependency('net.kyori:^(?!adventure-text-feature-pagination).+$'))
- }
-
- relocate 'net.kyori.adventure.text.feature.pagination', 'me.lucko.spark.lib.adventure.pagination'
- relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
- relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
- relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'
- relocate 'one.profiler', 'me.lucko.spark.lib.asyncprofiler'
- relocate 'me.lucko.bytesocks.client', 'me.lucko.spark.lib.bytesocks'
- relocate 'org.java_websocket', 'me.lucko.spark.lib.bytesocks.ws'
-
- exclude 'module-info.class'
- exclude 'META-INF/maven/**'
- exclude 'META-INF/proguard/**'
- exclude '**/*.proto'
- exclude '**/*.proto.bin'
-}
-
-artifacts {
- archives shadowJar
- shadow shadowJar
-}
diff --git a/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomClassSourceLookup.java b/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomClassSourceLookup.java
deleted file mode 100644
index ca44eea..0000000
--- a/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomClassSourceLookup.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.minestom;
-
-import me.lucko.spark.common.sampler.source.ClassSourceLookup;
-
-import net.minestom.server.MinecraftServer;
-import net.minestom.server.extensions.Extension;
-import net.minestom.server.extensions.ExtensionClassLoader;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class MinestomClassSourceLookup extends ClassSourceLookup.ByClassLoader {
- private final Map<ClassLoader, String> classLoaderToExtensions;
-
- public MinestomClassSourceLookup() {
- this.classLoaderToExtensions = new HashMap<>();
- for (Extension extension : MinecraftServer.getExtensionManager().getExtensions()) {
- this.classLoaderToExtensions.put(extension.getClass().getClassLoader(), extension.getOrigin().getName());
- }
- }
-
- @Override
- public String identify(ClassLoader loader) {
- if (loader instanceof ExtensionClassLoader) {
- return this.classLoaderToExtensions.get(loader);
- }
- return null;
- }
-}
diff --git a/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomCommandSender.java b/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomCommandSender.java
deleted file mode 100644
index e4323e6..0000000
--- a/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomCommandSender.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.minestom;
-
-import me.lucko.spark.common.command.sender.AbstractCommandSender;
-
-import net.kyori.adventure.text.Component;
-import net.minestom.server.command.CommandSender;
-import net.minestom.server.command.ConsoleSender;
-import net.minestom.server.entity.Player;
-
-import java.util.UUID;
-
-public class MinestomCommandSender extends AbstractCommandSender<CommandSender> {
- public MinestomCommandSender(CommandSender delegate) {
- super(delegate);
- }
-
- @Override
- public String getName() {
- if (this.delegate instanceof Player player) {
- return player.getUsername();
- } else if (this.delegate instanceof ConsoleSender) {
- return "Console";
- }else {
- return "unknown:" + this.delegate.getClass().getSimpleName();
- }
- }
-
- @Override
- public UUID getUniqueId() {
- if (super.delegate instanceof Player player) {
- return player.getUuid();
- }
- return null;
- }
-
- @Override
- public void sendMessage(Component message) {
- this.delegate.sendMessage(message);
- }
-
- @Override
- public boolean hasPermission(String permission) {
- if (this.delegate instanceof ConsoleSender) {
- return true;
- }
- return this.delegate.hasPermission(permission);
- }
-}
diff --git a/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomPlatformInfo.java b/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomPlatformInfo.java
deleted file mode 100644
index add258a..0000000
--- a/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomPlatformInfo.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.minestom;
-
-import me.lucko.spark.common.platform.PlatformInfo;
-
-import net.minestom.server.MinecraftServer;
-
-public class MinestomPlatformInfo implements PlatformInfo {
- @Override
- public Type getType() {
- return Type.SERVER;
- }
-
- @Override
- public String getName() {
- return "Minestom";
- }
-
- @Override
- public String getVersion() {
- return MinecraftServer.VERSION_NAME + "-" + MinecraftServer.getBrandName();
- }
-
- @Override
- public String getMinecraftVersion() {
- return MinecraftServer.VERSION_NAME;
- }
-}
diff --git a/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomPlayerPingProvider.java b/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomPlayerPingProvider.java
deleted file mode 100644
index 0b50c0a..0000000
--- a/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomPlayerPingProvider.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.minestom;
-
-import com.google.common.collect.ImmutableMap;
-
-import me.lucko.spark.common.monitor.ping.PlayerPingProvider;
-
-import net.minestom.server.MinecraftServer;
-import net.minestom.server.entity.Player;
-
-import java.util.Map;
-
-public class MinestomPlayerPingProvider implements PlayerPingProvider {
- @Override
- public Map<String, Integer> poll() {
- ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder();
- for (Player player : MinecraftServer.getConnectionManager().getOnlinePlayers()) {
- builder.put(player.getUsername(), player.getLatency());
- }
- return builder.build();
- }
-}
diff --git a/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomSparkPlugin.java b/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomSparkPlugin.java
deleted file mode 100644
index 9014476..0000000
--- a/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomSparkPlugin.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.minestom;
-
-import me.lucko.spark.common.SparkPlatform;
-import me.lucko.spark.common.SparkPlugin;
-import me.lucko.spark.common.monitor.ping.PlayerPingProvider;
-import me.lucko.spark.common.platform.PlatformInfo;
-import me.lucko.spark.common.sampler.source.ClassSourceLookup;
-import me.lucko.spark.common.sampler.source.SourceMetadata;
-import me.lucko.spark.common.tick.TickHook;
-import me.lucko.spark.common.tick.TickReporter;
-
-import net.minestom.server.MinecraftServer;
-import net.minestom.server.command.CommandSender;
-import net.minestom.server.command.builder.Command;
-import net.minestom.server.command.builder.CommandContext;
-import net.minestom.server.command.builder.CommandExecutor;
-import net.minestom.server.command.builder.arguments.ArgumentStringArray;
-import net.minestom.server.command.builder.arguments.ArgumentType;
-import net.minestom.server.command.builder.suggestion.Suggestion;
-import net.minestom.server.command.builder.suggestion.SuggestionCallback;
-import net.minestom.server.command.builder.suggestion.SuggestionEntry;
-import net.minestom.server.extensions.Extension;
-import net.minestom.server.timer.ExecutionType;
-
-import org.jetbrains.annotations.NotNull;
-
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.logging.Level;
-import java.util.stream.Stream;
-
-public class MinestomSparkPlugin extends Extension implements SparkPlugin {
- private SparkPlatform platform;
- private MinestomSparkCommand command;
-
- @Override
- public void initialize() {
- this.platform = new SparkPlatform(this);
- this.platform.enable();
- this.command = new MinestomSparkCommand(this.platform);
- MinecraftServer.getCommandManager().register(this.command);
- }
-
- @Override
- public void terminate() {
- this.platform.disable();
- MinecraftServer.getCommandManager().unregister(this.command);
- }
-
- @Override
- public String getVersion() {
- return getOrigin().getVersion();
- }
-
- @Override
- public Path getPluginDirectory() {
- return getDataDirectory();
- }
-
- @Override
- public String getCommandName() {
- return "spark";
- }
-
- @Override
- public Stream<MinestomCommandSender> getCommandSenders() {
- return Stream.concat(
- MinecraftServer.getConnectionManager().getOnlinePlayers().stream(),
- Stream.of(MinecraftServer.getCommandManager().getConsoleSender())
- ).map(MinestomCommandSender::new);
- }
-
- @Override
- public void executeAsync(Runnable task) {
- MinecraftServer.getSchedulerManager().scheduleNextTick(task, ExecutionType.ASYNC);
- }
-
- @Override
- public void log(Level level, String msg) {
- if (level == Level.INFO) {
- this.getLogger().info(msg);
- } else if (level == Level.WARNING) {
- this.getLogger().warn(msg);
- } else if (level == Level.SEVERE) {
- this.getLogger().error(msg);
- } else {
- throw new IllegalArgumentException(level.getName());
- }
- }
-
- @Override
- public PlatformInfo getPlatformInfo() {
- return new MinestomPlatformInfo();
- }
-
- @Override
- public ClassSourceLookup createClassSourceLookup() {
- return new MinestomClassSourceLookup();
- }
-
- @Override
- public Collection<SourceMetadata> getKnownSources() {
- return SourceMetadata.gather(
- MinecraftServer.getExtensionManager().getExtensions(),
- extension -> extension.getOrigin().getName(),
- extension -> extension.getOrigin().getVersion(),
- extension -> String.join(", ", extension.getOrigin().getAuthors())
- );
- }
-
- @Override
- public PlayerPingProvider createPlayerPingProvider() {
- return new MinestomPlayerPingProvider();
- }
-
- @Override
- public TickReporter createTickReporter() {
- return new MinestomTickReporter();
- }
-
- @Override
- public TickHook createTickHook() {
- return new MinestomTickHook();
- }
-
- private static final class MinestomSparkCommand extends Command implements CommandExecutor, SuggestionCallback {
- private final SparkPlatform platform;
-
- public MinestomSparkCommand(SparkPlatform platform) {
- super("spark");
- this.platform = platform;
-
- ArgumentStringArray arrayArgument = ArgumentType.StringArray("args");
- arrayArgument.setSuggestionCallback(this);
-
- addSyntax(this, arrayArgument);
- setDefaultExecutor((sender, context) -> platform.executeCommand(new MinestomCommandSender(sender), new String[0]));
- }
-
- // execute
- @Override
- public void apply(@NotNull CommandSender sender, @NotNull CommandContext context) {
- String[] args = processArgs(context, false);
- if (args == null) {
- return;
- }
-
- this.platform.executeCommand(new MinestomCommandSender(sender), args);
- }
-
- // tab complete
- @Override
- public void apply(@NotNull CommandSender sender, @NotNull CommandContext context, @NotNull Suggestion suggestion) {
- String[] args = processArgs(context, true);
- if (args == null) {
- return;
- }
-
- Iterable<String> suggestionEntries = this.platform.tabCompleteCommand(new MinestomCommandSender(sender), args);
- for (String suggestionEntry : suggestionEntries) {
- suggestion.addEntry(new SuggestionEntry(suggestionEntry));
- }
- }
-
- private static String [] processArgs(CommandContext context, boolean tabComplete) {
- String[] split = context.getInput().split(" ", tabComplete ? -1 : 0);
- if (split.length == 0 || !split[0].equals("/spark") && !split[0].equals("spark")) {
- return null;
- }
-
- return Arrays.copyOfRange(split, 1, split.length);
- }
- }
-}
diff --git a/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomTickHook.java b/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomTickHook.java
deleted file mode 100644
index 44c1c2d..0000000
--- a/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomTickHook.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.minestom;
-
-import me.lucko.spark.common.tick.AbstractTickHook;
-
-import net.minestom.server.MinecraftServer;
-import net.minestom.server.timer.Task;
-import net.minestom.server.timer.TaskSchedule;
-
-public class MinestomTickHook extends AbstractTickHook {
- private Task task;
-
- @Override
- public void start() {
- this.task = MinecraftServer.getSchedulerManager()
- .buildTask(this::onTick)
- .delay(TaskSchedule.tick(1))
- .repeat(TaskSchedule.tick(1))
- .schedule();
- }
-
- @Override
- public void close() {
- if (this.task != null) {
- this.task.cancel();
- }
- }
-}
diff --git a/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomTickReporter.java b/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomTickReporter.java
deleted file mode 100644
index ae25f92..0000000
--- a/spark-minestom/src/main/java/me/lucko/spark/minestom/MinestomTickReporter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.minestom;
-
-import me.lucko.spark.common.tick.AbstractTickReporter;
-
-import net.minestom.server.MinecraftServer;
-import net.minestom.server.event.Event;
-import net.minestom.server.event.EventNode;
-import net.minestom.server.event.server.ServerTickMonitorEvent;
-
-import java.util.UUID;
-
-public class MinestomTickReporter extends AbstractTickReporter {
- private final EventNode<Event> node = EventNode.all("sparkTickReporter-" + UUID.randomUUID());
-
- public MinestomTickReporter() {
- this.node.addListener(ServerTickMonitorEvent.class, event -> onTick(event.getTickMonitor().getTickTime()));
- }
-
- @Override
- public void start() {
- MinecraftServer.getGlobalEventHandler().addChild(this.node);
- }
-
- @Override
- public void close() {
- MinecraftServer.getGlobalEventHandler().removeChild(this.node);
- }
-}
diff --git a/spark-minestom/src/main/resources/extension.json b/spark-minestom/src/main/resources/extension.json
deleted file mode 100644
index bea56bb..0000000
--- a/spark-minestom/src/main/resources/extension.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "entrypoint": "me.lucko.spark.minestom.MinestomSparkPlugin",
- "name": "spark",
- "version": "${pluginVersion}"
-} \ No newline at end of file
diff --git a/spark-nukkit/build.gradle b/spark-nukkit/build.gradle
deleted file mode 100644
index c11e02e..0000000
--- a/spark-nukkit/build.gradle
+++ /dev/null
@@ -1,47 +0,0 @@
-plugins {
- id 'com.gradleup.shadow' version '8.3.0'
-}
-
-dependencies {
- implementation project(':spark-common')
- compileOnly 'cn.nukkit:nukkit:1.0-SNAPSHOT'
-}
-
-repositories {
- maven { url 'https://repo.opencollab.dev/main/' }
-}
-
-processResources {
- from(sourceSets.main.resources.srcDirs) {
- expand (
- 'pluginVersion': project.pluginVersion,
- 'pluginDescription': project.pluginDescription
- )
- include 'plugin.yml'
- }
-}
-
-shadowJar {
- archiveFileName = "spark-${project.pluginVersion}-nukkit.jar"
-
- relocate 'net.kyori.adventure', 'me.lucko.spark.lib.adventure'
- relocate 'net.kyori.examination', 'me.lucko.spark.lib.adventure.examination'
- relocate 'net.kyori.option', 'me.lucko.spark.lib.adventure.option'
- relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
- relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
- relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'
- relocate 'one.profiler', 'me.lucko.spark.lib.asyncprofiler'
- relocate 'me.lucko.bytesocks.client', 'me.lucko.spark.lib.bytesocks'
- relocate 'org.java_websocket', 'me.lucko.spark.lib.bytesocks.ws'
-
- exclude 'module-info.class'
- exclude 'META-INF/maven/**'
- exclude 'META-INF/proguard/**'
- exclude '**/*.proto'
- exclude '**/*.proto.bin'
-}
-
-artifacts {
- archives shadowJar
- shadow shadowJar
-}
diff --git a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitClassSourceLookup.java b/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitClassSourceLookup.java
deleted file mode 100644
index e815b6c..0000000
--- a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitClassSourceLookup.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.nukkit;
-
-import cn.nukkit.plugin.PluginClassLoader;
-import me.lucko.spark.common.sampler.source.ClassSourceLookup;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-public class NukkitClassSourceLookup extends ClassSourceLookup.ByFirstUrlSource {
-
- @Override
- public String identify(ClassLoader loader) throws IOException, URISyntaxException {
- if (loader instanceof PluginClassLoader) {
- return super.identify(loader);
- }
- return null;
- }
-}
diff --git a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitCommandSender.java b/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitCommandSender.java
deleted file mode 100644
index 3d6de22..0000000
--- a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitCommandSender.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.nukkit;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.CommandSender;
-import me.lucko.spark.common.command.sender.AbstractCommandSender;
-import net.kyori.adventure.text.Component;
-import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
-
-import java.util.UUID;
-
-public class NukkitCommandSender extends AbstractCommandSender<CommandSender> {
-
- public NukkitCommandSender(CommandSender delegate) {
- super(delegate);
- }
-
- @Override
- public String getName() {
- return this.delegate.getName();
- }
-
- @Override
- public UUID getUniqueId() {
- if (this.delegate instanceof Player) {
- return ((Player) this.delegate).getUniqueId();
- }
- return null;
- }
-
- @Override
- public void sendMessage(Component message) {
- this.delegate.sendMessage(LegacyComponentSerializer.legacySection().serialize(message));
- }
-
- @Override
- public boolean hasPermission(String permission) {
- return this.delegate.hasPermission(permission);
- }
-}
diff --git a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlatformInfo.java b/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlatformInfo.java
deleted file mode 100644
index a1c9c5b..0000000
--- a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlatformInfo.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.nukkit;
-
-import cn.nukkit.Server;
-import me.lucko.spark.common.platform.PlatformInfo;
-
-public class NukkitPlatformInfo implements PlatformInfo {
- private final Server server;
-
- public NukkitPlatformInfo(Server server) {
- this.server = server;
- }
-
- @Override
- public Type getType() {
- return Type.SERVER;
- }
-
- @Override
- public String getName() {
- return "Nukkit";
- }
-
- @Override
- public String getBrand() {
- return this.server.getName();
- }
-
- @Override
- public String getVersion() {
- return this.server.getNukkitVersion();
- }
-
- @Override
- public String getMinecraftVersion() {
- return this.server.getVersion();
- }
-}
diff --git a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlayerPingProvider.java b/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlayerPingProvider.java
deleted file mode 100644
index b2e5100..0000000
--- a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlayerPingProvider.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.nukkit;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import com.google.common.collect.ImmutableMap;
-import me.lucko.spark.common.monitor.ping.PlayerPingProvider;
-
-import java.util.Map;
-
-public class NukkitPlayerPingProvider implements PlayerPingProvider {
- private final Server server;
-
- public NukkitPlayerPingProvider(Server server) {
- this.server = server;
- }
-
- @Override
- public Map<String, Integer> poll() {
- ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder();
- for (Player player : this.server.getOnlinePlayers().values()) {
- builder.put(player.getName(), player.getPing());
- }
- return builder.build();
- }
-}
diff --git a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitSparkPlugin.java b/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitSparkPlugin.java
deleted file mode 100644
index 39be28d..0000000
--- a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitSparkPlugin.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.nukkit;
-
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.plugin.PluginBase;
-import cn.nukkit.plugin.service.ServicePriority;
-import me.lucko.spark.api.Spark;
-import me.lucko.spark.common.SparkPlatform;
-import me.lucko.spark.common.SparkPlugin;
-import me.lucko.spark.common.monitor.ping.PlayerPingProvider;
-import me.lucko.spark.common.platform.PlatformInfo;
-import me.lucko.spark.common.sampler.source.ClassSourceLookup;
-
-import java.nio.file.Path;
-import java.util.logging.Level;
-import java.util.stream.Stream;
-
-public class NukkitSparkPlugin extends PluginBase implements SparkPlugin {
- private SparkPlatform platform;
-
- @Override
- public void onEnable() {
- this.platform = new SparkPlatform(this);
- this.platform.enable();
- }
-
- @Override
- public void onDisable() {
- this.platform.disable();
- }
-
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- this.platform.executeCommand(new NukkitCommandSender(sender), args);
- return true;
- }
-
- @Override
- public String getVersion() {
- return getDescription().getVersion();
- }
-
- @Override
- public Path getPluginDirectory() {
- return getDataFolder().toPath();
- }
-
- @Override
- public String getCommandName() {
- return "spark";
- }
-
- @Override
- public Stream<NukkitCommandSender> getCommandSenders() {
- return Stream.concat(
- getServer().getOnlinePlayers().values().stream(),
- Stream.of(getServer().getConsoleSender())
- ).map(NukkitCommandSender::new);
- }
-
- @Override
- public void executeAsync(Runnable task) {
- getServer().getScheduler().scheduleTask(this, task, true);
- }
-
- @Override
- public void log(Level level, String msg) {
- if (level == Level.INFO) {
- getLogger().info(msg);
- } else if (level == Level.WARNING) {
- getLogger().warning(msg);
- } else if (level == Level.SEVERE) {
- getLogger().error(msg);
- } else {
- throw new IllegalArgumentException(level.getName());
- }
- }
-
- @Override
- public ClassSourceLookup createClassSourceLookup() {
- return new NukkitClassSourceLookup();
- }
-
- @Override
- public PlayerPingProvider createPlayerPingProvider() {
- return new NukkitPlayerPingProvider(getServer());
- }
-
- @Override
- public PlatformInfo getPlatformInfo() {
- return new NukkitPlatformInfo(getServer());
- }
-
- @Override
- public void registerApi(Spark api) {
- getServer().getServiceManager().register(Spark.class, api, this, ServicePriority.NORMAL);
- }
-}
diff --git a/spark-nukkit/src/main/resources/plugin.yml b/spark-nukkit/src/main/resources/plugin.yml
deleted file mode 100644
index cab74b5..0000000
--- a/spark-nukkit/src/main/resources/plugin.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-name: spark
-version: ${pluginVersion}
-description: ${pluginDescription}
-author: Luck
-website: https://spark.lucko.me/
-main: me.lucko.spark.nukkit.NukkitSparkPlugin
-api: [1.0.5]
-commands:
- spark:
- description: Main plugin command \ No newline at end of file
diff --git a/spark-sponge8/build.gradle b/spark-sponge/build.gradle
index a455e41..efb3321 100644
--- a/spark-sponge8/build.gradle
+++ b/spark-sponge/build.gradle
@@ -22,7 +22,7 @@ processResources {
}
shadowJar {
- archiveFileName = "spark-${project.pluginVersion}-sponge8.jar"
+ archiveFileName = "spark-${project.pluginVersion}-sponge.jar"
dependencies {
exclude(dependency('net.kyori:^(?!adventure-text-feature-pagination).+$'))
diff --git a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8ClassSourceLookup.java b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeClassSourceLookup.java
index 52218e5..0820ae3 100644
--- a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8ClassSourceLookup.java
+++ b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeClassSourceLookup.java
@@ -33,11 +33,11 @@ import java.nio.file.Path;
import java.util.Collection;
import java.util.Map;
-public class Sponge8ClassSourceLookup extends ClassSourceLookup.ByCodeSource {
+public class SpongeClassSourceLookup extends ClassSourceLookup.ByCodeSource {
private final Path modsDirectory;
private final Map<Path, String> pathToPluginMap;
- public Sponge8ClassSourceLookup(Game game) {
+ public SpongeClassSourceLookup(Game game) {
this.modsDirectory = game.gameDirectory().resolve("mods").toAbsolutePath().normalize();
this.pathToPluginMap = constructPathToPluginIdMap(game.pluginManager().plugins());
}
diff --git a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8CommandSender.java b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeCommandSender.java
index 8bf67bd..aa634cc 100644
--- a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8CommandSender.java
+++ b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeCommandSender.java
@@ -32,17 +32,17 @@ import java.util.UUID;
import static java.nio.charset.StandardCharsets.UTF_8;
-public class Sponge8CommandSender extends AbstractCommandSender<Subject> {
+public class SpongeCommandSender extends AbstractCommandSender<Subject> {
private final CommandCause cause;
private final Audience audience;
- public Sponge8CommandSender(CommandCause cause) {
+ public SpongeCommandSender(CommandCause cause) {
super(cause);
this.cause = cause;
this.audience = cause.audience();
}
- public <T extends Subject & Audience> Sponge8CommandSender(T cause) {
+ public <T extends Subject & Audience> SpongeCommandSender(T cause) {
super(cause);
this.cause = null;
this.audience = cause;
@@ -83,7 +83,7 @@ public class Sponge8CommandSender extends AbstractCommandSender<Subject> {
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
- Sponge8CommandSender that = (Sponge8CommandSender) o;
+ SpongeCommandSender that = (SpongeCommandSender) o;
return this.getUniqueId().equals(that.getUniqueId());
}
diff --git a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8PlatformInfo.java b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongePlatformInfo.java
index 840a686..e5811cd 100644
--- a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8PlatformInfo.java
+++ b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongePlatformInfo.java
@@ -25,10 +25,10 @@ import org.spongepowered.api.Game;
import org.spongepowered.api.Platform;
import org.spongepowered.plugin.metadata.PluginMetadata;
-public class Sponge8PlatformInfo implements PlatformInfo {
+public class SpongePlatformInfo implements PlatformInfo {
private final Game game;
- public Sponge8PlatformInfo(Game game) {
+ public SpongePlatformInfo(Game game) {
this.game = game;
}
diff --git a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8PlayerPingProvider.java b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongePlayerPingProvider.java
index e908d0d..b327a0a 100644
--- a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8PlayerPingProvider.java
+++ b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongePlayerPingProvider.java
@@ -27,10 +27,10 @@ import org.spongepowered.api.entity.living.player.server.ServerPlayer;
import java.util.Map;
-public class Sponge8PlayerPingProvider implements PlayerPingProvider {
+public class SpongePlayerPingProvider implements PlayerPingProvider {
private final Server server;
- public Sponge8PlayerPingProvider(Server server) {
+ public SpongePlayerPingProvider(Server server) {
this.server = server;
}
diff --git a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java
index c675a8c..3542dae 100644
--- a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java
+++ b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java
@@ -63,7 +63,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
@Plugin("spark")
-public class Sponge8SparkPlugin implements SparkPlugin {
+public class SpongeSparkPlugin implements SparkPlugin {
private final PluginContainer pluginContainer;
private final Logger logger;
@@ -76,7 +76,7 @@ public class Sponge8SparkPlugin implements SparkPlugin {
private SparkPlatform platform;
@Inject
- public Sponge8SparkPlugin(PluginContainer pluginContainer, Logger logger, Game game, @ConfigDir(sharedRoot = false) Path configDirectory) {
+ public SpongeSparkPlugin(PluginContainer pluginContainer, Logger logger, Game game, @ConfigDir(sharedRoot = false) Path configDirectory) {
this.pluginContainer = pluginContainer;
this.logger = logger;
this.game = game;
@@ -133,9 +133,9 @@ public class Sponge8SparkPlugin implements SparkPlugin {
return Stream.concat(
this.game.server().onlinePlayers().stream(),
Stream.of(this.game.systemSubject())
- ).map(Sponge8CommandSender::new);
+ ).map(SpongeCommandSender::new);
} else {
- return Stream.of(this.game.systemSubject()).map(Sponge8CommandSender::new);
+ return Stream.of(this.game.systemSubject()).map(SpongeCommandSender::new);
}
}
@@ -169,12 +169,12 @@ public class Sponge8SparkPlugin implements SparkPlugin {
@Override
public TickHook createTickHook() {
- return new Sponge8TickHook(this.pluginContainer, this.game);
+ return new SpongeTickHook(this.pluginContainer, this.game);
}
@Override
public ClassSourceLookup createClassSourceLookup() {
- return new Sponge8ClassSourceLookup(this.game);
+ return new SpongeClassSourceLookup(this.game);
}
@Override
@@ -193,7 +193,7 @@ public class Sponge8SparkPlugin implements SparkPlugin {
@Override
public PlayerPingProvider createPlayerPingProvider() {
if (this.game.isServerAvailable()) {
- return new Sponge8PlayerPingProvider(this.game.server());
+ return new SpongePlayerPingProvider(this.game.server());
} else {
return null;
}
@@ -202,7 +202,7 @@ public class Sponge8SparkPlugin implements SparkPlugin {
@Override
public WorldInfoProvider createWorldInfoProvider() {
if (this.game.isServerAvailable()) {
- return new Sponge8WorldInfoProvider(this.game.server());
+ return new SpongeWorldInfoProvider(this.game.server());
} else {
return WorldInfoProvider.NO_OP;
}
@@ -210,25 +210,25 @@ public class Sponge8SparkPlugin implements SparkPlugin {
@Override
public PlatformInfo getPlatformInfo() {
- return new Sponge8PlatformInfo(this.game);
+ return new SpongePlatformInfo(this.game);
}
private static final class SparkCommand implements Command.Raw {
- private final Sponge8SparkPlugin plugin;
+ private final SpongeSparkPlugin plugin;
- public SparkCommand(Sponge8SparkPlugin plugin) {
+ public SparkCommand(SpongeSparkPlugin plugin) {
this.plugin = plugin;
}
@Override
public CommandResult process(CommandCause cause, ArgumentReader.Mutable arguments) {
- this.plugin.platform.executeCommand(new Sponge8CommandSender(cause), arguments.input().split(" "));
+ this.plugin.platform.executeCommand(new SpongeCommandSender(cause), arguments.input().split(" "));
return CommandResult.success();
}
@Override
public List<CommandCompletion> complete(CommandCause cause, ArgumentReader.Mutable arguments) {
- return this.plugin.platform.tabCompleteCommand(new Sponge8CommandSender(cause), arguments.input().split(" "))
+ return this.plugin.platform.tabCompleteCommand(new SpongeCommandSender(cause), arguments.input().split(" "))
.stream()
.map(CommandCompletion::of)
.collect(Collectors.toList());
@@ -236,7 +236,7 @@ public class Sponge8SparkPlugin implements SparkPlugin {
@Override
public boolean canExecute(CommandCause cause) {
- return this.plugin.platform.hasPermissionForAnyCommand(new Sponge8CommandSender(cause));
+ return this.plugin.platform.hasPermissionForAnyCommand(new SpongeCommandSender(cause));
}
@Override
diff --git a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8TickHook.java b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeTickHook.java
index 6502da2..71b4541 100644
--- a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8TickHook.java
+++ b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeTickHook.java
@@ -28,12 +28,12 @@ import org.spongepowered.api.scheduler.Task;
import org.spongepowered.api.util.Ticks;
import org.spongepowered.plugin.PluginContainer;
-public class Sponge8TickHook extends AbstractTickHook implements TickHook, Runnable {
+public class SpongeTickHook extends AbstractTickHook implements TickHook, Runnable {
private final PluginContainer plugin;
private final Game game;
private ScheduledTask task;
- public Sponge8TickHook(PluginContainer plugin, Game game) {
+ public SpongeTickHook(PluginContainer plugin, Game game) {
this.plugin = plugin;
this.game = game;
}
diff --git a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8WorldInfoProvider.java b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeWorldInfoProvider.java
index 1bad9d7..15f15f8 100644
--- a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8WorldInfoProvider.java
+++ b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeWorldInfoProvider.java
@@ -41,10 +41,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
-public class Sponge8WorldInfoProvider implements WorldInfoProvider {
+public class SpongeWorldInfoProvider implements WorldInfoProvider {
private final Server server;
- public Sponge8WorldInfoProvider(Server server) {
+ public SpongeWorldInfoProvider(Server server) {
this.server = server;
}
diff --git a/spark-sponge8/src/main/resources/META-INF/sponge_plugins.json b/spark-sponge/src/main/resources/META-INF/sponge_plugins.json
index 55b1772..195d0b9 100644
--- a/spark-sponge8/src/main/resources/META-INF/sponge_plugins.json
+++ b/spark-sponge/src/main/resources/META-INF/sponge_plugins.json
@@ -7,9 +7,9 @@
"plugins": [
{
"id": "spark",
- "name": "spark-sponge8",
+ "name": "spark",
"version": "${version}",
- "entrypoint": "me.lucko.spark.sponge.Sponge8SparkPlugin",
+ "entrypoint": "me.lucko.spark.sponge.SpongeSparkPlugin",
"description": "${description}",
"links": {
"homepage": "https://spark.lucko.me/",
diff --git a/spark-sponge7/build.gradle b/spark-sponge7/build.gradle
deleted file mode 100644
index da2f3d5..0000000
--- a/spark-sponge7/build.gradle
+++ /dev/null
@@ -1,46 +0,0 @@
-plugins {
- id 'net.kyori.blossom' version '1.3.0'
- id 'com.gradleup.shadow' version '8.3.0'
-}
-
-dependencies {
- implementation project(':spark-common')
- compileOnly 'org.spongepowered:spongeapi:7.3.0'
- annotationProcessor 'org.spongepowered:spongeapi:7.3.0'
-}
-
-repositories {
- maven { url "https://repo.spongepowered.org/maven" }
-}
-
-blossom {
- replaceTokenIn('src/main/java/me/lucko/spark/sponge/Sponge7SparkPlugin.java')
- replaceToken '@version@', project.pluginVersion
- replaceToken '@desc@', project.pluginDescription
-}
-
-shadowJar {
- archiveFileName = "spark-${project.pluginVersion}-sponge7.jar"
-
- relocate 'net.kyori.adventure', 'me.lucko.spark.lib.adventure'
- relocate 'net.kyori.examination', 'me.lucko.spark.lib.adventure.examination'
- relocate 'net.kyori.option', 'me.lucko.spark.lib.adventure.option'
- relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
- relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
- relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'
- relocate 'one.profiler', 'me.lucko.spark.lib.asyncprofiler'
- relocate 'me.lucko.bytesocks.client', 'me.lucko.spark.lib.bytesocks'
- relocate 'org.java_websocket', 'me.lucko.spark.lib.bytesocks.ws'
-
- exclude 'module-info.class'
- exclude 'META-INF/maven/**'
- exclude 'META-INF/proguard/**'
- exclude 'META-INF/versions/**'
- exclude '**/*.proto'
- exclude '**/*.proto.bin'
-}
-
-artifacts {
- archives shadowJar
- shadow shadowJar
-}
diff --git a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7ClassSourceLookup.java b/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7ClassSourceLookup.java
deleted file mode 100644
index 9342f3d..0000000
--- a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7ClassSourceLookup.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.sponge;
-
-import me.lucko.spark.common.sampler.source.ClassSourceLookup;
-import org.spongepowered.api.Game;
-
-import java.nio.file.Path;
-
-public class Sponge7ClassSourceLookup extends ClassSourceLookup.ByCodeSource {
- private final Path modsDirectory;
-
- public Sponge7ClassSourceLookup(Game game) {
- this.modsDirectory = game.getGameDirectory().resolve("mods").toAbsolutePath().normalize();
- }
-
- @Override
- public String identifyFile(Path path) {
- if (!path.startsWith(this.modsDirectory)) {
- return null;
- }
-
- return super.identifyFileName(this.modsDirectory.relativize(path).toString());
- }
-}
diff --git a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7CommandSender.java b/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7CommandSender.java
deleted file mode 100644
index f19dfce..0000000
--- a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7CommandSender.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.sponge;
-
-import me.lucko.spark.common.command.sender.AbstractCommandSender;
-import net.kyori.adventure.text.Component;
-import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
-import org.spongepowered.api.command.CommandSource;
-import org.spongepowered.api.entity.living.player.Player;
-import org.spongepowered.api.text.serializer.TextSerializers;
-
-import java.util.UUID;
-
-public class Sponge7CommandSender extends AbstractCommandSender<CommandSource> {
- public Sponge7CommandSender(CommandSource source) {
- super(source);
- }
-
- @Override
- public String getName() {
- return super.delegate.getName();
- }
-
- @Override
- public UUID getUniqueId() {
- if (super.delegate instanceof Player) {
- return ((Player) super.delegate).getUniqueId();
- }
- return null;
- }
-
- @Override
- public void sendMessage(Component message) {
- super.delegate.sendMessage(TextSerializers.JSON.deserialize(GsonComponentSerializer.gson().serialize(message)));
- }
-
- @Override
- public boolean hasPermission(String permission) {
- return super.delegate.hasPermission(permission);
- }
-}
diff --git a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7PlatformInfo.java b/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7PlatformInfo.java
deleted file mode 100644
index 37463b1..0000000
--- a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7PlatformInfo.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.sponge;
-
-import me.lucko.spark.common.platform.PlatformInfo;
-import org.spongepowered.api.Game;
-import org.spongepowered.api.Platform;
-
-public class Sponge7PlatformInfo implements PlatformInfo {
- private final Game game;
-
- public Sponge7PlatformInfo(Game game) {
- this.game = game;
- }
-
- @Override
- public Type getType() {
- return Type.SERVER;
- }
-
- @Override
- public String getName() {
- return "Sponge";
- }
-
- @Override
- public String getBrand() {
- return this.game.getPlatform().getContainer(Platform.Component.IMPLEMENTATION).getName();
- }
-
- @Override
- public String getVersion() {
- return this.game.getPlatform().getContainer(Platform.Component.IMPLEMENTATION).getVersion().orElse("unknown");
- }
-
- @Override
- public String getMinecraftVersion() {
- return this.game.getPlatform().getMinecraftVersion().getName();
- }
-}
diff --git a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7PlayerPingProvider.java b/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7PlayerPingProvider.java
deleted file mode 100644
index 12fff78..0000000
--- a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7PlayerPingProvider.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.sponge;
-
-import com.google.common.collect.ImmutableMap;
-import me.lucko.spark.common.monitor.ping.PlayerPingProvider;
-import org.spongepowered.api.Server;
-import org.spongepowered.api.entity.living.player.Player;
-
-import java.util.Map;
-
-public class Sponge7PlayerPingProvider implements PlayerPingProvider {
- private final Server server;
-
- public Sponge7PlayerPingProvider(Server server) {
- this.server = server;
- }
-
- @Override
- public Map<String, Integer> poll() {
- ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder();
- for (Player player : this.server.getOnlinePlayers()) {
- builder.put(player.getName(), player.getConnection().getLatency());
- }
- return builder.build();
- }
-}
diff --git a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7SparkPlugin.java b/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7SparkPlugin.java
deleted file mode 100644
index 7cd73f4..0000000
--- a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7SparkPlugin.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.sponge;
-
-import com.google.inject.Inject;
-import me.lucko.spark.api.Spark;
-import me.lucko.spark.common.SparkPlatform;
-import me.lucko.spark.common.SparkPlugin;
-import me.lucko.spark.common.monitor.ping.PlayerPingProvider;
-import me.lucko.spark.common.platform.PlatformInfo;
-import me.lucko.spark.common.platform.world.WorldInfoProvider;
-import me.lucko.spark.common.sampler.ThreadDumper;
-import me.lucko.spark.common.sampler.source.ClassSourceLookup;
-import me.lucko.spark.common.tick.TickHook;
-import org.slf4j.Logger;
-import org.spongepowered.api.Game;
-import org.spongepowered.api.command.CommandCallable;
-import org.spongepowered.api.command.CommandResult;
-import org.spongepowered.api.command.CommandSource;
-import org.spongepowered.api.config.ConfigDir;
-import org.spongepowered.api.event.Listener;
-import org.spongepowered.api.event.game.state.GameStartedServerEvent;
-import org.spongepowered.api.event.game.state.GameStoppingServerEvent;
-import org.spongepowered.api.plugin.Plugin;
-import org.spongepowered.api.plugin.PluginContainer;
-import org.spongepowered.api.scheduler.AsynchronousExecutor;
-import org.spongepowered.api.scheduler.SpongeExecutorService;
-import org.spongepowered.api.scheduler.SynchronousExecutor;
-import org.spongepowered.api.text.Text;
-import org.spongepowered.api.world.Location;
-import org.spongepowered.api.world.World;
-
-import javax.annotation.Nullable;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.Optional;
-import java.util.logging.Level;
-import java.util.stream.Stream;
-
-@Plugin(
- id = "spark",
- name = "spark",
- version = "@version@",
- description = "@desc@",
- authors = {"Luck"}
-)
-public class Sponge7SparkPlugin implements SparkPlugin {
-
- private final PluginContainer pluginContainer;
- private final Logger logger;
- private final Game game;
- private final Path configDirectory;
- private final SpongeExecutorService asyncExecutor;
- private final SpongeExecutorService syncExecutor;
- private final ThreadDumper.GameThread gameThreadDumper = new ThreadDumper.GameThread();
-
- private SparkPlatform platform;
-
- @Inject
- public Sponge7SparkPlugin(PluginContainer pluginContainer, Logger logger, Game game, @ConfigDir(sharedRoot = false) Path configDirectory, @AsynchronousExecutor SpongeExecutorService asyncExecutor, @SynchronousExecutor SpongeExecutorService syncExecutor) {
- this.pluginContainer = pluginContainer;
- this.logger = logger;
- this.game = game;
- this.configDirectory = configDirectory;
- this.asyncExecutor = asyncExecutor;
- this.syncExecutor = syncExecutor;
-
- this.syncExecutor.execute(() -> this.gameThreadDumper.setThread(Thread.currentThread()));
- }
-
- @Listener
- public void onEnable(GameStartedServerEvent event) {
- this.platform = new SparkPlatform(this);
- this.platform.enable();
- this.game.getCommandManager().register(this, new SparkCommand(this), "spark");
- }
-
- @Listener
- public void onDisable(GameStoppingServerEvent event) {
- this.platform.disable();
- }
-
- @Override
- public String getVersion() {
- return Sponge7SparkPlugin.class.getAnnotation(Plugin.class).version();
- }
-
- @Override
- public Path getPluginDirectory() {
- return this.configDirectory;
- }
-
- @Override
- public String getCommandName() {
- return "spark";
- }
-
- @Override
- public Stream<Sponge7CommandSender> getCommandSenders() {
- if (this.game.isServerAvailable()) {
- return Stream.concat(
- this.game.getServer().getOnlinePlayers().stream(),
- Stream.of(this.game.getServer().getConsole())
- ).map(Sponge7CommandSender::new);
- } else {
- return Stream.of(this.game.getServer().getConsole()).map(Sponge7CommandSender::new);
- }
- }
-
- @Override
- public void executeAsync(Runnable task) {
- this.asyncExecutor.execute(task);
- }
-
- @Override
- public void executeSync(Runnable task) {
- this.syncExecutor.execute(task);
- }
-
- @Override
- public void log(Level level, String msg) {
- if (level == Level.INFO) {
- this.logger.info(msg);
- } else if (level == Level.WARNING) {
- this.logger.warn(msg);
- } else if (level == Level.SEVERE) {
- this.logger.error(msg);
- } else {
- throw new IllegalArgumentException(level.getName());
- }
- }
-
- @Override
- public ThreadDumper getDefaultThreadDumper() {
- return this.gameThreadDumper.get();
- }
-
- @Override
- public TickHook createTickHook() {
- return new Sponge7TickHook(this);
- }
-
- @Override
- public ClassSourceLookup createClassSourceLookup() {
- return new Sponge7ClassSourceLookup(this.game);
- }
-
- @Override
- public PlayerPingProvider createPlayerPingProvider() {
- if (this.game.isServerAvailable()) {
- return new Sponge7PlayerPingProvider(this.game.getServer());
- } else {
- return null;
- }
- }
-
- @Override
- public WorldInfoProvider createWorldInfoProvider() {
- if (this.game.isServerAvailable()) {
- return new Sponge7WorldInfoProvider(this.game.getServer());
- } else {
- return WorldInfoProvider.NO_OP;
- }
- }
-
- @Override
- public PlatformInfo getPlatformInfo() {
- return new Sponge7PlatformInfo(this.game);
- }
-
- @Override
- public void registerApi(Spark api) {
- this.game.getServiceManager().setProvider(this, Spark.class, api);
- }
-
- private static final class SparkCommand implements CommandCallable {
- private final Sponge7SparkPlugin plugin;
-
- private SparkCommand(Sponge7SparkPlugin plugin) {
- this.plugin = plugin;
- }
-
- @Override
- public CommandResult process(CommandSource source, String arguments) {
- this.plugin.platform.executeCommand(new Sponge7CommandSender(source), arguments.split(" "));
- return CommandResult.empty();
- }
-
- @Override
- public List<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPosition) {
- return this.plugin.platform.tabCompleteCommand(new Sponge7CommandSender(source), arguments.split(" "));
- }
-
- @Override
- public boolean testPermission(CommandSource source) {
- return this.plugin.platform.hasPermissionForAnyCommand(new Sponge7CommandSender(source));
- }
-
- @Override
- public Optional<Text> getShortDescription(CommandSource source) {
- return Optional.of(Text.of("Main spark plugin command"));
- }
-
- @Override
- public Optional<Text> getHelp(CommandSource source) {
- return Optional.of(Text.of("Run '/spark' to view usage."));
- }
-
- @Override
- public Text getUsage(CommandSource source) {
- return Text.of("Run '/spark' to view usage.");
- }
- }
-}
diff --git a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7TickHook.java b/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7TickHook.java
deleted file mode 100644
index c2b1483..0000000
--- a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7TickHook.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.sponge;
-
-import me.lucko.spark.common.tick.AbstractTickHook;
-import me.lucko.spark.common.tick.TickHook;
-import org.spongepowered.api.scheduler.Task;
-
-public class Sponge7TickHook extends AbstractTickHook implements TickHook, Runnable {
- private final Sponge7SparkPlugin plugin;
- private Task task;
-
- public Sponge7TickHook(Sponge7SparkPlugin plugin) {
- this.plugin = plugin;
- }
-
- @Override
- public void run() {
- onTick();
- }
-
- @Override
- public void start() {
- this.task = Task.builder().intervalTicks(1).name("spark-ticker").execute(this).submit(this.plugin);
- }
-
- @Override
- public void close() {
- this.task.cancel();
- }
-
-}
diff --git a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7WorldInfoProvider.java b/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7WorldInfoProvider.java
deleted file mode 100644
index fd26bfa..0000000
--- a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7WorldInfoProvider.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.sponge;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import me.lucko.spark.common.platform.world.AbstractChunkInfo;
-import me.lucko.spark.common.platform.world.CountMap;
-import me.lucko.spark.common.platform.world.WorldInfoProvider;
-import org.spongepowered.api.Server;
-import org.spongepowered.api.entity.Entity;
-import org.spongepowered.api.entity.EntityType;
-import org.spongepowered.api.world.Chunk;
-import org.spongepowered.api.world.World;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-
-public class Sponge7WorldInfoProvider implements WorldInfoProvider {
- private final Server server;
-
- public Sponge7WorldInfoProvider(Server server) {
- this.server = server;
- }
-
- @Override
- public CountsResult pollCounts() {
- int players = this.server.getOnlinePlayers().size();
- int entities = 0;
- int tileEntities = 0;
- int chunks = 0;
-
- for (World world : this.server.getWorlds()) {
- entities += world.getEntities().size();
- tileEntities += world.getTileEntities().size();
- chunks += Iterables.size(world.getLoadedChunks());
- }
-
- return new CountsResult(players, entities, tileEntities, chunks);
- }
-
- @Override
- public ChunksResult<Sponge7ChunkInfo> pollChunks() {
- ChunksResult<Sponge7ChunkInfo> data = new ChunksResult<>();
-
- for (World world : this.server.getWorlds()) {
- List<Chunk> chunks = Lists.newArrayList(world.getLoadedChunks());
-
- List<Sponge7ChunkInfo> list = new ArrayList<>(chunks.size());
- for (Chunk chunk : chunks) {
- list.add(new Sponge7ChunkInfo(chunk));
- }
-
- data.put(world.getName(), list);
- }
-
- return data;
- }
-
- @Override
- public GameRulesResult pollGameRules() {
- // No way to get defaults info on sponge API 7 :(
-
- // GameRulesResult data = new GameRulesResult();
- // for (World world : this.server.getWorlds()) {
- // for (Map.Entry<String, String> entry : world.getGameRules().entrySet()) {
- // data.put(entry.getKey(), world.getName(), entry.getValue());
- // }
- // }
- // return data;
-
- return null;
- }
-
- @Override
- public Collection<DataPackInfo> pollDataPacks() {
- return null;
- }
-
- static final class Sponge7ChunkInfo extends AbstractChunkInfo<EntityType> {
- private final CountMap<EntityType> entityCounts;
-
- Sponge7ChunkInfo(Chunk chunk) {
- super(chunk.getPosition().getX(), chunk.getPosition().getZ());
-
- this.entityCounts = new CountMap.Simple<>(new HashMap<>());
- for (Entity entity : chunk.getEntities()) {
- this.entityCounts.increment(entity.getType());
- }
- }
-
- @Override
- public CountMap<EntityType> getEntityCounts() {
- return this.entityCounts;
- }
-
- @Override
- public String entityTypeName(EntityType type) {
- return type.getName();
- }
-
- }
-}
diff --git a/spark-velocity4/build.gradle b/spark-velocity4/build.gradle
deleted file mode 100644
index a10d73b..0000000
--- a/spark-velocity4/build.gradle
+++ /dev/null
@@ -1,52 +0,0 @@
-plugins {
- id 'net.kyori.blossom' version '1.3.0'
- id 'com.gradleup.shadow' version '8.3.0'
-}
-
-tasks.withType(JavaCompile) {
- // override, compile targeting J11
- options.release = 11
-}
-
-dependencies {
- implementation project(':spark-common')
- compileOnly 'com.velocitypowered:velocity-api:4.0.0-SNAPSHOT'
- annotationProcessor 'com.velocitypowered:velocity-annotation-processor:4.0.0-SNAPSHOT'
-}
-
-repositories {
- maven { url "https://repo.papermc.io/repository/maven-public/" }
-}
-
-blossom {
- replaceTokenIn('src/main/java/me/lucko/spark/velocity/VelocitySparkPlugin.java')
- replaceToken '@version@', project.pluginVersion
- replaceToken '@desc@', project.pluginDescription
-}
-
-shadowJar {
- archiveFileName = "spark-${project.pluginVersion}-velocity4.jar"
-
- dependencies {
- exclude(dependency('net.kyori:^(?!adventure-text-feature-pagination).+$'))
- }
-
- relocate 'net.kyori.adventure.text.feature.pagination', 'me.lucko.spark.lib.adventure.pagination'
- relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
- relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
- relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'
- relocate 'one.profiler', 'me.lucko.spark.lib.asyncprofiler'
- relocate 'me.lucko.bytesocks.client', 'me.lucko.spark.lib.bytesocks'
- relocate 'org.java_websocket', 'me.lucko.spark.lib.bytesocks.ws'
-
- exclude 'module-info.class'
- exclude 'META-INF/maven/**'
- exclude 'META-INF/proguard/**'
- exclude '**/*.proto'
- exclude '**/*.proto.bin'
-}
-
-artifacts {
- archives shadowJar
- shadow shadowJar
-} \ No newline at end of file
diff --git a/spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4ClassSourceLookup.java b/spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4ClassSourceLookup.java
deleted file mode 100644
index c01e8a1..0000000
--- a/spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4ClassSourceLookup.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.velocity;
-
-import com.velocitypowered.api.plugin.PluginContainer;
-import com.velocitypowered.api.plugin.PluginManager;
-import me.lucko.spark.common.sampler.source.ClassSourceLookup;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class Velocity4ClassSourceLookup extends ClassSourceLookup.ByClassLoader {
- private static final Class<?> PLUGIN_CLASS_LOADER;
-
- static {
- try {
- PLUGIN_CLASS_LOADER = Class.forName("com.velocitypowered.proxy.plugin.PluginClassLoader");
- } catch (ReflectiveOperationException e) {
- throw new ExceptionInInitializerError(e);
- }
- }
-
- private final Map<ClassLoader, String> classLoadersToPlugin;
-
- public Velocity4ClassSourceLookup(PluginManager pluginManager) {
- this.classLoadersToPlugin = new HashMap<>();
- for (PluginContainer plugin : pluginManager.plugins()) {
- Object instance = plugin.instance();
- if (instance != null) {
- this.classLoadersToPlugin.put(instance.getClass().getClassLoader(), plugin.description().id());
- }
- }
- }
-
- @Override
- public @Nullable String identify(ClassLoader loader) {
- if (PLUGIN_CLASS_LOADER.isInstance(loader)) {
- return this.classLoadersToPlugin.get(loader);
- }
- return null;
- }
-}
diff --git a/spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4CommandSender.java b/spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4CommandSender.java
deleted file mode 100644
index 11549ee..0000000
--- a/spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4CommandSender.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.velocity;
-
-import com.velocitypowered.api.command.CommandSource;
-import com.velocitypowered.api.command.ConsoleCommandSource;
-import com.velocitypowered.api.proxy.connection.Player;
-import me.lucko.spark.common.command.sender.AbstractCommandSender;
-import net.kyori.adventure.text.Component;
-
-import java.util.UUID;
-
-public class Velocity4CommandSender extends AbstractCommandSender<CommandSource> {
- public Velocity4CommandSender(CommandSource source) {
- super(source);
- }
-
- @Override
- public String getName() {
- if (super.delegate instanceof Player) {
- return ((Player) super.delegate).username();
- } else if (super.delegate instanceof ConsoleCommandSource) {
- return "Console";
- } else {
- return "unknown:" + super.delegate.getClass().getSimpleName();
- }
- }
-
- @Override
- public UUID getUniqueId() {
- if (super.delegate instanceof Player) {
- return ((Player) super.delegate).id();
- }
- return null;
- }
-
- @Override
- public void sendMessage(Component message) {
- super.delegate.sendMessage(message);
- }
-
- @Override
- public boolean hasPermission(String permission) {
- return super.delegate.hasPermission(permission);
- }
-}
diff --git a/spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4PlatformInfo.java b/spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4PlatformInfo.java
deleted file mode 100644
index 86f5b95..0000000
--- a/spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4PlatformInfo.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.velocity;
-
-import com.velocitypowered.api.proxy.ProxyServer;
-import me.lucko.spark.common.platform.PlatformInfo;
-
-public class Velocity4PlatformInfo implements PlatformInfo {
- private final ProxyServer proxy;
-
- public Velocity4PlatformInfo(ProxyServer proxy) {
- this.proxy = proxy;
- }
-
- @Override
- public Type getType() {
- return Type.PROXY;
- }
-
- @Override
- public String getName() {
- return "Velocity";
- }
-
- @Override
- public String getBrand() {
- return this.proxy.version().name();
- }
-
- @Override
- public String getVersion() {
- return this.proxy.version().version();
- }
-
- @Override
- public String getMinecraftVersion() {
- return null;
- }
-}
diff --git a/spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4PlayerPingProvider.java b/spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4PlayerPingProvider.java
deleted file mode 100644
index 32114e5..0000000
--- a/spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4PlayerPingProvider.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.velocity;
-
-import com.google.common.collect.ImmutableMap;
-import com.velocitypowered.api.proxy.ProxyServer;
-import com.velocitypowered.api.proxy.connection.Player;
-import me.lucko.spark.common.monitor.ping.PlayerPingProvider;
-
-import java.util.Map;
-
-public class Velocity4PlayerPingProvider implements PlayerPingProvider {
- private final ProxyServer proxy;
-
- public Velocity4PlayerPingProvider(ProxyServer proxy) {
- this.proxy = proxy;
- }
-
- @Override
- public Map<String, Integer> poll() {
- ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder();
- for (Player player : this.proxy.connectedPlayers()) {
- builder.put(player.username(), (int) player.ping());
- }
- return builder.build();
- }
-}
diff --git a/spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4SparkPlugin.java b/spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4SparkPlugin.java
deleted file mode 100644
index 015deb4..0000000
--- a/spark-velocity4/src/main/java/me/lucko/spark/velocity/Velocity4SparkPlugin.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.velocity;
-
-import com.google.inject.Inject;
-import com.velocitypowered.api.command.SimpleCommand;
-import com.velocitypowered.api.event.PostOrder;
-import com.velocitypowered.api.event.Subscribe;
-import com.velocitypowered.api.event.lifecycle.ProxyInitializeEvent;
-import com.velocitypowered.api.event.lifecycle.ProxyShutdownEvent;
-import com.velocitypowered.api.plugin.Plugin;
-import com.velocitypowered.api.plugin.annotation.DataDirectory;
-import com.velocitypowered.api.proxy.ProxyServer;
-import me.lucko.spark.common.SparkPlatform;
-import me.lucko.spark.common.SparkPlugin;
-import me.lucko.spark.common.monitor.ping.PlayerPingProvider;
-import me.lucko.spark.common.platform.PlatformInfo;
-import me.lucko.spark.common.sampler.source.ClassSourceLookup;
-import me.lucko.spark.common.sampler.source.SourceMetadata;
-import org.slf4j.Logger;
-
-import java.nio.file.Path;
-import java.util.Collection;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.stream.Stream;
-
-@Plugin(
- id = "spark",
- name = "spark",
- version = "@version@",
- description = "@desc@",
- authors = {"Luck"}
-)
-public class Velocity4SparkPlugin implements SparkPlugin, SimpleCommand {
-
- private final ProxyServer proxy;
- private final Logger logger;
- private final Path configDirectory;
-
- private SparkPlatform platform;
-
- @Inject
- public Velocity4SparkPlugin(ProxyServer proxy, Logger logger, @DataDirectory Path configDirectory) {
- this.proxy = proxy;
- this.logger = logger;
- this.configDirectory = configDirectory;
- }
-
- @Subscribe(order = PostOrder.FIRST)
- public void onEnable(ProxyInitializeEvent e) {
- this.platform = new SparkPlatform(this);
- this.platform.enable();
- this.proxy.commandManager().register("sparkv", this, "sparkvelocity");
- }
-
- @Subscribe(order = PostOrder.LAST)
- public void onDisable(ProxyShutdownEvent e) {
- this.platform.disable();
- }
-
- @Override
- public void execute(Invocation inv) {
- this.platform.executeCommand(new Velocity4CommandSender(inv.source()), inv.arguments());
- }
-
- @Override
- public List<String> suggest(Invocation inv) {
- return this.platform.tabCompleteCommand(new Velocity4CommandSender(inv.source()), inv.arguments());
- }
-
- @Override
- public boolean hasPermission(Invocation inv) {
- return this.platform.hasPermissionForAnyCommand(new Velocity4CommandSender(inv.source()));
- }
-
- @Override
- public String getVersion() {
- return Velocity4SparkPlugin.class.getAnnotation(Plugin.class).version();
- }
-
- @Override
- public Path getPluginDirectory() {
- return this.configDirectory;
- }
-
- @Override
- public String getCommandName() {
- return "sparkv";
- }
-
- @Override
- public Stream<Velocity4CommandSender> getCommandSenders() {
- return Stream.concat(
- this.proxy.connectedPlayers().stream(),
- Stream.of(this.proxy.consoleCommandSource())
- ).map(Velocity4CommandSender::new);
- }
-
- @Override
- public void executeAsync(Runnable task) {
- this.proxy.scheduler().buildTask(this, task).schedule();
- }
-
- @Override
- public void log(Level level, String msg) {
- if (level == Level.INFO) {
- this.logger.info(msg);
- } else if (level == Level.WARNING) {
- this.logger.warn(msg);
- } else if (level == Level.SEVERE) {
- this.logger.error(msg);
- } else {
- throw new IllegalArgumentException(level.getName());
- }
- }
-
- @Override
- public ClassSourceLookup createClassSourceLookup() {
- return new Velocity4ClassSourceLookup(this.proxy.pluginManager());
- }
-
- @Override
- public Collection<SourceMetadata> getKnownSources() {
- return SourceMetadata.gather(
- this.proxy.pluginManager().plugins(),
- plugin -> plugin.description().id(),
- plugin -> plugin.description().version(),
- plugin -> String.join(", ", plugin.description().authors()),
- plugin -> plugin.description().description()
- );
- }
-
- @Override
- public PlayerPingProvider createPlayerPingProvider() {
- return new Velocity4PlayerPingProvider(this.proxy);
- }
-
- @Override
- public PlatformInfo getPlatformInfo() {
- return new Velocity4PlatformInfo(this.proxy);
- }
-}
diff --git a/spark-waterdog/build.gradle b/spark-waterdog/build.gradle
deleted file mode 100644
index 0f0dee2..0000000
--- a/spark-waterdog/build.gradle
+++ /dev/null
@@ -1,56 +0,0 @@
-plugins {
- id 'com.gradleup.shadow' version '8.3.0'
-}
-
-tasks.withType(JavaCompile) {
- // override, compile targeting J11
- options.release = 11
-}
-
-dependencies {
- implementation project(':spark-common')
- compileOnly('dev.waterdog.waterdogpe:waterdog:1.2.3') {
- exclude group: 'com.nukkitx.protocol'
- }
-}
-
-repositories {
- maven { url 'https://repo.opencollab.dev/main/' }
- maven { url 'https://repo.waterdog.dev/releases/' }
- maven { url 'https://repo.waterdog.dev/snapshots/' }
-}
-
-processResources {
- from(sourceSets.main.resources.srcDirs) {
- expand (
- 'pluginVersion': project.pluginVersion,
- 'pluginDescription': project.pluginDescription
- )
- include 'plugin.yml'
- }
-}
-
-shadowJar {
- archiveFileName = "spark-${project.pluginVersion}-waterdog.jar"
-
- relocate 'net.kyori.adventure', 'me.lucko.spark.lib.adventure'
- relocate 'net.kyori.examination', 'me.lucko.spark.lib.adventure.examination'
- relocate 'net.kyori.option', 'me.lucko.spark.lib.adventure.option'
- relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
- relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
- relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'
- relocate 'one.profiler', 'me.lucko.spark.lib.asyncprofiler'
- relocate 'me.lucko.bytesocks.client', 'me.lucko.spark.lib.bytesocks'
- relocate 'org.java_websocket', 'me.lucko.spark.lib.bytesocks.ws'
-
- exclude 'module-info.class'
- exclude 'META-INF/maven/**'
- exclude 'META-INF/proguard/**'
- exclude '**/*.proto'
- exclude '**/*.proto.bin'
-}
-
-artifacts {
- archives shadowJar
- shadow shadowJar
-}
diff --git a/spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogClassSourceLookup.java b/spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogClassSourceLookup.java
deleted file mode 100644
index 8a34983..0000000
--- a/spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogClassSourceLookup.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.waterdog;
-
-import dev.waterdog.waterdogpe.ProxyServer;
-import dev.waterdog.waterdogpe.plugin.Plugin;
-import dev.waterdog.waterdogpe.plugin.PluginClassLoader;
-import me.lucko.spark.common.sampler.source.ClassSourceLookup;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-
-public class WaterdogClassSourceLookup extends ClassSourceLookup.ByClassLoader {
- private final ProxyServer proxy;
- private final Map<ClassLoader, String> cache;
-
- public WaterdogClassSourceLookup(ProxyServer proxy) {
- this.proxy = proxy;
- this.cache = new WeakHashMap<>();
- }
-
- @Override
- public String identify(ClassLoader loader) throws ReflectiveOperationException {
- if (loader instanceof PluginClassLoader) {
- String name = this.cache.get(loader);
- if (name != null) {
- return name;
- }
-
- for (Plugin plugin : this.proxy.getPluginManager().getPlugins()) {
- if (plugin.getClass().getClassLoader() == loader) {
- name = plugin.getName();
- break;
- }
- }
-
- this.cache.put(loader, name);
- return name;
- }
- return null;
- }
-}
-
diff --git a/spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogCommandSender.java b/spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogCommandSender.java
deleted file mode 100644
index 259e832..0000000
--- a/spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogCommandSender.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.waterdog;
-
-import dev.waterdog.waterdogpe.command.CommandSender;
-import dev.waterdog.waterdogpe.player.ProxiedPlayer;
-import me.lucko.spark.common.command.sender.AbstractCommandSender;
-import net.kyori.adventure.text.Component;
-import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
-
-import java.util.UUID;
-
-public class WaterdogCommandSender extends AbstractCommandSender<CommandSender> {
-
- public WaterdogCommandSender(CommandSender sender) {
- super(sender);
- }
-
- @Override
- public String getName() {
- return super.delegate.getName();
- }
-
- @Override
- public UUID getUniqueId() {
- if (super.delegate instanceof ProxiedPlayer) {
- return ((ProxiedPlayer) super.delegate).getUniqueId();
- }
- return null;
- }
-
- @Override
- public void sendMessage(Component message) {
- super.delegate.sendMessage(LegacyComponentSerializer.legacySection().serialize(message));
- }
-
- @Override
- public boolean hasPermission(String permission) {
- return super.delegate.hasPermission(permission);
- }
-}
diff --git a/spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogPlatformInfo.java b/spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogPlatformInfo.java
deleted file mode 100644
index b32d427..0000000
--- a/spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogPlatformInfo.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.waterdog;
-
-import dev.waterdog.waterdogpe.WaterdogPE;
-import me.lucko.spark.common.platform.PlatformInfo;
-
-public class WaterdogPlatformInfo implements PlatformInfo {
-
- @Override
- public Type getType() {
- return Type.PROXY;
- }
-
- @Override
- public String getName() {
- return "Waterdog";
- }
-
- @Override
- public String getBrand() {
- return "Waterdog";
- }
-
- @Override
- public String getVersion() {
- return WaterdogPE.version().baseVersion();
- }
-
- @Override
- public String getMinecraftVersion() {
- return null;
- }
-}
diff --git a/spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogPlayerPingProvider.java b/spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogPlayerPingProvider.java
deleted file mode 100644
index 03c9242..0000000
--- a/spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogPlayerPingProvider.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.waterdog;
-
-import com.google.common.collect.ImmutableMap;
-import dev.waterdog.waterdogpe.ProxyServer;
-import dev.waterdog.waterdogpe.player.ProxiedPlayer;
-import me.lucko.spark.common.monitor.ping.PlayerPingProvider;
-
-import java.util.Map;
-
-public class WaterdogPlayerPingProvider implements PlayerPingProvider {
- private final ProxyServer proxy;
-
- public WaterdogPlayerPingProvider(ProxyServer proxy) {
- this.proxy = proxy;
- }
-
- @Override
- public Map<String, Integer> poll() {
- ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder();
- for (ProxiedPlayer player : this.proxy.getPlayers().values()) {
- builder.put(player.getName(), (int) player.getPing());
- }
- return builder.build();
- }
-}
diff --git a/spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogSparkPlugin.java b/spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogSparkPlugin.java
deleted file mode 100644
index f616176..0000000
--- a/spark-waterdog/src/main/java/me/lucko/spark/waterdog/WaterdogSparkPlugin.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.waterdog;
-
-import dev.waterdog.waterdogpe.ProxyServer;
-import dev.waterdog.waterdogpe.command.Command;
-import dev.waterdog.waterdogpe.command.CommandSender;
-import dev.waterdog.waterdogpe.plugin.Plugin;
-import me.lucko.spark.common.SparkPlatform;
-import me.lucko.spark.common.SparkPlugin;
-import me.lucko.spark.common.monitor.ping.PlayerPingProvider;
-import me.lucko.spark.common.platform.PlatformInfo;
-import me.lucko.spark.common.sampler.source.ClassSourceLookup;
-import me.lucko.spark.common.sampler.source.SourceMetadata;
-
-import java.nio.file.Path;
-import java.util.Collection;
-import java.util.logging.Level;
-import java.util.stream.Stream;
-
-public class WaterdogSparkPlugin extends Plugin implements SparkPlugin {
- private SparkPlatform platform;
-
- public ProxyServer getProxy() {
- return ProxyServer.getInstance();
- }
-
- @Override
- public void onEnable() {
- this.platform = new SparkPlatform(this);
- this.platform.enable();
- getProxy().getCommandMap().registerCommand(new SparkCommand(this));
- }
-
- @Override
- public void onDisable() {
- this.platform.disable();
- }
-
- @Override
- public String getVersion() {
- return getDescription().getVersion();
- }
-
- @Override
- public Path getPluginDirectory() {
- return getDataFolder().toPath();
- }
-
- @Override
- public String getCommandName() {
- return "sparkw";
- }
-
- @Override
- public Stream<WaterdogCommandSender> getCommandSenders() {
- return Stream.concat(
- getProxy().getPlayers().values().stream(),
- Stream.of(getProxy().getConsoleSender())
- ).map(WaterdogCommandSender::new);
- }
-
- @Override
- public void executeAsync(Runnable task) {
- getProxy().getScheduler().scheduleAsync(task);
- }
-
- @Override
- public void log(Level level, String msg) {
- if (level == Level.INFO) {
- getLogger().info(msg);
- } else if (level == Level.WARNING) {
- getLogger().warn(msg);
- } else if (level == Level.SEVERE) {
- getLogger().error(msg);
- } else {
- throw new IllegalArgumentException(level.getName());
- }
- }
-
- @Override
- public ClassSourceLookup createClassSourceLookup() {
- return new WaterdogClassSourceLookup(getProxy());
- }
-
- @Override
- public Collection<SourceMetadata> getKnownSources() {
- return SourceMetadata.gather(
- getProxy().getPluginManager().getPlugins(),
- Plugin::getName,
- plugin -> plugin.getDescription().getVersion(),
- plugin -> plugin.getDescription().getAuthor(),
- plugin -> null
- );
- }
-
- @Override
- public PlayerPingProvider createPlayerPingProvider() {
- return new WaterdogPlayerPingProvider(getProxy());
- }
-
- @Override
- public PlatformInfo getPlatformInfo() {
- return new WaterdogPlatformInfo();
- }
-
- private static final class SparkCommand extends Command {
- private final WaterdogSparkPlugin plugin;
-
- SparkCommand(WaterdogSparkPlugin plugin) {
- super("sparkw");
- this.plugin = plugin;
- }
-
- @Override
- public boolean onExecute(CommandSender sender, String alias, String[] args) {
- this.plugin.platform.executeCommand(new WaterdogCommandSender(sender), args);
- return true;
- }
- }
-}
diff --git a/spark-waterdog/src/main/resources/plugin.yml b/spark-waterdog/src/main/resources/plugin.yml
deleted file mode 100644
index ca0e846..0000000
--- a/spark-waterdog/src/main/resources/plugin.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-name: spark
-version: ${pluginVersion}
-description: ${pluginDescription}
-author: Luck
-website: https://spark.lucko.me/
-main: me.lucko.spark.waterdog.WaterdogSparkPlugin