Skip to content

Commit

Permalink
feat: add overlay not found message for all languages
Browse files Browse the repository at this point in the history
- Add a new message key 'Messages.Overlay Not Found' in messages_en_US.yml, messages_tr.yml, and messages_el.yml
- Check if the overlay file exists before creating a SkinParts object in SkinOverlayCommand.java
- Use MessagesUtil.OVERLAY_NOT_FOUND to send a message to the issuer if the overlay file is not found
  • Loading branch information
GeorgeV220 committed Jan 3, 2024
1 parent b0fe0b0 commit 2806402
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ public void overlay(@NotNull CommandIssuer issuer, String @NotNull [] args) {
}
SkinParts skinParts;
try {
skinParts = new SkinParts(new SerializableBufferedImage(ImageIO.read(new File(skinOverlay.getSkinsDataFolder(), overlay + ".png"))), overlay);
File overlayFile = new File(skinOverlay.getSkinsDataFolder(), overlay + ".png");
if (!overlayFile.exists()) {
MessagesUtil.OVERLAY_NOT_FOUND.msg(issuer, new HashObjectMap<String, String>().append("%overlay%", overlay), true);
return;
}
skinParts = new SkinParts(new SerializableBufferedImage(ImageIO.read(overlayFile)), overlay);
} catch (IOException e) {
skinOverlay.getLogger().log(Level.SEVERE, "Error while trying to load the skin: ", e);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public enum MessagesUtil {
OFFLINE_PLAYER("Messages.Offline Player", "&c&l(!)&c Player %player% is offline!"),
DONE("Messages.Overlay Applied", "&a&l(!)&a Overlay %url% applied!"),
RESET("Messages.Overlay Reset", "&a&l(!)&a Default skin applied(%player%)!!"),
OVERLAY_NOT_FOUND("Messages.Overlay Not Found", "&c&l(!)&c Overlay %overlay% not found!"),
INSUFFICIENT_ARGUMENTS("Messages.Insufficient arguments", "&c&l(!)&c Insufficient arguments (%command%)"),
COMMANDS_DESCRIPTIONS_SKINOVERLAY_HELP("Commands.Descriptions.SkinOverlay.help", "Shows the help page"),
COMMANDS_DESCRIPTIONS_SKINOVERLAY_OVERLAY("Commands.Descriptions.SkinOverlay.overlay", "Wear a specific overlay from the plugin files"),
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/messages_el.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Messages:
Only Player Command: '&c&l(!)&c Μόνο οι παίκτες μπορούν να εκτελέσουν αυτήν την εντολή!'
Offline Player: '&c&l(!)&c Ο παίκτης %player% είναι εκτός σύνδεσης!'
Overlay Applied: '&a&l(!)&a Εφαρμόστηκε το επικάλυμμα %url% στον παίκτη!'
Overlay Reset: '&a&l(!)&a Επαναφορά προεπιλεγμένου δέρματος(%player%)!!'
Overlay Reset: '&a&l(!)&a Επαναφορά προεπιλεγμένου επικαλύμματος(%player%)!!'
Overlay Not Found: '&c&l(!)&c Το επικάλυμμα %overlay% δεν βρέθηκε!'
Insufficient arguments: '&c&l(!)&c Μη επαρκείς παράμετροι (%command%)'
Commands:
Descriptions:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_en_US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Messages:
Offline Player: '&c&l(!)&c Player %player% is offline!'
Overlay Applied: '&a&l(!)&a Overlay %url% applied!'
Overlay Reset: '&a&l(!)&a Default skin applied(%player%)!!'
Overlay Not Found: '&c&l(!)&c Overlay %overlay% not found!'
Insufficient arguments: '&c&l(!)&c Insufficient arguments (%command%)'
Commands:
Descriptions:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_tr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Messages:
Offline Player: '&c&l(!)&c %player% adlı oyuncu çevrimdışı!'
Overlay Applied: '&a&l(!)&a %url% kaplaması uygulandı!'
Overlay Reset: '&a&l(!)&a Varsayılan cilt uygulandı (%player%)!'
Overlay Not Found: '&c&l(!)&c %overlay% kaplaması bulunamadı!'
Insufficient arguments: '&c&l(!)&c Yetersiz argüman(lar)! (%command%)'
Commands:
Descriptions:
Expand Down

0 comments on commit 2806402

Please sign in to comment.