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 abstract ItemStack display(RecipeInfo recipe);
public enum RecipeOption { public enum RecipeOption {
HIDE_WHEN_LOCKED, HIDE_WHEN_LOCKED(false),
OUTPUT_ITEM, OUTPUT_ITEM(true),
SILENT_CRAFT; SILENT_CRAFT(false);
private final boolean def; private final boolean def;
private RecipeOption() { private RecipeOption(boolean def) {
// this stores the defaults of the enums this.def = def;
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());
} }
public boolean getDefault() { public boolean getDefault() {

View File

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

View File

@ -1,17 +1,10 @@
package net.Indyuce.mmoitems.api.item.build; package net.Indyuce.mmoitems.api.item.build;
import net.Indyuce.mmoitems.MMOItems; import java.util.ArrayList;
import net.Indyuce.mmoitems.api.Type; import java.util.List;
import net.Indyuce.mmoitems.api.item.MMOItem; import java.util.UUID;
import net.Indyuce.mmoitems.api.util.StatFormat; import java.util.logging.Level;
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 org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier; import org.bukkit.attribute.AttributeModifier;
@ -20,10 +13,21 @@ import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList; import net.Indyuce.mmoitems.MMOItems;
import java.util.List; import net.Indyuce.mmoitems.api.Type;
import java.util.UUID; import net.Indyuce.mmoitems.api.item.MMOItem;
import java.util.logging.Level; 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 { public class MMOItemBuilder {
private final MMOItem mmoitem; private final MMOItem mmoitem;
@ -73,6 +77,8 @@ public class MMOItemBuilder {
} }
public NBTItem buildNBT() { public NBTItem buildNBT() {
// TODO MMOItems 6 - scrap that big portion
if (MMOItems.plugin.getConfig().getBoolean("item-upgrading.display-stat-changes", false)) if (MMOItems.plugin.getConfig().getBoolean("item-upgrading.display-stat-changes", false))
if (mmoitem.isUpgradable()) { if (mmoitem.isUpgradable()) {
UpgradeData upgradeData = ((UpgradeData) mmoitem.getData(ItemStat.UPGRADE)); 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 java.util.logging.Level;
import net.Indyuce.mmoitems.comp.mythicmobs.crafting.MythicItemIngredient;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler; 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 io.lumine.xikage.mythicmobs.skills.placeholders.Placeholder;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type; 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.DropItem;
import net.Indyuce.mmoitems.api.droptable.item.MMOItemDropItem; import net.Indyuce.mmoitems.api.droptable.item.MMOItemDropItem;
import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.player.PlayerData;
import net.mmogroup.mmolib.api.util.AltChar;
public class MythicMobsHook implements Listener { public class MythicMobsHook implements Listener {
/* /*
* has been moved over to MythicMobs because MMOItems needs access to * has been moved over to MythicMobs because MMOItems needs access to MythicMobs
* MythicMobs abilities and therefore must be enabled after 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() { public MythicMobsHook() {
MythicMobs.inst().getPlaceholderManager().register("mmoitems.skill", Placeholder.meta((metadata, arg) -> String MythicMobs.inst().getPlaceholderManager().register("mmoitems.skill",
.valueOf(PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getAbilityData().getCachedModifier(arg)))); Placeholder.meta((metadata, arg) -> String.valueOf(PlayerData
.get(metadata.getCaster().getEntity().getUniqueId()).getAbilityData().getCachedModifier(arg))));
Bukkit.getPluginManager().registerEvents(this, MMOItems.plugin); Bukkit.getPluginManager().registerEvents(this, MMOItems.plugin);
// MMOItems.plugin.getCrafting().registerIngredient("mythicitem", config -> new MythicItemIngredient(config), // MMOItems.plugin.getCrafting().registerIngredient("mythicitem", config -> new MythicItemIngredient(config),
// new ConditionalDisplay("&8" + AltChar.check + " &7#amount# #item#", "&c" + AltChar.cross + " &7#amount# #item#"), // 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 * register placeholders when MM is reloaded. the skill placeholder let players
* players retrieve cached ability values. * retrieve cached ability values.
*/ */
@EventHandler @EventHandler
public void b(MythicReloadedEvent event) { public void b(MythicReloadedEvent event) {
MythicMobs.inst().getPlaceholderManager().register("mmoitems.skill", Placeholder.meta((metadata, arg) -> String MythicMobs.inst().getPlaceholderManager().register("mmoitems.skill",
.valueOf(PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getAbilityData().getCachedModifier(arg)))); Placeholder.meta((metadata, arg) -> String.valueOf(PlayerData
.get(metadata.getCaster().getEntity().getUniqueId()).getAbilityData().getCachedModifier(arg))));
} }
public class MMOItemsDrop extends Drop implements IMultiDrop { public class MMOItemsDrop extends Drop implements IMultiDrop {
@ -68,12 +72,13 @@ public class MythicMobsHook implements Listener {
super(config.getLine(), config); super(config.getLine(), config);
/* /*
* TODO move try-catch to the MythicDropLoadEvent method and make * TODO move try-catch to the MythicDropLoadEvent method and make the dropItem
* the dropItem field final * field final
*/ */
try { try {
String typeFormat = config.getString("type").toUpperCase().replace("-", "_"); 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); Type type = MMOItems.plugin.getTypes().get(typeFormat);
String id = config.getString("id"); String id = config.getString("id");
@ -96,7 +101,8 @@ public class MythicMobsHook implements Listener {
public LootBag get(DropMetadata metadata) { public LootBag get(DropMetadata metadata) {
LootBag loot = new LootBag(metadata); LootBag loot = new LootBag(metadata);
if (dropItem != null) 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; return loot;
} }
} }