Skip to content

Commit

Permalink
Fix: config, GUI textures, PDC [desc]
Browse files Browse the repository at this point in the history
1. Config. ChatGPT screwed me over and broke the enum for Messages.

2. ChatGPT ALSO screwed me over by making variables have hyphens rather than underscores, resulting in broken replacements. Plus I accidentally messed up the material and texture checking in GUIAPI#create.

3. PDC - I use the CustomBlockData system which does NOT play nicely when it is used within paper's classloader and uses the legacy string namespace rather than a JavaPlugin instance.
Before I WAS using the string namespace and I eventually discovered that CustomBlockData does NOT like it, so I deferred back to supplying the plugin instance in PaperSharedConstants#from.
The plugin_namespace can still remain in the common SharedConstants class for future platforms that may work differently, although for Fabric (planned) we will either have to use NBT (https://wiki.fabricmc.net/tutorial:persistent_states) or Custom Data Components (https://docs.fabricmc.net/develop/items/custom-data-components#custom-data-components) which is 1.20.5 - which should actually be fine because we're 1.21+.

Still got some bugs left to iron out, especially pagination.
  • Loading branch information
Skullians committed Dec 28, 2024
1 parent 232c1d0 commit c0c300a
Show file tree
Hide file tree
Showing 21 changed files with 298 additions and 285 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class GUIAPI {
public static GUIData getGUIData(String guiName, SkyUser user) throws IllegalArgumentException {
YamlDocument config = GUIEnums.configs.getOrDefault(SkyApi.getInstance().getPlayerAPI().getLocale(user.getUniqueId()), getFallbackLanguage()).get(guiName);
if (config != null) {
String guiTitle = config.getString("title").replace("<player-name>", user.getName());
String guiTitle = config.getString("title").replace("<player_name>", user.getName());
String openSound = config.getString("open-sound");
int openPitch = config.getInt("open-pitch");
List<String> layout = config.getStringList("layout");
Expand Down Expand Up @@ -60,7 +60,7 @@ public static List<ItemData> getItemData(String guiName, SkyUser user) throws Il

char charValue = !isModel ? itemData.getString("char").charAt(0) : 'x';
String material = itemData.getString("material");
String text = itemData.getString("text").replace("<player-name>", user.getName());
String text = itemData.getString("text").replace("<player_name>", user.getName());
String sound = itemData.getString("sound");
String texture = itemData.getString("skull");
int pitch = itemData.getInt("pitch");
Expand Down Expand Up @@ -93,7 +93,7 @@ public static List<PaginationItemData> getPaginationData(SkyUser user) throws Ru
char charValue = itemData.getString("char").charAt(0);
String material = itemData.getString("material");
String texture = itemData.getString("skull");
String itemName = itemData.getString("name").replace("<player-name>", user.getName());
String itemName = itemData.getString("name").replace("<player_name>", user.getName());
String sound = itemData.getString("sound");
int pitch = itemData.getInt("pitch");
String morePagesLore = itemData.getString("more-pages-lore");
Expand Down Expand Up @@ -122,8 +122,9 @@ public static SkyItemStack createItem(PaginationItemData data, UUID playerUUID)

private static SkyItemStack create(String material, String texture, UUID playerUUID) {
SkyItemStack stack;
if (material.equalsIgnoreCase("player-head")) {
if (texture.equalsIgnoreCase("<player-skull>")) {

if (material.equalsIgnoreCase("PLAYER_HEAD")) {
if (texture.equalsIgnoreCase("<player_skull>")) {
stack = SkyApi.getInstance().getPlayerAPI().getPlayerSkull(SkyItemStack.builder().material("PLAYER_HEAD").build(), playerUUID);
} else {
stack = PlayerAPI.convertToSkull(SkyItemStack.builder().material("PLAYER_HEAD"), texture).build();
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class SkyUser {
public OptionalInt gems = OptionalInt.empty();
public OptionalInt runes = OptionalInt.empty();
public Optional<PlayerIsland> island = Optional.empty();
public Optional<List<InviteData>> incomingInvites = Optional.empty();
public List<InviteData> incomingInvites;
public Optional<JoinRequestData> activeJoinRequest = Optional.empty();
@Getter
public final boolean console;
Expand Down Expand Up @@ -93,16 +93,16 @@ public void removeRunes(int amount) {
}

public CompletableFuture<List<InviteData>> getIncomingInvites() {
return this.incomingInvites.map(CompletableFuture::completedFuture).orElseGet(() -> SkyApi.getInstance().getDatabaseManager().getFactionInvitesManager().getInvitesOfPlayer(getUniqueId()).whenComplete((invites, ex) -> {
return this.incomingInvites != null ? CompletableFuture.completedFuture(this.incomingInvites) : SkyApi.getInstance().getDatabaseManager().getFactionInvitesManager().getInvitesOfPlayer(getUniqueId()).whenComplete((invites, ex) -> {
if (ex != null) return;

this.incomingInvites = Optional.of(invites);
}));

this.incomingInvites = invites;
});
}

@Nullable
public List<InviteData> getCachedInvites() {
return this.incomingInvites.orElse(new ArrayList<>());
return this.incomingInvites;
}

public void onCacheComplete(int runesAddition, int gemsAddition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ items:
prompt:
char: "p" # This is the character to use in the layout!
material: "NETHER_STAR"
skull: "" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player-skull> - Skull texture of the player.
skull: "" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player_skull> - Skull texture of the player.
text: "<gold>Audit Log"
sound: "" # Sound played when the item is clicked. Set to 'none' to disable.
pitch: 1 # Pitch of the sound. Does not apply if 'sound' is 'none.'.
Expand All @@ -53,17 +53,17 @@ items:
lore: ""

# This is the item that displays each audit log.
# You cannot edit the character, however everythign else is customisable.
# You cannot edit the character, however everything else is customisable.
model:
material: "PLAYER_HEAD"
skull: "<player-skull>" # Placeholders: <player-skull> - Skull texture of the player.
text: "<audit-title>" # Placeholders: <audit-title> - Title of the audit log (e.g. "Player Joined")
skull: "<player_skull>" # Placeholders: <player_skull> - Skull texture of the player.
text: "<audit_title>" # Placeholders: <audit_title> - Title of the audit log (e.g. "Player Joined")
sound: "ui.button.click"
pitch: 1
# Placeholders: <audit-description> - Description of the audit log. The format & coloring is configured in the language files.
# Placeholders: <audit_description> - Description of the audit log. The format & coloring is configured in the language files.
# Placeholders: <timestamp> - Timestamp of the audit log.
lore:
- "<audit-description>"
- "<audit_description>"
- ""
- "<gray><timestamp>"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ items:
prompt:
char: "p" # This is the character to use in the layout!
material: "NETHER_STAR"
skull: "" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player-skull> - Skull texture of the player.
skull: "" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player_skull> - Skull texture of the player.
text: "<blue>Invite Type"
sound: "" # Sound played when the item is clicked. Set to 'none' to disable.
pitch: 1 # Pitch of the sound. Does not apply if 'sound' is 'none.'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ items:
prompt:
char: "p" # This is the character to use in the layout!
material: "NETHER_STAR"
skull: "" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player-skull> - Skull texture of the player.
skull: "" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player_skull> - Skull texture of the player.
text: "<blue>Outgoing Invites"
sound: "" # Sound played when the item is clicked. Set to 'none' to disable.
pitch: 1 # Pitch of the sound. Does not apply if 'sound' is 'none.'.
Expand All @@ -55,14 +55,14 @@ items:
# You can customise the text, lore and sound though.
model:
material: "PLAYER_HEAD"
skull: "<player-skull>"
text: "<blue><player-name>" # Placeholders: <player-name> - Name of player.
skull: "<player_skull>"
text: "<blue><player_name>" # Placeholders: <player_name> - Name of player.
sound: "ui.button.click" # The obelisk UI by default is set to make a sound. Don't want to trigger it twice.
pitch: 1
# Placeholders: <player-name> - Name of player invited / <inviter> - Play who invited them.
# Placeholders: <player_name> - Name of player invited / <inviter> - Play who invited them.
# Placeholders: <timestamp> - Timestamp of invite.
lore:
- "<green><inviter> <yellow>invited <green><player-name>"
- "<green><inviter> <yellow>invited <green><player_name>"
- "<yellow>to your Faction."
- ""
- "<gray><timestamp> ago"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ items:
prompt:
char: "p" # This is the character to use in the layout!
material: "NETHER_STAR"
skull: "" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player-skull> - Skull texture of the player.
skull: "" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player_skull> - Skull texture of the player.
text: "<blue>Incoming Invites"
sound: "" # Sound played when the item is clicked. Set to 'none' to disable.
pitch: 1 # Pitch of the sound. Does not apply if 'sound' is 'none.'.
Expand All @@ -55,14 +55,14 @@ items:
# You can customise the text, lore and sound though.
model:
material: "PLAYER_HEAD"
skull: "<player-skull>"
text: "<blue><faction-name>" # Placeholders: <faction-name> - Name of the faction who is inviting you.
skull: "<player_skull>"
text: "<blue><faction_name>" # Placeholders: <faction_name> - Name of the faction who is inviting you.
sound: "" # The obelisk UI by default is set to make a sound. Don't want to trigger it twice.
pitch: 1
# Placeholders: <player-name> - Name of player / <faction-name> - Name of Faction.
# Placeholders: <player_name> - Name of player / <faction_name> - Name of Faction.
lore:
- "<green><player-name> <yellow>wants you"
- "<yellow>to join <green><faction-name>."
- "<green><player_name> <yellow>wants you"
- "<yellow>to join <green><faction_name>."
- ""
- "<gray>Click for actions."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ items:
prompt:
char: "p" # This is the character to use in the layout!
material: "PLAYER_HEAD"
skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTczZGI5NmY3YjlmNzhlZGU5MjY5NDEwYzY1OTI4NWZjYTIwZWZiYzhkZmE5ZGVmZjRiYmU1NDM0OTNhNDQ0NSJ9fX0=" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player-skull> - Skull texture of the player.
text: "<red><bold><faction-name>" # Placeholders: <faction-name> - Name of the Faction you are requesting to join.
skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTczZGI5NmY3YjlmNzhlZGU5MjY5NDEwYzY1OTI4NWZjYTIwZWZiYzhkZmE5ZGVmZjRiYmU1NDM0OTNhNDQ0NSJ9fX0=" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player_skull> - Skull texture of the player.
text: "<red><bold><faction_name>" # Placeholders: <faction_name> - Name of the Faction you are requesting to join.
sound: "" # Sound played when the item is clicked. Set to 'none' to disable.
pitch: 1 # Pitch of the sound. Does not apply if 'sound' is 'none.'.
lore:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ items:
prompt:
char: "p" # This is the character to use in the layout!
material: "NETHER_STAR"
skull: "" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player-skull> - Skull texture of the player.
skull: "" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player_skull> - Skull texture of the player.
text: "<blue>Invite Type"
sound: "" # Sound played when the item is clicked. Set to 'none' to disable.
pitch: 1 # Pitch of the sound. Does not apply if 'sound' is 'none.'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ items:
prompt:
char: "p" # This is the character to use in the layout!
material: "NETHER_STAR"
skull: "" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player-skull> - Skull texture of the player.
skull: "" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player_skull> - Skull texture of the player.
text: "<gold>Manage Members"
sound: "" # Sound played when the item is clicked. Set to 'none' to disable.
pitch: 1 # Pitch of the sound. Does not apply if 'sound' is 'none.'.
Expand All @@ -55,13 +55,13 @@ items:
# You can customise the text, lore and sound though.
model:
material: "PLAYER_HEAD"
skull: "<player-skull>"
text: "<blue><player-name>" # Placeholders: <player-name> - Name of player.
skull: "<player_skull>"
text: "<blue><player_name>" # Placeholders: <player_name> - Name of player.
sound: "" # Sound already configured in manage-member.yml
pitch: 1
# Placeholders: <player-rank> - Rank of player.
# Placeholders: <player_rank> - Rank of player.
lore:
- "<green>Rank: <yellow><player-rank>"
- "<green>Rank: <yellow><player_rank>"
- ""
- "<yellow>Click to manage this player."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ items:
prompt:
char: "p" # This is the character to use in the layout!
material: "NETHER_STAR"
skull: "" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player-skull> - Skull texture of the player.
skull: "" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player_skull> - Skull texture of the player.
text: "<gold>Audit Log"
sound: "" # Sound played when the item is clicked. Set to 'none' to disable.
pitch: 1 # Pitch of the sound. Does not apply if 'sound' is 'none.'.
Expand All @@ -57,13 +57,13 @@ items:
model:
material: "PLAYER_HEAD"
skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjRiZDlkZDEyOGM5NGMxMGM5NDVlYWRhYTM0MmZjNmQ5NzY1ZjM3YjNkZjJlMzhmN2IwNTZkYzdjOTI3ZWQifX19"
text: "<notification-title>" # Placeholders: <notification-title> - Title of the notification (e.g. "Faction Invite")
text: "<notification_title>" # Placeholders: <notification_title> - Title of the notification (e.g. "Faction Invite")
sound: "ui.button.click"
pitch: 1
# Placeholders: <notification-description> - Description of the notification. The format & coloring is configured in the language files.
# Placeholders: <notification_description> - Description of the notification. The format & coloring is configured in the language files.
# Placeholders: <timestamp> - Timestamp of the audit log.
lore:
- "<notification-description>"
- "<notification_description>"
- "<gray><timestamp>"
- ""
- "<red>Right click to dismiss."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ items:
head:
char: "p" # This is the character to use in the layout!
material: "PLAYER_HEAD"
skull: "<player-skull>" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player-skull> - Skull texture of the player.
text: "<red><player-name>'s Obelisk" # Supported placeholders: <player-name> - Player's Name
skull: "<player_skull>" # You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player_skull> - Skull texture of the player.
text: "<red><player_name>'s Obelisk" # Supported placeholders: <player_name> - Player's Name
sound: "" # Sound played when the item is clicked. Set to 'none' to disable.
pitch: 1 # Pitch of the sound. Does not apply if 'sound' is 'none.'.
lore:
# Placeholders: <level> - Current Island Level
# Placeholders: <rune-count> - Total Rune Count / <gem-count> - Total Gem Count
# Placeholders: <rune_count> - Total Rune Count / <gem_count> - Total Gem Count
- "<blue>Stats<reset>"
- "<green>Level: <yellow><level>"
- "<green>Runes: <yellow><rune-count>"
- "<green>Gems: <yellow><gem-count>"
- "<green>Runes: <yellow><rune_count>"
- "<green>Gems: <yellow><gem_count>"

notifications:
char: "n"
Expand All @@ -45,11 +45,11 @@ items:
sound: ""
pitch: 1
lore:
# Placeholders: <notification-count> - Current unread notification count.
# Placeholders: <notification_count> - Current unread notification count.
- "<yellow>View and Manage your"
- "<yellow>unread Notifications."
- ""
- "<gray>You currently have <notification-count> unread"
- "<gray>You currently have <notification_count> unread"
- "<gray>Notifications."

# UI to convert select blocks into runes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ items:
forward-button:
char: ">" # This is the character used in the layout.
material: "PLAYER_HEAD"
# You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player-skull> - Skull texture of the player.
# You can set custom skull textures (e.g. from minecraft-heads.com). 'material' MUST BE SET TO 'PLAYER_HEAD'. Placeholders: <player_skull> - Skull texture of the player.
skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTYzMzlmZjJlNTM0MmJhMThiZGM0OGE5OWNjYTY1ZDEyM2NlNzgxZDg3ODI3MmY5ZDk2NGVhZDNiOGFkMzcwIn19fQ==" #
name: "<green><bold>Next Page" # Name of the item.
sound: "item.book.page_turn" # Sound played when the item is clicked. Set to 'none' to disable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public class PaperSharedConstants {

@NotNull
private static NamespacedKey from(@NotNull String key) {
return new NamespacedKey(SharedConstants.PLUGIN_NAMESPACE, key);
return new NamespacedKey(SkyFactionsReborn.getInstance(), key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.skullian.skyfactions.common.api.SkyApi;
import net.skullian.skyfactions.paper.api.SpigotSkyAPI;
import org.bukkit.Bukkit;

Check warning on line 5 in paper/src/main/java/net/skullian/skyfactions/paper/SkyFactionsReborn.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import

Unused import `import org.bukkit.Bukkit;`
import org.bukkit.plugin.java.JavaPlugin;

public final class SkyFactionsReborn extends JavaPlugin {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.skullian.skyfactions.paper.api;

import com.jeff_media.customblockdata.CustomBlockData;
import net.skullian.skyfactions.common.SharedConstants;

Check warning on line 4 in paper/src/main/java/net/skullian/skyfactions/paper/api/SpigotDefenceAPI.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import

Unused import `import net.skullian.skyfactions.common.SharedConstants;`
import net.skullian.skyfactions.common.api.DefenceAPI;
import net.skullian.skyfactions.common.api.PlayerAPI;
import net.skullian.skyfactions.common.api.SkyApi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.puregero.multilib.MultiLib;
import com.jeff_media.customblockdata.CustomBlockData;
import lombok.Getter;
import net.skullian.skyfactions.common.SharedConstants;

Check warning on line 6 in paper/src/main/java/net/skullian/skyfactions/paper/api/SpigotObeliskAPI.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import

Unused import `import net.skullian.skyfactions.common.SharedConstants;`
import net.skullian.skyfactions.common.api.ObeliskAPI;
import net.skullian.skyfactions.common.config.types.ObeliskConfig;
import net.skullian.skyfactions.common.config.types.Settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.destroystokyo.paper.profile.PlayerProfile;
import com.destroystokyo.paper.profile.ProfileProperty;
import com.sk89q.worldedit.math.BlockVector3;
import net.skullian.skyfactions.common.SharedConstants;

Check warning on line 6 in paper/src/main/java/net/skullian/skyfactions/paper/api/adapter/SpigotAdapter.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import

Unused import `import net.skullian.skyfactions.common.SharedConstants;`
import net.skullian.skyfactions.common.api.SkyApi;
import net.skullian.skyfactions.common.config.types.Messages;
import net.skullian.skyfactions.common.user.SkyUser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.github.puregero.multilib.MultiLib;
import com.jeff_media.customblockdata.CustomBlockData;
import io.lumine.mythic.bukkit.MythicBukkit;
import net.skullian.skyfactions.common.SharedConstants;

Check warning on line 8 in paper/src/main/java/net/skullian/skyfactions/paper/defence/SpigotDefence.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import

Unused import `import net.skullian.skyfactions.common.SharedConstants;`
import net.skullian.skyfactions.common.api.SkyApi;
import net.skullian.skyfactions.common.defence.Defence;
import net.skullian.skyfactions.common.defence.hologram.DefenceTextHologram;
Expand Down
Loading

0 comments on commit c0c300a

Please sign in to comment.