Small cleanup

This commit is contained in:
Jules 2020-08-03 18:35:28 +02:00
parent 3ed33ac172
commit c1401eb784
4 changed files with 49 additions and 44 deletions

View File

@ -145,20 +145,14 @@ public abstract class Recipe {
public abstract ItemStack display(RecipeInfo recipe);
public enum RecipeOption {
HIDE_WHEN_LOCKED,
OUTPUT_ITEM,
SILENT_CRAFT;
HIDE_WHEN_LOCKED(false),
OUTPUT_ITEM(true),
SILENT_CRAFT(false);
private final boolean def;
private RecipeOption() {
// this stores the defaults of the enums
HashMap<String, Boolean> defaultMap = new HashMap<String, Boolean>() {{
put("HIDE_WHEN_LOCKED", false);
put("OUTPUT_ITEM", true);
put("SILENT_CRAFT", false);
}};
this.def = defaultMap.get(this.toString());
private RecipeOption(boolean def) {
this.def = def;
}
public boolean getDefault() {

View File

@ -42,10 +42,9 @@ public class RecipeInfo {
if (!info.isMet())
conditionsMet = false;
if (info.getCondition() instanceof IngredientCondition) {
if (info.getCondition() instanceof IngredientCondition)
if (ingredientsHad)
conditionsMet = true;
}
}
}

View File

@ -1,17 +1,10 @@
package net.Indyuce.mmoitems.api.item.build;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.MMOItem;
import net.Indyuce.mmoitems.api.util.StatFormat;
import net.Indyuce.mmoitems.stat.data.*;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.item.NBTItem;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
@ -20,10 +13,21 @@ import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.MMOItem;
import net.Indyuce.mmoitems.api.util.StatFormat;
import net.Indyuce.mmoitems.stat.data.DoubleData;
import net.Indyuce.mmoitems.stat.data.MaterialData;
import net.Indyuce.mmoitems.stat.data.StoredTagsData;
import net.Indyuce.mmoitems.stat.data.StringData;
import net.Indyuce.mmoitems.stat.data.UpgradeData;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.item.NBTItem;
public class MMOItemBuilder {
private final MMOItem mmoitem;
@ -73,6 +77,8 @@ public class MMOItemBuilder {
}
public NBTItem buildNBT() {
// TODO MMOItems 6 - scrap that big portion
if (MMOItems.plugin.getConfig().getBoolean("item-upgrading.display-stat-changes", false))
if (mmoitem.isUpgradable()) {
UpgradeData upgradeData = ((UpgradeData) mmoitem.getData(ItemStat.UPGRADE));

View File

@ -2,7 +2,6 @@ package net.Indyuce.mmoitems.comp.mythicmobs;
import java.util.logging.Level;
import net.Indyuce.mmoitems.comp.mythicmobs.crafting.MythicItemIngredient;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
@ -21,21 +20,25 @@ import io.lumine.xikage.mythicmobs.io.MythicLineConfig;
import io.lumine.xikage.mythicmobs.skills.placeholders.Placeholder;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.crafting.ConditionalDisplay;
import net.Indyuce.mmoitems.api.droptable.DropItem;
import net.Indyuce.mmoitems.api.droptable.item.MMOItemDropItem;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.mmogroup.mmolib.api.util.AltChar;
public class MythicMobsHook implements Listener {
/*
* has been moved over to MythicMobs because MMOItems needs access to
* MythicMobs abilities and therefore must be enabled after MythicMobs
* has been moved over to MythicMobs because MMOItems needs access to MythicMobs
* abilities and therefore must be enabled after MythicMobs
*/
/*
* MUST NOT BE REMOVED - this class must be kept as vitam aeternam in case we
* need to change something in MM compatibility and sent it back to MM devs
*/
public MythicMobsHook() {
MythicMobs.inst().getPlaceholderManager().register("mmoitems.skill", Placeholder.meta((metadata, arg) -> String
.valueOf(PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getAbilityData().getCachedModifier(arg))));
MythicMobs.inst().getPlaceholderManager().register("mmoitems.skill",
Placeholder.meta((metadata, arg) -> String.valueOf(PlayerData
.get(metadata.getCaster().getEntity().getUniqueId()).getAbilityData().getCachedModifier(arg))));
Bukkit.getPluginManager().registerEvents(this, MMOItems.plugin);
// MMOItems.plugin.getCrafting().registerIngredient("mythicitem", config -> new MythicItemIngredient(config),
// new ConditionalDisplay("&8" + AltChar.check + " &7#amount# #item#", "&c" + AltChar.cross + " &7#amount# #item#"),
@ -52,13 +55,14 @@ public class MythicMobsHook implements Listener {
}
/*
* register placeholders when MM is reloaded. the skill placeholder let
* players retrieve cached ability values.
* register placeholders when MM is reloaded. the skill placeholder let players
* retrieve cached ability values.
*/
@EventHandler
public void b(MythicReloadedEvent event) {
MythicMobs.inst().getPlaceholderManager().register("mmoitems.skill", Placeholder.meta((metadata, arg) -> String
.valueOf(PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getAbilityData().getCachedModifier(arg))));
MythicMobs.inst().getPlaceholderManager().register("mmoitems.skill",
Placeholder.meta((metadata, arg) -> String.valueOf(PlayerData
.get(metadata.getCaster().getEntity().getUniqueId()).getAbilityData().getCachedModifier(arg))));
}
public class MMOItemsDrop extends Drop implements IMultiDrop {
@ -68,12 +72,13 @@ public class MythicMobsHook implements Listener {
super(config.getLine(), config);
/*
* TODO move try-catch to the MythicDropLoadEvent method and make
* the dropItem field final
* TODO move try-catch to the MythicDropLoadEvent method and make the dropItem
* field final
*/
try {
String typeFormat = config.getString("type").toUpperCase().replace("-", "_");
Validate.isTrue(MMOItems.plugin.getTypes().has(typeFormat), "Could not find type with ID " + typeFormat);
Validate.isTrue(MMOItems.plugin.getTypes().has(typeFormat),
"Could not find type with ID " + typeFormat);
Type type = MMOItems.plugin.getTypes().get(typeFormat);
String id = config.getString("id");
@ -96,7 +101,8 @@ public class MythicMobsHook implements Listener {
public LootBag get(DropMetadata metadata) {
LootBag loot = new LootBag(metadata);
if (dropItem != null)
loot.add(new ItemDrop(this.getLine(), (MythicLineConfig) this.getConfig(), new BukkitItemStack(dropItem.getItem(1))));
loot.add(new ItemDrop(this.getLine(), (MythicLineConfig) this.getConfig(),
new BukkitItemStack(dropItem.getItem(1))));
return loot;
}
}