Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-17 05:20:05 +01:00
Java 1.5 compat.
Dieser Commit ist enthalten in:
Ursprung
87dc04b750
Commit
9d9ad6bd1e
34
src/main/java/org/bukkit/craftbukkit/util/Java15Compat.java
Normale Datei
34
src/main/java/org/bukkit/craftbukkit/util/Java15Compat.java
Normale Datei
@ -0,0 +1,34 @@
|
|||||||
|
package org.bukkit.craftbukkit.util;
|
||||||
|
|
||||||
|
import java.lang.reflect.Array;
|
||||||
|
|
||||||
|
public class Java15Compat {
|
||||||
|
public static <T> T[] Arrays_copyOf(T[] original, int newLength) {
|
||||||
|
if (0 <= newLength) {
|
||||||
|
return org.bukkit.util.Java15Compat.Arrays_copyOfRange(original, 0, newLength);
|
||||||
|
}
|
||||||
|
throw new NegativeArraySizeException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long[] Arrays_copyOf(long[] original, int newLength) {
|
||||||
|
if (0 <= newLength) {
|
||||||
|
return Arrays_copyOfRange(original, 0, newLength);
|
||||||
|
}
|
||||||
|
throw new NegativeArraySizeException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long[] Arrays_copyOfRange(long[] original, int start, int end) {
|
||||||
|
if (original.length >= start && 0 <= start) {
|
||||||
|
if (start <= end) {
|
||||||
|
int length = end - start;
|
||||||
|
int copyLength = Math.min( length, original.length - start);
|
||||||
|
long[] copy = (long[]) Array.newInstance(original.getClass().getComponentType(), length);
|
||||||
|
System.arraycopy(original, start, copy, 0, copyLength);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
throw new ArrayIndexOutOfBoundsException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
package org.bukkit.craftbukkit.util;
|
package org.bukkit.craftbukkit.util;
|
||||||
import java.util.Arrays;
|
import static org.bukkit.craftbukkit.util.Java15Compat.Arrays_copyOf;
|
||||||
|
|
||||||
public class LongHashset extends LongHash {
|
public class LongHashset extends LongHash {
|
||||||
long values[][][] = new long[256][][];
|
long values[][][] = new long[256][][];
|
||||||
@ -31,7 +31,7 @@ public class LongHashset extends LongHash {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outer[outerIdx] = inner = Arrays.copyOf(inner, i+1);
|
outer[outerIdx] = inner = Arrays_copyOf(inner, i+1);
|
||||||
inner[i] = key;
|
inner[i] = key;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ public class LongHashset extends LongHash {
|
|||||||
if(i != max) {
|
if(i != max) {
|
||||||
inner[i] = inner[max];
|
inner[i] = inner[max];
|
||||||
}
|
}
|
||||||
outer[(int) ((key >> 32) & 255)] = (max == 0 ? null : Arrays.copyOf(inner, max));
|
outer[(int) ((key >> 32) & 255)] = (max == 0 ? null : Arrays_copyOf(inner, max));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ public class LongHashset extends LongHash {
|
|||||||
if(inner == null || inner.length == 0) continue;
|
if(inner == null || inner.length == 0) continue;
|
||||||
count--;
|
count--;
|
||||||
long ret = inner[inner.length - 1];
|
long ret = inner[inner.length - 1];
|
||||||
outer[i] = Arrays.copyOf(inner, inner.length - 1);
|
outer[i] = Arrays_copyOf(inner, inner.length - 1);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import net.minecraft.server.Chunk;
|
import net.minecraft.server.Chunk;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import static org.bukkit.craftbukkit.util.Java15Compat.Arrays_copyOf;
|
||||||
|
|
||||||
public class LongHashtable<V> extends LongHash
|
public class LongHashtable<V> extends LongHash
|
||||||
{
|
{
|
||||||
@ -55,7 +56,7 @@ public class LongHashtable<V> extends LongHash
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outer[outerIdx] = inner = Arrays.copyOf(inner, i + i);
|
outer[outerIdx] = inner = Arrays_copyOf(inner, i + i);
|
||||||
inner[i] = new Entry(key, value);
|
inner[i] = new Entry(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren