theres the code, but the problem is that line 14 does not work and i cannot seem to find anyone else done this
Most likely, this is a problem with the types: If you are familiar with Java, you should know that MCEntity
(example of its usage found with Tabnine) is not comparable to type EntityType
.
Therefore, you will have to use a method to get the Type
of the MCEntity
(the Type
I'm referring to in this context is the MC type, e.g., PLAYER
, not Java-type).
This method, that exists on the MCEntity
, is MCEntity.getType()
that will return to you the MC-Type
of the Killer. So you need the code:
public void onPlayerDead(PlayerDeathEvent event) {
Player playerDead = event.getEntity();
// Now check for the Type of the Killer with the getType()-method
if (playerDead.getKiller().getType() == EntityType.PLAYER) {
event.setKeepInventory(false);
}
}
If you have further questions, feel free to ask, but this question is rather hard to answer because you just provided us one image of your code. Please take a look on how to format code with markdown.
Furthermore, the line in the editor has a red line. That indicates an error in your code. Asking the question, it would be great if you could give us the exact error message that is shown, when you hover over the red line. That helps a lot while debugging (especially other people's) code!