Merge branch 'webbukkit:v3.0' into v3.0

This commit is contained in:
Michele 2022-08-08 11:26:06 +02:00 committed by GitHub
commit e2da0efd8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 3643 additions and 16 deletions

View file

@ -692,6 +692,7 @@ public class MapManager {
}
});
rslt.add(future);
}
}
/* Now, do our render (first one) */

View file

@ -1304,8 +1304,10 @@ public abstract class GenericMapChunkCache extends MapChunkCache {
long[] bdataPacked = nbtbiomes.getLongArray("data");
GenericNBTList bpalette = nbtbiomes.getList("palette", 8);
GenericBitStorage bdata = null;
if (bdataPacked.length > 0)
bdata = nbt.makeBitStorage(bdataPacked.length, 64, bdataPacked);
if (bdataPacked.length > 0) {
int valsPerLong = (64 / bdataPacked.length);
bdata = nbt.makeBitStorage((64 + valsPerLong - 1) / valsPerLong, 64, bdataPacked);
}
for (int j = 0; j < 64; j++) {
int b = bdata != null ? bdata.get(j) : 0;
sbld.xyzBiome(j & 0x3, (j & 0x30) >> 4, (j & 0xC) >> 2, BiomeMap.byBiomeResourceLocation(bpalette.getString(b)));

View file

@ -49,6 +49,8 @@ public class MicrosoftSQLMapStorage extends MapStorage {
protected int port;
private static final int POOLSIZE = 5;
private Connection[] cpool = new Connection[POOLSIZE];
private long[] cpoolLastUseTS = new long[POOLSIZE]; // Time when last returned to pool
private static final long IDLE_TIMEOUT = 60000; // Use 60 second timeout
private int cpoolCount = 0;
private static final Charset UTF8 = Charset.forName("UTF-8");
@ -527,12 +529,22 @@ public class MicrosoftSQLMapStorage extends MapStorage {
private Connection getConnection() throws SQLException {
Connection c = null;
synchronized (cpool) {
long now = System.currentTimeMillis();
while (c == null) {
for (int i = 0; i < cpool.length; i++) { // See if available connection
if (cpool[i] != null) { // Found one
c = cpool[i];
cpool[i] = null;
break;
// If in pool too long, close it and move on
if ((now - cpoolLastUseTS[i]) > IDLE_TIMEOUT) {
try { cpool[i].close(); } catch (SQLException x) {}
cpool[i] = null;
cpoolCount--;
}
else { // Else, use the connection
c = cpool[i];
cpool[i] = null;
cpoolLastUseTS[i] = now;
break;
}
}
}
if (c == null) {
@ -565,6 +577,7 @@ public class MicrosoftSQLMapStorage extends MapStorage {
for (int i = 0; i < POOLSIZE; i++) {
if (cpool[i] == null) {
cpool[i] = c;
cpoolLastUseTS[i] = System.currentTimeMillis(); // Record last use time
c = null; // Mark it recovered (no close needed
cpool.notifyAll();
break;

View file

@ -49,6 +49,8 @@ public class MySQLMapStorage extends MapStorage {
protected int port;
private static final int POOLSIZE = 5;
private Connection[] cpool = new Connection[POOLSIZE];
private long[] cpoolLastUseTS = new long[POOLSIZE]; // Time when last returned to pool
private static final long IDLE_TIMEOUT = 60000; // Use 60 second timeout
private int cpoolCount = 0;
private static final Charset UTF8 = Charset.forName("UTF-8");
@ -647,12 +649,22 @@ public class MySQLMapStorage extends MapStorage {
Connection c = null;
if (isShutdown) { throw new StorageShutdownException(); }
synchronized (cpool) {
long now = System.currentTimeMillis();
while (c == null) {
for (int i = 0; i < cpool.length; i++) { // See if available connection
if (cpool[i] != null) { // Found one
c = cpool[i];
cpool[i] = null;
break;
// If in pool too long, close it and move on
if ((now - cpoolLastUseTS[i]) > IDLE_TIMEOUT) {
try { cpool[i].close(); } catch (SQLException x) {}
cpool[i] = null;
cpoolCount--;
}
else { // Else, use the connection
c = cpool[i];
cpool[i] = null;
cpoolLastUseTS[i] = now;
break;
}
}
}
if (c == null) {
@ -685,6 +697,7 @@ public class MySQLMapStorage extends MapStorage {
for (int i = 0; i < POOLSIZE; i++) {
if (cpool[i] == null) {
cpool[i] = c;
cpoolLastUseTS[i] = System.currentTimeMillis(); // Record last use time
c = null; // Mark it recovered (no close needed
cpool.notifyAll();
break;

View file

@ -49,6 +49,8 @@ public class PostgreSQLMapStorage extends MapStorage {
private int port;
private static final int POOLSIZE = 5;
private Connection[] cpool = new Connection[POOLSIZE];
private long[] cpoolLastUseTS = new long[POOLSIZE]; // Time when last returned to pool
private static final long IDLE_TIMEOUT = 60000; // Use 60 second timeout
private int cpoolCount = 0;
private static final Charset UTF8 = Charset.forName("UTF-8");
@ -571,12 +573,22 @@ public class PostgreSQLMapStorage extends MapStorage {
Connection c = null;
if (isShutdown) throw new StorageShutdownException();
synchronized (cpool) {
long now = System.currentTimeMillis();
while (c == null) {
for (int i = 0; i < cpool.length; i++) { // See if available connection
if (cpool[i] != null) { // Found one
c = cpool[i];
cpool[i] = null;
break;
// If in pool too long, close it and move on
if ((now - cpoolLastUseTS[i]) > IDLE_TIMEOUT) {
try { cpool[i].close(); } catch (SQLException x) {}
cpool[i] = null;
cpoolCount--;
}
else { // Else, use the connection
c = cpool[i];
cpool[i] = null;
cpoolLastUseTS[i] = now;
break;
}
}
}
if (c == null) {
@ -608,6 +620,7 @@ public class PostgreSQLMapStorage extends MapStorage {
for (int i = 0; i < POOLSIZE; i++) {
if (cpool[i] == null) {
cpool[i] = c;
cpoolLastUseTS[i] = System.currentTimeMillis(); // Record last use time
c = null; // Mark it recovered (no close needed
cpool.notifyAll();
break;

View file

@ -33,6 +33,8 @@ public class SQLiteMapStorage extends MapStorage {
private String databaseFile;
private static final int POOLSIZE = 1; // SQLite is really not thread safe... 1 at a time works best
private Connection[] cpool = new Connection[POOLSIZE];
private long[] cpoolLastUseTS = new long[POOLSIZE]; // Time when last returned to pool
private static final long IDLE_TIMEOUT = 60000; // Use 60 second timeout
private int cpoolCount = 0;
private static final Charset UTF8 = Charset.forName("UTF-8");
@ -492,11 +494,22 @@ public class SQLiteMapStorage extends MapStorage {
throw new StorageShutdownException();
}
synchronized (cpool) {
long now = System.currentTimeMillis();
while (c == null) {
for (int i = 0; i < cpool.length; i++) { // See if available connection
if (cpool[i] != null) { // Found one
c = cpool[i];
cpool[i] = null;
// If in pool too long, close it and move on
if ((now - cpoolLastUseTS[i]) > IDLE_TIMEOUT) {
try { cpool[i].close(); } catch (SQLException x) {}
cpool[i] = null;
cpoolCount--;
}
else { // Else, use the connection
c = cpool[i];
cpool[i] = null;
cpoolLastUseTS[i] = now;
break;
}
}
}
if (c == null) {
@ -532,6 +545,7 @@ public class SQLiteMapStorage extends MapStorage {
for (int i = 0; i < POOLSIZE; i++) {
if (cpool[i] == null) {
cpool[i] = c;
cpoolLastUseTS[i] = System.currentTimeMillis(); // Record last use time
c = null; // Mark it recovered (no close needed
cpool.notifyAll();
break;