diff options
author | DoKM <mcazzyman@gmail.com> | 2021-08-29 17:24:00 +0200 |
---|---|---|
committer | DoKM <mcazzyman@gmail.com> | 2021-08-29 17:24:00 +0200 |
commit | 90ad79d106fd36f50edaf8a2bed6c4ee0210050d (patch) | |
tree | 109203c8afdde8353f8025a8902ba4a21039f2be /src | |
parent | 5ff913b685316c23317193cfeb30ae51f1a47f1d (diff) | |
download | NotEnoughUpdates-90ad79d106fd36f50edaf8a2bed6c4ee0210050d.tar.gz NotEnoughUpdates-90ad79d106fd36f50edaf8a2bed6c4ee0210050d.tar.bz2 NotEnoughUpdates-90ad79d106fd36f50edaf8a2bed6c4ee0210050d.zip |
Fix pv button showing in hypixel player menu and not showing when guest
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 84c58aeb..cb6a38ab 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -953,15 +953,20 @@ public class NEUEventListener { GuiChest eventGui = (GuiChest) guiScreen; ContainerChest cc = (ContainerChest) eventGui.inventorySlots; containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); - if(containerName.endsWith(" Profile")){ - Slot slot = new Slot(cc.getLowerChestInventory(), 34, cc.inventorySlots.get(34).xDisplayPosition, cc.inventorySlots.get(34).yDisplayPosition); - slot.putStack(Utils.createItemStack(Item.getItemFromBlock(Blocks.command_block), EnumChatFormatting.GREEN + "Profile Viewer", - EnumChatFormatting.YELLOW + "Click to open NEU profile viewer!")); - cc.inventorySlots.replaceAll(e -> { - if(e.getSlotIndex() == 34) - return slot; - return e; - }); + if(containerName.contains(" Profile") && cc.inventorySlots.size() >= 54){ + if(cc.inventorySlots.get(22).getStack() != null && cc.inventorySlots.get(22).getStack().getTagCompound() != null){ + NBTTagCompound tag = eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound(); + if(tag.hasKey("SkullOwner") && tag.getCompoundTag("SkullOwner").hasKey("Name")){ + String tagName = tag.getCompoundTag("SkullOwner").getString("Name"); + String displayname = Utils.cleanColour(cc.inventorySlots.get(22).getStack().getDisplayName()); + if(tagName.equals(displayname.substring(displayname.length()-tagName.length()))){ + Slot slot = new Slot(cc.getLowerChestInventory(), 42, cc.inventorySlots.get(42).xDisplayPosition, cc.inventorySlots.get(42).yDisplayPosition); + slot.putStack(Utils.createItemStack(Item.getItemFromBlock(Blocks.command_block), EnumChatFormatting.GREEN + "Profile Viewer", + EnumChatFormatting.YELLOW + "Click to open NEU profile viewer!")); + cc.inventorySlots.set(42, slot); + } + } + } } } @@ -1412,11 +1417,18 @@ public class NEUEventListener { GuiChest eventGui = (GuiChest) guiScreen; ContainerChest cc = (ContainerChest) eventGui.inventorySlots; containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); - if(containerName.endsWith(" Profile") && eventGui.getSlotUnderMouse() != null && eventGui.getSlotUnderMouse().getSlotIndex() == 34 && - Mouse.getEventButton() >= 0) { + if(containerName.contains(" Profile") && eventGui.getSlotUnderMouse() != null && + eventGui.getSlotUnderMouse().getSlotIndex() == 42 && Mouse.getEventButton() >= 0) { event.setCanceled(true); - Utils.playPressSound(); - NotEnoughUpdates.INSTANCE.viewProfileRunnable.processCommand(null, new String[]{containerName.replaceAll("'s? Profile", "")}); + if(eventGui.inventorySlots.inventorySlots.get(22).getStack() != null && eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound() != null){ + NBTTagCompound tag = eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound(); + if(tag.hasKey("SkullOwner") && tag.getCompoundTag("SkullOwner").hasKey("Name")){ + String username = tag.getCompoundTag("SkullOwner").getString("Name"); + Utils.playPressSound(); + NotEnoughUpdates.INSTANCE.viewProfileRunnable.processCommand(null, new String[]{username}); + } + } + } } |