Bungee message update, whatever.
This commit is contained in:
@@ -6,7 +6,7 @@ import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
|
||||
import fr.xephi.authme.datasource.CacheDataSource;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
@@ -35,8 +35,7 @@ public class BungeeCordMessage implements PluginMessageListener {
|
||||
* @see org.bukkit.plugin.messaging.PluginMessageListener#onPluginMessageReceived(String, Player, byte[])
|
||||
*/
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player,
|
||||
byte[] message) {
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
if (!channel.equals("BungeeCord")) {
|
||||
return;
|
||||
}
|
||||
@@ -47,36 +46,28 @@ public class BungeeCordMessage implements PluginMessageListener {
|
||||
// Put the IP (only the ip not the port) in the hashMap
|
||||
plugin.realIp.put(player.getName().toLowerCase(), ip);
|
||||
}
|
||||
if (subChannel.equals("Forward") || subChannel.equalsIgnoreCase("AuthMe"))
|
||||
{
|
||||
short len = in.readShort();
|
||||
byte[] data = new byte[len];
|
||||
in.readFully(data);
|
||||
|
||||
//bytearray to string
|
||||
String str = new String(data);
|
||||
if (!str.startsWith("AuthMe"))
|
||||
return;
|
||||
String[] args = str.split(";");
|
||||
try {
|
||||
String name = args[2];
|
||||
PlayerAuth auth = plugin.database.getAuth(name);
|
||||
if (auth == null)
|
||||
return;
|
||||
if (args[1].equalsIgnoreCase("login"))
|
||||
{
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
plugin.database.setLogged(name);
|
||||
ConsoleLogger.info("Player " + auth.getNickname() + " has logged in from one of your server!");
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("logout"))
|
||||
{
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
plugin.database.setUnlogged(name);
|
||||
ConsoleLogger.info("Player " + auth.getNickname() + " has logged out from one of your server!");
|
||||
}
|
||||
} catch (Exception e)
|
||||
{}
|
||||
if (subChannel.equalsIgnoreCase("AuthMe")) {
|
||||
String str = in.readUTF();
|
||||
String[] args = str.split(";");
|
||||
String name = args[1];
|
||||
PlayerAuth auth = plugin.database.getAuth(name);
|
||||
if (auth == null) {
|
||||
return;
|
||||
}
|
||||
if ("login".equals(args[0])) {
|
||||
PlayerCache.getInstance().updatePlayer(auth);
|
||||
plugin.database.setLogged(name);
|
||||
ConsoleLogger.info("Player " + auth.getNickname() + " has logged in from one of your server!");
|
||||
} else if ("logout".equals(args[0])) {
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
plugin.database.setUnlogged(name);
|
||||
ConsoleLogger.info("Player " + auth.getNickname() + " has logged out from one of your server!");
|
||||
} else if ("register".equals(args[0])) {
|
||||
if (plugin.database instanceof CacheDataSource) {
|
||||
((CacheDataSource)plugin.database).addAuthToCache(auth);
|
||||
}
|
||||
ConsoleLogger.info("Player " + auth.getNickname() + " has registered out from one of your server!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user