コード例 #1
0
ファイル: ChatBox.cs プロジェクト: K07H/The-Forest
 private void SendLine(string line)
 {
     if (BoltNetwork.isRunning)
     {
         if (line[0] == '/')
         {
             line = line.Trim(new char[]
             {
                 ' ',
                 '/'
             });
             int num = line.IndexOf(' ');
             if (num == -1)
             {
                 CoopAdminCommand.Send(line, string.Empty);
             }
             else
             {
                 CoopAdminCommand.Send(line.Substring(0, num), line.Substring(num + 1, line.Length - (num + 1)));
             }
         }
         else
         {
             ChatEvent chatEvent = ChatEvent.Create(GlobalTargets.OnlyServer);
             chatEvent.Message = line;
             chatEvent.Sender  = LocalPlayer.Entity.networkId;
             chatEvent.Send();
         }
     }
 }
コード例 #2
0
ファイル: MpPlayerList.cs プロジェクト: K07H/The-Forest
		public void BanByConnectionId(int connectionId)
		{
			if (CoopPeerStarter.Dedicated && CoopSteamClientStarter.IsAdmin)
			{
				CoopAdminCommand.Send("banbycid", connectionId.ToString());
			}
		}
コード例 #3
0
 public override void OnEvent(AdminCommand evnt)
 {
     if (evnt.RaisedBy.IsDedicatedServerAdmin())
     {
         CoopAdminCommand.Recv(evnt.Command, evnt.Data);
     }
 }
コード例 #4
0
ファイル: CoopAdminCommand.cs プロジェクト: K07H/The-Forest
    public static void Send(string command, string data)
    {
        if (CoopPeerStarter.Dedicated)
        {
            if (CoopSteamClientStarter.IsAdmin)
            {
                switch (command)
                {
                case "kick":
                case "kickbycid":
                case "ban":
                case "banbycid":
                case "unban":
                case "save":
                case "restart":
                case "shutdown":
                case "openlogs":
                case "closelogs":
                case "treeregrowmode":
                case "allowbuildingdestruction":
                case "allowenemiescreative":
                case "allowcheats":
                case "allowdebugconsole":
                {
                    AdminCommand adminCommand = AdminCommand.Create(GlobalTargets.OnlyServer);
                    adminCommand.Command = command;
                    adminCommand.Data    = data;
                    adminCommand.Send();
                    goto IL_193;
                }

                case "help":
                    CoopAdminCommand.SendLocalMessage("Help 1/3:\r\n/kick <steamId>, /ban <steamId>, /save <slotNum>, /restart, /shutdown");
                    CoopAdminCommand.SendLocalMessage("Help 2/3:\r\n/openlogs /closelogs");
                    CoopAdminCommand.SendLocalMessage("Help 3/3:\r\n/treeregrowmode <on|off>, /allowbuildingdestruction <on|off>, /allowenemiescreative <on|off>");
                    goto IL_193;
                }
                CoopAdminCommand.SendLocalMessage(string.Concat(new string[]
                {
                    "Unknow command: '",
                    command,
                    " ",
                    data,
                    "'"
                }));
                IL_193 :;
            }
            else
            {
                CoopAdminCommand.SendLocalMessage(string.Concat(new string[]
                {
                    "Cannot execute command '",
                    command,
                    " ",
                    data,
                    "' (not connected as administrator)"
                }));
            }
        }
    }
コード例 #5
0
ファイル: MpPlayerList.cs プロジェクト: K07H/The-Forest
		public void Kick(ulong steamid)
		{
			if (CoopPeerStarter.Dedicated && CoopSteamClientStarter.IsAdmin)
			{
				CoopAdminCommand.Send("kick", steamid.ToString());
			}
			else
			{
				CoopKick.KickPlayer(steamid, 1, "HOST_KICKED_YOU");
				base.Invoke("Refresh", 0.1f);
			}
		}
コード例 #6
0
ファイル: MpPlayerList.cs プロジェクト: K07H/The-Forest
		public void Ban(ulong steamid)
		{
			if (CoopPeerStarter.Dedicated && CoopSteamClientStarter.IsAdmin)
			{
				CoopAdminCommand.Send("ban", steamid.ToString());
			}
			else
			{
				BoltConnection connection;
				BoltEntity playerEntity;
				MpPlayerList.GetConnectionAndEntity(steamid, out connection, out playerEntity);
				CoopKick.BanPlayer(connection, playerEntity);
				base.Invoke("Refresh", 0.1f);
			}
		}
コード例 #7
0
 public void BanByName(string name)
 {
     if (CoopPeerStarter.Dedicated && CoopSteamClientStarter.IsAdmin)
     {
         CoopAdminCommand.Send("ban", name);
     }
     else
     {
         BoltEntity entityFromName = MpPlayerList.GetEntityFromName(name, null);
         if (entityFromName)
         {
             CoopKick.BanPlayer(entityFromName);
             base.Invoke("Refresh", 0.1f);
         }
     }
 }
コード例 #8
0
 public void Ban(ulong steamid)
 {
     if (CoopPeerStarter.Dedicated && CoopSteamClientStarter.IsAdmin)
     {
         CoopAdminCommand.Send("ban", steamid.ToString());
     }
     else
     {
         BoltEntity entityFromSteamID = MpPlayerList.GetEntityFromSteamID(steamid);
         if (entityFromSteamID)
         {
             CoopKick.BanPlayer(entityFromSteamID);
             base.Invoke("Refresh", 0.1f);
         }
     }
 }
コード例 #9
0
 public void KickByName(string name)
 {
     if (CoopPeerStarter.Dedicated && CoopSteamClientStarter.IsAdmin)
     {
         CoopAdminCommand.Send("kick", name);
     }
     else
     {
         BoltEntity entityFromName = MpPlayerList.GetEntityFromName(name, null);
         if (entityFromName)
         {
             CoopKick.KickPlayer(entityFromName, -1, "HOST_KICKED_YOU");
             base.Invoke("Refresh", 0.1f);
         }
     }
 }
コード例 #10
0
 public void Kick(ulong steamid)
 {
     if (CoopPeerStarter.Dedicated && CoopSteamClientStarter.IsAdmin)
     {
         CoopAdminCommand.Send("kick", steamid.ToString());
     }
     else
     {
         BoltEntity entityFromSteamID = MpPlayerList.GetEntityFromSteamID(steamid);
         if (entityFromSteamID)
         {
             CoopKick.KickPlayer(entityFromSteamID, -1, "HOST_KICKED_YOU");
             base.Invoke("Refresh", 0.1f);
         }
     }
 }
コード例 #11
0
    public static void Recv(string command, string data, BoltConnection source)
    {
        if (CoopPeerStarter.DedicatedHost && source.IsDedicatedServerAdmin() && command != null)
        {
            if (CoopAdminCommand.< > f__switch$map2 == null)
            {
                CoopAdminCommand.< > f__switch$map2 = new Dictionary <string, int>(12)
                {
                    {
                        "save",
                        0
                    },
                    {
                        "restart",
                        1
                    },
                    {
                        "shutdown",
                        2
                    },
                    {
                        "openlogs",
                        3
                    },
                    {
                        "closelogs",
                        4
                    },
                    {
                        "kick",
                        5
                    },
                    {
                        "ban",
                        6
                    },
                    {
                        "unban",
                        7
                    },
                    {
                        "treeregrowmode",
                        8
                    },
                    {
                        "allowbuildingdestruction",
                        9
                    },
                    {
                        "allowenemiescreative",
                        10
                    },
                    {
                        "allowcheats",
                        11
                    }
                };
            }
            int num;
            if (CoopAdminCommand.< > f__switch$map2.TryGetValue(command, out num))
            {
                switch (num)
                {
                case 0:
                {
                    int slot;
                    if (!string.IsNullOrEmpty(data) && int.TryParse(data, out slot))
                    {
                        GameSetup.SetSlot((Slots)slot);
                    }
                    LevelSerializer.Checkpoint();
                    SaveSlotUtils.SaveHostGameGUID();
                    CoopAdminCommand.SendNetworkMessage("Game saved to slot " + (int)GameSetup.Slot, source);
                    break;
                }

                case 1:
                    CoopAdminCommand.SendNetworkMessageAll("Server shuting down for restart, please reconnect.");
                    TheForest.Utils.Scene.ActiveMB.StartCoroutine(CoopAdminCommand.ShutDownRoutine(true));
                    break;

                case 2:
                    CoopAdminCommand.SendNetworkMessageAll("Server is shuting down (no restart)");
                    TheForest.Utils.Scene.ActiveMB.StartCoroutine(CoopAdminCommand.ShutDownRoutine(false));
                    break;

                case 3:
                    if (!SteamDSConfig.ShowLogs)
                    {
                        ConsoleWriter.Open();
                        if (CoopAdminCommand.< > f__mg$cache0 == null)
                        {
                            CoopAdminCommand.< > f__mg$cache0 = new Application.LogCallback(CoopAdminCommand.Application_logMessageReceived);
                        }
                        Application.logMessageReceived += CoopAdminCommand.< > f__mg$cache0;
                        SteamDSConfig.ShowLogs          = true;
                        CoopAdminCommand.SendNetworkMessage("Opened logs console", source);
                    }
                    else
                    {
                        CoopAdminCommand.SendNetworkMessage("Error: console already opened", source);
                    }
                    break;

                case 4:
                    ConsoleWriter.Close();
                    if (CoopAdminCommand.< > f__mg$cache1 == null)
                    {
                        CoopAdminCommand.< > f__mg$cache1 = new Application.LogCallback(CoopAdminCommand.Application_logMessageReceived);
                    }
                    Application.logMessageReceived -= CoopAdminCommand.< > f__mg$cache1;
                    SteamDSConfig.ShowLogs          = false;
                    CoopAdminCommand.SendNetworkMessage("Closed logs console", source);
                    break;

                case 5:
                {
                    ulong num2;
                    if (ulong.TryParse(data, out num2))
                    {
                        BoltEntity entityFromSteamID = MpPlayerList.GetEntityFromSteamID(num2);
                        if (entityFromSteamID)
                        {
                            CoopKick.KickPlayer(entityFromSteamID, 1, "ADMIN_KICKED_YOU");
                            CoopAdminCommand.SendNetworkMessage("Kicked " + data, source);
                        }
                        else
                        {
                            CoopAdminCommand.SendNetworkMessage("Failed to kick " + data, source);
                        }
                    }
                    else
                    {
                        BoltEntity entityFromName = MpPlayerList.GetEntityFromName(data, source);
                        if (entityFromName)
                        {
                            CoopKick.KickPlayer(entityFromName, 1, "ADMIN_KICKED_YOU");
                            CoopAdminCommand.SendNetworkMessage("Kicked " + data, source);
                        }
                        else
                        {
                            CoopAdminCommand.SendNetworkMessage("Invalid SteamId or Name, kick failed (data=" + data + ")", source);
                        }
                    }
                    break;
                }

                case 6:
                {
                    ulong num2;
                    if (ulong.TryParse(data, out num2))
                    {
                        BoltEntity entityFromSteamID2 = MpPlayerList.GetEntityFromSteamID(num2);
                        if (entityFromSteamID2)
                        {
                            CoopKick.BanPlayer(entityFromSteamID2);
                            CoopAdminCommand.SendNetworkMessage("Banned " + data, source);
                        }
                        else
                        {
                            CoopAdminCommand.SendNetworkMessage("Failed to ban " + data, source);
                        }
                    }
                    else
                    {
                        BoltEntity entityFromName2 = MpPlayerList.GetEntityFromName(data, source);
                        if (entityFromName2)
                        {
                            CoopKick.BanPlayer(entityFromName2);
                            CoopAdminCommand.SendNetworkMessage("Banned " + data, source);
                        }
                        else
                        {
                            CoopAdminCommand.SendNetworkMessage("Invalid SteamId or Name, ban failed (data=" + data + ")", source);
                        }
                    }
                    break;
                }

                case 7:
                {
                    ulong num2;
                    if (ulong.TryParse(data, out num2))
                    {
                        CoopKick.UnBanPlayer(num2);
                        CoopAdminCommand.SendNetworkMessage("Unbanned " + data, source);
                    }
                    else if (CoopKick.UnBanPlayer(data))
                    {
                        CoopAdminCommand.SendNetworkMessage("Unbanned " + data, source);
                    }
                    else
                    {
                        CoopAdminCommand.SendNetworkMessage("Invalid SteamId or Name, unban failed (data=" + data + ")", source);
                    }
                    break;
                }

                case 8:
                    if (data == "on")
                    {
                        SteamDSConfig.TreeRegrowMode = true;
                        PlayerPreferences.SetLocalTreeRegrowth(SteamDSConfig.TreeRegrowMode);
                        CoopAdminCommand.SendNetworkMessage("TreeRegrowMode set to on", source);
                    }
                    else if (data == "off")
                    {
                        SteamDSConfig.TreeRegrowMode = false;
                        PlayerPreferences.SetLocalTreeRegrowth(SteamDSConfig.TreeRegrowMode);
                        CoopAdminCommand.SendNetworkMessage("TreeRegrowMode set to off", source);
                    }
                    else
                    {
                        CoopAdminCommand.SendNetworkMessage("Invalid parameter (data=" + data + ")", source);
                    }
                    break;

                case 9:
                    if (data == "on")
                    {
                        SteamDSConfig.AllowBuildingDestruction = true;
                        PlayerPreferences.SetLocalNoDestructionMode(!SteamDSConfig.AllowBuildingDestruction);
                        CoopAdminCommand.SendNetworkMessage("allowbuildingdestruction set to on", source);
                    }
                    else if (data == "off")
                    {
                        SteamDSConfig.AllowBuildingDestruction = false;
                        PlayerPreferences.SetLocalNoDestructionMode(!SteamDSConfig.AllowBuildingDestruction);
                        CoopAdminCommand.SendNetworkMessage("allowbuildingdestruction set to off", source);
                    }
                    else
                    {
                        CoopAdminCommand.SendNetworkMessage("Invalid parameter (data=" + data + ")", source);
                    }
                    break;

                case 10:
                    if (data == "on")
                    {
                        SteamDSConfig.AllowEnemiesCreative = true;
                        PlayerPreferences.SetLocalAllowEnemiesCreativeMode(SteamDSConfig.AllowEnemiesCreative);
                        CoopAdminCommand.SendNetworkMessage("AllowEnemiesCreative set to on", source);
                    }
                    else if (data == "off")
                    {
                        SteamDSConfig.AllowEnemiesCreative = false;
                        PlayerPreferences.SetLocalAllowEnemiesCreativeMode(SteamDSConfig.AllowEnemiesCreative);
                        CoopAdminCommand.SendNetworkMessage("AllowEnemiesCreative set to off", source);
                    }
                    else
                    {
                        CoopAdminCommand.SendNetworkMessage("Invalid parameter (data=" + data + ")", source);
                    }
                    break;

                case 11:
                    if (data == "on")
                    {
                        SteamDSConfig.AllowCheats = true;
                        PlayerPreferences.SetAllowCheatsMode(SteamDSConfig.AllowCheats);
                        CoopAdminCommand.SendNetworkMessage("allowcheats set to on", source);
                    }
                    else if (data == "off")
                    {
                        SteamDSConfig.AllowCheats = false;
                        PlayerPreferences.SetAllowCheatsMode(SteamDSConfig.AllowCheats);
                        CoopAdminCommand.SendNetworkMessage("allowcheats set to off", source);
                    }
                    else
                    {
                        CoopAdminCommand.SendNetworkMessage("Invalid parameter (data=" + data + ")", source);
                    }
                    break;
                }
            }
        }
    }
コード例 #12
0
ファイル: CoopAdminCommand.cs プロジェクト: K07H/The-Forest
 private static void KickPlayer(ulong steamId, BoltConnection source, string message)
 {
     CoopKick.KickPlayer(steamId, 1, message);
     CoopAdminCommand.SendNetworkMessage("Kicked " + steamId, source);
 }
コード例 #13
0
ファイル: CoopAdminCommand.cs プロジェクト: K07H/The-Forest
 private static void BanPlayerByConnectionId(int connectionId, BoltConnection source, string message)
 {
     CoopKick.KickPlayerByConnectionId(connectionId, 0, message);
     CoopAdminCommand.SendNetworkMessage("Banned " + connectionId, source);
 }