Skip to content
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

Don't default to ProfileType SURVIVAL for spectator gamemode change. #459

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.multiverseinventories.event.ShareHandlingEvent;
import com.onarandombox.multiverseinventories.profile.PlayerProfile;
import com.onarandombox.multiverseinventories.profile.ProfileTypes;
import com.onarandombox.multiverseinventories.share.PersistingProfile;
import com.onarandombox.multiverseinventories.share.Shares;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -42,15 +43,19 @@ final void handleSharing() {
}

protected final void setAlwaysWriteProfile(PlayerProfile profile) {
affectedProfiles.setAlwaysWriteProfile(profile);
if (!profile.getProfileType().equals(ProfileTypes.NONE)) {
affectedProfiles.setAlwaysWriteProfile(profile);
}
}

/**
* @param profile The player profile that will need data saved to.
* @param shares What from this group needs to be saved.
*/
protected final void addWriteProfile(PlayerProfile profile, Shares shares) {
affectedProfiles.addWriteProfile(profile, shares);
if (!profile.getProfileType().equals(ProfileTypes.NONE)) {
affectedProfiles.addWriteProfile(profile, shares);
}
}

/**
Expand All @@ -61,7 +66,9 @@ protected final void addWriteProfile(PlayerProfile profile, Shares shares) {
* @param shares What from this group needs to be loaded.
*/
protected final void addReadProfile(PlayerProfile profile, Shares shares) {
affectedProfiles.addReadProfile(profile, shares);
if (!profile.getProfileType().equals(ProfileTypes.NONE)) {
affectedProfiles.addReadProfile(profile, shares);
}
}

protected abstract ShareHandlingEvent createEvent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public final class ProfileTypes {
*/
public static final ProfileType ADVENTURE = ProfileType.createProfileType("ADVENTURE");

/**
* The profile type for the any other Game Modes, i.e. spectator.
*/
public static final ProfileType NONE = ProfileType.createProfileType("NONE");

/**
* Returns the appropriate ProfileType for the given game mode.
*
Expand All @@ -37,7 +42,7 @@ public static ProfileType forGameMode(GameMode mode) {
case ADVENTURE:
return ADVENTURE;
default:
return SURVIVAL;
return NONE;
}
}

Expand Down