[DEV] [NEED TEST] BungeeCord

Add a way to send player login on other AuthMe instance through
BungeeCord plugin channel
This commit is contained in:
Xephi
2015-12-10 18:31:46 +01:00
parent 9c86fbd8bf
commit d01713a2f5
3 changed files with 69 additions and 1 deletions
@@ -14,6 +14,10 @@ import fr.xephi.authme.listener.AuthMePlayerListener;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.Utils;
import fr.xephi.authme.util.Utils.GroupType;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -113,6 +117,21 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
}
}
protected void sendBungeeMessage() {
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
String str = "AuthMe;login;" + name;
out.writeUTF("Forward");
out.writeUTF("ALL");
out.writeUTF("AuthMe");
out.writeShort(str.length());
out.writeUTF(str);
player.sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
} catch (Exception e)
{}
}
/**
* Method run.
*
@@ -186,7 +205,8 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
// The Login event now fires (as intended) after everything is processed
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
player.saveData();
if (Settings.bungee)
sendBungeeMessage();
// Login is finish, display welcome message
if (Settings.useWelcomeMessage)
if (Settings.broadcastWelcomeMessage) {
@@ -9,6 +9,10 @@ import fr.xephi.authme.output.Messages;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
@@ -38,6 +42,21 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
this.name = player.getName().toLowerCase();
}
protected void sendBungeeMessage() {
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
String str = "AuthMe;login;" + name;
out.writeUTF("Forward");
out.writeUTF("ALL");
out.writeUTF("AuthMe");
out.writeShort(str.length());
out.writeUTF(str);
player.sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
} catch (Exception e)
{}
}
/**
* Method run.
*
@@ -76,6 +95,8 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
}
// Player is now logout... Time to fire event !
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
if (Settings.bungee)
sendBungeeMessage();
m.send(player, MessageKey.LOGOUT_SUCCESS);
ConsoleLogger.info(player.getName() + " logged out");
}