Readd warnings for missing mappings

This commit is contained in:
KennyTV 2020-09-04 11:06:39 +02:00
parent 897e9545c2
commit 91b81ebb24
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
3 changed files with 33 additions and 15 deletions

View File

@ -84,11 +84,35 @@ public class BackwardsMappings extends MappingData {
return VBMappingDataLoader.loadFromDataDir("mapping-" + newVersion + "to" + oldVersion + ".json");
}
/**
* To be overridden.
*/
protected void loadVBExtras(JsonObject oldMappings, JsonObject newMappings) {
}
protected boolean shouldWarnOnMissing(String key) {
return !key.equals("blocks") && !key.equals("statistics");
}
protected void loadVBExtras(JsonObject oldMappings, JsonObject newMappings) {
/**
* @see #getMappedItem(int) for custom backwards mappings
*/
@Override
public int getNewItemId(int id) {
// Don't warn on missing here
return this.itemMappings.get(id);
}
@Override
public int getNewBlockId(int id) {
// Don't warn on missing here
return this.blockMappings.getNewId(id);
}
@Override
public int getOldItemId(final int id) {
// Warn on missing
return checkValidity(id, this.itemMappings.inverse().get(id), "item");
}
@Nullable
@ -101,11 +125,6 @@ public class BackwardsMappings extends MappingData {
return backwardsSoundMappings != null ? backwardsSoundMappings.get(id) : null;
}
@Override
protected int checkValidity(int id, String type) {
return id;
}
@Nullable
public Int2ObjectMap<MappedItem> getBackwardsItemMappings() {
return backwardsItemMappings;

View File

@ -25,9 +25,8 @@ public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewr
public Item handleItemToClient(Item item) {
if (item == null) return null;
CompoundTag display = null;
if (translatableRewriter != null
&& item.getTag() != null && (display = item.getTag().get("display")) != null) {
CompoundTag display = item.getTag() != null ? item.getTag().get("display") : null;
if (translatableRewriter != null && display != null) {
// Handle name and lore components
StringTag name = display.get("Name");
if (name != null) {

View File

@ -84,12 +84,6 @@ public class BackwardsMappings extends nl.matsv.viabackwards.api.data.BackwardsM
}
}
@Override
public int getOldItemId(final int id) {
// Return -1 when missing
return this.itemMappings.inverse().get(id);
}
@Override
@Nullable
protected Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
@ -103,6 +97,12 @@ public class BackwardsMappings extends nl.matsv.viabackwards.api.data.BackwardsM
}
}
@Override
protected int checkValidity(int id, int mappedId, String type) {
// Don't warn for missing ids here
return mappedId;
}
public Int2ObjectMap<String> getStatisticMappings() {
return statisticMappings;
}