public override bool doProcess(string[] args) { if (!hasPermission()) { permissionError(); return(false); } string player = string.Join(" ", args).Trim(); uint warp; if (player == null || player.Length < 1) { this.client.sendCommandMessage("Teleporting to your ship."); player = ""; warp = (uint)WarpType.WarpToOwnShip; } else { if (!hasPermission(true)) { permissionError(2); return(false); } Client target = StarryboundServer.getClient(player); if (target != null) { PlayerData targetPlayer = target.playerData; if (!this.player.canAccessShip(targetPlayer)) { this.client.sendCommandMessage("You cannot access this player's ship due to their ship's access settings."); return(false); } this.client.sendCommandMessage("Teleporting to " + player + " ship!"); warp = (uint)WarpType.WarpToPlayerShip; } else { this.client.sendCommandMessage("Player '" + player + "' not found."); return(false); } } MemoryStream packetWarp = new MemoryStream(); BinaryWriter packetWrite = new BinaryWriter(packetWarp); packetWrite.WriteBE(warp); packetWrite.Write(new WorldCoordinate()); packetWrite.WriteStarString(player); client.sendServerPacket(Packet.WarpCommand, packetWarp.ToArray()); return(true); }
public override bool doProcess(string[] args) { if (!hasPermission()) { permissionError(); return(false); } string player = string.Join(" ", args).Trim(); WorldCoordinate loc = this.player.loc; if (player == null || player.Length < 1) { showHelpText(); return(false); } else { Client target = StarryboundServer.getClient(player); if (target != null) { loc = target.playerData.loc; if (loc == null) { this.client.sendCommandMessage("Unable to find an exact location for " + player + "."); return(false); } this.client.sendCommandMessage("Warping ship to " + player + " [" + loc.ToString() + "]"); } else { this.client.sendCommandMessage("Player '" + player + "' not found."); return(false); } } MemoryStream packetWarp = new MemoryStream(); BinaryWriter packetWrite = new BinaryWriter(packetWarp); packetWrite.WriteBE((uint)WarpType.MoveShip); packetWrite.Write(loc); packetWrite.WriteStarString(""); client.sendServerPacket(Packet.WarpCommand, packetWarp.ToArray()); return(true); }
public override bool doProcess(string[] args) { if (!hasPermission()) { permissionError(); return(false); } string player; string reason; if (args.Length > 1) { player = args[0].Trim(); reason = string.Join(" ", args).Substring(player.Length + 1).Trim(); } else { player = string.Join(" ", args).Trim(); reason = "breaking the rules"; } if (player == null || player.Length < 1) { showHelpText(); return(false); } Client target = StarryboundServer.getClient(player); if (!this.player.group.canTarget(target.playerData.group)) { this.client.sendCommandMessage("^#f75d5d;You do not have permission to target this user."); return(false); } if (target != null) { target.kickClient(reason); return(true); } else { this.client.sendCommandMessage("Player '" + player + "' not found."); return(false); } }
public override bool doProcess(string[] args) { if (!hasPermission()) { permissionError(); return(false); } string player = string.Join(" ", args).Trim(); if (player == null || player.Length < 1) { showHelpText(); return(false); } Client target = StarryboundServer.getClient(player); if (!this.player.group.canTarget(target.playerData.group)) { this.client.sendCommandMessage("^#f75d5d;You do not have permission to target this user."); return(false); } if (target != null) { PlayerData pData = target.playerData; pData.canBuild = !pData.canBuild; if (!pData.canBuild) { StarryboundServer.sendGlobalMessage("^#f75d5d;" + pData.name + " has had their build rights revoked!"); } else { StarryboundServer.sendGlobalMessage("^#6cdb67;" + pData.name + " has been granted build rights on the server."); } return(true); } else { this.client.sendCommandMessage("Player '" + player + "' not found."); return(false); } }
public override object onReceive() { BinaryReader packetData = (BinaryReader)this.stream; bool success = packetData.ReadBoolean(); uint clientID = packetData.ReadVarUInt32(); string rejectReason = packetData.ReadStarString(); Client target = StarryboundServer.getClient(clientID); if (target != null) { target.forceDisconnect(direction, "The parent server reclaimed this clientId"); StarryboundServer.logError("[" + this.client.playerData.name + "] " + direction + ": The parent server reclaimed this clientId (" + clientID + ")"); return(true); } this.client.playerData.id = clientID; PlayerData player = this.client.playerData; if (!success) { this.client.rejectPreConnected("Connection Failed: Rejected by parent server: " + rejectReason); return(true); } StarryboundServer.addClient(this.client); string geoip_prefix = ""; if (StarryboundServer.config.enableGeoIP && StarryboundServer.Geo != null) { var code = StarryboundServer.Geo.TryGetCountryCode(IPAddress.Parse(player.ip)); var geo_loc = code == null ? "N/A" : GeoIPCountry.GetCountryNameByCode(code); geoip_prefix = String.Format("({0})", geo_loc); } StarryboundServer.sendGlobalMessage(String.Format("{0}{1} has joined the server!", player.name, geoip_prefix)); this.client.state = ClientState.Connected; StarryboundServer.logInfo(String.Format("[{0}][{1}] joined with UUID [{2}]{3}", this.client.playerData.client, this.client.playerData.ip, player.uuid, geoip_prefix != "" ? String.Format(" from {0}", geoip_prefix) : "")); return(true); }
public override bool doProcess(string[] args) { if (!hasPermission()) { permissionError(); return(false); } string player = string.Join(" ", args).Trim(); if (player == null || player.Length < 1) { if (this.client.playerData.loc == null) { this.client.sendCommandMessage("Unable to find your exact location at this time."); return(false); } this.client.sendCommandMessage("You are located [" + this.player.loc.ToString() + "]"); return(true); } else { Client target = StarryboundServer.getClient(player); if (target != null) { PlayerData playerData = target.playerData; if (playerData.loc == null) { this.client.sendCommandMessage("Unable to find an exact location for " + player + "."); return(false); } this.client.sendCommandMessage(player + " located at [" + playerData.loc.ToString() + "]" + (playerData.inPlayerShip ? "in a ship." : "")); return(true); } else { this.client.sendCommandMessage("Player '" + player + "' not found."); return(false); } } }
public override Object onReceive() { byte context = stream.ReadByte(); string world = stream.ReadStarString(); uint clientID = stream.ReadUInt32BE(); string name = stream.ReadStarString(); string message = stream.ReadStarString(); Client target = StarryboundServer.getClient(clientID); if (target != null) { target.playerData.serverName = name; string formatName = target.playerData.formatName; if (!String.IsNullOrEmpty(formatName)) { client.sendChatMessage((ChatReceiveContext)context, world, clientID, formatName, message); return(false); } } return(null); }
public override bool doProcess(string[] args) { if (!hasPermission()) { permissionError(); return(false); } if (args.Length < 1) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } string command = args[0].Trim().ToLower(); if (command == "list") // List all groups start { string groupList = ""; foreach (Group group in StarryboundServer.groups.Values) { groupList += group.name + ", "; } // TODO: Remove last comma this.client.sendChatMessage("^#5dc4f4;Group list: " + groupList.Substring(0, groupList.Length - 2)); return(true); } // List all groups end else if (command == "add") // Add new group start { if (args.Length <= 1) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } string groupName = args[1].Trim(); if (String.IsNullOrEmpty(groupName) || String.IsNullOrWhiteSpace(groupName)) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } Dictionary <string, bool> pPerms = new Dictionary <string, bool>(); pPerms.Add("client.*", true); pPerms.Add("chat.*", true); Group newGroup = new Group(groupName, null, null, pPerms); StarryboundServer.groups.Add(newGroup.name, newGroup); Groups.SaveGroups(); this.client.sendCommandMessage("New group " + newGroup.name + " has been added."); return(true); } // Add new group end else if (command == "adduser") { if (args.Length <= 1) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } string playerName = args[1].Trim(); string groupName = args[2].Trim(); if (String.IsNullOrWhiteSpace(playerName) || String.IsNullOrWhiteSpace(groupName)) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } Client target = StarryboundServer.getClient(playerName); if (target != null) { if (StarryboundServer.groups.ContainsKey(groupName)) { PlayerData playerData = target.playerData; playerData.group = StarryboundServer.groups[groupName]; this.client.sendCommandMessage("Player " + playerName + " has been added to group " + groupName + "."); StarryboundServer.sendGlobalMessage(playerName + " has been assigned the group " + groupName); Users.SaveUser(playerData); return(true); } else { this.client.sendCommandMessage("A Group with the name " + groupName + " does not exist."); return(false); } } else { this.client.sendCommandMessage("Player '" + playerName + "' not found."); return(false); } } else if (command == "deluser") { if (args.Length <= 1) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } string playerName = args[1].Trim(); if (String.IsNullOrWhiteSpace(playerName)) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } Client target = StarryboundServer.getClient(playerName); if (target != null) { PlayerData playerData = target.playerData; playerData.group = StarryboundServer.groups[StarryboundServer.defaultGroup]; this.client.sendCommandMessage("Player " + playerName + " has had their access revoked."); StarryboundServer.sendGlobalMessage(playerName + " has been demoted to " + StarryboundServer.defaultGroup); Users.SaveUser(playerData); return(true); } else { this.client.sendCommandMessage("Player '" + playerName + "' not found."); return(false); } } else if (command == "del") { // Delete a group start if (args.Length <= 1) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } string groupName = args[1].Trim(); if (String.IsNullOrEmpty(groupName) || String.IsNullOrWhiteSpace(groupName)) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } if (StarryboundServer.groups.ContainsKey(groupName)) { StarryboundServer.groups.Remove(groupName); Groups.SaveGroups(); this.client.sendCommandMessage("Group " + groupName + " has been removed."); return(true); } else { this.client.sendCommandMessage("A Group with the name " + groupName + " does not exist."); return(false); } } // Delete a group end else if (command == "info") { // Group info start if (args.Length <= 1) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } string groupName = args[1].Trim(); if (String.IsNullOrEmpty(groupName) || String.IsNullOrWhiteSpace(groupName)) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } if (StarryboundServer.groups.ContainsKey(groupName)) { Group targetGroup = StarryboundServer.groups[groupName]; this.client.sendCommandMessage("Group info: Name: " + targetGroup.name + "; Prefix: " + (String.IsNullOrEmpty(targetGroup.prefix) ? "None" : targetGroup.prefix) + "; Name color: " + (String.IsNullOrEmpty(targetGroup.nameColor) ? "None" : targetGroup.nameColor)); return(true); } else { this.client.sendCommandMessage("A Group with the name " + groupName + " does not exist."); return(false); } } // Group info end else if (command == "mod") { // Group mod start if (args.Length <= 3) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } string groupName = args[1].Trim(); string modCommand = args[2].Trim().ToLower(); string modValue = args[3].Trim(); if (String.IsNullOrEmpty(groupName) || String.IsNullOrEmpty(modCommand) || String.IsNullOrEmpty(modValue)) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } if (StarryboundServer.groups.ContainsKey(groupName)) { Group targetGroup = StarryboundServer.groups[groupName]; if (modCommand == "prefix") { targetGroup.prefix = modValue; Groups.SaveGroups(); this.client.sendCommandMessage("Group " + targetGroup.name + "'s prefix is now set to " + modValue); return(true); } else if (modCommand == "color") { if (modValue.Length == 7 && modValue[0] == '#') { targetGroup.nameColor = modValue; Groups.SaveGroups(); this.client.sendCommandMessage("Group " + targetGroup.name + "'s name color is now set to " + modValue); return(true); } else { this.client.sendCommandMessage("Invalid color. Must be a hex color starting with #"); return(false); } } else { this.client.sendCommandMessage("Invalid modification parameter. Use /group help for instructions."); return(false); } } else { this.client.sendCommandMessage("A Group with the name " + groupName + " does not exist."); return(false); } } // Group mod end else if (command == "permissions") { // Group permissions start if (args.Length <= 2) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } string groupName = args[1].Trim(); string prmCommand = args[2].Trim().ToLower(); if (String.IsNullOrEmpty(groupName) || String.IsNullOrEmpty(prmCommand)) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } if (StarryboundServer.groups.ContainsKey(groupName)) { Group targetGroup = StarryboundServer.groups[groupName]; if (prmCommand == "list") { string permissionList = ""; foreach (string prm in targetGroup.permissions.Keys) { permissionList += prm + "; "; } this.client.sendChatMessage("^#5dc4f4;Group permissions: " + permissionList.Substring(0, permissionList.Length - 2)); return(true); } else if (prmCommand == "add") { if (args.Length <= 3) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } string prmValue = args[3].Trim(); if (targetGroup.givePermission(prmValue)) { Groups.SaveGroups(); this.client.sendCommandMessage("Permission " + prmValue + " was successfully added."); return(true); } else { this.client.sendCommandMessage("Failed to add permission " + prmValue + ". Make sure it is valid."); return(false); } } else if (prmCommand == "del") { if (args.Length <= 3) { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } string prmValue = args[3].Trim(); if (targetGroup.permissions.ContainsKey(prmValue)) { targetGroup.permissions.Remove(prmValue); Groups.SaveGroups(); this.client.sendCommandMessage("Permission " + prmValue + " was successfully removed."); return(true); } else { this.client.sendCommandMessage("Failed to remove permission " + prmValue + ". Make sure the group has it."); return(false); } } else { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } } else { this.client.sendCommandMessage("A Group with the name " + groupName + " does not exist."); return(false); } } else if (command == "help") { this.client.sendChatMessage("^#5dc4f4;Group command help:"); this.client.sendChatMessage("^#5dc4f4;/group list - shows a list of all groups."); this.client.sendChatMessage("^#5dc4f4;/group add <group name> - adds a new group."); this.client.sendChatMessage("^#5dc4f4;/group del <group name> - deletes a group."); this.client.sendChatMessage("^#5dc4f4;/group adduser <player> <group name> - adds user to a group."); this.client.sendChatMessage("^#5dc4f4;/group deluser <player> <group name> - demotes user to default group."); this.client.sendChatMessage("^#5dc4f4;/group info <group name> - shows information about a group."); this.client.sendChatMessage("^#5dc4f4;/group mod <group name> <prefix/color> <value> - changes a group parameter."); this.client.sendChatMessage("^#5dc4f4;/group permissions <group name> list - lists the permissions of a group."); this.client.sendChatMessage("^#5dc4f4;/group permissions <group name> <add/del> <permission> - adds or removes a permission from the group."); return(true); } else { this.client.sendCommandMessage("Invalid syntax. Use /group help for instructions."); return(false); } }
public override bool doProcess(string[] args) { if (!hasPermission()) { permissionError(); return(false); } if (args.Length < 3) { showHelpText(); return(false); } string player = args[0].Trim(); string expiry = args[1].Trim(); int remainStuff = player.Length + expiry.Length; string reason = string.Join(" ", args).Substring(remainStuff + 2).Trim(); Client target = StarryboundServer.getClient(player); if (target != null) { if (!this.player.group.canTarget(target.playerData.group)) { this.client.sendCommandMessage("^#f75d5d;You do not have permission to target this user."); return(false); } string uuid = target.playerData.uuid; string name = target.playerData.name; string ip = target.playerData.ip; int timeNow = Utils.getTimestamp(); try { int bExpiry = int.Parse(expiry); if (bExpiry != 0) { bExpiry = timeNow + (bExpiry * 60); } Bans.addNewBan(name, uuid, ip, timeNow, this.player.name, bExpiry, reason); target.banClient(reason); return(true); } catch (Exception e) { this.client.sendCommandMessage("An exception occured while attempting to ban " + player); StarryboundServer.logException("Error occured while banning player " + player + ": " + e.Message); return(false); } } else { this.client.sendCommandMessage("Player '" + player + "' not found."); return(false); } }