-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Project exclude paths | ||
/target/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# VelocityPlus | ||
|
||
Join my Discord (German) | ||
[![Join my Discord (German)](https://img.shields.io/discord/674745039972466688.svg?logo=discord&label=)](https://discord.x-community.net) | ||
|
||
A Velocity proxy plugin which adds customizable commands from the bungeecord proxy and a little bit more. | ||
|
||
### !! It's my first velocity plugin, so please don't hate me for it. !! | ||
|
||
## Commands | ||
|
||
* Alert | ||
* Permission: `vplus.alert` | ||
* Description: `Send a message to every user which is connected to the proxy. It supports MiniMessage.` [Link](https://docs.adventure.kyori.net/minimessage/index.html) | ||
* Usage: `/alert <Message>` | ||
* Find | ||
* Permission: `vplus.find` | ||
* Description: `Find a player which is connected to the proxy. Good, if you want to see, which server someone is on.` | ||
* Usage: `/find <Player>` | ||
* Goto | ||
* Permission: `vplus.goto` | ||
* Description: `Go to a player, which is connected to a different server. (Only Server switching. Not teleporting to their location)` | ||
* Usage: `/goto <Player>` | ||
* IP | ||
* Permission: `vplus.ip` | ||
* Description: `Get the IP of a connected Player.` | ||
* Usage: `/ip <Player>` | ||
* Kickall | ||
* Permission: `vplus.kickall`, `vplus.kickall.bypass` (Bypass the Kickall Command), `vplus.kickall.force` (Kick all. Bypass Users included), `vplus.kickall.servername` (Per server permission) | ||
* Description: `Kick all players from the proxy, or from a specific server. There is a bypass Permission for the default and per server kickall command. If you use --force and have the vplus.kickall.force Permission, then you can kick even the Players which have the bypass permission.` | ||
* Usage: `/kickall {Server} {--force}` {} = Optional | ||
* Send | ||
* Permission: `vplus.send.all`, `vplus.send.current`, `vplus.send.server`, `vplus.send.user` | ||
* Description: `Send a player to another server. You can send all players which are connected to the proxy, all players which are connected to your current server, all players which are connected to a different browser or single users to another server.` | ||
* Usage: `/send <all, current, Server, User> <Target Server>` | ||
|
||
## Planned features | ||
- [x] Alert Command | ||
- [x] Find Command | ||
- [x] Goto Command | ||
- [x] IP Command | ||
- [x] Kickall Command | ||
- [x] Send Command | ||
- [x] Added configurable texts | ||
- [x] Configuration file with texts and prefix. (Alert command has its own prefix) | ||
- [x] Implement format parser to Alert command | ||
- [ ] Implement format parser to Kickall command | ||
- [ ] Implement format parser to configs for advanced text formatting. | ||
- [ ] Add placeholder function for every text. (I may add placeholderAPI support, but I'm not sure) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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> | ||
|
||
<groupId>eu.prellberg.nick</groupId> | ||
<artifactId>velocityplus</artifactId> | ||
<version>1.1.0</version> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>papermc</id> | ||
<url>https://papermc.io/repo/repository/maven-public/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.velocitypowered</groupId> | ||
<artifactId>velocity-api</artifactId> | ||
<version>3.1.1</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.moandjiezana.toml</groupId> | ||
<artifactId>toml4j</artifactId> | ||
<version>0.7.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.11.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.kyori</groupId> | ||
<artifactId>adventure-api</artifactId> | ||
<version>4.10.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.kyori</groupId> | ||
<artifactId>adventure-text-minimessage</artifactId> | ||
<version>4.10.1</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package eu.prellberg.nick.velocityplus; | ||
|
||
import com.google.inject.Inject; | ||
import com.moandjiezana.toml.Toml; | ||
import com.velocitypowered.api.event.Subscribe; | ||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; | ||
import com.velocitypowered.api.plugin.Plugin; | ||
import com.velocitypowered.api.proxy.ProxyServer; | ||
import eu.prellberg.nick.velocityplus.command.*; | ||
import org.slf4j.Logger; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.StandardOpenOption; | ||
|
||
@Plugin(id = "velocityplus", name = "VelocityPlus", version = "1.1.0", authors = {"Nick Prellberg"}, url = "https://github.com/xsehrmotiviert/velocityplus") | ||
public class VelocityPlus { | ||
|
||
private final ProxyServer server; | ||
private final Logger logger; | ||
private final String configPath; | ||
|
||
@Inject | ||
public VelocityPlus(ProxyServer server, Logger logger) { | ||
this.server = server; | ||
this.logger = logger; | ||
this.configPath = "./plugins/VelocityPlus/config.toml"; | ||
|
||
|
||
logger.info("[V+] Ready for duty!"); | ||
} | ||
|
||
@Subscribe | ||
public void onProxyInitialize(ProxyInitializeEvent event) { | ||
|
||
final var config = Path.of("plugins/VelocityPlus/config.toml"); | ||
if (!Files.exists(config)) { | ||
try (final var configTemplate = getClass().getResourceAsStream("/config.toml")) { | ||
Files.createDirectories(config.getParent()); | ||
assert configTemplate != null; | ||
Files.write(config, configTemplate.readAllBytes(), StandardOpenOption.CREATE_NEW); | ||
} catch (IOException e) { | ||
logger.error("New IO Exception: ", e); | ||
} | ||
|
||
} | ||
|
||
logger.info("\n\n /$$ /$$ /$$ /$$ /$$ \n" + | ||
"| $$ | $$ | $$ |__/ | $$ /$$ \n" + | ||
"| $$ | $$ /$$$$$$ | $$ /$$$$$$ /$$$$$$$ /$$ /$$$$$$ /$$ /$$ | $$ \n" + | ||
"| $$ / $$//$$__ $$| $$ /$$__ $$ /$$_____/| $$|_ $$_/ | $$ | $$ /$$$$$$$$\n" + | ||
" \\ $$ $$/| $$$$$$$$| $$| $$ \\ $$| $$ | $$ | $$ | $$ | $$|__ $$__/\n" + | ||
" \\ $$$/ | $$_____/| $$| $$ | $$| $$ | $$ | $$ /$$| $$ | $$ | $$ \n" + | ||
" \\ $/ | $$$$$$$| $$| $$$$$$/| $$$$$$$| $$ | $$$$/| $$$$$$$ |__/ \n" + | ||
" \\_/ \\_______/|__/ \\______/ \\_______/|__/ \\___/ \\____ $$ \n" + | ||
" /$$ | $$ \n" + | ||
" | $$$$$$/ \n" + | ||
" \\______/ \nVersion: 1.1.0"); | ||
|
||
new SendCommand(server, this, logger); | ||
new KickallCommand(server, this, logger); | ||
new FindCommand(server, this, logger); | ||
new IPCommand(server, this, logger); | ||
new AlertCommand(server, this, logger); | ||
new GotoCommand(server, this,logger); | ||
|
||
} | ||
|
||
public Toml getConfig() { | ||
return new Toml().read(new File(this.configPath)); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package eu.prellberg.nick.velocityplus.command; | ||
|
||
import com.velocitypowered.api.command.CommandManager; | ||
import com.velocitypowered.api.command.CommandSource; | ||
import com.velocitypowered.api.command.SimpleCommand; | ||
import com.velocitypowered.api.proxy.Player; | ||
import com.velocitypowered.api.proxy.ProxyServer; | ||
import eu.prellberg.nick.velocityplus.VelocityPlus; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.JoinConfiguration; | ||
import net.kyori.adventure.text.minimessage.MiniMessage; | ||
import org.slf4j.Logger; | ||
|
||
import eu.prellberg.nick.velocityplus.utils.formatParser; | ||
|
||
public class AlertCommand implements SimpleCommand { | ||
|
||
private final ProxyServer proxyServer; | ||
private final VelocityPlus velocityPlus; | ||
private final Logger logger; | ||
|
||
public AlertCommand(ProxyServer proxyServer, VelocityPlus velocityPlus, Logger logger) { | ||
this.proxyServer = proxyServer; | ||
this.velocityPlus = velocityPlus; | ||
this.logger = logger; | ||
CommandManager manager = proxyServer.getCommandManager(); | ||
manager.register(manager.metaBuilder("alert").build(), this); | ||
} | ||
|
||
@Override | ||
public void execute(Invocation invocation) { | ||
CommandSource source = invocation.source(); | ||
if (!source.hasPermission("vplus.alert")) { | ||
source.sendMessage(Component.text(String.join(" ", velocityPlus.getConfig().getString("general.prefix"), velocityPlus.getConfig().getString("general.missingPermissions")))); | ||
return; | ||
} | ||
|
||
if (invocation.arguments().length < 1) { | ||
source.sendMessage(Component.text(String.join(" ", velocityPlus.getConfig().getString("general.prefix"), velocityPlus.getConfig().getString("alert.command.missingMessage")))); | ||
return; | ||
} | ||
|
||
String text = String.join(" ", invocation.arguments()); | ||
text = new formatParser().parse(text); | ||
for (Player player : this.proxyServer.getAllPlayers()) { | ||
player.sendMessage(Component.join(JoinConfiguration.separator(Component.text(" ")), Component.text(velocityPlus.getConfig().getString("alert.command.prefix")), MiniMessage.miniMessage().deserialize(text))); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package eu.prellberg.nick.velocityplus.command; | ||
|
||
import com.velocitypowered.api.command.CommandManager; | ||
import com.velocitypowered.api.command.CommandSource; | ||
import com.velocitypowered.api.command.SimpleCommand; | ||
import com.velocitypowered.api.proxy.Player; | ||
import com.velocitypowered.api.proxy.ProxyServer; | ||
import com.velocitypowered.api.proxy.ServerConnection; | ||
import eu.prellberg.nick.velocityplus.VelocityPlus; | ||
import net.kyori.adventure.text.Component; | ||
import org.slf4j.Logger; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.stream.Collectors; | ||
|
||
public class FindCommand implements SimpleCommand { | ||
|
||
private final ProxyServer proxyServer; | ||
private final VelocityPlus velocityPlus; | ||
private final Logger logger; | ||
|
||
public FindCommand(ProxyServer proxyServer, VelocityPlus velocityPlus, Logger logger) { | ||
this.proxyServer = proxyServer; | ||
this.velocityPlus = velocityPlus; | ||
this.logger = logger; | ||
CommandManager manager = proxyServer.getCommandManager(); | ||
manager.register(manager.metaBuilder("find").build(), this); | ||
} | ||
|
||
@Override | ||
public void execute(Invocation invocation) { | ||
CommandSource source = invocation.source(); | ||
if (!source.hasPermission("vplus.find")) { | ||
source.sendMessage(Component.text(String.join(" ", velocityPlus.getConfig().getString("general.prefix"), velocityPlus.getConfig().getString("general.missingPermissions")))); | ||
return; | ||
} | ||
|
||
if (invocation.arguments().length < 1) { | ||
source.sendMessage(Component.text(String.join(" ", velocityPlus.getConfig().getString("general.prefix"), velocityPlus.getConfig().getString("find.command.missingUser")))); | ||
return; | ||
} | ||
|
||
Optional<Player> playerFound = proxyServer.getPlayer(invocation.arguments()[0]); | ||
if (playerFound.isEmpty()) { | ||
source.sendMessage(Component.text(String.join(" ", velocityPlus.getConfig().getString("general.prefix"), velocityPlus.getConfig().getString("find.command.userOffline")))); | ||
return; | ||
} | ||
Optional<ServerConnection> server = playerFound.get().getCurrentServer(); | ||
|
||
source.sendMessage(Component.text(String.join(" ", velocityPlus.getConfig().getString("general.prefix"), velocityPlus.getConfig().getString("find.command.result").replaceAll("<<user>>", playerFound.get().getUsername()).replaceAll("<<server>>", server.get().getServerInfo().getName())))); | ||
|
||
} | ||
|
||
@Override | ||
public List<String> suggest(Invocation invocation) { | ||
CommandSource source = invocation.source(); | ||
if (!source.hasPermission("vplus.find")) { | ||
return Collections.emptyList(); | ||
} | ||
if (invocation.arguments().length > 0) { | ||
return proxyServer.getAllPlayers() | ||
.stream() | ||
.map(Player::getUsername) | ||
.filter(s -> s.startsWith(String.join("", invocation.arguments()))) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
return Collections.emptyList(); | ||
} | ||
} |