Server Wont Accept This

Discussion in 'Plugin Development' started by candyfloss20, Mar 7, 2014.

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

    candyfloss20

    Hey when i put this plugin in to my server it dose nothing and in eclipse it says there are no errors
    Code:java
    1. package me.candyfloss20.PlaguecraftHubCore;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.event.EventHandler;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.event.block.BlockBreakEvent;
    12. import org.bukkit.event.block.BlockPlaceEvent;
    13. import org.bukkit.event.player.PlayerJoinEvent;
    14. import org.bukkit.event.player.PlayerQuitEvent;
    15. import org.bukkit.plugin.PluginDescriptionFile;
    16. import org.bukkit.plugin.java.JavaPlugin;
    17.  
    18. public class PlaguecraftHubCore extends JavaPlugin implements Listener {
    19. public final Logger logger = Logger.getLogger("Minecraft");
    20.  
    21. public void onEnable() {
    22. PluginDescriptionFile pdfflie = this.getDescription();
    23. this.logger.info(pdfflie.getName() + "By Candyfloss20 Has Been Loaded And Enabled");
    24. }
    25.  
    26. public void onDisale() {
    27. PluginDescriptionFile pdfflie = this.getDescription();
    28. this.logger.info(pdfflie.getName() + "By Candyfloss20 Has Been Unloaded And Disabled");
    29. }
    30.  
    31. @EventHandler
    32. public void onJoin(PlayerJoinEvent event){
    33. Player player = event.getPlayer();
    34. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + " §aYou Have Been Summend To Hub");
    35. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + " §aHub By Candyfloss20, slayerjet & thestinkysock");
    36. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + " §aRight Click On Your Compass To Play");
    37. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + " §aOr Jump In The Portals To Play");
    38.  
    39. }
    40.  
    41. @EventHandler
    42. public void onJoin1(PlayerJoinEvent event){
    43. event.setJoinMessage(ChatColor.GREEN + "§a§l> §6Plaguecraft §a§l> " + ChatColor.WHITE + event.getPlayer().getName() + " §6Connected To The Hub!");
    44.  
    45. }
    46.  
    47. @EventHandler
    48. public void OnQuit(PlayerQuitEvent event){
    49. event.setQuitMessage(ChatColor.GREEN + "§7[§2-§7] §r " + ChatColor.WHITE + event.getPlayer().getName());
    50. }
    51.  
    52. @EventHandler
    53. public void onBlockBreak(BlockBreakEvent event){
    54. Player player = event.getPlayer();
    55. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + ChatColor.RED + "Does Not Allow You To Edit Their Hub");
    56.  
    57. }
    58.  
    59. @EventHandler
    60. public void onBlockPlace(BlockPlaceEvent event){
    61. Player player = event.getPlayer();
    62. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + ChatColor.RED + "Does Not Allow You To Edit Their Hub");
    63.  
    64. }
    65.  
    66. public boolean onCommand(CommandSender sender, Command cmd, String lable, String[] a){
    67. Player player = (Player) sender;
    68. if(cmd.getName().equalsIgnoreCase("help")){
    69.  
    70. if(a.length < 1){
    71. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.GREEN + "The Help Commands Are As Follows:");
    72. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.YELLOW + "/hub - §6Reconnect to the hub from anywere");
    73. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.YELLOW + "/server-list - §6Lists All Server");
    74. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.YELLOW + "/donate - §6Gives The Info On How To Donate");
    75. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.YELLOW + "/website - §6Gives You The Website Info");
    76. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.YELLOW + "/report <name> <reason> - §6Report Players");
    77.  
    78.  
    79. }
    80.  
    81. }
    82. return false;
    83.  
    84. }
    85. }

    and the plugin.yml is this
    Code:
    name: [PlaguecraftHubCore]
    main: me.candyfloss20.PlaguecraftHubCore.PlaguecraftHubCore
    version: 1.0
    description: Core Plugin For Plaguecraft Hub
    author: candyfloss20
     
    commands:
        help:
            usage: /help
            aliases: [helpme]
            description: Help Cmds For Plaguecraft Hub!
     
  2. Offline

    GaaTavares

    Does the console shows something? If so, can we see?
    Type /pl in-game, is the plugin in it?
     
  3. Offline

    Garris0n

    1. You don't need to print enable/disable messages, the server does that for you. In addition, if you want to use the logger, use getLogger() from JavaPlugin, which is the correct logger and will also automatically prefix any logs with your plugin's name.
    2. Use the ChatColor enum for colors (for some reason, you're using both the enum and the actual color codes and randomly switching, but just use ChatColor).
    3. You don't actually register the listener so none of those event handlers work.
    4. You misspelled onDisable, so it won't actually be called.
    5. You assume the command sender is a player when it may not be a player, and if it is not a player you'll end up with a ClassCastException.
    6. A lot of the variables in your events are redundant.
    7. Your text has a lot of unnecessary capitalization (this is purely a cosmetic issue).
    8. You misspelled "summoned" (still a cosmetic issue, but you might want to fix that).
     
  4. Offline

    candyfloss20

    code it now this but it the console it was enabling as the way i had set it eg: [INFO]: [PlaguecraftHubCore]: enabled
    its the join message and the command /help that's not working

    Code:java
    1. package me.candyfloss20.PlaguecraftHubCore;
    2.  
    3.  
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.event.EventHandler;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.event.block.BlockBreakEvent;
    11. import org.bukkit.event.block.BlockPlaceEvent;
    12. import org.bukkit.event.player.PlayerJoinEvent;
    13. import org.bukkit.event.player.PlayerQuitEvent;
    14. import org.bukkit.plugin.java.JavaPlugin;
    15.  
    16. public class PlaguecraftHubCore extends JavaPlugin implements Listener {
    17.  
    18. @EventHandler
    19. public void onJoin(PlayerJoinEvent event){
    20. Player player = event.getPlayer();
    21. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + " §aYou Have Been Summend To Hub");
    22. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + " §aHub By Candyfloss20, slayerjet & thestinkysock");
    23. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + " §aRight Click On Your Compass To Play");
    24. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + " §aOr Jump In The Portals To Play");
    25.  
    26. }
    27.  
    28. @EventHandler
    29. public void onJoin1(PlayerJoinEvent event){
    30. event.setJoinMessage(ChatColor.GREEN + "§a§l> §6Plaguecraft §a§l> " + ChatColor.WHITE + event.getPlayer().getName() + " §6Connected To The Hub!");
    31.  
    32. }
    33.  
    34. @EventHandler
    35. public void OnQuit(PlayerQuitEvent event){
    36. event.setQuitMessage(ChatColor.GREEN + "§7[§2-§7] §r " + ChatColor.WHITE + event.getPlayer().getName());
    37. }
    38.  
    39. @EventHandler
    40. public void onBlockBreak(BlockBreakEvent event){
    41. Player player = event.getPlayer();
    42. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + ChatColor.RED + "Does Not Allow You To Edit Their Hub");
    43.  
    44. }
    45.  
    46. @EventHandler
    47. public void onBlockPlace(BlockPlaceEvent event){
    48. Player player = event.getPlayer();
    49. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + ChatColor.RED + "Does Not Allow You To Edit Their Hub");
    50.  
    51. }
    52.  
    53. public boolean onCommand(CommandSender sender, Command cmd, String lable, String[] a){
    54. Player player = (Player) sender;
    55. if(cmd.getName().equalsIgnoreCase("help")){
    56.  
    57. if(a.length < 1){
    58. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.GREEN + "The Help Commands Are As Follows:");
    59. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.YELLOW + "/hub - §6Reconnect to the hub from anywere");
    60. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.YELLOW + "/server-list - §6Lists All Server");
    61. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.YELLOW + "/donate - §6Gives The Info On How To Donate");
    62. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.YELLOW + "/website - §6Gives You The Website Info");
    63. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.YELLOW + "/report <name> <reason> - §6Report Players");
    64.  
    65.  
    66. }
    67.  
    68. }
    69. return false;
    70.  
    71. }
    72. }
     
  5. Offline

    Konkz

    You need an onEnable method, and inside that register your event.

    EDIT: Also you can replace

    Code:java
    1. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + " §aYou Have Been Summend To Hub");


    with something like (not actual colours!)

    Code:
    player.sendMessage(ChatColor.RED + "Plaguecraft" + ChatColor.AQUA + " You Have Been Summoned To Hub");
    You can use ChatColor.COLOR to add colors when sending messages. :)
     
  6. Offline

    candyfloss20

    Konkz
    i know but useing § also works ive used before so its easier for me to use but thanks for the tip

    Konkz so
    Code:java
    1. public void onEnable() {
    2. getServer().getPluginManager().registerEvents(this, this);


    ive done so and still nothing it it this now! but still not working !

    Jar:
    Code:java
    1. package me.candyfloss20.PlaguecraftHubCore;
    2.  
    3.  
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.event.EventHandler;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.event.block.BlockBreakEvent;
    11. import org.bukkit.event.block.BlockPlaceEvent;
    12. import org.bukkit.event.player.PlayerJoinEvent;
    13. import org.bukkit.event.player.PlayerQuitEvent;
    14. import org.bukkit.plugin.java.JavaPlugin;
    15.  
    16. public class PlaguecraftHubCore extends JavaPlugin implements Listener {
    17.  
    18. public void onEnable() {
    19. getServer().getPluginManager().registerEvents(this, this);
    20.  
    21. }
    22.  
    23. @EventHandler
    24. public void onJoin(PlayerJoinEvent event){
    25. Player player = event.getPlayer();
    26. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + " §aYou Have Been Summend To Hub");
    27. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + " §aHub By Candyfloss20, slayerjet & thestinkysock");
    28. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + " §aRight Click On Your Compass To Play");
    29. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + " §aOr Jump In The Portals To Play");
    30.  
    31. }
    32.  
    33. @EventHandler
    34. public void onJoin1(PlayerJoinEvent event){
    35. event.setJoinMessage(ChatColor.GREEN + "§a§l> §6Plaguecraft §a§l> " + ChatColor.WHITE + event.getPlayer().getName() + " §6Connected To The Hub!");
    36.  
    37. }
    38.  
    39. @EventHandler
    40. public void OnQuit(PlayerQuitEvent event){
    41. event.setQuitMessage(ChatColor.GREEN + "§7[§2-§7] §r " + ChatColor.WHITE + event.getPlayer().getName());
    42. }
    43.  
    44. @EventHandler
    45. public void onBlockBreak(BlockBreakEvent event){
    46. Player player = event.getPlayer();
    47. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + ChatColor.RED + "Does Not Allow You To Edit Their Hub");
    48.  
    49. }
    50.  
    51. @EventHandler
    52. public void onBlockPlace(BlockPlaceEvent event){
    53. Player player = event.getPlayer();
    54. player.sendMessage("§a§l> §6Plaguecraft §a§l>§6" + ChatColor.RED + "Does Not Allow You To Edit Their Hub");
    55.  
    56. }
    57.  
    58. public boolean onCommand(CommandSender sender, Command cmd, String lable, String[] a){
    59. Player player = (Player) sender;
    60. if(cmd.getName().equalsIgnoreCase("help")){
    61.  
    62. if(a.length < 1){
    63. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.GREEN + "The Help Commands Are As Follows:");
    64. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.YELLOW + "/hub - §6Reconnect to the hub from anywere");
    65. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.YELLOW + "/server-list - §6Lists All Server");
    66. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.YELLOW + "/donate - §6Gives The Info On How To Donate");
    67. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.YELLOW + "/website - §6Gives You The Website Info");
    68. player.sendMessage("§a§l> §6Plaguecraft §a§l>" + ChatColor.YELLOW + "/report <name> <reason> - §6Report Players");
    69.  
    70.  
    71. }
    72.  
    73. }
    74. return false;
    75.  
    76. }
    77. }


    yml:
    Code:
    name: [PlaguecraftHubCore]
    main: me.candyfloss20.PlaguecraftHubCore.PlaguecraftHubCore
    version: 1.0
    description: Core Plugin For Plaguecraft Hub
    author: candyfloss20
     
    commands:
      help:
        description: Help Command
     
  7. Offline

    0x277F

    But this is getting off-topic.
    • Your onCommand method cannot return true
    • You have 2 different onPlayerJoin eventhandlers. This might not be an issue, but you only really need one.
    • You don't cancel your onBlockPlace and onBlockBreak methods
    • While using the color codes might be easier for you, it decreases the readability of your code
    Feel free to correct me if I was wrong about anything.
     
  8. Offline

    thepowderguy

    I believe that the "name" key in plugin.yml should be a string, not a list.
    change it to
    Code:
    name: PlaguecraftHubCore
    [/COLOR][/FONT]
     
  9. Offline

    Necrodoom

    Cleaned up thread.
    TheKomputerKing Do not flame other users. If you have an issue with a thread, do not reply.
    candyfloss20 Threating to hack other users is not allowed here and will lead to your termination.
    Both of you, read guidelines before posting.
     
  10. Offline

    candyfloss20

    Necrodoom
    can you remove post i have fix the problem myself !
     
Thread Status:
Not open for further replies.

Share This Page