Newbie asking questions!

Discussion in 'Spigot Plugin Development' started by Deger, May 28, 2016.

  1. Hello as you guys/girls understand from my desc, i need to sort some stuff out!

    Firstly if f i created the thread on the wrong forum, please move me to the right tab!

    Secondly my questions is:

    Can someone give some easy and understandable explanation for a noob that started to try to program with java, and when i cleared that out of the way......

    I wanna know when and "how to use it" when you do: Location <name> = new Location();
    Can someone explain what the "new" does, and why you would want to import a class! Give as many exampled as you can!!!

    Second is:
    Location <name> = Bukkit.getServer().getWorld();
    Why and when do you wanna use it?! Examples please:D
    I understand a bit what it does, it uses "<name>" and when i use "<name>" it does exactly the same as if Bukkit.getServer()........... would do!

    I really need help to understand those and:
    public Permission playerPerm = new Permission("playerAbilities.allow");
    Permission playerPerm = new Permission("playerAbilities.allow");

    When would i want to use a public/private ................ = ...............
    What is the public perm.........
    Explain for me!! When do you wanna use public ..... ..... =

    Without the public it is something you import!!
    But why would i want to do a public and not public void/boolean?
    What does the word public mean excepts it is a public for all
    Why are we only setting public and nothing more?


    I do not understand the return things! I know void is non return but i never know when i wanna use a void!
    I now boolean returns either true or false, but i do not know what the return true/false does?!

    You can make a int x = 5 and int y = 5 and return x + y; But i really don't know what it mean!!!!

    Code (Text):
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

            if (label.equalsIgnoreCase("giveitems") && sender instanceof Player) {

                Player p = (Player) sender;

                if (p.hasPermission("playerAbilities.allow")) {
                    p.setItemInHand(new ItemStack(Material.DIAMOND_AXE));
                }
            }
            return true;
        }


    This code is a command thing, but what would happend if i set return to false, and what does the return true mean........

    If you can clear this up for me i would owe you big time!!!
    I have watched tutorials but they always forget to mention what does things mean, they are mentioning the easy parts but not what what a public import does!!!

    Thanks!!
     
  2. This is all simple Java/OOP. Google it.

    "Java public, private, protected"
    [​IMG]
    https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html

    I answered a similar question earlier:
     
    • Agree Agree x 1
  3. You're asking for a fair amount of information, and unfortunately Java isn't just made of the things you asked so you're gonna constantly be asking what things do.

    I would learn Java before trying to program plugins, you're gonna be at a very big disadvantage if you don't.
     
    • Agree Agree x 1
  4. I am watching new boston etc, but i also watched a plugin tut, and thats why i wanna know... so i can understand and then work from that!!

    Something i never have understood is when to use a void/boolean or just "public" classname ..... = new classname;
    That is my number one thing!!! Thanks!
    Im also thanking Cewlt for his answer!!
     
  5. 4chan

    Supporter

    Always learn how to make an API before you try to implement someone else's. Then you know what you're doing, maybe.
     
  6. As many in this thread have said: "Learn Java first".
    Trust us when we say this, it will save you a lot of time and effort.
    Continue with your studies, and try some of these examples I found here: link. You aren't going to become a good programmer without practice; doing lots of projects is one of the best ways to learn. Understand syntax, polymorphism, objects, memory, etc. Minecraft and Spigot were built using those fundamentals, you can't expect to manipulate something effectively when you don't understand how it works.

    Best of luck, and keep at it! ;)
     
  7. Please learn Java. It's not very hard to do, watch a few online videos, practice a little, THEN start getting into plugin development where you can apply the skills you learned and learn more. It's not going to be easy to do whatever is you're trying to do if you don't know anything about programming.