progress
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
package us.ajg0702.queue.platforms.velocity;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import us.ajg0702.queue.api.util.QueueLogger;
|
||||
|
||||
public class VelocityLogger implements QueueLogger {
|
||||
|
||||
private final Logger logger;
|
||||
|
||||
protected VelocityLogger(Logger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String message) {
|
||||
logger.warn(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(String message) {
|
||||
logger.warn(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String message) {
|
||||
logger.info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message) {
|
||||
logger.error(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String message) {
|
||||
logger.error(message);
|
||||
}
|
||||
}
|
||||
+10
-9
@@ -5,16 +5,15 @@ import com.google.common.io.ByteStreams;
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import us.ajg0702.queue.api.PlatformMethods;
|
||||
import us.ajg0702.queue.api.commands.IBaseCommand;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
import us.ajg0702.queue.api.players.QueuePlayer;
|
||||
import us.ajg0702.queue.api.queues.QueueServer;
|
||||
import us.ajg0702.queue.api.util.QueueLogger;
|
||||
import us.ajg0702.queue.commands.commands.PlayerSender;
|
||||
import us.ajg0702.queue.platforms.velocity.players.VelocityPlayer;
|
||||
|
||||
@@ -22,15 +21,14 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class VelocityMethods implements PlatformMethods {
|
||||
|
||||
final ProxyServer proxyServer;
|
||||
final Logger logger;
|
||||
final QueueLogger logger;
|
||||
final VelocityQueue plugin;
|
||||
|
||||
public VelocityMethods(VelocityQueue plugin, ProxyServer proxyServer, Logger logger) {
|
||||
public VelocityMethods(VelocityQueue plugin, ProxyServer proxyServer, QueueLogger logger) {
|
||||
this.proxyServer = proxyServer;
|
||||
this.logger = logger;
|
||||
this.plugin = plugin;
|
||||
@@ -46,8 +44,11 @@ public class VelocityMethods implements PlatformMethods {
|
||||
for(String s : data) {
|
||||
out.writeUTF( s );
|
||||
}
|
||||
|
||||
velocityPlayer.sendPluginMessage(MinecraftChannelIdentifier.from("ajqueue:tospigot"), out.toByteArray());
|
||||
Optional<ServerConnection> server = velocityPlayer.getCurrentServer();
|
||||
if(!server.isPresent()) {
|
||||
throw new IllegalStateException("No server to send data to");
|
||||
}
|
||||
server.get().sendPluginMessage(MinecraftChannelIdentifier.from("ajqueue:tospigot"), out.toByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-10
@@ -13,7 +13,6 @@ import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import us.ajg0702.queue.api.commands.IBaseCommand;
|
||||
import us.ajg0702.queue.commands.BaseCommand;
|
||||
import us.ajg0702.queue.commands.commands.leavequeue.LeaveCommand;
|
||||
@@ -29,7 +28,8 @@ import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@Plugin(
|
||||
id = "ajqueue",
|
||||
@@ -42,7 +42,7 @@ import java.util.logging.Logger;
|
||||
|
||||
public class VelocityQueue {
|
||||
final ProxyServer proxyServer;
|
||||
final Logger logger;
|
||||
final VelocityLogger logger;
|
||||
|
||||
QueueMain main;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class VelocityQueue {
|
||||
@Inject
|
||||
public VelocityQueue(ProxyServer proxyServer, Logger logger, @DataDirectory Path dataFolder) {
|
||||
this.proxyServer = proxyServer;
|
||||
this.logger = logger;
|
||||
this.logger = new VelocityLogger(logger);
|
||||
|
||||
this.dataFolder = dataFolder.toFile();
|
||||
}
|
||||
@@ -104,14 +104,9 @@ public class VelocityQueue {
|
||||
System.out.println("Skipping message: "+e.getIdentifier().getId());
|
||||
return;
|
||||
}
|
||||
if(!e.getIdentifier().getId().equals("ajqueue:toproxy")) {
|
||||
System.out.println("Skipping message: "+e.getIdentifier().getId());
|
||||
return;
|
||||
}
|
||||
if(!e.getIdentifier().getId().equals("ajqueue:toproxy")) return;
|
||||
e.setResult(PluginMessageEvent.ForwardResult.handled());
|
||||
|
||||
System.out.println("Processing message: "+e.getIdentifier().getId());
|
||||
|
||||
if(!(e.getTarget() instanceof Player)) return;
|
||||
|
||||
main.getEventHandler().handleMessage(new VelocityPlayer((Player) e.getTarget()), e.getData());
|
||||
|
||||
Reference in New Issue
Block a user