Skip to content

Commit

Permalink
Alpha v0.9.9 - Tweaks to squash some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Zulfen committed Sep 4, 2023
1 parent 0f19a35 commit dae5374
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 129 deletions.
146 changes: 37 additions & 109 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,8 @@ protected void processPacket(Packet packetIn) {
try {

Packet handledPacket = packetHandlerManager.handlePacket(packetIn, this);
pluginInstance.warning("Recieved: " + packetIn);

if (packetIn.isReturnable() && handledPacket != null) {
pluginInstance.warning("Sent: " + handledPacket);
sendDirect(handledPacket);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
import com.zulfen.zulfbungee.universal.socket.objects.Packet;

import java.util.Optional;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.TimeUnit;

public class BlockingPacketQueue {

private final Object shutdownFlag = new Object();
private final LinkedBlockingDeque<Object> blockingQueue = new LinkedBlockingDeque<>();
private final LinkedTransferQueue<Object> blockingQueue = new LinkedTransferQueue<>();

public void offer(Packet packet) {
blockingQueue.offerLast(packet);
try {
blockingQueue.transfer(packet);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}

public Optional<Packet> take(boolean poll) {
Expand Down Expand Up @@ -44,7 +48,7 @@ public Optional<Packet> take(boolean poll) {
}

public void notifyListeners() {
blockingQueue.offerLast(shutdownFlag);
blockingQueue.tryTransfer(shutdownFlag);
blockingQueue.clear();
}

Expand Down
15 changes: 11 additions & 4 deletions src/com/zulfen/zulfbungee/velocity/ZulfVelocityMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,28 @@ public class ZulfVelocityMain {

protected final static String VERSION = "0.9.9-pre4";
private final ProxyServer velocity;
private final ZulfVelocityPlugin plugin;
private final Logger logger;
private final Path dataDirectory;
private ZulfVelocityPlugin plugin;

private final MainServer<ProxyServer, Player> mainServer;
private MainServer<ProxyServer, Player> mainServer;

@Inject
public ZulfVelocityMain(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) {
this.velocity = server;
this.plugin = new ZulfVelocityPlugin(velocity, logger, dataDirectory, VERSION);
this.mainServer = plugin.getMainServer();
this.logger = logger;
this.dataDirectory = dataDirectory;
}

@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {

plugin = new ZulfVelocityPlugin(velocity, this, logger, dataDirectory, VERSION);
mainServer = plugin.getMainServer();

velocity.getEventManager().register(this, new VelocityEvents(mainServer));
velocity.getCommandManager().register("zulfbungee", new VelocityCommand(new CommandHandlerManager<>(mainServer)));

}

@Subscribe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.zulfen.zulfbungee.universal.managers.ProxyTaskManager;
import com.zulfen.zulfbungee.universal.socket.objects.proxy.ZulfProxyPlayer;
import com.zulfen.zulfbungee.universal.socket.objects.proxy.ZulfProxyServer;
import com.zulfen.zulfbungee.velocity.ZulfVelocityMain;
import com.zulfen.zulfbungee.velocity.command.VelocityConsole;
import com.zulfen.zulfbungee.velocity.config.VelocityConfig;
import com.zulfen.zulfbungee.velocity.objects.VelocityPlayer;
Expand Down Expand Up @@ -56,14 +57,14 @@ public Optional<ZulfProxyPlayer<ProxyServer, Player>> apply(Player nativePlayer)
.hexColors()
.build();

public ZulfVelocityImpl(ProxyServer proxyServerIn, Logger loggerIn, Path dataDirectoryIn, String versionIn) {
public ZulfVelocityImpl(ProxyServer proxyServerIn, ZulfVelocityMain pluginInstance, Logger loggerIn, Path dataDirectoryIn, String versionIn) {
this.velocity = proxyServerIn;
this.logger = loggerIn;
this.pluginFolderPath = dataDirectoryIn;
this.config = new VelocityConfig(this);
this.console = new VelocityConsole(this);
this.taskManager = new VelocityTaskManager(this);
this.taskManager = new VelocityTaskManager(this, pluginInstance);
this.isDebug = config.getBoolean("debug");
this.pluginFolderPath = dataDirectoryIn;
this.version = versionIn;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import com.zulfen.zulfbungee.universal.ZulfProxyPlugin;
import com.zulfen.zulfbungee.velocity.ZulfVelocityMain;
import org.slf4j.Logger;

import java.nio.file.Path;

public class ZulfVelocityPlugin extends ZulfProxyPlugin<ProxyServer, Player> {

public ZulfVelocityPlugin(ProxyServer proxyServerIn, Logger loggerIn, Path dataDirectoryIn, String versionIn) {
super(new ZulfVelocityImpl(proxyServerIn, loggerIn, dataDirectoryIn, versionIn));
public ZulfVelocityPlugin(ProxyServer proxyServerIn, ZulfVelocityMain pluginInstance, Logger loggerIn, Path dataDirectoryIn, String versionIn) {
super(new ZulfVelocityImpl(proxyServerIn, pluginInstance, loggerIn, dataDirectoryIn, versionIn));
}

}
11 changes: 6 additions & 5 deletions src/com/zulfen/zulfbungee/velocity/task/VelocityTaskManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@
import com.velocitypowered.api.scheduler.ScheduledTask;
import com.velocitypowered.api.scheduler.Scheduler;
import com.zulfen.zulfbungee.universal.managers.ProxyTaskManager;
import com.zulfen.zulfbungee.velocity.ZulfVelocityMain;
import com.zulfen.zulfbungee.velocity.interfaces.ZulfVelocityImpl;

import java.util.ArrayList;

public class VelocityTaskManager implements ProxyTaskManager {

private final ZulfVelocityImpl zulfVelocity;
private final ZulfVelocityMain pluginInstance;

private final Scheduler scheduler;

private final ArrayList<ScheduledTask> tasks = new ArrayList<>();

public VelocityTaskManager(ZulfVelocityImpl zulfVelocityIn) {
this.zulfVelocity = zulfVelocityIn;
this.scheduler = zulfVelocity.getPlatform().getScheduler();
public VelocityTaskManager(ZulfVelocityImpl zulfVelocityIn, ZulfVelocityMain pluginInstance) {
this.pluginInstance = pluginInstance;
this.scheduler = zulfVelocityIn.getPlatform().getScheduler();
}

@Override
public void newTask(Runnable taskIn) {
tasks.add(scheduler.buildTask(zulfVelocity, taskIn).schedule());
tasks.add(scheduler.buildTask(pluginInstance, taskIn).schedule());
}

@Override
Expand Down

0 comments on commit dae5374

Please sign in to comment.