Ejemplo n.º 1
0
        public override bool doProcess(string[] args)
        {
            if (!hasPermission())
            {
                permissionError(); return(false);
            }

            string message = string.Join(" ", args).Trim();

            if (message == null || message.Length < 1)
            {
                showHelpText(); return(false);
            }

            if (this.player.group.hasPermission("admin.chat"))
            {
                message = "^#f75d5d;[ADMIN] " + this.player.name + ": " + message;
            }
            else
            {
                message = "^#ff00c7;Message to admins from " + this.player.name + ": " + message;
            }

            foreach (Client client in StarryboundServer.getClients())
            {
                if (client.playerData.group.hasPermission("admin.chat") || client == this.client)
                {
                    client.sendChatMessage(message);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public static string ReloadGroups()
        {
            try
            {
                Dictionary <string, Group> tmpDict = new Dictionary <string, Group>();

                List <Group> groupList    = GroupFile.Read(GroupsPath);
                string       defaultGroup = null;

                foreach (Group group in groupList)
                {
                    tmpDict.Add(group.name, group);
                    if (group.isDefault)
                    {
                        defaultGroup = group.name;
                    }
                }

                if (String.IsNullOrWhiteSpace(defaultGroup))
                {
                    StarryboundServer.logFatal("Default user group flag (isDefault) is not set for any groups - Please set this in the groups.json!");
                    return("isDefault flag is not set for any group!");
                }

                var buffer = StarryboundServer.getClients();
                foreach (Client client in buffer)
                {
                    if (!tmpDict.ContainsKey(client.playerData.group.name))
                    {
                        StarryboundServer.logInfo("Updating user " + client.playerData.name + " to default group (" + defaultGroup + ") as old group " + client.playerData.group.name + " has been deleted.");
                        client.playerData.group = tmpDict[defaultGroup];
                    }
                }

                StarryboundServer.defaultGroup = defaultGroup;
                StarryboundServer.groups       = tmpDict;

                StarryboundServer.logInfo("Loaded " + StarryboundServer.groups.Count + " group(s). Default group is " + defaultGroup);
                return(null);
            }
            catch (Exception) { return("Command handler threw an exception!"); }
        }
Ejemplo n.º 3
0
        public override bool doProcess(string[] args)
        {
            if (!hasPermission())
            {
                permissionError(); return(false);
            }

            if (this.client.playerData.loc == null)
            {
                this.client.sendCommandMessage("Unable to find your exact location at this time.");
                return(false);
            }

            string list = "";

            foreach (Client otherClient in StarryboundServer.getClients())
            {
                PlayerData otherPlayer = otherClient.playerData;
                if (otherPlayer.loc == null)
                {
                    continue;
                }
                else if (this.player.isInSameWorldAs(otherPlayer) && this.player.name != otherPlayer.name)
                {
                    list += otherPlayer.name + ", ";
                }
            }
            if (list.Length != 0)
            {
                this.client.sendChatMessage("^#5dc4f4;Players in this world: " + list.Substring(0, list.Length - 2));
            }
            else
            {
                this.client.sendChatMessage("^#5dc4f4;There are no other players in this world.");
            }
            return(true);
        }
Ejemplo n.º 4
0
        public override Object onReceive()
        {
            byte[] assetDigest = stream.ReadStarByteArray();

            var claim = stream.ReadStarVariant();

            byte[] UUID    = stream.ReadStarUUID();
            string name    = stream.ReadStarString();
            string species = stream.ReadStarString();

            byte[] shipWorld = stream.ReadStarByteArray();
            string account   = stream.ReadStarString();

            // Identify player to server
            this.client.playerData.uuid    = Utils.ByteArrayToString(Utils.HashUUID(UUID)).ToLower();
            this.client.playerData.name    = name;
            this.client.playerData.account = account;

            User userPData = Users.GetUser(name, this.client.playerData.uuid, this.client.playerData.ip);

            if (StarryboundServer.config.maxClients <= StarryboundServer.clientCount)
            {
                if (!userPData.getGroup().hasPermission("admin.reservedlist") || StarryboundServer.clientCount == (StarryboundServer.serverConfig.maxPlayers - 1))
                {
                    this.client.rejectPreConnected("The server is full. Please try again later.");
                    return(false);
                }
            }

            string[] reasonExpiry = Bans.checkForBan(new string[] { name, this.client.playerData.uuid, this.client.playerData.ip });
            if (reasonExpiry.Length == 2 && !userPData.getGroup().hasPermission("admin.bypassban"))
            {
                this.client.rejectPreConnected("You are " + ((reasonExpiry[1] == "0") ? "permanently" : "temporarily") + " banned from this server.\nReason: " + reasonExpiry[0]);
                return(false);
            }

            string sAssetDigest = Utils.ByteArrayToString(assetDigest);

            StarryboundServer.logDebug("AssetDigest", "[" + this.client.playerData.client + "] [" + sAssetDigest + "]");
            if (!StarryboundServer.config.allowModdedClients)
            {
                if (sAssetDigest != StarryboundServer.unmoddedClientDigest)
                {
                    this.client.rejectPreConnected("Modded client detected: You cannot modify or add asset files or mods. Please delete your entire Starbound folder and reinstall Starbound to join.");
                    return(false);
                }
            }

            if (String.IsNullOrWhiteSpace(this.client.playerData.name))
            {
                this.client.rejectPreConnected("You may not have a blank name.");
                return(false);
            }

            if (!StarryboundServer.config.allowSpaces)
            {
                if (this.client.playerData.name.Contains(" "))
                {
                    this.client.rejectPreConnected("You may not have spaces in your name on this server.");
                    return(false);
                }
            }

            if (!StarryboundServer.config.allowSymbols)
            {
                Regex r = new Regex("^[a-zA-Z0-9_\\- ]*$");
                if (!r.IsMatch(this.client.playerData.name))
                {
                    this.client.rejectPreConnected("You may not have special characters in your name on this server.");
                    return(false);
                }
            }

            if (!userPData.getGroup().hasPermission("admin.bypassban"))
            {
                foreach (string bannedUnamePhrase in StarryboundServer.config.bannedUsernames)
                {
                    if (this.client.playerData.name.ToLower().Contains(bannedUnamePhrase.ToLower()))
                    {
                        this.client.rejectPreConnected("Your name contains a phrase that is banned on this server. (" + bannedUnamePhrase + ")");
                        return(false);
                    }
                }
            }

            if (!String.IsNullOrEmpty(account))
            {
                this.client.rejectPreConnected("You need clear the server account field of all text.");
                return(false);
            }

            try
            {
                PlayerData pData = this.client.playerData;

                pData.isMuted            = userPData.isMuted;
                pData.canBuild           = userPData.canBuild;
                pData.lastOnline         = userPData.lastOnline;
                pData.group              = userPData.getGroup();
                pData.freeFuel           = userPData.freeFuel;
                pData.receivedStarterKit = userPData.receivedStarterKit;
                pData.privateShip        = userPData.privateShip;
                pData.shipBlacklist      = userPData.shipBlacklist;
                pData.shipWhitelist      = userPData.shipWhitelist;

                if (userPData.uuid != pData.uuid && userPData.groupName != StarryboundServer.defaultGroup)
                {
                    this.client.rejectPreConnected("Connection Failed: You cannot use \"" + pData.name + "\" on this server.");
                    return(false);
                }
            }
            catch (Exception)
            {
                this.client.rejectPreConnected("Connection Failed: A internal server error occurred (2)");
                return(false);
            }

            foreach (Client checkClient in StarryboundServer.getClients())
            {
                if (checkClient.playerData.name.ToLower() == name.ToLower())
                {
                    if (userPData.groupName != StarryboundServer.defaultGroup)
                    {
                        checkClient.delayDisconnect("Someone else is attempting to connect with your name. Disconnecting.");
                        this.client.rejectPreConnected("We have disconnected the old player on the server. Please try again in 15 seconds.");
                    }
                    else
                    {
                        this.client.rejectPreConnected("Someone is already logged in with this name.");
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 5
0
        public override bool doProcess(string[] args)
        {
            string staffListO = "";
            string userListO  = "";

            int noOfUsers = StarryboundServer.clientCount;
            int i         = 0;

            foreach (Group group in StarryboundServer.groups.Values)
            {
                if (group.isStaff)
                {
                    List <Client> clients = StarryboundServer.getClients(group.name);
                    foreach (Client client in clients)
                    {
                        this.staffList.Add(client);
                    }
                }
                else
                {
                    List <Client> clients = StarryboundServer.getClients(group.name);
                    foreach (Client client in clients)
                    {
                        this.userList.Add(client);
                    }
                }
            }

            this.client.sendChatMessage("^#5dc4f4;There are " + noOfUsers + "/" + StarryboundServer.config.maxClients + " player(s) online.");

            foreach (Client staffMember in this.staffList)
            {
                staffListO = staffListO + "^shadow,yellow;" + staffMember.playerData.formatName + "^#5dc4f4;";
                if (i != staffList.Count - 1)
                {
                    staffListO = staffListO + ", ";
                }
                i++;
            }

            i = 0;

            foreach (Client player in this.userList)
            {
                userListO = userListO + "^shadow,yellow;" + player.playerData.formatName + "^#5dc4f4;";
                if (i != userList.Count - 1)
                {
                    userListO = userListO + ", ";
                }
                i++;
            }

            if (staffList.Count > 0)
            {
                this.client.sendChatMessage("Staff: " + staffListO);
            }
            if (userList.Count > 0)
            {
                this.client.sendChatMessage("Players: " + userListO);
            }

            return(true);
        }