Skip to content

Commit 64800ba

Browse files
committed
hotfix: Startup without licensing
1 parent 30f2b26 commit 64800ba

File tree

3 files changed

+89
-71
lines changed

3 files changed

+89
-71
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ __MACOSX/
6161
bin/
6262
obj/
6363
*.sln
64+
Zenith

deploy.sh

+13
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,20 @@ print_message() {
1414
echo -e "${color}[ INFO ] ${message}${NC}"
1515
}
1616

17+
rm -rf ./Zenith
18+
1719
# Normal deploy (copy and prepare DLLs)
20+
print_message "${BLUE}" "Creating directory structure..."
21+
mkdir -p ./Zenith/plugins/K4-Zenith \
22+
./Zenith/shared/K4-ZenithAPI \
23+
./Zenith/plugins/K4-Zenith-TimeStats \
24+
./Zenith/plugins/K4-Zenith-Ranks \
25+
./Zenith/plugins/K4-Zenith-Stats \
26+
./Zenith/plugins/K4-Zenith-Bans \
27+
./Zenith/plugins/K4-Zenith-ExtendedCommands \
28+
./Zenith/plugins/K4-Zenith-CustomTags \
29+
./Zenith/plugins/K4-Zenith-Toplists
30+
1831
print_message "${BLUE}" "Running dotnet publish..."
1932
dotnet publish -f net8.0 -c Release
2033
exit_code=$?

src/Plugin.cs

+75-71
Original file line numberDiff line numberDiff line change
@@ -50,100 +50,104 @@ public override void Load(bool hotReload)
5050
Menu = new Menu.KitsuneMenu(this);
5151

5252
Initialize_API();
53-
Initialize_Events();
54-
Initialize_Settings();
55-
Initialize_Commands();
56-
Initialize_Placeholders();
5753

58-
Player.RegisterModuleSettings(this, new Dictionary<string, object?>
54+
AddTimer(3.0f, () => // ! CSS Initialize some variables slow, so we need to wait a bit
5955
{
60-
{ "ShowClanTags", true },
61-
{ "ShowChatTags", true },
62-
{ "FreezeInMenu", GetCoreConfig<bool>("Core", "FreezeInMenu") },
63-
}, Localizer);
56+
Initialize_Events();
57+
Initialize_Settings();
58+
Initialize_Commands();
59+
Initialize_Placeholders();
6460

65-
RegisterListener<Listeners.OnTick>(() =>
66-
{
67-
foreach (var player in Player.List.Values)
61+
Player.RegisterModuleSettings(this, new Dictionary<string, object?>
6862
{
69-
if (player.IsValid)
70-
player.ShowCenterMessage();
71-
}
72-
});
63+
{ "ShowClanTags", true },
64+
{ "ShowChatTags", true },
65+
{ "FreezeInMenu", GetCoreConfig<bool>("Core", "FreezeInMenu") },
66+
}, Localizer);
7367

74-
if (hotReload)
75-
{
76-
Logger.LogCritical(@"*");
77-
Logger.LogCritical(@"*");
78-
Logger.LogCritical(@"* ██╗ ██╗ █████╗ ██████╗ ███╗ ██╗██╗███╗ ██╗ ██████╗");
79-
Logger.LogCritical(@"* ██║ ██║██╔══██╗██╔══██╗████╗ ██║██║████╗ ██║██╔════╝");
80-
Logger.LogCritical(@"* ██║ █╗ ██║███████║██████╔╝██╔██╗ ██║██║██╔██╗ ██║██║ ███╗");
81-
Logger.LogCritical(@"* ██║███╗██║██╔══██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║");
82-
Logger.LogCritical(@"* ╚███╔███╔╝██║ ██║██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝");
83-
Logger.LogCritical(@"* ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝");
84-
Logger.LogCritical(@"*");
85-
Logger.LogCritical(@"* WARNING: Hot reloading Zenith Core currently breaks the plugin. Please restart the server instead.");
86-
Logger.LogCritical(@"* More information: https://github.com/roflmuffin/CounterStrikeSharp/issues/565");
87-
Logger.LogCritical(@"*");
88-
89-
var players = Utilities.GetPlayers();
90-
91-
foreach (var player in players)
68+
RegisterListener<Listeners.OnTick>(() =>
9269
{
93-
if (player != null && player.IsValid && !player.IsBot && !player.IsHLTV)
70+
foreach (var player in Player.List.Values)
9471
{
95-
_ = new Player(this, player, true);
72+
if (player.IsValid)
73+
player.ShowCenterMessage();
9674
}
97-
}
98-
99-
Player.LoadAllOnlinePlayerDataWithSingleQuery(this);
100-
}
75+
});
10176

102-
AddTimer(3.0f, () =>
103-
{
104-
string coreFormat = GetCoreConfig<string>("Modular", "PlayerClantagFormat");
105-
foreach (var player in Player.List.Values)
77+
if (hotReload)
10678
{
107-
if (player.IsValid)
108-
player.EnforcePluginValues(coreFormat);
79+
Logger.LogCritical(@"*");
80+
Logger.LogCritical(@"*");
81+
Logger.LogCritical(@"* ██╗ ██╗ █████╗ ██████╗ ███╗ ██╗██╗███╗ ██╗ ██████╗");
82+
Logger.LogCritical(@"* ██║ ██║██╔══██╗██╔══██╗████╗ ██║██║████╗ ██║██╔════╝");
83+
Logger.LogCritical(@"* ██║ █╗ ██║███████║██████╔╝██╔██╗ ██║██║██╔██╗ ██║██║ ███╗");
84+
Logger.LogCritical(@"* ██║███╗██║██╔══██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║");
85+
Logger.LogCritical(@"* ╚███╔███╔╝██║ ██║██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝");
86+
Logger.LogCritical(@"* ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝");
87+
Logger.LogCritical(@"*");
88+
Logger.LogCritical(@"* WARNING: Hot reloading Zenith Core currently breaks the plugin. Please restart the server instead.");
89+
Logger.LogCritical(@"* More information: https://github.com/roflmuffin/CounterStrikeSharp/issues/565");
90+
Logger.LogCritical(@"*");
91+
92+
var players = Utilities.GetPlayers();
93+
94+
foreach (var player in players)
95+
{
96+
if (player != null && player.IsValid && !player.IsBot && !player.IsHLTV)
97+
{
98+
_ = new Player(this, player, true);
99+
}
100+
}
101+
102+
Player.LoadAllOnlinePlayerDataWithSingleQuery(this);
109103
}
110-
}, TimerFlags.REPEAT);
111104

112-
AddTimer(60.0f, () =>
113-
{
114-
int interval = GetCoreConfig<int>("Database", "AutoSaveInterval");
115-
if (interval <= 0)
116-
return;
105+
AddTimer(3.0f, () =>
106+
{
107+
string coreFormat = GetCoreConfig<string>("Modular", "PlayerClantagFormat");
108+
foreach (var player in Player.List.Values)
109+
{
110+
if (player.IsValid)
111+
player.EnforcePluginValues(coreFormat);
112+
}
113+
}, TimerFlags.REPEAT);
117114

118-
if ((DateTime.Now - _lastStorageSave).TotalMinutes >= interval)
115+
AddTimer(60.0f, () =>
119116
{
120-
_lastStorageSave = DateTime.Now;
121-
_ = Task.Run(() => Player.SaveAllOnlinePlayerDataWithTransaction(this));
122-
}
123-
}, TimerFlags.REPEAT);
117+
int interval = GetCoreConfig<int>("Database", "AutoSaveInterval");
118+
if (interval <= 0)
119+
return;
124120

125-
var overridePlugins = GetModuleConfigValue<List<string>>("Modular", "OverridePlugins");
126-
if (overridePlugins.Count != 0)
127-
{
128-
Logger.LogInformation("Forcing low priority to: " + string.Join(", ", overridePlugins));
121+
if ((DateTime.Now - _lastStorageSave).TotalMinutes >= interval)
122+
{
123+
_lastStorageSave = DateTime.Now;
124+
_ = Task.Run(() => Player.SaveAllOnlinePlayerDataWithTransaction(this));
125+
}
126+
}, TimerFlags.REPEAT);
129127

130-
overridePlugins.ForEach(plugin =>
128+
var overridePlugins = GetModuleConfigValue<List<string>>("Modular", "OverridePlugins");
129+
if (overridePlugins.Count != 0)
131130
{
132-
if (IsPluginExists(plugin))
133-
Server.ExecuteCommand($"css_plugins unload {plugin}");
134-
});
131+
Logger.LogInformation("Forcing low priority to: " + string.Join(", ", overridePlugins));
135132

136-
AddTimer(3.0f, () =>
137-
{
138133
overridePlugins.ForEach(plugin =>
139134
{
140135
if (IsPluginExists(plugin))
141-
Server.ExecuteCommand($"css_plugins load {plugin}");
136+
Server.ExecuteCommand($"css_plugins unload {plugin}");
142137
});
143-
});
144138

145-
bool IsPluginExists(string plugin) => Directory.Exists(Path.Combine(ModuleDirectory, "..", plugin));
146-
}
139+
AddTimer(3.0f, () =>
140+
{
141+
overridePlugins.ForEach(plugin =>
142+
{
143+
if (IsPluginExists(plugin))
144+
Server.ExecuteCommand($"css_plugins load {plugin}");
145+
});
146+
});
147+
148+
bool IsPluginExists(string plugin) => Directory.Exists(Path.Combine(ModuleDirectory, "..", plugin));
149+
}
150+
});
147151
}
148152

149153
public override void Unload(bool hotReload)

0 commit comments

Comments
 (0)