-
Ensure you have Python 3 installed. If not, follow the instructions here for installation.
-
Ensure an up-to-date version of the
ruamel.yaml
library is installed, as documented here. Optionally, instead install using the suppliedrequirements.txt
and using the following command:
pip install -r requirements.txt
-
Backup any files contained within the folder you're executing the script, and execute the script on a copy, not the source configuration files. Test out the script on a small batch of spell files first to ensure proper formatting. Open a command line in the folder containing the spells you wish to modify, and run the script with the following arguments.
-
Download and run the script in the directory you wish to modify, as specified in step 3. The script has the following arguments:
-
-i
,--indent
- used to specify the indent of the output file, and defaults to4
. For example--indent 4
results in the script's output having an indentation of 4 spaces. -
-w
,--max_width
- used to specify the maximum line width, and defaults to4096
. The library used for parsing YAML files wraps lines according to a maximum width. -
-b
,--block_seq_indent
- used to specify the indentation used for block sequences, and defaults to the same value as the indentation. For example, with--indent 4
the output is as following:key: key: - value - value
But if
--indent 4 --block_seq_indent 2
is specified, the output is as following:key: key: - value - value
-
-n
,--include_interactions
- flag used to specify that spells involved in interactions should be modified as well. As the bug fix only pertains towards the radius when hitting entities and not interactions between particle projectiles, special consideration may need to be made for spells using interactions. As such, by default, they are ignored by the script, and instead output a message when ignored. This flag overrides this behavior. -
file_globs
- list of globs used to determine the files to be modified. The usage of**
is recursive in this case. For example,**/spell*.yml
matches any file starting withspell
and ending in.yml
in the current folder, as well as all subdirectories, recursively.
-
The following is an example usage of the script:
python radius.py --indent 4 --block_seq_indent 2 spell*.yml
This command will modify all files starting with spell
and ending with .yml
in the current directory of the command line, with the modified output having an indent of 4 spaces and a block sequence indent of 2 spaces. If the following configuration was present:
# spells-test.yml
test-projectile:
spell-class: ".instant.ParticleProjectileSpell"
tags:
- projectile
- ranged
can-cast-by-command: false
beneficial: false
cooldown: 10
spell: test-projectile-damage
stop-on-hit-entity: false
stop-on-hit-ground: false
vertical-hit-radius: 1
hit-players: true
hit-ground: false
hit-radius: 2
effects:
effect1:
position: special
effect: effectlib
effectlib:
class: VortexEffect
color: d10000
particle: SPELL_INSTANT
iterations: 1
particles: 25
helixes: 5
yOffset: 1
period: 1
radius: 8
speed: 1
test-projectile-damage:
spell-class: ".targeted.PainSpell"
tags:
- ranged
- physical
beneficial: false
damage-type: PROJECTILE
damage: 10
After running the script with the above arguments, the file would be:
# spells-test.yml
test-projectile:
spell-class: ".instant.ParticleProjectileSpell"
tags:
- projectile
- ranged
can-cast-by-command: false
beneficial: false
cooldown: 10
spell: test-projectile-damage
stop-on-hit-entity: false
stop-on-hit-ground: false
vertical-hit-radius: 0.5
hit-players: true
hit-ground: false
hit-radius: 1
effects:
effect1:
position: special
effect: effectlib
effectlib:
class: VortexEffect
color: d10000
particle: SPELL_INSTANT
iterations: 1
particles: 25
helixes: 5
yOffset: 1
period: 1
radius: 8
speed: 1
test-projectile-damage:
spell-class: ".targeted.PainSpell"
tags:
- ranged
- physical
beneficial: false
damage-type: PROJECTILE
damage: 10
Note that the hit-radius
and vertical-hit-radius
of the spell halved from 2
to 1
and from 1
to 0.5
respectively, and with --block_seq_indent 2
, the tags
block sequences were indented with 2 spaces. Additionally, the script would have the following output:
'test-projectile', 'hit-radius': '2' -> '1'
'test-projectile', 'vertical-hit-radius': '1' -> '0.5'
Modified spell file spells-test.yml.
With the following format for each spell:
<spell name>, <option name>: '<previous value>' -> '<new value>'
Modified spell file <file name>.
The message when ignoring a spell with interactions is as follows:
Ignoring spell with interactions '<spell name>' in file '<file name>'.
-
As mentioned earlier, you should back up any folders or files this script will be ran on. Incorrect usage of the script may lead to incorrect formattting, and backups ensure that any problems can be rolled back without issue.
-
Both SnakeYAML (which is used for parsing MagicSpells configurations in the plugin) and this script ignore duplicate keys. However, when the scripts outputs, these duplicates are discarded. Caution should be exercised as this script (as per YAML spec) considers the first duplicate key, while SnakeYAML considers the last duplicate key. As such, this configuration:
test: spell-class: ".instant.DummySpell" str-cast-self: "Test 1." test: spell-class: ".instant.DummySpell" str-cast-self: "Test 2."
Would have a message of
Test 2.
when casted, but this script would convert this configuration with duplicate keys to:test: spell-class: ".instant.DummySpell" str-cast-self: "Test 1."
Run a YAML linter to scan for duplicates like this before running the script, as these duplicates are discarded silently. Optionally, you can instead change line 24 in
radius.py
toyaml.allow_duplicate_keys = False
, so that files with duplicates are not loaded.