mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
parent
84a6a6daf4
commit
538e2a6002
@ -112,13 +112,8 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
while (!toFetch.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
if (toFetch.isEmpty()) {
|
|
||||||
if (whenDone != null) {
|
|
||||||
whenDone.run();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < Math.min(500, toFetch.size()); i++) {
|
for (int i = 0; i < Math.min(500, toFetch.size()); i++) {
|
||||||
UUID uuid = toFetch.pop();
|
UUID uuid = toFetch.pop();
|
||||||
HttpURLConnection connection =
|
HttpURLConnection connection =
|
||||||
@ -132,11 +127,22 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
add(new StringWrapper(name), uuid);
|
add(new StringWrapper(name), uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
connection.disconnect();
|
||||||
}
|
}
|
||||||
}catch(IOException | ParseException e){
|
}catch(IOException | ParseException e){
|
||||||
PS.debug("Invalid response from Mojang: Some UUIDs will be cached later. (`unknown` until then or player joins)");
|
PS.debug("Invalid response from Mojang: Some UUIDs will be cached later. (`unknown` until then or player joins)");
|
||||||
}
|
}
|
||||||
TaskManager.runTaskLaterAsync(this, SQLUUIDHandler.this.INTERVAL);
|
try {
|
||||||
|
Thread.sleep(INTERVAL * 50);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (whenDone != null) {
|
||||||
|
whenDone.run();
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -249,8 +249,8 @@ public abstract class HybridUtils {
|
|||||||
@Override
|
@Override
|
||||||
public void run(Object value) {
|
public void run(Object value) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
while (System.currentTimeMillis() - start < 20 && !chunks.isEmpty()) {
|
|
||||||
Iterator<ChunkLoc> iterator = chunks.iterator();
|
Iterator<ChunkLoc> iterator = chunks.iterator();
|
||||||
|
while (System.currentTimeMillis() - start < 20 && !chunks.isEmpty()) {
|
||||||
final ChunkLoc chunk = iterator.next();
|
final ChunkLoc chunk = iterator.next();
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
regenerateRoad(area, chunk, extend);
|
regenerateRoad(area, chunk, extend);
|
||||||
|
@ -33,6 +33,9 @@ public class StringWrapper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getClass() != obj.getClass()) {
|
if (getClass() != obj.getClass()) {
|
||||||
|
if (obj.getClass() == String.class) {
|
||||||
|
return obj.toString().equalsIgnoreCase(this.value);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (obj.hashCode() != hashCode()) {
|
if (obj.hashCode() != hashCode()) {
|
||||||
@ -42,7 +45,7 @@ public class StringWrapper {
|
|||||||
if ((other.value == null) || (this.value == null)) {
|
if ((other.value == null) || (this.value == null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return other.value.equalsIgnoreCase(this.value.toLowerCase());
|
return other.value.equalsIgnoreCase(this.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +28,7 @@ public abstract class UUIDHandlerImplementation {
|
|||||||
public UUIDWrapper uuidWrapper;
|
public UUIDWrapper uuidWrapper;
|
||||||
private boolean cached = false;
|
private boolean cached = false;
|
||||||
private BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
private BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||||
|
private BiMap<UUID, StringWrapper> nameMap = uuidMap.inverse();
|
||||||
|
|
||||||
public UUIDHandlerImplementation(UUIDWrapper wrapper) {
|
public UUIDHandlerImplementation(UUIDWrapper wrapper) {
|
||||||
this.uuidWrapper = wrapper;
|
this.uuidWrapper = wrapper;
|
||||||
@ -61,7 +62,7 @@ public abstract class UUIDHandlerImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void rename(UUID uuid, StringWrapper name) {
|
public void rename(UUID uuid, StringWrapper name) {
|
||||||
this.uuidMap.inverse().remove(uuid);
|
this.nameMap.remove(uuid);
|
||||||
this.uuidMap.put(name, uuid);
|
this.uuidMap.put(name, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +76,7 @@ public abstract class UUIDHandlerImplementation {
|
|||||||
if (uuid == null || name == null) {
|
if (uuid == null || name == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BiMap<UUID, StringWrapper> inverse = this.uuidMap.inverse();
|
BiMap<UUID, StringWrapper> inverse = this.nameMap;
|
||||||
if (inverse.containsKey(uuid)) {
|
if (inverse.containsKey(uuid)) {
|
||||||
if (this.uuidMap.containsKey(name)) {
|
if (this.uuidMap.containsKey(name)) {
|
||||||
continue;
|
continue;
|
||||||
@ -164,11 +165,17 @@ public abstract class UUIDHandlerImplementation {
|
|||||||
replace(offline, uuid, name.value);
|
replace(offline, uuid, name.value);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
StringWrapper oName = this.nameMap.get(offline);
|
||||||
|
if (!oName.equals(name)) {
|
||||||
|
this.uuidMap.remove(name);
|
||||||
|
this.uuidMap.put(name, uuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
BiMap<UUID, StringWrapper> inverse = this.uuidMap.inverse();
|
BiMap<UUID, StringWrapper> inverse = this.nameMap;
|
||||||
if (inverse.containsKey(uuid)) {
|
if (inverse.containsKey(uuid)) {
|
||||||
if (this.uuidMap.containsKey(name)) {
|
if (this.uuidMap.containsKey(name)) {
|
||||||
return false;
|
return false;
|
||||||
@ -209,7 +216,7 @@ public abstract class UUIDHandlerImplementation {
|
|||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
StringWrapper name = this.uuidMap.inverse().get(uuid);
|
StringWrapper name = this.nameMap.get(uuid);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
return name.value;
|
return name.value;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user