本文整理汇总了C#中MiNET.Player.SendMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Player.SendMessage方法的具体用法?C# Player.SendMessage怎么用?C# Player.SendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MiNET.Player
的用法示例。
在下文中一共展示了Player.SendMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PM
public void PM(Player source, string[] arguments)
{
if (arguments.Length >= 2)
{
Player target = getPlayer(arguments[0], source);
if (target != source)
{
string message = string.Empty;
for (int i = 1; i < arguments.Length; i++)
{
message += arguments[i];
}
target.SendMessage("[MailPE] " + source.Username + ": " + message);
source.SendMessage("[MailPE] Message to " + target.Username + " was sent!");
}
else
{
source.SendMessage("[MailPE] Player not found!");
}
}
else
{
source.SendMessage("[MailPE] Wrong command usage!");
}
}
示例2: RegisterCommand
public void RegisterCommand(Player player, string password)
{
var userManager = Context.Server.UserManager;
var user = userManager.FindByNameAsync(player.Username).Result;
if (user == null)
{
if (password == null && password.IndexOf(' ') > -1)
{
player.SendMessage($"Do not add any space in your password!");
return;
}
user = new User(player.Username);
Context.Server.UserManager.CreateAsync(user, password);
user.IsAuthenticated = true;
userManager.UpdateAsync(user);
}
else if (user.IsAuthenticated)
{
player.SendMessage($"{ChatColors.Red}You has been Login!");
}
else if (Context.Server.UserManager.HasPasswordAsync(user.Id).Result)
{
player.SendMessage($"You has been register,Plz Type your password to login");
}
}
示例3: ToggleDownfall
public void ToggleDownfall(Player player)
{
ThreadPool.QueueUserWorkItem(delegate(object state)
{
for (int i = 0; i < short.MaxValue; i = i+2000)
{
var data = i;
{
McpeLevelEvent levelEvent = new McpeLevelEvent();
levelEvent.eventId = 3001;
levelEvent.data = data;
player.SendPackage(levelEvent);
}
//{
// McpeLevelEvent levelEvent = new McpeLevelEvent();
// levelEvent.eventId = 3002;
// levelEvent.data = i;
// player.SendPackage(levelEvent);
//}
player.SendMessage("Downfall " + data, type: MessageType.Raw);
Thread.Sleep(5000);
}
for (int i = short.MaxValue; i >= 0; i = i - 2000)
{
{
McpeLevelEvent levelEvent = new McpeLevelEvent();
levelEvent.eventId = 3001;
levelEvent.data = i;
player.SendPackage(levelEvent);
}
//{
// McpeLevelEvent levelEvent = new McpeLevelEvent();
// levelEvent.eventId = 3002;
// levelEvent.data = i;
// player.SendPackage(levelEvent);
//}
player.SendMessage("Downfall " + i, type: MessageType.Raw);
Thread.Sleep(5000);
}
});
//{
// McpeLevelEvent levelEvent = new McpeLevelEvent();
// levelEvent.eventId = 3001;
// levelEvent.data = 100000;
// player.SendPackage(levelEvent);
//}
//{
// McpeLevelEvent levelEvent = new McpeLevelEvent();
// levelEvent.eventId = 3002;
// levelEvent.data = 36625;
// player.SendPackage(levelEvent);
//}
player.SendMessage("Toggled downfall", type: MessageType.Raw);
}
示例4: ToggleDownfall
public void ToggleDownfall(Player player, int value)
{
{
McpeLevelEvent levelEvent = new McpeLevelEvent();
levelEvent.eventId = 3001;
levelEvent.data = value;
player.SendPackage(levelEvent);
}
player.SendMessage("Downfall " + value, type: MessageType.Raw);
}
示例5: SetHome
public void SetHome(Player source, string[] arguments)
{
if (PluginGlobals.Homes.ContainsKey(source))
{
PluginGlobals.Homes.Remove(source);
}
PlayerLocation p = source.KnownPosition;
p.Y += 2; //Do not spawn underground....
PluginGlobals.Homes.Add(source, p);
source.SendMessage("[SetHome] Home set!");
}
示例6: OnPlayerSendMessage
public Package OnPlayerSendMessage(McpeText packet, Player player)
{
var userManager = Context.Server.UserManager;
var user = userManager.FindByNameAsync(player.Username).Result;
if (user != null)
{
if (user.IsAuthenticated)
{
if (userManager.CheckPasswordAsync(user, packet.message).Result)
{
user.IsAuthenticated = true;
userManager.UpdateAsync(user);
player.SendMessage("you has been Logged");
}
else
{
player.SendMessage($"{ChatColors.Green}Check your password again,that have some error!");
}
packet.message = null;
return packet;
}
else
{
return packet;
}
}
else if (packet.message.StartsWith("/reg"))
{
return packet;
}
else
{
player.SendMessage($"{ChatColors.Green}Plz Register frist!");
packet.message = null;
return packet;
}
}
示例7: Home
public void Home(Player source, string[] arguments)
{
if (PluginGlobals.Homes.ContainsKey(source))
{
PlayerLocation pos = null;
PluginGlobals.Homes.TryGetValue(source, out pos);
if (pos != null)
{
source.SendMessage("[SetHome] Teleporting you to your home!");
source.KnownPosition = pos;
source.SendMovePlayer();
}
else
{
source.SendMessage("[SetHome] Something went wrong!");
}
}
else
{
source.SendMessage("[SetHome] You don't have a home set!");
source.SendMessage("[SetHome] Set a home with \"/sethome\" first!");
}
}
示例8: Pet
//public void Pet(Player player, string type)
public void Pet(Player player, string type, params string[] name)
{
//TODO: Fix space in pets name, too difficult damn..
PetTypes petType;
try
{
petType = (PetTypes) Enum.Parse(typeof (PetTypes), type, true);
}
catch (ArgumentException e)
{
return;
}
if (!Enum.IsDefined(typeof (PetTypes), petType))
{
player.SendMessage("No pet found");
return;
}
string petName = null;
if (name.Length > 0)
{
petName = string.Join(" ", name);
}
var entities = player.Level.GetEntites();
foreach (var entity in entities)
{
Pet pet = entity as Pet;
if (pet != null && pet.Owner == player)
{
pet.HealthManager.Kill();
break;
}
}
//ThreadPool.QueueUserWorkItem(delegate(object state)
//{
Pet newPet = new Pet(player, player.Level, (int) petType)
{
NameTag = petName,
KnownPosition = (PlayerLocation) player.KnownPosition.Clone()
};
newPet.SpawnEntity();
//});
}
示例9: Auth
public void Auth(Player player, string password)
{
if (!_registerlist.Contains(player.User))
{
player.User.IsAuthenticated = player.User.PasswordHash == GetPasswordHash(password);
player.ClearPopups();
player.AddPopup(new Popup()
{
Message = ChatColors.Green + "Добро пожаловать назад!.",
Duration = 20 * 10,
MessageType = MessageType.Popup
});
}
else
{
player.SendMessage(ChatColors.Red + "Вы не зарегистрированы!!");
}
}
示例10: Plugins
public void Plugins(Player player)
{
StringBuilder sb = new StringBuilder();
sb.Append("Plugins: ");
foreach (var plugin in Context.PluginManager.Plugins)
{
sb.AppendLine(plugin.GetType().Name);
}
player.SendMessage(sb.ToString(), type: MessageType.Raw);
}
示例11: PlayerInfo
public void PlayerInfo(Player player)
{
player.SendMessage(string.Format("Username={0}", player.Username), type: MessageType.Raw);
player.SendMessage(string.Format("Entity ID={0}", player.EntityId), type: MessageType.Raw);
player.SendMessage(string.Format("Client GUID={0}", player.ClientGuid), type: MessageType.Raw);
player.SendMessage(string.Format("Client ID={0}", player.ClientId), type: MessageType.Raw);
}
示例12: VideoX
public void VideoX(Player player, int numberOfFrames, bool color)
{
Task.Run(delegate
{
try
{
Dictionary<Tuple<int, int>, MapEntity> entities = new Dictionary<Tuple<int, int>, MapEntity>();
int width = 1;
int height = 1;
int frameCount = numberOfFrames;
//int frameOffset = 0;
int frameOffset = 120;
var frameTicker = new FrameTicker(frameCount);
// 768x384
for (int frame = frameOffset; frame < frameCount + frameOffset; frame++)
{
Log.Info($"Generating frame {frame}");
string file = Path.Combine(@"D:\Development\Other\Smash Heroes 3x6 (128)\Smash Heroes 3x6 (128)", $"Smash Heroes Trailer{frame:D4}.bmp");
//string file = Path.Combine(@"D:\Development\Other\2 by 1 PE test app ad for Gurun-2\exported frames 2", $"pe app ad{frame:D2}.bmp");
if (!File.Exists(file)) continue;
Bitmap image = new Bitmap((Bitmap) Image.FromFile(file), width*128, height*128);
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
var key = new Tuple<int, int>(x, y);
if (!entities.ContainsKey(key))
{
entities.Add(key, new MapEntity(player.Level) {ImageProvider = new VideoImageProvider(frameTicker)});
}
var croppedImage = CropImage(image, new Rectangle(new Point(x*128, y*128), new Size(128, 128)));
byte[] bitmapToBytes = BitmapToBytes(croppedImage, color);
if (bitmapToBytes.Length != 128*128*4) return;
((VideoImageProvider) entities[key].ImageProvider).Frames.Add(CreateCachedPacket(entities[key].EntityId, bitmapToBytes));
}
}
}
int i = 0;
player.Inventory.Slots[i++] = new ItemBlock(new Planks(), 0) {Count = 64};
player.Inventory.Slots[i++] = new ItemItemFrame {Count = 64};
foreach (MapEntity entity in entities.Values)
{
entity.SpawnEntity();
player.Inventory.Slots[i++] = new ItemMap(entity.EntityId);
}
player.SendPlayerInventory();
player.SendMessage("Done generating video.", MessageType.Raw);
}
catch (Exception e)
{
Log.Error("Aborted video generation", e);
}
});
player.SendMessage("Generating video...", MessageType.Raw);
}
示例13: Video2X
public void Video2X(Player player, int numberOfFrames, bool color)
{
Task.Run(delegate
{
try
{
Dictionary<Tuple<int, int>, List<MapEntity>> entities = new Dictionary<Tuple<int, int>, List<MapEntity>>();
int width = 3;
int height = 2;
int frameCount = numberOfFrames;
//int frameOffset = 0;
int frameOffset = 120;
var frameTicker = new FrameTicker(frameCount);
// 768x384
for (int frame = frameOffset; frame < frameCount + frameOffset; frame++)
{
Log.Info($"Generating frame {frame}");
string file = Path.Combine(@"D:\Development\Other\Smash Heroes 3x6 (128)\Smash Heroes 3x6 (128)", $"Smash Heroes Trailer{frame:D4}.bmp");
//string file = Path.Combine(@"D:\Development\Other\2 by 1 PE test app ad for Gurun-2\exported frames 2", $"pe app ad{frame:D2}.bmp");
if (!File.Exists(file)) continue;
Bitmap image = new Bitmap((Bitmap) Image.FromFile(file), width*128, height*128);
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
var key = new Tuple<int, int>(x, y);
if (!entities.ContainsKey(key))
{
entities.Add(key, new List<MapEntity>());
}
List<MapEntity> frames = entities[key];
var croppedImage = CropImage(image, new Rectangle(new Point(x*128, y*128), new Size(128, 128)));
byte[] bitmapToBytes = BitmapToBytes(croppedImage, color);
if (bitmapToBytes.Length != 128*128*4) return;
MapEntity entity = new MapEntity(player.Level);
entity.ImageProvider = new MapImageProvider {Batch = CreateCachedPacket(entity.EntityId, bitmapToBytes)};
entity.SpawnEntity();
frames.Add(entity);
}
}
}
int i = 0;
player.Inventory.Slots[i++] = new ItemBlock(new Planks(), 0) {Count = 64};
foreach (var entites in entities.Values)
{
player.Inventory.Slots[i++] = new CustomItemItemFrame(entites, frameTicker) {Count = 64};
}
player.SendPlayerInventory();
player.SendMessage("Done generating video.", MessageType.Raw);
BlockCoordinates center = player.KnownPosition.GetCoordinates3D();
var level = player.Level;
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
var key = new Tuple<int, int>(x, y);
List<MapEntity> frames = entities[key];
BlockCoordinates bc = new BlockCoordinates(center.X - x, center.Y + height - y - 1, center.Z + 2);
var wood = new Planks {Coordinates = bc};
level.SetBlock(wood);
BlockCoordinates frambc = new BlockCoordinates(center.X - x, center.Y + height - y - 1, center.Z + 1);
ItemFrameBlockEntity itemFrameBlockEntity = new ItemFrameBlockEntity
{
Coordinates = frambc
};
var itemFrame = new CustomItemFrame(frames, itemFrameBlockEntity, level, frameTicker) {Coordinates = frambc, Metadata = 3};
level.SetBlock(itemFrame);
level.SetBlockEntity(itemFrameBlockEntity);
}
}
}
catch (Exception e)
{
Log.Error("Aborted video generation", e);
}
});
player.SendMessage("Generating video...", MessageType.Raw);
}
示例14: Position
public void Position(Player player)
{
BlockCoordinates position = new BlockCoordinates(player.KnownPosition);
int chunkX = position.X >> 4;
int chunkZ = position.Z >> 4;
int xi = (chunkX%32);
if (xi < 0) xi += 32;
int zi = (chunkZ%32);
if (zi < 0) zi += 32;
StringBuilder sb = new StringBuilder();
sb.AppendLine(string.Format("Region X:{0} Z:{1}", chunkX >> 5, chunkZ >> 5));
sb.AppendLine(string.Format("Local chunk X:{0} Z:{1}", xi, zi));
sb.AppendLine(string.Format("Chunk X:{0} Z:{1}", chunkX, chunkZ));
sb.AppendLine(string.Format("Position X:{0:F1} Y:{1:F1} Z:{2:F1}", player.KnownPosition.X, player.KnownPosition.Y, player.KnownPosition.Z));
sb.AppendLine(string.Format("Direction Yaw:{0:F1} HeadYap:{1:F1} Pitch:{2:F1}", player.KnownPosition.Yaw, player.KnownPosition.HeadYaw, player.KnownPosition.Pitch));
string text = sb.ToString();
player.SendMessage(text, type: MessageType.Raw);
Log.Info(text);
}
示例15: test
public void test(Player player)
{
player.SendMessage(string.Format(ChatColors.Yellow + "Hi " + player.Username + " this is test command :-)"), type: MessageType.Raw);
var inventory = player.Inventory;
inventory.Boots = new ItemLeatherBoots();
inventory.Leggings = new ItemLeatherLeggings();
inventory.Chest = new ItemLeatherChestplate();
inventory.Helmet = new ItemLeatherHelmet();
player.SendPlayerInventory();
SendArmorForPlayer(player);
}