forked from JannisX11/blockbench-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathduplicate_renamer.js
More file actions
41 lines (41 loc) · 1.58 KB
/
Copy pathduplicate_renamer.js
File metadata and controls
41 lines (41 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(function () {
// Register plugin
Plugin.register('duplicate_renamer', {
title: 'Duplicate Bone Renamer',
author: 'Gecko',
icon: 'fa-font',
description: 'This plugin renames duplicate bones so they work in bedrock and GeckoLib',
about: 'Simply go to Edit -> Rename Duplicates. All duplicate bones will get renamed to {bone}_{number}',
version: '1.0.0',
variant: 'both',
onload() {
button = new Action('rename_duplicates', {
name: 'Rename Duplicates',
description: 'Rename all duplicate bone names',
icon: 'fa-font',
click: function () {
Undo.initEdit({outliner: true});
const duplicates = []
Group.all.forEach(x => {
if (duplicates.some(group => group.name === x.name)) {
let duplicate = duplicates.find(group => group.name === x.name);
x.name += "_" + duplicate.number;
duplicate.number++;
}
else {
duplicates.push({
name: x.name,
number: 1
})
}
})
Undo.finishEdit('rename duplicates', {outliner: true});
}
});
MenuBar.addAction(button, 'edit.-1');
},
onunload() {
button.delete();
}
});
})();