Skip to content

Commit

Permalink
Merge pull request #267 from FTBTeam/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
desht authored Sep 15, 2023
2 parents 6440e2f + 26177cc commit b4897b1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2001.2.2]

### Fixes
* Fixed crash on player disconnect if they don't have a team assigned
* Should never occur under normal circumstance but could happen if external factors force a premature disconnect

## [2001.2.1]

### Fixes
Expand Down
20 changes: 13 additions & 7 deletions common/src/main/java/dev/ftb/mods/ftbchunks/FTBChunks.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,19 @@ public void loggedOut(ServerPlayer player) {
}

ChunkTeamDataImpl data = ClaimedChunkManagerImpl.getInstance().getOrCreateData(player);
data.setForceLoadMember(player.getUUID(), FTBChunksWorldConfig.canPlayerOfflineForceload(player));
ClaimedChunkManagerImpl.getInstance().clearForceLoadedCache();
LongRangePlayerTracker.INSTANCE.stopTracking(player);

if (data.getTeam().getOnlineMembers().size() == 1 && !data.canDoOfflineForceLoading()) {
// last player on the team to log out; unforce chunks if the team can't do offline chunk-loading
data.updateChunkTickets(false);
// shouldn't normally be null here, but external problems could force a player logout before they have a team
// https://github.com/FTBTeam/FTB-Mods-Issues/issues/932
if (data != null) {
data.setForceLoadMember(player.getUUID(), FTBChunksWorldConfig.canPlayerOfflineForceload(player));
ClaimedChunkManagerImpl.getInstance().clearForceLoadedCache();
LongRangePlayerTracker.INSTANCE.stopTracking(player);

if (data.getTeam().getOnlineMembers().size() == 1 && !data.canDoOfflineForceLoading()) {
// last player on the team to log out; unforce chunks if the team can't do offline chunk-loading
data.updateChunkTickets(false);
}
} else {
FTBChunks.LOGGER.warn("on player disconnect: player '{}' has no team?", player.getGameProfile().getName());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ public interface ClaimedChunkManager {
/**
* Get the FTB Chunks team data for the given player, creating a new instance if necessary. This will get the
* data for the party team the player is in, if applicable.
* <p>
* This should not normally return null, but it is a possibility if external problems cause the player to be
* disconnected before they are assigned an FTB Team. So the return value should be checked.
*
* @param player the player
* @return the FTB Chunks data for the team
* @return the FTB Chunks data for the team, or null if something went wrong
*/
ChunkTeamData getOrCreateData(ServerPlayer player);

Expand All @@ -44,7 +47,7 @@ public interface ClaimedChunkManager {
* for the player's personal team, even if they are currently in a party team.
*
* @param id a player UUID
* @return the FTB Chunks data for the player
* @return the FTB Chunks data for the player, or null if something went wrong
*/
ChunkTeamData getPersonalData(UUID id);

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ org.gradle.daemon=false
mod_id=ftbchunks
archives_base_name=ftb-chunks
maven_group=dev.ftb.mods
mod_version=2001.2.1
mod_version=2001.2.2
mod_author=FTB Team

minecraft_version=1.20.1
Expand Down

0 comments on commit b4897b1

Please sign in to comment.