Exemplo n.º 1
0
        public static BlockDefinition[] Load(string path)
        {
            BlockDefinition[] defs = new BlockDefinition[Block.SUPPORTED_COUNT];
            if (!File.Exists(path))
            {
                return(defs);
            }
            if (elems == null)
            {
                elems = ConfigElement.GetAll(typeof(BlockDefinition));
            }

            try {
                string json = File.ReadAllText(path);

                JsonReader reader = new JsonReader(json);
                reader.OnMember = (obj, key, value) => {
                    if (obj.Meta == null)
                    {
                        obj.Meta = new BlockDefinition();
                    }
                    ConfigElement.Parse(elems, obj.Meta, key, (string)value);
                };

                JsonArray array = (JsonArray)reader.Parse();
                if (array == null)
                {
                    return(defs);
                }

                foreach (object raw in array)
                {
                    JsonObject obj = (JsonObject)raw;
                    if (obj == null || obj.Meta == null)
                    {
                        continue;
                    }

                    BlockDefinition def = (BlockDefinition)obj.Meta;
                    if (String.IsNullOrEmpty(def.Name))
                    {
                        continue;
                    }

                    BlockID block = def.GetBlock();
                    if (block >= defs.Length)
                    {
                        Logger.Log(LogType.Warning, "Invalid block ID: " + def.RawID);
                    }
                    else
                    {
                        defs[block] = def;
                    }

                    // In case user manually edited fallback in the json file
                    def.FallBack = Math.Min(def.FallBack, Block.CPE_MAX_BLOCK);
                }
            } catch (Exception ex) {
                Logger.LogError("Error Loading block defs from " + path, ex);
            }
            return(defs);
        }
Exemplo n.º 2
0
 public bool Load(string path)
 {
     return(ConfigElement.ParseFile(Server.levelConfig, path, this));
 }
Exemplo n.º 3
0
        static void SaveProps(StreamWriter w)
        {
            w.WriteLine("#   Edit the settings below to modify how your server operates. This is an explanation of what each setting does.");
            w.WriteLine("#   server-name                   = The name which displays on classicube.net");
            w.WriteLine("#   motd                          = The message which displays when a player connects");
            w.WriteLine("#   port                          = The port to operate from");
            w.WriteLine("#   console-only                  = Run without a GUI (useful for Linux servers with mono)");
            w.WriteLine("#   verify-names                  = Verify the validity of names");
            w.WriteLine("#   public                        = Set to true to appear in the public server list");
            w.WriteLine("#   max-players                   = The maximum number of connections");
            w.WriteLine("#   max-guests                    = The maximum number of guests allowed");
            w.WriteLine("#   max-maps                      = The maximum number of maps loaded at once");
            w.WriteLine("#   world-chat                    = Set to true to enable world chat");
            w.WriteLine("#   irc                           = Set to true to enable the IRC bot");
            w.WriteLine("#   irc-nick                      = The name of the IRC bot");
            w.WriteLine("#   irc-server                    = The server to connect to");
            w.WriteLine("#   irc-channel                   = The channel to join");
            w.WriteLine("#   irc-opchannel                 = The channel to join (posts OpChat)");
            w.WriteLine("#   irc-port                      = The port to use to connect");
            w.WriteLine("#   irc-identify                  = (true/false)    Do you want the IRC bot to Identify itself with nickserv. Note: You will need to register it's name with nickserv manually.");
            w.WriteLine("#   irc-password                  = The password you want to use if you're identifying with nickserv");
            w.WriteLine("#   anti-tunnels                  = Stops people digging below max-depth");
            w.WriteLine("#   max-depth                     = The maximum allowed depth to dig down");
            w.WriteLine("#   backup-time                   = The number of seconds between automatic backups");
            w.WriteLine("#   overload                      = The higher this is, the longer the physics is allowed to lag.  Default 1500");
            w.WriteLine("#   use-whitelist                 = Switch to allow use of a whitelist to override IP bans for certain players.  Default false.");
            w.WriteLine("#   premium-only                  = Only allow premium players (paid for minecraft) to access the server. Default false.");
            w.WriteLine("#   force-cuboid                  = Run cuboid until the limit is hit, instead of canceling the whole operation.  Default false.");
            w.WriteLine("#   profanity-filter              = Replace certain bad words in the chat.  Default false.");
            w.WriteLine("#   notify-on-join-leave          = Show a balloon popup in tray notification area when a player joins/leaves the server.  Default false.");
            w.WriteLine("#   allow-tp-to-higher-ranks      = Allows the teleportation to players of higher ranks");
            w.WriteLine("#   agree-to-rules-on-entry       = Forces all new players to the server to agree to the rules before they can build or use commands.");
            w.WriteLine("#   adminchat-perm                = The rank required to view adminchat. Default rank is superop.");
            w.WriteLine("#   admins-join-silent            = Players who have adminchat permission join the game silently. Default true");
            w.WriteLine("#   server-owner                  = The minecraft name, of the owner of the server.");
            w.WriteLine("#   total-undo                    = Track changes made by the last X people logged on for undo purposes. Folder is rotated when full, so when set to 200, will actually track around 400.");
            w.WriteLine("#   guest-limit-notify            = Show -Too Many Guests- message in chat when maxGuests has been reached. Default false");
            w.WriteLine("#   guest-join-notify             = Shows when guests and lower ranks join server in chat and IRC. Default true");
            w.WriteLine("#   guest-leave-notify            = Shows when guests and lower ranks leave server in chat and IRC. Default true");
            w.WriteLine();
            w.WriteLine("#   UseMySQL                      = Use MySQL (true) or use SQLite (false)");
            w.WriteLine("#   Host                          = The host name for the database (usually 127.0.0.1)");
            w.WriteLine("#   SQLPort                       = Port number to be used for MySQL.  Unless you manually changed the port, leave this alone.  Default 3306.");
            w.WriteLine("#   Username                      = The username you used to create the database (usually root)");
            w.WriteLine("#   Password                      = The password set while making the database");
            w.WriteLine("#   DatabaseName                  = The name of the database stored (Default = MCZall)");
            w.WriteLine();
            w.WriteLine("#   defaultColor                  = The color code of the default messages (Default = &e)");
            w.WriteLine();
            w.WriteLine("#   kick-on-hackrank              = Set to true if hackrank should kick players");
            w.WriteLine("#   hackrank-kick-time            = Number of seconds until player is kicked");
            w.WriteLine("#   custom-rank-welcome-messages  = Decides if different welcome messages for each rank is enabled. Default true.");
            w.WriteLine("#   ignore-ops                    = Decides whether or not an operator can be ignored. Default false.");
            w.WriteLine();
            w.WriteLine("#   admin-verification            = Determines whether admins have to verify on entry to the server.  Default true.");
            w.WriteLine("#   verify-admin-perm             = The minimum rank required for admin verification to occur.");
            w.WriteLine();
            w.WriteLine("#   mute-on-spam                  = If enabled it mutes a player for spamming.  Default false.");
            w.WriteLine("#   spam-messages                 = The amount of messages that have to be sent \"consecutively\" to be muted.");
            w.WriteLine("#   spam-mute-time                = The amount of seconds a player is muted for spam.");
            w.WriteLine("#   spam-counter-reset-time       = The amount of seconds the \"consecutive\" messages have to fall between to be considered spam.");
            w.WriteLine();
            w.WriteLine("#   As an example, if you wanted the spam to only mute if a user posts 5 messages in a row within 2 seconds, you would use the folowing:");
            w.WriteLine("#   mute-on-spam                  = true");
            w.WriteLine("#   spam-messages                 = 5");
            w.WriteLine("#   spam-mute-time                = 60");
            w.WriteLine("#   spam-counter-reset-time       = 2");
            w.WriteLine("#   bufferblocks                  = Should buffer blocks by default for maps?");
            w.WriteLine();

            ConfigElement.Serialise(Server.serverConfig, w, null);
        }
Exemplo n.º 4
0
 void LineProcessor(string key, string value)
 {
     ConfigElement.Parse(cfg, config, key, value);
 }