mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Reworked Knowledge Tome
This commit is contained in:
parent
60e7f8dc1d
commit
ce5ca5146e
@ -10,7 +10,6 @@ import org.bukkit.Sound;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Research;
|
import me.mrCookieSlime.Slimefun.Objects.Research;
|
||||||
@ -29,26 +28,27 @@ public class KnowledgeTome extends SimpleSlimefunItem<ItemInteractionHandler> {
|
|||||||
@Override
|
@Override
|
||||||
public ItemInteractionHandler getItemHandler() {
|
public ItemInteractionHandler getItemHandler() {
|
||||||
return (e, p, item) -> {
|
return (e, p, item) -> {
|
||||||
if (SlimefunManager.isItemSimilar(item, getItem(), true)) {
|
if (SlimefunManager.isItemSimilar(item, getItem(), false)) {
|
||||||
List<String> lore = item.getItemMeta().getLore();
|
List<String> lore = item.getItemMeta().getLore();
|
||||||
|
if (lore.get(1).isEmpty()) {
|
||||||
lore.set(0, ChatColor.translateAlternateColorCodes('&', "&7Owner: &b" + p.getName()));
|
lore.set(0, ChatColor.translateAlternateColorCodes('&', "&7Owner: &b" + p.getName()));
|
||||||
lore.set(1, ChatColor.BLACK + "" + p.getUniqueId());
|
lore.set(1, ChatColor.BLACK + "" + p.getUniqueId());
|
||||||
ItemMeta im = item.getItemMeta();
|
ItemMeta im = item.getItemMeta();
|
||||||
im.setLore(lore);
|
im.setLore(lore);
|
||||||
item.setItemMeta(im);
|
item.setItemMeta(im);
|
||||||
p.getEquipment().setItemInMainHand(item);
|
p.getInventory().setItemInMainHand(item);
|
||||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1F, 1F);
|
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1F, 1F);
|
||||||
|
} else {
|
||||||
|
UUID uuid = UUID.fromString(ChatColor.stripColor(item.getItemMeta().getLore().get(1)));
|
||||||
|
if (p.getUniqueId().equals(uuid))
|
||||||
return true;
|
return true;
|
||||||
}
|
PlayerProfile.get(p, profile -> PlayerProfile.fromUUID(uuid, owner -> {
|
||||||
else if (SlimefunManager.isItemSimilar(item, getItem(), false)) {
|
|
||||||
PlayerProfile.get(p, profile -> {
|
|
||||||
PlayerProfile.fromUUID(UUID.fromString(ChatColor.stripColor(item.getItemMeta().getLore().get(1))), owner -> {
|
|
||||||
Set<Research> researches = owner.getResearches();
|
Set<Research> researches = owner.getResearches();
|
||||||
researches.forEach(research -> profile.setResearched(research, true));
|
researches.forEach(research -> research.unlock(p, true));
|
||||||
});
|
}));
|
||||||
});
|
if (p.getGameMode() != GameMode.CREATIVE)
|
||||||
|
item.setAmount(item.getAmount() - 1);
|
||||||
if (p.getGameMode() != GameMode.CREATIVE) ItemUtils.consumeItem(item, false);
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else return false;
|
else return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user