Search in sources :

Example 1 with Floor

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

the class SystemLogonCommand method opFloor.

private void opFloor(CommandSender sender, String[] args) {
    if (!requirePermission(sender, PermissionLevel.ADMIN))
        return;
    Floor floor = lookupFloor(sender, args[2]);
    if (floor == null)
        return;
    systemProfileLoader.addAdminFloor(args[1], floor);
    sender.sendMessage(ChatColor.GREEN + "Added admin floor successfully.");
}
Also used : Floor(mc.dragons.core.gameobject.floor.Floor)

Example 2 with Floor

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

the class SystemLogonCommand method deopFloor.

private void deopFloor(CommandSender sender, String[] args) {
    if (!requirePermission(sender, PermissionLevel.ADMIN))
        return;
    Floor floor = lookupFloor(sender, args[2]);
    if (floor == null)
        return;
    systemProfileLoader.removeAdminFloor(args[1], floor);
    sender.sendMessage(ChatColor.GREEN + "Removed admin floor successfully.");
}
Also used : Floor(mc.dragons.core.gameobject.floor.Floor)

Example 3 with Floor

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

the class ContentToolsListeners method onChangeWorld.

@EventHandler
public void onChangeWorld(PlayerChangedWorldEvent e) {
    User user = UserLoader.fromPlayer(e.getPlayer());
    Floor floor = FloorLoader.fromLocation(e.getPlayer().getLocation());
    boolean isAdminWorld = user.getSystemProfile() != null && user.getSystemProfile().getLocalAdminFloors().contains(floor);
    if (e.getPlayer().getGameMode() != GameMode.ADVENTURE && !isAdminWorld && !PermissionUtil.verifyActivePermissionLevel(user, PermissionLevel.BUILDER, false)) {
        e.getPlayer().sendMessage(ChatColor.RED + "You are not authorized for this gamemode in this world!");
        e.getPlayer().setGameMode(GameMode.ADVENTURE);
    } else if (e.getPlayer().getGameMode() != GameMode.ADVENTURE && !floor.isGMLocked() && !PermissionUtil.verifyActivePermissionLevel(user, PermissionLevel.ADMIN, false)) {
        e.getPlayer().sendMessage(ChatColor.RED + "This floor is currently edit-locked and cannot be edited.");
        e.getPlayer().setGameMode(GameMode.ADVENTURE);
    }
}
Also used : Floor(mc.dragons.core.gameobject.floor.Floor) User(mc.dragons.core.gameobject.user.User) EventHandler(org.bukkit.event.EventHandler)

Example 4 with Floor

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

the class NPCCommand method propagateRevisions.

/**
 * Propagates revisions on this NPC class
 * to any floors containing NPCs of this class.
 *
 * Non-persistent NPCs (i.e. mobs) are not
 * counted.
 *
 * @param npcClass
 */
private void propagateRevisions(NPCClass npcClass) {
    if (!npcClass.getNPCType().isPersistent())
        return;
    Bukkit.getScheduler().runTaskAsynchronously(dragons, () -> {
        for (GameObject obj : dragons.getGameObjectRegistry().getRegisteredObjects(GameObjectType.FLOOR)) {
            Floor floor = (Floor) obj;
            for (Entity e : floor.getWorld().getEntities()) {
                NPC npc = NPCLoader.fromBukkit(e);
                if (npc == null)
                    continue;
                if (npc.getNPCClass().equals(npcClass)) {
                    LOGGER.trace("Automatically incremented revision count on " + floor.getFloorName() + " due to modification of NPC class " + npcClass.getClassName());
                    AUDIT_LOG.saveEntry(floor, null, "Picked up revision of NPC class " + npcClass.getClassName());
                    break;
                }
            }
        }
    });
}
Also used : NPC(mc.dragons.core.gameobject.npc.NPC) Floor(mc.dragons.core.gameobject.floor.Floor) Entity(org.bukkit.entity.Entity) GameObject(mc.dragons.core.gameobject.GameObject)

Example 5 with Floor

use of mc.dragons.core.gameobject.floor.Floor 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)

Aggregations

Floor (mc.dragons.core.gameobject.floor.Floor)20 User (mc.dragons.core.gameobject.user.User)4 Document (org.bson.Document)4 GameObject (mc.dragons.core.gameobject.GameObject)3 Player (org.bukkit.entity.Player)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 UUID (java.util.UUID)2 Dragons (mc.dragons.core.Dragons)2 FloorStatus (mc.dragons.core.gameobject.floor.Floor.FloorStatus)2 FloorLoader (mc.dragons.core.gameobject.floor.FloorLoader)2 Region (mc.dragons.core.gameobject.region.Region)2 Bukkit (org.bukkit.Bukkit)2 EventHandler (org.bukkit.event.EventHandler)2 IOException (java.io.IOException)1 BigInteger (java.math.BigInteger)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Path (java.nio.file.Path)1