Skip to content

Commit 5c98d7e

Browse files
committed
Small fixes
1 parent de5cb1b commit 5c98d7e

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

fNbt/Tags/NbtContainerTag.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void Clear()
5252
}
5353
public void Insert(int index, NbtTag item)
5454
{
55-
PerformAction(new DescriptionHolder("Insert {0} into {1} at index {2}", this, item, index),
55+
PerformAction(new DescriptionHolder("Insert {0} into {1} at index {2}", item, this, index),
5656
() => DoInsert(index, item),
5757
() => DoRemoveAt(index)
5858
);
@@ -64,7 +64,7 @@ public bool Remove(NbtTag item)
6464
return false;
6565
return PerformAction(new DescriptionHolder("Remove {0} from {1}", item, this),
6666
() => DoRemove(item),
67-
() => { DoInsert(index, item); }
67+
() => DoInsert(index, item)
6868
);
6969
}
7070
public void RemoveAt(int index)

fNbt/Tags/NbtTag.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ public abstract class NbtTag : ICloneable {
1515
public abstract NbtTagType TagType { get; }
1616

1717
/// <summary> Event raised when this tag or one of its children is changed. </summary>
18-
public event EventHandler<NbtTag> Changed;
18+
public event Action<NbtTag> Changed;
1919

20-
/// <summary> Event raised when this tag or one of its children has an undoable action performed on it. </summary>
21-
public event EventHandler<UndoableAction> ActionPerformed;
20+
/// <summary> Event raised when this tag has an undoable action performed on it. </summary>
21+
public event Action<UndoableAction> ActionPerformed;
2222

23-
private void RaiseChanged(NbtTag tag) => Changed?.Invoke(this, tag);
24-
private void RaiseActionPerformed(UndoableAction action) => ActionPerformed?.Invoke(this, action);
23+
private void RaiseChanged(NbtTag tag) => Changed?.Invoke(tag);
24+
private void RaiseActionPerformed(UndoableAction action) => ActionPerformed?.Invoke(action);
2525

2626
/// <summary> Helper method for signaling changes to parent tags. </summary>
2727
protected T PerformAction<T>(DescriptionHolder description, Func<T> action, Action undo)
@@ -84,21 +84,17 @@ public string Name {
8484
get { return name; }
8585
set {
8686
string current_name = name;
87+
if (current_name == value)
88+
return;
8789
PerformAction(new DescriptionHolder("Rename {0} from {1}", this, current_name),
8890
() => SetName(value),
8991
() => SetName(current_name)
9092
);
91-
9293
}
9394
}
9495

9596
private void SetName(string value)
9697
{
97-
if (name == value)
98-
{
99-
return;
100-
}
101-
10298
var parentAsCompound = Parent as NbtCompound;
10399
if (parentAsCompound != null)
104100
{

0 commit comments

Comments
 (0)