예제 #1
0
        public static void Init()
        {
            VRCToolsLogger.Info("[DRPC] Initialising...");
            DiscordRpc.EventHandlers eh = new DiscordRpc.EventHandlers();

            presence.state         = "Not in a world";
            presence.partySize     = 0;
            presence.partyMax      = 0;
            presence.details       = "Not logged in" + " (" + (DeobfGetters.IsVRLaunched() ? "VR" : "Desktop") + ")";
            presence.largeImageKey = "logo";
            presence.partyId       = "";

            Thread t = new Thread(new ThreadStart(() => {
                DiscordRpc.Initialize("404400696171954177", ref eh, true, null);

                while (true)
                {
                    Update();
                    Thread.Sleep(5000);
                }
            }));

            t.Name         = "Discord-RPC update thread";
            t.IsBackground = true;
            t.Start();

            VRCToolsLogger.Info("[DRPC] Done !");
        }
예제 #2
0
        public static void Update()
        {
            ApiWorld world = RoomManager.currentRoom;

            if (world != CurrentWorld)
            {
                CurrentWorld = world;
                if (world != null)
                {
                    if (world.currentInstanceAccess == AccessType.InviteOnly || world.currentInstanceAccess == AccessType.InvitePlus)
                    {
                        presence.state   = "in a private world";
                        presence.partyId = "";
                    }
                    else
                    {
                        presence.state = "in " + world.name + " " + (
                            world.currentInstanceAccess == AccessType.FriendsOfGuests ? "[Friends+]" :
                            world.currentInstanceAccess == AccessType.FriendsOnly ? "[Friends]" :
                            world.currentInstanceAccess == AccessType.Public ? "" :
                            "[Unknown]"
                            );
                        presence.partyId = world.currentInstanceIdOnly;
                        VRCToolsLogger.Info("WorldInstanceId: " + world.currentInstanceIdOnly);
                    }
                }
                else
                {
                    presence.state   = "Not in a world";
                    presence.partyId = "";
                }
                if (APIUser.CurrentUser != null)
                {
                    presence.details = "as " + APIUser.CurrentUser.displayName + " (" + (DeobfGetters.IsVRLaunched() ? "VR" : "Desktop") + ")";
                }
                else
                {
                    presence.details = "Not logged in" + " (" + (DeobfGetters.IsVRLaunched() ? "VR" : "Desktop") + ")";
                }
            }

            if (world != null && world.currentInstanceAccess != AccessType.InviteOnly && world.currentInstanceAccess != AccessType.InvitePlus)
            {
                presence.partySize = VRC.PlayerManager.GetAllPlayers().Length;
                presence.partyMax  = world.capacity;
            }
            else
            {
                presence.partySize = 0;
                presence.partyMax  = 0;
            }

            DiscordRpc.UpdatePresence(ref presence);
        }
예제 #3
0
        public VRCTRequest(string type, string data)
        {
            LNMIKJDOJDA cu = DeobfGetters.getCurrentUser();

            if (cu != null)
            {
                this.uuid     = cu.id;
                this.username = cu.username;
            }
            else
            {
                this.uuid     = "usr_none";
                this.username = "******";
            }
            this.modversion = VRCToolsMainComponent.VRCToolsVersion;
            this.type       = type;
            this.data       = data;
        }
예제 #4
0
        public static void Update()
        {
            try
            {
                lock (cb)
                {
                    foreach (Action a in cb)
                    {
                        a();
                    }
                    cb.Clear();
                }

                if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.O))
                {
                    if (PlayerManager.GetCurrentPlayer() == null)
                    {
                        VRCToolsLogger.Info("Unable to get current player");
                        VRCToolsMainComponent.MessageGUI(Color.red, "Unable to get current player", 3);
                    }
                    else
                    {
                        VRCPlayer vrcPlayer1 = PlayerManager.GetCurrentPlayer().vrcPlayer;

                        ApiAvatar apiAvatar1 = DeobfGetters.getApiAvatar();
                        if (apiAvatar1 == null)
                        {
                            VRCToolsLogger.Error("Your avatar couldn't be retrieved. Maybe your Assembly-CSharp.dll is in the wrong version ?");
                            return;
                        }
                        Boolean f = false;
                        if (apiAvatar1.releaseStatus != "public")
                        {
                            VRCToolsMainComponent.MessageGUI(Color.red, "Couldn't add avatar to list: This avatar is not public ! (" + apiAvatar1.name + ")", 3);
                        }
                        foreach (String s in apiAvatar1.tags)
                        {
                            if (s == "favorite")
                            {
                                f = true; break;
                            }
                        }
                        if (!f)
                        {
                            VRCToolsLogger.Info("Adding avatar to favorite: " + apiAvatar1.name);
                            VRCToolsLogger.Info("Description: " + apiAvatar1.description);

                            int rc = VRCTServerManager.AddAvatar(apiAvatar1);
                            if (rc == ReturnCodes.SUCCESS)
                            {
                                apiAvatar1.tags.Add("favorite");
                                VRCToolsMainComponent.MessageGUI(Color.green, "Successfully favorited avatar " + apiAvatar1.name, 3);
                            }
                            else if (rc == ReturnCodes.AVATAR_ALREADY_IN_FAV)
                            {
                                apiAvatar1.tags.Add("favorite");
                                VRCToolsMainComponent.MessageGUI(Color.yellow, "Already in favorite list: " + apiAvatar1.name, 3);
                            }
                            else if (rc == ReturnCodes.AVATAR_PRIVATE)
                            {
                                apiAvatar1.tags.Add("favorite");
                                VRCToolsMainComponent.MessageGUI(Color.red, "Couldn't add avatar to list: This avatar is not public ! (" + apiAvatar1.name + ")", 3);
                            }
                            else
                            {
                                VRCToolsMainComponent.MessageGUI(Color.red, "Unable to favorite avatar (error " + rc + "): " + apiAvatar1.name, 3);
                            }
                        }
                        else
                        {
                            VRCToolsLogger.Info("This avatar is already in favorite list");
                            VRCToolsMainComponent.MessageGUI(Color.yellow, "Already in favorite list: " + apiAvatar1.name, 3);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                VRCToolsLogger.Error(e.ToString());
            }
        }