Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SubscribeEvent
- public void onPlayerDeath(LivingDeathEvent event) {
- Entity entity = event.getEntity();
- if (entity instanceof PlayerEntity) {
- PlayerEntity player = (PlayerEntity)entity;
- for (ServerPlayerEntity serverPlayerEntity : player.getServer().getPlayerList().getPlayers()) {
- if (player.getCapability(BindingCapabilities.LIFE_BOUND_CAPABILITY).orElse(null).isBound()) {
- IBoundCapability bound = player.getCapability(BindingCapabilities.LIFE_BOUND_CAPABILITY).orElse(null);
- /** Checks if the source is from our damaging effect. */
- if (event.getSource().equals(ModDamageSource.causeBoundPlayer(player)) == true) {
- BoundPlayersList.removeUsername(bound.getUUID());
- serverPlayerEntity.removePotionEffect(LifeBindingPotion.LIFE_DAMAGING_EFFECT.get());
- }
- /** Checks if the bound player is offline. If so, adds their name to the death list. */
- if (player.getServer().getPlayerList().getPlayerByUUID(bound.getUUID()) == null) {
- BoundPlayersList.setUsername(bound.getUUID(), bound.getName());
- } else {
- /** If the player is online, remove their name and give the effect. */
- player.getServer().getPlayerList().getPlayerByUUID(bound.getUUID()).addPotionEffect(new
- EffectInstance(LifeBindingPotion.LIFE_DAMAGING_EFFECT.get(), 200));
- BoundPlayersList.removeUsername(bound.getUUID());
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement