mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2026-01-04 15:31:48 +00:00
Initial work to switch to Micronaut instead
At the moment local linking is broken, forwarding data is broken and only Velocity has been converted.
This commit is contained in:
@@ -1,221 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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/Floodgate
|
||||
*/
|
||||
|
||||
package org.geysermc.floodgate.ap;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.annotation.processing.AbstractProcessor;
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.lang.model.element.AnnotationMirror;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ElementKind;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
import javax.tools.FileObject;
|
||||
import javax.tools.StandardLocation;
|
||||
|
||||
/*
|
||||
* Copied from Geyser
|
||||
*/
|
||||
public class ClassProcessor extends AbstractProcessor {
|
||||
private final String annotationClassName;
|
||||
|
||||
private Path outputPath;
|
||||
|
||||
private final Set<String> locations = new HashSet<>();
|
||||
|
||||
public ClassProcessor(String annotationClassName) {
|
||||
this.annotationClassName = annotationClassName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void init(ProcessingEnvironment processingEnv) {
|
||||
super.init(processingEnv);
|
||||
|
||||
processingEnv.getMessager().printMessage(
|
||||
Kind.NOTE, "Initializing processor " + annotationClassName
|
||||
);
|
||||
|
||||
String outputFile = processingEnv.getOptions().get("metadataOutputFile");
|
||||
if (outputFile != null && !outputFile.isEmpty()) {
|
||||
outputPath = Paths.get(outputFile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
if (roundEnv.processingOver()) {
|
||||
if (!roundEnv.errorRaised()) {
|
||||
complete();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!contains(annotations, annotationClassName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Element element : roundEnv.getRootElements()) {
|
||||
if (element.getKind() != ElementKind.CLASS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!contains(element.getAnnotationMirrors(), annotationClassName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TypeElement typeElement = (TypeElement) element;
|
||||
locations.add(typeElement.getQualifiedName().toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(Collection<? extends TypeElement> elements, String className) {
|
||||
if (elements.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (TypeElement element : elements) {
|
||||
if (element.getQualifiedName().contentEquals(className)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(List<? extends AnnotationMirror> elements, String className) {
|
||||
if (elements.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AnnotationMirror element : elements) {
|
||||
if (element.getAnnotationType().toString().equals(className)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void complete() {
|
||||
// Read existing annotation list and verify each class still has this annotation
|
||||
try (BufferedReader reader = createReader()) {
|
||||
if (reader != null) {
|
||||
reader.lines().forEach(canonicalName -> {
|
||||
if (!locations.contains(canonicalName)) {
|
||||
|
||||
TypeElement element =
|
||||
processingEnv.getElementUtils().getTypeElement(canonicalName);
|
||||
|
||||
if (element != null && element.getKind() == ElementKind.CLASS &&
|
||||
contains(element.getAnnotationMirrors(), annotationClassName)) {
|
||||
locations.add(canonicalName);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!locations.isEmpty()) {
|
||||
try (BufferedWriter writer = createWriter()) {
|
||||
for (String location : locations) {
|
||||
writer.write(location);
|
||||
writer.newLine();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
processingEnv.getMessager().printMessage(Kind.NOTE,
|
||||
"Did not find any classes annotated with " + annotationClassName
|
||||
);
|
||||
}
|
||||
|
||||
processingEnv.getMessager().printMessage(
|
||||
Kind.NOTE, "Completed processing for " + annotationClassName
|
||||
);
|
||||
}
|
||||
|
||||
private BufferedReader createReader() throws IOException {
|
||||
if (outputPath != null) {
|
||||
processingEnv.getMessager().printMessage(Kind.NOTE,
|
||||
"Reading existing " + annotationClassName + " list from " + outputPath
|
||||
);
|
||||
|
||||
return Files.newBufferedReader(outputPath);
|
||||
}
|
||||
|
||||
FileObject obj = processingEnv.getFiler().getResource(
|
||||
StandardLocation.CLASS_OUTPUT, "", annotationClassName
|
||||
);
|
||||
|
||||
if (obj != null) {
|
||||
processingEnv.getMessager().printMessage(
|
||||
Kind.NOTE,
|
||||
"Reading existing " + annotationClassName + " list from " + obj.toUri()
|
||||
);
|
||||
|
||||
try {
|
||||
return new BufferedReader(obj.openReader(false));
|
||||
} catch (NoSuchFileException ignored) {}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private BufferedWriter createWriter() throws IOException {
|
||||
if (outputPath != null) {
|
||||
processingEnv.getMessager().printMessage(
|
||||
Kind.NOTE, "Writing " + annotationClassName + " to " + outputPath
|
||||
);
|
||||
|
||||
return Files.newBufferedWriter(outputPath);
|
||||
}
|
||||
|
||||
FileObject obj = processingEnv.getFiler().createResource(
|
||||
StandardLocation.CLASS_OUTPUT, "", annotationClassName
|
||||
);
|
||||
|
||||
processingEnv.getMessager().printMessage(
|
||||
Kind.NOTE, "Writing " + annotationClassName + " to " + obj.toUri()
|
||||
);
|
||||
|
||||
return new BufferedWriter(obj.openWriter());
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
org.geysermc.floodgate.ap.AutoBindProcessor
|
||||
@@ -18,6 +18,8 @@ tasks {
|
||||
val sJar: ShadowJar = this
|
||||
|
||||
doFirst {
|
||||
// mergeServiceFiles()
|
||||
|
||||
providedDependencies[project.name]?.forEach { (name, notation) ->
|
||||
sJar.dependencies {
|
||||
println("Excluding $name from ${project.name}")
|
||||
|
||||
@@ -48,13 +48,12 @@ import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
import org.geysermc.floodgate.core.api.ProxyFloodgateApi;
|
||||
import org.geysermc.floodgate.core.config.ProxyFloodgateConfig;
|
||||
import org.geysermc.floodgate.core.register.ListenerRegister;
|
||||
import org.geysermc.floodgate.core.skin.SkinApplier;
|
||||
import org.geysermc.floodgate.core.skin.SkinDataImpl;
|
||||
import org.geysermc.floodgate.core.util.LanguageManager;
|
||||
import org.geysermc.floodgate.core.util.ReflectionUtils;
|
||||
|
||||
@ListenerRegister.Listener
|
||||
@McListener
|
||||
@Singleton
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public final class BungeeListener implements Listener {
|
||||
|
||||
@@ -43,9 +43,8 @@ import org.geysermc.floodgate.core.pluginmessage.PluginMessageChannel;
|
||||
import org.geysermc.floodgate.core.pluginmessage.PluginMessageChannel.Identity;
|
||||
import org.geysermc.floodgate.core.pluginmessage.PluginMessageChannel.Result;
|
||||
import org.geysermc.floodgate.core.pluginmessage.PluginMessageManager;
|
||||
import org.geysermc.floodgate.core.register.ListenerRegister;
|
||||
|
||||
@ListenerRegister.Listener
|
||||
@McListener
|
||||
@Singleton
|
||||
public final class BungeePluginMessageUtils extends PluginMessageUtils implements Listener {
|
||||
@Inject PluginMessageManager pluginMessageManager;
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
plugins {
|
||||
id("floodgate.generate-templates")
|
||||
id("io.micronaut.library") version "3.7.4"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(projects.api)
|
||||
api("org.geysermc.configutils", "configutils", Versions.configUtilsVersion)
|
||||
|
||||
compileOnly(projects.ap)
|
||||
annotationProcessor(projects.ap)
|
||||
|
||||
api("com.google.inject", "guice", Versions.guiceVersion)
|
||||
api("com.nukkitx.fastutil", "fastutil-short-object-maps", Versions.fastutilVersion)
|
||||
api("com.nukkitx.fastutil", "fastutil-int-object-maps", Versions.fastutilVersion)
|
||||
@@ -19,11 +17,9 @@ dependencies {
|
||||
|
||||
api("com.google.guava:guava:31.1-jre")
|
||||
|
||||
api("io.avaje:avaje-inject:8.13")
|
||||
annotationProcessor("io.avaje:avaje-inject-generator:8.13")
|
||||
|
||||
testImplementation("io.avaje:avaje-inject-test:8.13")
|
||||
testAnnotationProcessor("io.avaje:avaje-inject-generator:8.13")
|
||||
annotationProcessor("io.micronaut:micronaut-inject-java")
|
||||
api("io.micronaut", "micronaut-inject-java")
|
||||
api("io.micronaut", "micronaut-context")
|
||||
}
|
||||
|
||||
// present on all platforms
|
||||
|
||||
@@ -25,10 +25,8 @@
|
||||
|
||||
package org.geysermc.floodgate.core;
|
||||
|
||||
import static org.geysermc.floodgate.core.util.Utils.makeModule;
|
||||
|
||||
import io.avaje.inject.BeanScope;
|
||||
import io.avaje.inject.BeanScopeBuilder;
|
||||
import io.micronaut.context.ApplicationContext;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
import org.geysermc.floodgate.api.InstanceHolder;
|
||||
@@ -41,43 +39,51 @@ import org.geysermc.floodgate.api.packet.PacketHandlers;
|
||||
import org.geysermc.floodgate.core.event.EventBus;
|
||||
import org.geysermc.floodgate.core.event.lifecycle.PostEnableEvent;
|
||||
import org.geysermc.floodgate.core.event.lifecycle.ShutdownEvent;
|
||||
import org.geysermc.floodgate.core.util.EagerSingleton;
|
||||
|
||||
public abstract class FloodgatePlatform {
|
||||
private static final UUID KEY = UUID.randomUUID();
|
||||
private static final String PROXY_MODULE = "org.geysermc.floodgate.core.api.ProxyModule";
|
||||
private static final String SERVER_MODULE = "org.geysermc.floodgate.core.api.ServerModule";
|
||||
|
||||
private BeanScope scope;
|
||||
private ApplicationContext context;
|
||||
private PlatformInjector injector;
|
||||
|
||||
protected void onBuildBeanScope(BeanScopeBuilder builder) {
|
||||
}
|
||||
protected void onContextCreated(ApplicationContext context) {}
|
||||
|
||||
public void load() {
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
var scopeBuilder = BeanScope.builder()
|
||||
.bean("isProxy", boolean.class, isProxy())
|
||||
.modules(new CoreModule())
|
||||
// temporary fix for https://github.com/avaje/avaje-inject/issues/295
|
||||
.modules(makeModule(isProxy() ? PROXY_MODULE : SERVER_MODULE));
|
||||
onBuildBeanScope(scopeBuilder);
|
||||
scope = scopeBuilder.build();
|
||||
//noinspection unchecked
|
||||
context = ApplicationContext.builder()
|
||||
.properties(Map.of(
|
||||
"platform.proxy", isProxy()
|
||||
))
|
||||
.eagerInitAnnotated(EagerSingleton.class)
|
||||
.build();
|
||||
onContextCreated(context);
|
||||
context.start();
|
||||
|
||||
injector = scope.get(PlatformInjector.class);
|
||||
// var scopeBuilder = BeanScope.builder()
|
||||
// .bean("isProxy", boolean.class, isProxy())
|
||||
// .modules(new CoreModule())
|
||||
// // temporary fix for https://github.com/avaje/avaje-inject/issues/295
|
||||
// .modules(makeModule(isProxy() ? PROXY_MODULE : SERVER_MODULE));
|
||||
// onBuildBeanScope(scopeBuilder);
|
||||
// scope = scopeBuilder.build();
|
||||
|
||||
injector = context.getBean(PlatformInjector.class);
|
||||
|
||||
InstanceHolder.set(
|
||||
scope.get(FloodgateApi.class),
|
||||
scope.get(PlayerLink.class),
|
||||
scope.get(FloodgateEventBus.class),
|
||||
context.getBean(FloodgateApi.class),
|
||||
context.getBean(PlayerLink.class),
|
||||
context.getBean(FloodgateEventBus.class),
|
||||
injector,
|
||||
scope.get(PacketHandlers.class),
|
||||
scope.get(HandshakeHandlers.class),
|
||||
context.getBean(PacketHandlers.class),
|
||||
context.getBean(HandshakeHandlers.class),
|
||||
KEY
|
||||
);
|
||||
|
||||
long endTime = System.currentTimeMillis();
|
||||
scope.get(FloodgateLogger.class)
|
||||
context.getBean(FloodgateLogger.class)
|
||||
.translatedInfo("floodgate.core.finish", endTime - startTime);
|
||||
}
|
||||
|
||||
@@ -94,11 +100,11 @@ public abstract class FloodgatePlatform {
|
||||
|
||||
// this.guice = guice.createChildInjector(new PostEnableModules(postEnableStageModules()));
|
||||
|
||||
scope.get(EventBus.class).fire(new PostEnableEvent());
|
||||
context.getBean(EventBus.class).fire(new PostEnableEvent());
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
scope.get(EventBus.class).fire(new ShutdownEvent());
|
||||
context.getBean(EventBus.class).fire(new ShutdownEvent());
|
||||
|
||||
if (injector != null && injector.canRemoveInjection()) {
|
||||
try {
|
||||
@@ -108,7 +114,7 @@ public abstract class FloodgatePlatform {
|
||||
}
|
||||
}
|
||||
|
||||
scope.close();
|
||||
context.close();
|
||||
}
|
||||
|
||||
abstract protected boolean isProxy();
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2023 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/Floodgate
|
||||
*/
|
||||
|
||||
package org.geysermc.floodgate.core.addon;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import org.geysermc.floodgate.api.inject.InjectorAddon;
|
||||
import org.geysermc.floodgate.core.inject.CommonPlatformInjector;
|
||||
|
||||
@Singleton
|
||||
public final class AddonManagerAddon implements InjectorAddon {
|
||||
@Inject CommonPlatformInjector injector;
|
||||
|
||||
@Override
|
||||
public void onInject(Channel channel, boolean toServer) {
|
||||
channel.closeFuture().addListener(listener -> {
|
||||
injector.channelClosedCall(channel);
|
||||
injector.removeInjectedClient(channel);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoveInject(Channel channel) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldInject() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public final class DebugAddon implements InjectorAddon {
|
||||
|
||||
@Override
|
||||
public void onInject(Channel channel, boolean toServer) {
|
||||
logger.info("Successfully called onInject. To server? " + toServer);
|
||||
logger.info("Successfully called onInject. To server? {} ({})", toServer, channel.id());
|
||||
|
||||
StateChangeDetector changeDetector = new StateChangeDetector(
|
||||
channel, packetEncoder, packetDecoder, logger
|
||||
@@ -74,6 +74,7 @@ public final class DebugAddon implements InjectorAddon {
|
||||
|
||||
@Override
|
||||
public void onRemoveInject(Channel channel) {
|
||||
logger.info("Removing injection ({})", channel.id());
|
||||
ChannelPipeline pipeline = channel.pipeline();
|
||||
|
||||
Utils.removeHandler(pipeline, "floodgate_debug_out");
|
||||
|
||||
@@ -27,11 +27,11 @@ package org.geysermc.floodgate.core.api;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import org.geysermc.floodgate.core.scope.ProxyScope;
|
||||
import org.geysermc.floodgate.core.scope.ProxyOnly;
|
||||
import org.geysermc.floodgate.crypto.FloodgateCipher;
|
||||
import org.geysermc.floodgate.util.BedrockData;
|
||||
|
||||
@ProxyScope
|
||||
@ProxyOnly
|
||||
public final class ProxyFloodgateApi extends SimpleFloodgateApi {
|
||||
@Inject
|
||||
FloodgateCipher cipher;
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import io.micronaut.context.BeanProvider;
|
||||
import jakarta.inject.Inject;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
@@ -47,12 +48,12 @@ import org.geysermc.floodgate.core.config.FloodgateConfig;
|
||||
import org.geysermc.floodgate.core.pluginmessage.PluginMessageManager;
|
||||
import org.geysermc.floodgate.core.pluginmessage.channel.FormChannel;
|
||||
import org.geysermc.floodgate.core.pluginmessage.channel.TransferChannel;
|
||||
import org.geysermc.floodgate.core.scope.ServerScope;
|
||||
import org.geysermc.floodgate.core.scope.ServerOnly;
|
||||
import org.geysermc.floodgate.core.util.Constants;
|
||||
import org.geysermc.floodgate.core.util.HttpClient;
|
||||
import org.geysermc.floodgate.core.util.Utils;
|
||||
|
||||
@ServerScope
|
||||
@ServerOnly
|
||||
public class SimpleFloodgateApi implements FloodgateApi {
|
||||
private final Map<UUID, FloodgatePlayer> players = new ConcurrentHashMap<>();
|
||||
private final Cache<UUID, FloodgatePlayer> pendingRemove =
|
||||
@@ -60,7 +61,7 @@ public class SimpleFloodgateApi implements FloodgateApi {
|
||||
.expireAfterWrite(20, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
@Inject PluginMessageManager pluginMessageManager;
|
||||
@Inject BeanProvider<PluginMessageManager> pluginMessageManager;
|
||||
@Inject FloodgateConfig config;
|
||||
@Inject HttpClient httpClient;
|
||||
@Inject FloodgateLogger logger;
|
||||
@@ -120,7 +121,7 @@ public class SimpleFloodgateApi implements FloodgateApi {
|
||||
|
||||
@Override
|
||||
public boolean sendForm(UUID uuid, Form form) {
|
||||
return pluginMessageManager.getChannel(FormChannel.class).sendForm(uuid, form);
|
||||
return pluginMessageManager.get().getChannel(FormChannel.class).sendForm(uuid, form);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,7 +141,7 @@ public class SimpleFloodgateApi implements FloodgateApi {
|
||||
|
||||
@Override
|
||||
public boolean transferPlayer(UUID uuid, String address, int port) {
|
||||
return pluginMessageManager
|
||||
return pluginMessageManager.get()
|
||||
.getChannel(TransferChannel.class)
|
||||
.sendTransfer(uuid, address, port);
|
||||
}
|
||||
@@ -185,7 +186,7 @@ public class SimpleFloodgateApi implements FloodgateApi {
|
||||
logger.warn("A plugin is trying to access an unsafe part of the Floodgate api!" +
|
||||
" The use of this api can result in client crashes if used incorrectly." +
|
||||
" Caller: " + callerClass);
|
||||
return new UnsafeFloodgateApi(pluginMessageManager);
|
||||
return new UnsafeFloodgateApi(pluginMessageManager.get());
|
||||
}
|
||||
|
||||
public FloodgatePlayer addPlayer(FloodgatePlayer player) {
|
||||
|
||||
@@ -30,7 +30,7 @@ import cloud.commandframework.Command;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.arguments.standard.StringArgument;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import io.avaje.inject.Secondary;
|
||||
import io.micronaut.context.annotation.Secondary;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -43,8 +43,7 @@ import org.geysermc.floodgate.core.util.HttpClient.HttpResponse;
|
||||
import org.geysermc.floodgate.core.util.Utils;
|
||||
|
||||
final class FirewallCheckSubcommand extends FloodgateSubCommand {
|
||||
@Inject
|
||||
private HttpClient httpClient;
|
||||
@Inject HttpClient httpProvider;
|
||||
|
||||
@Override
|
||||
public Class<?> parent() {
|
||||
@@ -84,7 +83,7 @@ final class FirewallCheckSubcommand extends FloodgateSubCommand {
|
||||
sender, "global api",
|
||||
() -> {
|
||||
HttpResponse<JsonElement> response =
|
||||
httpClient.get(Constants.HEALTH_URL, JsonElement.class);
|
||||
httpProvider.get(Constants.HEALTH_URL, JsonElement.class);
|
||||
|
||||
if (!response.isCodeOk()) {
|
||||
throw new IllegalStateException(String.format(
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
|
||||
package org.geysermc.floodgate.core.config;
|
||||
|
||||
import io.avaje.inject.Bean;
|
||||
import io.micronaut.context.annotation.Bean;
|
||||
import io.micronaut.context.annotation.Factory;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Named;
|
||||
import jakarta.inject.Singleton;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.Key;
|
||||
@@ -38,12 +38,12 @@ import org.geysermc.configutils.ConfigUtilities;
|
||||
import org.geysermc.configutils.file.codec.PathFileCodec;
|
||||
import org.geysermc.configutils.file.template.ResourceTemplateReader;
|
||||
import org.geysermc.configutils.updater.change.Changes;
|
||||
import org.geysermc.floodgate.core.scope.ProxyScope;
|
||||
import org.geysermc.floodgate.core.scope.ServerScope;
|
||||
import org.geysermc.floodgate.core.scope.ProxyOnly;
|
||||
import org.geysermc.floodgate.core.scope.ServerOnly;
|
||||
import org.geysermc.floodgate.crypto.FloodgateCipher;
|
||||
import org.geysermc.floodgate.crypto.KeyProducer;
|
||||
|
||||
@Singleton
|
||||
@Factory
|
||||
@Getter
|
||||
public final class ConfigLoader {
|
||||
private final Path dataDirectory;
|
||||
@@ -62,13 +62,13 @@ public final class ConfigLoader {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ServerScope
|
||||
@ServerOnly
|
||||
FloodgateConfig config() {
|
||||
return load(FloodgateConfig.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ProxyScope
|
||||
@ProxyOnly
|
||||
ProxyFloodgateConfig proxyConfig() {
|
||||
return load(ProxyFloodgateConfig.class);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
package org.geysermc.floodgate.core.database.config;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import io.micronaut.context.annotation.Requires;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Named;
|
||||
import java.io.BufferedReader;
|
||||
@@ -37,6 +38,7 @@ import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor;
|
||||
import org.yaml.snakeyaml.introspector.BeanAccess;
|
||||
|
||||
@Requires(env = "no")
|
||||
public class DatabaseConfigLoader {
|
||||
private Yaml yaml;
|
||||
|
||||
@@ -45,15 +47,15 @@ public class DatabaseConfigLoader {
|
||||
Path dataDirectory;
|
||||
|
||||
@Inject
|
||||
@Named("databaseName")
|
||||
@Named("database.name")
|
||||
String name;
|
||||
|
||||
@Inject
|
||||
@Named("databaseClassLoader")
|
||||
@Named("database.classloader")
|
||||
ClassLoader classLoader;
|
||||
|
||||
@Inject
|
||||
@Named("databaseInitData")
|
||||
@Named("database.init.data")
|
||||
JsonObject initData;
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -25,9 +25,10 @@
|
||||
|
||||
package org.geysermc.floodgate.core.event;
|
||||
|
||||
import io.avaje.inject.BeanScope;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import io.micronaut.context.ApplicationContext;
|
||||
import io.micronaut.core.annotation.AnnotationMetadata;
|
||||
import io.micronaut.inject.qualifiers.Qualifiers;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -38,19 +39,24 @@ import org.geysermc.event.subscribe.Subscribe;
|
||||
import org.geysermc.event.subscribe.Subscriber;
|
||||
import org.geysermc.floodgate.api.event.FloodgateEventBus;
|
||||
import org.geysermc.floodgate.api.event.FloodgateSubscriber;
|
||||
import org.geysermc.floodgate.core.util.EagerSingleton;
|
||||
|
||||
@Singleton
|
||||
@EagerSingleton
|
||||
@SuppressWarnings("unchecked")
|
||||
public final class EventBus extends EventBusImpl<Object, FloodgateSubscriber<?>>
|
||||
implements FloodgateEventBus {
|
||||
@Inject
|
||||
public void registerListeners(BeanScope scope) {
|
||||
// https://github.com/avaje/avaje-inject/issues/289
|
||||
for (Object listener : scope.listByAnnotation(Listener.class)) {
|
||||
register(listener);
|
||||
}
|
||||
}
|
||||
|
||||
// @Inject
|
||||
// Set<@Listener Object> detectedListeners;
|
||||
|
||||
@PostConstruct
|
||||
void registerListeners(ApplicationContext context) {
|
||||
// https://github.com/micronaut-projects/micronaut-core/issues/8881
|
||||
context.getBeansOfType(
|
||||
Object.class,
|
||||
Qualifiers.byAnnotation(AnnotationMetadata.EMPTY_METADATA, Listener.class)
|
||||
).forEach(this::register);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <H, T, B extends Subscriber<T>> B makeSubscription(
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
package org.geysermc.floodgate.core.inject;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.inject.Inject;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -41,9 +42,11 @@ public abstract class CommonPlatformInjector implements PlatformInjector {
|
||||
|
||||
private final Map<Class<?>, InjectorAddon> addons = new HashMap<>();
|
||||
|
||||
@Inject
|
||||
public void registerAddons(Set<InjectorAddon> addons) {
|
||||
addons.forEach(this::addAddon);
|
||||
@Inject Set<InjectorAddon> detectedAddons;
|
||||
|
||||
@PostConstruct
|
||||
public void registerAddons() {
|
||||
detectedAddons.forEach(this::addAddon);
|
||||
}
|
||||
|
||||
protected boolean addInjectedClient(Channel channel) {
|
||||
@@ -78,6 +81,12 @@ public abstract class CommonPlatformInjector implements PlatformInjector {
|
||||
* connecting to the proxy or false when the platform isn't a proxy
|
||||
*/
|
||||
public void injectAddonsCall(Channel channel, boolean proxyToServer) {
|
||||
// don't forget to remove the addons when the channel closes
|
||||
channel.closeFuture().addListener(listener -> {
|
||||
channelClosedCall(channel);
|
||||
removeInjectedClient(channel);
|
||||
});
|
||||
|
||||
for (InjectorAddon addon : addons.values()) {
|
||||
if (addon.shouldInject()) {
|
||||
addon.onInject(channel, proxyToServer);
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
package org.geysermc.floodgate.core.link;
|
||||
|
||||
import io.avaje.inject.BeanScope;
|
||||
import io.micronaut.context.ApplicationContext;
|
||||
import io.micronaut.context.annotation.Requires;
|
||||
import jakarta.annotation.PreDestroy;
|
||||
import jakarta.inject.Inject;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
@@ -33,8 +35,6 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.event.Listener;
|
||||
import org.geysermc.event.subscribe.Subscribe;
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
import org.geysermc.floodgate.api.link.LinkRequest;
|
||||
import org.geysermc.floodgate.api.link.PlayerLink;
|
||||
@@ -42,9 +42,9 @@ import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
||||
import org.geysermc.floodgate.core.config.FloodgateConfig;
|
||||
import org.geysermc.floodgate.core.database.config.DatabaseConfig;
|
||||
import org.geysermc.floodgate.core.database.config.DatabaseConfigLoader;
|
||||
import org.geysermc.floodgate.core.event.lifecycle.ShutdownEvent;
|
||||
|
||||
@Listener
|
||||
//@Listener
|
||||
@Requires(env = "no")
|
||||
public abstract class CommonPlayerLink implements PlayerLink {
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
private final ExecutorService executorService = Executors.newCachedThreadPool();
|
||||
@@ -62,7 +62,7 @@ public abstract class CommonPlayerLink implements PlayerLink {
|
||||
FloodgateApi api;
|
||||
|
||||
@Inject
|
||||
BeanScope scope;
|
||||
ApplicationContext context;
|
||||
|
||||
@Inject
|
||||
void init(FloodgateConfig config) {
|
||||
@@ -92,21 +92,17 @@ public abstract class CommonPlayerLink implements PlayerLink {
|
||||
public <T extends DatabaseConfig> T getConfig(Class<T> configClass) {
|
||||
// this method is not intended to be used more than once. It'll make a new instance of
|
||||
// DatabaseConfigLoader and DatabaseConfig every time you run this method.
|
||||
return scope.get(DatabaseConfigLoader.class).loadAs(configClass);
|
||||
return context.getBean(DatabaseConfigLoader.class).loadAs(configClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return scope.get(String.class, "databaseName");
|
||||
return context.get("database.name", String.class).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreDestroy
|
||||
public void stop() {
|
||||
executorService.shutdown();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onShutdown(ShutdownEvent ignored) {
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,10 @@ import static java.util.Objects.requireNonNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import io.avaje.inject.Bean;
|
||||
import io.avaje.inject.BeanScope;
|
||||
import io.avaje.inject.Factory;
|
||||
import io.micronaut.context.ApplicationContext;
|
||||
import io.micronaut.context.annotation.Bean;
|
||||
import io.micronaut.context.annotation.Factory;
|
||||
import jakarta.annotation.PreDestroy;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Named;
|
||||
import jakarta.inject.Singleton;
|
||||
@@ -46,12 +47,10 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import org.geysermc.event.Listener;
|
||||
import org.geysermc.event.subscribe.Subscribe;
|
||||
import org.geysermc.floodgate.api.link.PlayerLink;
|
||||
import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
||||
import org.geysermc.floodgate.core.config.FloodgateConfig;
|
||||
import org.geysermc.floodgate.core.config.FloodgateConfig.PlayerLinkConfig;
|
||||
import org.geysermc.floodgate.core.event.lifecycle.ShutdownEvent;
|
||||
import org.geysermc.floodgate.core.util.Constants;
|
||||
import org.geysermc.floodgate.core.util.Utils;
|
||||
|
||||
@@ -59,15 +58,15 @@ import org.geysermc.floodgate.core.util.Utils;
|
||||
@Factory
|
||||
@SuppressWarnings("unchecked")
|
||||
public final class PlayerLinkHolder {
|
||||
private final BeanScope currentScope;
|
||||
private final ApplicationContext currentContext;
|
||||
|
||||
private URLClassLoader classLoader;
|
||||
private BeanScope childScope;
|
||||
private ApplicationContext childContext;
|
||||
private PlayerLink instance;
|
||||
|
||||
@Inject
|
||||
PlayerLinkHolder(BeanScope scope) {
|
||||
this.currentScope = scope;
|
||||
PlayerLinkHolder(ApplicationContext context) {
|
||||
this.currentContext = context;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -104,7 +103,7 @@ public final class PlayerLinkHolder {
|
||||
// been found, or when global linking is enabled and own player linking is disabled.
|
||||
if (linkConfig.isEnableGlobalLinking() &&
|
||||
(files.isEmpty() || !linkConfig.isEnableOwnLinking())) {
|
||||
return currentScope.get(GlobalPlayerLinking.class);
|
||||
return currentContext.getBean(GlobalPlayerLinking.class);
|
||||
}
|
||||
|
||||
if (files.isEmpty()) {
|
||||
@@ -178,18 +177,26 @@ public final class PlayerLinkHolder {
|
||||
|
||||
init = false;
|
||||
|
||||
childScope = BeanScope.builder()
|
||||
.parent(currentScope)
|
||||
.bean("databaseName", String.class, databaseName)
|
||||
.bean("databaseClassLoader", ClassLoader.class, classLoader)
|
||||
.bean("databaseInitData", JsonObject.class, dbInitConfig)
|
||||
.build();
|
||||
// childContext = ApplicationContext.builder()
|
||||
// .singletons()
|
||||
// .classLoader(classLoader)
|
||||
// .packages()
|
||||
// .properties(Map.of(
|
||||
// "database.name", databaseName,
|
||||
// "database.classloader", classLoader,
|
||||
// "database.init.data", dbInitConfig
|
||||
// ))
|
||||
// .build();
|
||||
//
|
||||
// childContext.registerBeanDefinition(RuntimeBeanDefinition.builder(null).)
|
||||
//
|
||||
// childContext.environment(helo -> helo.);
|
||||
|
||||
instance = childScope.get(mainClass);
|
||||
instance = childContext.getBean(mainClass);
|
||||
|
||||
// we use our own internal PlayerLinking when global linking is enabled
|
||||
if (linkConfig.isEnableGlobalLinking()) {
|
||||
GlobalPlayerLinking linking = childScope.get(GlobalPlayerLinking.class);
|
||||
GlobalPlayerLinking linking = childContext.getBean(GlobalPlayerLinking.class);
|
||||
linking.setDatabaseImpl(instance);
|
||||
linking.load();
|
||||
return linking;
|
||||
@@ -213,10 +220,10 @@ public final class PlayerLinkHolder {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onShutdown(ShutdownEvent ignored) throws Exception {
|
||||
@PreDestroy
|
||||
void close() throws Exception {
|
||||
instance.stop();
|
||||
childScope.close();
|
||||
childContext.close();
|
||||
classLoader.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
||||
* Copyright (c) 2019-2023 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
|
||||
@@ -23,16 +23,17 @@
|
||||
* @link https://github.com/GeyserMC/Floodgate
|
||||
*/
|
||||
|
||||
package org.geysermc.floodgate.ap;
|
||||
package org.geysermc.floodgate.core.listener;
|
||||
|
||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
|
||||
@SupportedAnnotationTypes("*")
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
||||
public class AutoBindProcessor extends ClassProcessor {
|
||||
public AutoBindProcessor() {
|
||||
super("org.geysermc.floodgate.util.AutoBind");
|
||||
}
|
||||
}
|
||||
import jakarta.inject.Qualifier;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Qualifier
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE_USE)
|
||||
public @interface McListener {
|
||||
}
|
||||
@@ -23,33 +23,28 @@
|
||||
* @link https://github.com/GeyserMC/Floodgate
|
||||
*/
|
||||
|
||||
package org.geysermc.floodgate.core.register;
|
||||
package org.geysermc.floodgate.core.listener;
|
||||
|
||||
import io.micronaut.context.ApplicationContext;
|
||||
import io.micronaut.core.annotation.AnnotationMetadata;
|
||||
import io.micronaut.inject.qualifiers.Qualifiers;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Qualifier;
|
||||
import jakarta.inject.Singleton;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
||||
import org.geysermc.floodgate.core.platform.listener.ListenerRegistration;
|
||||
import org.geysermc.floodgate.core.util.EagerSingleton;
|
||||
|
||||
@Singleton
|
||||
@EagerSingleton
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public final class ListenerRegister {
|
||||
@Inject
|
||||
ListenerRegistration registration;
|
||||
public final class McListenerRegister {
|
||||
@Inject ListenerRegistration registration;
|
||||
@Inject FloodgateLogger logger;
|
||||
|
||||
// @Inject
|
||||
// public void registerListeners(Set<@Listener Object> foundListeners) {
|
||||
// for (Object listener : foundListeners) {
|
||||
// registration.register(listener);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Qualifier
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE_USE)
|
||||
public @interface Listener {
|
||||
@PostConstruct
|
||||
public void registerListeners(ApplicationContext context) {
|
||||
context.getBeansOfType(
|
||||
Object.class,
|
||||
Qualifiers.byAnnotation(AnnotationMetadata.EMPTY_METADATA, McListener.class)
|
||||
).forEach(registration::register);
|
||||
}
|
||||
}
|
||||
@@ -27,10 +27,10 @@ package org.geysermc.floodgate.core.logger;
|
||||
|
||||
import static org.geysermc.floodgate.core.util.MessageFormatter.format;
|
||||
|
||||
import io.avaje.inject.Secondary;
|
||||
import io.micronaut.context.annotation.Requires;
|
||||
import io.micronaut.context.annotation.Secondary;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Named;
|
||||
import jakarta.inject.Singleton;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
||||
@@ -38,7 +38,7 @@ import org.geysermc.floodgate.core.config.FloodgateConfig;
|
||||
import org.geysermc.floodgate.core.util.LanguageManager;
|
||||
|
||||
@Secondary
|
||||
@Singleton
|
||||
@Requires(property = "platform.logger", value = "java.util")
|
||||
public final class JavaUtilFloodgateLogger implements FloodgateLogger {
|
||||
@Inject
|
||||
@Named("logger")
|
||||
|
||||
@@ -25,21 +25,19 @@
|
||||
|
||||
package org.geysermc.floodgate.core.module;
|
||||
|
||||
import io.avaje.inject.Bean;
|
||||
import io.avaje.inject.Factory;
|
||||
import io.micronaut.context.annotation.Bean;
|
||||
import io.micronaut.context.annotation.Factory;
|
||||
import io.netty.util.AttributeKey;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Named;
|
||||
import jakarta.inject.Singleton;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.geysermc.event.Listener;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
import org.geysermc.floodgate.core.event.EventBus;
|
||||
import org.geysermc.floodgate.core.event.lifecycle.ShutdownEvent;
|
||||
import org.geysermc.floodgate.core.util.Constants;
|
||||
import org.geysermc.floodgate.crypto.AesCipher;
|
||||
import org.geysermc.floodgate.crypto.AesKeyProducer;
|
||||
@@ -50,23 +48,18 @@ import org.geysermc.floodgate.crypto.KeyProducer;
|
||||
@Factory
|
||||
@Listener
|
||||
public class CommonModule {
|
||||
@Bean
|
||||
@Bean(preDestroy = "shutdown")
|
||||
@Singleton
|
||||
@Named("commonPool")
|
||||
public ExecutorService commonPool() {
|
||||
return new ThreadPoolExecutor(0, 20, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void registerShutdown(
|
||||
EventBus eventBus,
|
||||
@Named("commonPool") ExecutorService commonPool,
|
||||
@Named("commonScheduledPool") ScheduledExecutorService commonScheduledPool
|
||||
) {
|
||||
eventBus.subscribe(ShutdownEvent.class, ignored -> {
|
||||
commonPool.shutdown();
|
||||
commonScheduledPool.shutdown();
|
||||
});
|
||||
@Bean(preDestroy = "shutdown")
|
||||
@Singleton
|
||||
@Named("commonScheduledPool")
|
||||
public ScheduledExecutorService commonScheduledPool() {
|
||||
return Executors.newSingleThreadScheduledExecutor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -91,7 +84,7 @@ public class CommonModule {
|
||||
@Bean
|
||||
@Singleton
|
||||
@Named("buildNumber")
|
||||
public Integer buildNumber() {
|
||||
public int buildNumber() {
|
||||
return Constants.BUILD_NUMBER;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ package org.geysermc.floodgate.core.news;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import io.avaje.inject.PostConstruct;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Named;
|
||||
import jakarta.inject.Singleton;
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2023 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/Floodgate
|
||||
*/
|
||||
|
||||
@InjectModule(requires = {
|
||||
PlatformUtils.class,
|
||||
String.class,
|
||||
// provided by either the Server- or ProxyModule
|
||||
FloodgateApi.class,
|
||||
FloodgateConfig.class,
|
||||
Path.class
|
||||
}, provides = {
|
||||
LanguageManager.class,
|
||||
})
|
||||
package org.geysermc.floodgate.core;
|
||||
|
||||
import io.avaje.inject.InjectModule;
|
||||
import java.nio.file.Path;
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
import org.geysermc.floodgate.core.config.FloodgateConfig;
|
||||
import org.geysermc.floodgate.core.platform.util.PlatformUtils;
|
||||
import org.geysermc.floodgate.core.util.LanguageManager;
|
||||
@@ -25,14 +25,15 @@
|
||||
|
||||
package org.geysermc.floodgate.core.platform.command;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.inject.Inject;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class SubCommands {
|
||||
Set<FloodgateSubCommand> subCommands;
|
||||
@Inject Set<FloodgateSubCommand> subCommands;
|
||||
|
||||
@Inject
|
||||
public void setup(Set<FloodgateSubCommand> subCommands) {
|
||||
@PostConstruct
|
||||
public void setup() {
|
||||
subCommands.removeIf(subCommand -> !subCommand.parent().isAssignableFrom(this.getClass()));
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ public class PluginMessageManager {
|
||||
@Inject PluginMessageRegistration registration;
|
||||
|
||||
@Inject
|
||||
public void addChannels(Set<PluginMessageChannel> channels) {
|
||||
public void registerChannels(Set<PluginMessageChannel> channels) {
|
||||
channels.forEach(channel -> System.out.println(channel.getClass().getName()));
|
||||
if (!classInstanceMap.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -27,18 +27,18 @@ package org.geysermc.floodgate.core.register;
|
||||
|
||||
import cloud.commandframework.CommandManager;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import java.util.Set;
|
||||
import org.geysermc.floodgate.core.config.FloodgateConfig;
|
||||
import org.geysermc.floodgate.core.platform.command.FloodgateCommand;
|
||||
import org.geysermc.floodgate.core.player.UserAudience;
|
||||
import org.geysermc.floodgate.core.util.EagerSingleton;
|
||||
|
||||
/**
|
||||
* This class is responsible for registering commands to the command register of the platform that
|
||||
* is currently in use. So that the commands only have to be written once (in the common module) and
|
||||
* can be used across all platforms without the need of adding platform specific commands.
|
||||
*/
|
||||
@Singleton
|
||||
@EagerSingleton
|
||||
public final class CommandRegister {
|
||||
@Inject CommandManager<UserAudience> commandManager;
|
||||
@Inject FloodgateConfig config;
|
||||
|
||||
@@ -25,14 +25,14 @@
|
||||
|
||||
package org.geysermc.floodgate.core.scope;
|
||||
|
||||
import io.avaje.inject.InjectModule;
|
||||
import jakarta.inject.Scope;
|
||||
import io.micronaut.context.annotation.Requires;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import org.geysermc.floodgate.core.config.FloodgateConfig;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Scope
|
||||
@InjectModule(provides = FloodgateConfig.class)
|
||||
public @interface ServerScope {
|
||||
@Target({ElementType.TYPE_USE})
|
||||
@Requires(property = "platform.proxy", value = "true")
|
||||
public @interface ProxyOnly {
|
||||
}
|
||||
@@ -23,16 +23,16 @@
|
||||
* @link https://github.com/GeyserMC/Floodgate
|
||||
*/
|
||||
|
||||
package org.geysermc.floodgate.core.util;
|
||||
package org.geysermc.floodgate.core.scope;
|
||||
|
||||
import io.micronaut.context.annotation.Requires;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Automatically binds an instance of itself as an eager singleton during the post-initialise stage
|
||||
* of the FloodgatePlatform. Add the annotation to a class, and it should automatically create an
|
||||
* instance and inject it for you.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface AutoBind {
|
||||
@Target({ElementType.TYPE_USE})
|
||||
@Requires(property = "platform.proxy", value = "false")
|
||||
public @interface ServerOnly {
|
||||
}
|
||||
@@ -28,13 +28,12 @@ package org.geysermc.floodgate.core.skin;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import jakarta.annotation.PreDestroy;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import org.geysermc.event.Listener;
|
||||
import org.geysermc.event.subscribe.Subscribe;
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
||||
import org.geysermc.floodgate.core.event.lifecycle.ShutdownEvent;
|
||||
|
||||
@Listener
|
||||
@Singleton
|
||||
@@ -59,15 +58,11 @@ public final class SkinUploadManager {
|
||||
connections.remove(id, socket);
|
||||
}
|
||||
|
||||
public void closeAllSockets() {
|
||||
@PreDestroy
|
||||
void closeAllSockets() {
|
||||
for (SkinUploadSocket socket : connections.values()) {
|
||||
socket.close();
|
||||
}
|
||||
connections.clear();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onShutdown(ShutdownEvent ignored) {
|
||||
closeAllSockets();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,16 @@
|
||||
* @link https://github.com/GeyserMC/Floodgate
|
||||
*/
|
||||
|
||||
package org.geysermc.floodgate.core.scope;
|
||||
package org.geysermc.floodgate.core.util;
|
||||
|
||||
import jakarta.inject.Scope;
|
||||
import jakarta.inject.Singleton;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Instead of a normal Singleton this is an
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Scope
|
||||
public @interface ProxyScope {
|
||||
@Singleton
|
||||
public @interface EagerSingleton {
|
||||
}
|
||||
@@ -26,6 +26,8 @@
|
||||
package org.geysermc.floodgate.core.util;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import io.micronaut.context.BeanProvider;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import java.net.URL;
|
||||
@@ -45,8 +47,8 @@ import org.geysermc.floodgate.core.config.FloodgateConfig;
|
||||
public final class LanguageManager {
|
||||
private final Map<String, Properties> localeMappings = new HashMap<>();
|
||||
|
||||
@Inject FloodgateConfig config;
|
||||
@Inject FloodgateLogger logger;
|
||||
@Inject BeanProvider<FloodgateConfig> config;
|
||||
@Inject BeanProvider<FloodgateLogger> logger;
|
||||
|
||||
/**
|
||||
* The locale used in console and as a fallback
|
||||
@@ -71,13 +73,15 @@ public final class LanguageManager {
|
||||
/**
|
||||
* Tries to load the log's locale file once a string has been requested
|
||||
*/
|
||||
@Inject
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
FloodgateLogger logger = this.logger.get();
|
||||
|
||||
if (!loadLocale("en_US")) {// Fallback
|
||||
logger.error("Failed to load the fallback language. This will likely cause errors!");
|
||||
}
|
||||
|
||||
defaultLocale = formatLocale(config.getDefaultLocale());
|
||||
defaultLocale = formatLocale(config.get().getDefaultLocale());
|
||||
|
||||
if (isValidLanguage(defaultLocale)) {
|
||||
if (loadLocale(defaultLocale)) {
|
||||
@@ -121,7 +125,7 @@ public final class LanguageManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
logger.warn("Missing locale file: " + formatLocale);
|
||||
logger.get().warn("Missing locale file: " + formatLocale);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -182,7 +186,7 @@ public final class LanguageManager {
|
||||
.getResource("/languages/texts/" + locale + ".properties");
|
||||
|
||||
if (languageFile == null) {
|
||||
logger.warn(locale + " is not a supported Floodgate language.");
|
||||
logger.get().warn(locale + " is not a supported Floodgate language.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
package org.geysermc.floodgate.core.util;
|
||||
|
||||
import io.avaje.inject.PostConstruct;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Named;
|
||||
import jakarta.inject.Singleton;
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
|
||||
package org.geysermc.floodgate.core.util;
|
||||
|
||||
import jakarta.annotation.Nullable;
|
||||
import java.lang.reflect.AccessibleObject;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
package org.geysermc.floodgate.core.util;
|
||||
|
||||
import io.avaje.inject.spi.Module;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
@@ -176,12 +175,4 @@ public class Utils {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Module makeModule(String moduleClassName) {
|
||||
try {
|
||||
return (Module) Class.forName(moduleClassName).getDeclaredConstructor().newInstance();
|
||||
} catch (Throwable throwable) {
|
||||
throw new RuntimeException(throwable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,5 @@ org.gradle.configureondemand=true
|
||||
org.gradle.caching=true
|
||||
org.gradle.parallel=true
|
||||
|
||||
version=2.2.2-SNAPSHOT
|
||||
version=2.2.2-SNAPSHOT
|
||||
micronautVersion=3.8.6
|
||||
@@ -4,7 +4,7 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
// mavenLocal()
|
||||
mavenLocal()
|
||||
|
||||
// Geyser, Cumulus etc.
|
||||
maven("https://repo.opencollab.dev/maven-releases") {
|
||||
@@ -65,7 +65,6 @@ pluginManagement {
|
||||
rootProject.name = "floodgate-parent"
|
||||
|
||||
include(":api")
|
||||
include(":ap")
|
||||
include(":core")
|
||||
include(":bungee")
|
||||
include(":spigot")
|
||||
|
||||
@@ -4,12 +4,9 @@ var guavaVersion = "25.1-jre"
|
||||
|
||||
dependencies {
|
||||
api(projects.core)
|
||||
annotationProcessor(projects.core)
|
||||
|
||||
implementation("cloud.commandframework", "cloud-velocity", Versions.cloudVersion)
|
||||
|
||||
annotationProcessor("io.avaje:avaje-inject-generator:8.13")
|
||||
|
||||
testImplementation("io.avaje:avaje-inject-test:8.13")
|
||||
testAnnotationProcessor("io.avaje:avaje-inject-generator:8.13")
|
||||
}
|
||||
|
||||
relocate("cloud.commandframework")
|
||||
|
||||
@@ -26,9 +26,12 @@
|
||||
package org.geysermc.floodgate.velocity;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.EventManager;
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import io.avaje.inject.BeanScopeBuilder;
|
||||
import io.micronaut.context.ApplicationContext;
|
||||
import io.micronaut.inject.qualifiers.Qualifiers;
|
||||
import java.nio.file.Path;
|
||||
import org.geysermc.floodgate.core.FloodgatePlatform;
|
||||
import org.geysermc.floodgate.core.util.ReflectionUtils;
|
||||
@@ -36,22 +39,24 @@ import org.slf4j.Logger;
|
||||
|
||||
public class VelocityPlatform extends FloodgatePlatform {
|
||||
@Inject
|
||||
private @DataDirectory Path dataDirectory;
|
||||
@Inject
|
||||
private ProxyServer proxyServer;
|
||||
@Inject
|
||||
private Logger logger;
|
||||
@DataDirectory
|
||||
Path dataDirectory;
|
||||
@Inject ProxyServer proxyServer;
|
||||
@Inject EventManager eventManager;
|
||||
@Inject PluginContainer container;
|
||||
@Inject Logger logger;
|
||||
|
||||
public VelocityPlatform() {
|
||||
ReflectionUtils.setPrefix("com.velocitypowered.proxy");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBuildBeanScope(BeanScopeBuilder builder) {
|
||||
builder.bean(ProxyServer.class, proxyServer)
|
||||
.bean("dataDirectory", Path.class, dataDirectory)
|
||||
.bean(Logger.class, logger)
|
||||
.modules(new VelocityModule());
|
||||
protected void onContextCreated(ApplicationContext context) {
|
||||
context.registerSingleton(proxyServer)
|
||||
.registerSingleton(container)
|
||||
.registerSingleton(eventManager)
|
||||
.registerSingleton(Path.class, dataDirectory, Qualifiers.byName("dataDirectory"))
|
||||
.registerSingleton(logger);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -85,7 +85,9 @@ public final class VelocityDataAddon implements InjectorAddon {
|
||||
// The handler is already added so we should add our handler before it
|
||||
channel.pipeline().addBefore(
|
||||
packetHandler, "floodgate_data_handler",
|
||||
new VelocityProxyDataHandler(config, handshakeHandler, blocker, kickMessageAttribute, logger)
|
||||
new VelocityProxyDataHandler(
|
||||
config, handshakeHandler, blocker, kickMessageAttribute, logger
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,10 +57,10 @@ import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
import org.geysermc.floodgate.core.api.ProxyFloodgateApi;
|
||||
import org.geysermc.floodgate.core.config.ProxyFloodgateConfig;
|
||||
import org.geysermc.floodgate.core.register.ListenerRegister;
|
||||
import org.geysermc.floodgate.core.listener.McListener;
|
||||
import org.geysermc.floodgate.core.util.LanguageManager;
|
||||
|
||||
@ListenerRegister.Listener
|
||||
@McListener
|
||||
@Singleton
|
||||
public final class VelocityListener {
|
||||
private static final Field INITIAL_MINECRAFT_CONNECTION;
|
||||
|
||||
@@ -26,18 +26,18 @@
|
||||
package org.geysermc.floodgate.velocity.listener;
|
||||
|
||||
import com.velocitypowered.api.event.EventManager;
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import org.geysermc.floodgate.core.platform.listener.ListenerRegistration;
|
||||
import org.geysermc.floodgate.velocity.VelocityPlugin;
|
||||
|
||||
@Singleton
|
||||
public final class VelocityListenerRegistration implements ListenerRegistration<Object> {
|
||||
@Inject EventManager eventManager;
|
||||
@Inject VelocityPlugin plugin;
|
||||
@Inject PluginContainer pluginContainer;
|
||||
|
||||
@Override
|
||||
public void register(Object listener) {
|
||||
eventManager.register(plugin, listener);
|
||||
eventManager.register(pluginContainer, listener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ package org.geysermc.floodgate.velocity.logger;
|
||||
|
||||
import static org.geysermc.floodgate.core.util.MessageFormatter.format;
|
||||
|
||||
import io.micronaut.context.BeanProvider;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import org.apache.logging.log4j.Level;
|
||||
@@ -38,12 +39,11 @@ import org.slf4j.Logger;
|
||||
|
||||
@Singleton
|
||||
public final class Slf4jFloodgateLogger implements FloodgateLogger {
|
||||
private LanguageManager languageManager;
|
||||
@Inject BeanProvider<LanguageManager> languageManager;
|
||||
@Inject Logger logger;
|
||||
|
||||
@Inject
|
||||
void init(LanguageManager languageManager, FloodgateConfig config) {
|
||||
this.languageManager = languageManager;
|
||||
void init(FloodgateConfig config) {
|
||||
if (config.isDebug() && !logger.isDebugEnabled()) {
|
||||
Configurator.setLevel(logger.getName(), Level.DEBUG);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public final class Slf4jFloodgateLogger implements FloodgateLogger {
|
||||
|
||||
@Override
|
||||
public void translatedInfo(String message, Object... args) {
|
||||
logger.info(languageManager.getLogString(message, args));
|
||||
logger.info(languageManager.get().getLogString(message, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,9 +29,10 @@ import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.velocity.VelocityCommandManager;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import io.avaje.inject.Bean;
|
||||
import io.avaje.inject.Factory;
|
||||
import io.micronaut.context.annotation.Bean;
|
||||
import io.micronaut.context.annotation.Factory;
|
||||
import jakarta.inject.Named;
|
||||
import jakarta.inject.Singleton;
|
||||
import org.geysermc.floodgate.core.platform.command.CommandUtil;
|
||||
@@ -42,9 +43,13 @@ import org.geysermc.floodgate.core.player.UserAudience;
|
||||
public final class VelocityPlatformModule {
|
||||
@Bean
|
||||
@Singleton
|
||||
public CommandManager<UserAudience> commandManager(CommandUtil commandUtil, ProxyServer proxy) {
|
||||
public CommandManager<UserAudience> commandManager(
|
||||
CommandUtil commandUtil,
|
||||
ProxyServer proxy,
|
||||
PluginContainer container
|
||||
) {
|
||||
CommandManager<UserAudience> commandManager = new VelocityCommandManager<>(
|
||||
null,
|
||||
container,
|
||||
proxy,
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
commandUtil::getUserAudience,
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2023 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/Floodgate
|
||||
*/
|
||||
|
||||
@InjectModule(
|
||||
requiresPackages = {FloodgatePlatform.class, FloodgateApi.class, ProxyModule.class},
|
||||
requires = {ProxyServer.class, LanguageManager.class},
|
||||
provides = Path.class
|
||||
)
|
||||
package org.geysermc.floodgate.velocity;
|
||||
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import io.avaje.inject.InjectModule;
|
||||
import java.nio.file.Path;
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
import org.geysermc.floodgate.core.FloodgatePlatform;
|
||||
import org.geysermc.floodgate.core.api.ProxyModule;
|
||||
import org.geysermc.floodgate.core.util.LanguageManager;
|
||||
@@ -34,29 +34,30 @@ import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelMessageSource;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import io.micronaut.context.BeanProvider;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
||||
import org.geysermc.floodgate.core.listener.McListener;
|
||||
import org.geysermc.floodgate.core.platform.pluginmessage.PluginMessageUtils;
|
||||
import org.geysermc.floodgate.core.pluginmessage.PluginMessageChannel;
|
||||
import org.geysermc.floodgate.core.pluginmessage.PluginMessageChannel.Identity;
|
||||
import org.geysermc.floodgate.core.pluginmessage.PluginMessageChannel.Result;
|
||||
import org.geysermc.floodgate.core.pluginmessage.PluginMessageManager;
|
||||
import org.geysermc.floodgate.core.register.ListenerRegister;
|
||||
|
||||
@ListenerRegister.Listener
|
||||
@McListener
|
||||
@Singleton
|
||||
public class VelocityPluginMessageUtils extends PluginMessageUtils {
|
||||
@Inject PluginMessageManager pluginMessageManager;
|
||||
@Inject BeanProvider<PluginMessageManager> pluginMessageManager;
|
||||
@Inject ProxyServer proxy;
|
||||
@Inject FloodgateLogger logger;
|
||||
|
||||
@Subscribe
|
||||
public void onPluginMessage(PluginMessageEvent event) {
|
||||
String channelId = event.getIdentifier().getId();
|
||||
PluginMessageChannel channel = pluginMessageManager.getChannel(channelId);
|
||||
PluginMessageChannel channel = pluginMessageManager.get().getChannel(channelId);
|
||||
if (channel == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,11 +40,9 @@ import org.geysermc.floodgate.core.platform.command.CommandUtil;
|
||||
import org.geysermc.floodgate.core.player.UserAudience;
|
||||
import org.geysermc.floodgate.core.player.UserAudience.ConsoleAudience;
|
||||
import org.geysermc.floodgate.core.player.UserAudience.PlayerAudience;
|
||||
import org.geysermc.floodgate.core.register.ListenerRegister;
|
||||
import org.geysermc.floodgate.core.util.LanguageManager;
|
||||
import org.geysermc.floodgate.core.util.Utils;
|
||||
|
||||
@ListenerRegister.Listener
|
||||
@Singleton
|
||||
public final class VelocityCommandUtil extends CommandUtil {
|
||||
private static UserAudience console;
|
||||
|
||||
Reference in New Issue
Block a user