Plugin load but didn't work

Discussion in 'Plugin Development' started by MrEpic, May 9, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    MrEpic

    Code:java
    1. package de.MrEpic.Ducky;
    2.  
    3. import org.bukkit.Location;
    4. import org.bukkit.Material;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.EventHandler;
    7. import org.bukkit.event.EventPriority;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.event.block.Action;
    10. import org.bukkit.event.player.PlayerInteractEvent;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13.  
    14.  
    15. public class main
    16. extends JavaPlugin
    17. implements Listener
    18. {
    19. public void onEnable()
    20. {
    21. }
    22.  
    23. public void onDisable() {}
    24.  
    25. @EventHandler(priority = EventPriority.MONITOR)
    26. public void onInterasct(PlayerInteractEvent ev) {
    27.  
    28.  
    29. if (ev.getAction() == Action.RIGHT_CLICK_BLOCK) {
    30. Player player = ev.getPlayer();
    31. if (ev.getClickedBlock().getType().equals(Material.IRON_BLOCK)) {
    32.  
    33. Location loc = ev.getClickedBlock().getLocation();
    34.  
    35. loc.setY(loc.getY() - 1);
    36. if (loc.getBlock().getType().equals(Material.DIAMOND_BLOCK)) {
    37. player.performCommand("warp pvp");
    38. }
    39. }
    40. }
    41. }
    42. @EventHandler(priority = EventPriority.MONITOR)
    43. public void onInterasct2(PlayerInteractEvent ev) {
    44.  
    45.  
    46. if (ev.getAction() == Action.RIGHT_CLICK_BLOCK) {
    47. Player player = ev.getPlayer();
    48. if (ev.getClickedBlock().getType().equals(Material.IRON_BLOCK)) {
    49.  
    50. Location loc = ev.getClickedBlock().getLocation();
    51. loc.setY(loc.getY() - 1);
    52. if (loc.getBlock().getType().equals(Material.GOLD_BLOCK)) {
    53. player.performCommand("warp arena");
    54. }
    55. }
    56. }
    57. }
    58. @EventHandler(priority = EventPriority.MONITOR)
    59. public void onInterasct3(PlayerInteractEvent ev) {
    60.  
    61.  
    62. if (ev.getAction() == Action.RIGHT_CLICK_BLOCK) {
    63. Player player = ev.getPlayer();
    64. if (ev.getClickedBlock().getType().equals(Material.IRON_BLOCK)) {
    65.  
    66. Location loc = ev.getClickedBlock().getLocation();
    67.  
    68. loc.setY(loc.getY() - 1);
    69. if (loc.getBlock().getType().equals(Material.STONE)) {
    70. player.performCommand("warp zombie");
    71. }
    72. }
    73. }
    74. }
    75. @EventHandler(priority = EventPriority.MONITOR)
    76. public void onInterasct4(PlayerInteractEvent ev) {
    77.  
    78.  
    79. if (ev.getAction() == Action.RIGHT_CLICK_BLOCK) {
    80. Player player = ev.getPlayer();
    81. if (ev.getClickedBlock().getType().equals(Material.IRON_BLOCK)) {
    82.  
    83. Location loc = ev.getClickedBlock().getLocation();
    84.  
    85. loc.setY(loc.getY() - 1);
    86. if (loc.getBlock().getType().equals(Material.DIRT)) {
    87. player.performCommand("warp skypvp");
    88. }
    89. }
    90. }
    91. }
    92. @EventHandler(priority = EventPriority.MONITOR)
    93. public void onInterasct5(PlayerInteractEvent ev) {
    94.  
    95.  
    96. if (ev.getAction() == Action.RIGHT_CLICK_BLOCK) {
    97. Player player = ev.getPlayer();
    98. if (ev.getClickedBlock().getType().equals(Material.IRON_BLOCK)) {
    99.  
    100. Location loc = ev.getClickedBlock().getLocation();
    101.  
    102. loc.setY(loc.getY() - 1);
    103. if (loc.getBlock().getType().equals(Material.GLOWSTONE)) {
    104. player.performCommand("warp Mobarena");
    105. }
    106. }
    107. }
    108. }
    109. @EventHandler(priority = EventPriority.MONITOR)
    110. public void onInterasct6(PlayerInteractEvent ev) {
    111.  
    112.  
    113. if (ev.getAction() == Action.RIGHT_CLICK_BLOCK) {
    114. Player player = ev.getPlayer();
    115. if (ev.getClickedBlock().getType().equals(Material.IRON_BLOCK)) {
    116.  
    117. Location loc = ev.getClickedBlock().getLocation();
    118.  
    119. loc.setY(loc.getY() - 1);
    120. if (loc.getBlock().getType().equals(Material.WORKBENCH)) {
    121. player.performCommand("warp sg");
    122. }
    123. }
    124. }
    125. }
    126. @EventHandler(priority = EventPriority.MONITOR)
    127. public void onInterasct7(PlayerInteractEvent ev) {
    128.  
    129.  
    130. if (ev.getAction() == Action.RIGHT_CLICK_BLOCK) {
    131. Player player = ev.getPlayer();
    132. if (ev.getClickedBlock().getType().equals(Material.IRON_BLOCK)) {
    133.  
    134. Location loc = ev.getClickedBlock().getLocation();
    135.  
    136. loc.setY(loc.getY() - 1);
    137. if (loc.getBlock().getType().equals(Material.BRICK)) {
    138. player.performCommand("warp quake");
    139. }
    140. }
    141. }
    142. }
    143. @EventHandler(priority = EventPriority.MONITOR)
    144. public void onInterasct8(PlayerInteractEvent ev) {
    145.  
    146.  
    147. if (ev.getAction() == Action.RIGHT_CLICK_BLOCK) {
    148. Player player = ev.getPlayer();
    149. if (ev.getClickedBlock().getType().equals(Material.IRON_BLOCK)) {
    150.  
    151. Location loc = ev.getClickedBlock().getLocation();
    152.  
    153. loc.setY(loc.getY() - 1);
    154. if (loc.getBlock().getType().equals(Material.QUARTZ_BLOCK)) {
    155. player.performCommand("warp spleef");
    156. }
    157. }
    158. }
    159. }
    160. @EventHandler(priority = EventPriority.MONITOR)
    161. public void onInterasct9(PlayerInteractEvent ev) {
    162.  
    163.  
    164. if (ev.getAction() == Action.RIGHT_CLICK_BLOCK) {
    165. Player player = ev.getPlayer();
    166. if (ev.getClickedBlock().getType().equals(Material.IRON_BLOCK)) {
    167.  
    168. Location loc = ev.getClickedBlock().getLocation();
    169.  
    170. loc.setY(loc.getY() - 1);
    171. if (loc.getBlock().getType().equals(Material.SPONGE)) {
    172. player.performCommand("warp skyblock");
    173. }
    174. }
    175. }
    176. }
    177. @EventHandler(priority = EventPriority.MONITOR)
    178. public void onInterasct10(PlayerInteractEvent ev) {
    179.  
    180.  
    181. if (ev.getAction() == Action.RIGHT_CLICK_BLOCK) {
    182. Player player = ev.getPlayer();
    183. if (ev.getClickedBlock().getType().equals(Material.IRON_BLOCK)) {
    184.  
    185. Location loc = ev.getClickedBlock().getLocation();
    186.  
    187. loc.setY(loc.getY() - 1);
    188. if (loc.getBlock().getType().equals(Material.GOLD_BLOCK)) {
    189. player.sendMessage("§6DUCKY §8-§r Comming soon...");
    190. }
    191. }
    192. }
    193. }
    194. }
    195.  


    My Plugin loaded up fine, but it still doesen't work. There are nor errors oder exceptions, does anyone know what the problem is?
     
  2. Offline

    koencraft2002

    You haven't registered your main class as a Listener. In your onEnable() put this line of code:

    Bukkit.getPluginManager().registerEvents(this, this);

    This will register your class to be a Listener, Now it should work!

    NOTE: If your listener is in a different class, for example in the class MyListener
    You have to change the first argument (the first "this") with: new MyListener()
    It should then look like: Bukkit.getPluginManager().registerEvents(new MyListener(), this);
     
  3. Offline

    MrEpic

    Oh thx I forget Ths :oops:
     
  4. Offline

    ChunkMe

    It is not what you asked for.
    But i have a tip.
    You let the player perform a command but you can also do this to let them teleport
    Code:java
    1. World w = p.getWorld();
    2. Location pvp = new Location(w, x, y, z);
    3. p.teleport(pvp);

    w can tough be another world that you are wanted to teleport to.
    x, y, z are the cooördinates.
    And the teleport teleports the player to it.
    Succes!
     
  5. Offline

    MrEpic

    Ok thx too
     
Thread Status:
Not open for further replies.

Share This Page