Skip to content

Commit

Permalink
Merge pull request #55 from Andre601/feature/proper-velocity-2-support
Browse files Browse the repository at this point in the history
Fully support Velocity 2
  • Loading branch information
Andre601 authored May 18, 2021
2 parents 5f478c1 + 6247b26 commit 1a0bab1
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ public String getVersion(){
return core.getVersion();
}

@Override
public String getProxyVersion(){
String[] version = getProxy().getVersion().split(":");

return String.format("%s (Build #%s)", version[2], version[4]);
}

public ServerPing.PlayerInfo[] getPlayers(List<String> lines, List<Integer> serverProtocols, int userProtocol, boolean majorOnly){
return core.getPlayers(ServerPing.PlayerInfo.class, lines, serverProtocols, userProtocol, majorOnly)
.toArray(new ServerPing.PlayerInfo[0]);
Expand Down
1 change: 1 addition & 0 deletions bungeecord/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: OneVersionRemake
author: Andre_601
version: ${project.version}
description: ${project.description}

main: com.andre601.oneversionremake.bungeecord.BungeeCore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private void printBanner(){
getProxyLogger().info("\\____/ |___/_/ |_|");
getProxyLogger().info("");
getProxyLogger().info("OneVersionRemake v" + getVersion());
getProxyLogger().info("Platform: " + pluginCore.getProxyPlatform().getName());
getProxyLogger().info("Platform: " + pluginCore.getProxyPlatform().getName() + " v" + pluginCore.getProxyVersion());
getProxyLogger().info("");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ public interface PluginCore{
CommandHandler getCommandHandler();

String getVersion();

String getProxyVersion();
}
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<plugin.version>3.5.0</plugin.version>

<plugin.version>3.5.1</plugin.version>
<plugin.description>Only allow specific client versions on your Network.</plugin.description>

<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ public String getVersion(){
return core.getVersion();
}

@Override
public String getProxyVersion(){
return getProxy().getVersion().getVersion();
}

public ProxyServer getProxy(){
return proxy;
}
Expand Down
2 changes: 1 addition & 1 deletion velocity-legacy/src/main/resources/velocity-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "oneversionremake",
"name": "OneVersionRemake",
"version": "${project.version}",
"description": "Block connections from Players with versions not matching your Network's.",
"description": "${project.description}",
"authors": [
"Andre_601"
],
Expand Down
1 change: 1 addition & 0 deletions velocity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<artifactId>velocity</artifactId>
<packaging>jar</packaging>
<version>${plugin.version}</version>
<description>${plugin.description}</description>

<parent>
<artifactId>parent</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.server.ServerPing;
import org.bstats.charts.DrilldownPie;
import org.bstats.velocity.Metrics;
import org.slf4j.LoggerFactory;

import java.nio.file.Path;
Expand All @@ -48,17 +46,13 @@ public class VelocityCore implements PluginCore{
private final ProxyServer proxy;
private final Path path;

private final Metrics.Factory factory;

private OneVersionRemake core;

@Inject
public VelocityCore(ProxyServer proxy, @DataDirectory Path path, Metrics.Factory factory){
@Inject // TODO: Re-Add Metrics.Factory factory once Velocity 2 supports it
public VelocityCore(ProxyServer proxy, @DataDirectory Path path){
this.logger = new VelocityLogger(LoggerFactory.getLogger("OneVersionRemake"));
this.proxy = proxy;
this.path = path;

this.factory = factory;
}

@Subscribe
Expand Down Expand Up @@ -86,9 +80,11 @@ public void loadEventListeners(){

@Override
public void loadMetrics(){
Metrics metrics = factory.make(this, 10341);
// TODO: Re-Add Metrics once available for Velocity 2
//Metrics metrics = factory.make(this, 10341);

//metrics.addCustomChart(new DrilldownPie("allowed_protocols", () -> core.getPieMap()));

metrics.addCustomChart(new DrilldownPie("allowed_protocols", () -> core.getPieMap()));
}

@Override
Expand Down Expand Up @@ -121,6 +117,11 @@ public String getVersion(){
return core.getVersion();
}

@Override
public String getProxyVersion(){
return getProxy().version().version();
}

public ProxyServer getProxy(){
return proxy;
}
Expand Down
12 changes: 12 additions & 0 deletions velocity/src/main/resources/velocity-plugin-info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"id": "oneversionremake",
"name": "OneVersionRemake",
"version": "${project.version}",
"description": "${project.description}",
"authors": [
"Andre_601"
],
"main": "com.andre601.oneversionremake.velocity.VelocityCore"
}
]

0 comments on commit 1a0bab1

Please sign in to comment.