mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-26 20:26:34 +01:00
New coop gui
This commit is contained in:
parent
7ee069fee5
commit
056ff3dae5
@ -4,8 +4,8 @@ import com.songoda.core.compatibility.CompatibleSound;
|
|||||||
import com.songoda.skyblock.command.SubCommand;
|
import com.songoda.skyblock.command.SubCommand;
|
||||||
import com.songoda.skyblock.config.FileManager;
|
import com.songoda.skyblock.config.FileManager;
|
||||||
import com.songoda.skyblock.config.FileManager.Config;
|
import com.songoda.skyblock.config.FileManager.Config;
|
||||||
|
import com.songoda.skyblock.gui.coop.GuiCoop;
|
||||||
import com.songoda.skyblock.island.*;
|
import com.songoda.skyblock.island.*;
|
||||||
import com.songoda.skyblock.menus.Coop;
|
|
||||||
import com.songoda.skyblock.message.MessageManager;
|
import com.songoda.skyblock.message.MessageManager;
|
||||||
import com.songoda.skyblock.permission.PermissionManager;
|
import com.songoda.skyblock.permission.PermissionManager;
|
||||||
import com.songoda.skyblock.sound.SoundManager;
|
import com.songoda.skyblock.sound.SoundManager;
|
||||||
@ -125,8 +125,8 @@ public class CoopCommand extends SubCommand {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Coop.getInstance().open(player);
|
plugin.getGuiManager().showGUI(player, new GuiCoop(plugin, island, null));
|
||||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
||||||
} else {
|
} else {
|
||||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Permission.Message"));
|
messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Permission.Message"));
|
||||||
|
186
src/main/java/com/songoda/skyblock/gui/coop/GuiCoop.java
Normal file
186
src/main/java/com/songoda/skyblock/gui/coop/GuiCoop.java
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
package com.songoda.skyblock.gui.coop;
|
||||||
|
|
||||||
|
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||||
|
import com.songoda.core.compatibility.CompatibleSound;
|
||||||
|
import com.songoda.core.gui.AnvilGui;
|
||||||
|
import com.songoda.core.gui.Gui;
|
||||||
|
import com.songoda.core.gui.GuiUtils;
|
||||||
|
import com.songoda.core.utils.TextUtils;
|
||||||
|
import com.songoda.skyblock.SkyBlock;
|
||||||
|
import com.songoda.skyblock.island.Island;
|
||||||
|
import com.songoda.skyblock.island.IslandCoop;
|
||||||
|
import com.songoda.skyblock.island.IslandRole;
|
||||||
|
import com.songoda.skyblock.message.MessageManager;
|
||||||
|
import com.songoda.skyblock.permission.PermissionManager;
|
||||||
|
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||||
|
import com.songoda.skyblock.sound.SoundManager;
|
||||||
|
import com.songoda.skyblock.utils.item.SkullUtil;
|
||||||
|
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class GuiCoop extends Gui {
|
||||||
|
private final SkyBlock plugin;
|
||||||
|
private final Island island;
|
||||||
|
private final FileConfiguration languageLoad;
|
||||||
|
|
||||||
|
public GuiCoop(SkyBlock plugin, Island island, Gui returnGui) {
|
||||||
|
super(returnGui);
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.island = island;
|
||||||
|
this.languageLoad = plugin.getFileManager()
|
||||||
|
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||||
|
setDefaultItem(null);
|
||||||
|
setTitle(TextUtils.formatText(languageLoad.getString("Menu.Coop.Title")));
|
||||||
|
paint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paint() {
|
||||||
|
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||||
|
SoundManager soundManager = plugin.getSoundManager();
|
||||||
|
PermissionManager permissionManager = plugin.getPermissionManager();
|
||||||
|
MessageManager messageManager = plugin.getMessageManager();
|
||||||
|
|
||||||
|
Map<UUID, IslandCoop> coopPlayers = island.getCoopPlayers();
|
||||||
|
|
||||||
|
if (inventory != null) {
|
||||||
|
inventory.clear();
|
||||||
|
}
|
||||||
|
setActionForRange(0, 0, 1, 8, null);
|
||||||
|
|
||||||
|
setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit
|
||||||
|
TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Exit.Displayname"))), (event) -> {
|
||||||
|
soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f);
|
||||||
|
event.player.closeInventory();
|
||||||
|
});
|
||||||
|
|
||||||
|
List<String> addButtonLore = languageLoad.getStringList("Menu.Coop.Item.Information.Lore");
|
||||||
|
Collections.replaceAll(addButtonLore, "%coops", "" + coopPlayers.size());
|
||||||
|
|
||||||
|
setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.PAINTING, // Add new
|
||||||
|
TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Information.Displayname")),
|
||||||
|
TextUtils.formatText(addButtonLore)),
|
||||||
|
(event) -> {
|
||||||
|
if ((island.hasRole(IslandRole.Operator, event.player.getUniqueId())
|
||||||
|
&& permissionManager.hasPermission(island, "CoopPlayers", IslandRole.Operator))
|
||||||
|
|| island.hasRole(IslandRole.Owner, event.player.getUniqueId())) {
|
||||||
|
|
||||||
|
AnvilGui gui = new AnvilGui(event.player, this);
|
||||||
|
gui.setAction((e -> {
|
||||||
|
String playerName = gui.getInputText().trim();
|
||||||
|
guiManager.showGUI(event.player, new GuiCoopChoose(plugin, parent, island, playerName));
|
||||||
|
}));
|
||||||
|
gui.setTitle(TextUtils.formatText(
|
||||||
|
languageLoad.getString("Menu.Coop.Item.Word.Normal") +
|
||||||
|
" / " + languageLoad.getString("Menu.Coop.Item.Word.Temp")));
|
||||||
|
guiManager.showGUI(event.player, gui);
|
||||||
|
} else {
|
||||||
|
messageManager.sendMessage(event.player,
|
||||||
|
languageLoad.getString("Command.Island.Coop.Permission.Message"));
|
||||||
|
soundManager.playSound(event.player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit
|
||||||
|
TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Exit.Displayname"))), (event) -> {
|
||||||
|
soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f);
|
||||||
|
event.player.closeInventory();
|
||||||
|
});
|
||||||
|
|
||||||
|
for(int i=9; i<18; i++){
|
||||||
|
setItem(i, CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(coopPlayers.size() == 0){
|
||||||
|
ItemStack empty = CompatibleMaterial.BARRIER.getItem();
|
||||||
|
ItemMeta emptyMeta = empty.getItemMeta();
|
||||||
|
emptyMeta.setDisplayName(languageLoad.getString("Menu.Coop.Item.Nothing.Displayname"));
|
||||||
|
empty.setItemMeta(emptyMeta);
|
||||||
|
setButton(31, empty, (event) ->
|
||||||
|
soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F));
|
||||||
|
} else {
|
||||||
|
//this.pages = (int) Math.max(1, Math.ceil((double) coopPlayers.size() / 36d));
|
||||||
|
|
||||||
|
/*if (page != 1) {
|
||||||
|
setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW,
|
||||||
|
TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Previous.Displayname"))),
|
||||||
|
(event) -> {
|
||||||
|
page--;
|
||||||
|
paint();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (page != pages) {
|
||||||
|
setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW,
|
||||||
|
TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Next.Displayname"))),
|
||||||
|
(event) -> {
|
||||||
|
page++;
|
||||||
|
paint();
|
||||||
|
});
|
||||||
|
}*/
|
||||||
|
|
||||||
|
setPages((int) Math.max(1, Math.ceil((double) coopPlayers.size() / 36d)));
|
||||||
|
setPrevPage(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW,
|
||||||
|
TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Previous.Displayname"))));
|
||||||
|
setNextPage(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW,
|
||||||
|
TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Next.Displayname"))));
|
||||||
|
|
||||||
|
UUID[] coopUUIDs = (UUID[]) coopPlayers.keySet().toArray();
|
||||||
|
|
||||||
|
for (int i = 9; i < ((getRows()-2)*9)+18; i++) {
|
||||||
|
int current = ((page - 1) * 36) - 18;
|
||||||
|
if (current + i < coopPlayers.size()) {
|
||||||
|
UUID uuid = coopUUIDs[current + i];
|
||||||
|
IslandCoop type = (IslandCoop) coopPlayers.values().toArray()[current + i];
|
||||||
|
if (uuid != null) {
|
||||||
|
String targetPlayerName;
|
||||||
|
String[] targetPlayerTexture;
|
||||||
|
|
||||||
|
Player targetPlayer = Bukkit.getServer().getPlayer(uuid);
|
||||||
|
|
||||||
|
if (targetPlayer == null) {
|
||||||
|
OfflinePlayer offlinePlayer = new OfflinePlayer(uuid);
|
||||||
|
targetPlayerName = offlinePlayer.getName();
|
||||||
|
targetPlayerTexture = offlinePlayer.getTexture();
|
||||||
|
} else {
|
||||||
|
targetPlayerName = targetPlayer.getName();
|
||||||
|
|
||||||
|
if (playerDataManager.hasPlayerData(targetPlayer)) {
|
||||||
|
targetPlayerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture();
|
||||||
|
} else {
|
||||||
|
targetPlayerTexture = new String[]{null, null};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack is = SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]);
|
||||||
|
ItemMeta im = is.getItemMeta();
|
||||||
|
if (im != null) {
|
||||||
|
im.setDisplayName(languageLoad.getString("Menu.Coop.Item.Coop.Displayname")
|
||||||
|
.replace("%player", targetPlayerName == null ? "" : targetPlayerName)
|
||||||
|
.replace("%type", type == IslandCoop.TEMP ?
|
||||||
|
languageLoad.getString("Menu.Coop.Item.Word.Temp") :
|
||||||
|
languageLoad.getString("Menu.Coop.Item.Word.Normal")));
|
||||||
|
im.setLore(languageLoad.getStringList("Menu.Coop.Item.Coop.Lore"));
|
||||||
|
is.setItemMeta(im);
|
||||||
|
}
|
||||||
|
|
||||||
|
setButton(i, is, e -> Bukkit.getServer().dispatchCommand(e.player, "island coop " + targetPlayerName));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setItem(i, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package com.songoda.skyblock.gui.coop;
|
||||||
|
|
||||||
|
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||||
|
import com.songoda.core.compatibility.CompatibleSound;
|
||||||
|
import com.songoda.core.gui.Gui;
|
||||||
|
import com.songoda.core.gui.GuiType;
|
||||||
|
import com.songoda.core.gui.GuiUtils;
|
||||||
|
import com.songoda.core.utils.TextUtils;
|
||||||
|
import com.songoda.skyblock.SkyBlock;
|
||||||
|
import com.songoda.skyblock.island.Island;
|
||||||
|
import com.songoda.skyblock.sound.SoundManager;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class GuiCoopChoose extends Gui {
|
||||||
|
|
||||||
|
private final SkyBlock plugin;
|
||||||
|
private final FileConfiguration languageLoad;
|
||||||
|
private final Gui returnGui;
|
||||||
|
private final String targetPlayer;
|
||||||
|
|
||||||
|
public GuiCoopChoose(SkyBlock plugin, Gui returnGui, Island island, String targetPlayer) {
|
||||||
|
super(GuiType.HOPPER);
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.returnGui = returnGui;
|
||||||
|
this.targetPlayer = targetPlayer;
|
||||||
|
this.languageLoad = plugin.getFileManager()
|
||||||
|
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||||
|
setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem());
|
||||||
|
setTitle(TextUtils.formatText(
|
||||||
|
languageLoad.getString("Menu.Coop.Item.Word.Normal") + " / " + languageLoad.getString("Menu.Coop.Item.Word.Temp")));
|
||||||
|
paint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paint() {
|
||||||
|
SoundManager soundManager = plugin.getSoundManager();
|
||||||
|
|
||||||
|
if (inventory != null)
|
||||||
|
inventory.clear();
|
||||||
|
|
||||||
|
setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem());
|
||||||
|
setActionForRange(0, 4, null);
|
||||||
|
|
||||||
|
setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit
|
||||||
|
TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Exit.Displayname"))), (event) -> {
|
||||||
|
soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f);
|
||||||
|
guiManager.showGUI(event.player, returnGui);
|
||||||
|
});
|
||||||
|
setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit
|
||||||
|
TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Exit.Displayname"))), (event) -> {
|
||||||
|
soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f);
|
||||||
|
guiManager.showGUI(event.player, returnGui);
|
||||||
|
});
|
||||||
|
|
||||||
|
setButton(1, GuiUtils.createButtonItem(CompatibleMaterial.OBSIDIAN, // Normal
|
||||||
|
TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Word.Normal"))),
|
||||||
|
(event) -> {
|
||||||
|
Bukkit.getServer().dispatchCommand(event.player,
|
||||||
|
"island coop " + targetPlayer + " " + languageLoad.getString("Menu.Coop.Item.Word.Normal"));
|
||||||
|
guiManager.showGUI(event.player, returnGui);
|
||||||
|
});
|
||||||
|
setButton(3, GuiUtils.createButtonItem(CompatibleMaterial.GLASS, // Temp
|
||||||
|
TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Word.Temp"))),
|
||||||
|
(event) -> {
|
||||||
|
Bukkit.getServer().dispatchCommand(event.player,
|
||||||
|
"island coop " + targetPlayer + " " + languageLoad.getString("Menu.Coop.Item.Word.Temp"));
|
||||||
|
guiManager.showGUI(event.player, returnGui);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -1,146 +0,0 @@
|
|||||||
package com.songoda.skyblock.gui.wip;
|
|
||||||
|
|
||||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
|
||||||
import com.songoda.core.compatibility.CompatibleSound;
|
|
||||||
import com.songoda.core.gui.Gui;
|
|
||||||
import com.songoda.core.gui.GuiUtils;
|
|
||||||
import com.songoda.core.utils.TextUtils;
|
|
||||||
import com.songoda.skyblock.SkyBlock;
|
|
||||||
import com.songoda.skyblock.island.Island;
|
|
||||||
import com.songoda.skyblock.island.IslandCoop;
|
|
||||||
import com.songoda.skyblock.island.IslandManager;
|
|
||||||
import com.songoda.skyblock.message.MessageManager;
|
|
||||||
import com.songoda.skyblock.permission.PermissionManager;
|
|
||||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
|
||||||
import com.songoda.skyblock.sound.SoundManager;
|
|
||||||
import com.songoda.skyblock.utils.item.SkullUtil;
|
|
||||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class GuiCoop extends Gui {
|
|
||||||
private final SkyBlock plugin;
|
|
||||||
private final Island island;
|
|
||||||
private final FileConfiguration languageLoad;
|
|
||||||
|
|
||||||
public GuiCoop(SkyBlock plugin, Island island, Gui returnGui) {
|
|
||||||
super(returnGui);
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.island = island;
|
|
||||||
this.languageLoad = plugin.getFileManager()
|
|
||||||
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
|
|
||||||
setDefaultItem(null);
|
|
||||||
setTitle(TextUtils.formatText("Coop"));
|
|
||||||
paint();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void paint() { // TODO Item to add ban
|
|
||||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
|
||||||
MessageManager messageManager = plugin.getMessageManager();
|
|
||||||
IslandManager islandManager = plugin.getIslandManager();
|
|
||||||
PermissionManager permissionManager = plugin.getPermissionManager();
|
|
||||||
SoundManager soundManager = plugin.getSoundManager();
|
|
||||||
|
|
||||||
if (inventory != null)
|
|
||||||
inventory.clear();
|
|
||||||
setActionForRange(0, 0, 1, 8, null);
|
|
||||||
|
|
||||||
setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit
|
|
||||||
TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Exit.Displayname"))), (event) -> {
|
|
||||||
soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f);
|
|
||||||
event.player.closeInventory();
|
|
||||||
});
|
|
||||||
|
|
||||||
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit
|
|
||||||
TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Exit.Displayname"))), (event) -> {
|
|
||||||
soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f);
|
|
||||||
event.player.closeInventory();
|
|
||||||
});
|
|
||||||
|
|
||||||
for(int i=9; i<18; i++){
|
|
||||||
setItem(i, CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<UUID, IslandCoop> coopPlayers = island.getCoopPlayers();
|
|
||||||
|
|
||||||
if(coopPlayers.size() == 0){
|
|
||||||
ItemStack empty = CompatibleMaterial.BARRIER.getItem();
|
|
||||||
ItemMeta emptyMeta = empty.getItemMeta();
|
|
||||||
emptyMeta.setDisplayName(languageLoad.getString("Menu.Coop.Item.Nothing.Displayname"));
|
|
||||||
empty.setItemMeta(emptyMeta);
|
|
||||||
setButton(31, empty, (event) ->
|
|
||||||
soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F));
|
|
||||||
} else {
|
|
||||||
this.pages = (int) Math.max(1, Math.ceil((double) coopPlayers.size() / 36d));
|
|
||||||
|
|
||||||
if (page != 1)
|
|
||||||
setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW,
|
|
||||||
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Last.Displayname"))),
|
|
||||||
(event) -> {
|
|
||||||
page--;
|
|
||||||
paint();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (page != pages)
|
|
||||||
setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW,
|
|
||||||
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Next.Displayname"))),
|
|
||||||
(event) -> {
|
|
||||||
page++;
|
|
||||||
paint();
|
|
||||||
});
|
|
||||||
|
|
||||||
UUID[] coopUUIDs = (UUID[]) coopPlayers.keySet().toArray();
|
|
||||||
|
|
||||||
for (int i = 9; i < ((getRows()-2)*9)+18; i++) {
|
|
||||||
int current = ((page - 1) * 36) - 18;
|
|
||||||
if (current + i >= coopPlayers.size()) {
|
|
||||||
setItem(i, null);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
UUID uuid = coopUUIDs[current + i];
|
|
||||||
if (uuid == null) continue;
|
|
||||||
|
|
||||||
String targetPlayerName;
|
|
||||||
String[] targetPlayerTexture;
|
|
||||||
|
|
||||||
Player targetPlayer = Bukkit.getServer().getPlayer(uuid);
|
|
||||||
|
|
||||||
if (targetPlayer == null) {
|
|
||||||
OfflinePlayer offlinePlayer = new OfflinePlayer(uuid);
|
|
||||||
targetPlayerName = offlinePlayer.getName();
|
|
||||||
targetPlayerTexture = offlinePlayer.getTexture();
|
|
||||||
} else {
|
|
||||||
targetPlayerName = targetPlayer.getName();
|
|
||||||
|
|
||||||
if (playerDataManager.hasPlayerData(targetPlayer)) {
|
|
||||||
targetPlayerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture();
|
|
||||||
} else {
|
|
||||||
targetPlayerTexture = new String[]{null, null};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack is = SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]);
|
|
||||||
ItemMeta im = is.getItemMeta();
|
|
||||||
if(im != null){
|
|
||||||
im.setDisplayName(languageLoad.getString("Menu.Bans.Item.Ban.Displayname")
|
|
||||||
.replace("%player", targetPlayerName == null ? "" : targetPlayerName));
|
|
||||||
im.setLore(languageLoad.getStringList("Menu.Bans.Item.Ban.Lore"));
|
|
||||||
is.setItemMeta(im);
|
|
||||||
}
|
|
||||||
|
|
||||||
setButton(i, is, e -> {
|
|
||||||
String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName()); // TODO Check if it actually works
|
|
||||||
Bukkit.getServer().dispatchCommand(e.player, "island coop " + playerName); // TODO Command or APIs?
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user