Search in sources :

Example 1 with AuditLogEntry

use of mc.dragons.tools.content.AuditLogLoader.AuditLogEntry in project DragonsOnline by UniverseCraft.

the class ObjectMetadataCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!requirePermission(sender, PermissionLevel.GM))
        return true;
    if (args.length == 0) {
        sender.sendMessage(ChatColor.RED + "/objmeta <gameobject type> <gameobject uuid>");
        return true;
    }
    GameObjectType type = StringUtil.parseEnum(sender, GameObjectType.class, args[0]);
    UUID uuid = parseUUID(sender, args[1]);
    if (type == null || uuid == null)
        return true;
    GameObject gameObject = type.getLoader().loadObject(dragons.getPersistentStorageManager().getStorageAccess(type, uuid));
    if (gameObject == null) {
        sender.sendMessage(ChatColor.RED + "No game object was found matching these criteria!");
        return true;
    }
    // MetadataConstants.displayMetadata(sender, gameObject);
    List<AuditLogEntry> entries = AUDIT_LOG.getEntries(gameObject.getIdentifier());
    int count = entries.size();
    if (count == 0) {
        sender.sendMessage(ChatColor.RED + "There is no metadata for this game object!");
        return true;
    }
    AuditLogEntry first = entries.get(0);
    AuditLogEntry last = entries.get(entries.size() - 1);
    AuditLogEntry lastPush = AUDIT_LOG.getLastPush(gameObject.getIdentifier());
    if (first != null && first.getLine().equals("Created")) {
        sender.sendMessage(ChatColor.GRAY + "Created By: " + ChatColor.GREEN + ObjectUtil.get(first.getBy(), () -> first.getBy().getName(), UNKNOWN));
        sender.sendMessage(ChatColor.GRAY + "Created On: " + ChatColor.GREEN + ObjectUtil.get(first.getDate(), () -> StringUtil.DATE_FORMAT.format(first.getDate()), UNKNOWN));
    }
    sender.sendMessage(ChatColor.GRAY + "Revision Count: " + ChatColor.GREEN + count);
    if (last != null) {
        sender.sendMessage(ChatColor.GRAY + "Last Revised By: " + ChatColor.GREEN + ObjectUtil.get(last.getBy(), () -> last.getBy().getName(), UNKNOWN));
        sender.sendMessage(ChatColor.GRAY + "Last Revised On: " + ChatColor.GREEN + ObjectUtil.get(last.getDate(), () -> StringUtil.DATE_FORMAT.format(last.getDate()), UNKNOWN));
    }
    if (lastPush != null) {
        sender.sendMessage(ChatColor.GRAY + "Last Pushed On: " + ChatColor.GREEN + StringUtil.DATE_FORMAT.format(lastPush.getDate()));
    }
    if (last == null || lastPush == null) {
        sender.sendMessage(ChatColor.GRAY + "Sync Status: " + UNKNOWN);
    } else if (last.getId() == lastPush.getId()) {
        sender.sendMessage(ChatColor.GRAY + "Sync Status: " + ChatColor.GREEN + "Matched in production");
    } else if (last.getId() > lastPush.getId()) {
        sender.sendMessage(ChatColor.GRAY + "Sync Status: " + ChatColor.YELLOW + "Changes made since last push");
    } else {
        sender.sendMessage(ChatColor.GRAY + "Sync Status: " + ChatColor.RED + "Behind production (SYNC ERROR)");
    }
    return true;
}
Also used : GameObjectType(mc.dragons.core.gameobject.GameObjectType) AuditLogEntry(mc.dragons.tools.content.AuditLogLoader.AuditLogEntry) GameObject(mc.dragons.core.gameobject.GameObject) UUID(java.util.UUID)

Aggregations

UUID (java.util.UUID)1 GameObject (mc.dragons.core.gameobject.GameObject)1 GameObjectType (mc.dragons.core.gameobject.GameObjectType)1 AuditLogEntry (mc.dragons.tools.content.AuditLogLoader.AuditLogEntry)1