Archiviert
13
0

Don't throw a NullPointerException if the injection fails.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-02-26 19:14:40 +01:00
Ursprung 3357fd6c9c
Commit 56807cbd3a
2 geänderte Dateien mit 16 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -78,11 +78,14 @@ class NetLoginInjector {
// This is the case if we're dealing with a connection initiated by the injected server socket // This is the case if we're dealing with a connection initiated by the injected server socket
if (socketInjector != null) { if (socketInjector != null) {
PlayerInjector injector = injectionHandler.injectPlayer(socketInjector.getPlayer(), inserting, GamePhase.LOGIN); PlayerInjector injector = injectionHandler.injectPlayer(socketInjector.getPlayer(), inserting, GamePhase.LOGIN);
if (injector != null) {
injector.updateOnLogin = true; injector.updateOnLogin = true;
// Save the login // Save the login
injectedLogins.putIfAbsent(inserting, injector); injectedLogins.putIfAbsent(inserting, injector);
} }
}
// NetServerInjector can never work (currently), so we don't need to replace the NetLoginHandler // NetServerInjector can never work (currently), so we don't need to replace the NetLoginHandler
return inserting; return inserting;
@ -90,7 +93,7 @@ class NetLoginInjector {
} catch (Throwable e) { } catch (Throwable e) {
// Minecraft can't handle this, so we'll deal with it here // Minecraft can't handle this, so we'll deal with it here
reporter.reportDetailed(this, "Unable to hook " + reporter.reportDetailed(this, "Unable to hook " +
MinecraftReflection.getNetLoginHandlerName() + ".", e, inserting); MinecraftReflection.getNetLoginHandlerName() + ".", e, inserting, injectionHandler);
return inserting; return inserting;
} }
} }

Datei anzeigen

@ -269,6 +269,13 @@ class ProxyPlayerInjectionHandler implements PlayerInjectionHandler {
* @return The resulting player injector, or NULL if the injection failed. * @return The resulting player injector, or NULL if the injection failed.
*/ */
PlayerInjector injectPlayer(Player player, Object injectionPoint, GamePhase phase) { PlayerInjector injectPlayer(Player player, Object injectionPoint, GamePhase phase) {
if (player == null)
throw new IllegalArgumentException("Player cannot be NULL.");
if (injectionPoint == null)
throw new IllegalArgumentException("injectionPoint cannot be NULL.");
if (phase == null)
throw new IllegalArgumentException("phase cannot be NULL.");
// Unfortunately, due to NetLoginHandler, multiple threads may potentially call this method. // Unfortunately, due to NetLoginHandler, multiple threads may potentially call this method.
synchronized (player) { synchronized (player) {
return injectPlayerInternal(player, injectionPoint, phase); return injectPlayerInternal(player, injectionPoint, phase);
@ -288,7 +295,7 @@ class ProxyPlayerInjectionHandler implements PlayerInjectionHandler {
boolean invalidInjector = injector != null ? !injector.canInject(phase) : true; boolean invalidInjector = injector != null ? !injector.canInject(phase) : true;
// Don't inject if the class has closed // Don't inject if the class has closed
if (!hasClosed && player != null && (tempHook != getInjectorType(injector) || invalidInjector)) { if (!hasClosed && (tempHook != getInjectorType(injector) || invalidInjector)) {
while (tempHook != PlayerInjectHooks.NONE) { while (tempHook != PlayerInjectHooks.NONE) {
// Whether or not the current hook method failed completely // Whether or not the current hook method failed completely
boolean hookFailed = false; boolean hookFailed = false;