mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-03 18:43:43 +01:00 
			
		
		
		
	Lets start over on PersistentPartyData
This commit is contained in:
		@@ -153,7 +153,6 @@ public class PlayerData {
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param map target map
 | 
					     * @param map target map
 | 
				
			||||||
     * @throws UnexpectedValueException when values are outside of expected norms
 | 
					     * @throws UnexpectedValueException when values are outside of expected norms
 | 
				
			||||||
     * @throws Exception when values are outside of expected norms
 | 
					 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void validateRootSkillMap(Map<PrimarySkillType, ? extends Number> map) throws UnexpectedValueException, NullPointerException {
 | 
					    private void validateRootSkillMap(Map<PrimarySkillType, ? extends Number> map) throws UnexpectedValueException, NullPointerException {
 | 
				
			||||||
        //TODO: Check for missing/unregistered
 | 
					        //TODO: Check for missing/unregistered
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,58 +1,7 @@
 | 
				
			|||||||
package com.gmail.nossr50.party;
 | 
					package com.gmail.nossr50.party;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.google.common.base.Objects;
 | 
					 | 
				
			||||||
import com.neetgames.mcmmo.party.PartyMember;
 | 
					 | 
				
			||||||
import com.neetgames.neetlib.dirtydata.DirtyData;
 | 
					 | 
				
			||||||
import com.neetgames.neetlib.dirtydata.DirtySet;
 | 
					 | 
				
			||||||
import com.neetgames.neetlib.mutableprimitives.MutableBoolean;
 | 
					 | 
				
			||||||
import com.neetgames.neetlib.mutableprimitives.MutableString;
 | 
					 | 
				
			||||||
import org.jetbrains.annotations.NotNull;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.HashSet;
 | 
					 | 
				
			||||||
import java.util.Set;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class PersistentPartyData {
 | 
					public class PersistentPartyData {
 | 
				
			||||||
 | 
					    private int hashCodeCache; //TODO: T&C wire this up later, see PlayerData for example
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final @NotNull MutableBoolean dirtyFlag; //Dirty values in this class will change this flag as needed
 | 
					 | 
				
			||||||
    private final @NotNull DirtyData<MutableString> partyName;
 | 
					 | 
				
			||||||
    private final @NotNull DirtySet<PartyMember> partyMembers; //TODO: Add cache for subsets
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public PersistentPartyData(@NotNull String partyName, @NotNull Set<PartyMember> partyMembers) throws RuntimeException {
 | 
					 | 
				
			||||||
        dirtyFlag = new MutableBoolean(false);
 | 
					 | 
				
			||||||
        this.partyName = new DirtyData<>(new MutableString(partyName), dirtyFlag);
 | 
					 | 
				
			||||||
        this.partyMembers = new DirtySet<>(new HashSet<>(partyMembers), dirtyFlag);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public @NotNull String getPartyName() {
 | 
					 | 
				
			||||||
        return partyName.getData().getImmutableCopy();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public @NotNull Set<PartyMember> getPartyMembers() {
 | 
					 | 
				
			||||||
        return partyMembers;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public boolean isDataDirty() {
 | 
					 | 
				
			||||||
        return dirtyFlag.getImmutableCopy();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public String toString() {
 | 
					 | 
				
			||||||
        return "PersistentPartyData{" +
 | 
					 | 
				
			||||||
                "partyName=" + partyName +
 | 
					 | 
				
			||||||
                ", partyMembers=" + partyMembers +
 | 
					 | 
				
			||||||
                '}';
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public boolean equals(Object o) {
 | 
					 | 
				
			||||||
        if (this == o) return true;
 | 
					 | 
				
			||||||
        if (o == null || getClass() != o.getClass()) return false;
 | 
					 | 
				
			||||||
        PersistentPartyData that = (PersistentPartyData) o;
 | 
					 | 
				
			||||||
        return Objects.equal(partyName, that.partyName) && Objects.equal(partyMembers, that.partyMembers);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public int hashCode() {
 | 
					 | 
				
			||||||
        return Objects.hashCode(partyName, partyMembers);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user