Solved Whats wrong!! it has to work?

Discussion in 'Plugin Development' started by Norbu10, Apr 2, 2014.

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

    Norbu10

    So i have a problem and i cant figur it out... i want a class : paintball
    but i seems to dont register the events! Why not!?
    Code :
    OnEnable(); :
    Code:java
    1. private paintball paint;
    2. public void onEnable(){
    3. paint = new paintball(this);
    4. this.getServer().getPluginManager().registerEvents(paint, this);
    5. }

    class :
    Code:java
    1. package me.norbert.norbuland;
    2.  
    3. import java.util.ArrayList;
    4. import java.util.HashMap;
    5.  
    6. import org.bukkit.Bukkit;
    7. import org.bukkit.ChatColor;
    8. import org.bukkit.Material;
    9. import org.bukkit.block.Sign;
    10. import org.bukkit.entity.Player;
    11. import org.bukkit.event.EventHandler;
    12. import org.bukkit.event.Listener;
    13. import org.bukkit.event.block.Action;
    14. import org.bukkit.event.block.SignChangeEvent;
    15. import org.bukkit.event.player.PlayerInteractEvent;
    16. import org.bukkit.event.player.PlayerJoinEvent;
    17. import org.bukkit.scheduler.BukkitRunnable;
    18.  
    19. public class paintball implements Listener {
    20. norbuland main;
    21. public HashMap<String, Integer> Score = new HashMap<String, Integer>();
    22. ArrayList<String> Blauw = new ArrayList<String>();
    23. ArrayList<String> Rood = new ArrayList<String>();
    24. public paintball(norbuland main) {
    25. this.main = main;
    26. }
    27. @EventHandler
    28. public void HelpByPlaceSign(SignChangeEvent event){
    29. Sign s = (Sign) event.getBlock();
    30. if (s.getLine(0).equals("NPB")){
    31. s.setLine(0, ChatColor.AQUA+"PaintBall");
    32. }
    33. if (s.getLine(1).equals("JB")){
    34. s.setLine(1, ChatColor.BLUE+"Team Blauw!");
    35. }
    36. if (s.getLine(1).equals("JR")){
    37. s.setLine(1, ChatColor.RED+"Team Rood!");
    38. }
    39. }
    40. @EventHandler
    41. public void Join (PlayerInteractEvent event){
    42. Player p = event.getPlayer();
    43. if (event.getAction() == Action.RIGHT_CLICK_BLOCK){
    44. if (event.getClickedBlock().getType() == Material.SIGN){
    45. Sign s = (Sign) event.getClickedBlock();
    46. if (s.getLine(0).equals(ChatColor.AQUA+"PaintBall")){
    47. if (s.getLine(1).equals(ChatColor.BLUE+"Team Blauw!")){
    48. if (Blauw.contains(p.getName()) || Rood.contains(p.getName())){
    49. p.sendMessage(ChatColor.GREEN+"Je zit al in een team!");
    50. } else {
    51. Blauw.add(p.getName());
    52. p.sendMessage(ChatColor.BLUE+"Je zit nu in team Blauw!");
    53. }
    54. }
    55. if (s.getLine(1).equals(ChatColor.RED+"Team Rood!")){
    56. if (Blauw.contains(p.getName()) || Rood.contains(p.getName())){
    57. p.sendMessage(ChatColor.GREEN+"Je zit al in een team!");
    58. } else {
    59. Rood.add(p.getName());
    60. p.sendMessage(ChatColor.RED+"Je zit nu in team Rood!");
    61. }
    62. }
    63. }
    64. }
    65. }
    66. new BukkitRunnable(){
    67. @Override
    68. public void run() {
    69. if (Blauw.size() >= 1 || Rood.size() >= 1){
    70. for (Player pl : Bukkit.getOnlinePlayers()){
    71. if (Blauw.contains(pl.getName()) || Rood.contains(pl.getName())){
    72. StartGame(pl);
    73. }
    74. }
    75. }
    76. }
    77. }.runTaskTimer(main, 0L, 10L);
    78. }
    79. public void StartGame (Player p){
    80. p.sendMessage("Hi");
    81. }
    82. @EventHandler
    83. public void OnJoin (PlayerJoinEvent event){
    84. event.getPlayer().setLevel(10);
    85. }
    86. }
    87.  
     
  2. Offline

    2MBKindiegames

    Please don't use general names like "Whats wrong!! it has to work?" as topic title!
     
  3. Offline

    Rocoty

    What makes you think it isn't registering? Any errors in the console? Can you post the plugin.yml and entire main class?
     
  4. Offline

    Norbu10

    Sorry i didnt know a name :p
    Its fixed the problem was in the event itself -.-
     
  5. Offline

    2MBKindiegames

    Norbu10 Something like "Events Not Registering", maybe ? :)
    Anyway, glad you fixed it!
     
Thread Status:
Not open for further replies.

Share This Page