Looking good for a first!
A few things:
You do a lot of unnecessary null checks on bestree. In the time it takes you to check if it is visible, it's not going to change to null.
Also, you would run away if the mugger is existing (but not targeting you) - check if both the player and mugger are in combat
You also define "tree" in a lot of local scopes - this can mean that the "tree" defined in getState() is different to the "tree" defined in onLoop() - keep variables like that outside the method scope and instead in the class scope (so every method can access it)
You only check if the "tree" is not null, not the oak tree (assuming woodcutting is > 15)
People would begin cutting oaks at level 16 (use >= 15 to start at 15) - if this is what you want then leave it as it is
It takes around 6-7 seconds for an NPC to lose interest of you after you are out of its range. Out of the mugger's range may be inside the castle, for example.
If you have any questions, feel free to message me