mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-26 10:37:39 +01:00
add features to our API #943
+ add getRegisteredNames() and getRegisteredRealNames() methods + add a new and more clear way to get the API instance
This commit is contained in:
parent
ffc5b77f36
commit
25df3ce032
@ -119,6 +119,15 @@ public class AuthMe extends JavaPlugin {
|
||||
return pluginBuildNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to obtain the plugin's api instance
|
||||
*
|
||||
* @return The plugin's api instance
|
||||
*/
|
||||
public static NewAPI getApi() {
|
||||
return NewAPI.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called when the server enables the plugin.
|
||||
*/
|
||||
|
@ -14,11 +14,13 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The current API of AuthMe. Recommended method of retrieving the API object:
|
||||
* <code>
|
||||
* NewAPI authmeApi = NewAPI.getInstance();
|
||||
* NewAPI authmeApi = AuthMe.getApi();
|
||||
* </code>
|
||||
*/
|
||||
public class NewAPI {
|
||||
@ -218,4 +220,26 @@ public class NewAPI {
|
||||
public void forceUnregister(Player player) {
|
||||
management.performUnregisterByAdmin(null, player.getName(), player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the registered names (lowercase)
|
||||
*
|
||||
* @return registered names
|
||||
*/
|
||||
public List<String> getRegisteredNames() {
|
||||
List<String> registeredNames = new ArrayList<>();
|
||||
dataSource.getAllAuths().forEach(auth -> registeredNames.add(auth.getNickname()));
|
||||
return registeredNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the registered real-names (original case)
|
||||
*
|
||||
* @return registered real-names
|
||||
*/
|
||||
public List<String> getRegisteredRealNames() {
|
||||
List<String> registeredNames = new ArrayList<>();
|
||||
dataSource.getAllAuths().forEach(auth -> registeredNames.add(auth.getRealName()));
|
||||
return registeredNames;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user