mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Fix persistent brushes
This commit is contained in:
parent
dbd31ea347
commit
c3db5c0cf1
@ -35,14 +35,12 @@ dependencies {
|
|||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
from (sourceSets.main.resources.srcDirs) {
|
from (sourceSets.main.resources.srcDirs) {
|
||||||
expand 'version': project.internalVersion
|
expand 'internalVersion': project.internalVersion
|
||||||
include 'plugin.yml'
|
include 'plugin.yml'
|
||||||
include 'fawe.properties'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
from (sourceSets.main.resources.srcDirs) {
|
from (sourceSets.main.resources.srcDirs) {
|
||||||
exclude 'plugin.yml'
|
exclude 'plugin.yml'
|
||||||
exclude 'fawe.properties'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ public class ItemUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public CompoundTag getNBT(ItemStack item) {
|
public CompoundTag getNBT(ItemStack item) {
|
||||||
try {
|
try {
|
||||||
if (!item.hasItemMeta()) return null;
|
if (!item.hasItemMeta()) return null;
|
||||||
|
@ -349,9 +349,7 @@ public class BukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
public static BaseItemStack adapt(ItemStack itemStack) {
|
public static BaseItemStack adapt(ItemStack itemStack) {
|
||||||
checkNotNull(itemStack);
|
checkNotNull(itemStack);
|
||||||
|
return new BukkitItemStack(itemStack);
|
||||||
|
|
||||||
return new BaseItemStack(ItemTypes.get(itemStack.getType().getKey().toString()), itemStack.getAmount());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -362,6 +360,7 @@ public class BukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
public static ItemStack adapt(BaseItemStack item) {
|
public static ItemStack adapt(BaseItemStack item) {
|
||||||
checkNotNull(item);
|
checkNotNull(item);
|
||||||
|
if (item instanceof BukkitItemStack) return ((BukkitItemStack) item).getBukkitItemStack();
|
||||||
return new ItemStack(adapt(item.getType()), item.getAmount());
|
return new ItemStack(adapt(item.getType()), item.getAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class BukkitItemStack extends BaseItemStack {
|
public class BukkitItemStack extends BaseItemStack {
|
||||||
private ItemStack stack;
|
private ItemStack stack;
|
||||||
|
private Object nativeItem;
|
||||||
private boolean loadedNBT;
|
private boolean loadedNBT;
|
||||||
|
|
||||||
public BukkitItemStack(ItemStack stack) {
|
public BukkitItemStack(ItemStack stack) {
|
||||||
@ -33,7 +34,23 @@ public class BukkitItemStack extends BaseItemStack {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Object getNativeItem() {
|
public Object getNativeItem() {
|
||||||
return super.getNativeItem();
|
ItemUtil util = Fawe.<FaweBukkit>imp().getItemUtil();
|
||||||
|
if (util != null && nativeItem == null) {
|
||||||
|
return nativeItem = util.getNMSItem(stack);
|
||||||
|
}
|
||||||
|
return nativeItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getBukkitItemStack() {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNbtData() {
|
||||||
|
if (!loadedNBT) {
|
||||||
|
return stack.hasItemMeta();
|
||||||
|
}
|
||||||
|
return super.hasNbtData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -54,6 +71,7 @@ public class BukkitItemStack extends BaseItemStack {
|
|||||||
ItemUtil util = Fawe.<FaweBukkit>imp().getItemUtil();
|
ItemUtil util = Fawe.<FaweBukkit>imp().getItemUtil();
|
||||||
if (util != null) {
|
if (util != null) {
|
||||||
stack = util.setNBT(stack, nbtData);
|
stack = util.setNBT(stack, nbtData);
|
||||||
|
nativeItem = null;
|
||||||
}
|
}
|
||||||
super.setNbtData(nbtData);
|
super.setNbtData(nbtData);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: WorldEdit
|
name: WorldEdit
|
||||||
main: com.sk89q.worldedit.bukkit.WorldEditPlugin
|
main: com.sk89q.worldedit.bukkit.WorldEditPlugin
|
||||||
version: "${version}"
|
version: "${internalVersion}"
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
description: Fast Async WorldEdit plugin
|
description: Fast Async WorldEdit plugin
|
||||||
authors: [Empire92]
|
authors: [Empire92]
|
||||||
|
@ -37,7 +37,7 @@ processResources {
|
|||||||
from('src/main/resources') {
|
from('src/main/resources') {
|
||||||
include 'fawe.properties'
|
include 'fawe.properties'
|
||||||
expand(
|
expand(
|
||||||
version: "${project.parent.version}",
|
internalVersion: "${project.parent.version}",
|
||||||
name: project.parent.name,
|
name: project.parent.name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,9 @@ public final class BrushCache {
|
|||||||
BrushTool cached = brushCache.get(key);
|
BrushTool cached = brushCache.get(key);
|
||||||
if (cached != null) return cached;
|
if (cached != null) return cached;
|
||||||
|
|
||||||
StringTag json = (StringTag) item.getNbtData().getValue().get("weBrushJson");
|
CompoundTag nbt = item.getNbtData();
|
||||||
|
if (nbt == null) return null;
|
||||||
|
StringTag json = (StringTag) nbt.getValue().get("weBrushJson");
|
||||||
if (json != null) {
|
if (json != null) {
|
||||||
try {
|
try {
|
||||||
if (RECURSION.get() != null) return null;
|
if (RECURSION.get() != null) return null;
|
||||||
|
@ -957,7 +957,7 @@ public class LocalSession implements TextureHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Tool getTool(BaseItem item, Player player) {
|
public Tool getTool(BaseItem item, Player player) {
|
||||||
if (item.getNativeItem() != null && Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES) {
|
if (Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && item.getNativeItem() != null) {
|
||||||
BrushTool tool = BrushCache.getTool(player, this, item);
|
BrushTool tool = BrushCache.getTool(player, this, item);
|
||||||
if (tool != null) return tool;
|
if (tool != null) return tool;
|
||||||
}
|
}
|
||||||
@ -1034,7 +1034,7 @@ public class LocalSession implements TextureHolder {
|
|||||||
throw new InvalidToolBindException(type, "Already used for the navigation wand");
|
throw new InvalidToolBindException(type, "Already used for the navigation wand");
|
||||||
}
|
}
|
||||||
Tool previous;
|
Tool previous;
|
||||||
if (player != null && (tool instanceof BrushTool || tool == null) && item.getNativeItem() != null && Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES) {
|
if (player != null && (tool instanceof BrushTool || tool == null) && Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && item.getNativeItem() != null) {
|
||||||
previous = BrushCache.getCachedTool(item);
|
previous = BrushCache.getCachedTool(item);
|
||||||
if (tool != null) {
|
if (tool != null) {
|
||||||
BrushCache.setTool(item, (BrushTool) tool);
|
BrushCache.setTool(item, (BrushTool) tool);
|
||||||
|
@ -168,8 +168,8 @@ public class SchematicCommands extends MethodCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"remap"},
|
aliases = {"remap"},
|
||||||
help = "Remap a clipboard between MCPE/PC values\n",
|
help = "Remap a clipboard between MCPE/PC values",
|
||||||
desc = "Remap a clipboard between MCPE/PC values\n"
|
desc = "Remap a clipboard between MCPE/PC values"
|
||||||
)
|
)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@CommandPermissions({"worldedit.schematic.remap"})
|
@CommandPermissions({"worldedit.schematic.remap"})
|
||||||
|
@ -1 +1 @@
|
|||||||
version=${version}
|
version=${internalVersion}
|
||||||
|
Loading…
Reference in New Issue
Block a user