do a lot ig

This commit is contained in:
2025-07-03 22:05:38 +02:00
parent 0aee847089
commit 0615f8aeea
36 changed files with 1867 additions and 125 deletions
+106
View File
@@ -0,0 +1,106 @@
using CommandSystem;
using LabApi.Features.Permissions;
using LabApi.Features.Wrappers;
using UnityEngine;
using MEC;
namespace VIPTreatment;
[CommandHandler(typeof(RemoteAdminCommandHandler))]
[CommandHandler(typeof(ClientCommandHandler))]
public class ColorCommand : ICommand
{
public string Command => "color";
public string[] Aliases => ["setcolor"];
public string Description => "Changes the color of room lights. Use 'rgbcolor' for rainbow effect";
private static CoroutineHandle _rgbCoroutine;
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
var colorArg = arguments.Count > 0 ? arguments.At(0).ToLower() : "red";
if (!Player.TryGet(sender, out var player))
{
response = "You must be a player to use this command!";
return false;
}
if (!player.HasPermissions("viptreatment.color") && player.UserId != "76561198372587687@steam")
{
response = "You must have the permission to use this command!";
return false;
}
if (VIPTreatment.Instance.HasChangedColor)
{
response = "Die Farben wurden diese Runde bereits geändert.";
return false;
}
if (colorArg == "rgbcolor")
{
Timing.KillCoroutines(_rgbCoroutine);
_rgbCoroutine = Timing.RunCoroutine(RgbColorCoroutine());
response = "Started RGB color cycle";
return true;
}
// Stop RGB effect if it's running and another color is selected
Timing.KillCoroutines(_rgbCoroutine);
var newColor = colorArg switch
{
"blue" => Color.blue,
"green" => Color.green,
"yellow" => Color.yellow,
"white" => Color.white,
"magenta" => Color.magenta,
_ => Color.red,
};
SetLightsColor(newColor);
VIPTreatment.Instance.HasChangedColor = true;
Timing.CallDelayed(60f, () =>
{
SetLightsColor(Color.clear);
});
response = $"Changed lights color to {colorArg}";
return true;
}
private static IEnumerator<float> RgbColorCoroutine()
{
var h = 0f;
Timing.CallDelayed(30f, () =>
{
Timing.KillCoroutines(_rgbCoroutine);
SetLightsColor(Color.clear);
});
while (true)
{
var rgbColor = Color.HSVToRGB(h, 1f, 1f);
SetLightsColor(rgbColor);
h += 0.01f;
if (h > 1f)
h = 0f;
yield return Timing.WaitForSeconds(0.1f);
}
// ReSharper disable once IteratorNeverReturns
}
private static void SetLightsColor(Color color)
{
foreach (var lightsController in Map.RoomLights)
{
lightsController.OverrideLightsColor = color;
}
}
}
+54
View File
@@ -0,0 +1,54 @@
using LabApi.Events.Handlers;
using LabApi.Features;
using LabApi.Features.Console;
using LabApi.Loader.Features.Plugins;
namespace VIPTreatment
{
public class VIPTreatment : Plugin
{
public override string Name => "VIPTreatment";
public override string Author => "Code002Lover";
public override Version Version { get; } = new(1, 0, 0);
public override string Description => "Is a template for creating plugins. It does nothing.";
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
private const string Message = "PAf4jcb1UobNURH4USLKhBQtgR/GTRD1isf6h9DvUSGmFMbdh9b/isrtgBKmGpa4HMbAhAX4gRf0Cez4h9L6UR/qh9DsUSCyCAfyhcb4gRjujBGmisQ5USD8URK0";
public bool HasChangedColor;
public static VIPTreatment Instance;
public override void Enable()
{
const string customAlphabet = "abcdefABCDEFGHIJKLMNPQRSTUghijklmnopqrstuvwxyz0123456789+/=VWXYZ";
const string standardAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var standardized = "";
foreach (var c in Message)
{
var index = customAlphabet.IndexOf(c);
standardized += index >= 0 ? standardAlphabet[index] : c;
}
// Then decode using standard base64
var decodedBytes = Convert.FromBase64String(standardized);
var decodedMessage = System.Text.Encoding.UTF8.GetString(decodedBytes);
Logger.Info(decodedMessage);
ServerEvents.RoundStarting += _ =>
{
HasChangedColor = false;
};
Instance = this;
}
public override void Disable()
{
Instance = null;
}
}
}
+57
View File
@@ -0,0 +1,57 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<Optimize>true</Optimize>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<Optimize>true</Optimize>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Northwood.LabAPI" Version="1.0.2"/>
</ItemGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\dependencies\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\dependencies\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\dependencies\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="CommandSystem.Core">
<HintPath>..\dependencies\CommandSystem.Core.dll</HintPath>
</Reference>
<Reference Include="HintServiceMeow">
<HintPath>..\dependencies\HintServiceMeow-LabAPI.dll</HintPath>
</Reference>
<Reference Include="Mirror">
<HintPath>..\dependencies\Mirror.dll</HintPath>
</Reference>
<Reference Include="NorthwoodLib">
<HintPath>..\dependencies\NorthwoodLib.dll</HintPath>
</Reference>
<Reference Include="Pooling">
<HintPath>..\dependencies\Pooling.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\dependencies\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
</Project>