Package com.github.zathrus_writer.commandsex.helpers

Examples of com.github.zathrus_writer.commandsex.helpers.ExperienceManager


        LogHelper.showInfo("xpNotNumeric", sender, ChatColor.RED);
        return true;
      }
    }

    ExperienceManager expman = new ExperienceManager(target);
    // We manually define the maximum amount of XP a player can have before their experience bar disappears
    int xpMax = 99999999;
    // Very simple view function to show how much XP a player has
    if (function.equalsIgnoreCase("view")){
      if (!sender.hasPermission("cex.xp.view")){
        LogHelper.showInfo("xpViewNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      if (sender != target && !sender.hasPermission("cex.xp.view.others")){
        LogHelper.showInfo("xpViewOthersNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      LogHelper.showInfo((sender != target ? "[" + Nicknames.getNick(target.getName()) + " #####xpHas#####[" : "xpViewSelf#####[") + expman.getCurrentExp() + " #####xpExperience", sender, ChatColor.AQUA);
      return true;
    }

    // Set function to set a players XP
    if (function.equalsIgnoreCase("set")){
      if (!sender.hasPermission("cex.xp.set")){
        LogHelper.showInfo("xpSetNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      if (sender != target && !sender.hasPermission("cex.xp.set.others")){
        LogHelper.showInfo("xpSetOthersNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      boolean overLimit = false;
      // See if the amount the player defined is over the limit
      if (amountint > xpMax){ overLimit = true; }
      // Check if it is over the limit, if it is set it to the maximum amount of XP otherwise set it to the amount the player defined
      expman.setExp((overLimit ? xpMax : amountint));
      // If the amount is over the limit, notify the sender
      if (overLimit) { LogHelper.showInfo("xpCouldNotAddAll", sender, ChatColor.RED); }
      // Send a message to the target with the actual amount of XP that was set
      if (sender != target) { LogHelper.showInfo("xpSet#####[" + Nicknames.getNick(target.getName()) " #####xpTo#####[" + (overLimit ? xpMax : amountint), sender, ChatColor.AQUA); }
      // Send a success message to the target with the actual amount of XP that was set
      LogHelper.showInfo((sender != target ? "[" + Nicknames.getNick(sender.getName()) + " #####xpSetMsgToTarget1#####[" : "xpSetMsgToTarget2#####[") + (overLimit ? xpMax : amountint), target, ChatColor.AQUA);
    }

    // Add function to add to a players current experience
    if (function.equalsIgnoreCase("add")){
      if (!sender.hasPermission("cex.xp.add")){
        LogHelper.showInfo("xpAddNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      if (sender != target && !sender.hasPermission("cex.xp.add.others")){
        LogHelper.showInfo("xpAddOthersNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      boolean overLimit = false;
      int oldXP = expman.getCurrentExp();
      // Determine whether adding this amount of XP would go over the limit
      if (expman.getCurrentExp() + amountint > xpMax) { overLimit = true; }
      // If it is over the limit, then set their XP to maximum
      // Otherwise add the XP normally
      if (overLimit){
        expman.setExp(xpMax);
        LogHelper.showInfo("xpCouldNotAddAll", sender, ChatColor.RED);
      } else {
        expman.changeExp(amountint);
      }
      // Send a success message to the target with the actual amount of XP that was added
      if (sender != target) { LogHelper.showInfo("xpAdded#####[" + (overLimit ? xpMax - oldXP : amountint) + " #####xpExperience#####[ #####xpTo#####[" + Nicknames.getNick(target.getName()), sender, ChatColor.AQUA); }
      // Send a success message to the sender with the actual amount of XP that was added
      LogHelper.showInfo((sender != target ? "[" + Nicknames.getNick(sender.getName()) + " #####xpAddedGave1#####[" : "xpAddedGave2#####[") + (overLimit ? xpMax - oldXP : amountint) + " #####xpExperience", target, ChatColor.AQUA);
    }

    // Take function to take XP from a player
    if (function.equalsIgnoreCase("take")){
      if (!sender.hasPermission("cex.xp.take")){
        LogHelper.showInfo("xpTakeNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      if (sender != target && !sender.hasPermission("cex.xp.take.others")){
        LogHelper.showInfo("xpTakeOthersNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      // Check if the player has the amount needed
      boolean hasXP = expman.hasExp(amountint);
      int oldXP = expman.getCurrentExp();
      // If the player has the XP, then take the amount the user defined
      // If not then take as much as we can
      expman.changeExp(-(hasXP ? amountint : expman.getCurrentExp()));
      // Send a message to sender saying the target didn't have that amount
      if (!hasXP) { LogHelper.showInfo("xpNotEnough", sender, ChatColor.RED); }
      // Alert the target that some of his XP has been stolen and the actual amount of XP taken
      if (sender != target) { LogHelper.showInfo("xpTaken#####[" + (hasXP ? amountint : oldXP) + " #####xpExperience#####[ #####xpFrom#####[" + Nicknames.getNick(target.getName()), sender, ChatColor.AQUA); }
      // Send a message to the sender with the actual amount of XP taken
View Full Code Here


      }
    }
    if (function == null || function.equalsIgnoreCase("health") || function.equalsIgnoreCase("hearts")){ LogHelper.showInfo("pinfoHealth#####[" + ChatColor.GOLD + target.getHealth() + "/20", sender, ChatColor.GRAY); }
    if (function == null || function.equalsIgnoreCase("food") || function.equalsIgnoreCase("hunger")){ LogHelper.showInfo("pinfoFood#####[" + ChatColor.GOLD + target.getFoodLevel() + "/20", sender, ChatColor.GRAY); }
    if (function == null || function.equalsIgnoreCase("xp") || function.equalsIgnoreCase("exp") || function.equalsIgnoreCase("experience")){
      ExperienceManager expman = new ExperienceManager(target);
      LogHelper.showInfo("pinfoXP#####[" + ChatColor.GOLD + expman.getCurrentExp(), sender, ChatColor.GRAY);
    }
    if (function == null || function.equalsIgnoreCase("explevel") || function.equalsIgnoreCase("explevels") || function.equalsIgnoreCase("xplevel")
        || function.equalsIgnoreCase("xplevels") || function.equalsIgnoreCase("experiencelevel") || function.equalsIgnoreCase("experiencelevels")){
      ExperienceManager expman = new ExperienceManager(target);
      LogHelper.showInfo("pinfoXPlvls#####[" + ChatColor.GOLD + expman.getLevelForExp(expman.getCurrentExp()), sender, ChatColor.GRAY);
    }
    if (function == null || function.equalsIgnoreCase("god")) { LogHelper.showInfo("pinfoGod#####[" + ChatColor.GOLD + (Common.godPlayers.contains(target.getName()) ? "#####pinfoOn" : "#####pinfoOff"), sender, ChatColor.GRAY); }
    if (function == null || function.equalsIgnoreCase("inv") || function.equalsIgnoreCase("invisible")) { LogHelper.showInfo("pinfoInv#####[" + ChatColor.GOLD + (Common.invisiblePlayers.contains(target.getName()) ? "#####pinfoOn" : "#####pinfoOff"), sender, ChatColor.GRAY); }
   
    if (function == null || function.equalsIgnoreCase("coords") || function.equalsIgnoreCase("coordinates") || function.equalsIgnoreCase("world")){ LogHelper.showInfo("pinfoWorld#####[" + ChatColor.GOLD + target.getLocation().getWorld().getName(), sender, ChatColor.GRAY); }
View Full Code Here

TOP

Related Classes of com.github.zathrus_writer.commandsex.helpers.ExperienceManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.