mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Merge branch 'master' of github.com:mcMMO-Dev/mcMMO into configurable
This commit is contained in:
commit
71a2ea2a2e
@ -163,6 +163,8 @@ Version 2.2.0
|
|||||||
Added API method to check if player parties are size capped
|
Added API method to check if player parties are size capped
|
||||||
Added API method to grab the level cap of a skill by its PrimarySkillType ENUM definition
|
Added API method to grab the level cap of a skill by its PrimarySkillType ENUM definition
|
||||||
Added API method to check if a skill was being level capped
|
Added API method to check if a skill was being level capped
|
||||||
|
Version 2.1.55
|
||||||
|
Fixed a bug that could occur when adding UUIDs to old outdated DBs
|
||||||
|
|
||||||
Version 2.1.54
|
Version 2.1.54
|
||||||
Fixed a bug where the Skill 'Understanding the Art' was preventing vanilla experience orbs from furnaces
|
Fixed a bug where the Skill 'Understanding the Art' was preventing vanilla experience orbs from furnaces
|
||||||
|
@ -69,6 +69,8 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
// Handle 429
|
// Handle 429
|
||||||
|
if(e.getMessage() != null)
|
||||||
|
{
|
||||||
if (e.getMessage().contains("429")) {
|
if (e.getMessage().contains("429")) {
|
||||||
size += userNamesSection.size();
|
size += userNamesSection.size();
|
||||||
try {
|
try {
|
||||||
@ -79,6 +81,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
plugin.getLogger().log(Level.SEVERE, "Unable to fetch UUIDs!", e);
|
plugin.getLogger().log(Level.SEVERE, "Unable to fetch UUIDs!", e);
|
||||||
return;
|
return;
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.gmail.nossr50.util.uuid;
|
package com.gmail.nossr50.util.uuid;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
|
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -28,6 +30,40 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
|||||||
this(names, true);
|
this(names, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, UUID> call() throws Exception {
|
||||||
|
Map<String, UUID> uuidMap = new HashMap<String, UUID>();
|
||||||
|
int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
|
||||||
|
for (int i = 0; i < requests; i++) {
|
||||||
|
HttpURLConnection connection = createConnection();
|
||||||
|
|
||||||
|
List<String> nameSubList = names.subList(i * PROFILES_PER_REQUEST, Math.min((i + 1) * PROFILES_PER_REQUEST, names.size()));
|
||||||
|
JsonArray array = new JsonArray();
|
||||||
|
|
||||||
|
for(String name : nameSubList)
|
||||||
|
{
|
||||||
|
JsonPrimitive element = new JsonPrimitive(name);
|
||||||
|
array.add(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
String body = array.toString();
|
||||||
|
|
||||||
|
writeBody(connection, body);
|
||||||
|
JsonObject[] jsonStreamArray = gson.fromJson(new InputStreamReader(connection.getInputStream()), JsonObject[].class);
|
||||||
|
|
||||||
|
for (JsonObject jsonProfile : jsonStreamArray) {
|
||||||
|
String id = jsonProfile.get("id").getAsString();
|
||||||
|
String name = jsonProfile.get("name").getAsString();
|
||||||
|
UUID uuid = UUIDFetcher.getUUID(id);
|
||||||
|
uuidMap.put(name, uuid);
|
||||||
|
}
|
||||||
|
if (rateLimiting && i != requests - 1) {
|
||||||
|
Thread.sleep(RATE_LIMIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return uuidMap;
|
||||||
|
}
|
||||||
|
|
||||||
private static void writeBody(HttpURLConnection connection, String body) throws Exception {
|
private static void writeBody(HttpURLConnection connection, String body) throws Exception {
|
||||||
OutputStream stream = connection.getOutputStream();
|
OutputStream stream = connection.getOutputStream();
|
||||||
stream.write(body.getBytes());
|
stream.write(body.getBytes());
|
||||||
@ -70,34 +106,4 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
|||||||
public static UUID getUUIDOf(String name) throws Exception {
|
public static UUID getUUIDOf(String name) throws Exception {
|
||||||
return new UUIDFetcher(Collections.singletonList(name)).call().get(name);
|
return new UUIDFetcher(Collections.singletonList(name)).call().get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, UUID> call() throws Exception {
|
|
||||||
Map<String, UUID> uuidMap = new HashMap<>();
|
|
||||||
int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
|
|
||||||
for (int i = 0; i < requests; i++) {
|
|
||||||
HttpURLConnection connection = createConnection();
|
|
||||||
|
|
||||||
List<String> nameSubList = names.subList(i * PROFILES_PER_REQUEST, Math.min((i + 1) * PROFILES_PER_REQUEST, names.size()));
|
|
||||||
JsonArray array = new JsonArray();
|
|
||||||
|
|
||||||
for (String name : nameSubList) {
|
|
||||||
JsonPrimitive element = new JsonPrimitive(name);
|
|
||||||
array.add(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
String body = array.getAsString();
|
|
||||||
writeBody(connection, body);
|
|
||||||
for (Object profile : array) {
|
|
||||||
JsonObject jsonProfile = (JsonObject) profile;
|
|
||||||
String id = jsonProfile.get("id").getAsString();
|
|
||||||
String name = jsonProfile.get("name").getAsString();
|
|
||||||
UUID uuid = UUIDFetcher.getUUID(id);
|
|
||||||
uuidMap.put(name, uuid);
|
|
||||||
}
|
|
||||||
if (rateLimiting && i != requests - 1) {
|
|
||||||
Thread.sleep(RATE_LIMIT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return uuidMap;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user