This commit is contained in:
sgdc3 2017-11-20 13:15:20 +01:00
parent f23b8933ac
commit 3ca97f5d30
2 changed files with 14 additions and 5 deletions

View File

@ -1,5 +1,6 @@
package fr.xephi.authme.service;
import com.google.common.collect.Iterables;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.initialization.SettingsDependent;
@ -331,6 +332,18 @@ public class BukkitService implements SettingsDependent {
useAsyncTasks = settings.getProperty(PluginSettings.USE_ASYNC_TASKS);
}
/**
* Send the specified message to bungeecord using the first available player connection.
*
* @param bytes the message
*/
public void sendBungeeMessage(byte[] bytes) {
Player player = Iterables.getFirst(getOnlinePlayers(), null);
if (player != null) {
player.sendPluginMessage(authMe, "BungeeCord", bytes);
}
}
/**
* Method run upon initialization to verify whether or not the Bukkit implementation
* returns the online players as a {@link Collection}.

View File

@ -1,6 +1,5 @@
package fr.xephi.authme.service.bungeecord;
import com.google.common.collect.Iterables;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import fr.xephi.authme.AuthMe;
@ -53,10 +52,7 @@ public class BungeeSender implements SettingsDependent {
for (String element : data) {
out.writeUTF(element);
}
Player player = Iterables.getFirst(plugin.getServer().getOnlinePlayers(), null);
if (player != null) {
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
}
bukkitService.sendBungeeMessage(out.toByteArray());
}
/**