Search in sources :

Example 1 with FloorStatus

use of mc.dragons.core.gameobject.floor.Floor.FloorStatus in project DragonsOnline by UniverseCraft.

the class FloorCommand method selectFloor.

private void selectFloor(CommandSender sender, String[] args) {
    User user = user(sender);
    Floor floor = lookupFloor(sender, args[0]);
    if (floor == null)
        return;
    if (args.length == 1) {
        sender.sendMessage(ChatColor.GREEN + "=== Floor: " + floor.getFloorName() + " ===");
        String usable = floor.isPlayerLocked() ? ChatColor.RED + "Closed to players" : ChatColor.GREEN + "Open to players";
        String editable = floor.isGMLocked() ? ChatColor.RED + "Closed to editing" : ChatColor.GREEN + "Open to editing";
        sender.sendMessage(usable + ChatColor.GRAY + " - " + editable);
        sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "[Go To Floor]", "/floor goto " + floor.getFloorName(), "Click to go to floor " + floor.getFloorName()));
        sender.sendMessage(ChatColor.GRAY + "Database identifier: " + ChatColor.GREEN + floor.getIdentifier().toString());
        sender.sendMessage(ChatColor.GRAY + "Floor Name: " + ChatColor.GREEN + floor.getFloorName());
        sender.sendMessage(ChatColor.GRAY + "Display Name: " + ChatColor.GREEN + floor.getDisplayName());
        sender.sendMessage(ChatColor.GRAY + "Status: " + ChatColor.GREEN + floor.getFloorStatus());
        sender.sendMessage(ChatColor.GRAY + "World Name: " + ChatColor.GREEN + floor.getWorldName());
        sender.sendMessage(ChatColor.GRAY + "Level Min: " + ChatColor.GREEN + floor.getLevelMin());
        sender.sendMessage(ChatColor.GRAY + "Volatile: " + ChatColor.GREEN + floor.isVolatile());
        sender.spigot().sendMessage(ObjectMetadataCommand.getClickableMetadataLink(GameObjectType.FLOOR, floor.getUUID()));
        return;
    }
    Document base = Document.parse(floor.getData().toJson());
    if (floor.isGMLocked() && !hasPermission(sender, PermissionLevel.ADMIN)) {
        sender.sendMessage(ChatColor.RED + "This floor is not currently editable. (Status: " + floor.getFloorStatus() + ")");
    } else if (args.length <= 2) {
        sender.sendMessage(ChatColor.RED + "Insufficient arguments! /floor <FloorName> <name|displayname|lvmin|volatile|status> <Value>");
    } else if (args[1].equalsIgnoreCase("name")) {
        floor.setFloorName(args[2]);
        sender.sendMessage(ChatColor.GREEN + "Updated floor name successfully.");
        AUDIT_LOG.saveEntry(floor, user, base, "Updated floor internal name to " + args[2]);
    } else if (args[1].equalsIgnoreCase("displayname")) {
        floor.setDisplayName(StringUtil.concatArgs(args, 2));
        sender.sendMessage(ChatColor.GREEN + "Updated floor display name successfully.");
        AUDIT_LOG.saveEntry(floor, user, base, "Updated floor display name to " + StringUtil.concatArgs(args, 2));
    } else if (args[1].equalsIgnoreCase("status")) {
        if (!requirePermission(sender, SystemProfileFlag.TASK_MANAGER))
            return;
        FloorStatus status = StringUtil.parseEnum(sender, FloorStatus.class, args[2]);
        if (status == null)
            return;
        floor.setFloorStatus(status);
        sender.sendMessage(ChatColor.GREEN + "Updated floor status successfully.");
        AUDIT_LOG.saveEntry(floor, user, base, "Updated floor status to " + status);
    } else if (args[1].equalsIgnoreCase("lvmin")) {
        Integer lvMin = parseInt(sender, args[2]);
        if (lvMin == null)
            return;
        floor.setLevelMin(lvMin);
        sender.sendMessage(ChatColor.GREEN + "Updated floor level requirement successfully.");
        AUDIT_LOG.saveEntry(floor, user, base, "Updated floor level min to " + lvMin);
    } else if (args[1].equalsIgnoreCase("volatile")) {
        Boolean isVolatile = parseBoolean(sender, args[2]);
        if (isVolatile == null)
            return;
        floor.setVolatile(isVolatile);
        sender.sendMessage(ChatColor.GREEN + "Updated floor volatility status sucessfully.");
        AUDIT_LOG.saveEntry(floor, user, base, "Updated floor volatility to " + isVolatile);
    } else {
        sender.sendMessage(ChatColor.RED + "Invalid arguments! /floor <FloorName> <name|displayname|lvmin|volatile> <Value>");
    }
}
Also used : Floor(mc.dragons.core.gameobject.floor.Floor) FloorStatus(mc.dragons.core.gameobject.floor.Floor.FloorStatus) User(mc.dragons.core.gameobject.user.User) Document(org.bson.Document)

Example 2 with FloorStatus

use of mc.dragons.core.gameobject.floor.Floor.FloorStatus in project DragonsOnline by UniverseCraft.

the class FloorCommand method goToFloor.

private void goToFloor(CommandSender sender, String[] args) {
    Floor floor = lookupFloor(sender, args[1]);
    if (floor == null)
        return;
    FloorStatus status = floor.getFloorStatus();
    boolean access = status == FloorStatus.TESTING || hasPermission(sender, PermissionLevel.BUILDER);
    if (!access) {
        sender.sendMessage(ChatColor.RED + "Testers can only teleport to floors that are in testing!");
        return;
    }
    user(sender).sendToFloor(floor.getFloorName(), true);
    sender.sendMessage(ChatColor.GREEN + "Teleported to floor successfully.");
}
Also used : Floor(mc.dragons.core.gameobject.floor.Floor) FloorStatus(mc.dragons.core.gameobject.floor.Floor.FloorStatus)

Aggregations

Floor (mc.dragons.core.gameobject.floor.Floor)2 FloorStatus (mc.dragons.core.gameobject.floor.Floor.FloorStatus)2 User (mc.dragons.core.gameobject.user.User)1 Document (org.bson.Document)1