Advertisement
Guest User

Untitled

a guest
Jan 25th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1. package com.eidoscraft.theboss;
  2.  
  3. import org.bukkit.block.Block;
  4. import org.bukkit.entity.Player;
  5. import org.bukkit.event.player.PlayerInteractEvent;
  6. import org.bukkit.event.player.PlayerListener;
  7. import org.bukkit.event.player.PlayerMoveEvent;
  8. import org.bukkit.event.player.PlayerRespawnEvent;
  9.  
  10. public class MinenionPlayerListener extends PlayerListener
  11. {
  12. public Minenion minenion;
  13.  
  14. //Constants
  15. public static final int BLUE_TEAM = 1;
  16. public static final int RED_TEAM = 2;
  17. public int WEAPON_BLOCK = 3500;
  18. public byte WEAPON_BLOCK_DAMAGE;
  19. public int SKILL_BLOCK;
  20. public byte SKILL_BLOCK_DAMAGE;
  21.  
  22. /*
  23. * Constructor
  24. * @param instance : instance of game
  25. */
  26. public MinenionPlayerListener(Minenion instance)
  27. {
  28. minenion = instance;
  29. }
  30.  
  31. /*
  32. * Management of player respawn
  33. * @param event : event on player respawn
  34. */
  35. public void onPlayerRespawn(PlayerRespawnEvent event)
  36. {
  37. if(minenion.start == true)
  38. {
  39. // if a blue team player respawn move it to blue team start point
  40. if(minenion.playerTeam.get(event.getPlayer()) == BLUE_TEAM)
  41. {
  42. event.setRespawnLocation(minenion.blueTeamLocation);
  43. }
  44.  
  45. // if a purple team player respawn move it to purple team start point
  46. if(minenion.playerTeam.get(event.getPlayer()) == RED_TEAM)
  47. {
  48. event.setRespawnLocation(minenion.purpleTeamLocation);
  49. }
  50.  
  51. if(minenion.logging == true) minenion.mineLog(minenion.gameStartTime + " - " + event.getPlayer().getName() + " has respawn, giving " + minenion.playerExperience.get(event.getPlayer()) + " experience points.");
  52. }
  53. }
  54.  
  55.  
  56. /*
  57. * Management of player interaction
  58. * @param event : event on player interaction
  59. */
  60. public void onPlayerInteract(PlayerInteractEvent event)
  61. {
  62. if(minenion.start == true)
  63. {
  64. if(event.getPlayer().getLocation().getBlock() != null)
  65. {
  66. // if the event is a clicked block
  67. if(event.getClickedBlock() != null)
  68. {
  69. // if player interact on a pressure plate (id=70) near a tower
  70. if(event.getClickedBlock().getTypeId() == 70
  71. && event.getPlayer().getLocation().getBlock().getTypeId() == 70
  72. && minenion.inWhichZone(event.getPlayer().getLocation()) != 0)
  73. {
  74. // get the tower number
  75. int tower = minenion.inWhichZone(event.getPlayer().getLocation());
  76. // if the tower is not controled by the player team
  77. if(minenion.playerTeam.get(minenion.playerOnTower.get(tower)) == null)
  78. {
  79. // add controled tower to the player
  80. minenion.playerOnTower.put(tower, event.getPlayer());
  81. int team = minenion.playerTeam.get(event.getPlayer());
  82. String message;
  83. if(team == BLUE_TEAM)
  84. {
  85. message = "blue";
  86. }
  87. else
  88. {
  89. message = "red";
  90. }
  91.  
  92. // messaging to the player
  93. if(minenion.logging == true) minenion.mineLog(minenion.gameStartTime + " - " + event.getPlayer().getName() + " : The tower #" + minenion.inWhichZone(event.getPlayer().getLocation()) + " is possessed by the " + message + " team.");
  94. }
  95. }
  96.  
  97. if(minenion.light == false)
  98. {
  99. if(WEAPON_BLOCK == 3500)
  100. {
  101. WEAPON_BLOCK = minenion.shopblocks[0];
  102. WEAPON_BLOCK_DAMAGE = minenion.damage2byte(minenion.shopblocks[2]);
  103. SKILL_BLOCK = minenion.shopblocks[1];
  104. SKILL_BLOCK_DAMAGE = minenion.damage2byte(minenion.shopblocks[3]);
  105. }
  106.  
  107. // if the player click on a SHOP BLOCK
  108. if(event.getClickedBlock().getTypeId() == WEAPON_BLOCK && event.getClickedBlock().getData() == WEAPON_BLOCK_DAMAGE)
  109. {
  110. minenion.buyweapon(event.getPlayer());
  111. }
  112. if(event.getClickedBlock().getTypeId() == SKILL_BLOCK && event.getClickedBlock().getData() == SKILL_BLOCK_DAMAGE)
  113. {
  114. minenion.buyskill(event.getPlayer());
  115. }
  116. }
  117. }
  118. }
  119. }
  120.  
  121. // display block coordinate in check mode
  122. if(minenion.check == true)
  123. {
  124. Block block = event.getClickedBlock();
  125. event.getPlayer().sendMessage("X:" + block.getX() + "/Y:" + block.getY() + "/Z:"+ block.getZ());
  126. }
  127. }
  128.  
  129. /*
  130. * Management of player move
  131. * @param event : event on player move
  132. */
  133. public void onPlayerMove(PlayerMoveEvent event)
  134. {
  135. if(minenion.start && minenion.light == false)
  136. {
  137. Player player = event.getPlayer();
  138. if(minenion.hasEffect(player) && minenion.getEffect(player).equals("stun"))
  139. {
  140. event.setCancelled(true);
  141. }
  142. }
  143. }
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement