Skip to content

Commit

Permalink
#1 added SSS
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoniofo committed Jan 12, 2025
1 parent c02ae71 commit b3eac99
Show file tree
Hide file tree
Showing 29 changed files with 39,750 additions and 39,491 deletions.
48 changes: 27 additions & 21 deletions AutoBadge/AutoBadge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,54 +34,60 @@
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ExMod.Exiled.9.2.2\lib\net48\Assembly-CSharp-Publicized.dll</HintPath>
<Reference Include="Assembly-CSharp">
<HintPath>$(EXILED_REFERENCES)\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="CommandSystem.Core, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ExMod.Exiled.9.2.2\lib\net48\CommandSystem.Core.dll</HintPath>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>$(EXILED_REFERENCES)\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Exiled.API, Version=9.2.2.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.2.2\lib\net48\Exiled.API.dll</HintPath>
<Reference Include="CommandSystem.Core">
<HintPath>$(EXILED_REFERENCES)\CommandSystem.Core.dll</HintPath>
</Reference>
<Reference Include="Exiled.CreditTags, Version=9.2.2.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.2.2\lib\net48\Exiled.CreditTags.dll</HintPath>
<Reference Include="Exiled.API, Version=9.3.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.3.0\lib\net48\Exiled.API.dll</HintPath>
</Reference>
<Reference Include="Exiled.CustomItems, Version=9.2.2.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.2.2\lib\net48\Exiled.CustomItems.dll</HintPath>
<Reference Include="Exiled.CreditTags, Version=9.3.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.3.0\lib\net48\Exiled.CreditTags.dll</HintPath>
</Reference>
<Reference Include="Exiled.CustomRoles, Version=9.2.2.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.2.2\lib\net48\Exiled.CustomRoles.dll</HintPath>
<Reference Include="Exiled.CustomItems, Version=9.3.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.3.0\lib\net48\Exiled.CustomItems.dll</HintPath>
</Reference>
<Reference Include="Exiled.Events, Version=9.2.2.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.2.2\lib\net48\Exiled.Events.dll</HintPath>
<Reference Include="Exiled.CustomRoles, Version=9.3.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.3.0\lib\net48\Exiled.CustomRoles.dll</HintPath>
</Reference>
<Reference Include="Exiled.Loader, Version=9.2.2.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.2.2\lib\net48\Exiled.Loader.dll</HintPath>
<Reference Include="Exiled.Events, Version=9.3.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.3.0\lib\net48\Exiled.Events.dll</HintPath>
</Reference>
<Reference Include="Exiled.Permissions, Version=9.2.2.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.2.2\lib\net48\Exiled.Permissions.dll</HintPath>
<Reference Include="Exiled.Loader, Version=9.3.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.3.0\lib\net48\Exiled.Loader.dll</HintPath>
</Reference>
<Reference Include="Exiled.Permissions, Version=9.3.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.3.0\lib\net48\Exiled.Permissions.dll</HintPath>
</Reference>
<Reference Include="Mirror">
<HintPath>$(EXILED_REFERENCES)\Mirror.dll</HintPath>
</Reference>
<Reference Include="NorthwoodLib, Version=1.3.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ExMod.Exiled.9.2.2\lib\net48\NorthwoodLib.dll</HintPath>
<HintPath>..\packages\ExMod.Exiled.9.3.0\lib\net48\NorthwoodLib.dll</HintPath>
</Reference>
<Reference Include="PluginAPI, Version=13.1.5.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.2.2\lib\net48\PluginAPI.dll</HintPath>
<HintPath>..\packages\ExMod.Exiled.9.3.0\lib\net48\PluginAPI.dll</HintPath>
</Reference>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Xml"/>
<Reference Include="Unity.TextMeshPro">
<HintPath>$(EXILED_REFERENCES)\Unity.TextMeshPro.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>$(EXILED_REFERENCES)\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>$(EXILED_REFERENCES)\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
<HintPath>..\packages\ExMod.Exiled.9.2.2\lib\net48\YamlDotNet.dll</HintPath>
<HintPath>..\packages\ExMod.Exiled.9.3.0\lib\net48\YamlDotNet.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
91 changes: 73 additions & 18 deletions AutoBadge/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,92 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using CommandSystem;
using Exiled.API.Features;
using Exiled.API.Features.Core.UserSettings;
using Exiled.API.Interfaces;
using Exiled.Events.EventArgs.Player;
using UnityEngine;
using UserSettings.ServerSpecific;


namespace AutoBadge
{
public class Plugin : Plugin<Config>
public class Plugin : Plugin<Config, Translation>
{
public override string Name { get; } = "AutoBadge";
public override string Author { get; } = "Antoniofo";
public override Version Version { get; } = new Version(1, 0, 0);
public override Version RequiredExiledVersion { get; } = new Version(9, 2, 2);
public override Version Version { get; } = new Version(1, 1, 0);
public override Version RequiredExiledVersion { get; } = new Version(9, 3, 0);
public static Plugin Instance = null;

public override void OnEnabled()
{
Instance = this;
Exiled.Events.Handlers.Player.Verified += OnVerified;
ServerSpecificSettingsSync.ServerOnSettingValueReceived += OnSetting;
HeaderSetting header = new HeaderSetting("AutoBadge");
IEnumerable<SettingBase> setttings = new SettingBase[]
{
new ButtonSetting(Config.ButtonId, Translation.Label, Translation.ButtonText,
hintDescription: Translation.HintDescription, header: header)
};
SettingBase.Register(setttings);
SettingBase.SendToAll();
base.OnEnabled();
}

public override void OnDisabled()
{
Exiled.Events.Handlers.Player.Verified -= OnVerified;
ServerSpecificSettingsSync.ServerOnSettingValueReceived -= OnSetting;
Instance = null;
base.OnDisabled();
}


private void OnSetting(ReferenceHub hub, ServerSpecificSettingBase settings)
{
if (!Player.TryGet(hub, out Player ply))
{
return;
}

if (settings is SSButton button && button.SettingId == Config.ButtonId &&
button.SyncLastPress.IsRunning == true)
{
if (ply.Group is null || ply.Group.BadgeText.Equals(Server.PermissionsHandler
.GetGroup(Config.SpecialGroup)?
.BadgeText))
{
string playername = ply.Nickname.ToLower();
foreach (var word in Config.MagicWords)
{
if (playername.Contains(word.ToLower()))
{
if (Server.PermissionsHandler.GetGroup(Config.SpecialGroup) == null)
{
Log.Warn("The group " + Config.SpecialGroup + " doesn't exist.");
}

ply.Group = Server.PermissionsHandler.GetGroup(Config.SpecialGroup);
}
}
}
}
}

private void OnVerified(VerifiedEventArgs ev)
{
if (ev.Player.Group is null)
ServerSpecificSettingsSync.SendToPlayer(ev.Player?.ReferenceHub);
if (ev.Player?.Group is null)
{
string playername = ev.Player.Nickname.ToLower();
foreach (var word in Config.MagicWords)
{
if (playername.Contains(word.ToLower()))
{
ev.Player.Group = Server.PermissionsHandler.GetGroup(Config.SpecialGroup);
}
}
}
}
}
Expand All @@ -52,10 +97,21 @@ public class Config : IConfig
public bool IsEnabled { get; set; } = true;
public bool Debug { get; set; } = false;

public List<string> MagicWords { get; set; } = new List<string>() {"pepper"};
public List<string> MagicWords { get; set; } = new List<string>() { "pepper" };
public string SpecialGroup { get; set; } = "frog";

[Description("Please change this if another setting has the same id")]
public int ButtonId { get; set; } = 667;
}

public class Translation : ITranslation
{
public string Label { get; set; } = "Reload my badge";
public string ButtonText { get; set; } = "Reload";
public string HintDescription { get; set; } = "Reload your autobadge if you name contains a magic word.";
}


[CommandHandler(typeof(ClientCommandHandler))]
public class SpecialGroup : ICommand
{
Expand All @@ -71,35 +127,34 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
response = "Your are the DEDICATED_SERVER WTF DO YOU MEAN";
return false;
}

if (ply.Group is null || ply.Group.BadgeText.Equals(Server.PermissionsHandler.GetGroup(Plugin.Instance.Config.SpecialGroup)

if (ply.Group is null || ply.Group.BadgeText.Equals(Server.PermissionsHandler
.GetGroup(Plugin.Instance.Config.SpecialGroup)?
.BadgeText))
{

string playername = ply.Nickname.ToLower();
foreach (var word in Plugin.Instance.Config.MagicWords)
{
if (playername.Contains(word.ToLower()))
{
if (Server.PermissionsHandler.GetGroup(Plugin.Instance.Config.SpecialGroup) == null)
{
response = "The group doesn't exist contact staff";
Log.Warn("The group " + Plugin.Instance.Config.SpecialGroup + " doesn't exist.");
response = "The group " + Plugin.Instance.Config.SpecialGroup +
" doesn't exist. please contact staff";
return false;
}

ply.Group = Server.PermissionsHandler.GetGroup(Plugin.Instance.Config.SpecialGroup);
response = "Your group has been refreshed";
return true;
}
else
{
response = "Your name does not contain the magic word";
return false;
}
}


response = "Your name does not contain the magic word";
return false;
}

response = "Your already are in a group and can't be in two at the same time";
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion AutoBadge/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ExMod.Exiled" version="9.2.2" targetFramework="net481" />
<package id="ExMod.Exiled" version="9.3.0" targetFramework="net481" />
</packages>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit b3eac99

Please sign in to comment.