mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Finish the BlockData caching in Bukkit
This commit is contained in:
parent
c931095736
commit
fdb9d77710
@ -345,6 +345,8 @@ public class BukkitAdapter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Map<String, BlockData> blockDataCache = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Bukkit BlockData from a WorldEdit BlockStateHolder
|
* Create a Bukkit BlockData from a WorldEdit BlockStateHolder
|
||||||
*
|
*
|
||||||
@ -353,8 +355,14 @@ public class BukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
public static BlockData adapt(BlockStateHolder block) {
|
public static BlockData adapt(BlockStateHolder block) {
|
||||||
checkNotNull(block);
|
checkNotNull(block);
|
||||||
|
return blockDataCache.computeIfAbsent(block.getAsString(), new Function<String, BlockData>() {
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public BlockData apply(@Nullable String input) {
|
||||||
return Bukkit.createBlockData(block.getAsString());
|
return Bukkit.createBlockData(block.getAsString());
|
||||||
}
|
}
|
||||||
|
}).clone();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a WorldEdit BlockState from a Bukkit ItemStack
|
* Create a WorldEdit BlockState from a Bukkit ItemStack
|
||||||
|
Loading…
Reference in New Issue
Block a user