forked from TuxCoding/FastLogin
Added support for the configuration options under BungeeCord
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
######1.1
|
||||||
|
|
||||||
|
* Make the configuration options also work under BungeeCord (premiumUUID, forwardSkin)
|
||||||
|
|
||||||
######1.0
|
######1.0
|
||||||
|
|
||||||
* Massive refactor to handle errors on force actions safely
|
* Massive refactor to handle errors on force actions safely
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.github.games647</groupId>
|
<groupId>com.github.games647</groupId>
|
||||||
<artifactId>fastlogin</artifactId>
|
<artifactId>fastlogin</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.1</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.github.games647</groupId>
|
<groupId>com.github.games647</groupId>
|
||||||
<artifactId>fastlogin</artifactId>
|
<artifactId>fastlogin</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.1</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -13,8 +13,9 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import net.md_5.bungee.api.connection.PendingConnection;
|
|
||||||
|
|
||||||
|
import net.md_5.bungee.Util;
|
||||||
|
import net.md_5.bungee.api.connection.PendingConnection;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.md_5.bungee.config.Configuration;
|
import net.md_5.bungee.config.Configuration;
|
||||||
import net.md_5.bungee.config.ConfigurationProvider;
|
import net.md_5.bungee.config.ConfigurationProvider;
|
||||||
@ -25,17 +26,13 @@ import net.md_5.bungee.config.YamlConfiguration;
|
|||||||
*/
|
*/
|
||||||
public class FastLoginBungee extends Plugin {
|
public class FastLoginBungee extends Plugin {
|
||||||
|
|
||||||
public static UUID parseId(String withoutDashes) {
|
|
||||||
return UUID.fromString(withoutDashes.substring(0, 8)
|
|
||||||
+ "-" + withoutDashes.substring(8, 12)
|
|
||||||
+ "-" + withoutDashes.substring(12, 16)
|
|
||||||
+ "-" + withoutDashes.substring(16, 20)
|
|
||||||
+ "-" + withoutDashes.substring(20, 32));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final char[] CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
private static final char[] CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
.toCharArray();
|
.toCharArray();
|
||||||
|
|
||||||
|
public static UUID parseId(String withoutDashes) {
|
||||||
|
return Util.getUUID(withoutDashes);
|
||||||
|
}
|
||||||
|
|
||||||
private BungeeAuthPlugin bungeeAuthPlugin;
|
private BungeeAuthPlugin bungeeAuthPlugin;
|
||||||
private final MojangApiConnector mojangApiConnector = new MojangApiConnector(this);
|
private final MojangApiConnector mojangApiConnector = new MojangApiConnector(this);
|
||||||
private Storage storage;
|
private Storage storage;
|
||||||
|
@ -30,7 +30,7 @@ public class ForceLoginTask implements Runnable {
|
|||||||
BungeeAuthPlugin authPlugin = plugin.getBungeeAuthPlugin();
|
BungeeAuthPlugin authPlugin = plugin.getBungeeAuthPlugin();
|
||||||
if (authPlugin == null) {
|
if (authPlugin == null) {
|
||||||
sendBukkitLoginNotification(autoRegister);
|
sendBukkitLoginNotification(autoRegister);
|
||||||
} else {
|
} else if (player.isConnected()) {
|
||||||
if (autoRegister) {
|
if (autoRegister) {
|
||||||
String password = plugin.generateStringPassword();
|
String password = plugin.generateStringPassword();
|
||||||
if (authPlugin.forceRegister(player, password)) {
|
if (authPlugin.forceRegister(player, password)) {
|
||||||
@ -66,6 +66,8 @@ public class ForceLoginTask implements Runnable {
|
|||||||
dataOutput.writeLong(proxyId.getLeastSignificantBits());
|
dataOutput.writeLong(proxyId.getLeastSignificantBits());
|
||||||
|
|
||||||
Server server = player.getServer();
|
Server server = player.getServer();
|
||||||
server.sendData(plugin.getDescription().getName(), dataOutput.toByteArray());
|
if (server != null) {
|
||||||
|
server.sendData(plugin.getDescription().getName(), dataOutput.toByteArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.github.games647.fastlogin.bungee;
|
package com.github.games647.fastlogin.bungee;
|
||||||
|
|
||||||
import com.github.games647.fastlogin.bungee.hooks.BungeeAuthPlugin;
|
import com.github.games647.fastlogin.bungee.hooks.BungeeAuthPlugin;
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@ -14,9 +16,13 @@ import net.md_5.bungee.api.connection.PendingConnection;
|
|||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.connection.Server;
|
import net.md_5.bungee.api.connection.Server;
|
||||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
import net.md_5.bungee.api.event.PreLoginEvent;
|
import net.md_5.bungee.api.event.PreLoginEvent;
|
||||||
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
|
import net.md_5.bungee.connection.InitialHandler;
|
||||||
|
import net.md_5.bungee.connection.LoginResult;
|
||||||
|
import net.md_5.bungee.connection.LoginResult.Property;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,6 +80,42 @@ public class PlayerConnectionListener implements Listener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onLogin(PostLoginEvent loginEvent) {
|
||||||
|
ProxiedPlayer player = loginEvent.getPlayer();
|
||||||
|
PendingConnection connection = player.getPendingConnection();
|
||||||
|
String username = connection.getName();
|
||||||
|
if (connection.isOnlineMode()) {
|
||||||
|
PlayerProfile playerProfile = plugin.getStorage().getProfile(player.getName(), false);
|
||||||
|
playerProfile.setUuid(player.getUniqueId());
|
||||||
|
|
||||||
|
//bungeecord will do this automatically so override it on disabled option
|
||||||
|
InitialHandler initialHandler = (InitialHandler) connection;
|
||||||
|
if (!plugin.getConfiguration().getBoolean("premiumUuid")) {
|
||||||
|
try {
|
||||||
|
UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(Charsets.UTF_8));
|
||||||
|
|
||||||
|
Field idField = initialHandler.getClass().getDeclaredField("uniqueId");
|
||||||
|
idField.setAccessible(true);
|
||||||
|
idField.set(connection, offlineUUID);
|
||||||
|
|
||||||
|
//bungeecord doesn't support overriding the premium uuid
|
||||||
|
// connection.setUniqueId(offlineUUID);
|
||||||
|
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||||
|
plugin.getLogger().log(Level.SEVERE, "Failed to set offline uuid", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin.getConfiguration().getBoolean("forwardSkin")) {
|
||||||
|
//this is null on offline mode
|
||||||
|
LoginResult loginProfile = initialHandler.getLoginProfile();
|
||||||
|
if (loginProfile != null) {
|
||||||
|
loginProfile.setProperties(new Property[]{});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onServerConnected(ServerConnectedEvent serverConnectedEvent) {
|
public void onServerConnected(ServerConnectedEvent serverConnectedEvent) {
|
||||||
ProxiedPlayer player = serverConnectedEvent.getPlayer();
|
ProxiedPlayer player = serverConnectedEvent.getPlayer();
|
||||||
@ -145,7 +187,8 @@ public class PlayerConnectionListener implements Listener {
|
|||||||
//update only on success to prevent corrupt data
|
//update only on success to prevent corrupt data
|
||||||
PlayerProfile playerProfile = plugin.getStorage().getProfile(forPlayer.getName(), false);
|
PlayerProfile playerProfile = plugin.getStorage().getProfile(forPlayer.getName(), false);
|
||||||
playerProfile.setPremium(true);
|
playerProfile.setPremium(true);
|
||||||
playerProfile.setUuid(forPlayer.getUniqueId());
|
//we override this in the loginevent
|
||||||
|
// playerProfile.setUuid(forPlayer.getUniqueId());
|
||||||
plugin.getStorage().save(playerProfile);
|
plugin.getStorage().save(playerProfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
pom.xml
2
pom.xml
@ -8,7 +8,7 @@
|
|||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>FastLogin</name>
|
<name>FastLogin</name>
|
||||||
<version>1.0</version>
|
<version>1.1</version>
|
||||||
<inceptionYear>2015</inceptionYear>
|
<inceptionYear>2015</inceptionYear>
|
||||||
<url>https://www.spigotmc.org/resources/fastlogin.14153/</url>
|
<url>https://www.spigotmc.org/resources/fastlogin.14153/</url>
|
||||||
<description>
|
<description>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.github.games647</groupId>
|
<groupId>com.github.games647</groupId>
|
||||||
<artifactId>fastlogin</artifactId>
|
<artifactId>fastlogin</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.1</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user