Skip to content

Commit

Permalink
You cannot invite yourself.
Browse files Browse the repository at this point in the history
  • Loading branch information
Euphillya committed Jan 5, 2025
1 parent 8da8abd commit f90babe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ private void deleteInvitePlayer(Main plugin, Player ownerIsland, String playerIn

private void invitePlayer(Main plugin, Player ownerIsland, String playerInvited) {
try {

UUID playerInvitedId = Bukkit.getPlayerUniqueId(playerInvited);
if (playerInvitedId == null) {
LanguageToml.sendMessage(ownerIsland, LanguageToml.messagePlayerNotFound);
return;
}

if (ownerIsland.getUniqueId().equals(playerInvitedId)) {
LanguageToml.sendMessage(ownerIsland, LanguageToml.messageInviteCanNotYourSelf);
return;
}

SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByPlayerId(ownerIsland.getUniqueId()).join();
if (island == null) {
Expand All @@ -130,12 +142,6 @@ private void invitePlayer(Main plugin, Player ownerIsland, String playerInvited)
return;
}

UUID playerInvitedId = Bukkit.getPlayerUniqueId(playerInvited);
if (playerInvitedId == null) {
LanguageToml.sendMessage(ownerIsland, LanguageToml.messagePlayerNotFound);
return;
}

InviteCacheExecution.addInviteCache(island.getId(), playerInvitedId);
LanguageToml.sendMessage(ownerIsland, LanguageToml.messageInvitePlayerInvited.formatted(playerInvited));
Player bPlayerInvited = Bukkit.getPlayer(playerInvitedId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class LanguageToml {
public static String messageInviteAcceptCommandNotEnoughArgs = "You must specify which island you want to join: /skyllia invite accept <island_owner>";
public static String messageInviteRemoveCommandNotEnoughArgs = "The command is incomplete: /skyllia invite remove <island_owner>";
public static String messageInviteDeclineCommandNotEnoughArgs = "You must specify which island you want to decline: /skyllia invite decline <island_owner>";
public static String messageInviteCanNotYourSelf = "You cannot invite yourself.";
public static String messageInviteAddCommandNotEnoughArgs = "You must specify which island you want to decline: /skyllia invite <player>";
public static String messageInvitePlayerInvited = "The player %s has been invited. Awaiting a response...";
public static String messageInviteDeletePlayerInvited = "You have deleted %s's invitation.";
Expand Down Expand Up @@ -343,6 +344,7 @@ private static void islandInviteLanguage() {
messageInviteCommandNotEnoughArgs = getString("island.invite.not-enough-args", messageInviteCommandNotEnoughArgs);
messageInviteAcceptCommandNotEnoughArgs = getString("island.invite.accept.not-enough-args", messageInviteAcceptCommandNotEnoughArgs);
messageInviteDeclineCommandNotEnoughArgs = getString("island.invite.decline.not-enough-args", messageInviteDeclineCommandNotEnoughArgs);
messageInviteCanNotYourSelf = getString("island.invite.add.not-yourself", messageInviteCanNotYourSelf);
messageInviteAddCommandNotEnoughArgs = getString("island.invite.add.not-enough-args", messageInviteAddCommandNotEnoughArgs);
messageInvitePlayerNotification = getString("island.invite.add.notification-player", messageInvitePlayerNotification);
messageInvitePlayerInvited = getString("island.invite.add.pending", messageInvitePlayerInvited);
Expand Down

0 comments on commit f90babe

Please sign in to comment.