Properly cleanup timer instances.

This commit is contained in:
UnknownShadow200 2016-05-21 10:36:44 +10:00
parent cc99811ac6
commit 1979c33435
6 changed files with 23 additions and 15 deletions

View File

@ -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" />

View File

@ -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;
}

View File

@ -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!");
}
}
}

View File

@ -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;

View File

@ -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>