mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-11 15:52:25 -05:00
fixed issue with not escaping regex for validating commands
This commit is contained in:
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
using SharedLibrary.Network;
|
||||
using SharedLibrary.Objects;
|
||||
using SharedLibrary.Helpers;
|
||||
using SharedLibrary.Configuration;
|
||||
|
||||
namespace Welcome_Plugin
|
||||
{
|
||||
@ -64,11 +65,17 @@ namespace Welcome_Plugin
|
||||
|
||||
public string Name => "Welcome Plugin";
|
||||
|
||||
private Dictionary<int, ConfigurationManager> Configs;
|
||||
private BaseConfigurationHandler<WelcomeConfiguration> Config;
|
||||
|
||||
public async Task OnLoadAsync(IManager manager)
|
||||
{
|
||||
await Task.FromResult(Configs = new Dictionary<int, ConfigurationManager>());
|
||||
// load custom configuration
|
||||
Config = new BaseConfigurationHandler<WelcomeConfiguration>("WelcomePluginSettings");
|
||||
if (Config.Configuration() == null)
|
||||
{
|
||||
Config.Set((WelcomeConfiguration)new WelcomeConfiguration().Generate());
|
||||
await Config.Save();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OnUnloadAsync()
|
||||
@ -84,39 +91,15 @@ namespace Welcome_Plugin
|
||||
if (E.Type == Event.GType.Connect)
|
||||
{
|
||||
Player newPlayer = E.Origin;
|
||||
var cfg = Configs[S.GetHashCode()];
|
||||
if (newPlayer.Level >= Player.Permission.Trusted && !E.Origin.Masked)
|
||||
await E.Owner.Broadcast(ProcessAnnouncement(cfg.GetProperty<string>("PrivilegedAnnouncementMessage"), newPlayer));
|
||||
await E.Owner.Broadcast(ProcessAnnouncement(Config.Configuration().PrivilegedAnnouncementMessage, newPlayer));
|
||||
|
||||
await newPlayer.Tell(ProcessAnnouncement(cfg.GetProperty<string>("UserWelcomeMessage"), newPlayer));
|
||||
await newPlayer.Tell(ProcessAnnouncement(Config.Configuration().UserWelcomeMessage, newPlayer));
|
||||
|
||||
if (newPlayer.Level == Player.Permission.Flagged)
|
||||
await E.Owner.ToAdmins($"^1NOTICE: ^7Flagged player ^5{newPlayer.Name} ^7has joined!");
|
||||
else
|
||||
await E.Owner.Broadcast(ProcessAnnouncement(cfg.GetProperty<string>("UserAnnouncementMessage"), newPlayer));
|
||||
}
|
||||
|
||||
if (E.Type == Event.GType.Start)
|
||||
{
|
||||
var cfg = new ConfigurationManager(S);
|
||||
Configs.Add(S.GetHashCode(), cfg);
|
||||
if (cfg.GetProperty<string>("UserWelcomeMessage") == null)
|
||||
{
|
||||
string welcomeMsg = "Welcome ^5{{ClientName}}^7, this is your ^5{{TimesConnected}} ^7time connecting!";
|
||||
cfg.AddProperty(new KeyValuePair<string, dynamic>("UserWelcomeMessage", welcomeMsg));
|
||||
}
|
||||
|
||||
if (cfg.GetProperty<string>("PrivilegedAnnouncementMessage") == null)
|
||||
{
|
||||
string annoucementMsg = "{{ClientLevel}} {{ClientName}} has joined the server";
|
||||
cfg.AddProperty(new KeyValuePair<string, dynamic>("PrivilegedAnnouncementMessage", annoucementMsg));
|
||||
}
|
||||
|
||||
if (cfg.GetProperty<string>("UserAnnouncementMessage") == null)
|
||||
{
|
||||
string annoucementMsg = "^5{{ClientName}} ^7hails from ^5{{ClientLocation}}";
|
||||
cfg.AddProperty(new KeyValuePair<string, dynamic>("UserAnnouncementMessage", annoucementMsg));
|
||||
}
|
||||
await E.Owner.Broadcast(ProcessAnnouncement(Config.Configuration().UserAnnouncementMessage, newPlayer));
|
||||
}
|
||||
}
|
||||
|
||||
|
26
Plugins/Welcome/WelcomeConfiguration.cs
Normal file
26
Plugins/Welcome/WelcomeConfiguration.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using SharedLibrary.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Welcome_Plugin
|
||||
{
|
||||
class WelcomeConfiguration : IBaseConfiguration
|
||||
{
|
||||
public string UserAnnouncementMessage { get; set; }
|
||||
public string UserWelcomeMessage { get; set; }
|
||||
public string PrivilegedAnnouncementMessage { get; set; }
|
||||
|
||||
public IBaseConfiguration Generate()
|
||||
{
|
||||
UserAnnouncementMessage = "^5{{ClientName}} ^7hails from ^5{{ClientLocation}}";
|
||||
UserWelcomeMessage = "Welcome ^5{{ClientName}}^7, this is your ^5{{TimesConnected}} ^7time connecting!";
|
||||
PrivilegedAnnouncementMessage = "{{ClientLevel}} {{ClientName}} has joined the server";
|
||||
return this;
|
||||
}
|
||||
|
||||
public string Name() => "WelcomeConfiguration";
|
||||
}
|
||||
}
|
@ -120,6 +120,7 @@
|
||||
<Compile Include="CountryLookup.cs" />
|
||||
<Compile Include="Plugin.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="WelcomeConfiguration.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="GeoIP.dat" />
|
||||
|
Reference in New Issue
Block a user