mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
ranks/agreed.txt now uses the standard ranks player list format, instead of its own hardcoded special way.
This commit is contained in:
parent
a793a164ba
commit
482e62d6a7
@ -30,40 +30,26 @@ namespace MCGalaxy.Commands
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
|
||||
public CmdAgree() { }
|
||||
|
||||
public override void Use(Player p, string message)
|
||||
{
|
||||
public override void Use(Player p, string message) {
|
||||
if (Player.IsSuper(p)) { MessageInGameOnly(p); return; }
|
||||
if (Server.agreetorulesonentry == false)
|
||||
{
|
||||
Player.Message(p, "This command can only be used if agree-to-rules-on-entry is enabled!");
|
||||
return;
|
||||
if (!Server.agreetorulesonentry) {
|
||||
Player.Message(p, "This command can only be used if agree-to-rules-on-entry is enabled."); return;
|
||||
}
|
||||
var agreed = File.ReadAllText("ranks/agreed.txt");
|
||||
if (p.hasreadrules == false)
|
||||
{
|
||||
Player.Message(p, "&9You must read /rules before agreeing!");
|
||||
return;
|
||||
|
||||
if (!p.hasreadrules) {
|
||||
Player.Message(p, "&9You must read /rules before agreeing!"); return;
|
||||
}
|
||||
if ((agreed+" ").Contains(" " + p.name.ToLower() + " ")) //Edited to prevent inner names from working.
|
||||
{
|
||||
Player.Message(p, "You have already agreed to the rules!");
|
||||
return;
|
||||
if (Server.agreed.Contains(p.name)) {
|
||||
Player.Message(p, "You have already agreed to the rules!"); return;
|
||||
}
|
||||
|
||||
p.agreed = true;
|
||||
Player.Message(p, "Thank you for agreeing to follow the rules. You may now build and use commands!");
|
||||
string playerspath = "ranks/agreed.txt";
|
||||
if (File.Exists(playerspath))
|
||||
{
|
||||
//We don't want player "test" to have already agreed if "nate" and "stew" agrred.
|
||||
// the preveious one, though, would put "natesteve" which also allows test
|
||||
//There is a better way, namely regular expressions, but I'll worry about that later.
|
||||
File.AppendAllText(playerspath, " " + p.name.ToLower()); //Ensures every name is seperated by a space.
|
||||
Server.agreed.Add(p.name);
|
||||
Server.agreed.Save(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void Help(Player p)
|
||||
{
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "/agree - Agree to the rules when entering the server");
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,8 @@
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
namespace MCGalaxy.Commands
|
||||
{
|
||||
public sealed class CmdDisagree : Command
|
||||
{
|
||||
namespace MCGalaxy.Commands {
|
||||
public sealed class CmdDisagree : Command {
|
||||
public override string name { get { return "disagree"; } }
|
||||
public override string shortcut { get { return ""; } }
|
||||
public override string type { get { return CommandTypes.Other; } }
|
||||
@ -28,24 +26,19 @@ namespace MCGalaxy.Commands
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
|
||||
public CmdDisagree() { }
|
||||
|
||||
public override void Use(Player p, string message)
|
||||
{
|
||||
public override void Use(Player p, string message) {
|
||||
if (Player.IsSuper(p)) { MessageInGameOnly(p); return; }
|
||||
if (!Server.agreetorulesonentry)
|
||||
{
|
||||
if (!Server.agreetorulesonentry) {
|
||||
Player.Message(p, "This command can only be used if agree-to-rules-on-entry is enabled in the console!");
|
||||
return;
|
||||
}
|
||||
if (p.group.Permission > LevelPermission.Guest)
|
||||
{
|
||||
Player.Message(p, "Your awesomeness prevents you from using this command");
|
||||
return;
|
||||
if (p.group.Permission > LevelPermission.Guest) {
|
||||
Player.Message(p, "Your awesomeness prevents you from using this command"); return;
|
||||
}
|
||||
p.Leave("If you don't agree with the rules, consider playing elsewhere.");
|
||||
}
|
||||
|
||||
public override void Help(Player p)
|
||||
{
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "/disagree - Disagree to the rules when entering the server");
|
||||
}
|
||||
}
|
||||
|
@ -552,15 +552,10 @@ namespace MCGalaxy {
|
||||
|
||||
CheckLoginJailed();
|
||||
CheckReviewList();
|
||||
if (Server.agreetorulesonentry) {
|
||||
if (!File.Exists("ranks/agreed.txt"))
|
||||
File.WriteAllText("ranks/agreed.txt", "");
|
||||
var agreedFile = File.ReadAllText("ranks/agreed.txt");
|
||||
if (group.Permission == LevelPermission.Guest && !agreedFile.Contains(this.name.ToLower())) {
|
||||
if (Server.agreetorulesonentry && group.Permission == LevelPermission.Guest && !Server.agreed.Contains(name)) {
|
||||
SendMessage("&9You must read the &c/rules&9 and &c/agree&9 to them before you can build and use commands!");
|
||||
agreed = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Server.verifyadmins && group.Permission >= Server.verifyadminsrank) {
|
||||
if (!Directory.Exists("extra/passwords") || !File.Exists("extra/passwords/" + this.name + ".dat"))
|
||||
|
@ -27,6 +27,9 @@ namespace MCGalaxy {
|
||||
List<string> players = new List<string>();
|
||||
readonly object locker = new object();
|
||||
|
||||
public PlayerList() { }
|
||||
public PlayerList(string file) { this.file = file; }
|
||||
|
||||
public void Add(string p) {
|
||||
lock (locker)
|
||||
players.Add(p.ToLower());
|
||||
@ -76,10 +79,8 @@ namespace MCGalaxy {
|
||||
public static PlayerList Load(string path) {
|
||||
if (!Directory.Exists("ranks"))
|
||||
Directory.CreateDirectory("ranks");
|
||||
PlayerList list = new PlayerList();
|
||||
list.file = path;
|
||||
PlayerList list = new PlayerList(path);
|
||||
path = "ranks/" + path;
|
||||
|
||||
if (!File.Exists(path)) {
|
||||
File.Create(path).Close();
|
||||
Server.s.Log("CREATED NEW: " + list.file);
|
||||
|
@ -66,6 +66,14 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
void LoadPlayerLists() {
|
||||
agreed = new PlayerList("ranks/agreed.txt");
|
||||
try {
|
||||
CheckOldAgreed();
|
||||
agreed = PlayerList.Load("agreed.txt");
|
||||
} catch (Exception ex) {
|
||||
Server.ErrorLog(ex);
|
||||
}
|
||||
|
||||
bannedIP = PlayerList.Load("banned-ip.txt");
|
||||
ircControllers = PlayerList.Load("IRC_Controllers.txt");
|
||||
muted = PlayerList.Load("muted.txt");
|
||||
@ -81,6 +89,19 @@ namespace MCGalaxy {
|
||||
whiteList = PlayerList.Load("whitelist.txt");
|
||||
}
|
||||
|
||||
void CheckOldAgreed() {
|
||||
// agreed.txt format used to be names separated by spaces, we need to fix that up.
|
||||
if (!File.Exists("ranks/agreed.txt")) return;
|
||||
|
||||
string data = null;
|
||||
using (FileStream fs = File.OpenRead("ranks/agreed.txt")) {
|
||||
if (fs.ReadByte() != ' ') return;
|
||||
data = new StreamReader(fs).ReadToEnd();
|
||||
data = data.Replace(" ", Environment.NewLine);
|
||||
}
|
||||
File.WriteAllText("ranks/agreed.txt", data);
|
||||
}
|
||||
|
||||
void LoadAutoloadCommands() {
|
||||
if (File.Exists("text/autoload.txt")) {
|
||||
try {
|
||||
|
@ -99,7 +99,7 @@ namespace MCGalaxy
|
||||
public static bool UseCTF = false;
|
||||
public static bool ServerSetupFinished = false;
|
||||
public static Auto_CTF ctf = null;
|
||||
public static PlayerList bannedIP, whiteList, ircControllers, muted, ignored, frozen, hidden;
|
||||
public static PlayerList bannedIP, whiteList, ircControllers, muted, ignored, frozen, hidden, agreed;
|
||||
public static PlayerExtList jailed, models, skins;
|
||||
|
||||
public static readonly List<string> Devs = new List<string>(), Mods = new List<string>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user