How Do I Learn How To Make A Plugin Like Essentials

Discussion in 'Plugin Development' started by iron768, Nov 26, 2014.

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

    iron768

    Hi! I would like to learn how to code a plugin like essentials. I did look up the source code for essentials and... it was really confusing! i have one of three .java files done. The 3 sections are Main,ChatColor and Warps. The one i got done is joining and leaving which changes the way leaving and joining looks. Thanks :D
    ~ iron768
     
  2. Offline

    Skionz

    iron768 I feel like essentials wouldn't be that hard to recreate but it has so many different features. What exactly do you need help with?
     
  3. Offline

    iron768

    I want to know how to teach my self how to code. My friend taught himself java and he is fluent in java. Thanks!
    :D
     
  4. Offline

    Skionz

  5. Offline

    iron768

    Thanks! I will buy it tonight!
    @Skionz
     
    Skionz likes this.
  6. Offline

    DivinanceMC

    What kinds of things are you looking to do? I may be able to help you out.
     
  7. Offline

    iron768

    I want to learn how to code commands. I have only got to do a plugin where it edits the leave & join message.
    Thanks!
     
  8. Offline

    Spinalvine89

  9. Offline

    DivinanceMC


    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {

    Code:java
    1. if (cmd.getName().equalsIgnoreCase("command")) {
     
  10. Offline

    iron768

    Thanks but order?
     
  11. Offline

    HeadGam3z

    DivinanceMC
    e_e...

    You could try checking out BukkitWiki's command tutorial if you want. There is some useful information in there!
     
  12. Offline

    Slikey

    You are unterestimating the work that went into Essentials. It is a high-performant and lightwight using plugin.
    Pro Tip: Do not look at Essentials if you have no proper experience with Java. It has some technics used, that challenge senior Java developers too.
     
    Skionz likes this.
  13. Offline

    iron768

    @Slikey Sadly i learned the hard way :c but yes i do realise it took a LONG time to make essentials but i want to make a simpler and easier version of essentials for my Prison server. (Also im only going to add stuff i need to the plugin )

    can someone send me a kick command? i will base everything off of that
     
  14. Offline

    DivinanceMC


    Code:java
    1. package DivinanceMC.MelonCore;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandExecutor;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9.  
    10. public class Kick implements CommandExecutor {
    11.  
    12. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    13.  
    14. if (!(sender instanceof Player)) {
    15. sender.sendMessage(MelonCore.Prefix + "This command is disabled for " + ChatColor.YELLOW + "Console" + ChatColor.GRAY + ".");
    16. return true;
    17. }
    18.  
    19. Player player = (Player) sender;
    20.  
    21. if (cmd.getName().equalsIgnoreCase("kick")) {
    22. if (! sender.hasPermission("meloncore.kick")) {
    23. sender.sendMessage(MelonCore.Prefix + "You don't have permission to use this command.");
    24. return true;
    25. }
    26.  
    27. if (args.length == 0) {
    28. player.sendMessage(MelonCore.Prefix + "You've provided incorrect arguments. Use " + ChatColor.YELLOW + "/kick [player] [reason]" + ChatColor.GRAY + ".");
    29. return true;
    30. }
    31.  
    32. Player target = Bukkit.getServer().getPlayer(args[0]);
    33. if (target == null) {
    34. player.sendMessage(MelonCore.Prefix + ChatColor.YELLOW + args[0] + ChatColor.GRAY + " is not online.");
    35. return true;
    36. }
    37.  
    38. if(args.length == 1){
    39. Player target1 = Bukkit.getServer().getPlayer(args[0]);
    40. target.kickPlayer(MelonCore.Prefix + "You have been kicked by " + ChatColor.YELLOW + sender.getName() + ChatColor.GRAY + "." + ChatColor.GRAY + "\n\nReason: " + ChatColor.YELLOW + "-");
    41. Bukkit.getServer().broadcastMessage(MelonCore.Prefix + ChatColor.YELLOW + sender.getName() + ChatColor.GRAY + " »" + ChatColor.GOLD + " Kick" + ChatColor.GRAY + " » " + ChatColor.YELLOW + target1.getName() + ChatColor.GRAY + " » " + ChatColor.YELLOW + "-");
    42. return true;
    43. }
    44.  
    45. String msg = "";
    46.  
    47. for (int i = 1; i < args.length; i++) {
    48. msg = msg + args[i] + " ";
    49. }
    50.  
    51. if(args.length > 1){
    52. Player target2 = Bukkit.getServer().getPlayer(args[0]);
    53. target2.kickPlayer(MelonCore.Prefix + "You have been kicked by " + ChatColor.YELLOW + sender.getName() + ChatColor.GRAY + "." + ChatColor.GRAY + "\n\nReason: " + ChatColor.YELLOW + msg);
    54. Bukkit.getServer().broadcastMessage(MelonCore.Prefix + ChatColor.YELLOW + sender.getName() + ChatColor.GRAY + " »" + ChatColor.GOLD + " Kick" + ChatColor.GRAY + " » " + ChatColor.YELLOW + target2.getName() + ChatColor.GRAY + " » " + ChatColor.YELLOW + msg);
    55. return true;
    56. }
    57. }
    58. return false;
    59. }
    60.  
    61. }[/i]
     
  15. Offline

    Skionz

    Slikey I have never looked at essentials source so I wouldn't know.
    DivinanceMC Its a bad idea to spoon-feed people as they will learn nothing from it.
     
  16. Offline

    iron768

    @Skionz like i said im going to base literally everything off that except change it when nesscery
     
  17. Offline

    Spinalvine89

    Like I said before I highly suggest looking into learning Java beforehand, or else you will have little understanding on what exactly you are doing, and likely be back here every 5 minutes to ask about something else.
     
  18. Offline

    iron768

    Spinalvine89 into learning Java beforehand, or else you will have little understanding on what exactly you are doing, and likely be back here every 5 minutes to ask about something else.[/quote] i believe i have some basic knowladge. i did make a plugin.

    thanks i will watch :D
     
  19. Offline

    mythbusterma

    Juancomaster1998

    And....there goes the thread.

    Skionz Slikey

    Yes, advanced Java concept that senior developers struggle with....like catching Exception. Essentials is terribly written, I wouldn't try to learn from that.
     
    rbrick, adventuretc and SuperOriginal like this.
  20. Offline

    iron768

  21. Offline

    mythbusterma

    iron768

    I wouldn't say learning from plugins is a good way to learn at all. Reverse engineering is difficult and an imprecise science, plus you'll pick up any bad habits that the creator of the plugin has.

    Learning Java from Oracle (or a book) and following the Bukkit plugin tutorial is really the best option.
     
  22. Offline

    iron768

    :/ ok im going to try really hard it will be hard but i dont care@mythbusterma
     
  23. Offline

    Asecta

    Uhm... Isn't the obvious solution to ask your friend who you say is fluent in Java?
     
  24. Offline

    mythbusterma

    iron768

    My point about difficulty not being about actual difficulty to do (which it isn't easy), but a very through understanding of the language is required to be able to reverse engineer someone's code, which is the truly difficult part.

    But, if you insist on learning by reading someone else's source code, I'd pry have to recommend some of mbaxter 's plugins.

    Also, this:

     
  25. Offline

    fireblast709

    mythbusterma gotta catch 'em all.
    DivinanceMC you shouldn't discriminate against the console like that. Also, use StringBuilders instead of concatenation :p.
     
  26. Offline

    iron768

    Lol my friend is DivinanceMC and he really wont help me :c i ask him all the time but still :C

    I will try to watch tutorials and mess around in eclipse tomorrow mourning. That should help right?
     
  27. Offline

    Etched

    Check out thenewboston's youtube channel for java tutoials, they're great. After that just mess around and you will get better and better: www.youtube.com/thenewboston
     
  28. Offline

    xize

    I would actually recommend to make a simple plugin first or a few.

    because a essentials plugin could end up to be very big and complicated which means if you are a beginner you will have to rewrite it many times atleast thats what I did because there are many things to look to such as performance, possible memory leaks, or just the model how it is implemented.

    now lets say I would upload it to bukkit from the start then there could be a chance to many people start requesting features while actually you may got a bit more better in java over time and start rewriting everything which mean you could get a bit stressy.

    Ive rewrited mine for the 5th time, and still I think there need more changes and or safety:p
     
  29. Offline

    Tecno_Wizard

    iron768, do you have the oppertunity to take a Java course in an eductational setting (if you are still in high school or college)? That is how I learned, but i must say that I'm actually better than my teacher now. The man's not too intelligent...
     
Thread Status:
Not open for further replies.

Share This Page