-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: game profiles are player references
- Loading branch information
Showing
6 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/dev/andante/audience/mixin/GameProfileMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package dev.andante.audience.mixin; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
import dev.andante.audience.Audience; | ||
import dev.andante.audience.player.PlayerReference; | ||
import dev.andante.audience.player.PlayerSet; | ||
import dev.andante.audience.player.StandalonePlayerReference; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@SuppressWarnings("AddedMixinMembersNamePattern") | ||
@Mixin(GameProfile.class) | ||
public abstract class GameProfileMixin implements Audience, PlayerReference { | ||
@Override | ||
public @NotNull PlayerSet getAudiencePlayers() { | ||
StandalonePlayerReference reference = this.getHardReference(); | ||
return new PlayerSet(List.of(reference)); | ||
} | ||
|
||
@Override | ||
public @NotNull UUID getReferenceUuid() { | ||
GameProfile that = (GameProfile) (Object) this; | ||
return that.getId(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (super.equals(other)) { | ||
return true; | ||
} | ||
|
||
if (other instanceof PlayerReference reference) { | ||
return reference.getReferenceUuid() == this.getReferenceUuid(); | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters