Added API methods for auth plugins to set their own hook

This commit is contained in:
games647
2016-05-14 12:27:03 +02:00
parent 59703bac4e
commit e439126294
9 changed files with 41 additions and 8 deletions

View File

@ -1,3 +1,8 @@
######1.2
* Added API methods for plugins to set their own password generator
* Added API methods for plugins to set their own auth plugin hook
######1.1
* Make the configuration options also work under BungeeCord (premiumUUID, forwardSkin)

View File

@ -5,7 +5,7 @@
<parent>
<groupId>com.github.games647</groupId>
<artifactId>fastlogin</artifactId>
<version>1.1</version>
<version>1.2</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -0,0 +1,12 @@
package com.github.games647.fastlogin.bukkit;
import org.apache.commons.lang.RandomStringUtils;
import org.bukkit.entity.Player;
public class DefaultPasswordGenerator implements PasswordGenerator {
@Override
public String getRandomPassword(Player player) {
return RandomStringUtils.random(8, true, true);
}
}

View File

@ -25,7 +25,6 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import org.apache.commons.lang.RandomStringUtils;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
@ -69,6 +68,7 @@ public class FastLoginBukkit extends JavaPlugin {
private BukkitAuthPlugin authPlugin;
private final MojangApiConnector mojangApiConnector = new MojangApiConnector(this);
private PasswordGenerator passwordGenerator = new DefaultPasswordGenerator();
@Override
public void onEnable() {
@ -166,8 +166,12 @@ public class FastLoginBukkit extends JavaPlugin {
}
}
public String generateStringPassword() {
return RandomStringUtils.random(8, true, true);
public String generateStringPassword(Player player) {
return passwordGenerator.getRandomPassword(player);
}
public void setPasswordGenerator(PasswordGenerator passwordGenerator) {
this.passwordGenerator = passwordGenerator;
}
/**
@ -203,6 +207,10 @@ public class FastLoginBukkit extends JavaPlugin {
return authPlugin;
}
public void setAuthPluginHook(BukkitAuthPlugin authPlugin) {
this.authPlugin = authPlugin;
}
/**
* Gets the a connection in order to access important features from the Mojang API.
*

View File

@ -82,7 +82,7 @@ public class ForceLoginTask implements Runnable {
private boolean forceRegister(BukkitAuthPlugin authPlugin, Player player) {
plugin.getLogger().log(Level.FINE, "Register player {0}", player.getName());
String generatedPassword = plugin.generateStringPassword();
String generatedPassword = plugin.generateStringPassword(player);
boolean success = authPlugin.forceRegister(player, generatedPassword);
player.sendMessage(ChatColor.DARK_GREEN + "Auto registered with password: " + generatedPassword);
player.sendMessage(ChatColor.DARK_GREEN + "You may want change it?");

View File

@ -0,0 +1,8 @@
package com.github.games647.fastlogin.bukkit;
import org.bukkit.entity.Player;
public interface PasswordGenerator {
String getRandomPassword(Player player);
}

View File

@ -5,7 +5,7 @@
<parent>
<groupId>com.github.games647</groupId>
<artifactId>fastlogin</artifactId>
<version>1.1</version>
<version>1.2</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -8,7 +8,7 @@
<packaging>pom</packaging>
<name>FastLogin</name>
<version>1.1</version>
<version>1.2</version>
<inceptionYear>2015</inceptionYear>
<url>https://www.spigotmc.org/resources/fastlogin.14153/</url>
<description>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>com.github.games647</groupId>
<artifactId>fastlogin</artifactId>
<version>1.1</version>
<version>1.2</version>
<relativePath>../pom.xml</relativePath>
</parent>