mirror of
https://github.com/misode/misode.github.io.git
synced 2026-05-02 13:42:55 +00:00
Add filtering in enums + handle JSON errors
This commit is contained in:
+21
-44
@@ -267,45 +267,7 @@
|
|||||||
"id": "enchantments",
|
"id": "enchantments",
|
||||||
"type": "set",
|
"type": "set",
|
||||||
"source": "enchantment",
|
"source": "enchantment",
|
||||||
"values": [
|
"values": "enchantments",
|
||||||
"minecraft:aqua_affinity",
|
|
||||||
"minecraft:bane_of_arthropods",
|
|
||||||
"minecraft:blast_protection",
|
|
||||||
"minecraft:channeling",
|
|
||||||
"minecraft:binding_curse",
|
|
||||||
"minecraft:vanishing_curse",
|
|
||||||
"minecraft:depth_strider",
|
|
||||||
"minecraft:efficiency",
|
|
||||||
"minecraft:feather_falling",
|
|
||||||
"minecraft:fire_aspect",
|
|
||||||
"minecraft:fire_protection",
|
|
||||||
"minecraft:flame",
|
|
||||||
"minecraft:fortune",
|
|
||||||
"minecraft:frost_walker",
|
|
||||||
"minecraft:impaling",
|
|
||||||
"minecraft:infinity",
|
|
||||||
"minecraft:knockback",
|
|
||||||
"minecraft:looting",
|
|
||||||
"minecraft:loyalty",
|
|
||||||
"minecraft:luck_of_the_sea",
|
|
||||||
"minecraft:lure",
|
|
||||||
"minecraft:mending",
|
|
||||||
"minecraft:multishot",
|
|
||||||
"minecraft:piercing",
|
|
||||||
"minecraft:power",
|
|
||||||
"minecraft:projectile_protection",
|
|
||||||
"minecraft:protection",
|
|
||||||
"minecraft:punch",
|
|
||||||
"minecraft:quick_charge",
|
|
||||||
"minecraft:respiration",
|
|
||||||
"minecraft:riptide",
|
|
||||||
"minecraft:sharpness",
|
|
||||||
"minecraft:silk_touch",
|
|
||||||
"minecraft:smite",
|
|
||||||
"minecraft:sweeping",
|
|
||||||
"minecraft:thorns",
|
|
||||||
"minecraft:unbreaking"
|
|
||||||
],
|
|
||||||
"require": [
|
"require": [
|
||||||
"minecraft:enchant_randomly"
|
"minecraft:enchant_randomly"
|
||||||
]
|
]
|
||||||
@@ -409,17 +371,32 @@
|
|||||||
"minecraft:alternative",
|
"minecraft:alternative",
|
||||||
"minecraft:inverted",
|
"minecraft:inverted",
|
||||||
"minecraft:entity_properties",
|
"minecraft:entity_properties",
|
||||||
"minecraft:block_state_propery",
|
{
|
||||||
"minecraft:match_tool",
|
"value": "minecraft:block_state_propery",
|
||||||
"minecraft:damage_source_properties",
|
"require": ["minecraft:block"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "minecraft:match_tool",
|
||||||
|
"require": ["minecraft:block", "minecraft:fishing"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "minecraft:damage_source_properties",
|
||||||
|
"require": ["minecraft:entity"]
|
||||||
|
},
|
||||||
"minecraft:location_check",
|
"minecraft:location_check",
|
||||||
"minecraft:weather_check",
|
"minecraft:weather_check",
|
||||||
"minecraft:entity_scores",
|
"minecraft:entity_scores",
|
||||||
"minecraft:random_chance",
|
"minecraft:random_chance",
|
||||||
"minecraft:random_chance_with_looting",
|
"minecraft:random_chance_with_looting",
|
||||||
"minecraft:table_bonus",
|
{
|
||||||
|
"value": "minecraft:table_bonus",
|
||||||
|
"require": ["minecraft:block"]
|
||||||
|
},
|
||||||
"minecraft:killed_by_player",
|
"minecraft:killed_by_player",
|
||||||
"minecraft:survives_explosion"
|
{
|
||||||
|
"value": "survives_explosion",
|
||||||
|
"require": ["minecraft:block"]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,10 +5,23 @@ let collections;
|
|||||||
changeVersion('1.14');
|
changeVersion('1.14');
|
||||||
function changeVersion(version) {
|
function changeVersion(version) {
|
||||||
$.getJSON('schemas/' + version + '.json', json => {
|
$.getJSON('schemas/' + version + '.json', json => {
|
||||||
$('#versionLabel').text(version);
|
|
||||||
structure = json.root;
|
structure = json.root;
|
||||||
components = json.components;
|
components = json.components;
|
||||||
collections = json.collections;
|
collections = json.collections;
|
||||||
|
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||||
|
let message = 'Failed loading ' + version + ' schema';
|
||||||
|
structure = {
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
id: 'pools',
|
||||||
|
type: 'error',
|
||||||
|
message: message
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
console.error(message + '\n' + errorThrown);
|
||||||
|
}).always(() => {
|
||||||
|
$('#versionLabel').text(version);
|
||||||
updateView();
|
updateView();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -56,7 +69,9 @@ function generateComponent(data, struct) {
|
|||||||
case 'nbt': return generateNbt(data, struct);
|
case 'nbt': return generateNbt(data, struct);
|
||||||
case 'array': return generateArray(data, struct);
|
case 'array': return generateArray(data, struct);
|
||||||
case 'object': return generateObject(data, struct, false);
|
case 'object': return generateObject(data, struct, false);
|
||||||
default: return generateError('Unknown component type "' + struct.type + '"')};
|
case 'error': return generateError(struct);
|
||||||
|
default: return generateError('Unknown component type "' + struct.type + '"');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateString(data, struct) {
|
function generateString(data, struct) {
|
||||||
@@ -138,8 +153,15 @@ function generateEnum(data, struct) {
|
|||||||
$el.find('select').append(setValueAndName($('<option/>'), 'unset', undefined));
|
$el.find('select').append(setValueAndName($('<option/>'), 'unset', undefined));
|
||||||
}
|
}
|
||||||
for (let value of collection) {
|
for (let value of collection) {
|
||||||
|
if (typeof value === 'object') {
|
||||||
|
console.log(value);
|
||||||
|
if (value.require.includes(table.type)) {
|
||||||
|
$el.find('select').append(setValueAndName($('<option/>'), value.value, struct.source));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$el.find('select').append(setValueAndName($('<option/>'), value, struct.source));
|
$el.find('select').append(setValueAndName($('<option/>'), value, struct.source));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$el.find('select').val(data);
|
$el.find('select').val(data);
|
||||||
return $el;
|
return $el;
|
||||||
}
|
}
|
||||||
@@ -148,7 +170,11 @@ function generateSet(data, struct) {
|
|||||||
let $el = $('#components').find('[data-type="set"]').clone();
|
let $el = $('#components').find('[data-type="set"]').clone();
|
||||||
$el.attr('data-field', struct.id);
|
$el.attr('data-field', struct.id);
|
||||||
$el.find('[data-name]').attr('data-i18n', struct.id);
|
$el.find('[data-name]').attr('data-i18n', struct.id);
|
||||||
for (let value of struct.values) {
|
let collection = struct.values;
|
||||||
|
if (typeof struct.values === 'string') {
|
||||||
|
collection = collections[struct.values];
|
||||||
|
}
|
||||||
|
for (let value of collection) {
|
||||||
let $item = $('<a class="dropdown-item" onclick="addToSet(this, \'' + struct.id + '\')" />');
|
let $item = $('<a class="dropdown-item" onclick="addToSet(this, \'' + struct.id + '\')" />');
|
||||||
setValueAndName($item, value, struct.source);
|
setValueAndName($item, value, struct.source);
|
||||||
$el.find('.dropdown-menu').append($item);
|
$el.find('.dropdown-menu').append($item);
|
||||||
@@ -212,8 +238,14 @@ function generateNbt(data, struct) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function generateError(error) {
|
function generateError(error) {
|
||||||
|
let message = 'Unknown Error';
|
||||||
|
if (typeof error === 'object' && typeof error.message === 'string') {
|
||||||
|
message = error.message;
|
||||||
|
} else if (typeof error === 'string'){
|
||||||
|
message = error;
|
||||||
|
}
|
||||||
let $el = $('#components').find('[data-type="error"]').clone();
|
let $el = $('#components').find('[data-type="error"]').clone();
|
||||||
$el.find('[data-name]').val(error);
|
$el.find('[data-name]').val(message);
|
||||||
return $el;
|
return $el;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user