EnvironmentallyAwareEventHandler.java 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package com.gmail.nossr50.skills.taming;
  2. import org.bukkit.entity.Player;
  3. import org.bukkit.entity.Wolf;
  4. import org.bukkit.event.entity.EntityDamageEvent;
  5. import com.gmail.nossr50.locale.LocaleLoader;
  6. public class EnvironmentallyAwareEventHandler {
  7. private Player player;
  8. private EntityDamageEvent event;
  9. private Wolf wolf;
  10. protected EnvironmentallyAwareEventHandler(TamingManager manager, EntityDamageEvent event) {
  11. this.player = manager.getPlayer();
  12. this.event = event;
  13. this.wolf = (Wolf) event.getEntity();
  14. }
  15. protected void teleportWolf() {
  16. if(player == null)
  17. return;
  18. if (event.getDamage() > wolf.getHealth()) {
  19. return;
  20. }
  21. wolf.teleport(player.getLocation());
  22. }
  23. protected void sendAbilityMessage() {
  24. if(player == null)
  25. return;
  26. player.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf"));
  27. }
  28. protected void cancelEvent() {
  29. event.setCancelled(true);
  30. }
  31. }