Read legacy item metadata only through matching primitive types
This commit is contained in:
parent
52375707de
commit
77cf4fd023
6 changed files with 43 additions and 10 deletions
|
|
@ -16,7 +16,7 @@ Steps: validate/pin inputs; assemble deterministic complete ZIP; validate model
|
|||
|
||||
The complete pack retains existing card-art glyphs and food/entity assets, including the exact owner-observed `dunerealms:ecology/jerboa_cooked_meat` and `dunerealms:equipment/uncommon_mk3_{helmet,chestplate,leggings,boots}` keys. Tests cover all224 quality/equipment variants and the complete model/font graph. No minecraft:default font override is included. The historical dangling dunerealms:imperial_menus reference has a real compatible font definition; a negative regression fixture reproduces the fatal missing-font condition and fails validation.
|
||||
|
||||
The new GUI adapter changes only the item_model component from existing native IDs or valid existing quality/mark metadata. It does not generate grades, change native identity, item type/amount, damage, lore, enchantments, attributes or bank state. Unknown foreign/refit/food models remain untouched. Known obsolete per-world visual components are cleared while retaining their original materials and provenance. Relevant join, inventory, held-item, pickup and drop paths receive presentation hooks; newly stamped authoritative metadata is read on the server thread.
|
||||
The GUI adapter type-checks legacy native ID, quality and MK tags before reading them; STRING and INTEGER marks are supported without invalid primitive casts. It changes only the item_model component from existing native IDs or valid existing quality/mark metadata. It does not generate grades, change native identity, item type/amount, damage, lore, enchantments, attributes or bank state. Unknown foreign/refit/food models remain untouched. Known obsolete per-world visual components are cleared while retaining their original materials and provenance. Relevant join, inventory, held-item, pickup and drop paths receive presentation hooks; newly stamped authoritative metadata is read on the server thread.
|
||||
|
||||
The owner acknowledges that every dried kelp block uses the spice carrier texture network-wide, including crafted blocks/lobby. Suspicious sand stages also change globally. Worn armour skins and entity redesign are outside the supplied overlay; existing required custom entity artwork is retained. Bedrock/Geyser conversion is not claimed.
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ The owner acknowledges that every dried kelp block uses the spice carrier textur
|
|||
|
||||
Use one permanent URL `https://www.dunerealms.com/downloads/DuneRealms-Resources-EXACT_SHA.zip`, exact built SHA1/SHA256 and UUID `c24c7cf5-a292-539d-971f-a96d8b838162` on every backend. GUI menu-pack.yml uses delivery: server and the same UUID. It observes SUCCESSFULLY_LOADED for that UUID and never offers a second GUI pack. MCGUI remains external merged mode, public-url empty, telemetry disabled; the pinned runtime's merged hasPack behavior is guarded by the GUI's actual successful-load state.
|
||||
|
||||
The built immutable publisher retains old download routes for rollback. The explicit fleet installer retains the gui-preserve-backends guard. For this rollout select ONLY DunerealmsGUI.jar (version1.1.33); keep installed DuneMenus/NPC/Lobby/MCGUI and all backend JARs. Before applying, the coordinator independently verifies actual inventory and a published pack hash. Use the selected built tools and manifest together.
|
||||
The built immutable publisher retains old download routes for rollback. The explicit fleet installer retains the gui-preserve-backends guard. For this rollout select ONLY DunerealmsGUI.jar (version1.1.34); keep installed DuneMenus/NPC/Lobby/MCGUI and all backend JARs. Before applying, the coordinator independently verifies actual inventory and a published pack hash. Use the selected built tools and manifest together.
|
||||
|
||||
Receipt format3 additionally backs up server.properties bytes/UID/GID/mode and changes ONLY resource-pack, resource-pack-sha1, resource-pack-id and require-resource-pack. Plans/receipts contain no other property values. Other fields are checked by canonical semantic hashes; Paper-generated timestamp comments are not treated as configuration drift. Explicit application-level rollback restores original JAR/configuration/properties bytes and metadata, and refuses unknown subsequent setting changes. Auto rollback restores the same state after a failed start. No direct SSH implementation is embedded; the authorised coordinating chat performs host invocation.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
plugins { java }
|
||||
group = "com.dunerealms"
|
||||
version = "1.1.33"
|
||||
version = "1.1.34"
|
||||
repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/"); maven("https://repo.opencollab.dev/main/") }
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
|
||||
compileOnly("org.geysermc.floodgate:api:2.2.5-SNAPSHOT")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.11.4")
|
||||
testImplementation("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
java { toolchain.languageVersion.set(JavaLanguageVersion.of(21)) }
|
||||
|
|
|
|||
|
|
@ -20,12 +20,8 @@ final class CentralItemModels implements Listener {
|
|||
static boolean style(ItemStack item){
|
||||
if(item==null||!item.hasItemMeta())return false;
|
||||
var meta=item.getItemMeta();var data=meta.getPersistentDataContainer();
|
||||
String id=data.get(new NamespacedKey("executableitems","ei-id"),PersistentDataType.STRING);
|
||||
if(id==null)id=data.get(new NamespacedKey("dunerealms","item"),PersistentDataType.STRING);
|
||||
String quality=data.get(new NamespacedKey("dunerealms","quality"),PersistentDataType.STRING);
|
||||
var key=new NamespacedKey("dunerealms","equipment_mark");String mark=data.get(key,PersistentDataType.STRING);
|
||||
if(mark==null){Integer number=data.get(key,PersistentDataType.INTEGER);if(number!=null)mark=number.toString();}
|
||||
var before=meta.getItemModel();String target=CentralItemModelPolicy.resolve(item.getType().name(),before==null?null:before.toString(),quality,mark,id);
|
||||
var tags=CentralItemTags.read(data);
|
||||
var before=meta.getItemModel();String target=CentralItemModelPolicy.resolve(item.getType().name(),before==null?null:before.toString(),tags.quality(),tags.mark(),tags.nativeId());
|
||||
var after=target==null?null:NamespacedKey.fromString(target);
|
||||
if(Objects.equals(before,after))return false;
|
||||
meta.setItemModel(after);item.setItemMeta(meta);return true;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.dunerealms.gui;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
/** Type-check legacy metadata before reading; Paper throws on a mismatched primitive type. */
|
||||
final class CentralItemTags {
|
||||
static final NamespacedKey ENGINE_ID=new NamespacedKey("executableitems","ei-id"),LEGACY_ID=new NamespacedKey("dunerealms","item"),QUALITY=new NamespacedKey("dunerealms","quality"),MARK=new NamespacedKey("dunerealms","equipment_mark");
|
||||
record Values(String nativeId,String quality,String mark){}
|
||||
private static String text(PersistentDataContainer data,NamespacedKey key){return data.has(key,PersistentDataType.STRING)?data.get(key,PersistentDataType.STRING):null;}
|
||||
static Values read(PersistentDataContainer data){
|
||||
String id=text(data,ENGINE_ID);if(id==null)id=text(data,LEGACY_ID);
|
||||
String mark=text(data,MARK);
|
||||
if(mark==null&&data.has(MARK,PersistentDataType.INTEGER)){Integer number=data.get(MARK,PersistentDataType.INTEGER);if(number!=null)mark=number.toString();}
|
||||
return new Values(id,text(data,QUALITY),mark);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
name: DunerealmsGUI
|
||||
main: com.dunerealms.gui.DuneGUI
|
||||
version: 1.1.33
|
||||
version: 1.1.34
|
||||
api-version: '1.21.8'
|
||||
depend: [JarvisTranslator]
|
||||
softdepend: [Citizens, MCGUI, DecentHolograms, DuneLobby, DuneCore, DuneEss, DuneNPC, Vault, floodgate, ViaVersion]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.dunerealms.gui;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.*;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.persistence.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
class CentralItemTagsTest {
|
||||
private PersistentDataContainer container(Map<NamespacedKey,Object> values){
|
||||
return (PersistentDataContainer)Proxy.newProxyInstance(getClass().getClassLoader(),new Class[]{PersistentDataContainer.class},(proxy,method,args)->{
|
||||
Object value=values.get(args[0]);
|
||||
if(method.getName().equals("has"))return args.length==1?value!=null:((PersistentDataType<?,?>)args[1]).getPrimitiveType().isInstance(value);
|
||||
if(method.getName().equals("get")){if(value!=null&&!((PersistentDataType<?,?>)args[1]).getPrimitiveType().isInstance(value))throw new IllegalArgumentException("Stored primitive differs");return value;}
|
||||
throw new AssertionError("Read-only metadata expected: "+method.getName());
|
||||
});
|
||||
}
|
||||
@Test void integerMarkDoesNotAttemptAnInvalidStringRead(){var values=new HashMap<NamespacedKey,Object>();values.put(CentralItemTags.MARK,3);values.put(CentralItemTags.QUALITY,"uncommon");var tags=CentralItemTags.read(container(values));assertEquals("3",tags.mark());assertEquals("dunerealms:equipment/uncommon_mk3_helmet",CentralItemModelPolicy.resolve("NETHERITE_HELMET",null,tags.quality(),tags.mark(),tags.nativeId()));assertEquals(3,values.get(CentralItemTags.MARK));}
|
||||
@Test void stringMarkAndLegacyIdentityArePreserved(){var values=Map.<NamespacedKey,Object>of(CentralItemTags.MARK,"6",CentralItemTags.QUALITY,"rare",CentralItemTags.LEGACY_ID,"spice");var tags=CentralItemTags.read(container(values));assertEquals("6",tags.mark());assertEquals("rare",tags.quality());assertEquals("spice",tags.nativeId());}
|
||||
@Test void unrelatedOrMalformedPrimitiveTypesAreIgnoredWithoutMutation(){var values=Map.<NamespacedKey,Object>of(CentralItemTags.MARK,1.5,CentralItemTags.QUALITY,4,CentralItemTags.ENGINE_ID,new byte[]{1});var tags=CentralItemTags.read(container(values));assertNull(tags.mark());assertNull(tags.quality());assertNull(tags.nativeId());assertEquals(3,values.size());}
|
||||
}
|
||||
Loading…
Reference in a new issue

Staff