mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
Properly cleanup timer instances.
This commit is contained in:
parent
cc99811ac6
commit
1979c33435
@ -576,7 +576,6 @@
|
||||
<Compile Include="Server\Extra\UPnP.cs" />
|
||||
<Compile Include="Server\Colors.cs" />
|
||||
<Compile Include="GlobalSuppressions.cs" />
|
||||
<Compile Include="Player\PlayerCollection.cs" />
|
||||
<Compile Include="Network\IBeat.cs" />
|
||||
<Compile Include="Levels\Level.cs" />
|
||||
<Compile Include="Server\Extra\Heart.cs" />
|
||||
|
@ -1064,26 +1064,18 @@ try { SendBlockchange(pos1.x, pos1.y, pos1.z, Block.waterstill); } catch { }
|
||||
// Put this after vote collection so that people can vote even when chat is moderated
|
||||
if ( Server.chatmod && !voice ) { this.SendMessage("Chat moderation is on, you cannot speak."); return; }
|
||||
|
||||
if ( Server.checkspam ) {
|
||||
if ( Player.lastMSG == this.name ) {
|
||||
if (Server.checkspam) {
|
||||
if (Player.lastMSG == name) {
|
||||
consecutivemessages++;
|
||||
} else {
|
||||
consecutivemessages--;
|
||||
}
|
||||
|
||||
if ( this.consecutivemessages >= Server.spamcounter ) {
|
||||
int total = Server.mutespamtime;
|
||||
if (consecutivemessages >= Server.spamcounter) {
|
||||
muteCooldown = Server.mutespamtime;
|
||||
Command.all.Find("mute").Use(null, name);
|
||||
Player.GlobalMessage(color + DisplayName + " %Shas been &0muted &efor spamming!");
|
||||
muteTimer.Elapsed += delegate {
|
||||
total--;
|
||||
if ( total <= 0 ) {
|
||||
muteTimer.Stop();
|
||||
if (muted) Command.all.Find("mute").Use(null, name);
|
||||
this.consecutivemessages = 0;
|
||||
Player.Message(this, "Remember, no &cspamming %Snext time!");
|
||||
}
|
||||
};
|
||||
muteTimer.Elapsed += MuteTimerElapsed;
|
||||
muteTimer.Start();
|
||||
return;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ namespace MCGalaxy {
|
||||
CP437Writer.WriteAllText("text/welcome.txt", "Welcome to my server!");
|
||||
SendMessage("Welcome to my server!");
|
||||
}
|
||||
loginTimer.Elapsed -= LoginTimerElapsed;
|
||||
loginTimer.Dispose();
|
||||
extraTimer.Start();
|
||||
}
|
||||
@ -83,11 +84,12 @@ namespace MCGalaxy {
|
||||
|
||||
if (Server.lava.active)
|
||||
SendMessage("There is a &aLava Survival %Sgame active! Join it by typing /ls go");
|
||||
extraTimer.Elapsed -= ExtraTimerElapsed;
|
||||
extraTimer.Dispose();
|
||||
}
|
||||
|
||||
void CheckTimerElapsed(object sender, ElapsedEventArgs e) {
|
||||
if ( name == "" ) return;
|
||||
if (name == "") return;
|
||||
SendRaw(Opcode.Ping);
|
||||
if (Server.afkminutes <= 0) return;
|
||||
|
||||
@ -117,5 +119,17 @@ namespace MCGalaxy {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int muteCooldown = 0;
|
||||
void MuteTimerElapsed(object sender, ElapsedEventArgs e) {
|
||||
muteCooldown--;
|
||||
if ( muteCooldown > 0) return;
|
||||
|
||||
muteTimer.Stop();
|
||||
muteTimer.Elapsed -= MuteTimerElapsed;
|
||||
if (muted) Command.all.Find("mute").Use(null, name);
|
||||
consecutivemessages = 0;
|
||||
Player.Message(this, "Remember, no &cspamming %Snext time!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -562,8 +562,10 @@ namespace MCGalaxy {
|
||||
// FlyBuffer.Clear();
|
||||
SaveIgnores();
|
||||
checkTimer.Stop();
|
||||
checkTimer.Elapsed -= CheckTimerElapsed;
|
||||
checkTimer.Dispose();
|
||||
muteTimer.Stop();
|
||||
muteTimer.Elapsed -= MuteTimerElapsed;
|
||||
muteTimer.Dispose();
|
||||
afkCount = 0;
|
||||
afkStart = DateTime.Now;
|
||||
|
@ -49,6 +49,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="GUI\LevelSettings.cs" />
|
||||
<Compile Include="GUI\PlayerCollection.cs" />
|
||||
<Compile Include="GUI\Program.cs" />
|
||||
<Compile Include="GUI\Window.cs">
|
||||
<SubType>Form</SubType>
|
||||
|
Loading…
x
Reference in New Issue
Block a user