mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
Add Leave method (instead of specifying message twice in LeaveServer method), make only actual kicks increment 'timesKicked'.
This commit is contained in:
parent
6b9326fa8a
commit
a94007b459
@ -41,8 +41,7 @@ namespace MCGalaxy.Commands
|
||||
Player.Message(p, "Your awesomeness prevents you from using this command");
|
||||
return;
|
||||
}
|
||||
const string msg = "If you don't agree with the rules, consider playing elsewhere.";
|
||||
p.LeaveServer(msg, msg);
|
||||
p.Leave("If you don't agree with the rules, consider playing elsewhere.");
|
||||
}
|
||||
|
||||
public override void Help(Player p)
|
||||
|
@ -61,8 +61,7 @@ namespace MCGalaxy.Commands {
|
||||
messageTimer.Start();
|
||||
messageTimer.Elapsed += delegate
|
||||
{
|
||||
string msg = "You have been kicked for hacking the rank " + newRank.ColoredName;
|
||||
p.LeaveServer(msg, msg);
|
||||
p.Leave("You have been kicked for hacking the rank " + newRank.ColoredName);
|
||||
p.color = oldCol;
|
||||
messageTimer.Stop();
|
||||
messageTimer.Dispose();
|
||||
|
@ -28,7 +28,7 @@ namespace MCGalaxy.Commands {
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
p.LeaveServer("RAGEQUIT!!", "RAGEQUIT!!");
|
||||
p.Leave("RAGEQUIT!!");
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
@ -45,7 +45,7 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
string msg = message != "" ? "Left the game: " + message : "Left the game.";
|
||||
p.LeaveServer(msg, msg);
|
||||
p.Leave(msg);
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
@ -63,8 +63,7 @@ namespace MCGalaxy.Commands {
|
||||
public override void Use(Player p, string message) {
|
||||
if (message != "") { Help(p); return; }
|
||||
int code = p.random.Next(int.MinValue, int.MaxValue);
|
||||
string msg = "Server crash! Error code 0x" + Convert.ToString(code, 16).ToUpper();
|
||||
p.LeaveServer(msg, msg);
|
||||
p.Leave("Server crash! Error code 0x" + Convert.ToString(code, 16).ToUpper());
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
@ -84,8 +83,7 @@ namespace MCGalaxy.Commands {
|
||||
Player.Message(p, "&cIncorrect syntax. Abuse detected.");
|
||||
Thread.Sleep(3000);
|
||||
}
|
||||
const string msg = "Your IP has been backtraced + reported to FBI Cyber Crimes Unit.";
|
||||
p.LeaveServer(msg, msg);
|
||||
p.Leave("Your IP has been backtraced + reported to FBI Cyber Crimes Unit.");
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -60,7 +60,7 @@ namespace MCGalaxy {
|
||||
p.disconnected = true;
|
||||
} catch ( Exception e ) {
|
||||
Server.ErrorLog(e);
|
||||
p.Kick("Error!");
|
||||
p.Leave("Error!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ namespace MCGalaxy {
|
||||
RevertBlock(x, y, z); return;
|
||||
}
|
||||
|
||||
if (action > 1 ) { Kick("Unknown block action!"); return; }
|
||||
if (action > 1 ) { Leave("Unknown block action!", true); return; }
|
||||
byte oldType = type;
|
||||
if (type < 128) type = bindings[type];
|
||||
|
||||
@ -221,7 +221,7 @@ namespace MCGalaxy {
|
||||
break;
|
||||
default:
|
||||
if (!dontmindme)
|
||||
Kick("Unhandled message id \"" + msg + "\"!");
|
||||
Leave("Unhandled message id \"" + msg + "\"!", true);
|
||||
else
|
||||
Server.s.Log(Encoding.UTF8.GetString(buffer, 0, buffer.Length));
|
||||
return new byte[0];
|
||||
@ -285,7 +285,7 @@ namespace MCGalaxy {
|
||||
byte version = message[0];
|
||||
name = enc.GetString(message, 1, 64).Trim();
|
||||
if (name.Length > 16) {
|
||||
Kick("Usernames must be 16 characters or less", true); return;
|
||||
Leave("Usernames must be 16 characters or less", true); return;
|
||||
}
|
||||
truename = name;
|
||||
skinName = name;
|
||||
@ -300,7 +300,7 @@ namespace MCGalaxy {
|
||||
pendingNames.Add(new PendingItem(name));
|
||||
|
||||
if (altsCount > 0) {
|
||||
Kick("Already logged in!", true); return;
|
||||
Leave("Already logged in!", true); return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,7 +311,7 @@ namespace MCGalaxy {
|
||||
string hashHex = BitConverter.ToString(hash);
|
||||
if (!verify.CaselessEq(hashHex.Replace("-", ""))) {
|
||||
if (!IPInPrivateRange(ip)) {
|
||||
Kick("Login failed! Try signing in again.", true); return;
|
||||
Leave("Login failed! Try signing in again.", true); return;
|
||||
}
|
||||
} else {
|
||||
verifiedName = true;
|
||||
@ -360,7 +360,7 @@ namespace MCGalaxy {
|
||||
{
|
||||
// Check to see how many guests we have
|
||||
Player[] online = PlayerInfo.Online.Items;
|
||||
if (online.Length >= Server.players && !IPInPrivateRange(ip)) { Kick("Server full!"); return; }
|
||||
if (online.Length >= Server.players && !IPInPrivateRange(ip)) { Leave("Server full!", true); return; }
|
||||
// Code for limiting no. of guests
|
||||
if (foundGrp == Group.findPerm(LevelPermission.Guest))
|
||||
{
|
||||
@ -371,22 +371,21 @@ namespace MCGalaxy {
|
||||
{
|
||||
if (Server.guestLimitNotify) Chat.GlobalMessageOps("Guest " + this.DisplayName + " couldn't log in - too many guests.");
|
||||
Server.s.Log("Guest " + this.name + " couldn't log in - too many guests.");
|
||||
const string msg = "Server has reached max number of guests";
|
||||
LeaveServer(msg, msg, true);
|
||||
Leave("Server has reached max number of guests", true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version != Server.version) { LeaveServer("Wrong version!", "Wrong version!", true); return; }
|
||||
if (version != Server.version) { Leave("Wrong version!", true); return; }
|
||||
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player p in players) {
|
||||
if (p.name == name) {
|
||||
if (Server.verify) {
|
||||
p.LeaveServer("Someone logged in as you!", "Someone logged in as you!"); break;
|
||||
p.Leave("Someone logged in as you!"); break;
|
||||
} else {
|
||||
LeaveServer("Already logged in!", "Already logged in!", true); return;
|
||||
Leave("Already logged in!", true); return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -445,8 +444,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
bool CheckWhitelist() {
|
||||
if (!Server.useWhitelist)
|
||||
return true;
|
||||
if (!Server.useWhitelist) return true;
|
||||
|
||||
if (Server.verify) {
|
||||
if (Server.whiteList.Contains(name))
|
||||
@ -465,7 +463,7 @@ namespace MCGalaxy {
|
||||
ipQuery.Dispose();
|
||||
}
|
||||
if (!onWhitelist)
|
||||
Kick("This is a private server!"); //i think someone forgot this?
|
||||
Leave("This is a private server!", true); //i think someone forgot this?
|
||||
return onWhitelist;
|
||||
}
|
||||
|
||||
@ -666,7 +664,7 @@ namespace MCGalaxy {
|
||||
PlayerActions.ChangeMap(this, level);
|
||||
Command.all.Find("jail").Use(null, name);
|
||||
} catch (Exception ex) {
|
||||
Kick("Error occured");
|
||||
Leave("Error occured", true);
|
||||
Server.ErrorLog(ex);
|
||||
}
|
||||
}
|
||||
@ -988,7 +986,7 @@ try { SendBlockchange(pos1.x, pos1.y, pos1.z, Block.waterstill); } catch { }
|
||||
|
||||
text = Regex.Replace(text, @"\s\s+", " ");
|
||||
if ( text.Any(ch => ch == '&') ) {
|
||||
Kick("Illegal character in chat message!");
|
||||
Leave("Illegal character in chat message!", true);
|
||||
return;
|
||||
}
|
||||
if ( text.Length == 0 )
|
||||
|
@ -360,7 +360,7 @@ namespace MCGalaxy {
|
||||
InitTimers();
|
||||
connections.Add(this);
|
||||
}
|
||||
catch ( Exception e ) { Kick("Login failed!"); Server.ErrorLog(e); }
|
||||
catch ( Exception e ) { Leave("Login failed!"); Server.ErrorLog(e); }
|
||||
}
|
||||
|
||||
|
||||
@ -525,7 +525,8 @@ namespace MCGalaxy {
|
||||
public void Disconnect() { LeaveServer("Disconnected", PlayerDB.GetLogoutMessage(this)); }
|
||||
public void Kick(string kickString) { LeaveServer(kickString, null); }
|
||||
public void Kick(string kickString, bool sync = false) { LeaveServer(kickString, null, sync); }
|
||||
|
||||
public void Leave(string discMsg, bool sync = false) { LeaveServer(discMsg, discMsg, sync); }
|
||||
|
||||
[Obsolete("Use LeaveServer() instead")]
|
||||
public void leftGame(string kickMsg = "") { LeaveServer(kickMsg, null); }
|
||||
|
||||
|
@ -692,35 +692,22 @@ namespace MCGalaxy
|
||||
|
||||
}
|
||||
|
||||
public static void Exit(bool AutoRestart)
|
||||
{
|
||||
public static void Exit(bool AutoRestart) {
|
||||
string msg = AutoRestart ? "Server restarted. Sign in again and rejoin." : Server.shutdownMessage;
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player p in players) { p.save(); }
|
||||
foreach (Player p in players)
|
||||
{
|
||||
string msg = AutoRestart ? "Server restarted. Sign in again and rejoin." : Server.shutdownMessage;
|
||||
p.LeaveServer(msg, msg);
|
||||
}
|
||||
foreach (Player p in players) { p.Leave(msg); }
|
||||
|
||||
if (APIServer != null) APIServer.Stop();
|
||||
if (InfoServer != null) InfoServer.Stop();
|
||||
//PlayerInfo.players.ForEach(delegate(Player p) { p.Kick("Server shutdown. Rejoin in 10 seconds."); });
|
||||
Player.connections.ForEach(
|
||||
delegate(Player p)
|
||||
{
|
||||
string msg = AutoRestart ? "Server restarted. Sign in again and rejoin." : Server.shutdownMessage;
|
||||
p.LeaveServer(msg, msg);
|
||||
}
|
||||
);
|
||||
|
||||
Player.connections.ForEach(p => p.Leave(msg));
|
||||
Plugin.Unload();
|
||||
if (listen != null)
|
||||
{
|
||||
listen.Close();
|
||||
}
|
||||
try
|
||||
{
|
||||
if (listen != null) listen.Close();
|
||||
try {
|
||||
IRC.Disconnect(!AutoRestart ? "Server is shutting down." : "Server is restarting.");
|
||||
} catch {
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
[Obsolete("Use LevelInfo.Loaded.Add()")]
|
||||
|
@ -217,7 +217,7 @@ namespace MCGalaxy.Gui
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player p in players) {
|
||||
string msg = restarting ? "Server restarted. Sign in again and rejoin." : Server.shutdownMessage;
|
||||
p.LeaveServer(msg, msg);
|
||||
p.Leave(msg);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Server.ErrorLog(ex);
|
||||
|
Loading…
x
Reference in New Issue
Block a user