Remove bungeecord messaging hook

It was the cause of many issues, as temp replacement server owners can
use AuthMeBridge.
This commit is contained in:
Gabriele C 2016-09-06 14:13:26 +02:00
parent 8327421dd4
commit 4a2ea7d372
6 changed files with 1 additions and 137 deletions

View File

@ -1,72 +0,0 @@
package fr.xephi.authme.hooks;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.util.BukkitService;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import javax.inject.Inject;
public class BungeeCordMessage implements PluginMessageListener {
@Inject
private DataSource dataSource;
@Inject
private BukkitService bukkitService;
@Inject
private PlayerCache playerCache;
BungeeCordMessage() { }
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!"BungeeCord".equals(channel)) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subChannel = in.readUTF();
if ("AuthMe".equalsIgnoreCase(subChannel)) {
String str = in.readUTF();
final String[] args = str.split(";");
final String act = args[0];
final String name = args[1];
bukkitService.runTaskAsynchronously(new Runnable() {
@Override
public void run() {
PlayerAuth auth = dataSource.getAuth(name);
if (auth == null) {
return;
}
if ("login".equals(act)) {
playerCache.updatePlayer(auth);
dataSource.setLogged(name);
ConsoleLogger.fine("Player " + auth.getNickname() + " has logged in from one of your server!");
} else if ("logout".equals(act)) {
playerCache.removePlayer(name);
dataSource.setUnlogged(name);
ConsoleLogger.fine("Player " + auth.getNickname() + " has logged out from one of your server!");
} else if ("register".equals(act)) {
ConsoleLogger.fine("Player " + auth.getNickname() + " has registered out from one of your server!");
} else if ("changepassword".equals(act)) {
final String password = args[2];
final String salt = args.length >= 4 ? args[3] : null;
auth.setPassword(new HashedPassword(password, salt));
playerCache.updatePlayer(auth);
dataSource.updatePassword(auth);
}
}
});
}
}
}

View File

@ -49,9 +49,6 @@ public class AsyncChangePassword implements AsynchronousProcess {
playerCache.updatePlayer(auth);
processService.send(player, MessageKey.PASSWORD_CHANGED_SUCCESS);
ConsoleLogger.info(player.getName() + " changed his password");
// Send a Bungee message for the password change
bungeeService.sendPasswordChanged(player, hashedPassword);
} else {
processService.send(player, MessageKey.WRONG_PASSWORD);
}

View File

@ -119,7 +119,6 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
// The Login event now fires (as intended) after everything is processed
bukkitService.callEvent(new LoginEvent(player));
player.saveData();
bungeeService.sendBungeeMessage(player, "login");
// Login is done, display welcome message
if (service.getProperty(RegistrationSettings.USE_WELCOME_MESSAGE)) {

View File

@ -64,8 +64,6 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
// Player is now logout... Time to fire event !
bukkitService.callEvent(new LogoutEvent(player));
// Send Bungee stuff. The service will check if it is enabled or not.
bungeeService.sendBungeeMessage(player, "logout");
service.send(player, MessageKey.LOGOUT_SUCCESS);
ConsoleLogger.info(player.getName() + " logged out");

View File

@ -92,7 +92,6 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
}
// Send Bungee stuff. The service will check if it is enabled or not.
bungeeService.sendBungeeMessage(player, "register");
bungeeService.connectPlayer(player);
}
}

View File

@ -3,13 +3,9 @@ package fr.xephi.authme.service;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.hooks.BungeeCordMessage;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.util.BukkitService;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.Messenger;
@ -21,8 +17,6 @@ import javax.inject.Inject;
public class BungeeService implements SettingsDependent {
private AuthMe plugin;
private BukkitService bukkitService;
private BungeeCordMessage bungeeCordMessage;
private boolean isEnabled;
private String bungeeServer;
@ -31,59 +25,11 @@ public class BungeeService implements SettingsDependent {
* Constructor.
*/
@Inject
BungeeService(AuthMe plugin, BukkitService bukkitService, Settings settings, BungeeCordMessage bungeeCordMessage) {
BungeeService(AuthMe plugin, Settings settings) {
this.plugin = plugin;
this.bukkitService = bukkitService;
this.bungeeCordMessage = bungeeCordMessage;
reload(settings);
}
/**
* Sends a Bungee message to a player, e.g. login.
*
* @param player The player to send the message to.
* @param action The action to send, e.g. login.
*/
public void sendBungeeMessage(Player player, String action) {
if (!isEnabled) {
return;
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Forward");
out.writeUTF("ALL");
out.writeUTF("AuthMe");
out.writeUTF(action + ";" + player.getName());
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
}
/**
* Send a Bungee message for a password change.
*
* @param player The player who's password is changed.
* @param password The new password.
*/
public void sendPasswordChanged(final Player player, HashedPassword password) {
if (!isEnabled) {
return;
}
final String hash = password.getHash();
final String salt = password.getSalt();
bukkitService.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Forward");
out.writeUTF("ALL");
out.writeUTF("AuthMe");
out.writeUTF("changepassword;" + player.getName() + ";" + hash + ";" + salt);
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
}
});
}
/**
* Send a player to a specified server. If no server is configured, this will
* do nothing.
@ -109,9 +55,6 @@ public class BungeeService implements SettingsDependent {
if (!this.isEnabled) {
return;
}
if (!messenger.isIncomingChannelRegistered(plugin, "BungeeCord")) {
messenger.registerIncomingPluginChannel(plugin, "BungeeCord", bungeeCordMessage);
}
if (!messenger.isOutgoingChannelRegistered(plugin, "BungeeCord")) {
messenger.registerOutgoingPluginChannel(plugin, "BungeeCord");
}