Skip to content

Commit

Permalink
Add EULA warning to login screen and accept EULA for the user.
Browse files Browse the repository at this point in the history
  • Loading branch information
richardbenson committed Dec 1, 2014
1 parent 0ac882b commit 70ce19c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
15 changes: 15 additions & 0 deletions Source/YAMS-Library/Objects/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class MCServer

public bool RestartWhenFree = false;

public bool AgreeEULA = false;

public Dictionary<string, Player> Players = new Dictionary<string, Player> { };

public MCServer(int intServerID)
Expand Down Expand Up @@ -438,6 +440,9 @@ private void ServerError(object sender, DataReceivedEventArgs e)
this.SafeStop = true;
AutoUpdate.CheckUpdates(true);
this.Start();
} else if (strMessage.IndexOf("You need to agree to the EULA in order to run the server. Go to eula.txt for more info.") > -1)
{
this.AgreeEULA = true;
}

Database.AddLog(datTimeStamp, strMessage, "server", strLevel, false, this.ServerID);
Expand All @@ -461,6 +466,16 @@ private void ServerExited(object sender, EventArgs e)
if (!this.SafeStop)
{
System.Threading.Thread.Sleep(10000);

if (this.AgreeEULA)
{
//It's the EULA message, let's clear it.
string strPathToRead = this.ServerDirectory + @"\eula.txt";
IniParser parser = new IniParser(strPathToRead);
parser.AddSetting("ROOT", "eula", "true");
parser.SaveSettings(this.ServerDirectory + @"\eula.txt", "#Minecraft EULA file\r\n#Generated by YAMS " + DateTime.Now.ToString() + "\r\n");
}

this.Start();
}
}
Expand Down
7 changes: 6 additions & 1 deletion Source/YAMS-Web/admin/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ <h1><a href="http://rcb.li/yams" target="_blank"><abbr title="Yet Another Minecr
<input type="password" name="strPassword" class="text" /></p>
<input type="submit" value="Login" />
</form>
<div class="version-tag">v0.18<br /><a href="https://github.com/richardbenson/YAMS/wiki/Version-history" target="_blank">Version History</a></div>
<div class="version-tag">
v0.18<br />
<a href="https://github.com/richardbenson/YAMS/wiki/Version-history" target="_blank">Version History</a><br />
<div class="eula">By running a Minecraft server with YAMS you are agreeing to <a href="https://account.mojang.com/documents/minecraft_eula">Mojang's EULA</a></div>
</div>

</div>

</body>
Expand Down
2 changes: 1 addition & 1 deletion Source/YAMS-Web/assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ body {
.login #logo { float: left; background: url(../images/redbg.gif) repeat-x; padding: 100px 25px 15px; margin: -46px 30px 20px 0px; }
.login #logo h1 { text-shadow: 1px 1px 1px #7E0E0E; color: #fff; font-size: 1.6em; font-weight: normal; }
.login a { text-decoration: none; color: #fff; }
.login .version-tag { float: right; width: 70px; font-size: .8em; color: #aaa; text-shadow: 1px 1px 1px #ccc; text-align: right; }
.login .version-tag { float: right; font-size: .8em; color: #aaa; text-shadow: 1px 1px 1px #ccc; text-align: right; }
.login .version-tag a, .login .version-tag a:link, .login .version-tag a:visited { color: #777; }
.login .version-tag a:hover { text-decoration: underline; }
.login input.text { width: 146px; padding: 2px; border: 1px solid #ccc; }
Expand Down

0 comments on commit 70ce19c

Please sign in to comment.