That should do it for player knowledge related API changes. Loads of stuff in the old TransmutationKnowledgeRegistry are now deprecated.

This commit is contained in:
Pahimar 2016-05-21 22:23:21 -04:00
parent 39448076b9
commit 1487490bf5
5 changed files with 453 additions and 299 deletions

View file

@ -40,14 +40,12 @@ public class EquivalentExchange3
public static IProxy proxy; public static IProxy proxy;
@EventHandler @EventHandler
public void invalidFingerprint(FMLFingerprintViolationEvent event) public void invalidFingerprint(FMLFingerprintViolationEvent event) {
{
if (Reference.FINGERPRINT.equals("@FINGERPRINT@")) if (Reference.FINGERPRINT.equals("@FINGERPRINT@")) {
{
LogHelper.info(Messages.NO_FINGERPRINT_MESSAGE); LogHelper.info(Messages.NO_FINGERPRINT_MESSAGE);
} }
else else {
{
LogHelper.warn(Messages.INVALID_FINGERPRINT_MESSAGE); LogHelper.warn(Messages.INVALID_FINGERPRINT_MESSAGE);
} }
} }
@ -165,9 +163,8 @@ public class EquivalentExchange3
return AlchemyArrayRegistry.getInstance(); return AlchemyArrayRegistry.getInstance();
} }
public TransmutationKnowledgeRegistry getTransmutationKnowledgeRegistry() public PlayerKnowledgeRegistry getPlayerKnowledgeRegistry() {
{ return PlayerKnowledgeRegistry.INSTANCE;
return TransmutationKnowledgeRegistry.getInstance();
} }
public TileEntityDataHelper getTileEntityDataHelper() public TileEntityDataHelper getTileEntityDataHelper()

View file

@ -1,4 +1,281 @@
package com.pahimar.ee3.api.knowledge; package com.pahimar.ee3.api.knowledge;
import com.pahimar.ee3.EquivalentExchange3;
import cpw.mods.fml.common.Mod;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
public class PlayerKnowledgeRegistryProxy { public class PlayerKnowledgeRegistryProxy {
/**
* TODO Finish JavaDoc
*
* @param entityPlayer
* @param object
* @return
*/
public static boolean doesPlayerKnow(EntityPlayer entityPlayer, Object object) {
init();
if (ee3Mod != null) {
return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().doesPlayerKnow(entityPlayer, object);
}
return false;
}
/**
* TODO Finish JavaDoc
*
* @param playerName
* @param object
* @return
*/
public static boolean doesPlayerKnow(String playerName, Object object) {
init();
if (ee3Mod != null) {
return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().doesPlayerKnow(playerName, object);
}
return false;
}
/**
* TODO Finish JavaDoc
*
* @param entityPlayer
* @param object
* @return
*/
public static boolean canPlayerLearn(EntityPlayer entityPlayer, Object object) {
init();
if (ee3Mod != null) {
return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().canPlayerLearn(entityPlayer, object);
}
return false;
}
/**
* TODO Finish JavaDoc
*
* @param playerName
* @param object
* @return
*/
public static boolean canPlayerLearn(String playerName, Object object) {
init();
if (ee3Mod != null) {
return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().canPlayerLearn(playerName, object);
}
return false;
}
/**
* TODO Finish JavaDoc
*
* @param entityPlayer
* @return
*/
public static Set<ItemStack> getKnownItemStacks(EntityPlayer entityPlayer) {
init();
if (ee3Mod != null) {
return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().getKnownItemStacks(entityPlayer);
}
return Collections.EMPTY_SET;
}
/**
* TODO Finish JavaDoc
*
* @param playerName
* @return
*/
public static Set<ItemStack> getKnownItemStacks(String playerName) {
init();
if (ee3Mod != null) {
return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().getKnownItemStacks(playerName);
}
return Collections.EMPTY_SET;
}
/**
* TODO Finish JavaDoc
*
* @param entityPlayer
* @param object
*/
public static void teachPlayer(EntityPlayer entityPlayer, Object object) {
init();
if (ee3Mod != null) {
EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().teachPlayer(entityPlayer, object);
}
}
/**
* TODO Finish JavaDoc
*
* @param playerName
* @param object
*/
public static void teachPlayer(String playerName, Object object) {
init();
if (ee3Mod != null) {
EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().teachPlayer(playerName, object);
}
}
/**
* TODO Finish JavaDoc
*
* @param entityPlayer
* @param objects
*/
public static void teachPlayer(EntityPlayer entityPlayer, Collection<?> objects) {
init();
if (ee3Mod != null) {
EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().teachPlayer(entityPlayer, objects);
}
}
/**
* TODO Finish JavaDoc
*
* @param playerName
* @param objects
*/
public static void teachPlayer(String playerName, Collection<?> objects) {
init();
if (ee3Mod != null) {
EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().teachPlayer(playerName, objects);
}
}
/**
* TODO Finish JavaDoc
*
* @param entityPlayer
* @param object
*/
public static void makePlayerForget(EntityPlayer entityPlayer, Object object) {
init();
if (ee3Mod != null) {
EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForget(entityPlayer, object);
}
}
/**
* TODO Finish JavaDoc
*
* @param playerName
* @param object
*/
public static void makePlayerForget(String playerName, Object object) {
init();
if (ee3Mod != null) {
EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForget(playerName, object);
}
}
/**
* TODO Finish JavaDoc
*
* @param entityPlayer
* @param objects
*/
public static void makePlayerForget(EntityPlayer entityPlayer, Collection<?> objects) {
init();
if (ee3Mod != null) {
EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForget(entityPlayer, objects);
}
}
/**
* TODO Finish JavaDoc
*
* @param playerName
* @param objects
*/
public static void makePlayerForget(String playerName, Collection<?> objects) {
init();
if (ee3Mod != null) {
EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForget(playerName, objects);
}
}
/**
* TODO Finish JavaDoc
*
* @param entityPlayer
*/
public static void makePlayerForgetAll(EntityPlayer entityPlayer) {
init();
if (ee3Mod != null) {
EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForgetAll(entityPlayer);
}
}
/**
* TODO Finish JavaDoc
*
* @param playerName
*/
public static void makePlayerForgetAll(String playerName) {
init();
if (ee3Mod != null) {
EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForgetAll(playerName);
}
}
@Mod.Instance("EE3")
private static Object ee3Mod;
private static class EE3Wrapper {
private static EquivalentExchange3 ee3mod;
}
private static void init() {
if (ee3Mod != null) {
PlayerKnowledgeRegistryProxy.EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod;
}
}
} }

View file

@ -5,281 +5,141 @@ import cpw.mods.fml.common.Mod;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
public class TransmutationKnowledgeRegistryProxy /**
{ * @deprecated as of API 0.4.0; use {@link PlayerKnowledgeRegistryProxy} instead
public static boolean doesPlayerKnow(EntityPlayer entityPlayer, ItemStack itemStack) * @see PlayerKnowledgeRegistryProxy
{ */
init(); @Deprecated
public class TransmutationKnowledgeRegistryProxy {
if (ee3Mod != null) @Deprecated
{ public static boolean doesPlayerKnow(EntityPlayer entityPlayer, ItemStack itemStack) {
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().doesPlayerKnow(entityPlayer, itemStack); return PlayerKnowledgeRegistryProxy.doesPlayerKnow(entityPlayer, itemStack);
} }
@Deprecated
public static boolean doesPlayerKnow(UUID playerUUID, ItemStack itemStack) {
return false; return false;
} }
public static boolean doesPlayerKnow(UUID playerUUID, ItemStack itemStack) @Deprecated
{ public static boolean canPlayerLearn(EntityPlayer entityPlayer, ItemStack itemStack) {
init(); return PlayerKnowledgeRegistryProxy.canPlayerLearn(entityPlayer, itemStack);
}
if (ee3Mod != null)
{
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().doesPlayerKnow(playerUUID, itemStack);
}
@Deprecated
public static boolean canPlayerLearn(UUID playerUUID, ItemStack itemStack) {
return false; return false;
} }
public static boolean canPlayerLearn(EntityPlayer entityPlayer, ItemStack itemStack) @Deprecated
{ public static Set<ItemStack> getPlayerKnownTransmutations(EntityPlayer entityPlayer) {
init(); return PlayerKnowledgeRegistryProxy.getKnownItemStacks(entityPlayer);
}
if (ee3Mod != null) @Deprecated
{ public static Set<ItemStack> getPlayerKnownTransmutations(UUID playerUUID) {
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().canPlayerLearn(entityPlayer, itemStack); return Collections.EMPTY_SET;
} }
@Deprecated
public static Set<ItemStack> getPlayerKnownTransmutationsFilteredStartsWith(EntityPlayer entityPlayer, String filterString) {
return PlayerKnowledgeRegistryProxy.getKnownItemStacks(entityPlayer);
}
@Deprecated
public static Set<ItemStack> getPlayerKnownTransmutationsFilteredStartsWith(UUID playerUUID, String filterString) {
return Collections.EMPTY_SET;
}
@Deprecated
public static Set<ItemStack> getPlayerKnownTransmutationsFilteredContains(EntityPlayer entityPlayer, String filterString) {
return PlayerKnowledgeRegistryProxy.getKnownItemStacks(entityPlayer);
}
@Deprecated
public static Set<ItemStack> getPlayerKnownTransmutationsFilteredContains(UUID playerUUID, String filterString) {
return Collections.EMPTY_SET;
}
@Deprecated
public static void teachPlayer(EntityPlayer entityPlayer, ItemStack itemStack) {
PlayerKnowledgeRegistryProxy.teachPlayer(entityPlayer, itemStack);
}
@Deprecated
public static void teachPlayer(UUID playerUUID, ItemStack itemStack) {
// NOOP
}
@Deprecated
public static void makePlayerForget(EntityPlayer entityPlayer, ItemStack itemStack) {
PlayerKnowledgeRegistryProxy.makePlayerForget(entityPlayer, itemStack);
}
@Deprecated
public static void makePlayerForget(UUID playerUUID, ItemStack itemStack) {
// NOOP
}
@Deprecated
public static void makePlayerForgetEverything(EntityPlayer entityPlayer) {
PlayerKnowledgeRegistryProxy.makePlayerForgetAll(entityPlayer);
}
@Deprecated
public static void makePlayerForgetEverything(UUID playerUUID) {
// NOOP
}
@Deprecated
public static boolean doesTemplateKnow(ItemStack itemStack) {
return false; return false;
} }
public static boolean canPlayerLearn(UUID playerUUID, ItemStack itemStack) @Deprecated
{ public static Set<ItemStack> getTemplateKnownTransmutations() {
init(); return Collections.EMPTY_SET;
if (ee3Mod != null)
{
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().canPlayerLearn(playerUUID, itemStack);
}
return false;
} }
public static Set<ItemStack> getPlayerKnownTransmutations(EntityPlayer entityPlayer) @Deprecated
{ public static Set<ItemStack> getTemplateKnownTransmutationsFilteredStartsWith(String filterString) {
init(); return Collections.EMPTY_SET;
if (ee3Mod != null)
{
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutations(entityPlayer);
}
return null;
} }
public static Set<ItemStack> getPlayerKnownTransmutations(UUID playerUUID) @Deprecated
{ public static Set<ItemStack> getTemplateKnownTransmutationsFilteredContains(String filterString) {
init(); return Collections.EMPTY_SET;
if (ee3Mod != null)
{
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutations(playerUUID);
}
return null;
} }
public static Set<ItemStack> getPlayerKnownTransmutationsFilteredStartsWith(EntityPlayer entityPlayer, String filterString) @Deprecated
{ public static void teachTemplate(ItemStack itemStack) {
init(); // NOOP
if (ee3Mod != null)
{
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutationsFilteredStartsWith(entityPlayer, filterString);
}
return null;
} }
public static Set<ItemStack> getPlayerKnownTransmutationsFilteredStartsWith(UUID playerUUID, String filterString) @Deprecated
{ public static void makeTemplateForget(ItemStack itemStack) {
init(); // NOOP
if (ee3Mod != null)
{
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutationsFilteredStartsWith(playerUUID, filterString);
}
return null;
} }
public static Set<ItemStack> getPlayerKnownTransmutationsFilteredContains(EntityPlayer entityPlayer, String filterString) @Deprecated
{ public static void makeTemplateForgetEverything() {
init(); // NOOP
if (ee3Mod != null)
{
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutationsFilteredContains(entityPlayer, filterString);
}
return null;
}
public static Set<ItemStack> getPlayerKnownTransmutationsFilteredContains(UUID playerUUID, String filterString)
{
init();
if (ee3Mod != null)
{
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutationsFilteredContains(playerUUID, filterString);
}
return null;
}
public static void teachPlayer(EntityPlayer entityPlayer, ItemStack itemStack)
{
init();
if (ee3Mod != null)
{
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().teachPlayer(entityPlayer, itemStack);
}
}
public static void teachPlayer(UUID playerUUID, ItemStack itemStack)
{
init();
if (ee3Mod != null)
{
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().teachPlayer(playerUUID, itemStack);
}
}
public static void makePlayerForget(EntityPlayer entityPlayer, ItemStack itemStack)
{
init();
if (ee3Mod != null)
{
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makePlayerForget(entityPlayer, itemStack);
}
}
public static void makePlayerForget(UUID playerUUID, ItemStack itemStack)
{
init();
if (ee3Mod != null)
{
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makePlayerForget(playerUUID, itemStack);
}
}
public static void makePlayerForgetEverything(EntityPlayer entityPlayer)
{
init();
if (ee3Mod != null)
{
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makePlayerForgetEverything(entityPlayer);
}
}
public static void makePlayerForgetEverything(UUID playerUUID)
{
init();
if (ee3Mod != null)
{
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makePlayerForgetEverything(playerUUID);
}
}
public static boolean doesTemplateKnow(ItemStack itemStack)
{
init();
if (ee3Mod != null)
{
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().doesTemplateKnow(itemStack);
}
return false;
}
public static Set<ItemStack> getTemplateKnownTransmutations()
{
init();
if (ee3Mod != null)
{
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getTemplatesKnownTransmutations();
}
return null;
}
public static Set<ItemStack> getTemplateKnownTransmutationsFilteredStartsWith(String filterString)
{
init();
if (ee3Mod != null)
{
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getTemplatesKnownTransmutationsFilteredStartsWith(filterString);
}
return null;
}
public static Set<ItemStack> getTemplateKnownTransmutationsFilteredContains(String filterString)
{
init();
if (ee3Mod != null)
{
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getTemplatesKnownTransmutationsFilteredContains(filterString);
}
return null;
}
public static void teachTemplate(ItemStack itemStack)
{
init();
if (ee3Mod != null)
{
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().teachTemplate(itemStack);
}
}
public static void makeTemplateForget(ItemStack itemStack)
{
init();
if (ee3Mod != null)
{
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makeTemplateForget(itemStack);
}
}
public static void makeTemplateForgetEverything()
{
init();
if (ee3Mod != null)
{
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makeTemplateForgetEverything();
}
} }
@Mod.Instance("EE3") @Mod.Instance("EE3")
private static Object ee3Mod; private static Object ee3Mod;
private static class EE3Wrapper private static class EE3Wrapper {
{
private static EquivalentExchange3 ee3mod; private static EquivalentExchange3 ee3mod;
} }
private static void init() private static void init() {
{ if (ee3Mod != null) {
if (ee3Mod != null)
{
EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod; EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod;
} }
} }

View file

@ -21,21 +21,21 @@ public class PlayerKnowledge {
this(playerKnowledge.knownItemStacks); this(playerKnowledge.knownItemStacks);
} }
public PlayerKnowledge(Collection<ItemStack> itemStacks) { public PlayerKnowledge(Collection<?> objects) {
knownItemStacks = new TreeSet<>(Comparators.ID_COMPARATOR); knownItemStacks = new TreeSet<>(Comparators.ID_COMPARATOR);
if (itemStacks != null) { if (objects != null) {
for (ItemStack itemStack : itemStacks) { for (Object object : objects) {
learn(itemStack); learn(object);
} }
} }
} }
public boolean isKnown(ItemStack itemStack) { public boolean isKnown(Object object) {
if (itemStack != null) { if (object instanceof ItemStack) {
return knownItemStacks.contains(ItemHelper.clone(itemStack, 1)); return knownItemStacks.contains(ItemHelper.clone((ItemStack) object, 1));
} }
return false; return false;
@ -45,36 +45,36 @@ public class PlayerKnowledge {
return knownItemStacks; return knownItemStacks;
} }
public void learn(ItemStack itemStack) { public void learn(Object object) {
if (itemStack != null) { if (object instanceof ItemStack) {
ItemStack unitItemStack = ItemHelper.clone(itemStack, 1); ItemStack unitItemStack = ItemHelper.clone((ItemStack) object, 1);
knownItemStacks.add(unitItemStack); knownItemStacks.add(unitItemStack);
} }
} }
public void learn(Collection<ItemStack> itemStacks) { public void learn(Collection<?> objects) {
if (itemStacks != null) { if (objects != null) {
for (ItemStack itemStack : itemStacks) { for (Object object : objects) {
learn(itemStack); learn(object);
} }
} }
} }
public void forget(ItemStack itemStack) { public void forget(Object object) {
if (itemStack != null) { if (object instanceof ItemStack) {
ItemStack unitItemStack = ItemHelper.clone(itemStack, 1); ItemStack unitItemStack = ItemHelper.clone((ItemStack) object, 1);
knownItemStacks.remove(unitItemStack); knownItemStacks.remove(unitItemStack);
} }
} }
public void forget(Collection<ItemStack> itemStacks) { public void forget(Collection<?> objects) {
if (itemStacks != null) { if (objects != null) {
for (ItemStack itemStack : itemStacks) { for (Object object : objects) {
forget(itemStack); forget(object);
} }
} }
} }

View file

@ -14,6 +14,8 @@ import net.minecraft.item.ItemStack;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
public class PlayerKnowledgeRegistry { public class PlayerKnowledgeRegistry {
@ -35,107 +37,107 @@ public class PlayerKnowledgeRegistry {
return templatePlayerKnowledge; return templatePlayerKnowledge;
} }
public boolean doesPlayerKnow(EntityPlayer player, ItemStack itemStack) { public boolean doesPlayerKnow(EntityPlayer player, Object object) {
if (player != null) { if (player != null) {
return doesPlayerKnow(player.getDisplayName(), itemStack); return doesPlayerKnow(player.getDisplayName(), object);
} }
return false; return false;
} }
public boolean doesPlayerKnow(String playerName, ItemStack itemStack) { public boolean doesPlayerKnow(String playerName, Object object) {
if (getPlayerKnowledge(playerName) != null) { if (getPlayerKnowledge(playerName) != null) {
return getPlayerKnowledge(playerName).isKnown(itemStack); return getPlayerKnowledge(playerName).isKnown(object);
} }
return false; return false;
} }
public boolean canPlayerLearn(EntityPlayer entityPlayer, ItemStack itemStack) { public boolean canPlayerLearn(EntityPlayer entityPlayer, Object object) {
if (entityPlayer != null) { if (entityPlayer != null) {
return canPlayerLearn(entityPlayer.getDisplayName(), itemStack); return canPlayerLearn(entityPlayer.getDisplayName(), object);
} }
return false; return false;
} }
public boolean canPlayerLearn(String playerName, ItemStack itemStack) { public boolean canPlayerLearn(String playerName, Object object) {
if (getPlayerKnowledge(playerName) != null) { if (getPlayerKnowledge(playerName) != null) {
return !getPlayerKnowledge(playerName).isKnown(itemStack) && AbilityRegistryProxy.isLearnable(itemStack); return !getPlayerKnowledge(playerName).isKnown(object) && AbilityRegistryProxy.isLearnable(object);
} }
return false; return false;
} }
public void teachPlayer(EntityPlayer entityPlayer, ItemStack itemStack) { public void teachPlayer(EntityPlayer entityPlayer, Object object) {
if (entityPlayer != null) { if (entityPlayer != null) {
teachPlayer(entityPlayer.getDisplayName(), itemStack); teachPlayer(entityPlayer.getDisplayName(), object);
} }
} }
public void teachPlayer(String playerName, ItemStack itemStack) { public void teachPlayer(String playerName, Object object) {
if (itemStack != null && getPlayerKnowledge(playerName) != null) { if (getPlayerKnowledge(playerName) != null) {
getPlayerKnowledge(playerName).learn(itemStack); getPlayerKnowledge(playerName).learn(object);
save(playerName); save(playerName);
} }
} }
public void teachPlayer(EntityPlayer entityPlayer, Collection<ItemStack> itemStacks) { public void teachPlayer(EntityPlayer entityPlayer, Collection<?> objects) {
if (entityPlayer != null) { if (entityPlayer != null) {
teachPlayer(entityPlayer.getDisplayName(), itemStacks); teachPlayer(entityPlayer.getDisplayName(), objects);
} }
} }
public void teachPlayer(String playerName, Collection<ItemStack> itemStacks) { public void teachPlayer(String playerName, Collection<?> objects) {
if (itemStacks != null) { if (objects != null) {
PlayerKnowledge playerKnowledge = getPlayerKnowledge(playerName); PlayerKnowledge playerKnowledge = getPlayerKnowledge(playerName);
if (playerKnowledge != null) { if (playerKnowledge != null) {
itemStacks.forEach(playerKnowledge::learn); objects.forEach(playerKnowledge::learn);
save(playerName); save(playerName);
} }
} }
} }
public void makePlayerForget(EntityPlayer entityPlayer, ItemStack itemStack) { public void makePlayerForget(EntityPlayer entityPlayer, Object object) {
if (entityPlayer != null) { if (entityPlayer != null) {
makePlayerForget(entityPlayer.getDisplayName(), itemStack); makePlayerForget(entityPlayer.getDisplayName(), object);
} }
} }
public void makePlayerForget(String playerName, ItemStack itemStack) { public void makePlayerForget(String playerName, Object object) {
if (getPlayerKnowledge(playerName) != null) { if (getPlayerKnowledge(playerName) != null) {
getPlayerKnowledge(playerName).forget(itemStack); getPlayerKnowledge(playerName).forget(object);
save(playerName); save(playerName);
} }
} }
public void makePlayerForget(EntityPlayer entityPlayer, Collection<ItemStack> itemStacks) { public void makePlayerForget(EntityPlayer entityPlayer, Collection<?> objects) {
if (entityPlayer != null) { if (entityPlayer != null) {
makePlayerForget(entityPlayer.getDisplayName(), itemStacks); makePlayerForget(entityPlayer.getDisplayName(), objects);
} }
} }
public void makePlayerForget(String playerName, Collection<ItemStack> itemStacks) { public void makePlayerForget(String playerName, Collection<?> objects) {
if (itemStacks != null) { if (objects != null) {
PlayerKnowledge playerKnowledge = getPlayerKnowledge(playerName); PlayerKnowledge playerKnowledge = getPlayerKnowledge(playerName);
if (playerKnowledge != null) { if (playerKnowledge != null) {
itemStacks.forEach(playerKnowledge::forget); objects.forEach(playerKnowledge::forget);
save(playerName); save(playerName);
} }
} }
@ -156,13 +158,31 @@ public class PlayerKnowledgeRegistry {
} }
} }
public Set<ItemStack> getKnownItemStacks(EntityPlayer entityPlayer) {
if (entityPlayer != null) {
return getKnownItemStacks(entityPlayer.getDisplayName());
}
return Collections.EMPTY_SET;
}
public Set<ItemStack> getKnownItemStacks(String playerName) {
if (getPlayerKnowledge(playerName) != null) {
return getPlayerKnowledge(playerName).getKnownItemStacks();
}
return Collections.EMPTY_SET;
}
/** /**
* TODO Finish JavaDoc * TODO Finish JavaDoc
* *
* @param entityPlayer * @param entityPlayer
* @return * @return
*/ */
public PlayerKnowledge getPlayerKnowledge(EntityPlayer entityPlayer) { protected PlayerKnowledge getPlayerKnowledge(EntityPlayer entityPlayer) {
if (entityPlayer != null) { if (entityPlayer != null) {
return getPlayerKnowledge(entityPlayer.getDisplayName()); return getPlayerKnowledge(entityPlayer.getDisplayName());
@ -177,7 +197,7 @@ public class PlayerKnowledgeRegistry {
* @param playerName * @param playerName
* @return * @return
*/ */
public PlayerKnowledge getPlayerKnowledge(String playerName) { protected PlayerKnowledge getPlayerKnowledge(String playerName) {
// TODO Logging // TODO Logging
if (playerName != null && !playerName.isEmpty()) { if (playerName != null && !playerName.isEmpty()) {