Skip to content

Commit

Permalink
Add CustomModelData to gui items - 1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
YanisBft committed Apr 8, 2022
1 parent f9b4020 commit 7e1bee4
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 35 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pacprofile_group = fr.peaceandcube
pacprofile_name = pacprofile
pacprofile_version = 1.1.2
pacprofile_version = 1.1.3

paper_version = 1.18.2-R0.1-SNAPSHOT

Expand Down
13 changes: 7 additions & 6 deletions src/main/java/fr/peaceandcube/pacprofile/gui/ClaimsGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ protected void fillInventory() {

CLAIM_SLOTS.put(slot, claimId);

this.setItem(slot, Material.GOLDEN_SHOVEL, this.getNameLore(claimId), List.of(
int customModelData = world.equals("world_nether") ? 3021 : 3020;
this.setItem(slot, Material.GOLDEN_SHOVEL, customModelData, this.getNameLore(claimId), List.of(
Component.empty(),
LoreComponents.CLAIM_WORLD.append(Component.text(world, TextColor.color(0xFFFF55), TextDecoration.BOLD)),
LoreComponents.CLAIM_GREATER_CORNER.append(Component.text(greaterCorner.getBlockX() + " " + greaterCorner.getBlockY() + " " + greaterCorner.getBlockZ(), TextColor.color(0xFFFF55), TextDecoration.BOLD)),
Expand All @@ -86,19 +87,19 @@ protected void fillInventory() {
this.getPermissionLore(components, LoreComponents.CLAIM_PERMISSIONS_ACCESSORS, accessors);
this.getPermissionLore(components, LoreComponents.CLAIM_PERMISSIONS_MANAGERS, managers);
components.add(Component.empty());
this.setItem(slot + 1, Material.KNOWLEDGE_BOOK, NameComponents.CLAIM_PERMISSIONS, components);
this.setItem(slot + 1, Material.KNOWLEDGE_BOOK, 3022, NameComponents.CLAIM_PERMISSIONS, components);

this.setItem(slot + 2, Material.PAPER, NameComponents.CLAIM_NAME, List.of(
this.setItem(slot + 2, Material.PAPER, 3023, NameComponents.CLAIM_NAME, List.of(
Component.empty(),
LoreComponents.CLAIM_NAME_CLICK
));
}

this.setItem(45, Material.ARROW, NameComponents.PAGE_PREVIOUS);
this.setItem(49, Material.BARRIER, NameComponents.EXIT);
this.setItem(45, Material.ARROW, 3002, NameComponents.PAGE_PREVIOUS);
this.setItem(49, Material.BARRIER, 3002, NameComponents.EXIT);
// if it's not the last page
if (claimCount > maxClaimOnPage) {
this.setItem(53, Material.ARROW, NameComponents.PAGE_NEXT);
this.setItem(53, Material.ARROW, 3003, NameComponents.PAGE_NEXT);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public HomeColorGui(Player viewer, Player player, String name, int page, int max
protected void fillInventory() {
for (int i = 0; i < Color.values().length; i++) {
Component name = Component.text(Color.values()[i].translate(), TextColor.color(0xFF55FF), TextDecoration.BOLD).decoration(TextDecoration.ITALIC, false);
this.setItem(i, Color.values()[i].getDye(), name);
this.setItem(i, Color.values()[i].getDye(), 3012, name);
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/fr/peaceandcube/pacprofile/gui/HomesGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected void fillInventory() {

HOME_SLOTS.put(slot, name);

this.setItem(slot, color.getBed(), Component.text(name, TextColor.color(0x5555FF), TextDecoration.BOLD).decoration(TextDecoration.ITALIC, false), List.of(
this.setItem(slot, color.getBed(), 3010, Component.text(name, TextColor.color(0x5555FF), TextDecoration.BOLD).decoration(TextDecoration.ITALIC, false), List.of(
Component.empty(),
LoreComponents.HOME_WORLD.append(Component.text(world, TextColor.color(0xFFFF55), TextDecoration.BOLD)),
LoreComponents.HOME_X.append(Component.text(x, TextColor.color(0xFFFF55), TextDecoration.BOLD)),
Expand All @@ -67,24 +67,24 @@ protected void fillInventory() {
LoreComponents.HOME_CLICK
));

this.setItem(slot + 1, Material.PAPER, NameComponents.HOME_NOTES, List.of(
this.setItem(slot + 1, Material.PAPER, 3011, NameComponents.HOME_NOTES, List.of(
Component.empty(),
this.getNotesLore(name),
Component.empty(),
LoreComponents.HOME_NOTES_CLICK
));

this.setItem(slot + 2, color.getDye(), NameComponents.HOME_COLOR, List.of(
this.setItem(slot + 2, color.getDye(), 3012, NameComponents.HOME_COLOR, List.of(
Component.empty(),
LoreComponents.HOME_COLOR_CLICK
));
}

this.setItem(45, Material.ARROW, NameComponents.PAGE_PREVIOUS);
this.setItem(49, Material.BARRIER, NameComponents.EXIT);
this.setItem(45, Material.ARROW, 3002, NameComponents.PAGE_PREVIOUS);
this.setItem(49, Material.BARRIER, 3002, NameComponents.EXIT);
// if it's not the last page
if (homeCount > maxHomeOnPage) {
this.setItem(53, Material.ARROW, NameComponents.PAGE_NEXT);
this.setItem(53, Material.ARROW, 3003, NameComponents.PAGE_NEXT);
}
}

Expand Down
34 changes: 17 additions & 17 deletions src/main/java/fr/peaceandcube/pacprofile/gui/ProfileGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected void fillInventory() {
String nickname = this.user.getNickname() != null ? this.user.getNickname() : Messages.NOT_DEFINED;
String birthday = this.getBirthday();
String joinDate = this.getFirstPlayed();
this.setPlayerHead(4, Component.text(this.player.getName(), TextColor.color(0x55FFFF), TextDecoration.BOLD).decoration(TextDecoration.ITALIC, false), List.of(
this.setPlayerHead(4, 3004, Component.text(this.player.getName(), TextColor.color(0x55FFFF), TextDecoration.BOLD).decoration(TextDecoration.ITALIC, false), List.of(
Component.empty(),
LoreComponents.PROFILE_RANK.append(Component.text(rank, TextColor.color(0xFFFF55), TextDecoration.BOLD)),
Component.empty(),
Expand All @@ -52,7 +52,7 @@ protected void fillInventory() {
));

double coinCount = this.user.getMoney().doubleValue();
this.setItem(20, Material.SUNFLOWER, NameComponents.COINS, List.of(
this.setItem(20, Material.SUNFLOWER, 3004, NameComponents.COINS, List.of(
Component.empty(),
LoreComponents.COINS_NUMBER.append(Component.text(coinCount, TextColor.color(0xFFFF55), TextDecoration.BOLD)),
Component.empty(),
Expand All @@ -61,14 +61,14 @@ protected void fillInventory() {

Objective objective = this.player.getScoreboard().getObjective(PACProfile.getInstance().config.getHeadTicketsScoreboard());
int headTicketCount = objective != null ? objective.getScore(this.player.getName()).getScore() : 0;
this.setItem(22, Material.NAME_TAG, NameComponents.HEAD_TICKETS, List.of(
this.setItem(22, Material.NAME_TAG, 3004, NameComponents.HEAD_TICKETS, List.of(
Component.empty(),
LoreComponents.HEAD_TICKETS_NUMBER.append(Component.text(headTicketCount, TextColor.color(0xFFFF55), TextDecoration.BOLD))
));

int mailCount = this.user.getMailAmount();
int unreadMailCount = this.user.getUnreadMailAmount();
this.setItem(24, Material.WRITABLE_BOOK, NameComponents.MAILS, List.of(
this.setItem(24, Material.WRITABLE_BOOK, 3004, NameComponents.MAILS, List.of(
Component.empty(),
LoreComponents.MAILS_TOTAL.append(Component.text(mailCount, TextColor.color(0xFFFF55), TextDecoration.BOLD)),
LoreComponents.MAILS_UNREAD.append(Component.text(unreadMailCount, TextColor.color(0xFFFF55), TextDecoration.BOLD)),
Expand All @@ -80,7 +80,7 @@ protected void fillInventory() {
int usedHomeCount = this.user.getHomes().size();
int remainingHomeCount = Math.max(0, totalHomeCount - usedHomeCount);
this.maxHomePages = (int) Math.ceil(usedHomeCount / 10.0f);
this.setItem(30, Material.RED_BED, NameComponents.HOMES, List.of(
this.setItem(30, Material.RED_BED, 3004, NameComponents.HOMES, List.of(
Component.empty(),
LoreComponents.HOMES_TOTAL.append(Component.text(usedHomeCount, TextColor.color(0xFFFF55), TextDecoration.BOLD)),
LoreComponents.HOMES_REMAINING.append(Component.text(remainingHomeCount, TextColor.color(0xFFFF55), TextDecoration.BOLD)),
Expand All @@ -97,7 +97,7 @@ protected void fillInventory() {
int usedClaimBlocks = totalClaimsBlocks - remainingClaimBlocks;
int blocksAccruedPerHour = PACProfile.getGriefPrevention().config_claims_blocksAccruedPerHour_default;
this.maxClaimPages = (int) Math.ceil(totalClaimCount / 10.0f);
this.setItem(32, Material.GOLDEN_SHOVEL, NameComponents.CLAIMS, List.of(
this.setItem(32, Material.GOLDEN_SHOVEL, 3004, NameComponents.CLAIMS, List.of(
Component.empty(),
LoreComponents.CLAIMS_TOTAL.append(Component.text(totalClaimCount, TextColor.color(0xFFFF55), TextDecoration.BOLD)),
LoreComponents.CLAIMS_CB_USED.append(Component.text(usedClaimBlocks, TextColor.color(0xFFFF55), TextDecoration.BOLD)),
Expand All @@ -112,30 +112,30 @@ protected void fillInventory() {
LoreComponents.CLAIMS_CLICK
));

this.setItem(45, Material.KNOWLEDGE_BOOK, NameComponents.RULES, List.of(
this.setItem(45, Material.KNOWLEDGE_BOOK, 3004, NameComponents.RULES, List.of(
Component.empty(),
LoreComponents.RULES_CLICK
));

this.setItem(46, Material.CHAIN, NameComponents.LINKS, List.of(
this.setItem(46, Material.CHAIN, 3004, NameComponents.LINKS, List.of(
Component.empty(),
LoreComponents.LINKS_CLICK
));

this.setItem(53, Material.BARRIER, NameComponents.EXIT);
this.setItem(53, Material.BARRIER, 3002, NameComponents.EXIT);

this.fillStainedGlassPanes();
}

private void fillStainedGlassPanes() {
this.setItem(0, Material.RED_STAINED_GLASS_PANE, Component.empty());
this.setItem(1, Material.RED_STAINED_GLASS_PANE, Component.empty());
this.setItem(2, Material.RED_STAINED_GLASS_PANE, Component.empty());
this.setItem(3, Material.ORANGE_STAINED_GLASS_PANE, Component.empty());
this.setItem(5, Material.ORANGE_STAINED_GLASS_PANE, Component.empty());
this.setItem(6, Material.LIME_STAINED_GLASS_PANE, Component.empty());
this.setItem(7, Material.LIME_STAINED_GLASS_PANE, Component.empty());
this.setItem(8, Material.LIME_STAINED_GLASS_PANE, Component.empty());
this.setItem(0, Material.RED_STAINED_GLASS_PANE, 3001, Component.empty());
this.setItem(1, Material.RED_STAINED_GLASS_PANE, 3001, Component.empty());
this.setItem(2, Material.RED_STAINED_GLASS_PANE, 3001, Component.empty());
this.setItem(3, Material.ORANGE_STAINED_GLASS_PANE, 3001, Component.empty());
this.setItem(5, Material.ORANGE_STAINED_GLASS_PANE, 3001, Component.empty());
this.setItem(6, Material.LIME_STAINED_GLASS_PANE, 3001, Component.empty());
this.setItem(7, Material.LIME_STAINED_GLASS_PANE, 3001, Component.empty());
this.setItem(8, Material.LIME_STAINED_GLASS_PANE, 3001, Component.empty());
}

private String getRank() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,28 @@ public void open() {
this.viewer.openInventory(this.inv);
}

protected void setItem(int slot, Material material, Component name) {
this.setItem(slot, material, name, List.of());
protected void setItem(int slot, Material material, int customModelData, Component name) {
this.setItem(slot, material, customModelData, name, List.of());
}

protected void setItem(int slot, Material material, Component name, List<Component> lore) {
protected void setItem(int slot, Material material, int customModelData, Component name, List<Component> lore) {
ItemStack stack = new ItemStack(material);
ItemMeta meta = stack.getItemMeta();
meta.displayName(name);
meta.lore(lore);
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
meta.setCustomModelData(customModelData);
stack.setItemMeta(meta);
this.inv.setItem(slot, stack);
}

protected void setPlayerHead(int slot, Component name, List<Component> lore) {
protected void setPlayerHead(int slot, int customModelData, Component name, List<Component> lore) {
ItemStack stack = new ItemStack(Material.PLAYER_HEAD);
if (stack.getItemMeta() instanceof SkullMeta meta) {
meta.displayName(name);
meta.lore(lore);
meta.setOwningPlayer(this.player);
meta.setCustomModelData(customModelData);
stack.setItemMeta(meta);
}
this.inv.setItem(slot, stack);
Expand Down

0 comments on commit 7e1bee4

Please sign in to comment.