本文整理匯總了C#中fCraft.Player.MessageNoAccess方法的典型用法代碼示例。如果您正苦於以下問題:C# Player.MessageNoAccess方法的具體用法?C# Player.MessageNoAccess怎麽用?C# Player.MessageNoAccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fCraft.Player
的用法示例。
在下文中一共展示了Player.MessageNoAccess方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SayHandler
static void SayHandler( Player player, Command cmd ) {
if( player.Info.IsMuted ) {
player.MessageMuted();
return;
}
if( player.DetectChatSpam() ) return;
if( player.Can( Permission.Say ) ) {
string msg = cmd.NextAll().Trim();
if( msg.Length > 0 ) {
Chat.SendSay( player, msg );
} else {
CdSay.PrintUsage( player );
}
} else {
player.MessageNoAccess( Permission.Say );
}
}
示例2: ImportHandler
static void ImportHandler( Player player, Command cmd )
{
string action = cmd.Next();
if( action == null ) {
CdImport.PrintUsage( player );
return;
}
switch( action.ToLower() ) {
case "bans":
if( !player.Can( Permission.Ban ) ) {
player.MessageNoAccess( Permission.Ban );
return;
}
ImportBans( player, cmd );
break;
case "ranks":
if( !player.Can( Permission.Promote ) ) {
player.MessageNoAccess( Permission.Promote );
return;
}
ImportRanks( player, cmd );
break;
default:
CdImport.PrintUsage( player );
break;
}
}
示例3: ParseBlockDBUndoParams
static BlockDBUndoArgs ParseBlockDBUndoParams( Player player, CommandReader cmd, string cmdName, bool not ) {
// check if command's being called by a worldless player (e.g. console)
World playerWorld = player.World;
if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );
// ensure that BlockDB is enabled
if( !BlockDB.IsEnabledGlobally ) {
player.Message( "&W{0}: BlockDB is disabled on this server.", cmdName );
return null;
}
if( !playerWorld.BlockDB.IsEnabled ) {
player.Message( "&W{0}: BlockDB is disabled in this world.", cmdName );
return null;
}
// parse the first parameter - either numeric or time limit
string range = cmd.Next();
if( range == null ) {
CdUndoPlayer.PrintUsage( player );
return null;
}
int countLimit;
TimeSpan ageLimit = TimeSpan.Zero;
if( !Int32.TryParse( range, out countLimit ) && !range.TryParseMiniTimeSpan( out ageLimit ) ) {
player.Message( "{0}: First parameter should be a number or a timespan.", cmdName );
return null;
}
if( ageLimit > DateTimeUtil.MaxTimeSpan ) {
player.MessageMaxTimeSpan();
return null;
}
// parse second and consequent parameters (player names)
HashSet<PlayerInfo> targets = new HashSet<PlayerInfo>();
bool allPlayers = false;
while( true ) {
string name = cmd.Next();
if( name == null ) {
break;
} else if( name == "*" ) {
// all players
if( not ) {
player.Message( "{0}: \"*\" not allowed (cannot undo \"everyone except everyone\")", cmdName );
return null;
}
if( allPlayers ) {
player.Message( "{0}: \"*\" was listed twice.", cmdName );
return null;
}
allPlayers = true;
} else {
// individual player
PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches( player, name, SearchOptions.IncludeSelf );
if( target == null ) {
return null;
}
if( targets.Contains( target ) ) {
player.Message( "{0}: Player {1}&S was listed twice.",
target.ClassyName, cmdName );
return null;
}
// make sure player has the permission
if( !not &&
player.Info != target && !player.Can( Permission.UndoAll ) &&
!player.Can( Permission.UndoOthersActions, target.Rank ) ) {
player.Message( "&W{0}: You may only undo actions of players ranked {1}&S or lower.",
cmdName,
player.Info.Rank.GetLimit( Permission.UndoOthersActions ).ClassyName );
player.Message( "Player {0}&S is ranked {1}",
target.ClassyName, target.Rank.ClassyName );
return null;
}
targets.Add( target );
}
}
if( targets.Count == 0 && !allPlayers ) {
player.Message( "{0}: Specify at least one player name, or \"*\" to undo everyone.", cmdName );
return null;
}
if( targets.Count > 0 && allPlayers ) {
player.Message( "{0}: Cannot mix player names and \"*\".", cmdName );
return null;
}
// undoing everyone ('*' in place of player name) requires UndoAll permission
if( ( not || allPlayers ) && !player.Can( Permission.UndoAll ) ) {
player.MessageNoAccess( Permission.UndoAll );
return null;
}
// Queue UndoPlayerCallback to run
return new BlockDBUndoArgs {
Player = player,
AgeLimit = ageLimit,
CountLimit = countLimit,
Area = player.WorldMap.Bounds,
World = playerWorld,
Targets = targets.ToArray(),
Not = not
//.........這裏部分代碼省略.........
示例4: 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( 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
//.........這裏部分代碼省略.........
示例5: BanInfoHandler
static void BanInfoHandler( Player player, CommandReader cmd ) {
string name = cmd.Next();
if( cmd.HasNext ) {
CdBanInfo.PrintUsage( player );
return;
}
IPAddress address;
PlayerInfo info = null;
if( name == null ) {
name = player.Name;
} else if( !player.Can( Permission.ViewOthersInfo ) ) {
player.MessageNoAccess( Permission.ViewOthersInfo );
return;
}
if( IPAddressUtil.IsIP( name ) && IPAddress.TryParse( name, out address ) ) {
IPBanInfo banInfo = IPBanList.Get( address );
if( banInfo != null ) {
player.Message( "{0} was banned by {1}&S on {2:dd MMM yyyy} ({3} ago)",
banInfo.Address,
banInfo.BannedByClassy,
banInfo.BanDate,
banInfo.TimeSinceLastAttempt );
if( !String.IsNullOrEmpty( banInfo.PlayerName ) ) {
player.Message( " Banned by association with {0}",
banInfo.PlayerNameClassy );
}
if( banInfo.Attempts > 0 ) {
player.Message( " There have been {0} attempts to log in, most recently {1} ago by {2}",
banInfo.Attempts,
banInfo.TimeSinceLastAttempt.ToMiniString(),
banInfo.LastAttemptNameClassy );
}
if( banInfo.BanReason != null ) {
player.Message( " Ban reason: {0}", banInfo.BanReason );
}
} else {
player.Message( "{0} is currently NOT banned.", address );
}
} else {
info = PlayerDB.FindPlayerInfoOrPrintMatches( player, name );
if( info == null ) return;
address = info.LastIP;
IPBanInfo ipBan = IPBanList.Get( info.LastIP );
switch( info.BanStatus ) {
case BanStatus.Banned:
if( ipBan != null ) {
player.Message( "Player {0}&S and their IP are &CBANNED", info.ClassyName );
} else {
player.Message( "Player {0}&S is &CBANNED&S (but their IP is not).", info.ClassyName );
}
break;
case BanStatus.IPBanExempt:
if( ipBan != null ) {
player.Message( "Player {0}&S is exempt from an existing IP ban.", info.ClassyName );
} else {
player.Message( "Player {0}&S is exempt from IP bans.", info.ClassyName );
}
break;
case BanStatus.NotBanned:
if( ipBan != null ) {
player.Message( "Player {0}&s is not banned, but their IP is.", info.ClassyName );
} else {
player.Message( "Player {0}&s is not banned.", info.ClassyName );
}
break;
}
if( info.BanDate != DateTime.MinValue ) {
player.Message( " Last ban by {0}&S on {1:dd MMM yyyy} ({2} ago).",
info.BannedByClassy,
info.BanDate,
info.TimeSinceBan.ToMiniString() );
if( info.BanReason != null ) {
player.Message( " Last ban reason: {0}", info.BanReason );
}
} else {
player.Message( "No past bans on record." );
}
if( info.UnbanDate != DateTime.MinValue && !info.IsBanned ) {
player.Message( " Unbanned by {0}&S on {1:dd MMM yyyy} ({2} ago).",
info.UnbannedByClassy,
info.UnbanDate,
info.TimeSinceUnban.ToMiniString() );
if( info.UnbanReason != null ) {
player.Message( " Last unban reason: {0}", info.UnbanReason );
}
}
if( info.BanDate != DateTime.MinValue ) {
TimeSpan banDuration;
if( info.IsBanned ) {
banDuration = info.TimeSinceBan;
player.Message( " Ban duration: {0} so far",
//.........這裏部分代碼省略.........
示例6: WhereHandler
static void WhereHandler( Player player, CommandReader cmd ) {
string name = cmd.Next();
if( cmd.HasNext ) {
CdWhere.PrintUsage( player );
return;
}
Player target = player;
if( name != null ) {
if( !player.Can( Permission.ViewOthersInfo ) ) {
player.MessageNoAccess( Permission.ViewOthersInfo );
return;
}
target = Server.FindPlayerOrPrintMatches( player, name, false, true );
if( target == null ) return;
} else if( target.World == null ) {
player.Message( "When called from console, &H/Where&S requires a player name." );
return;
}
if( target.World == null ) {
// Chances of this happening are miniscule
player.Message( "Player {0}&S is not in any world.", target.Name );
return;
} else {
player.Message( "Player {0}&S is on world {1}&S:",
target.ClassyName,
target.World.ClassyName );
}
Vector3I targetBlockCoords = target.Position.ToBlockCoords();
player.Message( "{0}{1} - {2}",
Color.Silver,
targetBlockCoords,
GetCompassString( target.Position.R ) );
}
示例7: HelpHandler
internal static void HelpHandler( Player player, Command cmd ) {
string commandName = cmd.Next();
if( commandName == "commands" ) {
CdCommands.Call( player, cmd, false );
} else if( commandName != null ) {
CommandDescriptor descriptor = CommandManager.GetDescriptor( commandName, true );
if( descriptor == null ) {
player.Message( "Unknown command: \"{0}\"", commandName );
return;
}
string sectionName = cmd.Next();
if( sectionName != null ) {
string sectionHelp;
if( descriptor.HelpSections != null && descriptor.HelpSections.TryGetValue( sectionName.ToLower(), out sectionHelp ) ) {
player.MessagePrefixed( HelpPrefix, sectionHelp );
} else {
player.Message( "No help found for \"{0}\"", sectionName );
}
} else {
StringBuilder sb = new StringBuilder( Color.Help );
sb.Append( descriptor.Usage ).Append( '\n' );
if( descriptor.Aliases != null ) {
sb.Append( "Aliases: &H" );
sb.Append( descriptor.Aliases.JoinToString() );
sb.Append( "\n&S" );
}
if( String.IsNullOrEmpty( descriptor.Help ) ) {
sb.Append( "No help is available for this command." );
} else {
sb.Append( descriptor.Help );
}
player.MessagePrefixed( HelpPrefix, sb.ToString() );
if( descriptor.Permissions != null && descriptor.Permissions.Length > 0 ) {
player.MessageNoAccess( descriptor );
}
}
} else {
player.Message( " To see a list of all commands, write &H/Commands" );
player.Message( " To see detailed help for a command, write &H/Help Command" );
if( player != Player.Console ) {
player.Message( " To see your stats, write &H/Info" );
}
player.Message( " To list available worlds, write &H/Worlds" );
player.Message( " To join a world, write &H/Join WorldName" );
player.Message( " To send private messages, write &[email protected] Message" );
}
}
示例8: 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 );
}
}
示例9: PortalH
private static void PortalH(Player player, Command command)
{
try
{
String option = command.Next();
if (option == null)
{
CdPortal.PrintUsage(player);
}
else if (option.ToLower().Equals("create"))
{
if (player.Can(Permission.ManagePortal))
{
string world = command.Next();
if (world != null && WorldManager.FindWorldExact(world) != null)
{
DrawOperation operation = new CuboidDrawOperation(player);
NormalBrush brush = new NormalBrush(Block.Water, Block.Water);
string blockTypeOrName = command.Next();
if (blockTypeOrName != null && blockTypeOrName.ToLower().Equals("lava"))
{
brush = new NormalBrush(Block.Lava, Block.Lava);
}
else if (blockTypeOrName != null && !blockTypeOrName.ToLower().Equals("water"))
{
player.Message("Invalid block, choose between water or lava.");
return;
}
string portalName = command.Next();
if (portalName == null)
{
player.PortalName = null;
}
else
{
if (!Portal.DoesNameExist(player.World, portalName))
{
player.PortalName = portalName;
}
else
{
player.Message("A portal with name {0} already exists in this world.", portalName);
return;
}
}
operation.Brush = brush;
player.PortalWorld = world;
player.SelectionStart(operation.ExpectedMarks, PortalCreateCallback, operation, Permission.Draw);
player.Message("Click {0} blocks or use &H/Mark&S to mark the area of the portal.", operation.ExpectedMarks);
}
else
{
if (world == null)
{
player.Message("No world specified.");
}
else
{
player.MessageNoWorld(world);
}
}
}
else
{
player.MessageNoAccess(Permission.ManagePortal);
}
}
else if (option.ToLower().Equals("remove"))
{
if (player.Can(Permission.ManagePortal))
{
string portalName = command.Next();
if (portalName == null)
{
player.Message("No portal name specified.");
}
else
{
if (player.World.Portals != null && player.World.Portals.Count > 0)
{
bool found = false;
Portal portalFound = null;
lock (player.World.Portals.SyncRoot)
{
foreach (Portal portal in player.World.Portals)
{
if (portal.Name.Equals(portalName))
{
portalFound = portal;
found = true;
//.........這裏部分代碼省略.........
示例10: ReportHandler
static void ReportHandler(Player player, Command cmd)
{
string option = cmd.Next();
string name = cmd.Next();
string PrintUsage = "&SAvailable options are: &HList, Add, Remove";
if (option == null)
{
player.Message("Please choose an option");
player.Message(PrintUsage);
return;
}
if (option.ToLower() == "add")
{
if (!player.Can(Permission.MakeReport))
{
player.MessageNoAccess(Permission.MakeReport);
return;
}
if (name == null)
{
player.Message("Please enter a name to report.");
return;
}
PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches(player, name);
if (target == null) return;
if (target.Name == player.Name)
{
player.Message("You cannot report yourself.");
return;
}
if (!Reports.Contains(target.Name))
{
Reports.Add(target.Name);
player.Message("Successfully reported {0}", target.ClassyName);
Server.Players.Except(player).Message("{0}&S has been reported by {1}", target.ClassyName, player.ClassyName);
return;
}
else
{
player.Message("This player has already been reported.");
return;
}
}
else if (option.ToLower() == "remove")
{
if (!player.Can(Permission.RemoveReport))
{
player.MessageNoAccess(Permission.RemoveReport);
return;
}
if (name == null)
{
player.Message("Please enter a name to remove.");
return;
}
PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches(player, name);
if (target == null) return;
if (target.Name == player.Name)
{
player.Message("You cannot report yourself.");
return;
}
if (Reports.Contains(target.Name))
{
Reports.Remove(target.Name);
player.Message("Successfully removed {0}", target.ClassyName);
Server.Players.Except(player).Message("{0}&S has been removed from the report list by {1}", target.ClassyName, player.ClassyName);
return;
}
else
{
player.Message("This player has not been reported.");
return;
}
}
else if (option.ToLower() == "list")
{
if (!player.Can(Permission.ViewReports))
{
player.MessageNoAccess(Permission.ViewReports);
return;
}
if (Reports.Count != 0)
{
player.Message("&S--------&cReports&S--------");
foreach (string ReportedPlayers in Reports)
{
player.Message("&c-&S {0}", ReportedPlayers);
}
player.Message("&S-----&cEnd of Reports&S-----");
}
else
{
player.Message("There are no reports.");
return;
}
}
else
{
//.........這裏部分代碼省略.........
示例11: PlayerDbHandler
static void PlayerDbHandler(Player player, CommandReader cmd) {
string command = cmd.Next();
if (command == null) {
CdPlayerDb.PrintUsage(player);
return;
}
switch (command.ToUpperInvariant()) {
case "MERGE":
player.Message("TODO: PlayerDB MERGE"); // TODO
break;
case "SPLIT":
player.Message("TODO: PlayerDB SPLIT"); // TODO
break;
case "SWAP":
InfoSwapHandler(player, cmd);
break;
case "IMPORTBANS":
if (player.Can(Permission.Import, Permission.Ban)) {
ImportBans(player, cmd);
} else {
player.MessageNoAccess(Permission.Import, Permission.Ban);
}
break;
case "IMPORTRANKS":
if (player.Can(Permission.Import, Permission.Promote, Permission.Demote)) {
ImportRanks(player, cmd);
} else {
player.MessageNoAccess(Permission.Import, Permission.Promote, Permission.Demote);
}
break;
case "PRUNE":
PruneDBHandler(player, cmd);
break;
default:
player.Message("Unknown PlayerDB function: " + command);
CdPlayerDb.PrintUsage(player);
break;
}
}
示例12: PortalH
private static void PortalH(Player player, CommandReader cmd) {
try {
string option = cmd.Next();
if (string.IsNullOrEmpty(option)) {
CdPortal.PrintUsage(player);
return;
}
switch (option.ToLower()) {
case "create":
case "add":
if (player.Can(Permission.CreatePortals)) {
string addWorld = cmd.Next();
if (!string.IsNullOrEmpty(addWorld) && WorldManager.FindWorldExact(addWorld) != null) {
DrawOperation operation = new CuboidDrawOperation(player);
NormalBrush brush = new NormalBrush(Block.Water, Block.Water);
string blockTypeOrName = cmd.Next();
Block pblock;
if (blockTypeOrName != null && Map.GetBlockByName(blockTypeOrName, false, out pblock)) {
if ((!validPBlocks.Contains(pblock) && pblock <= Block.StoneBrick) || (pblock == Block.Air && player.Info.Rank != RankManager.HighestRank)) {
player.Message("Invalid block, choose a non-solid block");
return;
} else {
brush = new NormalBrush(pblock, pblock);
}
}
string addPortalName = cmd.Next();
if (string.IsNullOrEmpty(addPortalName)) {
player.PortalName = null;
} else {
if (!Portal.DoesNameExist(player.World, addPortalName)) {
player.PortalName = addPortalName;
} else {
player.Message("A portal with name {0} already exists in this world.", addPortalName);
return;
}
}
World tpWorld = WorldManager.FindWorldExact(addWorld);
if (cmd.HasNext) {
int x, y, z, rot = player.Position.R, lot = player.Position.L;
if (cmd.NextInt(out x) && cmd.NextInt(out y) && cmd.NextInt(out z)) {
if (cmd.HasNext && cmd.HasNext) {
if (cmd.NextInt(out rot) && cmd.NextInt(out lot)) {
if (rot > 255 || rot < 0) {
player.Message("R must be inbetween 0 and 255. Set to player R");
rot = player.Position.R;
}
if (lot > 255 || lot < 0) {
player.Message("L must be inbetween 0 and 255. Set to player L");
lot = player.Position.L;
}
}
}
if (x < 1 || x >= 1024 || y < 1 || y >= 1024 || z < 1 || z >= 1024) {
player.Message("Coordinates are outside the valid range!");
return;
} else {
player.PortalTPPos = new Position((short)(x * 32), (short)(y * 32), (short)(z * 32), (byte)rot, (byte)lot);
}
} else {
player.PortalTPPos = tpWorld.map == null ? new Position(0, 0, 0) : tpWorld.map.Spawn;
}
} else {
player.PortalTPPos = tpWorld.map == null ? new Position(0, 0, 0) : tpWorld.map.Spawn;
}
operation.Brush = brush;
player.PortalWorld = addWorld;
player.SelectionStart(operation.ExpectedMarks, PortalCreateCallback, operation, Permission.CreatePortals);
player.Message("Click {0} blocks or use &H/Mark&S to mark the area of the portal.", operation.ExpectedMarks);
} else {
if (string.IsNullOrEmpty(addWorld)) {
player.Message("No world specified.");
} else {
player.MessageNoWorld(addWorld);
}
}
} else {
player.MessageNoAccess(Permission.CreatePortals);
}
break;
case "remove":
case "delete":
if (player.Can(Permission.CreatePortals)) {
string remPortalName = cmd.Next();
string remWString = cmd.Next();
World remWorld = player.World;
if (!string.IsNullOrEmpty(remWString)) {
remWorld = WorldManager.FindWorldOrPrintMatches(player, remWString);
}
if (remWorld == null) {
return;
}
if (string.IsNullOrEmpty(remPortalName)) {
player.Message("No portal name specified.");
} else {
if (remWorld.Portals != null && remWorld.Portals.Count > 0) {
bool found = false;
Portal portalFound = null;
lock (remWorld.Portals.SyncRoot) {
foreach (Portal portal in remWorld.Portals) {
//.........這裏部分代碼省略.........
示例13: 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);
}
}
示例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 );
}
}
//.........這裏部分代碼省略.........