|
3 | 3 | using CounterStrikeSharp.API;
|
4 | 4 | using CounterStrikeSharp.API.Modules.Commands;
|
5 | 5 | using CounterStrikeSharp.API.Modules.Admin;
|
| 6 | +using System.Text.Json; |
6 | 7 |
|
7 | 8 | namespace FunMatchPlugin;
|
8 | 9 |
|
9 |
| -public class FunMatchPlugin: BasePlugin |
| 10 | +public class FunMatchPlugin: BasePlugin , IPluginConfig<FunMatchPluginConfig> |
10 | 11 | {
|
11 | 12 | public override string ModuleName => "Fun Match Plugin";
|
12 |
| - public override string ModuleVersion => "1.0.7"; |
| 13 | + public override string ModuleVersion => "1.0.8"; |
| 14 | + public FunMatchPluginConfig Config {get;set;} = new(); |
13 | 15 | public override void Load(bool hotReload)
|
14 | 16 | {
|
15 | 17 | Console.WriteLine("Fun Match Plugin Load!");
|
16 |
| - FunBulletTeleport funBulletTeleport = new (this); |
17 |
| - FunLists.Add(funBulletTeleport); |
18 |
| - FunHealTeammates funHealTeammates = new (this); |
19 |
| - FunLists.Add(funHealTeammates); |
20 |
| - FunHealthRaid funHealthRaid = new (this); |
21 |
| - FunLists.Add(funHealthRaid); |
22 |
| - FunHighHP funHighHP = new (this); |
23 |
| - FunLists.Add(funHighHP); |
24 |
| - FunInfiniteGrenade funFunInfiniteGrenade = new (this); |
25 |
| - FunLists.Add(funFunInfiniteGrenade); |
26 |
| - FunJumpOrDie funJumpOrDie = new(this); |
27 |
| - FunLists.Add(funJumpOrDie); |
28 |
| - FunNoClip funNoClip = new (this); |
29 |
| - FunLists.Add(funNoClip); |
30 |
| - FunPlayerShootExChange funPlayerShootExChange = new (this); |
31 |
| - FunLists.Add(funPlayerShootExChange); |
32 |
| - FunToTheMoon funToTheMoon = new(this); |
33 |
| - FunLists.Add(funToTheMoon); |
34 |
| - FunWNoStop funWNoStop = new (this); |
35 |
| - FunLists.Add(funWNoStop); |
36 |
| - FunDropWeaponOnShoot funDropWeaponOnShoot = new(); |
37 |
| - FunLists.Add(funDropWeaponOnShoot); |
38 |
| - FunChangeWeaponOnShoot funChangeWeaponOnShoot = new(); |
39 |
| - FunLists.Add(funChangeWeaponOnShoot); |
| 18 | + InstallFun(Config); |
| 19 | + InstallCustomModes(); |
40 | 20 | //FunC4EveryWhere funC4EveryWhere = new(this);
|
41 | 21 | //FunLists.Add(funC4EveryWhere);
|
42 | 22 | }
|
| 23 | + public void OnConfigParsed(FunMatchPluginConfig config) |
| 24 | + { |
| 25 | + Console.WriteLine("Parsing config"); |
| 26 | + Config = config; |
| 27 | + } |
| 28 | + |
| 29 | + private void InstallCustomModes() |
| 30 | + { |
| 31 | + var configdirectory = Path.Combine(Application.RootDirectory, "configs/plugins/FunMatchPlugin"); |
| 32 | + if (!Path.Exists(configdirectory)) Directory.CreateDirectory(configdirectory); |
| 33 | + var configpath = Path.Combine(configdirectory,"CustomModes.json"); |
| 34 | + if (!File.Exists(configpath)) return; |
| 35 | + |
| 36 | + var dir_addons = Directory.GetParent(Application.RootDirectory); |
| 37 | + var dir_csgo = Directory.GetParent(dir_addons!.FullName); |
| 38 | + var path_cfg = Path.Combine(dir_csgo!.FullName,"cfg"); |
| 39 | + |
| 40 | + using (StreamReader r = new StreamReader(configpath)) |
| 41 | + { |
| 42 | + string json = r.ReadToEnd(); |
| 43 | + CustomModesConfig customModesConfig = JsonSerializer.Deserialize<CustomModesConfig>(json)!; |
| 44 | + foreach (var mode in customModesConfig.Modes) |
| 45 | + { |
| 46 | + var fun_cfg_game = Path.Combine(path_cfg,mode.Fun_cfgfilename); |
| 47 | + var fun_cfg_config = Path.Combine(configdirectory,mode.Fun_cfgfilename); |
| 48 | + var endfun_cfg_game = Path.Combine(path_cfg,mode.Endfun_cfgfilename); |
| 49 | + var endfun_cfg_config = Path.Combine(configdirectory,mode.Endfun_cfgfilename); |
| 50 | + File.Copy(fun_cfg_config,fun_cfg_game,true); |
| 51 | + File.Copy(endfun_cfg_config,endfun_cfg_game,true); |
| 52 | + FunLists.Add(new FunCustomConsoleMode(mode.Decr,mode.Fun_cfgfilename,mode.Endfun_cfgfilename)); |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + private void InstallFun(FunMatchPluginConfig config) |
| 58 | + { |
| 59 | + if (config.IsFunBulletTeleportOn) |
| 60 | + { |
| 61 | + FunBulletTeleport funBulletTeleport = new (this); |
| 62 | + FunLists.Add(funBulletTeleport); |
| 63 | + } |
| 64 | + if (config.IsFunHealTeammatesOn) |
| 65 | + { |
| 66 | + FunHealTeammates funHealTeammates = new(this) |
| 67 | + { |
| 68 | + BurnAfterSecond = config.FunHealTeammatesBurnAfterSecond, |
| 69 | + BurnDamage = config.FunHealTeammatesBurnDamage, |
| 70 | + HealValue = config.FunHealTeammatesHealValue, |
| 71 | + }; |
| 72 | + FunLists.Add(funHealTeammates); |
| 73 | + } |
| 74 | + if (config.IsFunHealthRaidOn) |
| 75 | + { |
| 76 | + FunHealthRaid funHealthRaid = new (this) |
| 77 | + { |
| 78 | + initHP = config.FunHealthRaidinitHP, |
| 79 | + maxRaid = config.FunHealthRaidmaxRaid, |
| 80 | + RaidScale = config.FunHealthRaidScale, |
| 81 | + }; |
| 82 | + FunLists.Add(funHealthRaid); |
| 83 | + } |
| 84 | + if (config.IsFunHighHPOn) |
| 85 | + { |
| 86 | + FunHighHP funHighHP = new (this) |
| 87 | + { |
| 88 | + maxHP = config.FunHighHPmaxHP, |
| 89 | + armor = config.FunHighHParmor, |
| 90 | + }; |
| 91 | + FunLists.Add(funHighHP); |
| 92 | + } |
| 93 | + if (config.IsFunInfiniteGrenadeOn) |
| 94 | + { |
| 95 | + FunInfiniteGrenade funFunInfiniteGrenade = new (this); |
| 96 | + FunLists.Add(funFunInfiniteGrenade); |
| 97 | + } |
| 98 | + if (config.IsFunJumpOrDieOn) |
| 99 | + { |
| 100 | + FunJumpOrDie funJumpOrDie = new(this) |
| 101 | + { |
| 102 | + BurnAfterSecond = config.FunJumpOrDieBurnAfterSecond, |
| 103 | + BurnDamage = config.FunJumpOrDieBurnDamage, |
| 104 | + }; |
| 105 | + FunLists.Add(funJumpOrDie); |
| 106 | + } |
| 107 | + if (config.IsFunNoClipOn) |
| 108 | + { |
| 109 | + FunNoClip funNoClip = new (this){ |
| 110 | + interval = config.FunNoClipinterval, |
| 111 | + }; |
| 112 | + FunLists.Add(funNoClip); |
| 113 | + } |
| 114 | + if (config.IsFunPlayerShootExChangeOn) |
| 115 | + { |
| 116 | + FunPlayerShootExChange funPlayerShootExChange = new (this); |
| 117 | + FunLists.Add(funPlayerShootExChange); |
| 118 | + } |
| 119 | + if (config.IsFunToTheMoonOn) |
| 120 | + { |
| 121 | + FunToTheMoon funToTheMoon = new(this) |
| 122 | + { |
| 123 | + gravity = config.FunToTheMoongravity, |
| 124 | + BulletGiveAbsV = config.FunToTheMoonBulletGiveAbsV, |
| 125 | + }; |
| 126 | + FunLists.Add(funToTheMoon); |
| 127 | + } |
| 128 | + if (config.IsFunWNoStopOn) |
| 129 | + { |
| 130 | + FunWNoStop funWNoStop = new (this) |
| 131 | + { |
| 132 | + BurnAfterSecond = config.FunWNoStopBurnAfterSecond, |
| 133 | + BurnDamage = config.FunWNoStopBurnDamage, |
| 134 | + }; |
| 135 | + FunLists.Add(funWNoStop); |
| 136 | + } |
| 137 | + if (config.IsFunDropWeaponOnShootOn) |
| 138 | + { |
| 139 | + FunDropWeaponOnShoot funDropWeaponOnShoot = new(); |
| 140 | + FunLists.Add(funDropWeaponOnShoot); |
| 141 | + } |
| 142 | + if (config.IsFunChangeWeaponOnShootOn) |
| 143 | + { |
| 144 | + FunChangeWeaponOnShoot funChangeWeaponOnShoot = new(); |
| 145 | + FunLists.Add(funChangeWeaponOnShoot); |
| 146 | + } |
| 147 | + } |
43 | 148 |
|
44 | 149 | public void LoadRandomFun()
|
45 | 150 | {
|
|
0 commit comments