Search in sources :

Example 1 with Rank

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

the class RankCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!requirePermission(sender, PermissionLevel.ADMIN))
        return true;
    if (args.length < 2) {
        sender.sendMessage(ChatColor.RED + "Insufficient arguments! /rank <player> <rank>");
        sender.sendMessage(ChatColor.RED + "Valid ranks are: " + StringUtil.parseList(Rank.values()));
        return true;
    }
    User targetUser = lookupUser(sender, args[0]);
    if (targetUser == null)
        return true;
    Player targetPlayer = targetUser.getPlayer();
    Rank rank = StringUtil.parseEnum(sender, Rank.class, args[1]);
    if (rank == null) {
        return true;
    }
    if (rank.isStaff() && !hasPermission(sender, PermissionLevel.SYSOP)) {
        sender.sendMessage(ChatColor.RED + "Staff ranks are only available through system profiles.");
        return true;
    }
    targetUser.setRank(rank);
    if (targetPlayer == null) {
        sender.sendMessage(ChatColor.YELLOW + "Player is not online on this server! They will have to rejoin for the rank update to be fully applied.");
    } else {
        targetPlayer.sendTitle(ChatColor.DARK_GRAY + "Rank Update", rank.getNameColor() + rank.getRankName(), 20, 40, 20);
        targetPlayer.sendMessage(ChatColor.GRAY + "Your rank was updated to " + rank.getNameColor() + rank.getRankName());
    }
    boolean verified = false;
    if (rank.isStaff() && !targetUser.isVerified()) {
        targetUser.setVerified(true);
        verified = true;
    }
    sender.sendMessage(ChatColor.GREEN + "Rank updated successfully." + (verified ? " User was automatically verified." : ""));
    return true;
}
Also used : Player(org.bukkit.entity.Player) User(mc.dragons.core.gameobject.user.User) Rank(mc.dragons.core.gameobject.user.Rank)

Example 2 with Rank

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

the class DevUserHook method onVerifiedJoin.

@Override
public void onVerifiedJoin(User user) {
    /* Lazy-load task markers */
    if (!loadedTasks) {
        // This is extremely important to clear out pre-existing slimes that would obstruct the new ones
        async(() -> {
            for (int i = 0; i < 5; i++) {
                sync(() -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "verifygameintegrity -resolve -silent"));
                try {
                    Thread.sleep(500);
                } catch (InterruptedException ignored) {
                }
            }
        });
        taskLoader.getAllInProgressTasks();
        loadedTasks = true;
    }
    /* Remind of any outstanding tasks */
    List<Task> myTasks = taskLoader.getAllTasksWith(user);
    boolean tm = PermissionUtil.verifyActiveProfileFlag(user, SystemProfileFlag.TASK_MANAGER, false);
    user.getPlayer().sendMessage(ChatColor.GOLD + "You have " + myTasks.size() + " tasks! " + ChatColor.YELLOW + "/tasks" + (tm ? " my" : ""));
    if (tm) {
        List<Task> myTasksToReview = taskLoader.getAllWaitingTasks();
        user.getPlayer().sendMessage(ChatColor.GOLD + "There are " + myTasksToReview.size() + " tasks that need reviewing. " + ChatColor.YELLOW + "/tasks waiting");
        List<Task> doneTasks = taskLoader.getAllCompletedTasks(true);
        user.getPlayer().sendMessage(ChatColor.GOLD + "There are " + doneTasks.size() + " completed tasks ready for review. " + ChatColor.YELLOW + "/tasks done");
    }
    /* Notify Discord when builders join the server */
    Rank rank = user.getRank();
    if (rank == Rank.BUILDER || rank == Rank.BUILDER_CMD || rank == Rank.BUILD_MANAGER || rank == Rank.HEAD_BUILDER || rank == Rank.NEW_BUILDER) {
        buildNotifier.sendNotification("[Builder Join] " + rank.getRankName() + " " + user.getName() + " joined the server!");
    }
    /* Set star count, if not already set */
    if (!user.getData().containsKey("stars")) {
        user.getStorageAccess().set("stars", 0);
    }
    user.getPlayer().sendMessage(ChatColor.GOLD + "You are have " + user.getData().getInteger("stars", 0) + " stars in your balance");
}
Also used : Task(mc.dragons.dev.tasks.TaskLoader.Task) Rank(mc.dragons.core.gameobject.user.Rank)

Example 3 with Rank

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

the class AutoRankCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!requirePermission(sender, PermissionLevel.ADMIN))
        return true;
    if (args.length < 2) {
        sender.sendMessage(ChatColor.RED + "/autorank <player> <rank>");
        return true;
    }
    User user = userLoader.loadObject(args[0]);
    if (user != null) {
        sender.sendMessage(ChatColor.RED + "That user already exists! Use /rank <player> <rank> instead");
        return true;
    }
    Rank rank = StringUtil.parseEnum(sender, Rank.class, args[1]);
    if (VAR.get("autorank") == null) {
        VAR.set("autorank", new Document());
    }
    UserLoader.uuidFromUsername(args[0], uuid -> {
        if (uuid == null) {
            sender.sendMessage(ChatColor.RED + "Invalid username! No Minecraft user by that name exists.");
            return;
        }
        VAR.set("autorank", VAR.getDocument("autorank").append(uuid.toString(), rank.toString()));
        sender.sendMessage(ChatColor.GREEN + "Updated auto rank successfully. When " + args[0] + " joins, they will automatically receive the " + rank + " rank.");
    });
    return true;
}
Also used : User(mc.dragons.core.gameobject.user.User) Rank(mc.dragons.core.gameobject.user.Rank) Document(org.bson.Document)

Aggregations

Rank (mc.dragons.core.gameobject.user.Rank)3 User (mc.dragons.core.gameobject.user.User)2 Task (mc.dragons.dev.tasks.TaskLoader.Task)1 Document (org.bson.Document)1 Player (org.bukkit.entity.Player)1