mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-19 22:33:48 -07:00
Added pre-login event for catching logins right after name verification has completed. This happens in a different thread from the server (and thus can also block).
By: sk89q <the.sk89q@gmail.com>
This commit is contained in:
@@ -75,8 +75,10 @@ public final class SimplePluginManager implements PluginManager {
|
||||
|
||||
Pattern[] patterns = instance.getPluginFileFilters();
|
||||
|
||||
for (Pattern pattern : patterns) {
|
||||
fileAssociations.put(pattern, instance);
|
||||
synchronized (this) {
|
||||
for (Pattern pattern : patterns) {
|
||||
fileAssociations.put(pattern, instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +147,7 @@ public final class SimplePluginManager implements PluginManager {
|
||||
* @throws InvalidPluginException Thrown when the specified file is not a valid plugin
|
||||
* @throws InvalidDescriptionException Thrown when the specified file contains an invalid description
|
||||
*/
|
||||
public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException {
|
||||
public synchronized Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException {
|
||||
Set<Pattern> filters = fileAssociations.keySet();
|
||||
Plugin result = null;
|
||||
|
||||
@@ -175,11 +177,11 @@ public final class SimplePluginManager implements PluginManager {
|
||||
* @param name Name of the plugin to check
|
||||
* @return Plugin if it exists, otherwise null
|
||||
*/
|
||||
public Plugin getPlugin(String name) {
|
||||
public synchronized Plugin getPlugin(String name) {
|
||||
return lookupNames.get(name);
|
||||
}
|
||||
|
||||
public Plugin[] getPlugins() {
|
||||
public synchronized Plugin[] getPlugins() {
|
||||
return plugins.toArray(new Plugin[0]);
|
||||
}
|
||||
|
||||
@@ -246,7 +248,7 @@ public final class SimplePluginManager implements PluginManager {
|
||||
* @param type Type of player related event to call
|
||||
* @param event Event details
|
||||
*/
|
||||
public void callEvent(Event event) {
|
||||
public synchronized void callEvent(Event event) {
|
||||
SortedSet<RegisteredListener> eventListeners = listeners.get(event.getType());
|
||||
|
||||
if (eventListeners != null) {
|
||||
|
@@ -258,6 +258,12 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
((PlayerListener) listener).onPlayerLogin((PlayerLoginEvent) event);
|
||||
}
|
||||
};
|
||||
case PLAYER_PRELOGIN:
|
||||
return new EventExecutor() {
|
||||
public void execute(Listener listener, Event event) {
|
||||
((PlayerListener) listener).onPlayerPreLogin((PlayerPreLoginEvent) event);
|
||||
}
|
||||
};
|
||||
case PLAYER_EGG_THROW:
|
||||
return new EventExecutor() {
|
||||
public void execute(Listener listener, Event event) {
|
||||
|
Reference in New Issue
Block a user