Advertisement
jayhillx

onPlayerDeath 02

Jun 13th, 2021
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. @SubscribeEvent
  2. public void onPlayerDeath(LivingDeathEvent event) {
  3. Entity entity = event.getEntity();
  4.  
  5. if (entity instanceof PlayerEntity) {
  6. PlayerEntity player = (PlayerEntity)entity;
  7.  
  8. for (ServerPlayerEntity serverPlayerEntity : player.getServer().getPlayerList().getPlayers()) {
  9.  
  10. if (player.getCapability(BindingCapabilities.LIFE_BOUND_CAPABILITY).orElse(null).isBound()) {
  11. IBoundCapability bound = player.getCapability(BindingCapabilities.LIFE_BOUND_CAPABILITY).orElse(null);
  12.  
  13. /** Checks if the source is from our damaging effect. */
  14. if (event.getSource().equals(ModDamageSource.causeBoundPlayer(player)) == true) {
  15. BoundPlayersList.removeUsername(bound.getUUID());
  16. serverPlayerEntity.removePotionEffect(LifeBindingPotion.LIFE_DAMAGING_EFFECT.get());
  17. }
  18.  
  19. /** Checks if the bound player is offline. If so, adds their name to the death list. */
  20. if (player.getServer().getPlayerList().getPlayerByUUID(bound.getUUID()) == null) {
  21. BoundPlayersList.setUsername(bound.getUUID(), bound.getName());
  22. } else {
  23. /** If the player is online, remove their name and give the effect. */
  24. player.getServer().getPlayerList().getPlayerByUUID(bound.getUUID()).addPotionEffect(new
  25. EffectInstance(LifeBindingPotion.LIFE_DAMAGING_EFFECT.get(), 200));
  26. BoundPlayersList.removeUsername(bound.getUUID());
  27. }
  28. }
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement