mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Isolated Velocity
This commit is contained in:
parent
bc301fba60
commit
d44b523acb
32 changed files with 337 additions and 131 deletions
35
bootstrap/velocity/isolated/build.gradle.kts
Normal file
35
bootstrap/velocity/isolated/build.gradle.kts
Normal file
|
@ -0,0 +1,35 @@
|
|||
plugins {
|
||||
java
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(projects.isolation)
|
||||
compileOnlyApi(libs.velocity.api)
|
||||
}
|
||||
|
||||
application {
|
||||
mainClass.set("org.geysermc.geyser.platform.velocity.VelocityMain")
|
||||
}
|
||||
|
||||
tasks {
|
||||
jar {
|
||||
dependsOn(":velocity-base:build", configurations.runtimeClasspath)
|
||||
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
|
||||
|
||||
archiveBaseName = "geyser-${project.name}"
|
||||
archiveVersion = ""
|
||||
archiveClassifier = ""
|
||||
|
||||
val libsDir = project.projects
|
||||
.velocityBase.dependencyProject
|
||||
.layout.buildDirectory.dir("libs")
|
||||
|
||||
from(libsDir) {
|
||||
include("Geyser-Velocity.jar")
|
||||
rename("Geyser-Velocity.jar", "platform-base.jar")
|
||||
into("bundled/")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
package org.geysermc.geyser.platform.velocity;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ListenerBoundEvent;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
||||
import com.velocitypowered.api.network.ListenerType;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import java.nio.file.Path;
|
||||
import org.geysermc.floodgate.isolation.library.LibraryManager;
|
||||
import org.geysermc.floodgate.isolation.loader.PlatformHolder;
|
||||
import org.geysermc.floodgate.isolation.loader.PlatformLoader;
|
||||
|
||||
public final class IsolatedVelocityPlugin {
|
||||
private final PlatformHolder holder;
|
||||
|
||||
@Inject
|
||||
public IsolatedVelocityPlugin(Injector guice, @DataDirectory Path dataDirectory) {
|
||||
try {
|
||||
var libsDirectory = dataDirectory.resolve("libs");
|
||||
|
||||
holder = PlatformLoader.loadDefault(getClass().getClassLoader(), libsDirectory);
|
||||
Injector child = guice.createChildInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(LibraryManager.class).toInstance(holder.manager());
|
||||
}
|
||||
});
|
||||
|
||||
holder.platformInstance(child.getInstance(holder.platformClass()));
|
||||
} catch (Exception exception) {
|
||||
throw new RuntimeException("Failed to load Floodgate", exception);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onInit(ProxyInitializeEvent event) {
|
||||
holder.load();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onShutdown(ProxyShutdownEvent event) {
|
||||
holder.disable();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyBound(ListenerBoundEvent event) {
|
||||
if (event.getListenerType() == ListenerType.MINECRAFT) {
|
||||
// Once listener is bound, do our startup process
|
||||
holder.enable();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.geyser.platform.velocity;
|
||||
|
||||
import org.geysermc.geyser.GeyserMain;
|
||||
|
||||
public class VelocityMain extends GeyserMain {
|
||||
public static void main(String[] args) {
|
||||
new VelocityMain().displayMessage();
|
||||
}
|
||||
|
||||
public String getPluginType() {
|
||||
return "Velocity";
|
||||
}
|
||||
|
||||
public String getPluginFolder() {
|
||||
return "plugins";
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
org.geysermc.geyser.platform.velocity.GeyserVelocityPlatform
|
|
@ -0,0 +1 @@
|
|||
{"id": "${id}", "name": "${name}", "version": "${version}", "description": "${description}", "url": "${url}", "authors": ["${author}"], "main": "org.geysermc.geyser.platform.velocity.IsolatedVelocityPlugin"}
|
Loading…
Add table
Add a link
Reference in a new issue