Advertisement
SmiDmi

MentorGuide

Jun 30th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.      * Verifies if player is mentee and if his current level should reward his mentor and if so sends a mail with reward.
  3.      * @param player
  4.      */
  5.     private void checkLevelForReward(PlayerInstance player)
  6.     {
  7.         if (!MENTEE_COINS.containsKey(player.getLevel()))
  8.         {
  9.             return;
  10.         }
  11.        
  12.         final Mentee mentor = MentorManager.getInstance().getMentor(player.getObjectId());
  13.         if (mentor == null)
  14.         {
  15.             return;
  16.         }
  17.        
  18.         final int amount = MENTEE_COINS.get(player.getLevel());
  19.         if (amount > 0)
  20.         {
  21.             sendMail(mentor.getObjectId(), LEVEL_UP_TITLE, String.format(LEVEL_UP_BODY, player.getName(), player.getLevel()), MENTEE_MARK, amount);
  22.         }
  23.     }
  24.    
  25.     private void sendMail(int objectId, String title, String body, int itemId, long amount)
  26.     {
  27.         final Message msg = new Message(MENTOR_GUIDE, objectId, title, body, MailType.MENTOR_NPC);
  28.         final Mail attachments = msg.createAttachments();
  29.         attachments.addItem(getName(), itemId, amount, null, null);
  30.         MailManager.getInstance().sendMessage(msg);
  31.     }
  32.    
  33.     public static void main(String[] args)
  34.     {
  35.         new MentorGuide();
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement