mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-03-11 06:01:32 +01:00
Bungee message update, whatever.
This commit is contained in:
parent
1ecee76b60
commit
cd1c861b47
@ -49,6 +49,10 @@ public class CacheDataSource implements DataSource {
|
||||
});
|
||||
}
|
||||
|
||||
public void addAuthToCache(PlayerAuth auth) {
|
||||
cache.put(auth.getNickname().toLowerCase(), auth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
*
|
||||
|
@ -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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package fr.xephi.authme.process.login;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.backup.JsonCache;
|
||||
@ -14,16 +16,12 @@ 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 org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
@ -118,17 +116,12 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
}
|
||||
|
||||
protected void sendBungeeMessage() {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
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", out.toByteArray());
|
||||
} catch (Exception e)
|
||||
{}
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Forward");
|
||||
out.writeUTF("ALL");
|
||||
out.writeUTF("AuthMe");
|
||||
out.writeUTF("login;" + name);
|
||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -205,7 +198,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
|
||||
player.saveData();
|
||||
if (Settings.bungee)
|
||||
sendBungeeMessage();
|
||||
sendBungeeMessage();
|
||||
// Login is finish, display welcome message
|
||||
if (Settings.useWelcomeMessage)
|
||||
if (Settings.broadcastWelcomeMessage) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package fr.xephi.authme.process.logout;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
@ -9,7 +11,6 @@ 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 org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@ -17,9 +18,6 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ProcessSyncronousPlayerLogout implements Runnable {
|
||||
@ -43,17 +41,12 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
||||
}
|
||||
|
||||
protected void sendBungeeMessage() {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
try {
|
||||
String str = "AuthMe;logout;" + name;
|
||||
out.writeUTF("Forward");
|
||||
out.writeUTF("ALL");
|
||||
out.writeUTF("AuthMe");
|
||||
out.writeShort(str.length());
|
||||
out.writeUTF(str);
|
||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||
} catch (Exception e)
|
||||
{}
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Forward");
|
||||
out.writeUTF("ALL");
|
||||
out.writeUTF("AuthMe");
|
||||
out.writeUTF("logout;" + name);
|
||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +88,7 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
||||
// Player is now logout... Time to fire event !
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
|
||||
if (Settings.bungee)
|
||||
sendBungeeMessage();
|
||||
sendBungeeMessage();
|
||||
m.send(player, MessageKey.LOGOUT_SUCCESS);
|
||||
ConsoleLogger.info(player.getName() + " logged out");
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public class AsyncRegister {
|
||||
database.setLogged(name);
|
||||
}
|
||||
plugin.otherAccounts.addPlayer(player.getUniqueId());
|
||||
ProcessSyncronousPasswordRegister sync = new ProcessSyncronousPasswordRegister(player, plugin);
|
||||
ProcessSyncPasswordRegister sync = new ProcessSyncPasswordRegister(player, plugin);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, sync);
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +64,9 @@ public class ProcessSyncEmailRegister implements Runnable {
|
||||
}
|
||||
|
||||
player.saveData();
|
||||
if (!Settings.noConsoleSpam)
|
||||
if (!Settings.noConsoleSpam) {
|
||||
ConsoleLogger.info(player.getName() + " registered " + plugin.getIP(player));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package fr.xephi.authme.process.register;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
@ -21,7 +23,7 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
public class ProcessSyncPasswordRegister implements Runnable {
|
||||
|
||||
protected final Player player;
|
||||
protected final String name;
|
||||
@ -29,18 +31,27 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
private final Messages m;
|
||||
|
||||
/**
|
||||
* Constructor for ProcessSyncronousPasswordRegister.
|
||||
* Constructor for ProcessSyncPasswordRegister.
|
||||
*
|
||||
* @param player Player
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public ProcessSyncronousPasswordRegister(Player player, AuthMe plugin) {
|
||||
public ProcessSyncPasswordRegister(Player player, AuthMe plugin) {
|
||||
this.m = plugin.getMessages();
|
||||
this.player = player;
|
||||
this.name = player.getName().toLowerCase();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private void sendBungeeMessage() {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Forward");
|
||||
out.writeUTF("ALL");
|
||||
out.writeUTF("AuthMe");
|
||||
out.writeUTF("register;" + name);
|
||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||
}
|
||||
|
||||
private void forceCommands() {
|
||||
for (String command : Settings.forceRegisterCommands) {
|
||||
player.performCommand(command.replace("%p", player.getName()));
|
||||
@ -155,6 +166,10 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.bungee) {
|
||||
sendBungeeMessage();
|
||||
}
|
||||
|
||||
// Register is now finish , we can force all commands
|
||||
forceCommands();
|
||||
}
|
Loading…
Reference in New Issue
Block a user