I dunno what to call this xD

Discussion in 'Plugin Development' started by DominicGamesHD, Jan 31, 2016.

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

    DominicGamesHD

    Hello :)
    I am new to developing bukkit plugins and I want to create a cookie clicker plugin I learn from looking at code and I am trying to make it so when you right click sponge it will add one point how can I do this I will give credit if I can't change the code ;) Thanks in advance :D

    P.S I like my emojis xD
     
  2. Offline

    teej107

  3. Offline

    DominicGamesHD

    @teej107 That made no sense to me but I will try thanks :)

    @teej107 If you could provide a example it would be great but its your choice :p

    EDIT by Moderator: merged posts
     
    Last edited by a moderator: Jan 31, 2016
  4. Offline

    DuduFTW

    I made a simple code hope it helps you! If you have questions or not that's what needs to tell me! Sorry google translate :p:D

    Code:
        public static HashMap<Player, Integer> points = new HashMap<>();
      
        @EventHandler
        public void onClick(PlayerInteractEvent e){
            Player p = e.getPlayer();
            if (e.getAction() == Action.RIGHT_CLICK_BLOCK){
                if (p.getItemInHand().getType().equals(Material.COOKIE)){
                    if (e.getClickedBlock().getType().equals(Material.SPONGE)){
                        if (points.containsKey(p)){
                            int points1 = points.get(p);
                            int points2 = points1 + 1;
                            points.put(p, points2);
                            p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
                        }else{
                            points.put(p, 1);
                        }
                    }
                }
            }
        }
     
  5. Offline

    teej107

  6. Offline

    Zombie_Striker

    @DuduFTW
    Thanks Captain Spoonfeeder! Not only does your code have bad practices, but will also create a ton of problems and errors later on!
     
    sam_0208, ChipDev and MarinD99 like this.
  7. Offline

    DominicGamesHD

    @DuduFTW Thanks for the help I will change the code around :p
     
  8. Offline

    JoaoBM

    @DominicGamesHD You shouldn't copy code from others as you won't learn anything from there.

    @teej107 already gave you the steps to do this. If you don't understand them:
    1. You don't know Java - Learn it
    2. You know Java but don't know how to mess with Bukkit - Look at http://wiki.bukkit.org/Plugin_Tutorial and https://jd.bukkit.org/|JavaDocs
    Any question you may have Google it. Still can't find the answer? That's why this Forum is for. Just don't copy code.
     
    ChipDev likes this.
  9. Offline

    DominicGamesHD

    @JoaoBM I am not copying it I am looking at it and changing it around :)

    @JoaoBM I am not copying it I am looking at it and changing it around :)

    P.s: Everyone learns diffrently
     
    Last edited by a moderator: Feb 1, 2016
  10. Offline

    JoaoBM

    @DominicGamesHD Yes everyone learns in different ways. I just mentioned copying is a bad practice. Don't forget to check JavaDocs, will help you :p
     
  11. Offline

    DominicGamesHD

    @JoaoBM Thanks for the tips sorry if I was a bit bi***y but I do appreciate it
     
  12. Offline

    JoaoBM

Thread Status:
Not open for further replies.

Share This Page