mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-02 16:07:06 +00:00
commit
84bb082d44
@ -24,7 +24,7 @@ plugins {
|
||||
id "de.undercouch.download" version "5.0.1"
|
||||
}
|
||||
|
||||
version '2.2.9-1.19.2' // Needs to be version specific
|
||||
version '2.2.10-1.19.2' // Needs to be version specific
|
||||
def nmsVersion = "1.19.2"
|
||||
def apiVersion = '1.19'
|
||||
def spigotJarVersion = '1.19.1-R0.1-SNAPSHOT'
|
||||
@ -38,7 +38,7 @@ registerCustomOutputTask('Psycho', 'D://Dan/MinecraftDevelopment/server/plugins'
|
||||
registerCustomOutputTask('ArcaneArts', 'C://Users/arcane/Documents/development/server/plugins')
|
||||
registerCustomOutputTask('Coco', 'D://Documents/MC/plugins')
|
||||
registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins')
|
||||
registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.19.1/plugins')
|
||||
registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.19.2/plugins')
|
||||
// ========================== UNIX ==============================
|
||||
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/development/server/plugins')
|
||||
registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Desktop/REMOTES/RemoteMinecraft/plugins')
|
||||
|
@ -22,17 +22,7 @@ import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
||||
import com.volmit.iris.core.loader.ResourceLoader;
|
||||
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||
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.engine.object.annotations.*;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
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_TYPE__N = "";
|
||||
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 FONT_TYPES = new JSONArray(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
|
||||
private final KMap<String, JSONObject> definitions;
|
||||
@ -67,16 +57,6 @@ public class SchemaBuilder {
|
||||
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() {
|
||||
JSONArray a = new JSONArray();
|
||||
|
||||
@ -87,6 +67,14 @@ public class SchemaBuilder {
|
||||
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() {
|
||||
JSONObject schema = new JSONObject();
|
||||
schema.put("$schema", "http://json-schema.org/draft-07/schema#");
|
||||
@ -309,7 +297,7 @@ public class SchemaBuilder {
|
||||
prop.put("$ref", "#/definitions/" + key);
|
||||
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";
|
||||
|
||||
if(!definitions.containsKey(key)) {
|
||||
@ -483,7 +471,7 @@ public class SchemaBuilder {
|
||||
items.put("$ref", "#/definitions/" + key);
|
||||
prop.put("items", items);
|
||||
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";
|
||||
String key = "enum-enchantment";
|
||||
|
||||
|
@ -19,21 +19,17 @@
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
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.Required;
|
||||
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@Snippet("enchantment")
|
||||
@Accessors(chain = true)
|
||||
@ -43,8 +39,9 @@ import java.lang.reflect.Field;
|
||||
@Data
|
||||
public class IrisEnchantment {
|
||||
@Required
|
||||
@RegistryListEnchantment
|
||||
@Desc("The enchantment")
|
||||
private String enchantment = "";
|
||||
private String enchantment;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum amount of this loot")
|
||||
@ -61,12 +58,17 @@ public class IrisEnchantment {
|
||||
|
||||
public void apply(RNG rng, ItemMeta meta) {
|
||||
try {
|
||||
Enchantment enchant = Enchantment.getByKey(NamespacedKey.minecraft(getEnchantment()));
|
||||
if(enchant == null) {
|
||||
Iris.warn("Unknown Enchantment: " + getEnchantment());
|
||||
return;
|
||||
}
|
||||
if(rng.nextDouble() < chance) {
|
||||
if(meta instanceof EnchantmentStorageMeta) {
|
||||
((EnchantmentStorageMeta) meta).addStoredEnchant(getEnchant(), getLevel(rng), true);
|
||||
((EnchantmentStorageMeta) meta).addStoredEnchant(enchant, getLevel(rng), true);
|
||||
return;
|
||||
}
|
||||
meta.addEnchant(getEnchant(), getLevel(rng), true);
|
||||
meta.addEnchant(enchant, getLevel(rng), true);
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
@ -74,21 +76,6 @@ public class IrisEnchantment {
|
||||
}
|
||||
}
|
||||
|
||||
public Enchantment getEnchant() {
|
||||
for(Field i : Enchantment.class.getDeclaredFields()) {
|
||||
if(i.getType().equals(Enchantment.class) && i.getName().equals(getEnchantment())) {
|
||||
try {
|
||||
return (Enchantment) i.get(null);
|
||||
} catch(IllegalArgumentException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getLevel(RNG rng) {
|
||||
return rng.i(getMinLevel(), getMaxLevel());
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class IrisLoot {
|
||||
private KList<String> lore = new KList<>();
|
||||
@RegistryListItemType
|
||||
@Required
|
||||
@Desc("This is the item or block type. Does not accept minecraft:*. Only materials such as DIAMOND_SWORD or DIRT.")
|
||||
@Desc("This is the item or block type. Does not accept minecraft:*, only materials such as DIAMOND_SWORD or DIRT. The exception are modded materials, as they require a namespace.")
|
||||
private String type = "";
|
||||
@Desc("The dye color")
|
||||
private DyeColor dyeColor = null;
|
||||
@ -120,89 +120,15 @@ public class IrisLoot {
|
||||
|
||||
public ItemStack get(boolean debug, RNG rng) {
|
||||
try {
|
||||
ItemStack is;
|
||||
if(!type.startsWith("minecraft:") && type.contains(":")) {
|
||||
Optional<ItemStack> opt = Iris.service(ExternalDataSVC.class).getItemStack(NamespacedKey.fromString(type));
|
||||
if(opt.isEmpty()) {
|
||||
//TODO Better third party provider
|
||||
Iris.warn("Unknown Material: " + type);
|
||||
return null;
|
||||
}
|
||||
is = opt.get();
|
||||
is.setAmount(Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
} else {
|
||||
is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
}
|
||||
|
||||
ItemMeta m = is.getItemMeta();
|
||||
|
||||
if(is.getType().getMaxDurability() > 0 && m instanceof Damageable d) {
|
||||
int max = is.getType().getMaxDurability();
|
||||
d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max))));
|
||||
}
|
||||
|
||||
for(IrisEnchantment i : getEnchantments()) {
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
for(IrisAttributeModifier i : getAttributes()) {
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
try {
|
||||
m.setCustomModelData(getCustomModel());
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setUnbreakable(isUnbreakable());
|
||||
|
||||
for(ItemFlag i : getItemFlags()) {
|
||||
m.addItemFlags(i);
|
||||
}
|
||||
|
||||
KList<String> lore = new KList<>();
|
||||
|
||||
getLore().forEach((i) ->
|
||||
{
|
||||
String mf = C.translateAlternateColorCodes('&', i);
|
||||
|
||||
if(mf.length() > 24) {
|
||||
for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E")) {
|
||||
lore.add(g.trim());
|
||||
}
|
||||
} else {
|
||||
lore.add(mf);
|
||||
}
|
||||
});
|
||||
|
||||
if(debug) {
|
||||
if(lore.isNotEmpty()) {
|
||||
lore.add(C.GRAY + "--------------------");
|
||||
}
|
||||
|
||||
lore.add(C.GRAY + "1 in " + (getRarity()) + " Chance (" + Form.pc(1D / (getRarity()), 5) + ")");
|
||||
}
|
||||
|
||||
m.setLore(lore);
|
||||
|
||||
if(getLeatherColor() != null && m instanceof LeatherArmorMeta) {
|
||||
Color c = Color.decode(getLeatherColor());
|
||||
((LeatherArmorMeta) m).setColor(org.bukkit.Color.fromRGB(c.getRed(), c.getGreen(), c.getBlue()));
|
||||
}
|
||||
|
||||
if(getDyeColor() != null && m instanceof Colorable) {
|
||||
((Colorable) m).setColor(getDyeColor());
|
||||
}
|
||||
|
||||
is.setItemMeta(m);
|
||||
ItemStack is = getItemStack(rng);
|
||||
if(is == null)
|
||||
return new ItemStack(Material.AIR);
|
||||
is.setItemMeta(applyProperties(is, rng, debug, null));
|
||||
return applyCustomNbt(is);
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
|
||||
public ItemStack get(boolean debug, boolean giveSomething, IrisLootTable table, RNG rng, int x, int y, int z) {
|
||||
@ -212,75 +138,10 @@ public class IrisLoot {
|
||||
|
||||
if(giveSomething || chance.aquire(() -> NoiseStyle.STATIC.create(rng)).fit(1, rarity * table.getRarity(), x, y, z) == 1) {
|
||||
try {
|
||||
ItemStack is;
|
||||
if(!type.startsWith("minecraft:") && type.contains(":")) {
|
||||
Optional<ItemStack> opt = Iris.service(ExternalDataSVC.class).getItemStack(NamespacedKey.fromString(type));
|
||||
if(opt.isEmpty()) {
|
||||
Iris.warn("Unknown Material: " + type);
|
||||
return null;
|
||||
}
|
||||
is = opt.get();
|
||||
is.setAmount(Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
return is;
|
||||
} else {
|
||||
is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
}
|
||||
|
||||
ItemMeta m = is.getItemMeta();
|
||||
|
||||
if(is.getType().getMaxDurability() > 0 && m instanceof Damageable d) {
|
||||
int max = is.getType().getMaxDurability();
|
||||
d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max))));
|
||||
}
|
||||
|
||||
for(IrisEnchantment i : getEnchantments()) {
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
for(IrisAttributeModifier i : getAttributes()) {
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
try {
|
||||
m.setCustomModelData(getCustomModel());
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
|
||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setUnbreakable(isUnbreakable());
|
||||
|
||||
for(ItemFlag i : getItemFlags()) {
|
||||
m.addItemFlags(i);
|
||||
}
|
||||
|
||||
KList<String> lore = new KList<>();
|
||||
|
||||
getLore().forEach((i) ->
|
||||
{
|
||||
String mf = C.translateAlternateColorCodes('&', i);
|
||||
|
||||
if(mf.length() > 24) {
|
||||
for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E")) {
|
||||
lore.add(g.trim());
|
||||
}
|
||||
} else {
|
||||
lore.add(mf);
|
||||
}
|
||||
});
|
||||
|
||||
if(debug) {
|
||||
if(lore.isNotEmpty()) {
|
||||
lore.add(C.GRAY + "--------------------");
|
||||
}
|
||||
|
||||
lore.add(C.GRAY + "From: " + table.getName() + " (" + Form.pc(1D / table.getRarity(), 5) + ")");
|
||||
lore.add(C.GRAY + "1 in " + (table.getRarity() * getRarity()) + " Chance (" + Form.pc(1D / (table.getRarity() * getRarity()), 5) + ")");
|
||||
}
|
||||
|
||||
m.setLore(lore);
|
||||
is.setItemMeta(m);
|
||||
ItemStack is = getItemStack(rng);
|
||||
if(is == null)
|
||||
return null;
|
||||
is.setItemMeta(applyProperties(is, rng, debug, table));
|
||||
return applyCustomNbt(is);
|
||||
} catch(Throwable e) {
|
||||
//Iris.reportError(e);
|
||||
@ -291,6 +152,98 @@ public class IrisLoot {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO Better Third Party Item Acquisition
|
||||
private ItemStack getItemStack(RNG rng) {
|
||||
if(!type.startsWith("minecraft:") && type.contains(":")) {
|
||||
Optional<ItemStack> opt = Iris.service(ExternalDataSVC.class).getItemStack(NamespacedKey.fromString(type));
|
||||
if(opt.isEmpty()) {
|
||||
Iris.warn("Unknown Material: " + type);
|
||||
return null;
|
||||
}
|
||||
ItemStack is = opt.get();
|
||||
is.setAmount(Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
return is;
|
||||
}
|
||||
return new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
}
|
||||
|
||||
private ItemMeta applyProperties(ItemStack is, RNG rng, boolean debug, IrisLootTable table) {
|
||||
ItemMeta m = is.getItemMeta();
|
||||
if(m == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for(IrisEnchantment i : getEnchantments()) {
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
for(IrisAttributeModifier i : getAttributes()) {
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
m.setUnbreakable(isUnbreakable());
|
||||
for(ItemFlag i : getItemFlags()) {
|
||||
m.addItemFlags(i);
|
||||
}
|
||||
|
||||
if(getCustomModel() != null) {
|
||||
m.setCustomModelData(getCustomModel());
|
||||
}
|
||||
|
||||
if(is.getType().getMaxDurability() > 0 && m instanceof Damageable d) {
|
||||
int max = is.getType().getMaxDurability();
|
||||
d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max))));
|
||||
}
|
||||
|
||||
if(getLeatherColor() != null && m instanceof LeatherArmorMeta leather) {
|
||||
Color c = Color.decode(getLeatherColor());
|
||||
leather.setColor(org.bukkit.Color.fromRGB(c.getRed(), c.getGreen(), c.getBlue()));
|
||||
}
|
||||
|
||||
if(getDyeColor() != null && m instanceof Colorable colorable) {
|
||||
colorable.setColor(getDyeColor());
|
||||
}
|
||||
|
||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
|
||||
|
||||
KList<String> lore = new KList<>();
|
||||
|
||||
getLore().forEach((i) ->
|
||||
{
|
||||
String mf = C.translateAlternateColorCodes('&', i);
|
||||
|
||||
if(mf.length() > 24) {
|
||||
for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E")) {
|
||||
lore.add(g.trim());
|
||||
}
|
||||
} else {
|
||||
lore.add(mf);
|
||||
}
|
||||
});
|
||||
|
||||
if(debug) {
|
||||
if(table == null) {
|
||||
if(lore.isNotEmpty()) {
|
||||
lore.add(C.GRAY + "--------------------");
|
||||
}
|
||||
lore.add(C.GRAY + "1 in " + (getRarity()) + " Chance (" + Form.pc(1D / (getRarity()), 5) + ")");
|
||||
} else {
|
||||
if(lore.isNotEmpty()) {
|
||||
lore.add(C.GRAY + "--------------------");
|
||||
}
|
||||
|
||||
lore.add(C.GRAY + "From: " + table.getName() + " (" + Form.pc(1D / table.getRarity(), 5) + ")");
|
||||
lore.add(C.GRAY + "1 in " + (table.getRarity() * getRarity()) + " Chance (" + Form.pc(1D / (table.getRarity() * getRarity()), 5) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
m.setLore(lore);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
private ItemStack applyCustomNbt(ItemStack stack) throws CommandSyntaxException {
|
||||
if(customNbt == null || customNbt.isEmpty())
|
||||
return stack;
|
||||
|
@ -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 {
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user