mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2025-02-07 08:01:50 +01:00
Add equals
and hashCode
functions for Player class (#629)
* Add `equals` and `hashCode` functions for Player class * Fix up the extending classes
This commit is contained in:
parent
124cbc6db6
commit
7200e94262
@ -29,42 +29,42 @@
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Player {
|
||||
public abstract class Player {
|
||||
|
||||
UUID getUuid();
|
||||
public abstract UUID getUuid();
|
||||
|
||||
Text getName();
|
||||
public abstract Text getName();
|
||||
|
||||
ServerWorld getWorld();
|
||||
public abstract ServerWorld getWorld();
|
||||
|
||||
Vector3d getPosition();
|
||||
public abstract Vector3d getPosition();
|
||||
|
||||
/**
|
||||
* x -> pitch, y -> yaw, z -> roll
|
||||
*/
|
||||
Vector3d getRotation();
|
||||
public abstract Vector3d getRotation();
|
||||
|
||||
int getSkyLight();
|
||||
public abstract int getSkyLight();
|
||||
|
||||
int getBlockLight();
|
||||
public abstract int getBlockLight();
|
||||
|
||||
/**
|
||||
* Return <code>true</code> if the player is sneaking.
|
||||
* <p><i>If the player is offline the value of this method is undetermined.</i></p>
|
||||
*/
|
||||
boolean isSneaking();
|
||||
public abstract boolean isSneaking();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the player has an invisibillity effect
|
||||
* <p><i>If the player is offline the value of this method is undetermined.</i></p>
|
||||
*/
|
||||
boolean isInvisible();
|
||||
public abstract boolean isInvisible();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the player is vanished
|
||||
* <p><i>If the player is offline the value of this method is undetermined.</i></p>
|
||||
*/
|
||||
default boolean isVanished() {
|
||||
public boolean isVanished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -72,6 +72,17 @@ default boolean isVanished() {
|
||||
* Returns the {@link Gamemode} this player is in
|
||||
* <p><i>If the player is offline the value of this method is undetermined.</i></p>
|
||||
*/
|
||||
Gamemode getGamemode();
|
||||
public abstract Gamemode getGamemode();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Player other = (Player) o;
|
||||
return getUuid().equals(other.getUuid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getUuid().hashCode();
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FabricPlayer implements Player {
|
||||
public class FabricPlayer extends Player {
|
||||
|
||||
private static final Map<GameMode, Gamemode> GAMEMODE_MAP = new EnumMap<>(GameMode.class);
|
||||
static {
|
||||
|
@ -42,7 +42,7 @@
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ForgePlayer implements Player {
|
||||
public class ForgePlayer extends Player {
|
||||
|
||||
private static final Map<GameType, Gamemode> GAMEMODE_MAP = new EnumMap<>(GameType.class);
|
||||
static {
|
||||
|
@ -42,7 +42,7 @@
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ForgePlayer implements Player {
|
||||
public class ForgePlayer extends Player {
|
||||
|
||||
private static final Map<GameType, Gamemode> GAMEMODE_MAP = new EnumMap<>(GameType.class);
|
||||
static {
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class BukkitPlayer implements Player {
|
||||
public class BukkitPlayer extends Player {
|
||||
|
||||
private static final Map<GameMode, Gamemode> GAMEMODE_MAP = new EnumMap<>(GameMode.class);
|
||||
static {
|
||||
|
@ -39,7 +39,7 @@
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitPlayer implements Player {
|
||||
public class BukkitPlayer extends Player {
|
||||
|
||||
private static final Map<GameMode, Gamemode> GAMEMODE_MAP = new EnumMap<>(GameMode.class);
|
||||
static {
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SpongePlayer implements Player {
|
||||
public class SpongePlayer extends Player {
|
||||
|
||||
private static final Map<GameMode, Gamemode> GAMEMODE_MAP = new HashMap<>(5);
|
||||
static {
|
||||
|
Loading…
Reference in New Issue
Block a user