本文整理汇总了C#中fCraft.Player.Can方法的典型用法代码示例。如果您正苦于以下问题:C# Player.Can方法的具体用法?C# Player.Can怎么用?C# Player.Can使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fCraft.Player
的用法示例。
在下文中一共展示了Player.Can方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CModeWater
internal static void CModeWater(Player player, Command cmd)
{
if (!player.Can(Permissions.ControlPhysics))
{
player.NoAccessMessage(Permissions.ControlPhysics);
return;
}
string blockpar = cmd.Next();
string wmt = "";
int BlockAddr = -1;
try { BlockAddr = Convert.ToInt32(blockpar); }
catch
{
player.Message("Incorrect parameter!"); return;
}
if (BlockAddr < 3 && BlockAddr >= 0)
{
player.world.map.modeWater = BlockAddr;
switch (BlockAddr)
{
case 0: wmt = "'none'"; break;
case 1: wmt = "'infinite'"; break;
case 2: wmt = "'finite'"; break;
}
player.Message("Water mode set to " + wmt + ".");
}
}
示例2: DoZone
void DoZone( Player player, Command cmd ) {
if( !player.Can( Permissions.SetSpawn ) ) {
world.NoAccessMessage( player );
return;
}
string name = cmd.Next();
if( name == null ) {
player.Message( "No zone name specified. See " + Color.Help + "/help zone" );
return;
}
if( !Player.IsValidName( name ) ) {
player.Message( "\"" + name + "\" is not a valid zone name" );
return;
}
Zone zone = new Zone();
zone.name = name;
string property = cmd.Next();
if( property == null ) {
player.Message( "No zone rank/whitelist/blacklist specified. See " + Color.Help + "/help zone" );
return;
}
PlayerClass minRank = world.classes.ParseClass( property );
if( minRank != null ) {
zone.buildRank = minRank.rank;
player.tag = zone;
player.marksExpected = 2;
player.marks.Clear();
player.markCount = 0;
player.selectionCallback = MakeZone;
}
}
示例3: SayHandler
static void SayHandler(Player player, CommandReader 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);
}
}
示例4: Draw
void Draw( Player player, Command command, DrawMode mode ) {
if( !player.Can( Permissions.Draw ) ) {
world.NoAccessMessage( player );
return;
}
if( player.drawingInProgress ) {
player.Message( "Another draw command is already in progress. Please wait." );
return;
}
string blockName = command.Next();
Block block;
if( blockName == null || blockName == "" ) {
if( mode == DrawMode.Cuboid ) {
player.Message( "Usage: " + Color.Help + "/cuboid blockName" + Color.Sys + " or " + Color.Help + "/cub blockName" );
} else {
player.Message( "Usage: " + Color.Help + "/ellipsoid blockName" + Color.Sys + " or " + Color.Help + "/ell blockName" );
}
return;
}
try {
block = Map.GetBlockByName( blockName );
} catch( Exception ) {
player.Message( "Unknown block name: " + blockName );
return;
}
player.tag = block;
Permissions permission = Permissions.Build;
switch( block ) {
case Block.Admincrete: permission = Permissions.PlaceAdmincrete; break;
case Block.Air: permission = Permissions.Delete; break;
case Block.Water:
case Block.StillWater: permission = Permissions.PlaceWater; break;
case Block.Lava:
case Block.StillLava: permission = Permissions.PlaceLava; break;
}
if( !player.Can( permission ) ) {
player.Message( "You are not allowed to draw with this block." );
return;
}
player.marksExpected = 2;
player.markCount = 0;
player.marks.Clear();
player.Message( mode.ToString() + ": Place a block or type /mark to use your location." );
if( mode == DrawMode.Cuboid ) {
player.selectionCallback = DrawCuboid;
} else {
player.selectionCallback = DrawEllipsoid;
}
}
示例5: BumHandler
static void BumHandler(Player player, CommandReader cmd)
{
string newModeName = cmd.Next();
if (newModeName == null)
{
player.Message("&sBytes Sent: {0} Per Second: {1:0.0}", player.BytesSent, player.BytesSentRate);
player.Message("&sBytes Received: {0} Per Second: {1:0.0}", player.BytesReceived, player.BytesReceivedRate);
player.Message("&sBandwidth mode: {0}",player.BandwidthUseMode);
return;
}
else if (player.Can(Permission.EditPlayerDB))
{
var newMode = (BandwidthUseMode)Enum.Parse(typeof(BandwidthUseMode), newModeName, true);
player.Message("&sBandwidth mode: {0} --> {1}", player.BandwidthUseMode, newMode.ToString());
player.BandwidthUseMode = newMode;
player.Info.BandwidthUseMode = newMode;
return;
}
else
{
player.Message("You need {0}&s to change your BandwidthUseMode", RankManager.GetMinRankWithAnyPermission(Permission.EditPlayerDB).ClassyName);
return;
}
}
示例6: TrollHandler
private static void TrollHandler( Player player, CommandReader cmd ) {
string Name = cmd.Next();
if ( Name == null ) {
player.Message( "Player not found. Please specify valid name." );
return;
}
if ( !Player.IsValidPlayerName( Name ) )
return;
Player target = Server.FindPlayerOrPrintMatches( player, Name, SearchOptions.Default );
if ( target == null )
return;
string options = cmd.Next();
if ( options == null ) {
CdTroll.PrintUsage( player );
return;
}
string Message = cmd.NextAll();
if ( Message.Length < 1 && options.ToLower() != "leave" ) {
player.Message( "&WError: Please enter a message for {0}.", target.ClassyName );
return;
}
switch ( options.ToLower() ) {
case "pm":
if ( player.Can( Permission.UseColorCodes ) && Message.Contains( "%" ) ) {
Message = Chat.ReplacePercentColorCodes( Message, false );
}
Server.Players.Message( "&Pfrom {0}: {1}",
target.Name, Message );
break;
case "st":
case "staff":
Chat.SendStaff( target, Message );
break;
case "i":
case "impersonate":
case "msg":
case "message":
case "m":
Server.Message( "{0}&S&F: {1}",
target.ClassyName, Message );
break;
case "leave":
case "disconnect":
case "gtfo":
Server.Players.Message( "&SPlayer {0}&S left the server.",
target.ClassyName );
break;
default:
player.Message( "Invalid option. Please choose st, ac, pm, message or leave" );
break;
}
}
示例7: Lava
void Lava( Player player, Command cmd ) {
if( player.mode == BlockPlacementMode.Lava ) {
player.mode = BlockPlacementMode.Normal;
player.Message( "Lava: OFF." );
} else if( player.Can( Permissions.PlaceWater ) ) {
player.mode = BlockPlacementMode.Lava;
player.Message( "Lava: ON. Red blocks are replaced with lava." );
} else {
world.NoAccessMessage( player );
}
}
示例8: Water
void Water( Player player, Command cmd ) {
if( player.mode == BlockPlacementMode.Water ) {
player.mode = BlockPlacementMode.Normal;
player.Message( "Water: OFF" );
} else if( player.Can( Permissions.PlaceWater ) ) {
player.mode = BlockPlacementMode.Water;
player.Message( "Water: ON. Blue blocks are replaced with water." );
} else {
world.NoAccessMessage( player );
}
}
示例9: Grass
void Grass( Player player, Command cmd ) {
if( player.mode == BlockPlacementMode.Grass ) {
player.mode = BlockPlacementMode.Normal;
player.Message( "Grass: OFF" );
} else if( player.Can( Permissions.PlaceGrass ) ) {
player.mode = BlockPlacementMode.Grass;
player.Message( "Grass: ON. Dirt blocks are replaced with grass." );
} else {
world.NoAccessMessage( player );
}
}
示例10: Solid
void Solid( Player player, Command cmd ) {
if( player.mode == BlockPlacementMode.Solid ){
player.mode = BlockPlacementMode.Normal;
player.Message( "Solid: OFF" );
} else if( player.Can( Permissions.PlaceAdmincrete ) ) {
player.mode = BlockPlacementMode.Solid;
player.Message( "Solid: ON" );
} else {
world.NoAccessMessage( player );
}
}
示例11: Hardened
internal static void Hardened(Player player, Command cmd)
{
if (player.hardenedMode == BlockPlacementMode.Hardened) {
player.hardenedMode = BlockPlacementMode.Normal;
player.Message("Hardened blocks: OFF");
} else if (player.Can(Permissions.PlaceHardenedBlocks)) {
player.hardenedMode = BlockPlacementMode.Hardened;
player.Message("Hardened blocks: ON");
} else {
player.NoAccessMessage( Permissions.PlaceHardenedBlocks );
}
}
示例12: Say
internal static void Say( Player player, Command cmd ) {
if( player.Info.IsMuted ) {
player.MutedMessage();
return;
}
if( player.Can( Permission.Say ) ) {
string msg = cmd.NextAll();
if( player.Can( Permission.UseColorCodes ) && msg.Contains( "%" ) ) {
msg = Color.ReplacePercentCodes( msg );
}
if( msg != null && msg.Trim().Length > 0 ) {
player.Info.LinesWritten++;
Server.SendToAllExceptIgnored( player, "&Y{0}", null, msg.Trim() );
IRC.SendAction( String.Format( "&Y{0}", msg.Trim() ) );
} else {
cdSay.PrintUsage( player );
}
} else {
player.NoAccessMessage( Permission.Say );
}
}
示例13: 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( player.Can( Permission.UseColorCodes ) && msg.Contains( "%" ) ) {
msg = Color.ReplacePercentCodes( msg );
}
if( msg.Length > 0 ) {
Chat.SendSay( player, msg );
} else {
CdSay.PrintUsage( player );
}
} else {
player.MessageNoAccess( Permission.Say );
}
}
示例14: MakeHandshake
internal static Packet MakeHandshake( Player player, string serverName, string motd )
{
if ( player == null )
throw new ArgumentNullException( "player" );
if ( serverName == null )
throw new ArgumentNullException( "serverName" );
if ( motd == null )
throw new ArgumentNullException( "motd" );
Packet packet = new Packet( OpCode.Handshake );
packet.Data[1] = Config.ProtocolVersion;
Encoding.ASCII.GetBytes( serverName.PadRight( 64 ), 0, 64, packet.Data, 2 );
Encoding.ASCII.GetBytes( motd.PadRight( 64 ), 0, 64, packet.Data, 66 );
packet.Data[130] = ( byte )( player.Can( Permission.DeleteAdmincrete ) ? 100 : 0 );
return packet;
}
示例15: Bring
internal static void Bring( Player player, Command cmd )
{
if( player.Can( Permissions.Bring ) ) {
string name = cmd.Next();
Player target = player.world.FindPlayer( name );
if( target != null ) {
Position pos = player.pos;
pos.x += 1;
pos.y += 1;
pos.h += 1;
target.Send( PacketWriter.MakeTeleport( 255, pos ) );
} else {
player.NoPlayerMessage( name );
}
} else {
player.NoAccessMessage( Permissions.Bring );
}
}