1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 11:45:51 +00:00

Merge pull request #868 from SoSeDiK/guide

Don't reset guide history when using cheat mode
This commit is contained in:
TheBusyBiscuit 2019-03-27 23:25:32 +01:00 committed by GitHub
commit 00b99072e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,7 +21,6 @@ import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.MaterialData;
import me.mrCookieSlime.CSCoreLibPlugin.PlayerRunnable;
import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage;
@ -349,6 +348,7 @@ public class SlimefunGuide {
}
public static void openMainMenu(final Player p, final boolean survival, final boolean book, final int selected_page) {
if (survival)
clearHistory(p.getUniqueId());
if (book) {
@ -953,7 +953,6 @@ public class SlimefunGuide {
return list.isEmpty() ? null: list.get(list.size() - 1);
}
@SuppressWarnings("deprecation")
public static void displayItem(Player p, final ItemStack item, boolean addToHistory, final boolean book, final int page) {
if (item == null || item.getType() == Material.AIR) return;
@ -987,7 +986,7 @@ public class SlimefunGuide {
Iterator<Recipe> iterator = Bukkit.recipeIterator();
while (iterator.hasNext()) {
Recipe r = iterator.next();
if (SlimefunManager.isItemSimiliar(new CustomItem(r.getResult(), 1), item, true) && r.getResult().getData().getData() == item.getData().getData()) recipes.add(r);
if (SlimefunManager.isItemSimiliar(new CustomItem(r.getResult(), 1), item, true)) recipes.add(r);
}
if (recipes.isEmpty()) return;
@ -1009,13 +1008,7 @@ public class SlimefunGuide {
String[] shape = ((ShapedRecipe) r).getShape();
for (int i = 0; i < shape.length; i++) {
for (int j = 0; j < shape[i].length(); j++) {
ItemStack ingredient = ((ShapedRecipe) r).getIngredientMap().get(shape[i].charAt(j));
if (ingredient != null) {
MaterialData data = ingredient.getData();
if (ingredient.getData().getData() < 0) data.setData((byte) 0);
ingredient = data.toItemStack(ingredient.getAmount());
}
recipe[i * 3 + j] = ingredient;
recipe[i * 3 + j] = ((ShapedRecipe) r).getIngredientMap().get(shape[i].charAt(j));
}
}
recipeType = RecipeType.SHAPED_RECIPE.toItem();
@ -1024,25 +1017,13 @@ public class SlimefunGuide {
else if (r instanceof ShapelessRecipe) {
List<ItemStack> ingredients = ((ShapelessRecipe) r).getIngredientList();
for (int i = 0; i < ingredients.size(); i++) {
ItemStack ingredient = ingredients.get(i);
if (ingredient != null) {
MaterialData data = ingredient.getData();
if (ingredient.getData().getData() < 0) data.setData((byte) 0);
ingredient = data.toItemStack(ingredient.getAmount());
}
recipe[i] = ingredient;
recipe[i] = ingredients.get(i);
}
recipeType = RecipeType.SHAPELESS_RECIPE.toItem();
recipeOutput = r.getResult();
}
else if (r instanceof FurnaceRecipe) {
ItemStack ingredient = ((FurnaceRecipe) r).getInput();
if (ingredient != null) {
MaterialData data = ingredient.getData();
if (ingredient.getData().getData() < 0) data.setData((byte) 0);
ingredient = data.toItemStack(ingredient.getAmount());
}
recipe[4] = ingredient;
recipe[4] = ((FurnaceRecipe) r).getInput();
recipeType = RecipeType.FURNACE.toItem();
recipeOutput = r.getResult();
@ -1318,7 +1299,7 @@ public class SlimefunGuide {
}
}
menu.build().open(p);
menu.open(p);
}
public static void clearHistory(UUID uuid) {