mirror of https://github.com/webbukkit/dynmap.git
Mojang mapped 1.19
This commit is contained in:
parent
5d867239b2
commit
aeaec4937a
|
@ -1,3 +1,7 @@
|
|||
plugins {
|
||||
id("io.papermc.paperweight.userdev") version "1.3.8"
|
||||
}
|
||||
|
||||
eclipse {
|
||||
project {
|
||||
name = "Dynmap(Spigot-1.19)"
|
||||
|
@ -7,9 +11,29 @@ eclipse {
|
|||
description = 'bukkit-helper-1.19'
|
||||
|
||||
dependencies {
|
||||
implementation project(':bukkit-helper')
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.spigotmc', name: 'spigot-api', version:'1.19-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.spigotmc', name: 'spigot', version:'1.19-R0.1-SNAPSHOT'
|
||||
compileOnly project(':bukkit-helper')
|
||||
compileOnly project(':dynmap-api')
|
||||
compileOnly project(':DynmapCore')
|
||||
compileOnly project(':DynmapCoreAPI')
|
||||
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.19.2-R0.1-SNAPSHOT")
|
||||
}
|
||||
|
||||
tasks {
|
||||
assemble {
|
||||
dependsOn(reobfJar)
|
||||
}
|
||||
reobfJar {
|
||||
outputJar.set(layout.buildDirectory.file("libs/bukkit-helper-119-${parent.version}-reobf.jar"))
|
||||
}
|
||||
configurations {
|
||||
spigotObf {
|
||||
canBeConsumed = true
|
||||
canBeResolved = false
|
||||
}
|
||||
}
|
||||
}
|
||||
artifacts {
|
||||
spigotObf(layout.buildDirectory.file("libs/bukkit-helper-119-${parent.version}-reobf.jar")) {
|
||||
builtBy(reobfJar)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,105 +1,47 @@
|
|||
package org.dynmap.bukkit.helper.v119;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import com.destroystokyo.paper.io.PaperFileIOThread;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import net.minecraft.world.level.chunk.IChunkAccess;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkRegionLoader;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkSerializer;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkSerializer.AsyncSaveData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.dynmap.MapManager;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* The provider used to work with paper libs
|
||||
* Because paper libs need java 17 we can't interact with them directly
|
||||
* Isolation of paper specific methods
|
||||
*/
|
||||
@SuppressWarnings({"JavaReflectionMemberAccess"}) //java don't know about paper
|
||||
public class AsyncChunkProvider119 {
|
||||
private final Thread ioThread;
|
||||
private final Method getChunk;
|
||||
private final Predicate<NBTTagCompound> ifFailed;
|
||||
private final Method getAsyncSaveData;
|
||||
private final Method save;
|
||||
private int currTick = MinecraftServer.currentTick;
|
||||
private int currChunks = 0;
|
||||
|
||||
AsyncChunkProvider119() {
|
||||
try {
|
||||
Predicate<NBTTagCompound> ifFailed1 = null;
|
||||
Method getChunk1 = null, getAsyncSaveData1 = null, save1 = null;
|
||||
Thread ioThread1 = null;
|
||||
try {
|
||||
Class<?> threadClass = Class.forName("com.destroystokyo.paper.io.PaperFileIOThread");
|
||||
Class<?> asyncChunkData = Arrays.stream(ChunkRegionLoader.class.getClasses())
|
||||
.filter(c -> c.getSimpleName().equals("AsyncSaveData"))
|
||||
.findFirst()
|
||||
.orElseThrow(RuntimeException::new);
|
||||
getAsyncSaveData1 = ChunkRegionLoader.class.getMethod("getAsyncSaveData", WorldServer.class, IChunkAccess.class);
|
||||
save1 = ChunkRegionLoader.class.getMethod("saveChunk", WorldServer.class, IChunkAccess.class, asyncChunkData);
|
||||
Class<?>[] classes = threadClass.getClasses();
|
||||
Class<?> holder = Arrays.stream(classes).filter(aClass -> aClass.getSimpleName().equals("Holder")).findAny().orElseThrow(RuntimeException::new);
|
||||
ioThread1 = (Thread) holder.getField("INSTANCE").get(null);
|
||||
getChunk1 = threadClass.getMethod("loadChunkDataAsync", WorldServer.class, int.class, int.class, int.class, Consumer.class, boolean.class, boolean.class, boolean.class);
|
||||
NBTTagCompound failure = (NBTTagCompound) threadClass.getField("FAILURE_VALUE").get(null);
|
||||
ifFailed1 = nbtTagCompound -> nbtTagCompound == failure;
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
getAsyncSaveData = Objects.requireNonNull(getAsyncSaveData1);
|
||||
save = Objects.requireNonNull(save1);
|
||||
ifFailed = Objects.requireNonNull(ifFailed1);
|
||||
getChunk = Objects.requireNonNull(getChunk1);
|
||||
ioThread = Objects.requireNonNull(ioThread1);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
public CompletableFuture<NBTTagCompound> getChunk(WorldServer world, int x, int y) throws InvocationTargetException, IllegalAccessException {
|
||||
CompletableFuture<Object> future = new CompletableFuture<>();
|
||||
getChunk.invoke(ioThread,world,x,y,5,(Consumer<Object>) future::complete, false, true, true);
|
||||
return future.thenApply((resultFuture) -> {
|
||||
if (resultFuture == null) return null;
|
||||
try {
|
||||
NBTTagCompound compound = (NBTTagCompound) resultFuture.getClass().getField("chunkData").get(resultFuture);
|
||||
return ifFailed.test(compound) ? null : compound;
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
public CompletableFuture<CompoundTag> getChunk(ServerLevel world, int x, int y) throws InvocationTargetException, IllegalAccessException {
|
||||
return PaperFileIOThread.Holder.INSTANCE.loadChunkDataAsyncFuture(world, x, y, 5, false, true, true)
|
||||
.thenApply(resultFuture -> resultFuture == null ? null : PaperFileIOThread.FAILURE_VALUE == resultFuture.chunkData ? null : resultFuture.chunkData);
|
||||
}
|
||||
|
||||
public synchronized Supplier<NBTTagCompound> getLoadedChunk(CraftWorld world, int x, int z) {
|
||||
public synchronized Supplier<CompoundTag> getLoadedChunk(CraftWorld world, int x, int z) {
|
||||
if (!world.isChunkLoaded(x, z)) return () -> null;
|
||||
Chunk c = world.getHandle().getChunkIfLoaded(x, z); //already safe async on vanilla
|
||||
if ((c == null) || !c.o) return () -> null; // c.loaded
|
||||
LevelChunk c = world.getHandle().getChunkIfLoaded(x, z);
|
||||
if ((c == null) || !c.loaded) return () -> null;
|
||||
if (currTick != MinecraftServer.currentTick) {
|
||||
currTick = MinecraftServer.currentTick;
|
||||
currChunks = 0;
|
||||
}
|
||||
//prepare data synchronously
|
||||
CompletableFuture<?> future = CompletableFuture.supplyAsync(() -> {
|
||||
CompletableFuture<AsyncSaveData> future = CompletableFuture.supplyAsync(() -> {
|
||||
//Null will mean that we save with spigot methods, which may be risky on async
|
||||
//Since we're not in main thread, it now refuses new tasks because of shutdown, the risk is lower
|
||||
if (!Bukkit.isPrimaryThread()) return null;
|
||||
try {
|
||||
return getAsyncSaveData.invoke(null, world.getHandle(), c);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return Bukkit.isPrimaryThread() ? ChunkSerializer.getAsyncSaveData(world.getHandle(), c) : null;
|
||||
}, ((CraftServer) Bukkit.getServer()).getServer());
|
||||
//we shouldn't stress main thread
|
||||
if (++currChunks > MapManager.mapman.getMaxChunkLoadsPerTick()) {
|
||||
|
@ -109,19 +51,15 @@ public class AsyncChunkProvider119 {
|
|||
}
|
||||
//save data asynchronously
|
||||
return () -> {
|
||||
Object o = null;
|
||||
try {
|
||||
o = future.get();
|
||||
return (NBTTagCompound) save.invoke(null, world.getHandle(), c, o);
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
} catch (InvocationTargetException e) {
|
||||
//We tried to use simple spigot methods at shutdown and failed, hopes for reading from disk
|
||||
if (o == null) return null;
|
||||
throw new RuntimeException(e);
|
||||
} catch (ReflectiveOperationException | ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
AsyncSaveData o;
|
||||
o = future.join();
|
||||
if (o == null) {
|
||||
try {
|
||||
return ChunkSerializer.saveChunk(world.getHandle(), c, null);
|
||||
} catch (Exception e) {
|
||||
return null; //Server stopping, Be more cautions
|
||||
}
|
||||
} else return ChunkSerializer.saveChunk(world.getHandle(), c, o);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,5 @@
|
|||
package org.dynmap.bukkit.helper.v119;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.bukkit.helper.BukkitMaterial;
|
||||
import org.dynmap.bukkit.helper.BukkitVersionHelper;
|
||||
import org.dynmap.bukkit.helper.BukkitWorld;
|
||||
import org.dynmap.bukkit.helper.BukkitVersionHelperGeneric.TexturesPayload;
|
||||
import org.dynmap.renderer.DynmapBlockState;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.Polygon;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
@ -22,30 +7,34 @@ import com.google.gson.JsonParseException;
|
|||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
|
||||
import net.minecraft.core.RegistryBlockID;
|
||||
import net.minecraft.core.RegistryBlocks;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.nbt.NBTTagByteArray;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagDouble;
|
||||
import net.minecraft.nbt.NBTTagFloat;
|
||||
import net.minecraft.nbt.NBTTagIntArray;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.nbt.NBTTagLong;
|
||||
import net.minecraft.nbt.NBTTagShort;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.DefaultedRegistry;
|
||||
import net.minecraft.core.IdMapper;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.level.BlockAccessAir;
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
import net.minecraft.world.level.EmptyBlockGetter;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.BlockFluids;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.level.block.LiquidBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.bukkit.helper.BukkitMaterial;
|
||||
import org.dynmap.bukkit.helper.BukkitVersionHelper;
|
||||
import org.dynmap.bukkit.helper.BukkitVersionHelperGeneric.TexturesPayload;
|
||||
import org.dynmap.bukkit.helper.BukkitWorld;
|
||||
import org.dynmap.renderer.DynmapBlockState;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.Polygon;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
|
@ -57,214 +46,218 @@ import java.util.IdentityHashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* Helper for isolation of bukkit version specific issues
|
||||
*/
|
||||
public class BukkitVersionHelperSpigot119 extends BukkitVersionHelper {
|
||||
private final boolean unsafeAsync;
|
||||
public class BukkitVersionHelperSpigot119 extends BukkitVersionHelper {
|
||||
private final boolean unsafeAsync;
|
||||
|
||||
public BukkitVersionHelperSpigot119() {
|
||||
boolean unsafeAsync1;
|
||||
try {
|
||||
Class.forName("com.destroystokyo.paper.io.PaperFileIOThread");
|
||||
unsafeAsync1 = false;
|
||||
} catch (ClassNotFoundException e) {
|
||||
unsafeAsync1 = true;
|
||||
}
|
||||
this.unsafeAsync = unsafeAsync1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnsafeAsync() {
|
||||
return unsafeAsync;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get block short name list
|
||||
*/
|
||||
@Override
|
||||
public String[] getBlockNames() {
|
||||
RegistryBlockID<IBlockData> bsids = Block.o;
|
||||
Block baseb = null;
|
||||
Iterator<IBlockData> iter = bsids.iterator();
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
while (iter.hasNext()) {
|
||||
IBlockData bs = iter.next();
|
||||
Block b = bs.b();
|
||||
// If this is new block vs last, it's the base block state
|
||||
if (b != baseb) {
|
||||
baseb = b;
|
||||
continue;
|
||||
}
|
||||
MinecraftKey id = RegistryBlocks.V.b(b);
|
||||
String bn = id.toString();
|
||||
if (bn != null) {
|
||||
names.add(bn);
|
||||
Log.info("block=" + bn);
|
||||
}
|
||||
public BukkitVersionHelperSpigot119() {
|
||||
boolean unsafeAsync1;
|
||||
try {
|
||||
Class.forName("com.destroystokyo.paper.io.PaperFileIOThread");
|
||||
unsafeAsync1 = false;
|
||||
} catch (ClassNotFoundException e) {
|
||||
unsafeAsync1 = true;
|
||||
}
|
||||
return names.toArray(new String[0]);
|
||||
}
|
||||
this.unsafeAsync = unsafeAsync1;
|
||||
}
|
||||
|
||||
private static IRegistry<BiomeBase> reg = null;
|
||||
@Override
|
||||
public boolean isUnsafeAsync() {
|
||||
return unsafeAsync;
|
||||
}
|
||||
|
||||
private static IRegistry<BiomeBase> getBiomeReg() {
|
||||
if (reg == null) {
|
||||
reg = MinecraftServer.getServer().aX().d(IRegistry.aR);
|
||||
}
|
||||
return reg;
|
||||
}
|
||||
|
||||
private Object[] biomelist;
|
||||
/**
|
||||
* Get list of defined biomebase objects
|
||||
*/
|
||||
@Override
|
||||
public Object[] getBiomeBaseList() {
|
||||
if (biomelist == null) {
|
||||
biomelist = new BiomeBase[256];
|
||||
Iterator<BiomeBase> iter = getBiomeReg().iterator();
|
||||
while (iter.hasNext()) {
|
||||
BiomeBase b = iter.next();
|
||||
int bidx = getBiomeReg().a(b);
|
||||
if (bidx >= biomelist.length) {
|
||||
biomelist = Arrays.copyOf(biomelist, bidx + biomelist.length);
|
||||
}
|
||||
biomelist[bidx] = b;
|
||||
}
|
||||
}
|
||||
return biomelist;
|
||||
}
|
||||
|
||||
/** Get ID from biomebase */
|
||||
@Override
|
||||
public int getBiomeBaseID(Object bb) {
|
||||
return getBiomeReg().a((BiomeBase)bb);
|
||||
}
|
||||
|
||||
public static IdentityHashMap<IBlockData, DynmapBlockState> dataToState;
|
||||
|
||||
/**
|
||||
* Initialize block states (org.dynmap.blockstate.DynmapBlockState)
|
||||
*/
|
||||
@Override
|
||||
public void initializeBlockStates() {
|
||||
dataToState = new IdentityHashMap<IBlockData, DynmapBlockState>();
|
||||
HashMap<String, DynmapBlockState> lastBlockState = new HashMap<String, DynmapBlockState>();
|
||||
RegistryBlockID<IBlockData> bsids = Block.o;
|
||||
Block baseb = null;
|
||||
Iterator<IBlockData> iter = bsids.iterator();
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
|
||||
// Loop through block data states
|
||||
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
|
||||
/**
|
||||
* Get block short name list
|
||||
*/
|
||||
@Override
|
||||
public String[] getBlockNames() {
|
||||
IdMapper<BlockState> bsids = Block.BLOCK_STATE_REGISTRY;
|
||||
Block baseb = null;
|
||||
Iterator<BlockState> iter = bsids.iterator();
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
while (iter.hasNext()) {
|
||||
IBlockData bd = iter.next();
|
||||
Block b = bd.b();
|
||||
MinecraftKey id = RegistryBlocks.V.b(b);
|
||||
String bname = id.toString();
|
||||
DynmapBlockState lastbs = lastBlockState.get(bname); // See if we have seen this one
|
||||
int idx = 0;
|
||||
if (lastbs != null) { // Yes
|
||||
idx = lastbs.getStateCount(); // Get number of states so far, since this is next
|
||||
}
|
||||
// Build state name
|
||||
String sb = "";
|
||||
String fname = bd.toString();
|
||||
int off1 = fname.indexOf('[');
|
||||
if (off1 >= 0) {
|
||||
int off2 = fname.indexOf(']');
|
||||
sb = fname.substring(off1+1, off2);
|
||||
}
|
||||
net.minecraft.world.level.material.Material mat = bd.d();
|
||||
|
||||
int lightAtten = b.g(bd, BlockAccessAir.a, BlockPosition.b); // getLightBlock
|
||||
//Log.info("statename=" + bname + "[" + sb + "], lightAtten=" + lightAtten);
|
||||
// Fill in base attributes
|
||||
bld.setBaseState(lastbs).setStateIndex(idx).setBlockName(bname).setStateName(sb).setMaterial(mat.toString()).setAttenuatesLight(lightAtten);
|
||||
if (mat.b()) { bld.setSolid(); }
|
||||
if (mat == net.minecraft.world.level.material.Material.a) { bld.setAir(); }
|
||||
if (mat == net.minecraft.world.level.material.Material.z) { bld.setLog(); }
|
||||
if (mat == net.minecraft.world.level.material.Material.F) { bld.setLeaves(); }
|
||||
if ((!bd.p().c()) && ((bd.b() instanceof BlockFluids) == false)) { // Test if fluid type for block is not empty
|
||||
BlockState bs = iter.next();
|
||||
Block b = bs.getBlock();
|
||||
// If this is new block vs last, it's the base block state
|
||||
if (b != baseb) {
|
||||
baseb = b;
|
||||
continue;
|
||||
}
|
||||
ResourceLocation id = DefaultedRegistry.BLOCK.getKey(b);
|
||||
String bn = id.toString();
|
||||
names.add(bn);
|
||||
Log.info("block=" + bn);
|
||||
}
|
||||
return names.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private static Registry<Biome> reg = null;
|
||||
|
||||
private static Registry<Biome> getBiomeReg() {
|
||||
if (reg == null) {
|
||||
reg = MinecraftServer.getServer().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
|
||||
}
|
||||
return reg;
|
||||
}
|
||||
|
||||
private Object[] biomelist;
|
||||
|
||||
/**
|
||||
* Get list of defined biomebase objects
|
||||
*/
|
||||
@Override
|
||||
public Object[] getBiomeBaseList() {
|
||||
if (biomelist == null) {
|
||||
biomelist = new Biome[256];
|
||||
for (Biome b : getBiomeReg()) {
|
||||
int bidx = getBiomeReg().getId(b);
|
||||
if (bidx >= biomelist.length) {
|
||||
biomelist = Arrays.copyOf(biomelist, bidx + biomelist.length);
|
||||
}
|
||||
biomelist[bidx] = b;
|
||||
}
|
||||
}
|
||||
return biomelist;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ID from biomebase
|
||||
*/
|
||||
@Override
|
||||
public int getBiomeBaseID(Object bb) {
|
||||
return getBiomeReg().getId((Biome) bb);
|
||||
}
|
||||
|
||||
public static IdentityHashMap<BlockState, DynmapBlockState> dataToState;
|
||||
|
||||
/**
|
||||
* Initialize block states (org.dynmap.blockstate.DynmapBlockState)
|
||||
*/
|
||||
@Override
|
||||
public void initializeBlockStates() {
|
||||
dataToState = new IdentityHashMap<>();
|
||||
HashMap<String, DynmapBlockState> lastBlockState = new HashMap<String, DynmapBlockState>();
|
||||
IdMapper<BlockState> bsids = Block.BLOCK_STATE_REGISTRY;
|
||||
Block baseb = null;
|
||||
Iterator<BlockState> iter = bsids.iterator();
|
||||
|
||||
// Loop through block data states
|
||||
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
|
||||
while (iter.hasNext()) {
|
||||
BlockState bd = iter.next();
|
||||
Block b = bd.getBlock();
|
||||
ResourceLocation id = DefaultedRegistry.BLOCK.getKey(b);
|
||||
String bname = id.toString();
|
||||
DynmapBlockState lastbs = lastBlockState.get(bname); // See if we have seen this one
|
||||
int idx = 0;
|
||||
if (lastbs != null) { // Yes
|
||||
idx = lastbs.getStateCount(); // Get number of states so far, since this is next
|
||||
}
|
||||
// Build state name
|
||||
String sb = "";
|
||||
String fname = bd.toString();
|
||||
int off1 = fname.indexOf('[');
|
||||
if (off1 >= 0) {
|
||||
int off2 = fname.indexOf(']');
|
||||
sb = fname.substring(off1 + 1, off2);
|
||||
}
|
||||
net.minecraft.world.level.material.Material mat = bd.getMaterial();
|
||||
|
||||
int lightAtten = b.getLightBlock(bd, EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
|
||||
//Log.info("statename=" + bname + "[" + sb + "], lightAtten=" + lightAtten);
|
||||
// Fill in base attributes
|
||||
bld.setBaseState(lastbs).setStateIndex(idx).setBlockName(bname).setStateName(sb).setMaterial(mat.toString()).setAttenuatesLight(lightAtten);
|
||||
if (mat.isSolid()) bld.setSolid();
|
||||
if (mat == Material.AIR) bld.setAir();
|
||||
if (mat == Material.WOOD) bld.setLog();
|
||||
if (mat == Material.LEAVES) bld.setLeaves();
|
||||
if (!bd.getFluidState().isEmpty() && !(bd.getBlock() instanceof LiquidBlock)) { // Test if fluid type for block is not empty
|
||||
bld.setWaterlogged();
|
||||
}
|
||||
DynmapBlockState dbs = bld.build(); // Build state
|
||||
|
||||
dataToState.put(bd, dbs);
|
||||
lastBlockState.put(bname, (lastbs == null) ? dbs : lastbs);
|
||||
Log.verboseinfo("blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + dbs.isWaterlogged());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create chunk cache for given chunks of given world
|
||||
* @param dw - world
|
||||
* @param chunks - chunk list
|
||||
* @return cache
|
||||
*/
|
||||
@Override
|
||||
public MapChunkCache getChunkCache(BukkitWorld dw, List<DynmapChunk> chunks) {
|
||||
MapChunkCache119 c = new MapChunkCache119(gencache);
|
||||
c.setChunks(dw, chunks);
|
||||
return c;
|
||||
}
|
||||
|
||||
DynmapBlockState dbs = bld.build(); // Build state
|
||||
|
||||
dataToState.put(bd, dbs);
|
||||
lastBlockState.put(bname, (lastbs == null) ? dbs : lastbs);
|
||||
Log.verboseinfo("blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + dbs.isWaterlogged());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create chunk cache for given chunks of given world
|
||||
*
|
||||
* @param dw - world
|
||||
* @param chunks - chunk list
|
||||
* @return cache
|
||||
*/
|
||||
@Override
|
||||
public MapChunkCache getChunkCache(BukkitWorld dw, List<DynmapChunk> chunks) {
|
||||
MapChunkCache119 c = new MapChunkCache119(gencache);
|
||||
c.setChunks(dw, chunks);
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get biome base water multiplier
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public int getBiomeBaseWaterMult(Object bb) {
|
||||
BiomeBase biome = (BiomeBase) bb;
|
||||
return biome.k(); // waterColor
|
||||
Biome biome = (Biome) bb;
|
||||
return biome.getWaterColor();
|
||||
}
|
||||
|
||||
/** Get temperature from biomebase */
|
||||
@Override
|
||||
public float getBiomeBaseTemperature(Object bb) {
|
||||
return ((BiomeBase)bb).i();
|
||||
}
|
||||
/**
|
||||
* Get temperature from biomebase
|
||||
*/
|
||||
@Override
|
||||
public float getBiomeBaseTemperature(Object bb) {
|
||||
return ((Biome) bb).getBaseTemperature();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get humidity from biomebase
|
||||
*/
|
||||
@Override
|
||||
public float getBiomeBaseHumidity(Object bb) {
|
||||
return ((Biome) bb).getDownfall();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Polygon getWorldBorder(World world) {
|
||||
Polygon p = null;
|
||||
WorldBorder wb = world.getWorldBorder();
|
||||
if (wb != null) {
|
||||
Location c = wb.getCenter();
|
||||
double size = wb.getSize();
|
||||
if ((size > 1) && (size < 1E7)) {
|
||||
size = size / 2;
|
||||
p = new Polygon();
|
||||
p.addVertex(c.getX() - size, c.getZ() - size);
|
||||
p.addVertex(c.getX() + size, c.getZ() - size);
|
||||
p.addVertex(c.getX() + size, c.getZ() + size);
|
||||
p.addVertex(c.getX() - size, c.getZ() + size);
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/** Get humidity from biomebase */
|
||||
@Override
|
||||
public float getBiomeBaseHumidity(Object bb) {
|
||||
return ((BiomeBase)bb).h();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Polygon getWorldBorder(World world) {
|
||||
Polygon p = null;
|
||||
WorldBorder wb = world.getWorldBorder();
|
||||
if (wb != null) {
|
||||
Location c = wb.getCenter();
|
||||
double size = wb.getSize();
|
||||
if ((size > 1) && (size < 1E7)) {
|
||||
size = size / 2;
|
||||
p = new Polygon();
|
||||
p.addVertex(c.getX()-size, c.getZ()-size);
|
||||
p.addVertex(c.getX()+size, c.getZ()-size);
|
||||
p.addVertex(c.getX()+size, c.getZ()+size);
|
||||
p.addVertex(c.getX()-size, c.getZ()+size);
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
// Send title/subtitle to user
|
||||
public void sendTitleText(Player p, String title, String subtitle, int fadeInTicks, int stayTicks, int fadeOutTIcks) {
|
||||
if (p != null) {
|
||||
p.sendTitle(title, subtitle, fadeInTicks, stayTicks, fadeOutTIcks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get material map by block ID
|
||||
*/
|
||||
@Override
|
||||
public BukkitMaterial[] getMaterialList() {
|
||||
return new BukkitMaterial[4096]; // Not used
|
||||
}
|
||||
public void sendTitleText(Player p, String title, String subtitle, int fadeInTicks, int stayTicks, int fadeOutTIcks) {
|
||||
if (p != null) {
|
||||
p.sendTitle(title, subtitle, fadeInTicks, stayTicks, fadeOutTIcks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get material map by block ID
|
||||
*/
|
||||
@Override
|
||||
public BukkitMaterial[] getMaterialList() {
|
||||
return new BukkitMaterial[4096]; // Not used
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unloadChunkNoSave(World w, org.bukkit.Chunk c, int cx, int cz) {
|
||||
|
@ -272,36 +265,37 @@ public class BukkitVersionHelperSpigot119 extends BukkitVersionHelper {
|
|||
}
|
||||
|
||||
private String[] biomenames;
|
||||
|
||||
@Override
|
||||
public String[] getBiomeNames() {
|
||||
if (biomenames == null) {
|
||||
biomenames = new String[256];
|
||||
Iterator<BiomeBase> iter = getBiomeReg().iterator();
|
||||
while (iter.hasNext()) {
|
||||
BiomeBase b = iter.next();
|
||||
int bidx = getBiomeReg().a(b);
|
||||
if (bidx >= biomenames.length) {
|
||||
biomenames = Arrays.copyOf(biomenames, bidx + biomenames.length);
|
||||
}
|
||||
biomenames[bidx] = b.toString();
|
||||
}
|
||||
}
|
||||
return biomenames;
|
||||
if (biomenames == null) {
|
||||
biomenames = new String[256];
|
||||
for (Biome b : getBiomeReg()) {
|
||||
int bidx = getBiomeReg().getId(b);
|
||||
if (bidx >= biomenames.length) {
|
||||
biomenames = Arrays.copyOf(biomenames, bidx + biomenames.length);
|
||||
}
|
||||
biomenames[bidx] = b.toString();
|
||||
}
|
||||
}
|
||||
return biomenames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStateStringByCombinedId(int blkid, int meta) {
|
||||
Log.severe("getStateStringByCombinedId not implemented");
|
||||
Log.severe("getStateStringByCombinedId not implemented");
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Get ID string from biomebase */
|
||||
@Override
|
||||
/** Get ID string from biomebase */
|
||||
public String getBiomeBaseIDString(Object bb) {
|
||||
return getBiomeReg().b((BiomeBase)bb).a();
|
||||
}
|
||||
public String getBiomeBaseIDString(Object bb) {
|
||||
return getBiomeReg().getKey((Biome) bb).getPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBiomeBaseResourceLocsation(Object bb) {
|
||||
return getBiomeReg().b((BiomeBase)bb).toString();
|
||||
public String getBiomeBaseResourceLocsation(Object bb) {
|
||||
return getBiomeReg().getKey((Biome) bb).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -327,130 +321,123 @@ public class BukkitVersionHelperSpigot119 extends BukkitVersionHelper {
|
|||
|
||||
@Override
|
||||
public long getInhabitedTicks(Chunk c) {
|
||||
return ((CraftChunk)c).getHandle().u();
|
||||
return ((CraftChunk) c).getHandle().getInhabitedTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<?, ?> getTileEntitiesForChunk(Chunk c) {
|
||||
return ((CraftChunk)c).getHandle().i;
|
||||
return ((CraftChunk) c).getHandle().blockEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTileEntityX(Object te) {
|
||||
TileEntity tileent = (TileEntity) te;
|
||||
return tileent.p().u();
|
||||
BlockEntity tileent = (BlockEntity) te;
|
||||
return tileent.getBlockPos().getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTileEntityY(Object te) {
|
||||
TileEntity tileent = (TileEntity) te;
|
||||
return tileent.p().v();
|
||||
BlockEntity tileent = (BlockEntity) te;
|
||||
return tileent.getBlockPos().getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTileEntityZ(Object te) {
|
||||
TileEntity tileent = (TileEntity) te;
|
||||
return tileent.p().w();
|
||||
BlockEntity tileent = (BlockEntity) te;
|
||||
return tileent.getBlockPos().getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object readTileEntityNBT(Object te) {
|
||||
TileEntity tileent = (TileEntity) te;
|
||||
NBTTagCompound nbt = tileent.n();
|
||||
return nbt;
|
||||
BlockEntity tileent = (BlockEntity) te;
|
||||
return tileent.saveWithId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getFieldValue(Object nbt, String field) {
|
||||
NBTTagCompound rec = (NBTTagCompound) nbt;
|
||||
NBTBase val = rec.c(field);
|
||||
if(val == null) return null;
|
||||
if(val instanceof NBTTagByte) {
|
||||
return ((NBTTagByte)val).h();
|
||||
}
|
||||
else if(val instanceof NBTTagShort) {
|
||||
return ((NBTTagShort)val).g();
|
||||
}
|
||||
else if(val instanceof NBTTagInt) {
|
||||
return ((NBTTagInt)val).f();
|
||||
}
|
||||
else if(val instanceof NBTTagLong) {
|
||||
return ((NBTTagLong)val).e();
|
||||
}
|
||||
else if(val instanceof NBTTagFloat) {
|
||||
return ((NBTTagFloat)val).j();
|
||||
}
|
||||
else if(val instanceof NBTTagDouble) {
|
||||
return ((NBTTagDouble)val).i();
|
||||
}
|
||||
else if(val instanceof NBTTagByteArray) {
|
||||
return ((NBTTagByteArray)val).d();
|
||||
}
|
||||
else if(val instanceof NBTTagString) {
|
||||
return ((NBTTagString)val).e_();
|
||||
}
|
||||
else if(val instanceof NBTTagIntArray) {
|
||||
return ((NBTTagIntArray)val).f();
|
||||
}
|
||||
return null;
|
||||
CompoundTag rec = (CompoundTag) nbt;
|
||||
Tag val = rec.get(field);
|
||||
if (val == null) return null;
|
||||
if (val instanceof ByteTag) {
|
||||
return ((ByteTag) val).getAsByte();
|
||||
} else if (val instanceof ShortTag) {
|
||||
return ((ShortTag) val).getAsShort();
|
||||
} else if (val instanceof IntTag) {
|
||||
return ((IntTag) val).getAsInt();
|
||||
} else if (val instanceof LongTag) {
|
||||
return ((LongTag) val).getAsLong();
|
||||
} else if (val instanceof FloatTag) {
|
||||
return ((FloatTag) val).getAsFloat();
|
||||
} else if (val instanceof DoubleTag) {
|
||||
return ((DoubleTag) val).getAsDouble();
|
||||
} else if (val instanceof ByteArrayTag) {
|
||||
return ((ByteArrayTag) val).getAsByteArray();
|
||||
} else if (val instanceof StringTag) {
|
||||
return val.getAsString();
|
||||
} else if (val instanceof IntArrayTag) {
|
||||
return ((IntArrayTag) val).getAsIntArray();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player[] getOnlinePlayers() {
|
||||
Collection<? extends Player> p = Bukkit.getServer().getOnlinePlayers();
|
||||
return p.toArray(new Player[0]);
|
||||
Collection<? extends Player> p = Bukkit.getServer().getOnlinePlayers();
|
||||
return p.toArray(new Player[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealth(Player p) {
|
||||
return p.getHealth();
|
||||
}
|
||||
|
||||
private static final Gson gson = new GsonBuilder().create();
|
||||
|
||||
/**
|
||||
* Get skin URL for player
|
||||
* @param player
|
||||
*/
|
||||
private static final Gson gson = new GsonBuilder().create();
|
||||
|
||||
/**
|
||||
* Get skin URL for player
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
@Override
|
||||
public String getSkinURL(Player player) {
|
||||
String url = null;
|
||||
CraftPlayer cp = (CraftPlayer)player;
|
||||
GameProfile profile = cp.getProfile();
|
||||
if (profile != null) {
|
||||
PropertyMap pm = profile.getProperties();
|
||||
if (pm != null) {
|
||||
Collection<Property> txt = pm.get("textures");
|
||||
Property textureProperty = Iterables.getFirst(pm.get("textures"), null);
|
||||
if (textureProperty != null) {
|
||||
String val = textureProperty.getValue();
|
||||
if (val != null) {
|
||||
TexturesPayload result = null;
|
||||
try {
|
||||
String json = new String(Base64.getDecoder().decode(val), StandardCharsets.UTF_8);
|
||||
result = gson.fromJson(json, TexturesPayload.class);
|
||||
} catch (JsonParseException e) {
|
||||
} catch (IllegalArgumentException x) {
|
||||
Log.warning("Malformed response from skin URL check: " + val);
|
||||
}
|
||||
if ((result != null) && (result.textures != null) && (result.textures.containsKey("SKIN"))) {
|
||||
url = result.textures.get("SKIN").url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
public String getSkinURL(Player player) {
|
||||
String url = null;
|
||||
CraftPlayer cp = (CraftPlayer) player;
|
||||
GameProfile profile = cp.getProfile();
|
||||
if (profile != null) {
|
||||
PropertyMap pm = profile.getProperties();
|
||||
if (pm != null) {
|
||||
Collection<Property> txt = pm.get("textures");
|
||||
Property textureProperty = Iterables.getFirst(pm.get("textures"), null);
|
||||
if (textureProperty != null) {
|
||||
String val = textureProperty.getValue();
|
||||
if (val != null) {
|
||||
TexturesPayload result = null;
|
||||
try {
|
||||
String json = new String(Base64.getDecoder().decode(val), StandardCharsets.UTF_8);
|
||||
result = gson.fromJson(json, TexturesPayload.class);
|
||||
} catch (JsonParseException e) {
|
||||
} catch (IllegalArgumentException x) {
|
||||
Log.warning("Malformed response from skin URL check: " + val);
|
||||
}
|
||||
if ((result != null) && (result.textures != null) && (result.textures.containsKey("SKIN"))) {
|
||||
url = result.textures.get("SKIN").url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
// Get minY for world
|
||||
@Override
|
||||
public int getWorldMinY(World w) {
|
||||
CraftWorld cw = (CraftWorld) w;
|
||||
return cw.getMinHeight();
|
||||
return w.getMinHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useGenericCache() {
|
||||
return true;
|
||||
}
|
||||
public boolean useGenericCache() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package org.dynmap.bukkit.helper.v119;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkSerializer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.dynmap.DynmapChunk;
|
||||
|
@ -9,17 +13,10 @@ import org.dynmap.common.chunk.GenericChunk;
|
|||
import org.dynmap.common.chunk.GenericChunkCache;
|
||||
import org.dynmap.common.chunk.GenericMapChunkCache;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.level.ChunkCoordIntPair;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkRegionLoader;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
|
@ -38,36 +35,38 @@ public class MapChunkCache119 extends GenericMapChunkCache {
|
|||
// Load generic chunk from existing and already loaded chunk
|
||||
@Override
|
||||
protected Supplier<GenericChunk> getLoadedChunkAsync(DynmapChunk chunk) {
|
||||
Supplier<NBTTagCompound> supplier = provider.getLoadedChunk((CraftWorld) w, chunk.x, chunk.z);
|
||||
Supplier<CompoundTag> supplier = provider.getLoadedChunk((CraftWorld) w, chunk.x, chunk.z);
|
||||
return () -> {
|
||||
NBTTagCompound nbt = supplier.get();
|
||||
return nbt != null ? parseChunkFromNBT(new NBT.NBTCompound(nbt)) : null;
|
||||
try {
|
||||
if (Thread.interrupted()) throw new InterruptedException(); //reason to catch it, we would throw it anyway
|
||||
CompoundTag nbt = supplier.get();
|
||||
return nbt != null ? parseChunkFromNBT(new NBT.NBTCompound(nbt)) : null;
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
protected GenericChunk getLoadedChunk(DynmapChunk chunk) {
|
||||
CraftWorld cw = (CraftWorld) w;
|
||||
if (!cw.isChunkLoaded(chunk.x, chunk.z)) return null;
|
||||
Chunk c = cw.getHandle().getChunkIfLoaded(chunk.x, chunk.z);
|
||||
if (c == null || !c.o) return null; // c.loaded
|
||||
NBTTagCompound nbt = ChunkRegionLoader.a(cw.getHandle(), c);
|
||||
return nbt != null ? parseChunkFromNBT(new NBT.NBTCompound(nbt)) : null;
|
||||
LevelChunk c = cw.getHandle().getChunkIfLoaded(chunk.x, chunk.z);
|
||||
if (c == null || !c.loaded) return null;
|
||||
CompoundTag nbt = ChunkSerializer.write(cw.getHandle(), c);
|
||||
return parseChunkFromNBT(new NBT.NBTCompound(nbt));
|
||||
}
|
||||
|
||||
// Load generic chunk from unloaded chunk
|
||||
@Override
|
||||
protected Supplier<GenericChunk> loadChunkAsync(DynmapChunk chunk){
|
||||
try {
|
||||
CompletableFuture<NBTTagCompound> nbt = provider.getChunk(((CraftWorld) w).getHandle(), chunk.x, chunk.z);
|
||||
CompletableFuture<CompoundTag> nbt = provider.getChunk(((CraftWorld) w).getHandle(), chunk.x, chunk.z);
|
||||
return () -> {
|
||||
NBTTagCompound compound;
|
||||
try {
|
||||
compound = nbt.get();
|
||||
if (Thread.interrupted()) throw new InterruptedException(); //reason to catch it, we would throw it anyway
|
||||
return nbt.join() == null ? null : parseChunkFromNBT(new NBT.NBTCompound(nbt.join()));
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return compound == null ? null : parseChunkFromNBT(new NBT.NBTCompound(compound));
|
||||
};
|
||||
} catch (InvocationTargetException | IllegalAccessException ignored) {
|
||||
return () -> null;
|
||||
|
@ -76,14 +75,12 @@ public class MapChunkCache119 extends GenericMapChunkCache {
|
|||
|
||||
protected GenericChunk loadChunk(DynmapChunk chunk) {
|
||||
CraftWorld cw = (CraftWorld) w;
|
||||
NBTTagCompound nbt = null;
|
||||
ChunkCoordIntPair cc = new ChunkCoordIntPair(chunk.x, chunk.z);
|
||||
CompoundTag nbt = null;
|
||||
ChunkPos cc = new ChunkPos(chunk.x, chunk.z);
|
||||
GenericChunk gc = null;
|
||||
try { // BUGBUG - convert this all to asyn properly, since now native async
|
||||
nbt = cw.getHandle().k().a.f(cc).join().get(); // playerChunkMap
|
||||
} catch (CancellationException cx) {
|
||||
} catch (NoSuchElementException snex) {
|
||||
}
|
||||
nbt = cw.getHandle().getChunkSource().chunkMap.read(cc).join().orElse(null); // playerChunkMap
|
||||
} catch (CancellationException ignored) {}
|
||||
if (nbt != null) {
|
||||
gc = parseChunkFromNBT(new NBT.NBTCompound(nbt));
|
||||
}
|
||||
|
|
|
@ -1,88 +1,88 @@
|
|||
package org.dynmap.bukkit.helper.v119;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import org.dynmap.common.chunk.GenericBitStorage;
|
||||
import org.dynmap.common.chunk.GenericNBTCompound;
|
||||
import org.dynmap.common.chunk.GenericNBTList;
|
||||
|
||||
import java.util.Set;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.SimpleBitStorage;
|
||||
|
||||
public class NBT {
|
||||
|
||||
public static class NBTCompound implements GenericNBTCompound {
|
||||
private final NBTTagCompound obj;
|
||||
public NBTCompound(NBTTagCompound t) {
|
||||
private final CompoundTag obj;
|
||||
public NBTCompound(CompoundTag t) {
|
||||
this.obj = t;
|
||||
}
|
||||
@Override
|
||||
public Set<String> getAllKeys() {
|
||||
return obj.d();
|
||||
return obj.getAllKeys();
|
||||
}
|
||||
@Override
|
||||
public boolean contains(String s) {
|
||||
return obj.e(s);
|
||||
return obj.contains(s);
|
||||
}
|
||||
@Override
|
||||
public boolean contains(String s, int i) {
|
||||
return obj.b(s, i);
|
||||
return obj.contains(s, i);
|
||||
}
|
||||
@Override
|
||||
public byte getByte(String s) {
|
||||
return obj.f(s);
|
||||
return obj.getByte(s);
|
||||
}
|
||||
@Override
|
||||
public short getShort(String s) {
|
||||
return obj.g(s);
|
||||
return obj.getShort(s);
|
||||
}
|
||||
@Override
|
||||
public int getInt(String s) {
|
||||
return obj.h(s);
|
||||
return obj.getInt(s);
|
||||
}
|
||||
@Override
|
||||
public long getLong(String s) {
|
||||
return obj.i(s);
|
||||
return obj.getLong(s);
|
||||
}
|
||||
@Override
|
||||
public float getFloat(String s) {
|
||||
return obj.j(s);
|
||||
return obj.getFloat(s);
|
||||
}
|
||||
@Override
|
||||
public double getDouble(String s) {
|
||||
return obj.k(s);
|
||||
return obj.getDouble(s);
|
||||
}
|
||||
@Override
|
||||
public String getString(String s) {
|
||||
return obj.l(s);
|
||||
return obj.getString(s);
|
||||
}
|
||||
@Override
|
||||
public byte[] getByteArray(String s) {
|
||||
return obj.m(s);
|
||||
return obj.getByteArray(s);
|
||||
}
|
||||
@Override
|
||||
public int[] getIntArray(String s) {
|
||||
return obj.n(s);
|
||||
return obj.getIntArray(s);
|
||||
}
|
||||
@Override
|
||||
public long[] getLongArray(String s) {
|
||||
return obj.o(s);
|
||||
return obj.getLongArray(s);
|
||||
}
|
||||
@Override
|
||||
public GenericNBTCompound getCompound(String s) {
|
||||
return new NBTCompound(obj.p(s));
|
||||
return new NBTCompound(obj.getCompound(s));
|
||||
}
|
||||
@Override
|
||||
public GenericNBTList getList(String s, int i) {
|
||||
return new NBTList(obj.c(s, i));
|
||||
return new NBTList(obj.getList(s, i));
|
||||
}
|
||||
@Override
|
||||
public boolean getBoolean(String s) {
|
||||
return obj.q(s);
|
||||
return obj.getBoolean(s);
|
||||
}
|
||||
@Override
|
||||
public String getAsString(String s) {
|
||||
return obj.c(s).e_();
|
||||
return obj.get(s).getAsString();
|
||||
}
|
||||
@Override
|
||||
public GenericBitStorage makeBitStorage(int bits, int count, long[] data) {
|
||||
|
@ -93,8 +93,8 @@ public class NBT {
|
|||
}
|
||||
}
|
||||
public static class NBTList implements GenericNBTList {
|
||||
private final NBTTagList obj;
|
||||
public NBTList(NBTTagList t) {
|
||||
private final ListTag obj;
|
||||
public NBTList(ListTag t) {
|
||||
obj = t;
|
||||
}
|
||||
@Override
|
||||
|
@ -103,11 +103,11 @@ public class NBT {
|
|||
}
|
||||
@Override
|
||||
public String getString(int idx) {
|
||||
return obj.j(idx);
|
||||
return obj.getString(idx);
|
||||
}
|
||||
@Override
|
||||
public GenericNBTCompound getCompound(int idx) {
|
||||
return new NBTCompound(obj.a(idx));
|
||||
return new NBTCompound(obj.getCompound(idx));
|
||||
}
|
||||
public String toString() {
|
||||
return obj.toString();
|
||||
|
@ -120,7 +120,7 @@ public class NBT {
|
|||
}
|
||||
@Override
|
||||
public int get(int idx) {
|
||||
return bs.a(idx);
|
||||
return bs.get(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ dependencies {
|
|||
implementation(project(':bukkit-helper-118-2')) {
|
||||
transitive = false
|
||||
}
|
||||
implementation(project(':bukkit-helper-119')) {
|
||||
implementation(project(path: ':bukkit-helper-119', configuration: 'spigotObf')) {
|
||||
transitive = false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue