pdinklag / MinecraftStats

A Minecraft player statistics browser for the web - supports 1.13 and later!
https://discord.gg/brH5PGG8By
Other
227 stars 53 forks source link

Electrician counting redstone_ore as mined #40

Closed AidanSkerry closed 5 years ago

AidanSkerry commented 5 years ago

Unsure why, but this causes the award stat to go negative very quickly. Easy to replicate by modifying save data.

pdinklag commented 5 years ago

Hm. May be that I understand Python's matching the wrong way? It does try to match minecraft:redstone, which is a prefix of minecraft:redstone_ore. This may be the issue here. Possibly something like minecraft:redstone$ is needed.

AidanSkerry commented 5 years ago

Not entirely sure, not well versed with python myself, but that does seem the most likely cause.

pdinklag commented 5 years ago

Aye, confirmed by this little test:

import re

def find_match(p, subjects):
    print('"{}" matches ...'.format(p))
    pc = re.compile(p)
    for s in subjects:
        if pc.match(s):
            print('\t' + s)

subjects = ['redstone', 'redstone_ore']
find_match('redstone', subjects)
find_match('redstone$', subjects)

Result:

"redstone" matches ...
        redstone
        redstone_ore
"redstone$" matches ...
        redstone

Will fix - probably by auto-inserting $ at the end of each pattern and even ^ at the beginning, because that's really what's intended. Might even sort out more issues like this that haven't been found yet.

AidanSkerry commented 5 years ago

Cheers mate, good stuff.