mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Add /irccontrollers rank [rank] to set rank of IRC controllers, make server.properties saving threadsafe, make default rank of pass/setpass operator.
This commit is contained in:
parent
17e1f4cc0a
commit
51fa8002df
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2012 MCGalaxy
|
Copyright 2012 MCForge
|
||||||
|
|
||||||
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
|
||||||
|
@ -19,7 +19,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MCGalaxy.Commands {
|
namespace MCGalaxy.Commands {
|
||||||
public sealed class CmdIrcControllers : Command {
|
public sealed class CmdIrcControllers : Command {
|
||||||
public override string name { get { return "irccontrollers"; } }
|
public override string name { get { return "irccontrollers"; } }
|
||||||
public override string shortcut { get { return "ircctrl"; } }
|
public override string shortcut { get { return "ircctrl"; } }
|
||||||
public override string type { get { return CommandTypes.Moderation; } }
|
public override string type { get { return CommandTypes.Moderation; } }
|
||||||
@ -36,6 +36,7 @@ namespace MCGalaxy.Commands {
|
|||||||
Server.ircControllers = PlayerList.Load("IRC_Controllers.txt");
|
Server.ircControllers = PlayerList.Load("IRC_Controllers.txt");
|
||||||
Player.Message(p, "IRC Controllers reloaded!");
|
Player.Message(p, "IRC Controllers reloaded!");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "add":
|
case "add":
|
||||||
if (parts.Length < 2) { Player.Message(p, "You need to provide a name to add."); return; }
|
if (parts.Length < 2) { Player.Message(p, "You need to provide a name to add."); return; }
|
||||||
if (Server.ircControllers.Contains(parts[1])) {
|
if (Server.ircControllers.Contains(parts[1])) {
|
||||||
@ -46,6 +47,7 @@ namespace MCGalaxy.Commands {
|
|||||||
Server.ircControllers.Save();
|
Server.ircControllers.Save();
|
||||||
Player.Message(p, parts[1] + " added to the IRC controller list.");
|
Player.Message(p, parts[1] + " added to the IRC controller list.");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "remove":
|
case "remove":
|
||||||
if (parts.Length < 2) { Player.Message(p, "You need to provide a name to remove."); return; }
|
if (parts.Length < 2) { Player.Message(p, "You need to provide a name to remove."); return; }
|
||||||
if (!Server.ircControllers.Contains(parts[1])) {
|
if (!Server.ircControllers.Contains(parts[1])) {
|
||||||
@ -56,19 +58,49 @@ namespace MCGalaxy.Commands {
|
|||||||
Server.ircControllers.Save();
|
Server.ircControllers.Save();
|
||||||
Player.Message(p, parts[1] + " removed from the IRC controller list.");
|
Player.Message(p, parts[1] + " removed from the IRC controller list.");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "list":
|
case "list":
|
||||||
string names = Server.ircControllers.All().Concatenate(", ");
|
string names = Server.ircControllers.All().Concatenate(", ");
|
||||||
Player.Message(p, "IRC controllers list:");
|
Player.Message(p, "IRC controllers list:");
|
||||||
Player.Message(p, names);
|
Player.Message(p, names);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
case "rank":
|
||||||
|
if (parts.Length < 2) {
|
||||||
|
Group exist = Group.findPerm(Server.ircControllerRank);
|
||||||
|
if (exist == null)
|
||||||
|
Player.Message(p, "IRC controllers have permission level {0}.", (int)Server.ircControllerRank);
|
||||||
|
else
|
||||||
|
Player.Message(p, "IRC controllers have the rank {0}", exist.ColoredName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Group grp = Group.FindOrShowMatches(p, parts[1]);
|
||||||
|
if (grp == null) return;
|
||||||
|
if (p != null && Server.ircControllerRank > p.group.Permission) {
|
||||||
|
Player.Message(p, "Cannot change the IRC controllers rank, as it is currently a rank higher than yours."); return;
|
||||||
|
}
|
||||||
|
if (p != null && grp.Permission > p.group.Permission) {
|
||||||
|
Player.Message(p, "Cannot set the IRC controllers rank to a rank higher than yours."); return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Server.ircControllerRank = grp.Permission;
|
||||||
|
SrvProperties.Save();
|
||||||
|
Player.Message(p, "Set IRC controller rank to {0}%S.", grp.ColoredName);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Help(p); break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%T/ircctrl <add/remove> [name]");
|
Player.Message(p, "%T/irccontrollers <add/remove> [name]");
|
||||||
Player.Message(p, "%HAdds or removes <name> from list of IRC controllers");
|
Player.Message(p, "%HAdds or removes [name] from list of IRC controllers");
|
||||||
Player.Message(p, "%T/ircctrl <reload/list>");
|
Player.Message(p, "%T/irccontrollers <reload/list>");
|
||||||
Player.Message(p, "%HReloads or outputslist of IRC controllers");
|
Player.Message(p, "%HReloads or outputslist of IRC controllers");
|
||||||
|
Player.Message(p, "%T/irccontrollers rank [rank]");
|
||||||
|
Player.Message(p, "%HSets which rank IRC controllers are treated as having in-game.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
Copyright 2012 MCGalaxy
|
Copyright 2012 MCForge
|
||||||
|
|
||||||
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
|
||||||
@ -20,15 +20,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using MCGalaxy.Util;
|
using MCGalaxy.Util;
|
||||||
namespace MCGalaxy.Commands
|
|
||||||
{
|
namespace MCGalaxy.Commands {
|
||||||
public sealed class CmdPass : Command
|
public sealed class CmdPass : Command {
|
||||||
{
|
|
||||||
public override string name { get { return "pass"; } }
|
public override string name { get { return "pass"; } }
|
||||||
public override string shortcut { get { return ""; } }
|
public override string shortcut { get { return ""; } }
|
||||||
public override string type { get { return CommandTypes.Other; } }
|
public override string type { get { return CommandTypes.Other; } }
|
||||||
public override bool museumUsable { get { return true; } }
|
public override bool museumUsable { get { return true; } }
|
||||||
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||||
|
|
||||||
public CmdPass() { }
|
public CmdPass() { }
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
Copyright 2012 MCGalaxy
|
Copyright 2012 MCForge
|
||||||
|
|
||||||
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
|
||||||
@ -19,15 +19,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using MCGalaxy.Util;
|
using MCGalaxy.Util;
|
||||||
namespace MCGalaxy.Commands
|
|
||||||
{
|
namespace MCGalaxy.Commands {
|
||||||
public sealed class CmdSetPass : Command
|
public sealed class CmdSetPass : Command {
|
||||||
{
|
|
||||||
public override string name { get { return "setpass"; } }
|
public override string name { get { return "setpass"; } }
|
||||||
public override string shortcut { get { return ""; } }
|
public override string shortcut { get { return ""; } }
|
||||||
public override string type { get { return CommandTypes.Other; } }
|
public override string type { get { return CommandTypes.Other; } }
|
||||||
public override bool museumUsable { get { return true; } }
|
public override bool museumUsable { get { return true; } }
|
||||||
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||||
public CmdSetPass() { }
|
public CmdSetPass() { }
|
||||||
|
|
||||||
public override void Use(Player p, string message)
|
public override void Use(Player p, string message)
|
||||||
|
@ -70,11 +70,13 @@ namespace MCGalaxy {
|
|||||||
internal class ReviewPerms { public int viewPerm = -1, nextPerm = -1, clearPerm = -1; }
|
internal class ReviewPerms { public int viewPerm = -1, nextPerm = -1, clearPerm = -1; }
|
||||||
|
|
||||||
public static void Save() { Save("properties/server.properties"); }
|
public static void Save() { Save("properties/server.properties"); }
|
||||||
|
static readonly object saveLock = new object();
|
||||||
public static void Save(string givenPath) {
|
public static void Save(string givenPath) {
|
||||||
try {
|
try {
|
||||||
using (CP437Writer w = new CP437Writer(givenPath))
|
lock (saveLock) {
|
||||||
SaveProps(w);
|
using (CP437Writer w = new CP437Writer(givenPath))
|
||||||
|
SaveProps(w);
|
||||||
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Server.ErrorLog(ex);
|
Server.ErrorLog(ex);
|
||||||
Server.s.Log("SAVE FAILED! " + givenPath);
|
Server.s.Log("SAVE FAILED! " + givenPath);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2012 MCGalaxy
|
Copyright 2012 MCForge
|
||||||
|
|
||||||
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
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2012 MCGalaxy
|
Copyright 2012 MCForge
|
||||||
|
|
||||||
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
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2012 MCGalaxy
|
Copyright 2012 MCForge
|
||||||
|
|
||||||
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user