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:
commit
00b99072e7
@ -21,7 +21,6 @@ import org.bukkit.inventory.Recipe;
|
|||||||
import org.bukkit.inventory.ShapedRecipe;
|
import org.bukkit.inventory.ShapedRecipe;
|
||||||
import org.bukkit.inventory.ShapelessRecipe;
|
import org.bukkit.inventory.ShapelessRecipe;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.material.MaterialData;
|
|
||||||
|
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.PlayerRunnable;
|
import me.mrCookieSlime.CSCoreLibPlugin.PlayerRunnable;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage;
|
||||||
@ -349,7 +348,8 @@ public class SlimefunGuide {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void openMainMenu(final Player p, final boolean survival, final boolean book, final int selected_page) {
|
public static void openMainMenu(final Player p, final boolean survival, final boolean book, final int selected_page) {
|
||||||
clearHistory(p.getUniqueId());
|
if (survival)
|
||||||
|
clearHistory(p.getUniqueId());
|
||||||
|
|
||||||
if (book) {
|
if (book) {
|
||||||
List<TellRawMessage> pages = new ArrayList<TellRawMessage>();
|
List<TellRawMessage> pages = new ArrayList<TellRawMessage>();
|
||||||
@ -939,7 +939,7 @@ public class SlimefunGuide {
|
|||||||
list.add(urid);
|
list.add(urid);
|
||||||
history.put(p.getUniqueId(), list);
|
history.put(p.getUniqueId(), list);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static URID getLastEntry(Player p, boolean remove) {
|
private static URID getLastEntry(Player p, boolean remove) {
|
||||||
List<URID> list = new ArrayList<URID>();
|
List<URID> list = new ArrayList<URID>();
|
||||||
if (history.containsKey(p.getUniqueId())) list = history.get(p.getUniqueId());
|
if (history.containsKey(p.getUniqueId())) list = history.get(p.getUniqueId());
|
||||||
@ -952,8 +952,7 @@ public class SlimefunGuide {
|
|||||||
else history.put(p.getUniqueId(), list);
|
else history.put(p.getUniqueId(), list);
|
||||||
return list.isEmpty() ? null: list.get(list.size() - 1);
|
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) {
|
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;
|
if (item == null || item.getType() == Material.AIR) return;
|
||||||
|
|
||||||
@ -987,7 +986,7 @@ public class SlimefunGuide {
|
|||||||
Iterator<Recipe> iterator = Bukkit.recipeIterator();
|
Iterator<Recipe> iterator = Bukkit.recipeIterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Recipe r = iterator.next();
|
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;
|
if (recipes.isEmpty()) return;
|
||||||
@ -1009,13 +1008,7 @@ public class SlimefunGuide {
|
|||||||
String[] shape = ((ShapedRecipe) r).getShape();
|
String[] shape = ((ShapedRecipe) r).getShape();
|
||||||
for (int i = 0; i < shape.length; i++) {
|
for (int i = 0; i < shape.length; i++) {
|
||||||
for (int j = 0; j < shape[i].length(); j++) {
|
for (int j = 0; j < shape[i].length(); j++) {
|
||||||
ItemStack ingredient = ((ShapedRecipe) r).getIngredientMap().get(shape[i].charAt(j));
|
recipe[i * 3 + j] = ((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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recipeType = RecipeType.SHAPED_RECIPE.toItem();
|
recipeType = RecipeType.SHAPED_RECIPE.toItem();
|
||||||
@ -1024,25 +1017,13 @@ public class SlimefunGuide {
|
|||||||
else if (r instanceof ShapelessRecipe) {
|
else if (r instanceof ShapelessRecipe) {
|
||||||
List<ItemStack> ingredients = ((ShapelessRecipe) r).getIngredientList();
|
List<ItemStack> ingredients = ((ShapelessRecipe) r).getIngredientList();
|
||||||
for (int i = 0; i < ingredients.size(); i++) {
|
for (int i = 0; i < ingredients.size(); i++) {
|
||||||
ItemStack ingredient = ingredients.get(i);
|
recipe[i] = 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;
|
|
||||||
}
|
}
|
||||||
recipeType = RecipeType.SHAPELESS_RECIPE.toItem();
|
recipeType = RecipeType.SHAPELESS_RECIPE.toItem();
|
||||||
recipeOutput = r.getResult();
|
recipeOutput = r.getResult();
|
||||||
}
|
}
|
||||||
else if (r instanceof FurnaceRecipe) {
|
else if (r instanceof FurnaceRecipe) {
|
||||||
ItemStack ingredient = ((FurnaceRecipe) r).getInput();
|
recipe[4] = ((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;
|
|
||||||
|
|
||||||
recipeType = RecipeType.FURNACE.toItem();
|
recipeType = RecipeType.FURNACE.toItem();
|
||||||
recipeOutput = r.getResult();
|
recipeOutput = r.getResult();
|
||||||
@ -1318,7 +1299,7 @@ public class SlimefunGuide {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.build().open(p);
|
menu.open(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearHistory(UUID uuid) {
|
public static void clearHistory(UUID uuid) {
|
||||||
|
Loading…
Reference in New Issue
Block a user