Skip to content

Commit

Permalink
feat: allow disabling player heads in menus for slow servers (closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
oddlama committed Feb 18, 2022
1 parent 3dba537 commit 3af7ced
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions vane-core/src/main/java/org/oddlama/vane/core/Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public static Core instance() {
private CustomModelDataRegistry model_data_registry;
private CustomItemRegistry item_registry;

@ConfigBoolean(def = true, desc = "Allow loading of player heads in relevant menus. Disabling this will show all player heads using the Steve skin, which may perform better on low-performance servers and clients.")
public boolean config_player_heads_in_menus;

@LangMessage
public TranslatedMessage lang_command_not_a_player;

Expand Down
8 changes: 4 additions & 4 deletions vane-core/src/main/java/org/oddlama/vane/util/ItemUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ public int compare(final ItemStack a, final ItemStack b) {
}
}

public static ItemStack skull_for_player(final OfflinePlayer player) {
public static ItemStack skull_for_player(final OfflinePlayer player, final boolean is_for_menu) {
final var item = new ItemStack(Material.PLAYER_HEAD);
final var meta = (SkullMeta) item.getItemMeta();
meta.setOwningPlayer(player);
item.setItemMeta(meta);
if (!is_for_menu || Core.instance().config_player_heads_in_menus) {
item.editMeta(SkullMeta.class, meta -> meta.setOwningPlayer(player));
}
return item;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ private MenuWidget menu_item_assign_player(final RegionGroup group, final Role r
lang_select_assign_player_title.str(),
lang_filter_players_title.str(),
all_players,
p -> item_select_player.alternative(ItemUtil.skull_for_player(p), "§a§l" + p.getName()),
p -> item_select_player.alternative(ItemUtil.skull_for_player(p, true), "§a§l" + p.getName()),
filter,
(player2, m, p) -> {
all_players.remove(p);
Expand Down Expand Up @@ -334,7 +334,7 @@ private MenuWidget menu_item_remove_player(final RegionGroup group, final Role r
lang_select_remove_player_title.str(),
lang_filter_players_title.str(),
all_players,
p -> item_select_player.alternative(ItemUtil.skull_for_player(p), "§a§l" + p.getName()),
p -> item_select_player.alternative(ItemUtil.skull_for_player(p, true), "§a§l" + p.getName()),
filter,
(player2, m, p) -> {
all_players.remove(p);
Expand Down

0 comments on commit 3af7ced

Please sign in to comment.