Skip to content

Commit

Permalink
Added code
Browse files Browse the repository at this point in the history
  • Loading branch information
AtiLion committed Oct 17, 2017
1 parent ac385fd commit fff5319
Show file tree
Hide file tree
Showing 7 changed files with 450 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,4 @@ __pycache__/
*.btm.cs
*.odx.cs
*.xsd.cs
*.dll
25 changes: 25 additions & 0 deletions CopiedLobbyMess.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2002
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CopiedLobbyMess", "CopiedLobbyMess\CopiedLobbyMess.csproj", "{2656F89B-6390-4A9B-B791-3635D539B12C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2656F89B-6390-4A9B-B791-3635D539B12C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2656F89B-6390-4A9B-B791-3635D539B12C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2656F89B-6390-4A9B-B791-3635D539B12C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2656F89B-6390-4A9B-B791-3635D539B12C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A2C5F465-0F95-4E73-BDB0-E7AEC6968953}
EndGlobalSection
EndGlobal
67 changes: 67 additions & 0 deletions CopiedLobbyMess/Configuration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rocket.API;

namespace CopiedLobbyMess
{
public class Configuration : IRocketPluginConfiguration
{
public bool InvisibleRocket;
public bool HidePlugins;
public bool MessPlugins;
public string[] Plugins;

public bool HideWorkshop;
public bool MessWorkshop;
public string[] Workshop;

public bool MessGamemode;
public string Gamemode;

public bool HideConfig;
public bool MessConfig;
public bool IsPVP;
public bool HasCheats;
public string Difficulty;
public string CameraMode;
public bool GoldOnly;
public bool HasBattleye;
public bool IsVannila;

public void LoadDefaults()
{
InvisibleRocket = false;
HidePlugins = false;
MessPlugins = false;
Plugins = new string[]
{
"Plugins removed by",
"CopiedLobbyMess",
"Thanks AtiLion"
};

HideWorkshop = true;
MessWorkshop = false;
Workshop = new string[]
{
"936182532",
"1112690830"
};

MessGamemode = false;
Gamemode = "Nothing you have ever seen before";

HideConfig = true;
MessConfig = false;
IsPVP = true;
HasCheats = false;
Difficulty = "NORMAL";
CameraMode = "BOTH";
GoldOnly = false;
HasBattleye = true;
IsVannila = false;
}
}
}
230 changes: 230 additions & 0 deletions CopiedLobbyMess/CopiedLobbyMess.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
using System;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rocket.Core;
using Rocket.Core.Plugins;
using Rocket.Core.Logging;
using SDG.Unturned;
using SDG.Framework.Modules;
using Steamworks;

namespace CopiedLobbyMess
{
public class CopiedLobbyMess : RocketPlugin<Configuration>
{
#region Properties
public static CopiedLobbyMess Instance { get; private set; }
#endregion

protected override void Load()
{
R.Plugins.OnPluginsLoaded += OnLoad;
}

protected override void Unload()
{
R.Plugins.OnPluginsLoaded -= OnLoad;
}

#region Functions
public int GetWorkshopCount()
{
string text = string.Empty;
for (int l = 0; l < Provider.serverWorkshopFileIDs.Count; l++)
{
if (text.Length > 0)
{
text += ',';
}
text += Provider.serverWorkshopFileIDs[l];
}
return (text.Length - 1) / 120 + 1;
}

public int GetConfigurationCount()
{
string text2 = string.Empty;
Type type = Provider.modeConfigData.GetType();
FieldInfo[] fields = type.GetFields();
for (int n = 0; n < fields.Length; n++)
{
FieldInfo fieldInfo = fields[n];
object value = fieldInfo.GetValue(Provider.modeConfigData);
Type type2 = value.GetType();
FieldInfo[] fields2 = type2.GetFields();
for (int num7 = 0; num7 < fields2.Length; num7++)
{
FieldInfo fieldInfo2 = fields2[num7];
object value2 = fieldInfo2.GetValue(value);
if (text2.Length > 0)
{
text2 += ',';
}
if (value2 is bool)
{
text2 += ((!(bool)value2) ? "F" : "T");
}
else
{
text2 += value2;
}
}
}
return (text2.Length - 1) / 120 + 1;
}

public void ModifyGameTags()
{
string tags = "";

#region Workshop
if (Configuration.Instance.HideWorkshop)
{
tags += "KROW"; // No workshop
SteamGameServer.SetKeyValue("Browser_Workshop_Count", "0");
}
else if (Configuration.Instance.MessWorkshop)
{
tags += "WORK"; // Workshop

string txt = "";
foreach(string a in Configuration.Instance.Workshop)
{
if (txt.Length > 0)
txt += ",";
txt += a;
}
SteamGameServer.SetKeyValue("Browser_Workshop_Count", ((txt.Length - 1) / 120 + 1).ToString());

int num5 = 0;
for (int m = 0; m < txt.Length; m += 120)
{
int num6 = 120;
if (m + num6 > txt.Length)
{
num6 = txt.Length - m;
}
string pValue2 = txt.Substring(m, num6);
SteamGameServer.SetKeyValue("Browser_Workshop_Line_" + num5, pValue2);
num5++;
}
}
else
{
if(Provider.serverWorkshopFileIDs.Count <= 0)
{
tags += "KROW";
}
else
{
tags += "WORK"; // Workshop
SteamGameServer.SetKeyValue("Browser_Workshop_Count", GetWorkshopCount().ToString());
}
}
#endregion

#region Gamemode
if (Configuration.Instance.MessGamemode)
tags += ",GAMEMODE:" + Configuration.Instance.Gamemode;
else if (Provider.gameMode != null)
tags += ",GAMEMODE:" + Provider.gameMode.GetType().Name;
#endregion

#region Config
if (Configuration.Instance.MessConfig)
{
tags += ",";
if (Configuration.Instance.IsPVP)
tags += "PVP";
else
tags += "PVE";
tags += ",";
if (Configuration.Instance.HasCheats)
tags += "CHEATS";
else
tags += "STAEHC";
tags += ",";
tags += Configuration.Instance.Difficulty;
tags += ",";
tags += Configuration.Instance.CameraMode;
tags += ",";
if (Configuration.Instance.GoldOnly)
tags += "GOLDONLY";
else
tags += "YLNODLOG";
tags += ",";
if (Configuration.Instance.HasBattleye)
tags += "BATTLEYE_ON";
else
tags += "BATTLEYE_OFF";
}
else
{
tags += ",";
tags += (!Provider.isPvP) ? "PVE" : "PVP";
tags += ",";
tags += (!Provider.hasCheats) ? "STAEHC" : "CHEATS";
tags += ",";
tags += Provider.mode.ToString();
tags += ",";
tags += Provider.cameraMode.ToString();
tags += ",";
tags += (!Provider.isGold) ? "YLNODLOG" : "GOLDONLY";
tags += ",";
tags += (!Provider.configData.Server.BattlEye_Secure) ? "BATTLEYE_OFF" : "BATTLEYE_ON";
}
#endregion

#region Configuration
if (Configuration.Instance.HideConfig)
SteamGameServer.SetKeyValue("Browser_Config_Count", "0");
else
SteamGameServer.SetKeyValue("Browser_Config_Count", GetConfigurationCount().ToString());
#endregion

SteamGameServer.SetGameTags(tags);

#region Plugins
if (Configuration.Instance.InvisibleRocket)
SteamGameServer.SetBotPlayerCount(0); // Bypasses unturned's filter for rocket <3

if (!Configuration.Instance.HidePlugins)
{
if (Configuration.Instance.MessPlugins)
SteamGameServer.SetKeyValue("rocketplugins", string.Join(",", Configuration.Instance.Plugins));
else
SteamGameServer.SetKeyValue("rocketplugins", string.Join(",", R.Plugins.GetPlugins().Select(p => p.Name).ToArray()));
}
else
{
SteamGameServer.SetKeyValue("rocketplugins", "");
}

if (Configuration.Instance.IsVannila)
{
SteamGameServer.SetBotPlayerCount(0);
SteamGameServer.SetKeyValue("rocketplugins", "");
SteamGameServer.SetKeyValue("rocket", "");
}
else
{
if (!Configuration.Instance.InvisibleRocket)
SteamGameServer.SetBotPlayerCount(1);
if (!Configuration.Instance.HidePlugins && !Configuration.Instance.MessPlugins)
SteamGameServer.SetKeyValue("rocketplugins", string.Join(",", R.Plugins.GetPlugins().Select(p => p.Name).ToArray()));
SteamGameServer.SetKeyValue("rocket", ModuleHook.modules.FirstOrDefault(a => a.config.Name == "Rocket.Unturned").config.Version);
}
#endregion
}
#endregion

#region Event Functions
void OnLoad()
{
ModifyGameTags();
}
#endregion
}
}
64 changes: 64 additions & 0 deletions CopiedLobbyMess/CopiedLobbyMess.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2656F89B-6390-4A9B-B791-3635D539B12C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CopiedLobbyMess</RootNamespace>
<AssemblyName>CopiedLobbyMess</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\Libraries\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\Libraries\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Rocket.API">
<HintPath>..\Libraries\Rocket.API.dll</HintPath>
</Reference>
<Reference Include="Rocket.Core">
<HintPath>..\Libraries\Rocket.Core.dll</HintPath>
</Reference>
<Reference Include="Rocket.Unturned">
<HintPath>..\Libraries\Rocket.Unturned.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>..\Libraries\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration.cs" />
<Compile Include="CopiedLobbyMess.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Loading

0 comments on commit fff5319

Please sign in to comment.