mirror of
https://github.com/CarmJos/MineConfiguration.git
synced 2026-06-04 13:55:03 +08:00
fix(item): 修复物品获取后修改被直接应用到缓存导致重复获取第一次物品的问题。
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>2.6.1</version>
|
<version>2.6.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>2.6.1</version>
|
<version>2.6.2</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+7
-5
@@ -13,10 +13,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class ConfiguredItem extends ConfiguredSection<ItemStack> {
|
public class ConfiguredItem extends ConfiguredSection<ItemStack> {
|
||||||
@@ -40,6 +37,11 @@ public class ConfiguredItem extends ConfiguredSection<ItemStack> {
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable ItemStack get() {
|
||||||
|
return Optional.ofNullable(super.get()).map(ItemStack::clone).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
public void modifyItem(Consumer<ItemStack> modifier) {
|
public void modifyItem(Consumer<ItemStack> modifier) {
|
||||||
ItemStack item = get();
|
ItemStack item = get();
|
||||||
if (item == null) return;
|
if (item == null) return;
|
||||||
@@ -81,7 +83,7 @@ public class ConfiguredItem extends ConfiguredSection<ItemStack> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable ItemStack get(@Nullable Player player, @NotNull Map<String, Object> placeholders) {
|
public @Nullable ItemStack get(@Nullable Player player, @NotNull Map<String, Object> placeholders) {
|
||||||
return get((item) -> {
|
return get(item -> {
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
if (meta == null) return;
|
if (meta == null) return;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>2.6.1</version>
|
<version>2.6.2</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<version>2.6.1</version>
|
<version>2.6.2</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<modules>
|
<modules>
|
||||||
<module>common</module>
|
<module>common</module>
|
||||||
|
|||||||
Reference in New Issue
Block a user