Add brew glint #617

This commit is contained in:
Jsinco 2024-04-04 22:30:32 -04:00
parent 66c8201430
commit 3f51fe2b31
4 changed files with 52 additions and 12 deletions

View File

@ -437,6 +437,7 @@ cauldron:
# Specific Commands for quality possible, using + bad, ++ normal, +++ good, added to the front of the line.
# drinkmessage: Chat-message to the Player when drinking the Brew
# drinktitle: Title on Screen to the Player when drinking the Brew
# glint: Boolean if the item should have a glint (enchant glint)
# customModelData: Custom Model Data Tag. This is a number that can be used to add custom textures to the item.
# Can specify one for all, or one for each quality, separated by /
# effects: List of effect/level/duration Special potion-effect when drinking, duration in sek.
@ -478,6 +479,7 @@ recipes:
- homes
drinkmessage: Tastes good
drinktitle: Warms you from inside
glint: true
customModelData: 556/557/557
effects:
- FIRE_RESISTANCE/20

View File

@ -11,6 +11,8 @@ import com.dre.brewery.recipe.RecipeItem;
import com.dre.brewery.recipe.PotionColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.jetbrains.annotations.Nullable;
@ -133,6 +135,10 @@ public class BIngredients {
cookRecipe.getColor().colorBrew(potionMeta, potion, false);
brew.updateCustomModelData(potionMeta);
if (cookRecipe.hasGlint()) {
potionMeta.addEnchant(Enchantment.LUCK, 1, true);
potionMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
} else {
// new base potion
brew = new Brew(this);

View File

@ -10,7 +10,9 @@ import com.dre.brewery.recipe.PotionColor;
import com.dre.brewery.utility.BUtil;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.BrewerInventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta;
@ -53,6 +55,7 @@ public class Brew implements Cloneable {
private boolean stripped; // Most Brewing information removed, only drinking and rough quality information available. Brew should not change anymore
private int lastUpdate; // last update in hours after install time
private boolean needsSave; // There was a change that has not yet been saved
private boolean hasGlint; // The Brew has a glint effect
/**
* A new Brew with only ingredients
@ -572,6 +575,10 @@ public class Brew implements Cloneable {
return needsSave;
}
public boolean hasGlint() {
return hasGlint;
}
public void setNeedsSave(boolean needsSave) {
this.needsSave = needsSave;
}
@ -708,6 +715,11 @@ public class Brew implements Cloneable {
lore.addOrReplaceEffects(getEffects(), quality);
potionMeta.setDisplayName(BreweryPlugin.getInstance().color("&f" + recipe.getName(quality)));
recipe.getColor().colorBrew(potionMeta, item, canDistill());
if (recipe.hasGlint()) {
potionMeta.addEnchant(Enchantment.LUCK, 1, true);
potionMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
} else {
quality = 0;
lore.convertLore(false);
@ -804,6 +816,13 @@ public class Brew implements Cloneable {
recipe.getColor().colorBrew(potionMeta, potion, false);
updateCustomModelData(potionMeta);
if (recipe.hasGlint()) {
potionMeta.addEnchant(Enchantment.LUCK, 1, true);
potionMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
potionMeta.setDisplayName(BreweryPlugin.getInstance().color("&f" + recipe.getName(quality)));
//if (!P.use1_14) {
// Before 1.14 the effects duration would strangely be only a quarter of what we tell it to be

View File

@ -56,6 +56,7 @@ public class BRecipe {
private @Nullable List<Tuple<Integer, String>> servercmds; // Commands executed as the server when drinking
private String drinkMsg; // Message when drinking
private String drinkTitle; // Title to show when drinking
private boolean glint; // If the potion should have a glint effect
private BRecipe() {
}
@ -101,7 +102,7 @@ public class BRecipe {
BreweryPlugin.getInstance().errorLog(recipeId + ": Recipe Name missing or invalid!");
return null;
}
if (recipe.getRecipeName() == null || recipe.getRecipeName().length() < 1) {
if (recipe.getRecipeName() == null || recipe.getRecipeName().isEmpty()) {
BreweryPlugin.getInstance().errorLog(recipeId + ": Recipe Name invalid");
return null;
}
@ -138,6 +139,8 @@ public class BRecipe {
recipe.drinkMsg = BreweryPlugin.getInstance().color(BUtil.loadCfgString(configSectionRecipes, recipeId + ".drinkmessage"));
recipe.drinkTitle = BreweryPlugin.getInstance().color(BUtil.loadCfgString(configSectionRecipes, recipeId + ".drinktitle"));
recipe.glint = configSectionRecipes.getBoolean(recipeId + ".glint", false);
if (configSectionRecipes.isString(recipeId + ".customModelData")) {
String[] cmdParts = configSectionRecipes.getString(recipeId + ".customModelData", "").split("/");
if (cmdParts.length == 3) {
@ -157,17 +160,15 @@ public class BRecipe {
}
List<String> effectStringList = configSectionRecipes.getStringList(recipeId + ".effects");
if (effectStringList != null) {
for (String effectString : effectStringList) {
BEffect effect = new BEffect(effectString);
if (effect.isValid()) {
recipe.effects.add(effect);
} else {
BreweryPlugin.getInstance().errorLog("Error adding Effect to Recipe: " + recipe.getRecipeName());
}
}
}
return recipe;
for (String effectString : effectStringList) {
BEffect effect = new BEffect(effectString);
if (effect.isValid()) {
recipe.effects.add(effect);
} else {
BreweryPlugin.getInstance().errorLog("Error adding Effect to Recipe: " + recipe.getRecipeName());
}
}
return recipe;
}
public static List<RecipeItem> loadIngredients(ConfigurationSection cfg, String recipeId) {
@ -660,6 +661,10 @@ public class BRecipe {
return drinkTitle;
}
public boolean hasGlint() {
return glint;
}
public List<BEffect> getEffects() {
return effects;
}
@ -945,6 +950,14 @@ public class BRecipe {
return this;
}
/**
* Add a Glint to the Potion
*/
public Builder glint(boolean glint) {
recipe.glint = glint;
return this;
}
/**
* Set the Optional ID of this recipe
*/