It lets an owner of a server to require a web/forum registration of players for being able to buy a higher rank in a shop.
The feature is turned off by default as it will be useful only for a handful of servers. Also a knowledge of programming is needed in order to make it work correctly.
Below is the example of the plugin that is needed at an MCDzienny server side:
- Code: Select all
using System.IO;
using System.Net;
namespace MCDzienny
{
public class CmdRegistrationCheck : Command
{
// Don't change it.
public override string name { get { return ""; } }
public override string shortcut { get { return ""; } }
public override string type { get { return ""; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
// Init is executed only once when the server starts.
public override void Init()
{
// In the following line you tell the program to invoke DoRegistrationCheck
// method when a player registration check is needed.
Player.PlayerRegisteredCheck += DoRegistrationCheck;
}
// Here's the place where you want to write your registration check.
// The code has to include a part where it connects to your website
// and ask it whether the calling user is registered or not.
// This requires some sort of communication method between
// your web server and your minecraft server.
// The easiest way I can think of is using a POST/GET HTTP method.
// You can code a web server part of a code in PHP for example.
// Player p - player that is a subject of a check,
// bool isRegistered - variable that is by default set to 'false'
// if the player is recognized as registered
// you have to set this variable to 'true'.
// *When the isRegistered for a player is set to 'true' this state
// is saved to a database, so that the check will not be performed
// again and again, as it'd be pointless.
private void DoRegistrationCheck(Player p, ref bool isRegistered)
{
// Assuming that you decided to use GET HTTP method, example:
string query;
query = "http://writeYourWebsiteAddressHere.com/yourSubpageJustForRespondingToQueries.php?player-name=" + p.name;
using (StreamReader sr = new StreamReader(WebRequest.Create(query).GetResponse().GetResponseStream()))
{
// 1. The first line of the response is read.
// 2. Then the white spaces at the beginning and at the end are
// removed.
// 3. Then the text is changed to the lowercase.
// *You don't really have to do the 2. and 3. step
// if you do your web site coding well.
string result = sr.ReadLine().Trim().ToLower();
// In this example the php site is returing "ok" text
// if a player is found in the web site database.
// No action is needed if he is not found.
if (result == "ok")
{
isRegistered = true;
}
}
}
// Don't change it.
public override void Help(Player p) { }
public override void Use(Player p, string message) { }
}
}
*The default message in case a player is not registered is: "%cYou have to register on the forum before you can get a higher rank!". You can define your own message by a following line to 'messages/messages.txt' file :
- Code: Select all
RegistrationRequired = "Your message"