Skip to content

Commit

Permalink
fix: Multiple GUI menus that displays player heads (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamHRLive authored Mar 4, 2024
1 parent 798f53c commit b02e594
Show file tree
Hide file tree
Showing 12 changed files with 209 additions and 108 deletions.
22 changes: 11 additions & 11 deletions src/main/java/com/craftaro/skyblock/gui/coop/GuiCoop.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.craftaro.core.gui.AnvilGui;
import com.craftaro.core.gui.Gui;
import com.craftaro.core.gui.GuiUtils;
import com.craftaro.third_party.com.cryptomorin.xseries.SkullUtils;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
import com.craftaro.core.utils.ItemUtils;
Expand Down Expand Up @@ -139,7 +140,7 @@ public void paint() {
String targetPlayerName;
String[] targetPlayerTexture;

Player targetPlayer = Bukkit.getServer().getPlayer(uuid);
org.bukkit.OfflinePlayer targetPlayer = Bukkit.getServer().getOfflinePlayer(uuid);

if (targetPlayer == null) {
OfflinePlayer offlinePlayer = new OfflinePlayer(uuid);
Expand All @@ -148,26 +149,25 @@ public void paint() {
} else {
targetPlayerName = targetPlayer.getName();

if (playerDataManager.hasPlayerData(targetPlayer)) {
targetPlayerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture();
if (playerDataManager.hasPlayerData(targetPlayer.getUniqueId())) {
targetPlayerTexture = playerDataManager.getPlayerData(targetPlayer.getUniqueId()).getTexture();
} else {
targetPlayerTexture = new String[]{null, null};
}
}

ItemStack is = ItemUtils.getCustomHead(targetPlayerTexture[0], targetPlayerTexture[1]);
ItemMeta im = is.getItemMeta();
if (im != null) {
im.setDisplayName(TextUtils.formatText(this.languageLoad.getString("Menu.Coop.Item.Coop.Displayname")
ItemStack phead = SkullUtils.getSkull(targetPlayer.getUniqueId());
ItemMeta pheadmeta = phead.getItemMeta();
if (pheadmeta != null) {
pheadmeta.setDisplayName(TextUtils.formatText(this.languageLoad.getString("Menu.Coop.Item.Coop.Displayname")
.replace("%player", targetPlayerName == null ? "" : targetPlayerName)
.replace("%type", type == IslandCoop.TEMP ?
this.languageLoad.getString("Menu.Coop.Item.Word.Temp") :
this.languageLoad.getString("Menu.Coop.Item.Word.Normal"))));
im.setLore(TextUtils.formatText(this.languageLoad.getStringList("Menu.Coop.Item.Coop.Lore")));
is.setItemMeta(im);
pheadmeta.setLore(TextUtils.formatText(this.languageLoad.getStringList("Menu.Coop.Item.Coop.Lore")));
phead.setItemMeta(pheadmeta);
}

setButton(i, is, e -> {
setButton(i, phead, e -> {
Bukkit.getServer().dispatchCommand(e.player, "island coop " + targetPlayerName);
paint();
});
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/craftaro/skyblock/gui/wip/GuiBans.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.craftaro.core.gui.Gui;
import com.craftaro.core.gui.GuiUtils;
import com.craftaro.third_party.com.cryptomorin.xseries.SkullUtils;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
import com.craftaro.core.utils.ItemUtils;
Expand Down Expand Up @@ -102,7 +103,7 @@ public void paint() { // TODO Item to add ban
String targetPlayerName;
String[] targetPlayerTexture;

Player targetPlayer = Bukkit.getServer().getPlayer(uuid);
org.bukkit.OfflinePlayer targetPlayer = Bukkit.getServer().getOfflinePlayer(uuid);

if (targetPlayer == null) {
OfflinePlayer offlinePlayer = new OfflinePlayer(uuid);
Expand All @@ -111,14 +112,14 @@ public void paint() { // TODO Item to add ban
} else {
targetPlayerName = targetPlayer.getName();

if (this.playerDataManager.hasPlayerData(targetPlayer)) {
targetPlayerTexture = this.playerDataManager.getPlayerData(targetPlayer).getTexture();
if (this.playerDataManager.hasPlayerData(targetPlayer.getUniqueId())) {
targetPlayerTexture = this.playerDataManager.getPlayerData(targetPlayer.getUniqueId()).getTexture();
} else {
targetPlayerTexture = new String[]{null, null};
}
}

ItemStack is = ItemUtils.getCustomHead(targetPlayerTexture[0], targetPlayerTexture[1]);
ItemStack is = SkullUtils.getSkull(targetPlayer.getUniqueId());
ItemMeta im = is.getItemMeta();
if (im != null) {
im.setDisplayName(this.languageLoad.getString("Menu.Bans.Item.Ban.Displayname")
Expand Down
32 changes: 21 additions & 11 deletions src/main/java/com/craftaro/skyblock/menus/Bans.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.craftaro.skyblock.menus;

import com.craftaro.core.gui.AnvilGui;
import com.craftaro.third_party.com.cryptomorin.xseries.SkullUtils;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
import com.craftaro.core.utils.ItemUtils;
Expand All @@ -22,6 +23,7 @@
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;

import java.util.Set;
import java.util.UUID;
Expand Down Expand Up @@ -163,16 +165,24 @@ public void open(Player player) {
int playerMenuPage = playerData.getPage(MenuType.BANS), nextEndIndex = islandBans.size() - playerMenuPage * 36;

if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge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YTIzIn19fQ==",
"ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=");
Lhead.setItemMeta(LskullMeta);
nInv.addItem(nInv.createItem(Lhead,
configLoad.getString("Menu.Bans.Item.Previous.Displayname"), null, null, null, null), 1);
}

if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jn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Z25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ==",
"wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=");
Rhead.setItemMeta(RskullMeta);
nInv.addItem(nInv.createItem(Rhead,
configLoad.getString("Menu.Bans.Item.Next.Displayname"), null, null, null, null), 7);
}

Expand All @@ -193,7 +203,7 @@ public void open(Player player) {
String targetPlayerName;
String[] targetPlayerTexture;

Player targetPlayer = Bukkit.getServer().getPlayer(targetPlayerUUID);
org.bukkit.OfflinePlayer targetPlayer = Bukkit.getServer().getOfflinePlayer(targetPlayerUUID);

if (targetPlayer == null) {
OfflinePlayer offlinePlayer = new OfflinePlayer(targetPlayerUUID);
Expand All @@ -202,15 +212,15 @@ public void open(Player player) {
} else {
targetPlayerName = targetPlayer.getName();

if (playerDataManager.hasPlayerData(targetPlayer)) {
targetPlayerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture();
if (playerDataManager.hasPlayerData(targetPlayer.getUniqueId())) {
targetPlayerTexture = playerDataManager.getPlayerData(targetPlayer.getUniqueId()).getTexture();
} else {
targetPlayerTexture = new String[]{null, null};
}
}

ItemStack phead = SkullUtils.getSkull(targetPlayer.getUniqueId());
nInv.addItem(
nInv.createItem(ItemUtils.getCustomHead(targetPlayerTexture[0], targetPlayerTexture[1]),
nInv.createItem(phead,
plugin.formatText(
configLoad.getString("Menu.Bans.Item.Ban.Displayname")
.replace("%player", targetPlayerName == null ? "" : targetPlayerName)),
Expand Down
Loading

0 comments on commit b02e594

Please sign in to comment.