PvpLevels Api tutorial [v0.2.2]

Discussion in 'Resources' started by lenis0012, Dec 22, 2012.

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

    lenis0012

    Hello everyone,
    my name is lenis0012 and i am the devlopper of the plugin PvpLevels.

    And i am here to show you how to use my plugin to modify it using your own plugin.

    let me first explain how it works,

    First of all you need to make sure you have the latest PvpLevels jar added as libary (the same way as you did with the bukkit.jar)

    now, this plugin creates a new class binded to a player to modify its pvp level/amount of kills
    this how to check a players level once he logs in:
    Code:
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event)
    {
        Player player = event.getPlayer();
        PvpPlayer pp = new PvpPlayer(player);
        int lvl = pp.getLevel();
        player.sendMessage(ChatColor.GREEN+"You got level "+String.valueOf(lvl));
    }
    was that really hard??

    now to make someone get 1 more level when they right click a button for ex.

    Code:
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event)
    {
        if(event.getAction() != Action.RIGHT_CLICK_BLOCK)
            return;
     
        Player player = event.getPlayer();
        Block block = event.getClickedBlock();
        if(block.getType() == Material.BUTTON)
        {
            PvpPlayer pp = new PvpPlayer(player);
            int lvl = pp.getLevel();
            pp.setLevel(lvl + 1);
            player.sendMessage(ChatColor.GREEN+"You are now lvl "+String.valueOf(lvl + 1));
        }
    }
    so to get the player as a PvpPlayer all you have to do is:
    PvpPlayer pp = new PvpPlayer(player);

    and then you can use it.
    Check BukkitDev for source code and download

    Updated for PvpLevels v0.2.1

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

    Sushi

    3 things:
    1. Grammar
    2. JavaDocs
    3. IDE-agnostic
     
  3. Offline

    lenis0012

    1. where?
    2. no need to
    3. maybe
     
  4. Offline

    Sushi

    1. Capitalization, sentences, paragraphs, homonyms.
    2. It's nonstandard if you don't
     
  5. Offline

    lenis0012

    The api is not the main part of the plugin
     
  6. Offline

    Sushi

    How does that have anything to do with anything?
     
    L33m4n123, user_43347 and chaseoes like this.
  7. Offline

    lenis0012

    Updated api to v0.2.2
     
  8. Offline

    CeramicTitan Retired Staff

    OOO i have a really cool idea for a plugin that hooks into this.
     
  9. Offline

    lenis0012

    nice :)
     
  10. Offline

    CeramicTitan Retired Staff

    I'll start on it either later, or tomorrow.
     
  11. Offline

    TnT Retired Staff

    Moved to Resources.
     
    lenis0012 and hawkfalcon like this.
  12. Offline

    lenis0012

    shiny :p
     
  13. Offline

    Bikespot

    Is there a way i can change the chat text [Lvl] to say [Kills]
     
  14. Offline

    lenis0012

    cusotm chat format

    example (ChatManager):
    chat-format: '[Kills [Lvl]] %prefix%displayname: %message'
     
  15. Offline

    Garris0n

    I fixed most of the grammar/spelling, not sure if I got everything.
     
  16. Offline

    lenis0012

    Im sorry for all my spelling, i am not english and i type faster than my fingers can handle sometimes :p
     
  17. Offline

    Garris0n

    It's no problem, I just fixed it up because I was bored in school :p You've accomplished more than I have as far as learning languages anyway :)
     
  18. Offline

    MTN

    Javadocs are mandatory for APIs, that is what they are made for
     
    Goblom likes this.
  19. Offline

    lenis0012

    Its just 1 class, you can easily use eclipse to see all possible functions.
    And if thats nto enough you can look it up at github

    I know that its common for api's to have it but this is a little side project, not a massive plugin made for people to depend on.
     
  20. Offline

    Goblom

    lenis0012 Even so, i have a small resources repo on github (link) and i tend to document everything (and when i don't i usually do it later when im done writing the class) because doing so explains what each thing does without having to actually look at the code of a single method. Its simple, easy to do and efficient. Without JavaDocs expect people to ask many questions about how to use your API and also expect people to not use your API as much as compared to making their own (I know i would choose to create my own if i was given the option between my own api vs yours)
     
  21. Offline

    lenis0012

Thread Status:
Not open for further replies.

Share This Page