Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by hasanas, May 28, 2017.
You would have to give the entity a name before you can check for one, Or else It returns null
That's obviously not the problem, his IDE its telling him that there is no getName method in the entity class. Also, you don't have to set the entity's name before accessing it.
Do what your IDE is telling you.
There is no getName() method in the Entity class (thats what getDamager() returns, an Entity). Cast it to Player since you already did an instanceof check.
Try using #getCustomName()
Entity does in fact have a getName() method, so the OP maybe using an outdated version.
If you are really new to Java you should probably learn the language first before attempting to use a Java api. It will help a lot, trust me.
Actually, no. It doesn't. It comes from CommandSender which Entity now extends in recent versions of the API.
Right now he is learning, one of the best ways to learn is just do it.
Exactly - so the OP should be able to use #getName() on the entity.
Not everyone uses the most up-to-date API. For all you know he's making a plugin for 1.7, so don't assume, and make sure you give correct answers. The answer you keep poking at is the correct answer because his IDE obviously is telling him there is no method there, and is forward compatible so nothing breaks in the newer APIs.