-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix inconsistencies between offline/online spawn position getter #11960
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -264,6 +264,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D | |
@Nullable | ||
@Deprecated(since = "1.20.4") | ||
public Location getBedSpawnLocation(); | ||
|
||
// Paper start | ||
/** | ||
* Gets the last date and time that this player logged into the server. | ||
|
@@ -290,13 +291,28 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D | |
// Paper end | ||
|
||
/** | ||
* Gets the Location where the player will spawn at, null if they | ||
* Gets the Location where the player will spawn at, {@code null} if they | ||
* don't have a valid respawn point. | ||
* <br> | ||
* Unlike online players, the location if found will not be loaded by default. | ||
* | ||
* @return respawn location if exists, otherwise {@code null}. | ||
*/ | ||
@Nullable | ||
default Location getRespawnLocation() { | ||
return this.getRespawnLocation(false); // keep old behavior for offline players | ||
} | ||
|
||
/** | ||
* Gets the Location where the player will spawn at, {@code null} if they | ||
* don't have a valid respawn point. | ||
* | ||
* @return respawn location if exists, otherwise null. | ||
* @param load load the current location to retrieve the exact position of the spawn block | ||
* and check if this position is still valid or not | ||
* @return respawn location if exists, otherwise {@code null}. | ||
*/ | ||
@Nullable | ||
public Location getRespawnLocation(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am wondering, what really is the rule for interfaces and explicit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I know, it was an unnecessary rule enforced by spigot. |
||
Location getRespawnLocation(boolean load); | ||
|
||
/** | ||
* Increments the given statistic for this player. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -560,15 +560,11 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM | |
@Deprecated(since = "1.20.4") | ||
public Location getBedSpawnLocation(); | ||
|
||
/** | ||
* Gets the Location where the player will spawn at, null if they | ||
* don't have a valid respawn point. | ||
* | ||
* @return respawn location if exists, otherwise null. | ||
*/ | ||
Comment on lines
-563
to
-568
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Javadocs have been removed on this method. Is this intentional, or are you going to be adding different Javadocs soon? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iirc it should now inherit from offline player? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think JDs are inherited by default? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, no, nvm, they are, ineritDoc is for additive |
||
@Nullable | ||
@Override | ||
public Location getRespawnLocation(); | ||
default Location getRespawnLocation() { | ||
return this.getRespawnLocation(true); | ||
} | ||
|
||
/** | ||
* Sets the Location where the player will spawn at their bed. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on deprecating this method (without overload) altogether?
Player
extendsOfflinePlayer
, and both have different default chunk loading behavior, which is quite confusing (also would be nice to specify the default behavior in respective javadocs).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the javadoc, not sure for the deprecation, i kinda expect offline player data to be less accurate than online by default. What i think is confusing is the fact that an online player extends an offline player in the api.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was my concern. Technically, you can have
OfflinePlayer
object representing an onlinePlayer
instance (#getOfflinePlayer
too returns online player if present), so you may call the method on an offline player expecting not to load chunks, but they will load due to the object being an online player.New devs might stumble upon this quirk and will have to account for it. Deprecation would require to explicitly specify the wanted behavior, but I don't have a strong feeling against leaving this as is.