Plugin help. First Plugin

Discussion in 'Plugin Development' started by marvinpenn, Feb 20, 2014.

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

    marvinpenn

    Hay guys not rely to sure how to put this so im going to try to explain the best i can. Sorry for grammar and punctuation. never been to good with writing lol.

    Im wanting to make a first plugin. I don't rely care to much what it does i just want something that i can try to edit so i can start to understand the concept of writing plugins and understanding the rules of java script. I have tried to copy a source code from the net for "/ping" and it reply's "pong". I have changed the class name and i have changed everything i believe i need to change to get the plugin working but when i install it, it keeps telling me that i cant find the main class so i am wanting to start again.

    Would some one be able to post a very very simple source code for a command. This command can be for anything at all and can do anything. It could be something simple like "/hi" and replies back saying "hay". Im not rely to fussed what its doing but if possible would you be able to make it clear the things i need to change to make it work. I also would prefer if you could post something that you are 100% sure works with 1.7.2 so i know that if it doesn't work then its something i have done and that i can fix rather then wondering if its going to just not work no matter how much work i put into it. Or even a link to a tutorial that is 100% guaranteed to work with 1.7.2 as i cant be bothered to watch a Youtube video that was made for 1.6.2 and they have just changed the tital and it not work with 1.7.2 and i waste a whole lot of time (happened 3 times so far).

    I would love to be able to post up my first plugin so if you could post something that you would not mind me posting up as a first plugin. Im going to be starting a java course in 6 months but i want to be able to go in there with some basic knowledge of what im doing so i don't look to stupid trying to work out basic things. I will also post in a reply the current plugin i tried to copy to see if any one can help with correcting it.


    If this is the wrong place sorry, could you link me to the write place cause i haven't ever asked for help with a plugin so i don't know where to post or to even start.

    Kind regards to all!

    package hub.modzmarvin.plugin;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;

    public class Commands implements CommandExecutor{
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    if(commandLabel.equalsIgnoreCase("ping")){
    if(args.length == 0){
    sender.sendMessage("Pong!");
    return true;
    }else{
    sender.sendMessage("Pong!");
    return true;
    }
    }else if(commandLabel.equalsIgnoreCase("pong")){
    if(args.length == 0){
    Bukkit.getServer().broadcastMessage(ChatColor.YELLOW + "I heard "+sender.getName()+" likes cute Asian boys!");
    return true;
    }else{
    Bukkit.getServer().broadcastMessage(ChatColor.YELLOW + "I heard "+sender.getName()+" likes cute Asian boys!");
    return true;
    }
    }
    return true;

    }
    }







    Package: hub.modzmarvin.plugin
    Class name: Commands





    Error respose from console:

    [13:55:44 ERROR]: Could not load 'plugins\modzmarvin.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `hub.modzmarvin
    .plugin'
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav
    a:42) ~[1.7.2.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:133) ~[1.7.2.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:313) ~[1.7.2.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:236) [1.7.2.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugins(CraftServer.ja
    va:350) [1.7.2.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.<init>(CraftServer.java:31
    2) [1.7.2.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.PlayerList.<init>(PlayerList.java:63) [1
    .7.2.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.DedicatedPlayerList.<init>(SourceFile:14
    ) [1.7.2.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.DedicatedServer.init(DedicatedServer.jav
    a:126) [1.7.2.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :424) [1.7.2.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [1.7.2.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    Caused by: java.lang.ClassNotFoundException: hub.modzmarvin.plugin
    at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.7.0_51]
    at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.7.0_51]
    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_
    51]
    at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.7.0_51]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:77) ~[1.7.2.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:62) ~[1.7.2.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_51]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_51]
    at java.lang.Class.forName0(Native Method) ~[?:1.7.0_51]
    at java.lang.Class.forName(Unknown Source) ~[?:1.7.0_51]
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav
    a:40) ~[1.7.2.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    ... 10 more

    copied from :

    http://www.curse.com/bukkit-plugins/minecraft/pingpong



    I will also give FULL credit to who ever helps and any time i use that source to create something else!


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  2. Offline

    tomudding

    The errors, is saying your mainclass "hub.modzmarvin.plugin" could not be found, because that is the package name, not the main class who extends JavaPlugin
     
  3. Offline

    marvinpenn

    tomudding So would i change it to say this "hub.modzmarvin.plugin.commands" or would i change that to just the class name? so "commands".


    So exsample

    Main class: test.plugin.one
    class: class1

    I would change it to just class1 or would i need to have the main class too? Sorry little confused

    p.s thank you for helping :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  4. Offline

    Garris0n

  5. Offline

    marvinpenn

    Thats very useful! that will be bookmarked. I wanted to find out how to play a minecraft sounds within minecraft and that just explained how to do it! thanks dude!

    http://dev.bukkit.org/bukkit-plugins/modzfirstplugin/


    Thank you all! Made my first plugin! Put a thanks to you both :p

    Garris0n
    @tomudding

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  6. marvinpenn I advise you to learn the language (Java) before trying to mess with the Bukkit API. I studied the language a little then started messing with the API over time and started to learn it easy.
     
  7. Offline

    ChromeHD__

    marvinpenn sorry to ruin this moment but they won't approve your plugin because it has little to no detail
     
    tylerthecreeper1 likes this.
  8. marvinpenn He is right, you should add more detail to the post. Maybe add something "worth downloading", like another command for example, /modz who is the best new dev, and the output can be "Marvin!" in gold.

    Just an idea ;)
     
  9. Offline

    marvinpenn

    @tylerthecreeper1 You achualy make a very good point. as i sit here im thinking that i still dont quite understand formats, case sensative (this is driveing me INSAIN!) and understanding the language its self lol...

    @ChromeHD_ I was achualy just wondering why it wasnt going to get approved XD its all good i will leave this one for the fact im trying something a bit diffrent!.

    @tylerthecreeper1

    Agreed, it was a bit uselss XD. Im half way through trying to add a config cause im going to try something i feel might be useful! I will post up when iv done it. i dont want to say what it is yet just for the fact if it dosent work then i can make something else and not seem like i couldnt get it :p
     
  10. marvinpenn mine hasn't even been approved yet from 2 days ago. I have detail in the post, it's working, and it's a fun useful plugin.
     
  11. Offline

    marvinpenn

    @tylerthecreeper1 oh so its not just that it wont. it just might not. I wouldn't be surprised if it didn't lol its not very good but i have made a new one and its much much better lol

    Il add much more detail and post when its up to see what you think :)

    @tylerthecreeper1
    @ChromeHD_
    @tylerthecreeper1

    What do you think about this?
    More info and A bit more useful.



    http://dev.bukkit.org/bukkit-plugins/showme_info/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  12. marvinpenn If you send me the file via a mediafire link, I will download it, and try it out
     
  13. Offline

    marvinpenn

    @tylerthecreeper1
    <Edit by Moderator: Redacted mediafire url>


    Commands: /showme motd /showme staff /showme rules
    Responses defined in config.yml

    Thanks for trying it out :D

    one question, when i want to edit something i cant work out why it wont change on the plugin.

    basically im wanting to edit the config.yml to say only edit the text and im puting it with # at the start. when i compile again and replace nothing changes. too when i change the command till i put it in a new project. to make big changes do you need to start a new project or am i missing something?

    :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 3, 2016
  14. Offline

    Gater12

    marvinpenn

    You can easily just "Tahg" people by hitting the " Tahg" button.
     
  15. marvinpenn I tried it. Could have some improvements though. Add ChatColor.(color) to your messages that come from config, etc..

    Also, console throws errors when you use the commands in console :p
    Add an else statement, and an instanceof Player, so if it is used in console, a message is sent in console..

    marvinpenn you need to recompile the plugin when you make changes to the code..

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  16. Offline

    marvinpenn

    Gater12 i know that :p na i didnt lmao thanks for that XD i hate copying names. its so anoying lmao

    tylerthecreeper1 OOO i can add the colour :D that was one i learnt lastnight!
    I am going to update it ina bout a hour and then put it out as a update :D Iv wanted to add a update :p
    version 1.1 on the way XD!

    Il tahg (why is it tagh XD) you when its done XD

    tylerthecreeper1

    update versions 1.1
    http://dev.bukkit.org/bukkit-plugins/showme_info


    download:
    <Edit by Moderator: Redacted mediafire url>

    Im still having some issues with getting console commands working. I will hopefully have that added by the end of the night :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 3, 2016
  17. marvinpenn I'm reading the post, and every other word is "XD". lol

    marvinpenn What's your code for commands? I can help you with that ;)

    In the section of the post, when you are typing it, (shows B for bold, I for italic, etc) The last 3 should be a picture of code, then quotes, then a puzzle piece, the code one, if you click it, you can paste code into there to organize it better in your posts :p

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  18. Offline

    marvinpenn

    tylerthecreeper1 I know i know, it actually irritates me how much i do XD. i just type it out of reaction (like lol when you just cant stop saying it over nothing) and its driving me mad lol

    tylerthecreeper1 I spent about 10 min thinking "how the hell did they get there code looking awesome" lol. Thanks for that!!!

    Main

    Code:java
    1. package showme.info;
    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.plugin.PluginDescriptionFile;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. public class Main extends JavaPlugin {
    13. public final Logger logger = Logger.getLogger("Minecraft");
    14.  
    15. public void onEnable() {
    16. PluginDescriptionFile pdfFile = this.getDescription();
    17. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " has been enabled!");
    18. getConfig().options().copyDefaults(true);
    19. saveConfig();
    20. }
    21. public void onDisable() {
    22. PluginDescriptionFile pdfFile = this.getDescription();
    23. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " has been disable!d");
    24. }
    25. public boolean onCommand(CommandSender sender, Command cmd,
    26. String commandLabel, String [] args) {
    27. Player player = (Player) sender;
    28. if(args.length == 0) {
    29. player.sendMessage(ChatColor.GOLD +"Commands For " + this.getDescription().getName());
    30. player.sendMessage(ChatColor.GREEN + "/showme ");
    31. } else if(args[0].equalsIgnoreCase("MOTD")) {
    32. player.sendMessage(ChatColor.DARK_GREEN + "MOTD: " + getConfig().getString("MOTD"));
    33. } else if(args[0].equalsIgnoreCase("Rules")) {
    34. player.sendMessage(ChatColor.YELLOW + "The Rules are: ");
    35. } else if(args[0].equalsIgnoreCase("Staff")) {
    36. player.sendMessage(ChatColor.GOLD + " " + getConfig().getString("Staff"));
    37. }
    38. return false;
    39. }
    40. }
    41.  
    42.  


    Plugin.yml:

    Code:
    name: Showme
    main: showme.info.Main
    version: 1.1
    commands:
      showme:
        description: Showme plugin Main Command!
    Config.yml:

    Code:
     
    #Only edit the messages starting with "The" or you will have issues.
    #if you do break this, there is A copy on the plugin dev page.
    MOTD: this is the default MOTD!
    Rules: The Rules are ...
    Staff: The Staff Are Modzmarvin, MrAndyPipkin, LILJAYJAY21
    


    With this i also cant get the message with # at the start to show up in the config. is there a special way to do this?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  19. marvinpenn I'm not too sure about configurations yet, I haven't used them in the plugins I have made :p

    I am reading the code now, so I will be replying again in a sec...
     
  20. Offline

    marvinpenn

    tylerthecreeper1 was going to post what i had for the command but it all went wrong so iv given up re typing it out lol
     
  21. Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd,
    2. String commandLabel, String [] args) {
    3. Player player = (Player) sender;
    4. if( sender instanceof Player);
    5. if(args.length == 0) {
    6. player.sendMessage(ChatColor.GOLD +"Commands For " + this.getDescription().getName());
    7. player.sendMessage(ChatColor.GREEN + "/showme ");
    8. } else if(args[0].equalsIgnoreCase("MOTD")) {
    9. player.sendMessage(ChatColor.DARK_GREEN + "MOTD: " + getConfig().getString("MOTD"));
    10. } else if(args[0].equalsIgnoreCase("Rules")) {
    11. player.sendMessage(ChatColor.YELLOW + "The Rules are: ");
    12. } else if(args[0].equalsIgnoreCase("Staff")) {
    13. player.sendMessage(ChatColor.GOLD + " " + getConfig().getString("Staff"));
    14. }
    15. return false;
    16. else {
    17. sender.sendMessage("You can only run this command as a player!");
    18. }
    19. }
    20.  


    Try that code? Not sure if that's right... timtower how can he make a message go to console when the instanceof isn't a player?

    Also, I'm not too sure on my instanceof, it might not be "sender" before instanceof..
     
  22. Offline

    marvinpenn

    tylerthecreeper1
    The instanceof that i was useing was
    Code:java
    1. if (sender instaceof Player) {
    2. sender.sendMessage("only players can use this command!"};

    i am getting 2 errors. one on the else and one on the } in
    Code:java
    1. else {
    2. sender.sendMessage("You can only run this command as a player!");
    3. }
    4. }


    cant take any away or add any lol

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  23. marvinpenn you spelt instance wrong. you wrote instaceof
     
  24. Offline

    timtower Administrator Administrator Moderator

  25. Offline

    marvinpenn

    tylerthecreeper1

    This is what i have at the moment and still have the error on the two
    Code:java
    1. package showme.info;
    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.plugin.PluginDescriptionFile;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. public class Main extends JavaPlugin {
    13. public final Logger logger = Logger.getLogger("Minecraft");
    14.  
    15. public void onEnable() {
    16. PluginDescriptionFile pdfFile = this.getDescription();
    17. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " has been enabled!");
    18. getConfig().options().copyDefaults(true);
    19. saveConfig();
    20. }
    21. public void onDisable() {
    22. PluginDescriptionFile pdfFile = this.getDescription();
    23. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " has been disable!d");
    24. }
    25. public boolean onCommand(CommandSender sender, Command cmd,
    26. String commandLabel, String [] args) {
    27. Player player = (Player) sender;
    28. if( sender instanceof Player);
    29. if(args.length == 0) {
    30. player.sendMessage(ChatColor.GOLD +"Commands For " + this.getDescription().getName());
    31. player.sendMessage(ChatColor.GREEN + "/showme ");
    32. } else if(args[0].equalsIgnoreCase("MOTD")) {
    33. player.sendMessage(ChatColor.DARK_GREEN + "MOTD: " + getConfig().getString("MOTD"));
    34. } else if(args[0].equalsIgnoreCase("Rules")) {
    35. player.sendMessage(ChatColor.YELLOW + "The Rules are: ");
    36. } else if(args[0].equalsIgnoreCase("Staff")) {
    37. player.sendMessage(ChatColor.GOLD + " " + getConfig().getString("Staff"));
    38. }
    39. return false;
    40. else {
    41. sender.sendMessage("You can only run this command as a player!");
    42. }
    43. }
    44.  


    timtower

    when i check the error i only get "syntax error" and i never know what to do when i get them lol. If it was something like importing or something like that i would be able to work that out lol.
     
  26. Offline

    timtower Administrator Administrator Moderator

    Tip: don't cast to player before you check if it even is one
     
  27. Offline

    marvinpenn

    timtower
    i thought thats what this did?
    Code:java
    1. Player player = (Player) sender;


    i cant seem to work out how to check if a player is a player lol. What would i start that off with?
     
  28. Offline

    timtower Administrator Administrator Moderator

    marvinpenn marvinpenn That is the casting itself, you need to check if it is a player before you do that
    Code:java
    1. if(sender instanceof Player){
    2. Player player = ( Player)sender;
    3. //player stuff here
    4. }else{
    5. //console stuff here
    6. }
     
  29. Offline

    marvinpenn

    timtower okay i kinda went a bit crazy on that one.

    I couldnt work out how to check if the player is a player so i have it checking if the player is online. Im not 100% sure if this would work or what. i think i have just jumped like 2 weeks ahead of my knolege lmao

    Code:java
    1. package showme.info;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.plugin.PluginDescriptionFile;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13. public class Main extends JavaPlugin {
    14. public final Logger logger = Logger.getLogger("Minecraft");
    15.  
    16. public void onEnable() {
    17. PluginDescriptionFile pdfFile = this.getDescription();
    18. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " has been enabled!");
    19. getConfig().options().copyDefaults(true);
    20. saveConfig();
    21. }
    22. public void onDisable() {
    23. PluginDescriptionFile pdfFile = this.getDescription();
    24. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " has been disable!d");
    25. }
    26. public boolean onCommand(CommandSender sender, Command cmd,
    27. String commandLabel, String [] args) {
    28.  
    29. if( sender instanceof Player);
    30. Player player = Bukkit.getPlayerExact(args[0]);
    31. if(player == null){
    32.  
    33. sender.sendMessage("The Player Could Not Be Found!");
    34. return true;
    35. }
    36.  
    37.  
    38. sender.sendMessage("You can only run this command as a player!");
    39.  
    40. if(args.length == 0) {
    41. player.sendMessage(ChatColor.GOLD +"Commands For " + this.getDescription().getName());
    42. player.sendMessage(ChatColor.GREEN + "/showme ");
    43. } else if(args[0].equalsIgnoreCase("MOTD")) {
    44. player.sendMessage(ChatColor.DARK_GREEN + "MOTD: " + getConfig().getString("MOTD"));
    45. } else if(args[0].equalsIgnoreCase("Rules")) {
    46. player.sendMessage(ChatColor.YELLOW + "The Rules are: ");
    47. } else if(args[0].equalsIgnoreCase("Staff")) {
    48. player.sendMessage(ChatColor.GOLD + " " + getConfig().getString("Staff"));
    49. }
    50. return false;
    51.  
    52.  
    53.  
    54. }
    55. }
    56.  
    57.  


    no errors but i have just screwed the thing up lol. i now get told on every command that it cant find the player XD

    Im so lost

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  30. Offline

    timtower Administrator Administrator Moderator

    marvinpenn This is how I do this usually:
    Code:java
    1. package showme.info;
    2.  
    3. import java.util.logging.Logger;
    4. import org.bukkit.Bukkit;
    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.plugin.PluginDescriptionFile;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. public class Main extends JavaPlugin {
    13.  
    14. public final Logger logger = Logger.getLogger("Minecraft");
    15. public void onEnable() {
    16. PluginDescriptionFile pdfFile = this.getDescription();
    17. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " has been enabled!");
    18. getConfig().options().copyDefaults(true);
    19. saveConfig();
    20. }
    21. public void onDisable() {
    22. PluginDescriptionFile pdfFile = this.getDescription();
    23. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " has been disable!d");
    24. }
    25. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String [] args) {
    26. if(!(sender instanceof Player)){
    27. //Sender is the console
    28. sender.sendMessage("You can only run this command as a player!");
    29. return true;
    30. }
    31. Player player = (Player) sender;
    32. if(args.length == 0) {
    33. player.sendMessage(ChatColor.GOLD +"Commands For " + this.getDescription().getName());
    34. player.sendMessage(ChatColor.GREEN + "/showme ");
    35. } else if(args[0].equalsIgnoreCase("MOTD")) {
    36. player.sendMessage(ChatColor.DARK_GREEN + "MOTD: " + getConfig().getString("MOTD"));
    37. } else if(args[0].equalsIgnoreCase("Rules")) {
    38. player.sendMessage(ChatColor.YELLOW + "The Rules are: ");
    39. } else if(args[0].equalsIgnoreCase("Staff")) {
    40. player.sendMessage(ChatColor.GOLD + " " + getConfig().getString("Staff"));
    41. }
    42. return false;
    43. }
    44. }
     
Thread Status:
Not open for further replies.

Share This Page