Fixed a bug where version below 1.16 would fail to load

This commit is contained in:
ASangarin 2020-09-24 01:32:29 +02:00
parent fd93308ea3
commit f4a20057d0
2 changed files with 305 additions and 297 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>net.Indyuce</groupId> <groupId>net.Indyuce</groupId>
<artifactId>MMOItems</artifactId> <artifactId>MMOItems</artifactId>
<version>6.2.0</version> <version>6.2.1</version>
<name>MMOItems</name> <name>MMOItems</name>
<description>A great item solution for your RPG server.</description> <description>A great item solution for your RPG server.</description>

View File

@ -5,6 +5,7 @@ import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.mmogroup.mmolib.MMOLib;
public class RecipeBookUtil { public class RecipeBookUtil {
private static boolean amounts = false; private static boolean amounts = false;
@ -26,6 +27,7 @@ public class RecipeBookUtil {
public static void refresh(Player player) { public static void refresh(Player player) {
if(!enabled) return; if(!enabled) return;
if (MMOLib.plugin.getVersion().isStrictlyHigher(1, 16)) {
for (NamespacedKey key : player.getDiscoveredRecipes()) for (NamespacedKey key : player.getDiscoveredRecipes())
if (key.getNamespace().equals("mmoitems") if (key.getNamespace().equals("mmoitems")
&& !MMOItems.plugin.getRecipes().getNamespacedKeys().contains(key)) && !MMOItems.plugin.getRecipes().getNamespacedKeys().contains(key))
@ -34,6 +36,12 @@ public class RecipeBookUtil {
for (NamespacedKey recipe : MMOItems.plugin.getRecipes().getNamespacedKeys()) for (NamespacedKey recipe : MMOItems.plugin.getRecipes().getNamespacedKeys())
if (!player.hasDiscoveredRecipe(recipe)) if (!player.hasDiscoveredRecipe(recipe))
player.discoverRecipe(recipe); player.discoverRecipe(recipe);
return;
}
for (NamespacedKey recipe : MMOItems.plugin.getRecipes().getNamespacedKeys())
player.discoverRecipe(recipe);
} }
public static void refreshOnline() { public static void refreshOnline() {