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

Port PteroBungee to Velocity #4

Merged
merged 6 commits into from
Jan 22, 2022
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
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@ plugins {
}

group = 'us.sparkedhost'
version = '1.2.0'
version = '1.2.1'

repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven {
name 'velocity'
url 'https://nexus.velocitypowered.com/repository/maven-public/'
}
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
compileOnly 'net.md-5:bungeecord-api:1.18-R0.1-SNAPSHOT'
compile 'com.velocitypowered:velocity-api:3.0.1'
annotationProcessor 'com.velocitypowered:velocity-api:3.0.1'
}

sourceCompatibility = '1.8'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;

public class StopCommand extends Command {
public StopCommand() {
public class BungeeStopCommand extends Command {
public BungeeStopCommand() {
super("stop");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer)) {
ProxyServer.getInstance().stop();
} else {
((ProxiedPlayer) sender).chat("/minecraft:stop");
return;
}

((ProxiedPlayer) sender).chat("/minecraft:stop");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package us.sparkedhost.pterobungee.Commands;

import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
import com.velocitypowered.api.proxy.Player;
import us.sparkedhost.pterobungee.PteroVelocity;

public class VelocityStopCommand implements SimpleCommand {
@Override
public void execute(final Invocation invocation) {
CommandSource source = invocation.source();

if (!(source instanceof Player)) {
PteroVelocity.instance.server.shutdown();
return;
}

((Player) source).spoofChatInput("/minecraft:stop");
}
}
4 changes: 2 additions & 2 deletions src/main/java/us/sparkedhost/pterobungee/PteroBungee.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.plugin.Plugin;
import us.sparkedhost.pterobungee.Commands.StopCommand;
import us.sparkedhost.pterobungee.Commands.BungeeStopCommand;

import java.util.logging.Level;

public final class PteroBungee extends Plugin {
@Override
public void onEnable() {
// Plugin startup logic
getProxy().getPluginManager().registerCommand(this, new StopCommand());
getProxy().getPluginManager().registerCommand(this, new BungeeStopCommand());
getLogger().log(Level.INFO, "PteroBungee loaded. v" + this.getDescription().getVersion() + " developed by" + this.getDescription().getAuthor());
Runnable doneOutput = this::sendStartedMsg;
getProxy().getScheduler().runAsync(this, doneOutput);
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/us/sparkedhost/pterobungee/PteroVelocity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package us.sparkedhost.pterobungee;

import com.google.inject.Inject;
import com.velocitypowered.api.command.CommandManager;
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 org.slf4j.Logger;
import us.sparkedhost.pterobungee.Commands.VelocityStopCommand;

@Plugin(id = "pterobungee", name = "PteroBungee", version = "1.2.1-Velocity", url = "https://github.com/SparkedHost/PteroBungee", authors = "BetTD")
public class PteroVelocity {
public static PteroVelocity instance;
public final ProxyServer server;
private final Logger logger;

@Inject
public PteroVelocity(ProxyServer server, Logger logger) {
this.server = server;
this.logger = logger;
instance = this;

logger.info("PteroBungee (for Velocity) is now loading.");
}

@Subscribe
public void onProxyInitialization(ProxyInitializeEvent e) {
CommandManager cmdManager = server.getCommandManager();
cmdManager.register(cmdManager.metaBuilder("stop").build(), new VelocityStopCommand());
}
}
2 changes: 1 addition & 1 deletion src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: PteroBungee
version: 1.2.0
version: 1.2.1
main: us.sparkedhost.pterobungee.PteroBungee
description: Workaround for Pterodactyl's inability to properly interact with BungeeCord servers - fixes "Starting..." status and Stop button.
author: Sparked Host