private bool OnGiveCommand(string userName, string[] pieces)
        {
            if (!modDetails.enabled)
            {
                return(false);
            }

            var player = FrogtownShared.GetPlayerWithName(userName);
            int index = 0, count = 0;

            if (pieces.Length >= 2)
            {
                if (!Int32.TryParse(pieces[1], out index))
                {
                    if (Enum.TryParse(pieces[1], true, out ItemIndex result))
                    {
                        index = (int)result;
                    }
                    else
                    {
                        FrogtownShared.SendChat("\"" + pieces[1] + "\" not recognized.");
                        return(true);
                    }
                }
            }
            if (index < 0 || index >= (int)ItemIndex.Count)
            {
                index = (int)ItemIndex.SprintOutOfCombat;
            }

            if (pieces.Length >= 3)
            {
                Int32.TryParse(pieces[2], out count);
            }
            if (count == 0)
            {
                count = 1;
            }

            player.master.inventory.GiveItem((ItemIndex)index, count);
            FrogtownShared.SendChat("Gave " + userName + " " + count + " " + ((ItemIndex)index).ToString());

            return(true);
        }
 /// <summary>
 /// Restores all users to their original prefabs.
 /// </summary>
 public void RestoreCharacterPrefabsAndKill()
 {
     foreach (string name in originalBodyNames.Keys)
     {
         PlayerCharacterMasterController player = FrogtownShared.GetPlayerWithName(name);
         if (player != null)
         {
             if (originalBodyNames.TryGetValue(name, out string oldBodyName))
             {
                 var prefab = BodyCatalog.FindBodyPrefab(oldBodyName);
                 if (prefab != null)
                 {
                     FrogtownShared.ChangePrefab(name, prefab);
                     player.master.Invoke("TrueKill", 0.1f);
                 }
             }
         }
     }
 }
        private bool OnRemoveCommand(string userName, string[] pieces)
        {
            if (!modDetails.enabled)
            {
                return(false);
            }

            var player = FrogtownShared.GetPlayerWithName(userName);
            int index = 0, count = 0;

            if (pieces.Length >= 2)
            {
                if (!Int32.TryParse(pieces[1], out index))
                {
                    if (Enum.TryParse(pieces[1], true, out ItemIndex result))
                    {
                        index = (int)result;
                    }
                    else
                    {
                        FrogtownShared.SendChat("\"" + pieces[1] + "\" not recognized.");
                        return(true);
                    }
                }
            }

            if (pieces.Length >= 3)
            {
                Int32.TryParse(pieces[2], out count);
            }
            int countPlayerHas = player.master.inventory.GetItemCount((ItemIndex)index);

            count = Math.Min(Math.Max(count, 1), countPlayerHas);

            if (count > 0)
            {
                player.master.inventory.GiveItem((ItemIndex)index, -count);
                FrogtownShared.SendChat("Took " + count + " " + ((ItemIndex)index).ToString() + " from " + userName + ".");
            }

            return(true);
        }
        /// <summary>
        /// Restores user to their original prefab
        /// </summary>
        /// <param name="name"></param>
        public void RestoreCharacterPrefab(string name)
        {
            PlayerCharacterMasterController player = FrogtownShared.GetPlayerWithName(name);

            if (player != null)
            {
                if (originalBodyNames.TryGetValue(name, out string oldBodyName))
                {
                    var prefab = BodyCatalog.FindBodyPrefab(oldBodyName);
                    if (prefab != null)
                    {
                        player.master.bodyPrefab = prefab;
                    }
                    else
                    {
                        FrogtownShared.SendChat("No prefab for \"" + oldBodyName + "\"");
                    }
                }
            }
        }
        private bool OnClearItemsCommand(string userName, string[] pieces)
        {
            if (!modDetails.enabled)
            {
                return(false);
            }

            var player = FrogtownShared.GetPlayerWithName(userName);

            foreach (ItemIndex itemIndex in ItemCatalog.allItems)
            {
                int count = player.master.inventory.GetItemCount(itemIndex);
                if (count > 0)
                {
                    player.master.inventory.GiveItem(itemIndex, -count);
                }
            }
            FrogtownShared.SendChat("Took all items from " + userName + ".");

            return(true);
        }