From 1487490bf53825155f9fe58e7d7819c573569b8d Mon Sep 17 00:00:00 2001 From: Pahimar Date: Sat, 21 May 2016 22:23:21 -0400 Subject: [PATCH] That should do it for player knowledge related API changes. Loads of stuff in the old TransmutationKnowledgeRegistry are now deprecated. --- .../com/pahimar/ee3/EquivalentExchange3.java | 15 +- .../PlayerKnowledgeRegistryProxy.java | 277 ++++++++++++++ .../TransmutationKnowledgeRegistryProxy.java | 340 ++++++------------ .../ee3/knowledge/PlayerKnowledge.java | 42 +-- .../knowledge/PlayerKnowledgeRegistry.java | 78 ++-- 5 files changed, 453 insertions(+), 299 deletions(-) diff --git a/src/main/java/com/pahimar/ee3/EquivalentExchange3.java b/src/main/java/com/pahimar/ee3/EquivalentExchange3.java index 3040de29..31fc42c4 100644 --- a/src/main/java/com/pahimar/ee3/EquivalentExchange3.java +++ b/src/main/java/com/pahimar/ee3/EquivalentExchange3.java @@ -40,14 +40,12 @@ public class EquivalentExchange3 public static IProxy proxy; @EventHandler - public void invalidFingerprint(FMLFingerprintViolationEvent event) - { - if (Reference.FINGERPRINT.equals("@FINGERPRINT@")) - { + public void invalidFingerprint(FMLFingerprintViolationEvent event) { + + if (Reference.FINGERPRINT.equals("@FINGERPRINT@")) { LogHelper.info(Messages.NO_FINGERPRINT_MESSAGE); } - else - { + else { LogHelper.warn(Messages.INVALID_FINGERPRINT_MESSAGE); } } @@ -165,9 +163,8 @@ public class EquivalentExchange3 return AlchemyArrayRegistry.getInstance(); } - public TransmutationKnowledgeRegistry getTransmutationKnowledgeRegistry() - { - return TransmutationKnowledgeRegistry.getInstance(); + public PlayerKnowledgeRegistry getPlayerKnowledgeRegistry() { + return PlayerKnowledgeRegistry.INSTANCE; } public TileEntityDataHelper getTileEntityDataHelper() diff --git a/src/main/java/com/pahimar/ee3/api/knowledge/PlayerKnowledgeRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/knowledge/PlayerKnowledgeRegistryProxy.java index 4684d053..58159d98 100644 --- a/src/main/java/com/pahimar/ee3/api/knowledge/PlayerKnowledgeRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/knowledge/PlayerKnowledgeRegistryProxy.java @@ -1,4 +1,281 @@ 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 { + + /** + * 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 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 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; + } + } } diff --git a/src/main/java/com/pahimar/ee3/api/knowledge/TransmutationKnowledgeRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/knowledge/TransmutationKnowledgeRegistryProxy.java index 7a09f877..9ca7e012 100644 --- a/src/main/java/com/pahimar/ee3/api/knowledge/TransmutationKnowledgeRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/knowledge/TransmutationKnowledgeRegistryProxy.java @@ -5,281 +5,141 @@ import cpw.mods.fml.common.Mod; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import java.util.Collections; import java.util.Set; import java.util.UUID; -public class TransmutationKnowledgeRegistryProxy -{ - public static boolean doesPlayerKnow(EntityPlayer entityPlayer, ItemStack itemStack) - { - init(); +/** + * @deprecated as of API 0.4.0; use {@link PlayerKnowledgeRegistryProxy} instead + * @see PlayerKnowledgeRegistryProxy + */ +@Deprecated +public class TransmutationKnowledgeRegistryProxy { - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().doesPlayerKnow(entityPlayer, itemStack); - } + @Deprecated + public static boolean doesPlayerKnow(EntityPlayer entityPlayer, ItemStack itemStack) { + return PlayerKnowledgeRegistryProxy.doesPlayerKnow(entityPlayer, itemStack); + } + @Deprecated + public static boolean doesPlayerKnow(UUID playerUUID, ItemStack itemStack) { return false; } - public static boolean doesPlayerKnow(UUID playerUUID, ItemStack itemStack) - { - init(); - - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().doesPlayerKnow(playerUUID, itemStack); - } + @Deprecated + public static boolean canPlayerLearn(EntityPlayer entityPlayer, ItemStack itemStack) { + return PlayerKnowledgeRegistryProxy.canPlayerLearn(entityPlayer, itemStack); + } + @Deprecated + public static boolean canPlayerLearn(UUID playerUUID, ItemStack itemStack) { return false; } - public static boolean canPlayerLearn(EntityPlayer entityPlayer, ItemStack itemStack) - { - init(); + @Deprecated + public static Set getPlayerKnownTransmutations(EntityPlayer entityPlayer) { + return PlayerKnowledgeRegistryProxy.getKnownItemStacks(entityPlayer); + } - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().canPlayerLearn(entityPlayer, itemStack); - } + @Deprecated + public static Set getPlayerKnownTransmutations(UUID playerUUID) { + return Collections.EMPTY_SET; + } + @Deprecated + public static Set getPlayerKnownTransmutationsFilteredStartsWith(EntityPlayer entityPlayer, String filterString) { + return PlayerKnowledgeRegistryProxy.getKnownItemStacks(entityPlayer); + } + + @Deprecated + public static Set getPlayerKnownTransmutationsFilteredStartsWith(UUID playerUUID, String filterString) { + return Collections.EMPTY_SET; + } + + @Deprecated + public static Set getPlayerKnownTransmutationsFilteredContains(EntityPlayer entityPlayer, String filterString) { + return PlayerKnowledgeRegistryProxy.getKnownItemStacks(entityPlayer); + } + + @Deprecated + public static Set 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; } - public static boolean canPlayerLearn(UUID playerUUID, ItemStack itemStack) - { - init(); - - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().canPlayerLearn(playerUUID, itemStack); - } - - return false; + @Deprecated + public static Set getTemplateKnownTransmutations() { + return Collections.EMPTY_SET; } - public static Set getPlayerKnownTransmutations(EntityPlayer entityPlayer) - { - init(); - - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutations(entityPlayer); - } - - return null; + @Deprecated + public static Set getTemplateKnownTransmutationsFilteredStartsWith(String filterString) { + return Collections.EMPTY_SET; } - public static Set getPlayerKnownTransmutations(UUID playerUUID) - { - init(); - - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutations(playerUUID); - } - - return null; + @Deprecated + public static Set getTemplateKnownTransmutationsFilteredContains(String filterString) { + return Collections.EMPTY_SET; } - public static Set getPlayerKnownTransmutationsFilteredStartsWith(EntityPlayer entityPlayer, String filterString) - { - init(); - - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutationsFilteredStartsWith(entityPlayer, filterString); - } - - return null; + @Deprecated + public static void teachTemplate(ItemStack itemStack) { + // NOOP } - public static Set getPlayerKnownTransmutationsFilteredStartsWith(UUID playerUUID, String filterString) - { - init(); - - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutationsFilteredStartsWith(playerUUID, filterString); - } - - return null; + @Deprecated + public static void makeTemplateForget(ItemStack itemStack) { + // NOOP } - public static Set getPlayerKnownTransmutationsFilteredContains(EntityPlayer entityPlayer, String filterString) - { - init(); - - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutationsFilteredContains(entityPlayer, filterString); - } - - return null; - } - - public static Set 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 getTemplateKnownTransmutations() - { - init(); - - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getTemplatesKnownTransmutations(); - } - - return null; - } - - public static Set getTemplateKnownTransmutationsFilteredStartsWith(String filterString) - { - init(); - - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getTemplatesKnownTransmutationsFilteredStartsWith(filterString); - } - - return null; - } - - public static Set 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(); - } + @Deprecated + public static void makeTemplateForgetEverything() { + // NOOP } @Mod.Instance("EE3") private static Object ee3Mod; - private static class EE3Wrapper - { + private static class EE3Wrapper { private static EquivalentExchange3 ee3mod; } - private static void init() - { - if (ee3Mod != null) - { + private static void init() { + if (ee3Mod != null) { EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod; } } diff --git a/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledge.java b/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledge.java index 24e8b332..54271435 100644 --- a/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledge.java +++ b/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledge.java @@ -21,21 +21,21 @@ public class PlayerKnowledge { this(playerKnowledge.knownItemStacks); } - public PlayerKnowledge(Collection itemStacks) { + public PlayerKnowledge(Collection objects) { knownItemStacks = new TreeSet<>(Comparators.ID_COMPARATOR); - if (itemStacks != null) { - for (ItemStack itemStack : itemStacks) { - learn(itemStack); + if (objects != null) { + for (Object object : objects) { + learn(object); } } } - public boolean isKnown(ItemStack itemStack) { + public boolean isKnown(Object object) { - if (itemStack != null) { - return knownItemStacks.contains(ItemHelper.clone(itemStack, 1)); + if (object instanceof ItemStack) { + return knownItemStacks.contains(ItemHelper.clone((ItemStack) object, 1)); } return false; @@ -45,36 +45,36 @@ public class PlayerKnowledge { return knownItemStacks; } - public void learn(ItemStack itemStack) { + public void learn(Object object) { - if (itemStack != null) { - ItemStack unitItemStack = ItemHelper.clone(itemStack, 1); + if (object instanceof ItemStack) { + ItemStack unitItemStack = ItemHelper.clone((ItemStack) object, 1); knownItemStacks.add(unitItemStack); } } - public void learn(Collection itemStacks) { + public void learn(Collection objects) { - if (itemStacks != null) { - for (ItemStack itemStack : itemStacks) { - learn(itemStack); + if (objects != null) { + for (Object object : objects) { + learn(object); } } } - public void forget(ItemStack itemStack) { + public void forget(Object object) { - if (itemStack != null) { - ItemStack unitItemStack = ItemHelper.clone(itemStack, 1); + if (object instanceof ItemStack) { + ItemStack unitItemStack = ItemHelper.clone((ItemStack) object, 1); knownItemStacks.remove(unitItemStack); } } - public void forget(Collection itemStacks) { + public void forget(Collection objects) { - if (itemStacks != null) { - for (ItemStack itemStack : itemStacks) { - forget(itemStack); + if (objects != null) { + for (Object object : objects) { + forget(object); } } } diff --git a/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledgeRegistry.java b/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledgeRegistry.java index dbcc25ec..c86911f0 100644 --- a/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledgeRegistry.java +++ b/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledgeRegistry.java @@ -14,6 +14,8 @@ import net.minecraft.item.ItemStack; import java.io.File; import java.io.FileNotFoundException; import java.util.Collection; +import java.util.Collections; +import java.util.Set; import java.util.TreeMap; public class PlayerKnowledgeRegistry { @@ -35,107 +37,107 @@ public class PlayerKnowledgeRegistry { return templatePlayerKnowledge; } - public boolean doesPlayerKnow(EntityPlayer player, ItemStack itemStack) { + public boolean doesPlayerKnow(EntityPlayer player, Object object) { if (player != null) { - return doesPlayerKnow(player.getDisplayName(), itemStack); + return doesPlayerKnow(player.getDisplayName(), object); } return false; } - public boolean doesPlayerKnow(String playerName, ItemStack itemStack) { + public boolean doesPlayerKnow(String playerName, Object object) { if (getPlayerKnowledge(playerName) != null) { - return getPlayerKnowledge(playerName).isKnown(itemStack); + return getPlayerKnowledge(playerName).isKnown(object); } return false; } - public boolean canPlayerLearn(EntityPlayer entityPlayer, ItemStack itemStack) { + public boolean canPlayerLearn(EntityPlayer entityPlayer, Object object) { if (entityPlayer != null) { - return canPlayerLearn(entityPlayer.getDisplayName(), itemStack); + return canPlayerLearn(entityPlayer.getDisplayName(), object); } return false; } - public boolean canPlayerLearn(String playerName, ItemStack itemStack) { + public boolean canPlayerLearn(String playerName, Object object) { if (getPlayerKnowledge(playerName) != null) { - return !getPlayerKnowledge(playerName).isKnown(itemStack) && AbilityRegistryProxy.isLearnable(itemStack); + return !getPlayerKnowledge(playerName).isKnown(object) && AbilityRegistryProxy.isLearnable(object); } return false; } - public void teachPlayer(EntityPlayer entityPlayer, ItemStack itemStack) { + public void teachPlayer(EntityPlayer entityPlayer, Object object) { 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) { - getPlayerKnowledge(playerName).learn(itemStack); + if (getPlayerKnowledge(playerName) != null) { + getPlayerKnowledge(playerName).learn(object); save(playerName); } } - public void teachPlayer(EntityPlayer entityPlayer, Collection itemStacks) { + public void teachPlayer(EntityPlayer entityPlayer, Collection objects) { if (entityPlayer != null) { - teachPlayer(entityPlayer.getDisplayName(), itemStacks); + teachPlayer(entityPlayer.getDisplayName(), objects); } } - public void teachPlayer(String playerName, Collection itemStacks) { + public void teachPlayer(String playerName, Collection objects) { - if (itemStacks != null) { + if (objects != null) { PlayerKnowledge playerKnowledge = getPlayerKnowledge(playerName); if (playerKnowledge != null) { - itemStacks.forEach(playerKnowledge::learn); + objects.forEach(playerKnowledge::learn); save(playerName); } } } - public void makePlayerForget(EntityPlayer entityPlayer, ItemStack itemStack) { + public void makePlayerForget(EntityPlayer entityPlayer, Object object) { 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) { - getPlayerKnowledge(playerName).forget(itemStack); + getPlayerKnowledge(playerName).forget(object); save(playerName); } } - public void makePlayerForget(EntityPlayer entityPlayer, Collection itemStacks) { + public void makePlayerForget(EntityPlayer entityPlayer, Collection objects) { if (entityPlayer != null) { - makePlayerForget(entityPlayer.getDisplayName(), itemStacks); + makePlayerForget(entityPlayer.getDisplayName(), objects); } } - public void makePlayerForget(String playerName, Collection itemStacks) { + public void makePlayerForget(String playerName, Collection objects) { - if (itemStacks != null) { + if (objects != null) { PlayerKnowledge playerKnowledge = getPlayerKnowledge(playerName); if (playerKnowledge != null) { - itemStacks.forEach(playerKnowledge::forget); + objects.forEach(playerKnowledge::forget); save(playerName); } } @@ -156,13 +158,31 @@ public class PlayerKnowledgeRegistry { } } + public Set getKnownItemStacks(EntityPlayer entityPlayer) { + + if (entityPlayer != null) { + return getKnownItemStacks(entityPlayer.getDisplayName()); + } + + return Collections.EMPTY_SET; + } + + public Set getKnownItemStacks(String playerName) { + + if (getPlayerKnowledge(playerName) != null) { + return getPlayerKnowledge(playerName).getKnownItemStacks(); + } + + return Collections.EMPTY_SET; + } + /** * TODO Finish JavaDoc * * @param entityPlayer * @return */ - public PlayerKnowledge getPlayerKnowledge(EntityPlayer entityPlayer) { + protected PlayerKnowledge getPlayerKnowledge(EntityPlayer entityPlayer) { if (entityPlayer != null) { return getPlayerKnowledge(entityPlayer.getDisplayName()); @@ -177,7 +197,7 @@ public class PlayerKnowledgeRegistry { * @param playerName * @return */ - public PlayerKnowledge getPlayerKnowledge(String playerName) { + protected PlayerKnowledge getPlayerKnowledge(String playerName) { // TODO Logging if (playerName != null && !playerName.isEmpty()) {