Skip to content
Open
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 @@ -171,10 +171,10 @@ private void addLegacyChange(int shift) {
AttributeModifier newModifier =
new AttributeModifier(LEGACY_UUID, "legacy", current, AttributeModifier.Operation.ADDITION);
this.modifiers.put(newModifier.getId(), newModifier);
Collection<AttributeModifier> modifiers =
this.getModifiersByOperation(newModifier.getOperation());
modifiers.remove(newModifier);
modifiers.add(newModifier);
synchronized (this.modifiersByOperation) {
this.modifiersByOperation.remove(newModifier.getOperation(), newModifier);
this.modifiersByOperation.put(newModifier.getOperation(), newModifier);
}
this.persistentModifiers.remove(newModifier);
this.persistentModifiers.add(newModifier);
this.flagUpdate();
Expand Down Expand Up @@ -437,12 +437,16 @@ public Set<AttributeModifier> getCachedModifiers() {

public Collection<AttributeModifier> getModifiersByOperation(
AttributeModifier.Operation operation) {
return this.modifiersByOperation.get(operation);
synchronized (this.modifiersByOperation) {
return new ArrayList<>(this.modifiersByOperation.get(operation));
}
}

public void addTransientModifier(AttributeModifier modifier) {
this.modifiers.put(modifier.getId(), modifier);
this.getModifiersByOperation(modifier.getOperation()).add(modifier);
synchronized (this.modifiersByOperation) {
this.modifiersByOperation.put(modifier.getOperation(), modifier);
}
this.flagUpdate();
}

Expand All @@ -456,7 +460,9 @@ public void removeModifier(UUID uuid) {

if (modifier != null) {
this.persistentModifiers.remove(modifier);
this.getModifiersByOperation(modifier.getOperation()).remove(modifier);
synchronized (this.modifiersByOperation) {
this.modifiersByOperation.remove(modifier.getOperation(), modifier);
}
this.flagUpdate();
}
}
Expand Down