public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
        {
            try
            {
                if (_params.Count < 3 || _params.Count > 4)
                {
                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 3 or 4, found {0}", _params.Count));

                    return;
                }
                if (_params.Count == 3)
                {
                    ClientInfo cInfo = PersistentOperations.GetClientInfoFromNameOrId(_params[0]);
                    if (cInfo != null)
                    {
                        PersistentPlayerData persistentPlayerData = PersistentOperations.GetPersistentPlayerDataFromEntityId(cInfo.entityId);
                        if (persistentPlayerData != null)
                        {
                            List <Vector3i> claimBlockList = persistentPlayerData.GetLandProtectionBlocks();
                            if (claimBlockList != null)
                            {
                                for (int i = 0; i < claimBlockList.Count; i++)
                                {
                                    Vector3i claimLocation = claimBlockList[i];
                                    persistentPlayerData.RemoveLandProtectionBlock(claimLocation);
                                }
                            }
                            SingletonMonoBehaviour <SdtdConsole> .Instance.ExecuteSync(string.Format("ban add {0} {1} {2}", cInfo.CrossplatformId.CombinedString, _params[1], _params[2]), null);

                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Id '{0}' '{1}' has been banned. Their claims have been removed", cInfo.PlatformId.CombinedString, cInfo.CrossplatformId.CombinedString, _params[0]));

                            return;
                        }
                        else
                        {
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Unable to ban '{0}'. The player data can not be found", _params[0]));

                            return;
                        }
                    }
                    else
                    {
                        PersistentPlayerData persistentPlayerData = PersistentOperations.GetPersistentPlayerDataFromId(_params[0]);
                        if (persistentPlayerData != null)
                        {
                            List <Vector3i> _claimBlockList = persistentPlayerData.GetLandProtectionBlocks();
                            if (_claimBlockList != null)
                            {
                                for (int i = 0; i < _claimBlockList.Count; i++)
                                {
                                    Vector3i _claimLocation = _claimBlockList[i];
                                    persistentPlayerData.RemoveLandProtectionBlock(_claimLocation);
                                }
                            }
                            SingletonMonoBehaviour <SdtdConsole> .Instance.ExecuteSync(string.Format("ban add {0} {1} {2}", persistentPlayerData.UserIdentifier.CombinedString, _params[1], _params[2]), null);

                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] '{0}' has been banned. Their claims have been removed", _params[0]));

                            return;
                        }
                        else
                        {
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Unable to ban '{0}'. The player data can not be found", _params[0]));

                            return;
                        }
                    }
                }
                if (_params.Count == 4)
                {
                    ClientInfo cInfo = ConsoleHelper.ParseParamIdOrName(_params[0]);
                    if (cInfo != null)
                    {
                        PersistentPlayerData _persistentPlayerData = GameManager.Instance.GetPersistentPlayerList().GetPlayerDataFromEntityID(cInfo.entityId);
                        if (_persistentPlayerData != null)
                        {
                            List <Vector3i> _claimBlockList = _persistentPlayerData.GetLandProtectionBlocks();
                            if (_claimBlockList != null)
                            {
                                for (int i = 0; i < _claimBlockList.Count; i++)
                                {
                                    Vector3i _claimLocation = _claimBlockList[i];
                                    _persistentPlayerData.RemoveLandProtectionBlock(_claimLocation);
                                }
                            }
                            SingletonMonoBehaviour <SdtdConsole> .Instance.ExecuteSync(string.Format("ban add {0} {1} {2} {3}", cInfo.CrossplatformId.CombinedString, _params[1], _params[2], _params[3]), null);

                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Id {0} has been banned. Their claims have been removed", _params[0]));

                            return;
                        }
                        else
                        {
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Unable to ban id {0}. The player data for id can not be found", _params[0]));

                            return;
                        }
                    }
                    else
                    {
                        PersistentPlayerData persistentPlayerData = PersistentOperations.GetPersistentPlayerDataFromId(_params[0]);
                        if (persistentPlayerData != null)
                        {
                            List <Vector3i> claimBlockList = persistentPlayerData.GetLandProtectionBlocks();
                            if (claimBlockList != null)
                            {
                                for (int i = 0; i < claimBlockList.Count; i++)
                                {
                                    Vector3i claimLocation = claimBlockList[i];
                                    persistentPlayerData.RemoveLandProtectionBlock(claimLocation);
                                }
                            }
                            SingletonMonoBehaviour <SdtdConsole> .Instance.ExecuteSync(string.Format("ban add {0} {1} {2} {3}", persistentPlayerData.UserIdentifier.CombinedString, _params[1], _params[2], _params[3]), null);

                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] '{0}' has been banned. Their claims have been removed", _params[0]));

                            return;
                        }
                        else
                        {
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Unable to ban '{0}'. The player data can not be found", _params[0]));

                            return;
                        }
                    }
                }
                else
                {
                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Invalid argument {0}", _params[0]));
                }
            }
            catch (Exception e)
            {
                Log.Out(string.Format("[SERVERTOOLS] Error in BanPlayer.Execute: {0}", e.Message));
            }
        }
示例#2
0
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         if (_params.Count < 3 || _params.Count > 4)
         {
             SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 3 or 4, found {0}", _params.Count));
             return;
         }
         if (_params.Count == 3)
         {
             ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[0]);
             if (_cInfo != null)
             {
                 PersistentPlayerData _persistentPlayerData = GameManager.Instance.GetPersistentPlayerList().GetPlayerDataFromEntityID(_cInfo.entityId);
                 if (_persistentPlayerData != null)
                 {
                     List <Vector3i> _claimBlockList = _persistentPlayerData.GetLandProtectionBlocks();
                     if (_claimBlockList != null)
                     {
                         for (int i = 0; i < _claimBlockList.Count; i++)
                         {
                             Vector3i _claimLocation = _claimBlockList[i];
                             _persistentPlayerData.RemoveLandProtectionBlock(_claimLocation);
                         }
                     }
                     SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} {1} {2}", _cInfo.playerId, _params[1], _params[2]), (ClientInfo)null);
                     SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Id {0} has been banned. Their claims have been removed.", _params[0]));
                     return;
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Unable to ban id {0}. The player data for id can not be found.", _params[0]));
                     return;
                 }
             }
             else if (_params[0].Length == 17)
             {
                 PersistentPlayerData _persistentPlayerData = GameManager.Instance.GetPersistentPlayerList().GetPlayerData(_params[0]);
                 if (_persistentPlayerData != null)
                 {
                     List <Vector3i> _claimBlockList = _persistentPlayerData.GetLandProtectionBlocks();
                     if (_claimBlockList != null)
                     {
                         for (int i = 0; i < _claimBlockList.Count; i++)
                         {
                             Vector3i _claimLocation = _claimBlockList[i];
                             _persistentPlayerData.RemoveLandProtectionBlock(_claimLocation);
                         }
                     }
                     SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} {1} {2}", _cInfo.playerId, _params[1], _params[2]), (ClientInfo)null);
                     SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Id {0} has been banned. Their claims have been removed.", _params[0]));
                     return;
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Unable to ban id {0}.  The player data for id can not be found.", _params[0]));
                     return;
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Unable to ban id {0}. If the player is offline, use their steam id to ban them", _params[0]));
                 return;
             }
         }
         if (_params.Count == 4)
         {
             ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[0]);
             if (_cInfo != null)
             {
                 PersistentPlayerData _persistentPlayerData = GameManager.Instance.GetPersistentPlayerList().GetPlayerDataFromEntityID(_cInfo.entityId);
                 if (_persistentPlayerData != null)
                 {
                     List <Vector3i> _claimBlockList = _persistentPlayerData.GetLandProtectionBlocks();
                     if (_claimBlockList != null)
                     {
                         for (int i = 0; i < _claimBlockList.Count; i++)
                         {
                             Vector3i _claimLocation = _claimBlockList[i];
                             _persistentPlayerData.RemoveLandProtectionBlock(_claimLocation);
                         }
                     }
                     SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} {1} {2} {3}", _cInfo.playerId, _params[1], _params[2], _params[3]), (ClientInfo)null);
                     SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Id {0} has been banned. Their claims have been removed.", _params[0]));
                     return;
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Unable to ban id {0}. The player data for id can not be found.", _params[0]));
                     return;
                 }
             }
             else if (_params[0].Length == 17)
             {
                 PersistentPlayerData _persistentPlayerData = GameManager.Instance.GetPersistentPlayerList().GetPlayerData(_params[0]);
                 if (_persistentPlayerData != null)
                 {
                     List <Vector3i> _claimBlockList = _persistentPlayerData.GetLandProtectionBlocks();
                     if (_claimBlockList != null)
                     {
                         for (int i = 0; i < _claimBlockList.Count; i++)
                         {
                             Vector3i _claimLocation = _claimBlockList[i];
                             _persistentPlayerData.RemoveLandProtectionBlock(_claimLocation);
                         }
                     }
                     SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} {1} {2} {3}", _cInfo.playerId, _params[1], _params[2], _params[3]), (ClientInfo)null);
                     SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Id {0} has been banned. Their claims have been removed.", _params[0]));
                     return;
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Unable to ban id {0}. The player data for id can not be found.", _params[0]));
                     return;
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Unable to ban id {0}. If the player is offline, use their steam id to ban them", _params[0]));
                 return;
             }
         }
         else
         {
             SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Invalid argument {0}", _params[0]));
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in BanPlayer.Execute: {0}", e.Message));
     }
 }
 public static bool ProcessBlockDamage(GameManager __instance, string _persistentPlayerId, List <BlockChangeInfo> _blocksToChange)
 {
     try
     {
         World _world = __instance.World;
         for (int i = 0; i < _blocksToChange.Count; i++)
         {
             BlockChangeInfo _newBlockInfo = _blocksToChange[i];                 //new block info
             BlockValue      _blockValue   = _world.GetBlock(_newBlockInfo.pos); //old block value
             if (_newBlockInfo.bChangeBlockValue)                                //new block value
             {
                 if (_newBlockInfo.blockValue.type == BlockValue.Air.type)       //new block is air
                 {
                     if (_blockValue.type == BlockValue.Air.type)                //replaced block
                     {
                         return(true);
                     }
                     if (_blockValue.Block is BlockLandClaim)            //removed claim
                     {
                         if (!string.IsNullOrEmpty(_persistentPlayerId)) //id is valid
                         {
                             PersistentPlayerData _ppd = PersistentOperations.GetPersistentPlayerData(_persistentPlayerId);
                             if (_ppd != null)
                             {
                                 List <Vector3i> _protectionBlocks = _ppd.GetLandProtectionBlocks();
                                 if (_protectionBlocks != null && !_protectionBlocks.Contains(_newBlockInfo.pos))//protection block list valid and does not contain this location
                                 {
                                     int _total = _blockValue.Block.MaxDamage - _blockValue.damage;
                                     if (_blockValue.Block.MaxDamage - _blockValue.damage >= Block_Damage_Limit && ProcessPenalty(_total, _persistentPlayerId, _newBlockInfo))
                                     {
                                         //_world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue);
                                         //return false;
                                     }
                                 }
                             }
                         }
                     }
                     if (!_blockValue.Block.CanPickup)//old block can not be picked up
                     {
                         int _total = _blockValue.Block.MaxDamage - _blockValue.damage;
                         if (_total >= Block_Damage_Limit && ProcessPenalty(_total, _persistentPlayerId, _newBlockInfo))
                         {
                             //_world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue);
                             //return false;
                         }
                     }
                 }
                 else if (_blockValue.type == BlockValue.Air.type)           //old block was air
                 {
                     if (_newBlockInfo.blockValue.Block is BlockSleepingBag) //placed a sleeping bag
                     {
                         PersistentOperations.BedBug(_persistentPlayerId);
                         if (Block_Log)
                         {
                             BlockLog(_persistentPlayerId, _newBlockInfo);
                         }
                     }
                     else if (_newBlockInfo.blockValue.Block is BlockLandClaim)//placed a land claim
                     {
                         PersistentOperations.ClaimBug(_persistentPlayerId);
                         if (Block_Log)
                         {
                             BlockLog(_persistentPlayerId, _newBlockInfo);
                         }
                     }
                     else//placed block
                     {
                         if (Block_Log)
                         {
                             BlockLog(_persistentPlayerId, _newBlockInfo);
                         }
                     }
                 }
                 else if (_blockValue.Block.blockID == _newBlockInfo.blockValue.Block.blockID) //block is the same
                 {
                     if (_newBlockInfo.bChangeDamage)                                          //block took damage
                     {
                         int _total = _newBlockInfo.blockValue.damage - _blockValue.damage;
                         if (_total >= Block_Damage_Limit && ProcessPenalty(_total, _persistentPlayerId, _newBlockInfo))
                         {
                             //_world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue);
                             //return false;
                         }
                     }
                     if (_blockValue.damage == _newBlockInfo.blockValue.damage || _newBlockInfo.blockValue.damage == 0)//protected block replaced
                     {
                         //return true;
                     }
                 }
                 else if (_blockValue.Block.DowngradeBlock.Block.blockID == _newBlockInfo.blockValue.Block.blockID)//downgraded
                 {
                     int _total = _blockValue.Block.MaxDamage - _blockValue.damage + _newBlockInfo.blockValue.damage;
                     if (_total >= Block_Damage_Limit && ProcessPenalty(_total, _persistentPlayerId, _newBlockInfo))
                     {
                         //_world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue);
                         //return false;
                     }
                 }
             }
             //if (Lobby.IsEnabled && Lobby.Protected && Lobby.Lobby_Position != "0,0,0")
             //{
             //    if (Lobby.ProtectedSpace(_newBlockInfo.pos.x, _newBlockInfo.pos.z))
             //    {
             //        _world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue);
             //        return false;
             //    }
             //}
             //if (Market.IsEnabled && Market.Protected && Market.Market_Position != "0,0,0")
             //{
             //    if (Market.ProtectedSpace(_newBlockInfo.pos.x, _newBlockInfo.pos.z))
             //    {
             //        _world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue);
             //        return false;
             //    }
             //}
             //if (Zones.IsEnabled)
             //{
             //    if (Zones.Protected(_newBlockInfo.pos))
             //    {
             //        _world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue);
             //        return false;
             //    }
             //}
             //if (ProtectedSpace.IsEnabled)
             //{
             //    if (ProtectedSpace.Exec(_newBlockInfo.pos))
             //    {
             //        _world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue);
             //        return false;
             //    }
             //}
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in DamageDetector.ProcessBlockDamage: {0}", e.Message));
     }
     return(true);
 }