Schedule connectPlayer action

Thanks to @Dimatert9
This commit is contained in:
Gabriele C 2017-03-31 20:27:04 +02:00
parent 20ab161406
commit 9381d024cd

View File

@ -17,6 +17,7 @@ import javax.inject.Inject;
public class BungeeService implements SettingsDependent {
private AuthMe plugin;
private BukkitService service;
private boolean isEnabled;
private String bungeeServer;
@ -25,8 +26,9 @@ public class BungeeService implements SettingsDependent {
* Constructor.
*/
@Inject
BungeeService(AuthMe plugin, Settings settings) {
BungeeService(AuthMe plugin, BukkitService service, Settings settings) {
this.plugin = plugin;
this.service = service;
reload(settings);
}
@ -41,10 +43,15 @@ public class BungeeService implements SettingsDependent {
return;
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(bungeeServer);
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
service.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(bungeeServer);
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
}
}, 5L);
}
@Override