-
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,103 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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
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,75 @@ | ||
plugins { | ||
id 'io.github.goooler.shadow' version '8.1.7' | ||
id 'maven-publish' | ||
} | ||
|
||
tasks.withType(JavaCompile) { | ||
// override, compile targeting J21 | ||
options.release = 21 | ||
} | ||
|
||
tasks.jar { | ||
archiveClassifier = 'original' | ||
} | ||
|
||
dependencies { | ||
implementation project(':spark-common') | ||
compileOnly 'io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT' | ||
} | ||
|
||
repositories { | ||
maven { url "https://repo.papermc.io/repository/maven-public/" } | ||
} | ||
|
||
shadowJar { | ||
archiveFileName = "spark-${project.pluginVersion}-paper.jar" | ||
archiveClassifier = '' | ||
|
||
dependencies { | ||
exclude(dependency('net.kyori:^(?!adventure-text-feature-pagination).+$')) | ||
exclude(dependency('net.bytebuddy:byte-buddy-agent')) | ||
} | ||
|
||
relocate 'net.kyori.adventure.text.feature.pagination', 'me.lucko.spark.paper.lib.adventure.pagination' | ||
relocate 'com.google.protobuf', 'me.lucko.spark.paper.lib.protobuf' | ||
relocate 'org.objectweb.asm', 'me.lucko.spark.paper.lib.asm' | ||
relocate 'one.profiler', 'me.lucko.spark.paper.lib.asyncprofiler' | ||
relocate 'me.lucko.bytesocks.client', 'me.lucko.spark.paper.lib.bytesocks' | ||
relocate 'org.java_websocket', 'me.lucko.spark.paper.lib.bytesocks.ws' | ||
|
||
// nest common classes beneath the paper package to avoid conflicts with spark-bukkit | ||
relocate 'me.lucko.spark.common', 'me.lucko.spark.paper.common' | ||
relocate 'me.lucko.spark.proto', 'me.lucko.spark.paper.proto' | ||
relocate 'spark-native', 'spark-paper-native' | ||
|
||
exclude 'module-info.class' | ||
exclude 'META-INF/maven/**' | ||
exclude 'META-INF/proguard/**' | ||
exclude '**/*.proto' | ||
exclude '**/*.proto.bin' | ||
exclude '**/*.proto' | ||
exclude '**/*.proto.bin' | ||
} | ||
|
||
artifacts { | ||
archives shadowJar | ||
shadow shadowJar | ||
} | ||
|
||
publishing { | ||
//repositories { | ||
// maven { | ||
// url = 'https://oss.sonatype.org/content/repositories/snapshots' | ||
// credentials { | ||
// username = sonatypeUsername | ||
// password = sonatypePassword | ||
// } | ||
// } | ||
//} | ||
publications { | ||
shadow(MavenPublication) { publication -> | ||
project.shadow.component(publication) | ||
version = "${project.pluginVersion}-SNAPSHOT" | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
spark-paper/src/main/java/me/lucko/spark/paper/PaperClassSourceLookup.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,61 @@ | ||
/* | ||
* 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.paper; | ||
|
||
import me.lucko.spark.common.sampler.source.ClassSourceLookup; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
public class PaperClassSourceLookup extends ClassSourceLookup.ByClassLoader { | ||
private static final Class<?> PLUGIN_CLASS_LOADER; | ||
private static final Field PLUGIN_FIELD; | ||
|
||
private static final Class<?> PAPER_PLUGIN_CLASS_LOADER; | ||
private static final Field PAPER_PLUGIN_FIELD; | ||
|
||
static { | ||
try { | ||
PLUGIN_CLASS_LOADER = Class.forName("org.bukkit.plugin.java.PluginClassLoader"); | ||
PLUGIN_FIELD = PLUGIN_CLASS_LOADER.getDeclaredField("plugin"); | ||
PLUGIN_FIELD.setAccessible(true); | ||
|
||
PAPER_PLUGIN_CLASS_LOADER = Class.forName("io.papermc.paper.plugin.entrypoint.classloader.PaperPluginClassLoader"); | ||
PAPER_PLUGIN_FIELD = PAPER_PLUGIN_CLASS_LOADER.getDeclaredField("loadedJavaPlugin"); | ||
PAPER_PLUGIN_FIELD.setAccessible(true); | ||
} catch (ReflectiveOperationException e) { | ||
throw new ExceptionInInitializerError(e); | ||
} | ||
} | ||
|
||
@Override | ||
public String identify(ClassLoader loader) throws ReflectiveOperationException { | ||
if (PLUGIN_CLASS_LOADER.isInstance(loader)) { | ||
JavaPlugin plugin = (JavaPlugin) PLUGIN_FIELD.get(loader); | ||
return plugin.getName(); | ||
} else if (PAPER_PLUGIN_CLASS_LOADER.isInstance(loader)) { | ||
JavaPlugin plugin = (JavaPlugin) PAPER_PLUGIN_FIELD.get(loader); | ||
return plugin.getName(); | ||
} | ||
return null; | ||
} | ||
} | ||
|
58 changes: 58 additions & 0 deletions
58
spark-paper/src/main/java/me/lucko/spark/paper/PaperCommandSender.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,58 @@ | ||
/* | ||
* 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.paper; | ||
|
||
import me.lucko.spark.common.command.sender.AbstractCommandSender; | ||
import net.kyori.adventure.text.Component; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.UUID; | ||
|
||
public class PaperCommandSender extends AbstractCommandSender<CommandSender> { | ||
|
||
public PaperCommandSender(CommandSender sender) { | ||
super(sender); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return this.delegate.getName(); | ||
} | ||
|
||
@Override | ||
public UUID getUniqueId() { | ||
if (super.delegate instanceof Player player) { | ||
return player.getUniqueId(); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public void sendMessage(Component message) { | ||
super.delegate.sendMessage(message); | ||
} | ||
|
||
@Override | ||
public boolean hasPermission(String permission) { | ||
return super.delegate.hasPermission(permission); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
spark-paper/src/main/java/me/lucko/spark/paper/PaperPlatformInfo.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,53 @@ | ||
/* | ||
* 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.paper; | ||
|
||
import io.papermc.paper.ServerBuildInfo; | ||
import me.lucko.spark.common.platform.PlatformInfo; | ||
|
||
public enum PaperPlatformInfo implements PlatformInfo { | ||
INSTANCE; | ||
|
||
@Override | ||
public Type getType() { | ||
return Type.SERVER; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "Paper"; | ||
} | ||
|
||
@Override | ||
public String getBrand() { | ||
return ServerBuildInfo.buildInfo().brandName(); | ||
} | ||
|
||
@Override | ||
public String getVersion() { | ||
return ServerBuildInfo.buildInfo().asString(ServerBuildInfo.StringRepresentation.VERSION_SIMPLE); | ||
} | ||
|
||
@Override | ||
public String getMinecraftVersion() { | ||
return ServerBuildInfo.buildInfo().minecraftVersionId(); | ||
} | ||
} |
Oops, something went wrong.