nothing to see here
This commit is contained in:
parent
f65a672a93
commit
7795c7a00e
|
@ -16,13 +16,16 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -127,11 +130,12 @@ public class FlatItemDb extends AbstractItemDb {
|
|||
final ItemStack stack = new ItemStack(material);
|
||||
stack.setAmount(material.getMaxStackSize());
|
||||
|
||||
final PotionMetaProvider.AbstractPotionData potionData = data.getPotionData();
|
||||
final ItemData.EssentialPotionData potionData = data.getPotionData();
|
||||
final ItemMeta meta = stack.getItemMeta();
|
||||
|
||||
if (potionData != null && meta instanceof PotionMeta) {
|
||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
||||
potionMeta.setBasePotionType(potionData.getType());
|
||||
//todo figure out what to do here potionMeta.setBasePotionType(potionData);
|
||||
}
|
||||
|
||||
|
@ -205,7 +209,7 @@ public class FlatItemDb extends AbstractItemDb {
|
|||
|
||||
if (MaterialUtil.isPotion(type) && item.getItemMeta() instanceof PotionMeta) {
|
||||
final PotionMetaProvider.AbstractPotionData potion = ess.getPotionMetaProvider().getPotionData(item);
|
||||
return new ItemData(type, potion);
|
||||
return new ItemData(type, new ItemData.EssentialPotionData(potion.getType(), potion.isUpgraded(), potion.isExtended();
|
||||
} else if (type.toString().contains("SPAWNER")) {
|
||||
final EntityType entity = ess.getSpawnerItemProvider().getEntityType(item);
|
||||
return new ItemData(type, entity);
|
||||
|
@ -224,17 +228,16 @@ public class FlatItemDb extends AbstractItemDb {
|
|||
public static class ItemData {
|
||||
private Material material;
|
||||
private String[] fallbacks = null;
|
||||
// todo unfuck all of this
|
||||
//private PotionMetaProvider.AbstractPotionData potionData = null;
|
||||
private EssentialPotionData potionData = null;
|
||||
private EntityType entity = null;
|
||||
|
||||
ItemData(final Material material) {
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
ItemData(final Material material, final PotionMetaProvider.AbstractPotionData potionData) {
|
||||
ItemData(final Material material, final EssentialPotionData potionData) {
|
||||
this.material = material;
|
||||
//this.potionData = potionData;
|
||||
this.potionData = potionData;
|
||||
}
|
||||
|
||||
ItemData(final Material material, final EntityType entity) {
|
||||
|
@ -244,8 +247,7 @@ public class FlatItemDb extends AbstractItemDb {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * material.hashCode();
|
||||
//return (31 * material.hashCode()) ^ potionData.hashCode();
|
||||
return (31 * material.hashCode()) ^ potionData.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -269,9 +271,8 @@ public class FlatItemDb extends AbstractItemDb {
|
|||
return material;
|
||||
}
|
||||
|
||||
public PotionMetaProvider.AbstractPotionData getPotionData() {
|
||||
return null;
|
||||
//return this.potionData;
|
||||
public EssentialPotionData getPotionData() {
|
||||
return this.potionData;
|
||||
}
|
||||
|
||||
public EntityType getEntity() {
|
||||
|
@ -279,8 +280,6 @@ public class FlatItemDb extends AbstractItemDb {
|
|||
}
|
||||
|
||||
private boolean potionDataEquals(final ItemData o) {
|
||||
return true;
|
||||
/*
|
||||
if (this.potionData == null && o.getPotionData() == null) {
|
||||
return true;
|
||||
} else if (this.potionData != null && o.getPotionData() != null) {
|
||||
|
@ -288,7 +287,6 @@ public class FlatItemDb extends AbstractItemDb {
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private boolean entityEquals(final ItemData o) {
|
||||
|
@ -300,5 +298,50 @@ public class FlatItemDb extends AbstractItemDb {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EssentialPotionData {
|
||||
private PotionType type;
|
||||
private String fallbackType;
|
||||
private final boolean upgraded;
|
||||
private final boolean extended;
|
||||
|
||||
EssentialPotionData(PotionType type, boolean upgraded, boolean extended) {
|
||||
this.type = type;
|
||||
this.upgraded = upgraded;
|
||||
this.extended = extended;
|
||||
}
|
||||
|
||||
public PotionType getType() {
|
||||
if (type == null && fallbackType != null) {
|
||||
type = EnumUtil.valueOf(PotionType.class, fallbackType);
|
||||
fallbackType = null; // If fallback fails, don't keep trying to look up fallbacks
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isUpgraded() {
|
||||
return upgraded;
|
||||
}
|
||||
|
||||
public boolean isExtended() {
|
||||
return extended;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final EssentialPotionData that = (EssentialPotionData) o;
|
||||
return upgraded == that.upgraded &&
|
||||
extended == that.extended &&
|
||||
type == that.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(type, upgraded, extended);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,33 +2,9 @@ package net.ess3.provider;
|
|||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface PotionMetaProvider extends Provider {
|
||||
ItemStack createPotionItem(Material initial, int effectId);
|
||||
|
||||
AbstractPotionData getPotionData(ItemStack stack);
|
||||
|
||||
void updatePotionStack(ItemStack stack, AbstractPotionData data);
|
||||
|
||||
interface AbstractPotionData {
|
||||
/**
|
||||
* Should only be used for pre-flattening
|
||||
*/
|
||||
boolean isSplash();
|
||||
|
||||
/**
|
||||
* Should only be used for pre-flattening
|
||||
*/
|
||||
Collection<PotionEffect> getEffects();
|
||||
|
||||
int hashCode();
|
||||
|
||||
PotionType getType();
|
||||
|
||||
void setType(final PotionType type);
|
||||
}
|
||||
ItemStack setBasePotionData(ItemStack stack, PotionData data);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue