File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
common/src/main/kotlin/com/lambda/command/commands Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -83,15 +83,16 @@ object FriendCommand : LambdaCommand(
8383
8484 executeWithResult {
8585 val name = player().value()
86+
87+ if (mc.gameProfile.name == name) return @executeWithResult failure(" You can't befriend yourself" )
88+
8689 val id = mc.networkHandler
8790 ?.playerList
88- ?.firstOrNull {
89- it.profile.name == name &&
90- it.profile != mc.gameProfile
91- } ? : return @executeWithResult failure(" Could not find the player on the server" )
91+ ?.firstOrNull { it.profile.name == name }
92+ ? : return @executeWithResult failure(" Could not find the player on the server" )
9293
9394 return @executeWithResult if (FriendManager .befriend(id.profile)) {
94- this @FriendCommand. info(FriendManager .befriendedText(id.profile.name))
95+ info(FriendManager .befriendedText(id.profile.name))
9596 success()
9697 } else {
9798 failure(" This player is already in your friend list" )
@@ -112,11 +113,12 @@ object FriendCommand : LambdaCommand(
112113
113114 executeWithResult {
114115 val uuid = player().value()
116+
117+ if (mc.gameProfile.id == uuid) return @executeWithResult failure(" You can't befriend yourself" )
118+
115119 val id = mc.networkHandler
116120 ?.playerList
117- ?.firstOrNull {
118- it.profile.id == uuid && it.profile != mc.gameProfile
119- } ? : return @executeWithResult failure(" Could not find the player on the server" )
121+ ?.firstOrNull { it.profile.id == uuid } ? : return @executeWithResult failure(" Could not find the player on the server" )
120122
121123 return @executeWithResult if (FriendManager .befriend(id.profile)) {
122124 this @FriendCommand.info(FriendManager .befriendedText(id.profile.name))
You can’t perform that action at this time.
0 commit comments