本文整理匯總了C#中API.Cancel方法的典型用法代碼示例。如果您正苦於以下問題:C# API.Cancel方法的具體用法?C# API.Cancel怎麽用?C# API.Cancel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類API
的用法示例。
在下文中一共展示了API.Cancel方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnPlayerBlockChange_Low
void OnPlayerBlockChange_Low(Player sender, API.Events.BlockChangeEventArgs args) {
if (!args.Canceled && args.Action == API.Events.ActionType.Delete) {
object tmp = sender.ExtraData["TmpBlockList"];
if (tmp != null && ((List<Tuple<string, Vector3S>>)tmp).Count != 0) {
List<Tuple<string, Vector3S>> tmplist = (List<Tuple<string, Vector3S>>)tmp;
string level = sender.Level.Name;
string tpLocal = "/tp " + (args.X * 32 + 16) + " " + (args.Z * 32 + 16) + " " + ((args.Y + 1) * 32 + 16);
string tpLevel = "/tp " + (args.X * 32 + 16) + " " + (args.Z * 32 + 16) + " " + ((args.Y + 1) * 32 + 16) + " " + level;
ICommand mb = Command.Find("messageblock");
if (mb == null) {
Logger.Log("MessageBlock command and plugin are required to create portals");
sender.SendMessage("MessageBlock command and plugin are required to create portals");
args.Cancel();
return;
}
foreach (Tuple<string, Vector3S> e in tmplist) {
List<string> mbArgs = new List<string>() { "+", e.Item2.x + "", e.Item2.z + "", e.Item2.y + "", e.Item1 };
if (e.Item1 == level) {
mbArgs.AddRange(tpLocal.Split(' '));
}
else {
mbArgs.AddRange(tpLevel.Split(' '));
}
mb.Use(sender, mbArgs.ToArray());
}
sender.SendMessage("Portal created");
sender.OnPlayerBlockChange.Low -= OnPlayerBlockChange_Low;
}
}
else {
object tmp = sender.ExtraData["TmpBlockList"];
if (tmp == null) {
tmp = new List<Tuple<string, Vector3S>>();
sender.ExtraData["TmpBlockList"] = tmp;
}
((List<Tuple<string, Vector3S>>)tmp).Add(new Tuple<string, Vector3S>(sender.Level.Name, new Vector3S(args.X, args.Z, args.Y)));
}
}
示例2: OnPlayerBlockChange_Normal
void OnPlayerBlockChange_Normal(Player sender, API.Events.BlockChangeEventArgs args) {
if (args.Action == API.Events.ActionType.Delete && args.Current == 0) {
args.Cancel();
}
}
示例3: OnPacket
private static void OnPacket(MCForge.Entity.Player sender, API.Events.PacketEventArgs args)
{
if (cancelPackets.Contains((byte)args.Type)) {
args.Cancel();
return;
}
if (reducePackets.ContainsKey((byte)args.Type)) {
if (xthPackets[(byte)args.Type] % reducePackets[(byte)args.Type] != 0) {
xthPackets[(byte)args.Type]++;
args.Cancel();
return;
}
else {
xthPackets[(byte)args.Type] = 1;
}
}
if (hidePackets.Contains((byte)args.Type)) return;
Logger.Log(((args.Incoming) ? "Incoming" : "Outgoing") + " Packet " + (packet.types)(byte)args.Type + "(" + (byte)args.Type + ") for player " + sender.Username, ((args.Incoming) ? Color.Green : Color.Red), Color.Black);
}