Search in sources :

Example 1 with SkillType

use of mc.dragons.core.gameobject.user.SkillType in project DragonsOnline by UniverseCraft.

the class UpdateStatsCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!requirePermission(sender, PermissionLevel.GM))
        return true;
    if (args.length < 3) {
        sender.sendMessage(ChatColor.RED + "Specify a player! /updatestats <Player> <StatName> <Value>");
        sender.sendMessage(ChatColor.RED + "Valid StatNames: xp, level, gold, health, maxHealth, skill.<SkillType>, savedlocation");
        return true;
    }
    User target = lookupUser(sender, args[0]);
    if (target == null)
        return true;
    if (args[1].equalsIgnoreCase("xp")) {
        target.setXP(Integer.valueOf(args[2]));
        if (target.getPlayer() != null) {
            target.getPlayer().setHealth(Math.min(target.getPlayer().getHealth(), User.calculateMaxHealth(target.getLevel())));
        }
        sender.sendMessage(ChatColor.GREEN + "Updated XP of " + target.getName());
    } else if (args[1].equalsIgnoreCase("level")) {
        int level = Integer.valueOf(args[2]);
        double max = User.calculateMaxXPDecimal(level);
        target.setXP((int) Math.ceil(max + 1));
        sender.sendMessage(ChatColor.GREEN + "Updated level of " + target.getName());
    } else if (args[1].equalsIgnoreCase("gold")) {
        target.setGold(Double.valueOf(args[2]));
        sender.sendMessage(ChatColor.GREEN + "Updated gold balance of " + target.getName());
    } else if (args[1].equalsIgnoreCase("health")) {
        target.getPlayer().setHealth(Double.valueOf(args[2]));
        sender.sendMessage(ChatColor.GREEN + "Updated health of " + target.getName());
    } else if (args[1].equalsIgnoreCase("maxHealth")) {
        if (target.getPlayer() == null) {
            sender.sendMessage(ChatColor.RED + "The specified player must be online to set their max health.");
        }
        target.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(Double.valueOf(args[2]));
        sender.sendMessage(ChatColor.GREEN + "Updated local max health of " + target.getName());
        sender.sendMessage(ChatColor.YELLOW + "Warning: This change will only persist until the player rejoins.");
    } else if (args[1].startsWith("skill.")) {
        String skillName = args[1].replaceAll("skill.", "").toUpperCase();
        SkillType skill = StringUtil.parseEnum(sender, SkillType.class, skillName);
        target.setSkillProgress(skill, Double.valueOf(args[2]));
    } else if (args[1].equalsIgnoreCase("savedLocation") && requirePlayer(sender)) {
        if (!(sender instanceof Player)) {
            sender.sendMessage(ChatColor.RED + "This sub-command requires that you be in-game.");
            return true;
        }
        target.setSavedLocation(player(sender).getLocation());
        sender.sendMessage(ChatColor.GREEN + "Updated saved location of " + target.getName());
    } else {
        sender.sendMessage(ChatColor.RED + "Invalid usage! /updatestats");
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) User(mc.dragons.core.gameobject.user.User) SkillType(mc.dragons.core.gameobject.user.SkillType)

Example 2 with SkillType

use of mc.dragons.core.gameobject.user.SkillType in project DragonsOnline by UniverseCraft.

the class ResetProfileCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!requirePermission(sender, PermissionLevel.TESTER))
        return true;
    User target = user(sender);
    if (args.length != 0 && requirePermission(sender, PermissionLevel.ADMIN)) {
        target = lookupUser(sender, args[0]);
    }
    if (target == null)
        return true;
    boolean resetRank = false;
    if (args.length > 1) {
        resetRank = hasPermission(sender, PermissionLevel.ADMIN) && (args[1].equalsIgnoreCase("-r") || args[1].equalsIgnoreCase("-resetrank"));
    }
    target.setXP(0);
    target.setActivePermissionLevel(PermissionLevel.USER);
    target.setGold(0.0);
    target.setChatSpy(false);
    target.setGodMode(false);
    target.setGameMode(GameMode.ADVENTURE, true);
    // target.setDebuggingErrors(false);
    target.setStreamConsoleLevel(Level.OFF);
    target.clearInventory();
    for (SkillType skill : SkillType.values()) {
        target.setSkillLevel(skill, 0);
        target.setSkillProgress(skill, 0.0);
    }
    for (Quest quest : new HashSet<>(target.getQuestProgress().keySet())) {
        target.updateQuestProgress(quest, null);
    }
    target.sendToFloor("BeginnerTown");
    for (ItemClass itemClass : PlayerEventListeners.DEFAULT_INVENTORY) {
        target.giveItem(itemLoader.registerNew(itemClass));
    }
    if (resetRank) {
        target.setRank(Rank.DEFAULT);
    }
    target.getPlayer().sendTitle(ChatColor.DARK_RED + "RESET", ChatColor.RED + "Your stats have been wiped!", 10, 70, 20);
    target.sendActionBar(ChatColor.DARK_RED + "- Your stats have been wiped! -");
    target.debug("Profile forcibly reset");
    if (target.equals(user(sender))) {
        sender.sendMessage(ChatColor.GREEN + "Wiped your stats.");
    } else {
        sender.sendMessage(ChatColor.GREEN + "Wiped " + target.getName() + "'s stats.");
    }
    return true;
}
Also used : ItemClass(mc.dragons.core.gameobject.item.ItemClass) User(mc.dragons.core.gameobject.user.User) SkillType(mc.dragons.core.gameobject.user.SkillType) Quest(mc.dragons.core.gameobject.quest.Quest) HashSet(java.util.HashSet)

Aggregations

SkillType (mc.dragons.core.gameobject.user.SkillType)2 User (mc.dragons.core.gameobject.user.User)2 HashSet (java.util.HashSet)1 ItemClass (mc.dragons.core.gameobject.item.ItemClass)1 Quest (mc.dragons.core.gameobject.quest.Quest)1 Player (org.bukkit.entity.Player)1