Weird stuff happening?

Discussion in 'Plugin Development' started by lcpvp, Mar 28, 2013.

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

    lcpvp

    I am not sure what is wrong, but when a player does /bank it says you You need 15 cookies to buy this! To earn cookies, go get some kills!
    When I kill a mooshroom cow, it doesn't put 2 cookies in my bank.
    Whats wrong with this?
    Code:java
    1.  
    2. public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
    3. {
    4. Player player = (Player) sender;
    5. if(commandLabel.equalsIgnoreCase("help")){
    6. player.sendMessage(ChatColor.GRAY + "-----" + ChatColor.GOLD + "GGKits Help" + ChatColor.GRAY + "-----");
    7. player.sendMessage(ChatColor.GRAY + "/sharp " + ChatColor.GREEN + "Sharpens your sword for 20 cookies." );
    8. player.sendMessage(ChatColor.GRAY + "/spawn " + ChatColor.GREEN + "Teleports you to spawn." );
    9. player.sendMessage(ChatColor.GRAY + "/shop " + ChatColor.GREEN + "Shop help." );
    10. player.sendMessage(ChatColor.GRAY + "/bank " + ChatColor.GREEN + "Your bank." );
    11. }
    12. if(commandLabel.equalsIgnoreCase("bank")){
    13. player.openInventory(player.getEnderChest());
    14. }
    15. if(commandLabel.equalsIgnoreCase("Shop"))
    16. {
    17. if(args.length == 0){
    18. player.sendMessage(ChatColor.GRAY + "-----" + ChatColor.GOLD + "Shop Help" + ChatColor.GRAY + "-----");
    19. player.sendMessage(ChatColor.GRAY + "/sharp" + ChatColor.GREEN + "Sharpens your sword, costs 15 cookies. ");
    20. player.sendMessage(ChatColor.GRAY + "/diamond" + ChatColor.GREEN + "Gives diamond armor, costs 50 cookies.");
    21. }
    22.  
    23. }
    24. if(commandLabel.equalsIgnoreCase("Sharp"))
    25. {
    26. Map<Enchantment, Integer> Enchants = player.getInventory().getItemInHand().getEnchantments();
    27. Integer level = Enchants.get(Enchantment.DAMAGE_ALL);
    28. if(player.getItemInHand().getType() == Material.DIAMOND_SWORD){
    29. if(player.getEnderChest().contains(Material.COOKIE, 15));
    30. if(player.getItemInHand().containsEnchantment(Enchantment.DAMAGE_ALL)){
    31. if(level == 1){
    32. player.getItemInHand().addEnchantment(Enchantment.DAMAGE_ALL, 2);
    33. }else if(level == 2){
    34. player.getItemInHand().addEnchantment(Enchantment.DAMAGE_ALL, 3);
    35. }else if (level == 0){
    36. player.getItemInHand().addEnchantment(Enchantment.DAMAGE_ALL, 1);
    37. }else{
    38. player.sendMessage(ChatColor.GOLD + "This Sword Has Maximized Its Enchantments!");
    39. }
    40. }
    41. }else{
    42. player.sendMessage(ChatColor.GOLD + "Please Hold A Diamond Sword");
    43. }
    44. }else{
    45. player.sendMessage(ChatColor.GOLD + "You need 15 cookies to buy this! To earn cookies, go get some kills!");
    46.  
    47. }
    48.  
     
  2. Offline

    Compressions

    lcpvp Where is your mooshroom kill event?
     
  3. Offline

    dillyg10

    WHERE
    ARE
    THE
    COOOOOKKIES
    O___O
     
  4. Offline

    lcpvp

    Code:java
    1.  
    2. @EventHandler
    3. public void onDeath(PlayerDeathEvent event) {
    4. Player killer = event.getEntity().getKiller();
    5. Player dead = event.getEntity();
    6. if(dead instanceof MushroomCow){
    7. killer.getEnderChest().addItem(new ItemStack(Material.COOKIE, 2));
    8. event.getDrops().clear();
    9. event.getDrops().add(new ItemStack(Material.MUSHROOM_SOUP, 1));
    10. event.getDrops().add(new ItemStack(Material.MUSHROOM_SOUP, 1));
    11. event.getDrops().add(new ItemStack(Material.MUSHROOM_SOUP, 1));
    12. event.getDrops().add(new ItemStack(Material.MUSHROOM_SOUP, 1));
    13. }
    14. }
    15.  
    16.  
     
  5. Offline

    chasechocolate

    lcpvp event.getEntity() will return the player who died, event.getEntity().getKiller() will also return the player who got killed afaik, but it may be null. So you flipped your variable names.
     
  6. Offline

    lcpvp

    Wait, so killer should be
    event.getEntity();
    and Dead should be
    event.getEntity().getKiller();?
     
  7. Offline

    chasechocolate

  8. Offline

    lcpvp

    Thats what I have right now though?

    Can you reply to my pm?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
Thread Status:
Not open for further replies.

Share This Page