-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: rtm516 <[email protected]>
- Loading branch information
Showing
8 changed files
with
430 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
plugins { | ||
id 'com.gradleup.shadow' version '8.3.0' | ||
} | ||
|
||
tasks.withType(JavaCompile) { | ||
// override, compile targeting J17 | ||
options.release = 17 | ||
} | ||
|
||
dependencies { | ||
implementation "me.lucko:spark-common:${project.baseVersion}-SNAPSHOT" | ||
|
||
implementation 'net.kyori:adventure-text-serializer-legacy:4.14.0' | ||
compileOnly 'org.geysermc.geyser:api:2.4.2-SNAPSHOT' | ||
compileOnly 'com.google.guava:guava:29.0-jre' | ||
compileOnly('org.geysermc.geyser:core:2.4.2-SNAPSHOT') { | ||
transitive(false) | ||
} | ||
} | ||
|
||
repositories { | ||
maven { url 'https://repo.opencollab.dev/main/' } | ||
} | ||
|
||
processResources { | ||
from(sourceSets.main.resources.srcDirs) { | ||
expand ( | ||
'pluginVersion': project.pluginVersion, | ||
'pluginDescription': project.pluginDescription | ||
) | ||
include 'extension.yml' | ||
} | ||
} | ||
|
||
shadowJar { | ||
archiveFileName = "spark-${project.pluginVersion}-geyser.jar" | ||
|
||
relocate 'net.kyori.adventure', 'me.lucko.spark.lib.adventure' | ||
relocate 'net.kyori.examination', 'me.lucko.spark.lib.adventure.examination' | ||
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/**' | ||
} | ||
|
||
artifacts { | ||
archives shadowJar | ||
shadow shadowJar | ||
} |
39 changes: 39 additions & 0 deletions
39
spark-geyser/src/main/java/me/lucko/spark/geyser/GeyserClassSourceLookup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* This file is part of spark. | ||
* | ||
* Copyright (c) lucko (Luck) <[email protected]> | ||
* 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.geyser; | ||
|
||
import me.lucko.spark.common.sampler.source.ClassSourceLookup; | ||
|
||
import org.geysermc.geyser.extension.GeyserExtensionClassLoader; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
|
||
public class GeyserClassSourceLookup extends ClassSourceLookup.ByFirstUrlSource { | ||
|
||
@Override | ||
public String identify(ClassLoader loader) throws IOException, URISyntaxException { | ||
if (loader instanceof GeyserExtensionClassLoader) { | ||
return super.identify(loader); | ||
} | ||
return null; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
spark-geyser/src/main/java/me/lucko/spark/geyser/GeyserCommandSender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* This file is part of spark. | ||
* | ||
* Copyright (c) lucko (Luck) <[email protected]> | ||
* 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.geyser; | ||
|
||
import me.lucko.spark.common.command.sender.AbstractCommandSender; | ||
|
||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; | ||
|
||
import org.geysermc.geyser.api.command.CommandSource; | ||
|
||
import java.util.UUID; | ||
|
||
public class GeyserCommandSender extends AbstractCommandSender<CommandSource> { | ||
|
||
public GeyserCommandSender(CommandSource delegate) { | ||
super(delegate); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return this.delegate.name(); | ||
} | ||
|
||
@Override | ||
public UUID getUniqueId() { | ||
return this.delegate.playerUuid(); | ||
} | ||
|
||
@Override | ||
public void sendMessage(Component message) { | ||
this.delegate.sendMessage(LegacyComponentSerializer.legacySection().serialize(message)); | ||
} | ||
|
||
@Override | ||
public boolean hasPermission(String permission) { | ||
return this.delegate.hasPermission(permission); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
spark-geyser/src/main/java/me/lucko/spark/geyser/GeyserPlatformInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* This file is part of spark. | ||
* | ||
* Copyright (c) lucko (Luck) <[email protected]> | ||
* 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.geyser; | ||
|
||
import me.lucko.spark.common.platform.PlatformInfo; | ||
|
||
import org.geysermc.api.util.ApiVersion; | ||
import org.geysermc.geyser.api.GeyserApi; | ||
|
||
public class GeyserPlatformInfo implements PlatformInfo { | ||
private final GeyserApi geyserApi; | ||
|
||
public GeyserPlatformInfo(GeyserApi geyserApi) { | ||
this.geyserApi = geyserApi; | ||
} | ||
|
||
@Override | ||
public Type getType() { | ||
return Type.SERVER; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "Geyser"; | ||
} | ||
|
||
@Override | ||
public String getBrand() { | ||
return "Geyser"; | ||
} | ||
|
||
@Override | ||
public String getVersion() { | ||
ApiVersion version = this.geyserApi.geyserApiVersion(); | ||
return version.human() + "." + version.major() + "." + version.minor(); | ||
} | ||
|
||
@Override | ||
public String getMinecraftVersion() { | ||
return this.geyserApi.supportedJavaVersion().versionString(); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
spark-geyser/src/main/java/me/lucko/spark/geyser/GeyserPlayerPingProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* This file is part of spark. | ||
* | ||
* Copyright (c) lucko (Luck) <[email protected]> | ||
* 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.geyser; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
|
||
import me.lucko.spark.common.monitor.ping.PlayerPingProvider; | ||
|
||
import org.geysermc.geyser.api.GeyserApi; | ||
import org.geysermc.geyser.api.connection.GeyserConnection; | ||
|
||
import java.util.Map; | ||
|
||
public class GeyserPlayerPingProvider implements PlayerPingProvider { | ||
private final GeyserApi server; | ||
|
||
public GeyserPlayerPingProvider(GeyserApi server) { | ||
this.server = server; | ||
} | ||
|
||
@Override | ||
public Map<String, Integer> poll() { | ||
ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder(); | ||
for (GeyserConnection player : this.server.onlineConnections()) { | ||
builder.put(player.name(), player.ping()); | ||
} | ||
return builder.build(); | ||
} | ||
} |
Oops, something went wrong.