Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(velocity): @version@ placeholder not being replaced in VelocityTriton #459

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.rexcantor64.triton.loader;

import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.rexcantor64.triton.loader.utils.CommonLoader;
import com.rexcantor64.triton.loader.utils.LoaderBootstrap;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Dependency;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
import org.slf4j.Logger;
Expand Down Expand Up @@ -34,17 +36,19 @@ public class VelocityLoader {
private final LoaderBootstrap plugin;

@Inject
public VelocityLoader(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) {
public VelocityLoader(ProxyServer server, Logger logger, @Named("triton") PluginContainer container, @DataDirectory Path dataDirectory) {
this.plugin = CommonLoader.builder()
.jarInJarName(PLATFORM_JAR_NAME)
.bootstrapClassName(BOOTSTRAP_CLASS)
.constructorType(Object.class)
.constructorType(ProxyServer.class)
.constructorType(Logger.class)
.constructorType(PluginContainer.class)
.constructorType(Path.class)
.constructorValue(this)
.constructorValue(server)
.constructorValue(logger)
.constructorValue(container)
.constructorValue(dataDirectory)
.build()
.loadPlugin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import com.velocitypowered.api.scheduler.ScheduledTask;
import lombok.Getter;
import lombok.NonNull;
import lombok.val;
import org.bstats.charts.SingleLineChart;
import org.bstats.velocity.Metrics;
Expand Down Expand Up @@ -93,8 +94,8 @@ public File getDataFolder() {
}

@Override
public String getVersion() {
return "@version@";
public @NonNull String getVersion() {
return getLoader().getPluginContainer().getDescription().getVersion().orElse("unknown");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.rexcantor64.triton.velocity.plugin;

import com.google.inject.name.Named;
import com.rexcantor64.triton.dependencies.DependencyManager;
import com.rexcantor64.triton.loader.utils.LoaderBootstrap;
import com.rexcantor64.triton.loader.utils.LoaderFlag;
Expand All @@ -8,6 +9,7 @@
import com.rexcantor64.triton.plugin.Platform;
import com.rexcantor64.triton.plugin.PluginLoader;
import com.rexcantor64.triton.velocity.VelocityTriton;
import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
import lombok.Getter;
Expand All @@ -27,17 +29,20 @@ public class VelocityPlugin implements PluginLoader, LoaderBootstrap {
private final Object plugin;
private final ProxyServer server;
private final TritonLogger tritonLogger;
@Getter
private final PluginContainer pluginContainer;
private final Path dataDirectory;
private final Metrics.Factory metricsFactory;
@Getter
private final Set<LoaderFlag> loaderFlags;
@Getter
private final DependencyManager dependencyManager;

public VelocityPlugin(Object loader, ProxyServer server, Logger logger, @DataDirectory Path dataDirectory, Set<LoaderFlag> loaderFlags) {
public VelocityPlugin(Object loader, ProxyServer server, Logger logger, @Named("triton") PluginContainer container, @DataDirectory Path dataDirectory, Set<LoaderFlag> loaderFlags) {
this.plugin = loader;
this.server = server;
this.tritonLogger = new SLF4JLogger(logger);
this.pluginContainer = container;
this.dataDirectory = dataDirectory;
this.loaderFlags = loaderFlags;
this.dependencyManager = new DependencyManager(new VelocityLibraryManager<>(logger, dataDirectory, server.getPluginManager(), loader), loaderFlags);
Expand Down
Loading