Guest User

Untitled

a guest
Dec 10th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. package com.MiracleM4n.InvinciWolf;
  2.  
  3. import org.bukkit.ChatColor;
  4. import org.bukkit.entity.Entity;
  5. import org.bukkit.entity.Player;
  6. import org.bukkit.entity.Wolf;
  7. import org.bukkit.event.player.PlayerInteractEntityEvent;
  8. import org.bukkit.event.player.PlayerListener;
  9.  
  10. public class IWPlayerListener extends PlayerListener {
  11.  
  12. InvinciWolf plugin = null;
  13.  
  14. public IWPlayerListener(InvinciWolf callbackPlugin) {
  15. plugin = callbackPlugin;
  16. }
  17.  
  18. public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
  19. Player player = event.getPlayer();
  20. int wolves = 0;
  21. if (event.getRightClicked() instanceof Wolf) {
  22. System.out.println("Clicked Is Wolf");
  23. for (Entity entity : player.getWorld().getEntities()) {
  24. if ((entity instanceof Wolf) && (((Wolf) entity).isTamed() == true)) {
  25. System.out.println("Found All Tamed Wolves");
  26. if (((Wolf) entity).getOwner() == player) {
  27. System.out.println("Wolves Are Players");
  28. if (wolves > 10) {
  29. System.out.println("More Than 10");
  30. if ((InvinciWolf.Permissions == null && ((player.isOp())) ||
  31. (InvinciWolf.Permissions != null && InvinciWolf.Permissions.has(player, "invinciwolf.many")))) {
  32. System.out.println("Permissions Found");
  33. Wolf wolf = (Wolf) entity;
  34. System.out.println("Entity Identifier");
  35. wolf.setTamed(true);
  36. System.out.println("SetTamed");
  37. } else {
  38. player.sendMessage(ChatColor.RED + "[InvinciWolf] You can't own over 10 wolves.");
  39. Wolf wolf = (Wolf) entity;
  40. wolf.setTamed(false);
  41. }
  42. wolves++;
  43. }
  44. }
  45. }
  46. }
  47. }
  48. }
  49. }
Add Comment
Please, Sign In to add comment