Skip to content

Commit

Permalink
Update:
Browse files Browse the repository at this point in the history
 Minor update, further work on skulls.
  • Loading branch information
cobrex1 committed Mar 29, 2024
1 parent 95b9abe commit 5123300
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 31 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>me.cobrex</groupId>
<artifactId>TownyMenu</artifactId>
<version>1.8.3</version>
<version>1.8.3.1</version>

<properties>

Expand Down
15 changes: 5 additions & 10 deletions src/main/java/me/cobrex/townymenu/nation/NationMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.bukkit.profile.PlayerProfile;
import org.mineacademy.fo.Common;
import org.mineacademy.fo.TimeUtil;
import org.mineacademy.fo.debug.LagCatcher;
import org.mineacademy.fo.menu.Menu;
import org.mineacademy.fo.menu.MenuPagged;
import org.mineacademy.fo.menu.button.Button;
Expand Down Expand Up @@ -472,17 +471,13 @@ protected ItemStack convertToItemStack(Resident item) {
// LagCatcher.start("load-nation-players");
ItemStack itemSkull = new ItemStack(Material.PLAYER_HEAD, 1);
SkullMeta skull = (SkullMeta) itemSkull.getItemMeta();
skull.setDisplayName(ChatColor.translateAlternateColorCodes('&',
Localization.NationMenu.NationResidentMenu.RES_NAME + item.getFormattedTitleName()));
// skull.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + item.getFormattedTitleName());
if (item.getUUID() == null)
return DUMMY_BUTTON;
PlayerProfile profile = Bukkit.createPlayerProfile(String.valueOf(item));
// skull.setOwningPlayer(item.getPlayer());
PlayerProfile profile = Bukkit.createPlayerProfile(item.getUUID(), item.getName());
skull.setOwnerProfile(profile);
// LagCatcher.start("load-offline-nation-players");
// OfflinePlayer player = Bukkit.getOfflinePlayer(item.getUUID());
// skull.setOwningPlayer(player);
// LagCatcher.end("load-offline-nation-players", true);
skull.setDisplayName(ChatColor.translateAlternateColorCodes('&',
Localization.NationMenu.NationResidentMenu.RES_NAME + item.getFormattedTitleName()));
List<String> lore = new ArrayList<>();
lore.add("");
lore.add(ChatColor.translateAlternateColorCodes('&', Localization.NationMenu.NationResidentMenu.TOWN + item.getTown()));
Expand All @@ -491,7 +486,7 @@ protected ItemStack convertToItemStack(Resident item) {
TimeUtil.getFormattedDateShort(item.getLastOnline())));
skull.setLore(lore);
itemSkull.setItemMeta(skull);
LagCatcher.end("loaded-nation-players", true);
// LagCatcher.end("loaded-nation-players", true);
return itemSkull;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ protected void onCommand() {
Resident resident = TownyAPI.getInstance().getResident(getPlayer().getName());
Town town = TownyAPI.getInstance().getTown(getPlayer().getName());
if (resident.hasTown() && resident.hasNation()) {
town = resident.getTown();
nation = town.getNation();
town = resident.getTownOrNull();
nation = town.getNationOrNull();

if (nation.getKing().equals(resident) && town.getMayor().hasPermissionNode("townymenu.nation.use"))
new NationMenu(nation, getPlayer()).displayTo(getPlayer());
Expand Down
28 changes: 11 additions & 17 deletions src/main/java/me/cobrex/townymenu/town/TownMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import java.util.Objects;

public class TownMenu extends Menu {

// TODO set up discord, spigot

private final Button toggleMenuButton;
Expand Down Expand Up @@ -489,45 +489,39 @@ protected ResidentListMenu(Iterable<Resident> pages) {
}

@Override
protected ItemStack convertToItemStack(Resident item) {
protected ItemStack convertToItemStack(Resident resident) {

// LagCatcher.start("load-player-skulls");
ItemStack itemSkull = new ItemStack(Material.PLAYER_HEAD, 1);
SkullMeta skull = (SkullMeta) itemSkull.getItemMeta();
skull.setDisplayName(ChatColor.translateAlternateColorCodes('&', item.getFormattedName()));
if (item.getUUID() == null)
if (resident.getUUID() == null)
return DUMMY_BUTTON;
// skull.setOwningPlayer(item.getPlayer());
PlayerProfile profile = Bukkit.createPlayerProfile(String.valueOf(item));
PlayerProfile profile = Bukkit.createPlayerProfile(resident.getUUID(), resident.getName());
skull.setOwnerProfile(profile);
// LagCatcher.start("load-offline-player-skulls");
// OfflinePlayer player = Bukkit.getOfflinePlayer(item.getUUID());
// if (player != null)
// return DUMMY_BUTTON;
// skull.setOwningPlayer(player);
// LagCatcher.end("load-offline-player-skulls", true);
skull.setDisplayName(ChatColor.translateAlternateColorCodes('&',
Localization.TownMenu.ResidentMenu.RESIDENT_NAME + resident.getFormattedName()));
List<String> lore = new ArrayList<>();
lore.add("");
lore.add(ChatColor.translateAlternateColorCodes('&', Localization.TownMenu.ResidentMenu.TOWN_RANK +
ChatColor.translateAlternateColorCodes('&', StringMgmt.join(item.getTownRanks(), ""))));
ChatColor.translateAlternateColorCodes('&', StringMgmt.join(resident.getTownRanks(), ""))));
lore.add("");
lore.add(ChatColor.translateAlternateColorCodes('&', Localization.TownMenu.ResidentMenu.ONLINE +
TimeUtil.getFormattedDateShort(item.getLastOnline())));
TimeUtil.getFormattedDateShort(resident.getLastOnline())));
skull.setLore(lore);
itemSkull.setItemMeta(skull);

// LagCatcher.end("load-player-skulls", true);
return itemSkull;
}

@Override
protected void onPageClick(Player player, Resident item, ClickType click) {
if (item.getName().equals(player.getName())) {
protected void onPageClick(Player player, Resident resident, ClickType click) {
if (resident.getName().equals(player.getName())) {
Common.tell(player, Localization.Error.CANNOT_SELECT_SELF);
player.closeInventory();
return;
}
new ResidentMenu(item).displayTo(player);
new ResidentMenu(resident).displayTo(player);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Prefix: "&b&lTM &7// "

# The Language this plugin's messages will be run in.
# The following translations are available: en, es, de, pt, ru and vi. More will follow!
# The following translations are available: en, fr, es, de, pt, ru and vi. More will follow!
# Once chosen, please re-boot the server to generate the chosen language file.
# It will then appear in the localization folder.
Locale: "en"
Expand Down

0 comments on commit 5123300

Please sign in to comment.