-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
~ Velocity 1.x is now shared under the velocity-legacy module
- Loading branch information
Showing
13 changed files
with
585 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright 2020 Andre601 | ||
~ | ||
~ 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. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>velocity-legacy</artifactId> | ||
<packaging>jar</packaging> | ||
<version>${plugin.version}</version> | ||
|
||
<parent> | ||
<artifactId>parent</artifactId> | ||
<groupId>com.andre601.oneversionremake</groupId> | ||
<version>parent</version> | ||
</parent> | ||
|
||
<repositories> | ||
<repository> | ||
<id>velocity</id> | ||
<url>https://nexus.velocitypowered.com/repository/maven-public</url> | ||
</repository> | ||
<repository> | ||
<id>sonatype</id> | ||
<url>https://oss.sonatype.org/content/repositories/snapshots</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.andre601.oneversionremake</groupId> | ||
<artifactId>core</artifactId> | ||
<version>${project.version}</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.velocitypowered</groupId> | ||
<artifactId>velocity-api</artifactId> | ||
<version>1.1.5</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.kyori</groupId> | ||
<artifactId>adventure-text-minimessage</artifactId> | ||
<version>4.0.0-SNAPSHOT</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.bstats</groupId> | ||
<artifactId>bstats-velocity</artifactId> | ||
<version>2.2.1</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.spongepowered</groupId> | ||
<artifactId>configurate-yaml</artifactId> | ||
<version>4.1.1</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>OneVersionRemake-Velocity-legacy-${project.version}</finalName> | ||
<resources> | ||
<resource> | ||
<filtering>true</filtering> | ||
<directory>${project.basedir}/src/main/resources</directory> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>3.2.4</version> | ||
<configuration> | ||
<minimizeJar>true</minimizeJar> | ||
<relocations> | ||
<relocation> | ||
<pattern>org.spongepowered.configurate</pattern> | ||
<shadedPattern>com.andre601.oneversionremake.velocity.dependencies.configurate</shadedPattern> | ||
</relocation> | ||
<relocation> | ||
<pattern>org.bstats</pattern> | ||
<shadedPattern>com.andre601.oneversionremake.velocity.dependencies.bstats</shadedPattern> | ||
</relocation> | ||
</relocations> | ||
<filters> | ||
<filter> | ||
<artifact>*:*</artifact> | ||
<excludes> | ||
<exclude>META-INF/*.SF</exclude> | ||
<exclude>META-INF/*.RSA</exclude> | ||
<exclude>META-INF/versions/16/</exclude> | ||
</excludes> | ||
</filter> | ||
</filters> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
132 changes: 132 additions & 0 deletions
132
velocity-legacy/src/main/java/com/andre601/oneversionremake/velocity/VelocityCore.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,132 @@ | ||
/* | ||
* Copyright 2020 - 2021 Andre601 | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.andre601.oneversionremake.velocity; | ||
|
||
import com.andre601.oneversionremake.core.OneVersionRemake; | ||
import com.andre601.oneversionremake.core.commands.CommandHandler; | ||
import com.andre601.oneversionremake.core.enums.ProxyPlatform; | ||
import com.andre601.oneversionremake.core.files.ConfigHandler; | ||
import com.andre601.oneversionremake.core.interfaces.PluginCore; | ||
import com.andre601.oneversionremake.core.interfaces.ProxyLogger; | ||
import com.andre601.oneversionremake.velocity.commands.CmdOneVersionRemake; | ||
import com.andre601.oneversionremake.velocity.listener.VelocityLoginListener; | ||
import com.andre601.oneversionremake.velocity.listener.VelocityPingListener; | ||
import com.andre601.oneversionremake.velocity.logging.VelocityLogger; | ||
import com.google.inject.Inject; | ||
import com.velocitypowered.api.command.CommandMeta; | ||
import com.velocitypowered.api.event.Subscribe; | ||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; | ||
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; | ||
import java.util.List; | ||
|
||
public class VelocityCore implements PluginCore{ | ||
|
||
private final ProxyLogger logger; | ||
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){ | ||
this.logger = new VelocityLogger(LoggerFactory.getLogger("OneVersionRemake")); | ||
this.proxy = proxy; | ||
this.path = path; | ||
|
||
this.factory = factory; | ||
} | ||
|
||
@Subscribe | ||
public void initialize(ProxyInitializeEvent event){ | ||
this.core = new OneVersionRemake(this); | ||
} | ||
|
||
// PluginCore stuff | ||
|
||
@Override | ||
public void loadCommands(){ | ||
CommandMeta commandMeta = getProxy().getCommandManager() | ||
.metaBuilder("oneversionremake") | ||
.aliases("ovr") | ||
.build(); | ||
|
||
getProxy().getCommandManager().register(commandMeta, new CmdOneVersionRemake(this)); | ||
} | ||
|
||
@Override | ||
public void loadEventListeners(){ | ||
new VelocityLoginListener(this); | ||
new VelocityPingListener(this); | ||
} | ||
|
||
@Override | ||
public void loadMetrics(){ | ||
Metrics metrics = factory.make(this, 10341); | ||
|
||
metrics.addCustomChart(new DrilldownPie("allowed_protocols", () -> core.getPieMap())); | ||
} | ||
|
||
@Override | ||
public Path getPath(){ | ||
return path; | ||
} | ||
|
||
@Override | ||
public ProxyPlatform getProxyPlatform(){ | ||
return ProxyPlatform.VELOCITY; | ||
} | ||
|
||
@Override | ||
public ProxyLogger getProxyLogger(){ | ||
return logger; | ||
} | ||
|
||
@Override | ||
public ConfigHandler getConfigHandler(){ | ||
return core.getConfigHandler(); | ||
} | ||
|
||
@Override | ||
public CommandHandler getCommandHandler(){ | ||
return core.getCommandHandler(); | ||
} | ||
|
||
@Override | ||
public String getVersion(){ | ||
return core.getVersion(); | ||
} | ||
|
||
public ProxyServer getProxy(){ | ||
return proxy; | ||
} | ||
|
||
public ServerPing.SamplePlayer[] getPlayers(List<String> lines, List<Integer> serverProtocols, int userProtocol, boolean majorOnly){ | ||
return core.getPlayers(ServerPing.SamplePlayer.class, lines, serverProtocols, userProtocol, majorOnly) | ||
.toArray(new ServerPing.SamplePlayer[0]); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...cy/src/main/java/com/andre601/oneversionremake/velocity/commands/CmdOneVersionRemake.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,39 @@ | ||
/* | ||
* Copyright 2020 - 2021 Andre601 | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.andre601.oneversionremake.velocity.commands; | ||
|
||
import com.andre601.oneversionremake.velocity.VelocityCore; | ||
import com.velocitypowered.api.command.SimpleCommand; | ||
|
||
public class CmdOneVersionRemake implements SimpleCommand{ | ||
|
||
private final VelocityCore plugin; | ||
|
||
public CmdOneVersionRemake(VelocityCore plugin){ | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public void execute(Invocation invocation){ | ||
VelocitySender sender = new VelocitySender(invocation.source()); | ||
String[] args = invocation.arguments(); | ||
|
||
plugin.getCommandHandler().handle(sender, args); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...-legacy/src/main/java/com/andre601/oneversionremake/velocity/commands/VelocitySender.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,54 @@ | ||
/* | ||
* Copyright 2020 - 2021 Andre601 | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.andre601.oneversionremake.velocity.commands; | ||
|
||
import com.andre601.oneversionremake.core.CommandPermissions; | ||
import com.andre601.oneversionremake.core.interfaces.CmdSender; | ||
import com.velocitypowered.api.command.CommandSource; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.format.NamedTextColor; | ||
|
||
public class VelocitySender implements CmdSender{ | ||
|
||
private final CommandSource sender; | ||
|
||
public VelocitySender(CommandSource sender){ | ||
this.sender = sender; | ||
} | ||
|
||
@Override | ||
public boolean hasPermission(String permission){ | ||
return sender.hasPermission(permission) || sender.hasPermission(CommandPermissions.ADMIN); | ||
} | ||
|
||
@Override | ||
public void sendMsg(){ | ||
sendMsg(""); | ||
} | ||
|
||
@Override | ||
public void sendMsg(String msg, Object... args){ | ||
sendMsg(NamedTextColor.WHITE, msg, args); | ||
} | ||
|
||
@Override | ||
public void sendMsg(NamedTextColor color, String msg, Object... args){ | ||
sender.sendMessage(Component.text(String.format(msg, args)).color(color)); | ||
} | ||
} |
Oops, something went wrong.