[Tutorial] How To Use Enum Class!

Discussion in 'Resources' started by TheUpdater, Dec 27, 2013.

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

    TheUpdater

    ok welcome to this tutorial its going to be fast!
    ever wanted to make something like this that allows you to make custom names for
    your metods when add stuff to player/mobs/all other thing in ---> minecraft
    PHP:
    getit.setCustomPotion(playerCp,SUPERMANtimestrongness);
    for ex:
    getit = the class name of enum
    setCustomPotion = the method that you created in the enum class called getit , this can be changed to anything so does the class just press f2 on class to rename it , or just change method name ;)
    player = the player that will get the custompotion
    cp.SUPERMAN = the custom potion, the cp can be changed so does the SUPERMAN
    time = the time that the potion will last on player
    strongness = how fast you gona run with speed potion for ex: here it is just so you need and int

    an int is a number so you guys know <---

    well this is the tutorial for you so we can start by create a new Enum class called what ever you want but it will be the key word to get the option, for it in this case, i will call the class get
    it will look like this
    Code:
    package YOURPACK;
     
    public enum get {
        //ADD CUSTOMPOTION
    }
    
    the YOURPACK = is the main package for you class
    ADD CUSTOMPOTION = just add words for your potions

    ok when that's done lets add some words that we can use to get the custom potion effect

    PHP:
    public enum get {
        
    //ADD CUSTOM
        
    ONE,
        
    TWO,
        
    END,
        
    SUPER,
    }
    now we added; one , two, end, and super
    this are the names of the custompotions

    now under that create how you want to get the custom names in to a method where we call
    the custom potion and its settings

    PHP:
        static get CO get.ONE;
     
        public static 
    void setspell(final Player pget Getir){
            switch(
    Getir){
            case 
    ONE:
                break;
            case 
    TWO:
                break;
            case 
    END:
                break;
            case 
    SUPER:
                break;
            }
        }
    this will be like this
    PHP:
    get.setspeel(playerget.ONE);
    so it will give the player that you selected the effect ONE

    now when you do
    PHP:
    get.setspell(playerget.ONE)
    it will set it to one, now you can change what 1 will do for ex:


    Code:
            case ONE:
    p.sendmessage("you was sent 1");
                break;
    this means if do
    PHP:
    get.setspell(playerget.ONE)
    it will send player the message "you was sent 1"
     
  2. Offline

    DrJava

    There are many grammar and spelling errors in this. Also, this is not set out very neatly. When creating a thread in resources, please try to use correct grammar/spellings and also set it out nicely.
     
    Garris0n likes this.
  3. Offline

    xTrollxDudex

    TheUpdater
    You don't even have proper conventions, and this is not the place to post java tutorials. This is just to show off code, not a proper resource.
     
    Cirno, Garris0n, iZanax and 1 other person like this.
  4. Offline

    TheUpdater

    this might help pp
     
  5. Offline

    Jogy34

    If people want to look at a strictly java tutorial, then they should go to the oracle website or somewhere dedicated to java. Stuff here should really have something to do with bukkit.
     
  6. Offline

    Jake0oo0

    Considering I can barely understand it, it didn't help me.
     
    Cirno, Garris0n, Chinwe and 1 other person like this.
  7. Offline

    Ultimate_n00b

    You are both wrong, Java tutorials are in fact allowed here.
     
  8. Offline

    Jogy34

    Yes they're allowed here, but they should still have something to do with bukkit considering we're in the Resources sub-section, of the Plugin Development section, of the Bukkit forums.
     
  9. Offline

    Ultimate_n00b

    Code:
    getit.setCustomPotion(player, Cp,SUPERMAN, time, strongness);
    Seems to me he's using this as an example of something we can do in bukkit.
     
  10. Offline

    Jogy34

    I'd like to see you use that line of code in one of your plugins using his explanation of it.
     
    Garris0n and ZeusAllMighty11 like this.
  11. Offline

    xTrollxDudex

    Ultimate_n00b
    The posting of Java turorials aren't moderated, but discouraged. It depends on the definition of "not allowed". There are things that are less loosely bound to a certain rule than others, if you understand.
     
  12. Offline

    TheUpdater

    well you dont know how to make stuff easy in plugins? for ex if i want to add item to inv make it unclickable
    and give you something and remove money i can use this to get that to work bu adding all i need and btw this is used in my wip project Mcc


    so i dont need to make like 500 extra lines of code to get that to work

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

    BungeeTheCookie

    Before you even start to code, why don't you clean up your grammar, capitalization, and make this a little more detailed. This is not Kik (if you don't know what I am talking about, Google it); we are a professional community and we expect decent material from these resources.
     
    AoH_Ruthless likes this.
  14. Offline

    Ivan

    Not really... xD
    Most of us just code java as a hobby. You can't really get professional with developing plugins.
     
  15. Offline

    BungeeTheCookie

    In the resources section, we try to be as professional as possible.
     
  16. Offline

    Jogy34

    Getting paid isn't the only definition of professional (more specifically look at the world English dictionary part, points 3, 7, and 8)

    (I'm assuming you meant to quote me there since he was defending you)

    As to not knowing how to make stuff easy, feel free to look through some of my code.

    And my point to you is that you made a Java tutorial which in my opinion shouldn't be posted here since this is the bukkit forums in a section related to bukkit (e.g. not the off-topic section). Something like this can easily be looked up from a quick google search which will find much much (not trying to offend you here) better documentation, explanations, and examples.

    My point to Ultimate_n00b (not going to tag him as it applies to you more than him) was that yes, you threw in bits of bukkit API references but you never bothered explaining them in the least bit. For instance, that line of code:
    Code:java
    1. getit.setCustomPotion(player, Cp,SUPERMAN, time, strongness);

    I have not idea what 'getit' is.
    I have not idea what the 'setCustomPotion()' method is.
    I can assume that 'player' is a player but what significance does that have to the method.
    I have not idea what 'Cp' is.
    I have not idea what 'SUPERMAN' is.
    'time' is what? Ticks, Seconds, Minutes, etc...
    'strongness'? I don't even know what that means.

    Even from your own way of phrasing things, it doesn't even seem like you know what's going on.
    By Java convention, the class name should be capitalized. And that comment doesn't make any sense to me, why does an enum have to be a custom potion? What does the class name 'get' even have to do with custom potions?

    This part just annoys me (as in it isn't all that big of a deal). words? 'lets add some words'? They're constants. They are static Enumeration constants. They are basically variables that don't change. Calling them 'words' makes them sound like they are part of a String.


    I'm not trying to hurt your feeling though I fear that I did as I've hurt other people's feeling for far far less. I was trying to express mainly that I don't think a tutorial like this should belong here and secondly that it isn't a very good tutorial to begin with along with there being better ways to find out this information. I usually don't get involved in these but I've seen quite a few of them lately and it ends up being a nuisance to see this sub-section littered with poorly written tutorials and/or ones that shouldn't be here in the first place.
     
  17. Offline

    Ivan

    Jogy34
    Well I wasn't really referring to the getting paid aspect since I get paid for making plugins. I'm more referring to the pressure, deadlines and the eye for perfectionism.
     
  18. Offline

    BungeeTheCookie

    We all agree this needs to be improved (alot more)
     
  19. Offline

    TheUpdater

    well... ok ama improve it -.-

    is it better?????

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

    BungeeTheCookie

    How about using capatalizion, correct punctuation, and grammar and we will see if it is better.
     
  21. Offline

    Garris0n

    Cirno, Chinwe and DrJava like this.
Thread Status:
Not open for further replies.

Share This Page