本文整理汇总了C#中fCraft.Player.MessageManyMatches方法的典型用法代码示例。如果您正苦于以下问题:C# Player.MessageManyMatches方法的具体用法?C# Player.MessageManyMatches怎么用?C# Player.MessageManyMatches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fCraft.Player
的用法示例。
在下文中一共展示了Player.MessageManyMatches方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InfoHandler
//.........这里部分代码省略.........
IPAddress ip;
if( name.Contains( "/" ) ) {
// IP range matching (CIDR notation)
string ipString = name.Substring( 0, name.IndexOf( '/' ) );
string rangeString = name.Substring( name.IndexOf( '/' ) + 1 );
byte range;
if( IPAddressUtil.IsIP( ipString ) && IPAddress.TryParse( ipString, out ip ) &&
Byte.TryParse( rangeString, out range ) && range <= 32 ) {
player.Message( "Searching {0}-{1}", ip.RangeMin( range ), ip.RangeMax( range ) );
infos = PlayerDB.FindPlayersCidr( ip, range );
} else {
player.Message( "Info: Invalid IP range format. Use CIDR notation." );
return;
}
} else if( IPAddressUtil.IsIP( name ) && IPAddress.TryParse( name, out ip ) ) {
// find players by IP
infos = PlayerDB.FindPlayers( ip );
} else if( name.Equals( "*" ) ) {
infos = (PlayerInfo[])PlayerDB.PlayerInfoList.Clone();
} else if( name.Contains( "*" ) || name.Contains( "?" ) ) {
// find players by regex/wildcard
string regexString = "^" + RegexNonNameChars.Replace( name, "" ).Replace( "*", ".*" ).Replace( "?", "." ) + "$";
Regex regex = new Regex( regexString, RegexOptions.IgnoreCase | RegexOptions.Compiled );
infos = PlayerDB.FindPlayers( regex );
} else if( name.StartsWith( "@" ) ) {
string rankName = name.Substring( 1 );
Rank rank = RankManager.FindRank( rankName );
if( rank == null ) {
player.MessageNoRank( rankName );
return;
} else {
infos = PlayerDB.PlayerInfoList
.Where( info => info.Rank == rank )
.ToArray();
}
} else if( name.StartsWith( "!" ) ) {
// find online players by partial matches
name = name.Substring( 1 );
infos = Server.FindPlayers( name, true )
.Select( p => p.Info )
.ToArray();
} else {
// find players by partial matching
PlayerInfo tempInfo;
if( !PlayerDB.FindPlayerInfo( name, out tempInfo ) ) {
infos = PlayerDB.FindPlayers( name );
} else if( tempInfo == null ) {
player.MessageNoPlayer( name );
return;
} else {
infos = new[] { tempInfo };
}
}
Array.Sort( infos, new PlayerInfoComparer( player ) );
if( infos.Length == 1 ) {
// only one match found; print it right away
player.LastUsedPlayerName = infos[0].Name;
PrintPlayerInfo( player, infos[0] );
} else if( infos.Length > 1 ) {
// multiple matches found
if( infos.Length <= PlayersPerPage ) {
// all fit to one page
player.MessageManyMatches( "player", infos );
} else {
// pagination
int offset;
if( !cmd.NextInt( out offset ) ) offset = 0;
if( offset >= infos.Length ) {
offset = Math.Max( 0, infos.Length - PlayersPerPage );
}
PlayerInfo[] infosPart = infos.Skip( offset ).Take( PlayersPerPage ).ToArray();
player.MessageManyMatches( "player", infosPart );
if( offset + infosPart.Length < infos.Length ) {
// normal page
player.Message( "Showing {0}-{1} (out of {2}). Next: &H/Info {3} {4}",
offset + 1, offset + infosPart.Length, infos.Length,
name, offset + infosPart.Length );
} else {
// last page
player.Message( "Showing matches {0}-{1} (out of {2}).",
offset + 1, offset + infosPart.Length, infos.Length );
}
}
} else {
// no matches found
player.MessageNoPlayer( name );
}
}
示例2: SetSpawnHandler
static void SetSpawnHandler( Player player, CommandReader cmd ) {
World playerWorld = player.World;
if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );
string playerName = cmd.Next();
if( playerName == null ) {
Map map = player.WorldMap;
map.Spawn = player.Position;
player.TeleportTo( map.Spawn );
player.Send( Packet.MakeAddEntity( Packet.SelfID, player.ListName, player.Position ) );
player.Message( "New spawn point saved." );
Logger.Log( LogType.UserActivity,
"{0} changed the spawned point.",
player.Name );
} else if( player.Can( Permission.Bring ) ) {
Player[] infos = playerWorld.FindPlayers( player, playerName );
if( infos.Length == 1 ) {
Player target = infos[0];
player.LastUsedPlayerName = target.Name;
if( player.Can( Permission.Bring, target.Info.Rank ) ) {
target.Send( Packet.MakeAddEntity( Packet.SelfID, target.ListName, player.Position ) );
} else {
player.Message( "You may only set spawn of players ranked {0}&S or lower.",
player.Info.Rank.GetLimit( Permission.Bring ).ClassyName );
player.Message( "{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName );
}
} else if( infos.Length > 0 ) {
player.MessageManyMatches( "player", infos );
} else {
infos = Server.FindPlayers( player, playerName, true, false, true );
if( infos.Length > 0 ) {
player.Message( "You may only set spawn of players on the same world as you." );
} else {
player.MessageNoPlayer( playerName );
}
}
} else {
player.MessageNoAccess( CdSetSpawn );
}
}
示例3: TeleportHandler
static void TeleportHandler( Player player, CommandReader cmd ) {
string name = cmd.Next();
if( name == null ) {
CdTeleport.PrintUsage( player );
return;
}
if( cmd.Next() != null ) {
cmd.Rewind();
int x, y, z;
if( cmd.NextInt( out x ) && cmd.NextInt( out y ) && cmd.NextInt( out z ) ) {
if( x <= -1024 || x >= 1024 || y <= -1024 || y >= 1024 || z <= -1024 || z >= 1024 ) {
player.Message( "Coordinates are outside the valid range!" );
} else {
player.TeleportTo( new Position {
X = (short)(x * 32 + 16),
Y = (short)(y * 32 + 16),
Z = (short)(z * 32 + 16),
R = player.Position.R,
L = player.Position.L
} );
}
} else {
CdTeleport.PrintUsage( player );
}
} else {
if( name == "-" ) {
if( player.LastUsedPlayerName != null ) {
name = player.LastUsedPlayerName;
} else {
player.Message( "Cannot repeat player name: you haven't used any names yet." );
return;
}
}
Player[] matches = Server.FindPlayers( player, name, false, true, true );
if( matches.Length == 1 ) {
Player target = matches[0];
World targetWorld = target.World;
if( targetWorld == null ) PlayerOpException.ThrowNoWorld( target );
if( targetWorld == player.World ) {
player.TeleportTo( target.Position );
} else {
switch( targetWorld.AccessSecurity.CheckDetailed( player.Info ) ) {
case SecurityCheckResult.Allowed:
case SecurityCheckResult.WhiteListed:
if( targetWorld.IsFull ) {
player.Message( "Cannot teleport to {0}&S because world {1}&S is full.",
target.ClassyName,
targetWorld.ClassyName );
return;
}
player.StopSpectating();
player.JoinWorld( targetWorld, WorldChangeReason.Tp, target.Position );
break;
case SecurityCheckResult.BlackListed:
player.Message( "Cannot teleport to {0}&S because you are blacklisted on world {1}",
target.ClassyName,
targetWorld.ClassyName );
break;
case SecurityCheckResult.RankTooLow:
player.Message( "Cannot teleport to {0}&S because world {1}&S requires {2}+&S to join.",
target.ClassyName,
targetWorld.ClassyName,
targetWorld.AccessSecurity.MinRank.ClassyName );
break;
}
}
} else if( matches.Length > 1 ) {
player.MessageManyMatches( "player", matches );
} else {
player.MessageNoPlayer( name );
}
}
}
示例4: JoinHandler
static void JoinHandler(Player player, Command cmd)
{
string worldName = cmd.Next();
if (worldName == null)
{
CdJoin.PrintUsage(player);
return;
}
if (worldName == "-")
{
if (player.LastUsedWorldName != null)
{
worldName = player.LastUsedWorldName;
}
else
{
player.Message("Cannot repeat world name: you haven't used any names yet.");
return;
}
}
World[] worlds = WorldManager.FindWorlds(player, worldName);
if (worlds.Length > 1)
{
player.MessageManyMatches("world", worlds);
}
else if (worlds.Length == 1)
{
World world = worlds[0];
player.LastUsedWorldName = world.Name;
switch (world.AccessSecurity.CheckDetailed(player.Info))
{
case SecurityCheckResult.Allowed:
case SecurityCheckResult.WhiteListed:
if (world.IsFull)
{
player.Message("Cannot join {0}&S: world is full.", world.ClassyName);
return;
}
player.StopSpectating();
if (!player.JoinWorldNow(world, true, WorldChangeReason.ManualJoin))
{
player.Message("ERROR: Failed to join world. See log for details.");
}
break;
case SecurityCheckResult.BlackListed:
player.Message("Cannot join world {0}&S: you are blacklisted.",
world.ClassyName);
break;
case SecurityCheckResult.RankTooLow:
player.Message("Cannot join world {0}&S: must be {1}+",
world.ClassyName, world.AccessSecurity.MinRank.ClassyName);
break;
}
}
else
{
// no worlds found - see if player meant to type in "/Join" and not "/TP"
Player[] players = Server.FindPlayers(player, worldName, true);
if (players.Length == 1)
{
player.LastUsedPlayerName = players[0].Name;
player.StopSpectating();
player.ParseMessage("/TP " + players[0].Name, false, true);
}
else
{
player.MessageNoWorld(worldName);
}
}
}
示例5: WorldSearchHandler
static void WorldSearchHandler(Player player, Command cmd)
{
string worldName = cmd.Next();
if (worldName == null)
{
CdWorldSearch.PrintUsage(player);
return;
}
if (worldName.Length < 2)
{
CdWorldSearch.PrintUsage(player);
return;
}
else
{
worldName = worldName.ToLower();
var WorldNames = WorldManager.Worlds
.Where(w => w.Name.ToLower().Contains(worldName)).ToArray();
if (WorldNames.Length <= 30)
{
player.MessageManyMatches("worlds", WorldNames);
}
else
{
int offset;
if (!cmd.NextInt(out offset)) offset = 0;
if (offset >= WorldNames.Count())
offset = Math.Max(0, WorldNames.Length - 30);
World[] WorldPart = WorldNames.Skip(offset).Take(30).ToArray();
player.MessageManyMatches("worlds", WorldPart);
if (offset + WorldNames.Length < WorldNames.Length)
player.Message("Showing {0}-{1} (out of {2}). Next: &H/List {3} {4}",
offset + 1, offset + WorldPart.Length, WorldNames.Length,
"worldsearch", offset + WorldPart.Length);
else
player.Message("Showing matches {0}-{1} (out of {2}).",
offset + 1, offset + WorldPart.Length, WorldNames.Length);
return;
}
}
}
示例6: ListHandler
internal static void ListHandler(Player player, Command cmd)
{
string Option = cmd.Next();
if (Option == null)
{
CdList.PrintUsage(player);
player.Message(" Sections include: Staff, DisplayedNames, Idles, Portals, Rank, Top10");
return;
}
switch (Option.ToLower())
{
default:
CdList.PrintUsage(player);
player.Message(" Sections include: Staff, DisplayedNames, Idles, Portals, Rank, Top10");
break;
case "top10":
List<World> WorldNames = new List<World>(WorldManager.Worlds.Where(w => w.VisitCount > 0)
.OrderBy(c => c.VisitCount)
.ToArray()
.Reverse());
string list = WorldNames.Take(10).JoinToString(w => String.Format("{0}&S: {1}", w.ClassyName, w.VisitCount));
if (WorldNames.Count() < 1){
player.Message("&WNo results found");
return;
}
player.Message("&WShowing worlds with the most visits: " + list);
WorldNames.Clear();
break;
case "idles":
case "idle":
var Idles = Server.Players.Where(p => p.IdleTime.TotalMinutes > 5).ToArray();
var visiblePlayers = Idles.Where(player.CanSee);
if (Idles.Count() > 0)
player.Message("Listing players idle for 5 mins or more: {0}",
visiblePlayers.JoinToString(r => String.Format("{0}", r.ClassyName)));
else player.Message("No players have been idle for more than 5 minutes");
break;
case "portals":
if (player.World == null){
player.Message("/List portals cannot be used from Console");
return;
}
if (player.World.Portals == null ||
player.World.Portals.Count == 0){
player.Message("There are no portals in {0}&S.", player.World.ClassyName);
}
else
{
String[] portalNames = new String[player.World.Portals.Count];
StringBuilder output = new StringBuilder("There are " + player.World.Portals.Count + " portals in " + player.World.ClassyName + "&S: ");
for (int i = 0; i < player.World.Portals.Count; i++)
{
portalNames[i] = ((fCraft.Portals.Portal)player.World.Portals[i]).Name;
}
output.Append(portalNames.JoinToString(", "));
player.Message(output.ToString());
}
break;
case "staff":
var StaffNames = PlayerDB.PlayerInfoList
.Where(r => r.Rank.Can(Permission.ReadStaffChat) &&
r.Rank.Can(Permission.Ban) &&
r.Rank.Can(Permission.Promote))
.OrderBy(p => p.Rank)
.ToArray();
if (StaffNames.Length < 1){
player.Message("&WNo results found");
return;
}
if (StaffNames.Length <= PlayersPerPage){
player.MessageManyMatches("staff", StaffNames);
}else{
int offset;
if (!cmd.NextInt(out offset)) offset = 0;
if (offset >= StaffNames.Length)
offset = Math.Max(0, StaffNames.Length - PlayersPerPage);
PlayerInfo[] StaffPart = StaffNames.Skip(offset).Take(PlayersPerPage).ToArray();
player.MessageManyMatches("staff", StaffPart);
if (offset + StaffPart.Length < StaffNames.Length)
player.Message("Showing {0}-{1} (out of {2}). Next: &H/List {3} {4}",
offset + 1, offset + StaffPart.Length, StaffNames.Length,
"staff", offset + StaffPart.Length);
else
player.Message("Showing matches {0}-{1} (out of {2}).",
offset + 1, offset + StaffPart.Length, StaffNames.Length);
}
break;
case "rank":
string rankName = cmd.Next();
if (rankName == null)
{
player.Message("Usage: /List rank rankName");
return;
}
Rank rank = RankManager.FindRank(rankName);
var RankNames = PlayerDB.PlayerInfoList
.Where(r => r.Rank == rank)
.ToArray();
//.........这里部分代码省略.........
示例7: AnnounceHandler
private static void AnnounceHandler(Player player, Command cmd)
{
if (!Heartbeat.ClassiCube() || !player.ClassiCube)
{
player.Message("This is a ClassiCube only command!");
return;
}
Player[] targetPlayers;
string world = cmd.Next();
if(string.IsNullOrEmpty(world))
{
CdAnnounce.PrintUsage(player);
return;
}
if (world == "all")
{
targetPlayers = Server.Players;
}
else
{
World[] targetWorlds = WorldManager.FindWorlds(player, world);
if (targetWorlds.Length > 1)
{
player.MessageManyMatches("world", targetWorlds);
return;
}
else if (targetWorlds.Length == 1)
{
targetPlayers = targetWorlds[0].Players;
}
else
{
player.Message("No worlds found matching {0}! Please check your spelling.", world);
return;
}
}
string message = cmd.Next();
if (string.IsNullOrEmpty(message))
{
CdAnnounce.PrintUsage(player);
return;
}
Packet packet = PacketWriter.MakeSpecialMessage(100, message);
foreach (Player p in targetPlayers)
{
p.Send(packet);
}
}
示例8: ListHandler
//.........这里部分代码省略.........
else player.Message( "No players have been idle for more than 5 minutes" );
break;
case "portals":
if ( player.World == null ) {
player.Message( "/List portals cannot be used from Console" );
return;
}
if ( player.World.Map.Portals == null ||
player.World.Map.Portals.Count == 0 ) {
player.Message( "There are no portals in {0}&S.", player.World.ClassyName );
} else {
String[] portalNames = new String[player.World.Map.Portals.Count];
StringBuilder output = new StringBuilder( "There are " + player.World.Map.Portals.Count + " portals in " + player.World.ClassyName + "&S: " );
for ( int i = 0; i < player.World.Map.Portals.Count; i++ ) {
portalNames[i] = ( ( fCraft.Portals.Portal )player.World.Map.Portals[i] ).Name;
}
output.Append( portalNames.JoinToString( ", " ) );
player.Message( output.ToString() );
}
break;
case "staff":
var StaffNames = PlayerDB.PlayerInfoList
.Where( r => r.Rank.Can( Permission.ReadStaffChat ) &&
r.Rank.Can( Permission.Ban ) &&
r.Rank.Can( Permission.Promote ) )
.OrderBy( p => p.Rank )
.ToArray();
if ( StaffNames.Length < 1 ) {
player.Message( "&WNo results found" );
return;
}
if ( StaffNames.Length <= PlayersPerPage ) {
player.MessageManyMatches( "staff", StaffNames );
} else {
int offset;
if ( !cmd.NextInt( out offset ) ) offset = 0;
if ( offset >= StaffNames.Length )
offset = Math.Max( 0, StaffNames.Length - PlayersPerPage );
PlayerInfo[] StaffPart = StaffNames.Skip( offset ).Take( PlayersPerPage ).ToArray();
player.MessageManyMatches( "staff", StaffPart );
if ( offset + StaffPart.Length < StaffNames.Length )
player.Message( "Showing {0}-{1} (out of {2}). Next: &H/List {3} {4}",
offset + 1, offset + StaffPart.Length, StaffNames.Length,
"staff", offset + StaffPart.Length );
else
player.Message( "Showing matches {0}-{1} (out of {2}).",
offset + 1, offset + StaffPart.Length, StaffNames.Length );
}
break;
case "rank":
string rankName = cmd.Next();
if ( rankName == null ) {
player.Message( "Usage: /List rank rankName" );
return;
}
Rank rank = RankManager.FindRank( rankName );
var RankNames = PlayerDB.PlayerInfoList
.Where( r => r.Rank == rank )
.ToArray();
if ( RankNames.Length < 1 ) {
player.Message( "&WNo results found" );
return;
}
if ( RankNames.Length <= PlayersPerPage ) {
示例9: TeleportHandler
//.........这里部分代码省略.........
Z = (short) (z*32 + 48),
R = (byte) rot,
L = (byte) lot
});
}
} else {
CdTeleport.PrintUsage(player);
}
} else {
if (name == "-") {
if (player.LastUsedPlayerName != null) {
name = player.LastUsedPlayerName;
} else {
player.Message("Cannot repeat player name: you haven't used any names yet.");
return;
}
}
Player[] matches = Server.FindPlayers(player, name, SearchOptions.Default);
if (matches.Length == 1) {
Player target = matches[0];
World targetWorld = target.World;
if (targetWorld == null) PlayerOpException.ThrowNoWorld(target);
if (target.Info.TPDeny && target.Info.Rank >= player.Info.Rank) {
player.Message("&CThis player does not want people teleporting to them");
player.Message("Cannot teleport to {0}&S.", target.ClassyName, targetWorld.ClassyName,
targetWorld.AccessSecurity.MinRank.ClassyName);
return;
}
if (targetWorld == player.World) {
if (player.World != null) {
player.LastWorld = player.World;
player.LastPosition = player.Position;
}
player.TeleportTo(target.Position);
} else {
if (targetWorld.Name.StartsWith("PW_") &&
!targetWorld.AccessSecurity.ExceptionList.Included.Contains(player.Info)) {
player.Message(
"You cannot join due to that player being in a personal world that you cannot access.");
return;
}
switch (targetWorld.AccessSecurity.CheckDetailed(player.Info)) {
case SecurityCheckResult.Allowed:
case SecurityCheckResult.WhiteListed:
if (player.Info.Rank.Name == "Banned") {
player.Message("&CYou can not change worlds while banned.");
player.Message("Cannot teleport to {0}&S.", target.ClassyName,
targetWorld.ClassyName, targetWorld.AccessSecurity.MinRank.ClassyName);
break;
}
if (targetWorld.IsFull) {
player.Message("Cannot teleport to {0}&S because world {1}&S is full.",
target.ClassyName, targetWorld.ClassyName);
player.Message("Cannot teleport to {0}&S.", target.ClassyName,
targetWorld.ClassyName, targetWorld.AccessSecurity.MinRank.ClassyName);
break;
}
player.StopSpectating();
player.JoinWorld(targetWorld, WorldChangeReason.Tp, target.Position);
break;
case SecurityCheckResult.BlackListed:
player.Message("Cannot teleport to {0}&S because you are blacklisted on world {1}",
target.ClassyName, targetWorld.ClassyName);
break;
case SecurityCheckResult.RankTooLow:
if (player.Info.Rank.Name == "Banned") {
player.Message("&CYou can not change worlds while banned.");
player.Message("Cannot teleport to {0}&S.", target.ClassyName,
targetWorld.ClassyName, targetWorld.AccessSecurity.MinRank.ClassyName);
break;
}
if (targetWorld.IsFull) {
if (targetWorld.IsFull) {
player.Message("Cannot teleport to {0}&S because world {1}&S is full.",
target.ClassyName, targetWorld.ClassyName);
player.Message("Cannot teleport to {0}&S.", target.ClassyName,
targetWorld.ClassyName, targetWorld.AccessSecurity.MinRank.ClassyName);
break;
}
player.StopSpectating();
player.JoinWorld(targetWorld, WorldChangeReason.Tp, target.Position);
break;
}
player.Message("Cannot teleport to {0}&S because world {1}&S requires {2}+&S to join.",
target.ClassyName, targetWorld.ClassyName,
targetWorld.AccessSecurity.MinRank.ClassyName);
break;
}
}
} else if (matches.Length > 1) {
player.MessageManyMatches("player", matches);
}
}
}
示例10: TPHandler2
static void TPHandler2(Player player, Command cmd)
{
string name = cmd.Next();
if (name == null)
{
return;
}
if (cmd.Next() != null)
{
cmd.Rewind();
int x, y, z;
if (cmd.NextInt(out x) && cmd.NextInt(out y) && cmd.NextInt(out z))
{
if (x <= -1024 || x >= 1024 || y <= -1024 || y >= 1024 || z <= -1024 || z >= 1024)
{
player.Message("Coordinates are outside the valid range!");
}
else
{
player.TeleportTo(new Position
{
X = (short)(x * 32 + 16),
Y = (short)(y * 32 + 16),
Z = (short)(z * 32 + 16),
R = player.Position.R,
L = player.Position.L
});
}
}
else
{
return;
}
}
else
{
Player[] matches = Server.FindPlayers(player, name, true);
if (matches.Length == 1)
{
Player target = matches[0];
World targetWorld = target.World;
if (targetWorld == null) PlayerOpException.ThrowNoWorld(target);
if (targetWorld == player.World)
{
player.TeleportTo(target.Position);
}
else
{
switch (targetWorld.AccessSecurity.CheckDetailed(player.Info))
{
case SecurityCheckResult.Allowed:
case SecurityCheckResult.WhiteListed:
if (targetWorld.IsFull)
{
player.Message("Cannot teleport to {0}&S because world {1}&S is full.",
target.ClassyName,
targetWorld.ClassyName);
return;
}
player.StopSpectating();
player.JoinWorld(targetWorld, WorldChangeReason.Tp, target.Position);
break;
case SecurityCheckResult.BlackListed:
player.Message("Cannot teleport to {0}&S because you are blacklisted on world {1}",
target.ClassyName,
targetWorld.ClassyName);
break;
case SecurityCheckResult.RankTooLow:
player.Message("Cannot teleport to {0}&S because world {1}&S requires {2}+&S to join.",
target.ClassyName,
targetWorld.ClassyName,
targetWorld.AccessSecurity.MinRank.ClassyName);
break;
// TODO: case PermissionType.RankTooHigh:
}
}
}
else if (matches.Length > 1)
{
player.MessageManyMatches("player", matches);
}
else
{
// Try to guess if player typed "/TP" instead of "/Join"
World[] worlds = WorldManager.FindWorlds(player, name);
if (worlds.Length == 1)
{
player.LastUsedWorldName = worlds[0].Name;
player.StopSpectating();
player.ParseMessage("/Join " + worlds[0].Name, false);
//.........这里部分代码省略.........
示例11: JoinHandler
static void JoinHandler( Player player, CommandReader cmd ) {
string worldName = cmd.Next();
if( worldName == null ) {
CdJoin.PrintUsage( player );
return;
}
if( worldName == "-" ) {
if( player.LastUsedWorldName != null ) {
worldName = player.LastUsedWorldName;
} else {
player.Message( "Cannot repeat world name: you haven't used any names yet." );
return;
}
}
World[] worlds = WorldManager.FindWorlds( player, worldName );
if( worlds.Length > 1 ) {
player.MessageManyMatches( "world", worlds );
} else if( worlds.Length == 1 ) {
World world = worlds[0];
player.LastUsedWorldName = world.Name;
switch( world.AccessSecurity.CheckDetailed( player.Info ) ) {
case SecurityCheckResult.Allowed:
case SecurityCheckResult.WhiteListed:
if( world.IsFull ) {
player.Message( "Cannot join {0}&S: world is full.", world.ClassyName );
return;
}
player.StopSpectating();
if( !player.JoinWorldNow( world, true, WorldChangeContext.ManualJoin ) ) {
player.Message( "ERROR: Failed to join world. See log for details." );
}
break;
case SecurityCheckResult.BlackListed:
player.Message( "Cannot join world {0}&S: you are blacklisted.",
world.ClassyName );
break;
case SecurityCheckResult.RankTooLow:
player.Message( "Cannot join world {0}&S: must be {1}+",
world.ClassyName, world.AccessSecurity.MinRank.ClassyName );
break;
// TODO: Uncomment
//case SecurityCheckResult.RankTooHigh:
// player.Message("Cannot join world {0}&S: must be {1}-",
// world.ClassyName, world.AccessSecurity.MaxRank.ClassyName);
// break;
}
} else {
player.MessageNoWorld( worldName );
}
}
示例12: SetSpawnHandler
static void SetSpawnHandler(Player player, Command cmd)
{
string playerName = cmd.Next();
if (playerName == null)
{
player.World.Map.Spawn = player.Position;
player.TeleportTo(player.World.Map.Spawn);
player.Send(PacketWriter.MakeAddEntity(255, player.ListName, player.Position));
player.Message("New spawn point saved.");
Logger.Log(LogType.UserActivity, "{0} changed the spawned point.",
player.Name);
}
else if (player.Can(Permission.Bring))
{
Player[] infos = player.World.FindPlayers(player, playerName);
if (infos.Length == 1)
{
Player target = infos[0];
if (player.Can(Permission.Bring, target.Info.Rank))
{
target.Send(PacketWriter.MakeAddEntity(255, target.ListName, player.Position));
}
else
{
player.Message("You can only set spawn of players ranked {0}&S or lower.",
player.Info.Rank.GetLimit(Permission.Bring).ClassyName);
player.Message("{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName);
}
}
else if (infos.Length > 0)
{
player.MessageManyMatches("player", infos);
}
else
{
infos = Server.FindPlayers(player, playerName, true);
if (infos.Length > 0)
{
player.Message("You can only set spawn of players on the same world as you.");
}
else
{
player.MessageNoPlayer(playerName);
}
}
}
else
{
player.MessageNoAccess(CdRealm);
}
}
示例13: ListHandler
internal static void ListHandler(Player player, Command cmd)
{
string Option = cmd.Next();
if (Option == null)
{
CdList.PrintUsage(player);
return;
}
if (Option.ToLower() == "staff")
{
var StaffNames = PlayerDB.PlayerInfoList
.Where(r => r.Rank.Can(Permission.ReadStaffChat) &&
r.Rank.Can(Permission.Ban) &&
r.Rank.Can(Permission.Promote))
.ToArray();
if (StaffNames.Length <= PlayersPerPage)
{
player.MessageManyMatches("staff", StaffNames);
}
else
{
int offset;
if (!cmd.NextInt(out offset)) offset = 0;
if (offset >= StaffNames.Length)
offset = Math.Max(0, StaffNames.Length - PlayersPerPage);
PlayerInfo[] StaffPart = StaffNames.Skip(offset).Take(PlayersPerPage).ToArray();
player.MessageManyMatches("staff", StaffPart);
if (offset + StaffPart.Length < StaffNames.Length)
player.Message("Showing {0}-{1} (out of {2}). Next: &H/List {3} {4}",
offset + 1, offset + StaffPart.Length, StaffNames.Length,
"staff", offset + StaffPart.Length);
else
player.Message("Showing matches {0}-{1} (out of {2}).",
offset + 1, offset + StaffPart.Length, StaffNames.Length);
}
}
if (Option.ToLower() == "displayednames" || Option.ToLower() == "displayedname" || Option.ToLower() == "dn")
{
var DisplayedNames = PlayerDB.PlayerInfoList
.Where(r => r.DisplayedName != null).ToArray();
if (DisplayedNames.Count() > 0)
player.Message("Listing all DisplayedNames: {0}",
DisplayedNames.JoinToString(r => String.Format("{0}&S({1})", r.ClassyName, r.Name)));
else player.Message("No players with DisplayedNames were found in the Player Database");
}
}
示例14: InfoHandler
static void InfoHandler( Player player, CommandReader cmd ) {
string name = cmd.Next();
if( name == null ) {
// no name given, print own info
PrintPlayerInfo( player, player.Info );
return;
} else if( name.Equals( player.Name, StringComparison.OrdinalIgnoreCase ) ) {
// own name given
player.LastUsedPlayerName = player.Name;
PrintPlayerInfo( player, player.Info );
return;
} else if( !player.Can( Permission.ViewOthersInfo ) ) {
// someone else's name or IP given, permission required.
player.MessageNoAccess( Permission.ViewOthersInfo );
return;
}
// repeat last-typed name
if( name == "-" ) {
if( player.LastUsedPlayerName != null ) {
name = player.LastUsedPlayerName;
} else {
player.Message( "Cannot repeat player name: you haven't used any names yet." );
return;
}
}
PlayerInfo[] infos;
IPAddress ip;
if( IPAddressUtil.IsIP( name ) && IPAddress.TryParse( name, out ip ) ) {
// find players by IP
infos = PlayerDB.FindByIP( ip ).ToArray();
} else if( name.Contains( "*" ) || name.Contains( "?" ) ) {
// find players by regex/wildcard
infos = PlayerDB.FindByPattern( name ).ToArray();
} else if( name.StartsWith( "@" ) ) {
string rankName = name.Substring( 1 );
Rank rank = RankManager.FindRank( rankName );
if( rank == null ) {
player.Message( "Unknown rank: {0}", rankName );
return;
} else {
using( PlayerDB.GetReadLock() ) {
infos = PlayerDB.List
.Where( info => info.Rank == rank )
.ToArray();
}
}
} else {
// find players by partial matching
PlayerInfo tempInfo;
if( !PlayerDB.FindOneByPartialName( name, out tempInfo ) ) {
infos = PlayerDB.FindByPartialName( name ).ToArray();
} else if( tempInfo == null ) {
player.MessageNoPlayer( name );
return;
} else {
infos = new[] { tempInfo };
}
}
Array.Sort( infos, new PlayerInfoComparer( player ) );
if( infos.Length == 1 ) {
// only one match found; print it right away
player.LastUsedPlayerName = infos[0].Name;
PrintPlayerInfo( player, infos[0] );
} else if( infos.Length > 1 ) {
// multiple matches found
if( infos.Length <= PlayersPerPage ) {
// all fit to one page
player.MessageManyMatches( "player", infos );
} else {
// pagination
int offset;
if( !cmd.NextInt( out offset ) ) offset = 0;
if( offset >= infos.Length ) {
offset = Math.Max( 0, infos.Length - PlayersPerPage );
}
PlayerInfo[] infosPart = infos.Skip( offset ).Take( PlayersPerPage ).ToArray();
player.MessageManyMatches( "player", infosPart );
if( offset + infosPart.Length < infos.Length ) {
// normal page
player.Message( "Showing {0}-{1} (out of {2}). Next: &H/Info {3} {4}",
offset + 1, offset + infosPart.Length, infos.Length,
name, offset + infosPart.Length );
} else {
// last page
player.Message( "Showing matches {0}-{1} (out of {2}).",
offset + 1, offset + infosPart.Length, infos.Length );
}
}
//.........这里部分代码省略.........