use of com.velocitypowered.api.proxy.ProxyServer in project LuckPerms by lucko.
the class VelocityCommandExecutor method register.
public void register() {
ProxyServer proxy = this.plugin.getBootstrap().getProxy();
proxy.getCommandManager().register(PRIMARY_ALIAS, this, ALIASES);
// register slash aliases so the console can run '/lpv' in the same way as 'lpv'.
proxy.getCommandManager().register(SLASH_PRIMARY_ALIAS, new ForwardingCommand(this) {
@Override
public boolean hasPermission(Invocation invocation) {
return invocation.source() instanceof ConsoleCommandSource;
}
}, SLASH_ALIASES);
}
use of com.velocitypowered.api.proxy.ProxyServer in project LuckPerms by lucko.
the class PluginMessageMessenger method init.
public void init() {
ProxyServer proxy = this.plugin.getBootstrap().getProxy();
proxy.getChannelRegistrar().register(CHANNEL);
proxy.getEventManager().register(this.plugin.getBootstrap(), this);
}
use of com.velocitypowered.api.proxy.ProxyServer in project LuckPerms by lucko.
the class PluginMessageMessenger method close.
@Override
public void close() {
ProxyServer proxy = this.plugin.getBootstrap().getProxy();
proxy.getChannelRegistrar().unregister(CHANNEL);
proxy.getEventManager().unregisterListener(this.plugin.getBootstrap(), this);
}
use of com.velocitypowered.api.proxy.ProxyServer in project LibertyBans by A248.
the class VelocityCulpritFinderTest method findCulprit.
@Test
public void findCulprit(@Mock ProxyServer server, @Mock PluginManager pluginManager, @Mock PluginContainer pluginString, @Mock PluginContainer pluginOwnClass) {
class OwnClass {
}
{
when(server.getPluginManager()).thenReturn(pluginManager);
when(pluginManager.getPlugins()).thenReturn(List.of(pluginString, pluginOwnClass));
when(pluginString.getInstance()).thenAnswer((i) -> Optional.of("a".concat("b")));
setDescription(pluginString, "JDK", "0");
when(pluginOwnClass.getInstance()).thenAnswer((i) -> Optional.of(new OwnClass()));
setDescription(pluginOwnClass, "Self", "1");
}
CulpritFinder culpritFinder = new VelocityCulpritFinder(server);
assertEquals("JDK 0", culpritFinder.findCulprit(List.class));
assertEquals("Self 1", culpritFinder.findCulprit(getClass()));
}
use of com.velocitypowered.api.proxy.ProxyServer in project CommandSyncServer by Wind-Development.
the class SyncConnection method startConnection.
/**
* Starts the connection
*
* @param clientSocket The client's socket
*/
public void startConnection(Socket clientSocket) {
SyncPlugin.getInstance().getLogger().info("New connection from " + this.connectionName + " established.");
// Initializes a new connection from a client
Runnable connectionRunnable = (() -> {
try {
// The connected client's input
BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
// Output for communication with client
PrintWriter output = new PrintWriter(clientSocket.getOutputStream(), true);
// Handle keep alives
startKeepAliveHandler();
// Handle client messages
String clientInput;
while (true) {
clientInput = in.readLine();
// Exit connection if keep alive has expired
if (hasUnregistered) {
break;
}
// Exit connection if told to do so by the client
if (clientInput.equalsIgnoreCase(".")) {
closeConnection();
break;
} else if (clientInput.toLowerCase().contains("name ")) {
String finalName = clientInput.toLowerCase().replace("name ", "");
SyncConnection.this.connectionName = finalName;
} else if (clientInput.equalsIgnoreCase("keep alive packet")) {
keepAliveTimeOutTime = 100;
} else if (clientInput.toLowerCase().contains("run command ")) {
String processCommand = clientInput.toLowerCase().replace("run command ", "");
ProxyServer server = SyncPlugin.getInstance().getServer();
SyncPlugin.getInstance().getLogger().info("received command " + processCommand);
server.getCommandManager().executeAsync(server.getConsoleCommandSource(), processCommand);
SyncPlugin.getInstance().getLogger().info("ran command " + processCommand);
}
}
} catch (IOException e) {
e.printStackTrace();
}
});
// Start the connection with the client on its own thread
connectionPool.execute(connectionRunnable);
}
Aggregations