Skip to content

Commit

Permalink
updated for latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
ExtraJuiceMan committed Jun 4, 2018
1 parent fff5319 commit 78b521b
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 145 deletions.
10 changes: 5 additions & 5 deletions CopiedLobbyMess/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Configuration : IRocketPluginConfiguration
public string CameraMode;
public bool GoldOnly;
public bool HasBattleye;
public bool IsVannila;
public bool IsVanilla;

public void LoadDefaults()
{
Expand All @@ -39,7 +39,7 @@ public void LoadDefaults()
{
"Plugins removed by",
"CopiedLobbyMess",
"Thanks AtiLion"
"AtiLion is gay"
};

HideWorkshop = true;
Expand All @@ -57,11 +57,11 @@ public void LoadDefaults()
MessConfig = false;
IsPVP = true;
HasCheats = false;
Difficulty = "NORMAL";
CameraMode = "BOTH";
Difficulty = "NRM";
CameraMode = "2p";
GoldOnly = false;
HasBattleye = true;
IsVannila = false;
IsVanilla = false;
}
}
}
200 changes: 60 additions & 140 deletions CopiedLobbyMess/CopiedLobbyMess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,178 +14,104 @@ 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;
}
if (Level.isLoaded)
ModifyLobbyInfo();

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

protected override void Unload() => Level.onPostLevelLoaded -= OnPostLevelLoaded;

#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 static int GetWorkshopCount() =>
(String.Join(",", Provider.serverWorkshopFileIDs.Select(x => x.ToString()).ToArray()).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 static int GetConfigurationCount() =>
(String.Join(",", typeof(ModeConfigData).GetFields()
.SelectMany(x => x.GetValue(Provider.modeConfigData).GetType().GetFields().Select(y => y.GetValue(x.GetValue(Provider.modeConfigData))))
.Select(x => x is bool v ? v ? "T" : "F" : (String.Empty + x)).ToArray()).Length - 1) / 120 + 1;


public void OnPostLevelLoaded(int xd) => ModifyLobbyInfo();

public void ModifyGameTags()
private void ModifyLobbyInfo()
{
string tags = "";
bool workshop = Provider.serverWorkshopFileIDs.Count > 0;

#region Workshop
if (Configuration.Instance.HideWorkshop)
{
tags += "KROW"; // No workshop
workshop = false;
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;
}
workshop = true;
string txt = String.Join(",", Configuration.Instance.Workshop);
SteamGameServer.SetKeyValue("Browser_Workshop_Count", ((txt.Length - 1) / 120 + 1).ToString());

int num5 = 0;
for (int m = 0; m < txt.Length; m += 120)
int line = 0;
for (int i = 0; i < txt.Length; i += 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++;

if (i + num6 > txt.Length)
num6 = txt.Length - i;

string pValue2 = txt.Substring(i, num6);
SteamGameServer.SetKeyValue("Browser_Workshop_Line_" + line, pValue2);
line++;
}
}
else
{
if(Provider.serverWorkshopFileIDs.Count <= 0)
{
tags += "KROW";
}
else
{
tags += "WORK"; // Workshop
SteamGameServer.SetKeyValue("Browser_Workshop_Count", GetWorkshopCount().ToString());
}
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
string tags = "";

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";
tags += String.Concat(new string[]
{
Configuration.Instance.IsPVP ? "PVP" : "PVE",
",<gm>",
Configuration.Instance.MessGamemode ? Configuration.Instance.Gamemode : Provider.gameMode.GetType().Name,
"</gm>,",
Configuration.Instance.HasCheats ? "CHy" : "CHn",
",",
Configuration.Instance.Difficulty,
",",
Configuration.Instance.CameraMode,
",",
workshop ? "WSn" : "WSy",
",",
Configuration.Instance.GoldOnly ? "GLD" : "F2P",
",",
Configuration.Instance.HasBattleye ? "BEy" : "BEn"
});

if (!String.IsNullOrEmpty(Provider.configData.Browser.Thumbnail))
tags += ",<tn>" + Provider.configData.Browser.Thumbnail + "</tn>";


SteamGameServer.SetGameTags(tags);
}

#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
Expand All @@ -202,7 +128,7 @@ public void ModifyGameTags()
SteamGameServer.SetKeyValue("rocketplugins", "");
}

if (Configuration.Instance.IsVannila)
if (Configuration.Instance.IsVanilla)
{
SteamGameServer.SetBotPlayerCount(0);
SteamGameServer.SetKeyValue("rocketplugins", "");
Expand All @@ -214,17 +140,11 @@ public void ModifyGameTags()
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);
string version = ModuleHook.modules.FirstOrDefault(a => a.config.Name == "Rocket.Unturned")?.config.Version ?? "0.0.0.69";
SteamGameServer.SetKeyValue("rocket", version);
}
#endregion
}
#endregion

#region Event Functions
void OnLoad()
{
ModifyGameTags();
}
#endregion
}
}

0 comments on commit 78b521b

Please sign in to comment.