Skip to content

Commit

Permalink
minor, ensure packet_handler channel is loaded before injecting playe…
Browse files Browse the repository at this point in the history
…r channel
  • Loading branch information
ds58 committed Jun 9, 2019
1 parent d02b0cb commit bd115af
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ public interface IPanillaPlatform {

Logger getLogger();

void runTaskLater(long delay, Runnable task);

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.ruinscraft.panilla.api.IPanillaPlayer;
import io.netty.channel.Channel;

import java.util.concurrent.TimeUnit;

public interface IPlayerInjector {

String CHANNEL_HANDLER_MINECRAFT = "packet_handler";
Expand All @@ -19,8 +21,10 @@ default void register(IPanilla panilla, IPanillaPlayer player) {
if (channel.pipeline().get(CHANNEL_HANDLER_MINECRAFT) != null) {
channel.pipeline().addBefore(CHANNEL_HANDLER_MINECRAFT, CHANNEL_HANDLER_PANILLA, channelHandler);
} else {
panilla.getPlatform().getLogger().warning(
"Could not find Minecraft Netty channel: " + CHANNEL_HANDLER_MINECRAFT + ". Please report this as a bug.");
// try again later, server was likely booting up
panilla.getPlatform().runTaskLater(TimeUnit.SECONDS.toMillis(10), () -> {
register(panilla, player);
});
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ public Collection<IPanillaPlayer> getOnlinePlayers() {
return panillaPlayers;
}

@Override
public void runTaskLater(long delay, Runnable task) {
getServer().getScheduler().runTaskLater(this, task, delay);
}

private synchronized void loadConfig() throws IOException {
PFiles.saveResource("config.yml", getDataFolder());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ public Logger getLogger() {
return logger;
}

@Override
public void runTaskLater(long delay, Runnable task) {
// TODO:
}

private synchronized void loadConfig() {
// TODO:
}
Expand Down

0 comments on commit bd115af

Please sign in to comment.