Skip to content

Commit

Permalink
Enforce code character limit
Browse files Browse the repository at this point in the history
  • Loading branch information
ericlmao committed Mar 14, 2024
1 parent e122929 commit 04a68eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/main/java/fun/supersmp/codelock/ui/EditCodeMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ public void onClick(@NotNull MenuButton button, @NotNull Player player, @NotNull
return;
}

if (code.length() != CODE_CHARACTER_LIMIT) {
Locale.CODE_LENGTH.send(player);
return;
}

if (original != null && original.equals(code)) {
player.closeInventory();

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/fun/supersmp/codelock/ui/EnterCodeMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public class SubmitClickHandler implements MenuButton.ClickAction {

@Override
public void onClick(@NotNull MenuButton button, @NotNull Player player, @NotNull InventoryClickEvent event) {
if (current.isEmpty()) return;
if (current.isEmpty() || current.length() == CODE_CHARACTER_LIMIT) return;

boolean unlocked = current.equals(code);
if (!unlocked) {
Expand Down

0 comments on commit 04a68eb

Please sign in to comment.