31
31
* @author FlameyosFlow
32
32
* @since 2.0.0
33
33
*/
34
- @ ApiStatus .Experimental
35
34
public class State {
36
35
private final TextHolder key ;
37
36
private final MenuItem item ;
38
37
private final Supplier <TextHolder > value ;
38
+ private final Lore originalLore ;
39
39
40
40
private State (TextHolder key , Supplier <TextHolder > value , @ NotNull MenuItem item ) {
41
41
this .item = item ;
@@ -50,6 +50,7 @@ private State(TextHolder key, Supplier<TextHolder> value, @NotNull MenuItem item
50
50
51
51
this .key = key ;
52
52
this .value = value ;
53
+ this .originalLore = new Lore (stack .getItemMeta ());
53
54
}
54
55
55
56
@ Contract (value = "_, _, _ -> new" , pure = true )
@@ -100,12 +101,13 @@ private State(TextHolder key, Supplier<TextHolder> value, @NotNull MenuItem item
100
101
@ Contract (pure = true )
101
102
public void update () {
102
103
ItemStack otherItem = item .getItemStack ();
103
- ItemMeta meta = Preconditions .checkNotNull (otherItem .getItemMeta ());
104
- Lore lore = new Lore (meta );
104
+ Lore lore = new Lore (originalLore );
105
105
106
106
int size = lore .size ();
107
- for (int stringIndex = 0 ; stringIndex < size ; stringIndex ++) replaceWithKey (stringIndex , lore , key , value );
108
- lore .toItemLore (item .getItemStack ());
107
+ for (int stringIndex = 0 ; stringIndex < size ; stringIndex ++) {
108
+ replaceWithKey (stringIndex , lore , key , value );
109
+ }
110
+ lore .toItemLore (otherItem );
109
111
}
110
112
111
113
private static void replaceWithKey (int stringIndex , @ NotNull Lore list , TextHolder key , Supplier <TextHolder > value ) {
0 commit comments