mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-10-03 10:33:29 -04:00
Tidy up leaving server code a little bit
This commit is contained in:
parent
e3ef369c38
commit
7eeb3d6c53
@ -62,8 +62,7 @@ namespace MCGalaxy {
|
|||||||
case Opcode.CpeTwoWayPing: return 1 + 1 + 2;
|
case Opcode.CpeTwoWayPing: return 1 + 1 + 2;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
string msg = "Unhandled message id \"" + opcode + "\"!";
|
Leave("Unhandled opcode \"" + opcode + "\"!", true);
|
||||||
Leave(msg, msg, true);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,8 +188,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
byte action = buffer[offset + 7];
|
byte action = buffer[offset + 7];
|
||||||
if (action > 1) {
|
if (action > 1) {
|
||||||
const string msg = "Unknown block action!";
|
Leave("Unknown block action!", true); return;
|
||||||
Leave(msg, msg, true); return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LastAction = DateTime.UtcNow;
|
LastAction = DateTime.UtcNow;
|
||||||
@ -496,8 +495,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
text = Regex.Replace(text, " +", " ");
|
text = Regex.Replace(text, " +", " ");
|
||||||
if (text.IndexOf('&') >= 0) {
|
if (text.IndexOf('&') >= 0) {
|
||||||
const string msg = "Illegal character in chat message!";
|
Leave("Illegal character in chat message!", true); return true;
|
||||||
Leave(msg, msg, true); return true;
|
|
||||||
}
|
}
|
||||||
return text.Length == 0;
|
return text.Length == 0;
|
||||||
}
|
}
|
||||||
|
@ -191,25 +191,20 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Disconnects the players from the server,
|
/// <summary> Disconnects the players from the server,
|
||||||
/// with the given message shown in both chat and in the disconnect packet. </summary>
|
/// with the given messages shown in chat and in the disconnect packet. </summary>
|
||||||
public void Leave(string chatMsg, string discMsg, bool sync = false) {
|
public void Leave(string chatMsg, string discMsg, bool sync = false) {
|
||||||
LeaveServer(chatMsg, discMsg, false, sync);
|
LeaveServer(chatMsg, discMsg, false, sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Disconnects the players from the server,
|
/// <summary> Disconnects the players from the server,
|
||||||
/// with the given messages shown in chat and in the disconnect packet. </summary>
|
/// with the same message shown in chat and in the disconnect packet. </summary>
|
||||||
public void Leave(string discMsg) { Leave(discMsg, false); }
|
public void Leave(string msg) { Leave(msg, false); }
|
||||||
public void Leave(string discMsg, bool sync = false) {
|
public void Leave(string msg, bool sync = false) {
|
||||||
LeaveServer(discMsg, discMsg, false, sync);
|
LeaveServer(msg, msg, false, sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("Use Leave() or Kick() instead")]
|
[Obsolete("Use Leave() or Kick() instead")]
|
||||||
public void leftGame(string discMsg = "") {
|
public void leftGame(string discMsg = "") { Kick(discMsg); }
|
||||||
string chatMsg = discMsg;
|
|
||||||
if (chatMsg.Length > 0) chatMsg = "(" + chatMsg + ")"; // old format
|
|
||||||
LeaveServer(chatMsg, discMsg, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool leftServer = false;
|
bool leftServer = false;
|
||||||
void LeaveServer(string chatMsg, string discMsg, bool isKick, bool sync = false) {
|
void LeaveServer(string chatMsg, string discMsg, bool isKick, bool sync = false) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user