Cleanup /xban.

This commit is contained in:
UnknownShadow200 2016-01-30 07:37:32 +11:00
parent 063c8794f5
commit 32e500d63f
3 changed files with 40 additions and 69 deletions

View File

@ -63,7 +63,7 @@ namespace MCGalaxy.Commands {
char code2 = code; char code2 = code;
if (Colors.MapColor(ref code2)) { if (Colors.MapColor(ref code2)) {
Player.SendMessage(p, "There is already a custom or server defined color with the code " + code + Player.SendMessage(p, "There is already a custom or server defined color with the code " + code +
", you must either use a different code or use \"/ccols remove " + code + "\""); ", you must either use a different code or use \"%T/ccols remove " + code + "%S\"");
return; return;
} }

View File

@ -15,55 +15,30 @@
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 namespace MCGalaxy.Commands {
{
public sealed class CmdXban : Command public sealed class CmdXban : Command {
{
public override string name { get { return "xban"; } } public override string name { get { return "xban"; } }
public override string shortcut { get { return ""; } } public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Moderation; } } public override string type { get { return CommandTypes.Moderation; } }
public override bool museumUsable { get { return false; } } public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public CmdXban() { } public CmdXban() { }
public override void Use(Player p, string message)
{
public override void Use(Player p, string message) {
if (message == "") { Help(p); return; } if (message == "") { Help(p); return; }
Player who = Player.Find(message.Split(' ')[0]); string name = message.Split(' ')[0];
string msg = message.Split(' ')[0]; Player who = Player.Find(name);
if (p != null) Command.all.Find("ban").Use(p, message);
{ Command.all.Find("banip").Use(p, "@" + name);
p.ignorePermission = true;
}
try
{
if (who != null) if (who != null)
{
Command.all.Find("xundo").Use(p, msg);
Command.all.Find("ban").Use(p, msg);
Command.all.Find("banip").Use(p, "@" + msg);
Command.all.Find("kick").Use(p, message); Command.all.Find("kick").Use(p, message);
Command.all.Find("xundo").Use(p, msg); Command.all.Find("xundo").Use(p, name);
}
else
{
Command.all.Find("ban").Use(p, msg);
Command.all.Find("banip").Use(p, "@" + msg);
Command.all.Find("xundo").Use(p, msg);
} }
} public override void Help(Player p) {
finally
{
if (p != null) p.ignorePermission = false;
}
}
public override void Help(Player p)
{
Player.SendMessage(p, "/xban [name] [message]- Bans, banips, undoes, and kicks [name] with [message], if specified."); Player.SendMessage(p, "/xban [name] [message]- Bans, banips, undoes, and kicks [name] with [message], if specified.");
} }
} }

View File

@ -16,10 +16,10 @@
permissions and limitations under the Licenses. permissions and limitations under the Licenses.
*/ */
using System.IO; using System.IO;
namespace MCGalaxy.Commands namespace MCGalaxy.Commands {
{
public sealed class CmdReload : Command public sealed class CmdReload : Command {
{
public override string name { get { return "reload"; } } public override string name { get { return "reload"; } }
public override string shortcut { get { return "rd"; } } public override string shortcut { get { return "rd"; } }
public override string type { get { return CommandTypes.World; } } public override string type { get { return CommandTypes.World; } }
@ -27,21 +27,17 @@ namespace MCGalaxy.Commands
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public CmdReload() { } public CmdReload() { }
public override void Use(Player p, string message) public override void Use(Player p, string message) {
{
if (p == null && message == "") { if (p == null && message == "") {
Player.SendMessage(p, "You must give a level name when running the command from console."); Player.SendMessage(p, "You must give a level name when running the command from console."); return;
return;
} }
string name = message == "" ? p.level.name : message; string name = message == "" ? p.level.name : message;
if (!File.Exists("levels/" + name + ".lvl")) { if (!File.Exists("levels/" + name + ".lvl")) {
Player.SendMessage(p, "The given level \"" + name + "\" does not exist."); Player.SendMessage(p, "The given level \"" + name + "\" does not exist."); return;
return;
} }
if (Server.mainLevel.name == name) { if (Server.mainLevel.name == name) {
Player.SendMessage(p, "You cannot reload the main level."); Player.SendMessage(p, "You cannot reload the main level."); return;
return;
} }
foreach (Player pl in Player.players) { foreach (Player pl in Player.players) {