mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Cleanup /shutdown.
This commit is contained in:
parent
a890e91d74
commit
c6d79ac32d
@ -44,8 +44,8 @@ namespace MCGalaxy.Commands {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (DataRow row in Inbox.Rows) {
|
foreach (DataRow row in Inbox.Rows) {
|
||||||
Player.Message(p, "{0}: From &5{1} %Sat &a{2}:", i, row["PlayerFrom"], row["TimeSent"]); i++;
|
Player.Message(p, "{0}: From &5{1} %Sat &a{2}:", i, row["PlayerFrom"], row["TimeSent"]); i++;
|
||||||
Player.Message(p, row["Contents"].ToString());
|
|
||||||
}
|
}
|
||||||
|
Player.Message(p, "Use %T/inbox [number] %Sto read the contents of that message.");
|
||||||
}
|
}
|
||||||
} else if (parts[0] == "del" || parts[0] == "delete") {
|
} else if (parts[0] == "del" || parts[0] == "delete") {
|
||||||
int num = -1;
|
int num = -1;
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2011 MCForge
|
Copyright 2011 MCForge
|
||||||
|
|
||||||
Written by jordanneil23 with alot of help from TheMusiKid.
|
Written by jordanneil23 with alot of help from TheMusiKid.
|
||||||
|
|
||||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
not use this file except in compliance with the Licenses. You may
|
not use this file except in compliance with the Licenses. You may
|
||||||
obtain a copy of the Licenses at
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
http://www.opensource.org/licenses/ecl2.php
|
http://www.opensource.org/licenses/ecl2.php
|
||||||
http://www.gnu.org/licenses/gpl-3.0.html
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,
|
||||||
software distributed under the Licenses are distributed on an "AS IS"
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -31,38 +31,46 @@ namespace MCGalaxy.Commands {
|
|||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
int secTime = 10;
|
int secTime = 10;
|
||||||
bool shutdown = true;
|
bool shutdown = message != "cancel";
|
||||||
string file = "stopShutdown";
|
Server.abortShutdown = false;
|
||||||
if (File.Exists(file)) { File.Delete(file); }
|
|
||||||
if (message == "") { message = "Server is going to shutdown in " + secTime + " seconds"; }
|
if (message == "") {
|
||||||
else
|
message = "Server is going to shutdown in " + secTime + " seconds";
|
||||||
{
|
} else if (message == "cancel") {
|
||||||
if (message == "cancel") { File.Create(file).Close(); shutdown = false; message = "Shutdown cancelled"; }
|
Server.abortShutdown = true; message = "Shutdown cancelled";
|
||||||
else
|
} else {
|
||||||
{
|
string[] args = message.SplitSpaces(2);
|
||||||
if (!message.StartsWith("0"))
|
if (int.TryParse(args[0], out secTime)) {
|
||||||
{
|
message = args.Length > 1 ? args[1] : message;
|
||||||
string[] split = message.Split(' ');
|
} else {
|
||||||
bool isNumber = false;
|
secTime = 10;
|
||||||
try { secTime = Convert.ToInt32(split[0]); isNumber = true; }
|
|
||||||
catch { secTime = 10; isNumber = false; }
|
|
||||||
if (split.Length > 1) { if (isNumber) { message = message.Substring(1 + split[0].Length); } }
|
|
||||||
}
|
|
||||||
else { Player.Message(p, "Countdown time cannot be zero"); return; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (shutdown)
|
|
||||||
{
|
if (secTime <= 0) {
|
||||||
Player.GlobalMessage("%4" + message);
|
Player.Message(p, "Countdown time must be greater than zero"); return;
|
||||||
Server.s.Log(message);
|
|
||||||
for (int t = secTime; t > 0; t = t - 1)
|
|
||||||
{
|
|
||||||
if (!File.Exists(file)) { Player.GlobalMessage("%4Server shutdown in " + t + " seconds"); Server.s.Log("Server shutdown in " + t + " seconds"); Thread.Sleep(1000); }
|
|
||||||
else { File.Delete(file); Player.GlobalMessage("Shutdown cancelled"); Server.s.Log("Shutdown cancelled"); return; }
|
|
||||||
}
|
|
||||||
if (!File.Exists(file)) { MCGalaxy.Gui.App.ExitProgram(false); return; }
|
|
||||||
else { File.Delete(file); Player.GlobalMessage("Shutdown cancelled"); Server.s.Log("Shutdown cancelled"); return; }
|
|
||||||
}
|
}
|
||||||
|
if (!shutdown) return;
|
||||||
|
|
||||||
|
Log(message);
|
||||||
|
for (int t = secTime; t > 0; t--) {
|
||||||
|
if (!Server.abortShutdown) {
|
||||||
|
Log("Server shutdown in " + t + " seconds"); Thread.Sleep(1000);
|
||||||
|
} else {
|
||||||
|
Server.abortShutdown = false; Log("Shutdown cancelled"); return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Server.abortShutdown) {
|
||||||
|
MCGalaxy.Gui.App.ExitProgram(false);
|
||||||
|
} else {
|
||||||
|
Server.abortShutdown = false; Log("Shutdown cancelled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Log(string message) {
|
||||||
|
Player.GlobalMessage("&4" + message);
|
||||||
|
Server.s.Log(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
|
@ -14,64 +14,54 @@
|
|||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
namespace MCGalaxy.Commands.Building {
|
namespace MCGalaxy.Commands.Building {
|
||||||
public sealed class CmdMode : Command {
|
public sealed class CmdMode : Command {
|
||||||
public override string name { get { return "mode"; } }
|
public override string name { get { return "mode"; } }
|
||||||
public override string shortcut { get { return ""; } }
|
public override string shortcut { get { return ""; } }
|
||||||
public override string type { get { return CommandTypes.Building; } }
|
public override string type { get { return CommandTypes.Building; } }
|
||||||
public override bool museumUsable { get { return false; } }
|
public override bool museumUsable { get { return false; } }
|
||||||
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
|
||||||
public CmdMode() { }
|
public CmdMode() { }
|
||||||
|
|
||||||
public override void Use(Player p, string message)
|
public override void Use(Player p, string message) {
|
||||||
{
|
if (message == "") {
|
||||||
if (message == "")
|
if (p.modeType != 0) {
|
||||||
{
|
Player.Message(p, "&b{0} %Smode: &cOFF", Block.Name(p.modeType).Capitalize());
|
||||||
if (p.modeType != 0)
|
p.modeType = 0;
|
||||||
{
|
} else {
|
||||||
Player.Message(p, "&b" + Block.Name(p.modeType)[0].ToString().ToUpper() + Block.Name(p.modeType).Remove(0, 1).ToLower() + " %Smode: &cOFF");
|
Help(p);
|
||||||
p.modeType = 0;
|
}
|
||||||
}
|
return;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
Help(p); return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
byte b = Block.Byte(message);
|
|
||||||
if (b == Block.Zero) { Player.Message(p, "Could not find block given."); return; }
|
|
||||||
if (b == Block.air) { Player.Message(p, "Cannot use Air Mode."); return; }
|
|
||||||
|
|
||||||
if (!p.allowTnt && (b == Block.tnt || b == Block.bigtnt || b == Block.smalltnt
|
byte b = Block.Byte(message);
|
||||||
|| b == Block.nuketnt || b == Block.tntexplosion)) {
|
if (b == Block.Zero) { Player.Message(p, "Could not find block given."); return; }
|
||||||
Player.Message(p, "Tnt usage is not allowed at the moment"); return;
|
if (b == Block.air) { Player.Message(p, "Cannot use Air Mode."); return; }
|
||||||
}
|
|
||||||
|
|
||||||
if (!p.allowTnt && b == Block.fire) {
|
if (!p.allowTnt && (b == Block.tnt || b == Block.bigtnt || b == Block.smalltnt
|
||||||
Player.Message(p, "Tnt usage is not allowed at the moment, fire is a lighter for tnt and is also disabled"); return;
|
|| b == Block.nuketnt || b == Block.tntexplosion)) {
|
||||||
}
|
Player.Message(p, "Tnt usage is not allowed at the moment"); return;
|
||||||
|
}
|
||||||
|
if (!p.allowTnt && b == Block.fire) {
|
||||||
|
Player.Message(p, "Tnt usage is not allowed at the moment, fire is a lighter for tnt and is also disabled"); return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Block.canPlace(p, b)) { Player.Message(p, "Cannot place this block at your rank."); return; }
|
if (!Block.canPlace(p, b)) { Player.Message(p, "Cannot place this block at your rank."); return; }
|
||||||
|
|
||||||
if (p.modeType == b)
|
if (p.modeType == b) {
|
||||||
{
|
Player.Message(p, "&b{0} %Smode: &cOFF", Block.Name(p.modeType).Capitalize());
|
||||||
Player.Message(p, "&b" + Block.Name(p.modeType)[0].ToString().ToUpper() + Block.Name(p.modeType).Remove(0, 1).ToLower() + " %Smode: &cOFF");
|
p.modeType = 0;
|
||||||
p.modeType = 0;
|
} else {
|
||||||
}
|
p.modeType = b;
|
||||||
else
|
Player.Message(p, "&b{0} %Smode: &aON", Block.Name(p.modeType).Capitalize());
|
||||||
{
|
}
|
||||||
p.modeType = b;
|
}
|
||||||
Player.Message(p, "&b" + Block.Name(p.modeType)[0].ToString().ToUpper() + Block.Name(p.modeType).Remove(0, 1).ToLower() + " %Smode: &aON");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%T/mode [block]");
|
Player.Message(p, "%T/mode [block]");
|
||||||
Player.Message(p, "%HMakes every block placed into [block].");
|
Player.Message(p, "%HMakes every block placed into [block].");
|
||||||
Player.Message(p, "%H/[block] also works");
|
Player.Message(p, "%H/[block] also works");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -365,8 +365,7 @@ namespace MCGalaxy
|
|||||||
|
|
||||||
public static bool flipHead = false;
|
public static bool flipHead = false;
|
||||||
|
|
||||||
public static bool shuttingDown = false;
|
public static bool shuttingDown = false, restarting = false, abortShutdown = false;
|
||||||
public static bool restarting = false;
|
|
||||||
|
|
||||||
//hackrank stuff
|
//hackrank stuff
|
||||||
[ConfigBool("kick-on-hackrank", "Other", null, true)]
|
[ConfigBool("kick-on-hackrank", "Other", null, true)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user