mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-17 14:21:33 +00:00
Added autocomplete for enchantment types.
This commit is contained in:
@@ -22,17 +22,7 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.core.loader.IrisData;
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
import com.volmit.iris.core.loader.IrisRegistrant;
|
||||||
import com.volmit.iris.core.loader.ResourceLoader;
|
import com.volmit.iris.core.loader.ResourceLoader;
|
||||||
import com.volmit.iris.engine.object.annotations.ArrayType;
|
import com.volmit.iris.engine.object.annotations.*;
|
||||||
import com.volmit.iris.engine.object.annotations.Desc;
|
|
||||||
import com.volmit.iris.engine.object.annotations.MaxNumber;
|
|
||||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
|
||||||
import com.volmit.iris.engine.object.annotations.RegistryListBlockType;
|
|
||||||
import com.volmit.iris.engine.object.annotations.RegistryListFont;
|
|
||||||
import com.volmit.iris.engine.object.annotations.RegistryListItemType;
|
|
||||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
|
||||||
import com.volmit.iris.engine.object.annotations.RegistryListSpecialEntity;
|
|
||||||
import com.volmit.iris.engine.object.annotations.Required;
|
|
||||||
import com.volmit.iris.engine.object.annotations.Snippet;
|
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.data.B;
|
import com.volmit.iris.util.data.B;
|
||||||
@@ -52,7 +42,7 @@ public class SchemaBuilder {
|
|||||||
private static final String SYMBOL_LIMIT__N = "*";
|
private static final String SYMBOL_LIMIT__N = "*";
|
||||||
private static final String SYMBOL_TYPE__N = "";
|
private static final String SYMBOL_TYPE__N = "";
|
||||||
private static final JSONArray POTION_TYPES = getPotionTypes();
|
private static final JSONArray POTION_TYPES = getPotionTypes();
|
||||||
private static final JSONArray ENCHANT_TYPES = getEnchantmentTypes();
|
private static final JSONArray ENCHANT_TYPES = getEnchantTypes();
|
||||||
private static final JSONArray ITEM_TYPES = new JSONArray(B.getItemTypes());
|
private static final JSONArray ITEM_TYPES = new JSONArray(B.getItemTypes());
|
||||||
private static final JSONArray FONT_TYPES = new JSONArray(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
|
private static final JSONArray FONT_TYPES = new JSONArray(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
|
||||||
private final KMap<String, JSONObject> definitions;
|
private final KMap<String, JSONObject> definitions;
|
||||||
@@ -67,16 +57,6 @@ public class SchemaBuilder {
|
|||||||
this.root = root;
|
this.root = root;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JSONArray getEnchantmentTypes() {
|
|
||||||
JSONArray a = new JSONArray();
|
|
||||||
|
|
||||||
for(Field gg : Enchantment.class.getDeclaredFields()) {
|
|
||||||
a.put(gg.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static JSONArray getPotionTypes() {
|
private static JSONArray getPotionTypes() {
|
||||||
JSONArray a = new JSONArray();
|
JSONArray a = new JSONArray();
|
||||||
|
|
||||||
@@ -87,6 +67,14 @@ public class SchemaBuilder {
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static JSONArray getEnchantTypes() {
|
||||||
|
JSONArray array = new JSONArray();
|
||||||
|
for(Enchantment e : Enchantment.values()) {
|
||||||
|
array.put(e.getKey().getKey());
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
public JSONObject construct() {
|
public JSONObject construct() {
|
||||||
JSONObject schema = new JSONObject();
|
JSONObject schema = new JSONObject();
|
||||||
schema.put("$schema", "http://json-schema.org/draft-07/schema#");
|
schema.put("$schema", "http://json-schema.org/draft-07/schema#");
|
||||||
@@ -309,7 +297,7 @@ public class SchemaBuilder {
|
|||||||
prop.put("$ref", "#/definitions/" + key);
|
prop.put("$ref", "#/definitions/" + key);
|
||||||
description.add(SYMBOL_TYPE__N + " Must be a valid Font Family (use ctrl+space for auto complete!)");
|
description.add(SYMBOL_TYPE__N + " Must be a valid Font Family (use ctrl+space for auto complete!)");
|
||||||
|
|
||||||
} else if(k.getType().equals(Enchantment.class)) {
|
} else if(k.isAnnotationPresent(RegistryListEnchantment.class)) {
|
||||||
String key = "enum-enchantment";
|
String key = "enum-enchantment";
|
||||||
|
|
||||||
if(!definitions.containsKey(key)) {
|
if(!definitions.containsKey(key)) {
|
||||||
@@ -483,7 +471,7 @@ public class SchemaBuilder {
|
|||||||
items.put("$ref", "#/definitions/" + key);
|
items.put("$ref", "#/definitions/" + key);
|
||||||
prop.put("items", items);
|
prop.put("items", items);
|
||||||
description.add(SYMBOL_TYPE__N + " Must be a valid Font Family (use ctrl+space for auto complete!)");
|
description.add(SYMBOL_TYPE__N + " Must be a valid Font Family (use ctrl+space for auto complete!)");
|
||||||
} else if(t.type().equals(Enchantment.class)) {
|
} else if(k.isAnnotationPresent(RegistryListEnchantment.class)) {
|
||||||
fancyType = "List of Enchantment Types";
|
fancyType = "List of Enchantment Types";
|
||||||
String key = "enum-enchantment";
|
String key = "enum-enchantment";
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,9 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
@Data
|
@Data
|
||||||
public class IrisEnchantment {
|
public class IrisEnchantment {
|
||||||
@Required
|
@Required
|
||||||
|
@RegistryListEnchantment
|
||||||
@Desc("The enchantment")
|
@Desc("The enchantment")
|
||||||
private String enchantment = "";
|
private String enchantment;
|
||||||
|
|
||||||
@MinNumber(1)
|
@MinNumber(1)
|
||||||
@Desc("Minimum amount of this loot")
|
@Desc("Minimum amount of this loot")
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.volmit.iris.engine.object.annotations;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import static java.lang.annotation.ElementType.*;
|
||||||
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
|
||||||
|
@Retention(RUNTIME)
|
||||||
|
@Target({PARAMETER, TYPE, FIELD})
|
||||||
|
public @interface RegistryListEnchantment {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user