Jump to content
  • Sign Up
  • 0
tux_peng

[MCGalaxy] Can I require players register on my forum?

Question

Posted (edited)

Can I require all users register on my forum before building.  Like setting a default password for all new players?  I could the send that upon registration.

Edited by tux_peng

Share this post


Link to post

1 answer to this question

Recommended Posts

  • 0

Yes. Using the server property "agree-to-rules-on-entry = true", you can prevent players from building or using commands before they agree to the rules. Then you can use a plugin to override the normal /rules agree behavior to require a password based on your specifications.

Here is an example plugin. You would place this inside a file called forumpass.cs in your plugins folder, then use /pcompile forumpass , /pload forumpass
 

using System;
using MCGalaxy;
using MCGalaxy.Events.PlayerEvents;
using MCGalaxy.Commands;

namespace Lol
{
    public sealed class ForumPass : Plugin 
    {
        public override string creator { get { return "Goodly"; } }
        public override string name { get { return "forumpass"; } }
        public override string MCGalaxy_Version { get { return "1.9.3.6"; } }
        
        public override void Load(bool startup) {
            OnPlayerCommandEvent.Register(OnPlayerCommand, Priority.Low);
            OnPlayerChatEvent.Register(OnPlayerChat, Priority.High);
        }
        public override void Unload(bool shutdown) {
            OnPlayerCommandEvent.Unregister(OnPlayerCommand);
            OnPlayerChatEvent.Unregister(OnPlayerChat);
        }
        
        static void OnPlayerCommand(Player p, string cmd, string args, CommandData data) {
            if (cmd.CaselessEq("rules")) {
                p.cancelcommand = true;
                if (args.CaselessEq("agree")) {
                    
                    if (!p.hasreadrules) {
                        p.Message("You must read the rules before agreeing to them. Dimb ass.");
                        return;
                    }
                    
                    if (p.agreed) {
                        p.Message("You already agreed to the rules.");
                        return;
                    }
                    
                    p.Message("To agree to the rules, you must enter /pass [pass] from your forum account.");
                    return;
                }
                p.hasreadrules = true;
                //Since we are overriding the normal rules command, you must display the rules here via p.Message
                p.Message("Rules:");
                p.Message("0. Make a forum account to play here.");
                p.Message("1. Don't make your level too difficult to join");
                p.Message("2. TODO");
                return;
            }
            
            if (cmd.CaselessEq("pass")) {
                p.cancelcommand = true;
                //the command /pass actually exists and does something else but we're going to hijack it because it is
                //one of the few commands that actually invokes OnPlayerCommand before the user has agreed to the rules
                if (p.agreed) { p.Message("You already correctly entered the password."); return; }
                
                if (!p.hasreadrules) { p.Message("&9You must read &T/Rules &9before entering the password."); return; }
                if (args.Length == 0) { p.Message("Please enter a password."); return; }
                
                if (args != GetPassword(p)) { p.Message("Incorrect password."); return; }
                
                p.Message("&6You've succesfully entered the password. Welcome!");
                Command.Find("rules").Use(p, "agree");
                return; //this return is only here in case you add other command cases below this if statement
            }
        }
        
        static string GetPassword(Player p) {
            //Modify this method for your requirements
            return p.name + "waow";
        }
        
        static void OnPlayerChat(Player p, string message) {
            // Optionally mute players who haven't entered pass yet
            //if (!p.agreed) { p.Message("&cBefore speaking, you must read /rules then agree to them with /agree."); p.cancelchat = true; }
        }
        
    }
}

If you modify the file and want to reload the plugin, use /punload forumpass , then /pcompile forumpass, then /pload forumpass

  • Friendly 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...