Skip to content

Commit

Permalink
Cut down on calls to session service (closes #568)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveyBiggers committed Jul 7, 2017
1 parent 387be4c commit 70ef288
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
import com.microsoft.Malmo.Utils.TCPSocket;
import com.microsoft.Malmo.Utils.TCPUtils;
import com.microsoft.Malmo.Utils.TimeHelper;
import com.mojang.authlib.properties.Property;

/**
* Class designed to track and control the state of the mod, especially regarding mission launching/running.<br>
Expand Down Expand Up @@ -850,7 +851,11 @@ protected void execute() throws Exception
List<AgentSection> agents = currentMissionInit().getMission().getAgentSection();
String agentName = agents.get(currentMissionInit().getClientRole()).getName();
AuthenticationHelper.setPlayerName(Minecraft.getMinecraft().getSession(), agentName);

// If the player's profile properties are empty, MC will keep pinging the Minecraft session service
// to fill them, resulting in multiple http requests and grumpy responses from the server
// (see https://github.com/Microsoft/malmo/issues/568).
// To prevent this, we add a dummy property.
Minecraft.getMinecraft().getProfileProperties().put("dummy", new Property("dummy", "property"));
// Handlers and poller created successfully; proceed to next stage of loading.
// We will either need to connect to an existing server, or to start
// a new integrated server ourselves, depending on our role.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public static boolean setPlayerName(Session currentSession, String newPlayerName

// Create new session object:
Session newSession = new Session(newPlayerName, currentSession.getPlayerID(), currentSession.getToken(), "mojang"/*currentSession.getSessionType().toString()*/);
newSession.setProperties(new com.mojang.authlib.properties.PropertyMap()); // Prevents calls to the session service to get profile properties
return setSession(newSession);
}

Expand Down

0 comments on commit 70ef288

Please sign in to comment.