Changes in 1.8

Discussion in 'Plugin Development' started by Smerfa, May 9, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Smerfa

    Simple question...
    Authorization of players will be changed in 1.8? (because of UUID)
    And if yes, then how much?

    No changes in packets? or?
    hasPaid URL will still work?
     
  2. It isn't much to do with authentication, it's mainly to do with the fact that you can no longer rely on using the players Username to store data as players will be able to change their username. There are many API's out there which gets the UUID of a player, my favourite being the one created by BigTeddy98
    Show Spoiler
    Code:java
    1. import java.io.BufferedReader;
    2. import java.io.DataOutputStream;
    3. import java.io.IOException;
    4. import java.io.InputStreamReader;
    5. import java.net.HttpURLConnection;
    6. import java.net.Proxy;
    7. import java.net.URL;
    8. import java.net.URLConnection;
    9. import java.util.Scanner;
    10.  
    11. import net.minecraft.util.com.google.gson.Gson;
    12.  
    13. import org.json.simple.JSONObject;
    14. import org.json.simple.parser.JSONParser;
    15.  
    16. public class UUIDUtils {
    17.  
    18. /*
    19. * Class made by BigTeddy98.
    20. *
    21. * UUIDLibrary is class to convert UUID <-> Playername
    22. *
    23. * 1. No warranty is given or implied. 2. All damage is your own
    24. * responsibility. 3. If you want to use this in your plugins, a credit
    25. * would we appreciated.
    26. */
    27.  
    28. private static Gson gson = new Gson();
    29.  
    30. public static String getNameFromUUID(String uuid) {
    31. String name = null;
    32. try {
    33. URL url = new URL("[url]https://sessionserver.mojang.com/session/minecraft/profile/[/url]" + uuid);
    34. URLConnection connection = url.openConnection();
    35. Scanner jsonScanner = new Scanner(connection.getInputStream(), "UTF-8");
    36. String json = jsonScanner.next();
    37. JSONParser parser = new JSONParser();
    38. Object obj = parser.parse(json);
    39. name = (String) ((JSONObject) obj).get("name");
    40. jsonScanner.close();
    41. } catch (Exception ex) {
    42. ex.printStackTrace();
    43. }
    44. return name;
    45. }
    46.  
    47. public static String getUUIDFromName(String name) {
    48. try {
    49. ProfileData profC = new ProfileData(name);
    50. String UUID = null;
    51. for (int i = 1; i <= 100; i++) {
    52. PlayerProfile[] result = post(new URL("[url]https://api.mojang.com/profiles/page/[/url]" + i), Proxy.NO_PROXY, gson.toJson(profC).getBytes());
    53. if (result.length == 0) {
    54. break;
    55. }
    56. UUID = result[0].getId();
    57. }
    58. return UUID;
    59. } catch (Exception e) {
    60. e.printStackTrace();
    61. }
    62. return null;
    63. }
    64.  
    65. private static PlayerProfile[] post(URL url, Proxy proxy, byte[] bytes) throws IOException {
    66. HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxy);
    67. connection.setRequestMethod("POST");
    68. connection.setRequestProperty("Content-Type", "application/json");
    69. connection.setDoInput(true);
    70. connection.setDoOutput(true);
    71.  
    72. DataOutputStream out = new DataOutputStream(connection.getOutputStream());
    73. out.write(bytes);
    74. out.flush();
    75. out.close();
    76.  
    77. BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    78. StringBuffer response = new StringBuffer();
    79. String line;
    80. while ((line = reader.readLine()) != null) {
    81. response.append(line);
    82. response.append('\r');
    83. }
    84. reader.close();
    85. return gson.fromJson(response.toString(), SearchResult.class).getProfiles();
    86. }
    87.  
    88. private static class PlayerProfile {
    89. private String id;
    90.  
    91. public String getId() {
    92. return id;
    93. }
    94. }
    95.  
    96. private static class SearchResult {
    97. private PlayerProfile[] profiles;
    98.  
    99. public PlayerProfile[] getProfiles() {
    100. return profiles;
    101. }
    102. }
    103.  
    104. private static class ProfileData {
    105.  
    106. @SuppressWarnings("unused")
    107. private String name;
    108. @SuppressWarnings("unused")
    109. private String agent = "minecraft";
    110.  
    111. public ProfileData(String name) {
    112. this.name = name;
    113. }
    114. }
    115. }
    116.  
     
    Smerfa likes this.
  3. Offline

    Smerfa

    Hyyym... but in LoginStart packet that will be still username? not UUID?
     
  4. Smerfa I'm not entirely sure with the packet side of things, but as far as my mini research shows, it uses a GameProfile which does store a name (but since it's NMS code, there's probably some UUID authentication or something).
     
    Smerfa likes this.
Thread Status:
Not open for further replies.

Share This Page