本文整理汇总了C#中OTA.Plugin.HookContext.CheckForKick方法的典型用法代码示例。如果您正苦于以下问题:C# HookContext.CheckForKick方法的具体用法?C# HookContext.CheckForKick怎么用?C# HookContext.CheckForKick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OTA.Plugin.HookContext
的用法示例。
在下文中一共展示了HookContext.CheckForKick方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPlayerHurt
//Death message
//Player killed
//Teleport
/// <summary>
/// Callde via vanilla code when a player has been hurt
/// </summary>
/// <param name="player">Player.</param>
/// <param name="damage">Damage.</param>
/// <param name="hitDirection">Hit direction.</param>
/// <param name="pvp">If set to <c>true</c> pvp.</param>
/// <param name="quiet">If set to <c>true</c> quiet.</param>
/// <param name="deathText">Death text.</param>
/// <param name="crit">If set to <c>true</c> crit.</param>
/// <param name="cooldownCounter">Cooldown counter.</param>
public static bool OnPlayerHurt(Terraria.Player player, int damage, int hitDirection, bool pvp = false, bool quiet = false, string deathText = " was slain...", bool crit = false, int cooldownCounter = -1)
{
var ctx = new HookContext()
{
// Sender = player, This
// Player = player
};
var args = new HookArgs.PlayerHurt()
{
Victim = player,
Damage = damage,
HitDirection = hitDirection,
Pvp = pvp,
Quiet = quiet,
Obituary = deathText,
Critical = crit,
CooldownCounter = cooldownCounter
};
HookPoints.PlayerHurt.Invoke(ref ctx, ref args);
if (ctx.CheckForKick()) return false;
return ctx.Result == HookResult.DEFAULT;
}
示例2: OnPlayerKilled
/// <summary>
/// Raised by vanilla code when a player has been killed
/// </summary>
/// <param name="player">Player.</param>
/// <param name="dmg">Dmg.</param>
/// <param name="hitDirection">Hit direction.</param>
/// <param name="pvp">Pvp.</param>
/// <param name="deathText">Death text.</param>
public static bool OnPlayerKilled(Terraria.Player player, ref double dmg, ref int hitDirection, ref bool pvp, ref string deathText)
{
var ctx = new HookContext()
{
Sender = player,
Player = player
};
var args = new HookArgs.PlayerKilled()
{
Damage = dmg,
HitDirection = hitDirection,
PvP = pvp,
DeathText = deathText
};
HookPoints.PlayerKilled.Invoke(ref ctx, ref args);
if (ctx.CheckForKick()) return false;
if (ctx.Result == HookResult.DEFAULT)
{
deathText = player.name + deathText;
return true;
}
dmg = args.Damage;
hitDirection = args.HitDirection;
pvp = args.PvP;
deathText = args.DeathText;
return ctx.Result != HookResult.IGNORE;
}
示例3: ClientConnection
public ClientConnection(Socket sock)
: base(sock)
{
if (SlotId == 0)
SlotId = -1;
var remoteEndPoint = (IPEndPoint)sock.RemoteEndPoint;
_remoteAddress = new TcpAddress(remoteEndPoint.Address, remoteEndPoint.Port);
sock.LingerState = new LingerOption(true, 10);
sock.NoDelay = true;
var ctx = new HookContext
{
Connection = this
};
var args = new HookArgs.NewConnection();
HookPoints.NewConnection.Invoke(ref ctx, ref args);
if (ctx.CheckForKick())
return;
_isReceiving = true; //The connection was established, so we can begin reading
}
示例4: Read
public bool Read(int bufferId, int start, int length)
{
var buffer = NetMessage.buffer[bufferId];
var player = Main.player[bufferId];
if (Main.netMode != 2)
return true;
int x = (int)buffer.reader.ReadInt16();
int y = (int)buffer.reader.ReadInt16();
if (Math.Abs(player.position.X / 16 - x) >= 7 || Math.Abs(player.position.Y / 16 - y) >= 7)
return true;
int chestIndex = Chest.FindChest(x, y);
if (chestIndex <= -1 || Chest.UsingChest(chestIndex) != -1)
return true;
var ctx = new HookContext
{
Connection = player.Connection.Socket,
Player = player,
Sender = player
};
var args = new TDSMHookArgs.ChestOpenReceived
{
X = x,
Y = y,
ChestIndex = chestIndex
};
TDSMHookPoints.ChestOpenReceived.Invoke(ref ctx, ref args);
if (ctx.CheckForKick())
return true;
if (ctx.Result == HookResult.IGNORE)
return true;
if (ctx.Result == HookResult.DEFAULT && chestIndex > -1)
{
for (int i = 0; i < 40; i++)
{
NetMessage.SendData(32, bufferId, -1, "", chestIndex, (float)i, 0, 0, 0, 0, 0);
}
NetMessage.SendData(33, bufferId, -1, "", chestIndex, 0, 0, 0, 0, 0, 0);
Main.player[bufferId].chest = chestIndex;
if (Main.myPlayer == bufferId)
{
Main.recBigList = false;
}
NetMessage.SendData(80, -1, bufferId, "", bufferId, (float)chestIndex, 0, 0, 0, 0, 0);
}
return true;
}
示例5: Read
public bool Read(int bufferId, int start, int length)
{
var buffer = NetMessage.buffer[bufferId];
var x = (int)buffer.reader.ReadInt16();
var y = (int)buffer.reader.ReadInt16();
var colour = buffer.reader.ReadByte();
if (!WorldGen.InWorld(x, y, 3))
{
return true;
}
var player = Main.player[bufferId];
var ctx = new HookContext
{
Connection = player.Connection.Socket,
Sender = player,
Player = player,
};
var args = new TDSMHookArgs.PaintWall
{
X = x,
Y = y,
Colour = colour
};
TDSMHookPoints.PaintWall.Invoke(ref ctx, ref args);
if (ctx.CheckForKick())
return true;
if (ctx.Result == HookResult.IGNORE)
return true;
if (ctx.Result == HookResult.RECTIFY)
{
NetMessage.SendTileSquare(bufferId, x, y, 1);
return true;
}
WorldGen.paintWall(x, y, colour, false);
if (Main.netMode == 2)
{
NetMessage.SendData(64, -1, bufferId, "", x, (float)y, (float)colour, 0f, 0, 0, 0);
}
return true;
}
示例6: Read
public bool Read(int bufferId, int start, int length)
{
var buffer = NetMessage.buffer[bufferId];
var player = Main.player[bufferId];
if (Main.netMode != 2)
{
return true;
}
int x = (int)buffer.reader.ReadInt16();
int y = (int)buffer.reader.ReadInt16();
int id = Sign.ReadSign(x, y, true);
if (id >= 0)
{
var ctx = new HookContext
{
Connection = player.Connection.Socket,
Sender = player,
Player = player
};
var args = new TDSMHookArgs.SignTextGet
{
X = x,
Y = y,
SignIndex = (short)id,
Text = (id >= 0 && Main.sign[id] != null) ? Main.sign[id].text : null,
};
TDSMHookPoints.SignTextGet.Invoke(ref ctx, ref args);
if (ctx.CheckForKick() || ctx.Result == HookResult.IGNORE)
return true;
if (args.Text != null)
{
NetMessage.SendData(47, bufferId, -1, "", id, (float)bufferId, 0, 0, 0, 0, 0);
}
}
return true;
}
示例7: Read
public bool Read(int bufferId, int start, int length)
{
var buffer = NetMessage.buffer[bufferId];
int npcId = (int)buffer.reader.ReadInt16();
int playerId = (int)buffer.reader.ReadByte();
if (Main.netMode == 2)
playerId = bufferId;
var ply = Main.player[playerId];
var ctx = new HookContext()
{
Sender = ply,
Player = ply
};
var args = new TDSMHookArgs.NpcHurtReceived()
{
Victim = Terraria.Main.npc[npcId],
Damage = ply.inventory[ply.selectedItem].damage,
HitDirection = ply.direction,
Knockback = ply.inventory[ply.selectedItem].knockBack,
Critical = false,
FromNet = false,
NoEffect = false
};
TDSMHookPoints.NpcHurtReceived.Invoke(ref ctx, ref args);
if (ctx.CheckForKick() || ctx.Result == HookResult.IGNORE) return true;
Terraria.Main.npc[npcId].StrikeNPC(args.Damage, args.Knockback, args.HitDirection, false, false, false);
if (Main.netMode == 2)
{
NetMessage.SendData(24, -1, bufferId, "", npcId, (float)playerId, 0, 0, 0, 0, 0);
NetMessage.SendData(23, -1, -1, "", npcId, 0, 0, 0, 0, 0, 0);
}
return true;
}
示例8: ProcessTileSquare
private static void ProcessTileSquare(int bufferId)
{
var buffer = NetMessage.buffer[bufferId];
var player = Main.player[bufferId];
short size = buffer.reader.ReadInt16();
int startX = (int)buffer.reader.ReadInt16();
int startY = (int)buffer.reader.ReadInt16();
if (!WorldGen.InWorld(startX, startY, 3))
{
return;
}
var ctx = new HookContext
{
Sender = player,
Player = player,
Connection = player.Connection.Socket
};
var args = new HookArgs.TileSquareReceived
{
X = startX,
Y = startY,
Size = size,
ReadBuffer = buffer.readBuffer
// start = num
};
HookPoints.TileSquareReceived.Invoke(ref ctx, ref args);
// if (args.applied > 0)
// {
// WorldGen.RangeFrame(startX, startY, startX + (int)size, startY + (int)size);
// NetMessage.SendData((int)Packet.TILE_SQUARE, -1, bufferId, String.Empty, (int)size, (float)startX, (float)startY, 0f, 0);
// }
if (ctx.CheckForKick() || ctx.Result == HookResult.IGNORE)
return;
BitsByte bitsByte10 = 0;
BitsByte bitsByte11 = 0;
for (int x = startX; x < startX + (int)size; x++)
{
for (int y = startY; y < startY + (int)size; y++)
{
if (Main.tile[x, y] == null)
{
#if Full_API && !MemTile && !VANILLACOMPAT
Main.tile[x, y] = new Tile();
#elif Full_API && MemTile
Main.tile[x, y] = new OTA.Memory.MemTile(x, y);
#elif Full_API && VANILLACOMPAT && TileReady
Main.tile[x, y] = new OTA.Memory.MemTile();
#endif
}
var tile = Main.tile[x, y];
bool flag7 = tile.active();
bitsByte10 = buffer.reader.ReadByte();
bitsByte11 = buffer.reader.ReadByte();
tile.active(bitsByte10[0]);
tile.wall = (bitsByte10[2] ? (byte)1 : (byte)0);
bool flag8 = bitsByte10[3];
if (Main.netMode != 2)
{
tile.liquid = (flag8 ? (byte)1 : (byte)0);
}
tile.wire(bitsByte10[4]);
tile.halfBrick(bitsByte10[5]);
tile.actuator(bitsByte10[6]);
tile.inActive(bitsByte10[7]);
tile.wire2(bitsByte11[0]);
tile.wire3(bitsByte11[1]);
if (bitsByte11[2])
{
tile.color(buffer.reader.ReadByte());
}
if (bitsByte11[3])
{
tile.wallColor(buffer.reader.ReadByte());
}
if (tile.active())
{
int type3 = (int)tile.type;
tile.type = buffer.reader.ReadUInt16();
if (Main.tileFrameImportant[(int)tile.type])
{
tile.frameX = buffer.reader.ReadInt16();
tile.frameY = buffer.reader.ReadInt16();
}
else
{
if (!flag7 || (int)tile.type != type3)
{
tile.frameX = -1;
tile.frameY = -1;
}
}
byte b4 = 0;
//.........这里部分代码省略.........
示例9: Read
public bool Read(int bufferId, int start, int length)
{
var buffer = NetMessage.buffer[bufferId];
var player = Main.player[bufferId];
int x = (int)buffer.reader.ReadInt16();
int y = (int)buffer.reader.ReadInt16();
byte liquid = buffer.reader.ReadByte();
byte liquidType = buffer.reader.ReadByte();
if (Main.netMode == 2 && Netplay.spamCheck)
{
int centerX = (int)(Main.player[bufferId].position.X + (float)(Main.player[bufferId].width / 2));
int centerY = (int)(Main.player[bufferId].position.Y + (float)(Main.player[bufferId].height / 2));
int range = 10;
int minX = centerX - range;
int maxX = centerX + range;
int minY = centerY - range;
int maxY = centerY + range;
if (x < minX || x > maxX || y < minY || y > maxY)
{
NetMessage.BootPlayer(bufferId, "Cheating attempt detected: Liquid spam");
return true;
}
}
var ctx = new HookContext
{
Connection = player.Connection.Socket,
Player = player,
Sender = player
};
var args = new TDSMHookArgs.LiquidFlowReceived
{
X = x,
Y = y,
Amount = liquid,
Lava = liquidType == 1
};
TDSMHookPoints.LiquidFlowReceived.Invoke(ref ctx, ref args);
if (ctx.CheckForKick())
return true;
if (ctx.Result == HookResult.IGNORE)
return true;
if (ctx.Result == HookResult.RECTIFY)
{
// var msg = NewNetMessage.PrepareThreadInstance();
// msg.FlowLiquid(x, y);
// msg.Send(whoAmI);
Terraria.NetMessage.SendData((int)Packet.FLOW_LIQUID, bufferId, -1, String.Empty, x, y);
return true;
}
if (Main.tile[x, y] == null)
{
Main.tile[x, y] = new OTA.Memory.MemTile();
}
lock (Main.tile[x, y])
{
Main.tile[x, y].liquid = liquid;
Main.tile[x, y].liquidType((int)liquidType);
if (Main.netMode == 2)
{
WorldGen.SquareTileFrame(x, y, true);
}
}
return true;
}
示例10: Read
public bool Read(int bufferId, int start, int length)
{
var buffer = NetMessage.buffer[bufferId];
var player = Main.player[bufferId];
byte b7 = buffer.reader.ReadByte();
int x = (int)buffer.reader.ReadInt16();
int y = (int)buffer.reader.ReadInt16();
int type = (int)buffer.reader.ReadInt16();
if (Math.Abs(player.position.X / 16 - x) >= 7 || Math.Abs(player.position.Y / 16 - y) >= 7)
{
return true;
}
var ctx = new HookContext
{
Connection = player.Connection.Socket,
Player = player,
Sender = player
};
var args = new TDSMHookArgs.ChestBreakReceived
{
X = x,
Y = y
};
TDSMHookPoints.ChestBreakReceived.Invoke(ref ctx, ref args);
if (ctx.CheckForKick())
return true;
if (ctx.Result == HookResult.IGNORE)
return true;
if (ctx.Result == HookResult.RECTIFY)
{
NetMessage.SendTileSquare(bufferId, x, y, 3);
return true;
}
if (Main.netMode == 2)
{
if (b7 == 0)
{
int num107 = WorldGen.PlaceChest(x, y, 21, false, type);
if (num107 == -1)
{
NetMessage.SendData(34, bufferId, -1, "", (int)b7, (float)x, (float)y, (float)type, num107, 0, 0);
Item.NewItem(x * 16, y * 16, 32, 32, Chest.chestItemSpawn[type], 1, true, 0, false, false);
return true;
}
NetMessage.SendData(34, -1, -1, "", (int)b7, (float)x, (float)y, (float)type, num107, 0, 0);
return true;
}
else if (b7 == 2)
{
int num108 = WorldGen.PlaceChest(x, y, 88, false, type);
if (num108 == -1)
{
NetMessage.SendData(34, bufferId, -1, "", (int)b7, (float)x, (float)y, (float)type, num108, 0, 0);
Item.NewItem(x * 16, y * 16, 32, 32, Chest.dresserItemSpawn[type], 1, true, 0, false, false);
return true;
}
NetMessage.SendData(34, -1, -1, "", (int)b7, (float)x, (float)y, (float)type, num108, 0, 0);
return true;
}
else
{
var tile2 = Main.tile[x, y];
if (tile2.type == 21 && b7 == 1)
{
if (tile2.frameX % 36 != 0)
{
x--;
}
if (tile2.frameY % 36 != 0)
{
y--;
}
int number = Chest.FindChest(x, y);
WorldGen.KillTile(x, y, false, false, false);
if (!tile2.active())
{
NetMessage.SendData(34, -1, -1, "", (int)b7, (float)x, (float)y, 0f, number, 0, 0);
return true;
}
return true;
}
else
{
if (tile2.type != 88 || b7 != 3)
{
return true;
}
x -= (int)(tile2.frameX % 54 / 18);
if (tile2.frameY % 36 != 0)
{
y--;
//.........这里部分代码省略.........
示例11: ParseAndProcess
/// <summary>
/// Parses and process a command from a sender
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="line">Line.</param>
public void ParseAndProcess(ISender sender, string line)
{
var ctx = new HookContext
{
Sender = sender,
#if Full_API
Player = sender as Player
#endif
};
#if Full_API
ctx.Connection = ctx.Player != null ? ctx.Player.Connection.Socket : null;
#endif
var hargs = new HookArgs.ServerCommand();
try
{
CommandInfo info;
var firstSpace = line.IndexOf(' ');
if (firstSpace < 0)
firstSpace = line.Length;
var prefix = line.Substring(0, firstSpace).ToLower();
hargs.Prefix = prefix;
if (FindStringCommand(prefix, out info))
{
hargs.ArgumentString = (firstSpace < line.Length - 1 ? line.Substring(firstSpace + 1, line.Length - firstSpace - 1) : "").Trim();
HookPoints.ServerCommand.Invoke(ref ctx, ref hargs);
if (ctx.CheckForKick() || ctx.Result == HookResult.IGNORE)
return;
if (ctx.Result != HookResult.CONTINUE && !CheckAccessLevel(info, sender))
{
sender.SendMessage("Permissions error", 255, 238, 130, 238);
return;
}
try
{
info.Run(sender, hargs.ArgumentString);
}
catch (NLua.Exceptions.LuaScriptException e)
{
if (e.IsNetException)
{
var ex = e.GetBaseException();
if (ex != null)
{
if (ex is CommandError)
{
sender.SendMessage(prefix + ": " + ex.Message);
info.ShowHelp(sender);
}
}
}
}
catch (ExitException e)
{
throw e;
}
catch (CommandError e)
{
sender.SendMessage(prefix + ": " + e.Message);
info.ShowHelp(sender);
}
return;
}
var args = new ArgumentList();
var command = Tokenize(line, args);
if (command != null)
{
if (FindTokenCommand(command, out info))
{
hargs.Arguments = args;
hargs.ArgumentString = args.ToString();
foreach (BasePlugin plg in PluginManager._plugins.Values)
{
if (plg.commands.ContainsKey(command))
{
args.Plugin = plg;
}
}
HookPoints.ServerCommand.Invoke(ref ctx, ref hargs);
//.........这里部分代码省略.........
示例12: Read
public bool Read(int bufferId, int start, int length)
{
var buffer = NetMessage.buffer[bufferId];
var player = Main.player[bufferId];
var conn = Netplay.Clients[bufferId];
if (Main.netMode != 2)
{
return true;
}
var clientPassword = buffer.reader.ReadString();
if (conn.State == -1)
{
var ctx = new HookContext
{
Connection = conn.Socket,
Player = player,
Sender = player
};
var args = new TDSMHookArgs.ServerPassReceived
{
Password = clientPassword,
};
TDSMHookPoints.ServerPassReceived.Invoke(ref ctx, ref args);
if (ctx.CheckForKick())
return true;
if (ctx.Result == HookResult.ASK_PASS)
{
NetMessage.SendData((int)Packet.PASSWORD_REQUEST, bufferId);
return true;
}
else if (ctx.Result == HookResult.CONTINUE || clientPassword == Netplay.ServerPassword)
{
Netplay.Clients[bufferId].State = 1;
NetMessage.SendData((int)Packet.CONNECTION_RESPONSE, bufferId, -1, "", 0, 0f, 0f, 0f, 0, 0, 0);
return true;
}
conn.Kick("Incorrect server password.");
}
else if (conn.State == (int)ConnectionState.AwaitingUserPassword)
{
//var name = player.name ?? "";
var ctx = new HookContext
{
Connection = conn.Socket,
Player = player,
Sender = player
};
var args = new TDSMHookArgs.PlayerPassReceived
{
Password = clientPassword
};
TDSMHookPoints.PlayerPassReceived.Invoke(ref ctx, ref args);
if (ctx.CheckForKick())
return true;
if (ctx.Result == HookResult.ASK_PASS)
{
NetMessage.SendData((int)Packet.PASSWORD_REQUEST, bufferId);
return true;
}
else // HookResult.DEFAULT
{
//ProgramLog.Error.Log("Accepted player: " + player.name + "/" + (player.AuthenticatedAs ?? "null"));
//Continue with world request
Netplay.Clients[bufferId].State = 2;
Netplay.Clients[bufferId].ResetSections();
NetMessage.SendData(7, bufferId, -1, "", 0, 0f, 0f, 0f, 0, 0, 0);
Main.SyncAnInvasion(bufferId);
return true;
}
}
return true;
}
示例13: Read
public bool Read(int bufferId, int start, int length)
{
var buffer = NetMessage.buffer[bufferId];
var player = Main.player[bufferId];
var isConnection = player == null || player.Connection == null || !player.active;
if (isConnection)
{
//player = new Player();
}
player.whoAmI = bufferId;
player.IPAddress = Netplay.Clients[bufferId].Socket.GetRemoteAddress().GetIdentifier();
if (bufferId == Main.myPlayer && !Main.ServerSideCharacter)
{
return true;
}
var data = new TDSMHookArgs.PlayerDataReceived()
{
IsConnecting = isConnection
};
data.Parse(buffer.reader, start, length);
// Skip(read);
//
// if (data.Hair >= MAX_HAIR_ID)
// {
// data.Hair = 0;
// }
//
var ctx = new HookContext
{
Connection = player.Connection.Socket,
Player = player,
Sender = player,
};
//
TDSMHookPoints.PlayerDataReceived.Invoke(ref ctx, ref data);
//
if (ctx.CheckForKick())
return true;
if (!data.NameChecked)
{
string error;
if (!data.CheckName(out error))
{
player.Connection.Kick(error);
return true;
}
}
// string address = player.IPAddress.Split(':')[0];
// if (!data.BansChecked)
// {
// if (Server.Bans.Contains(address) || Server.Bans.Contains(data.Name))
// {
// ProgramLog.Admin.Log("Prevented banned user {0} from accessing the server.", data.Name);
// conn.Kick("You are banned from this server.");
// return;
// }
// }
//
// if (!data.WhitelistChecked && Server.WhitelistEnabled)
// {
// if (!Server.Whitelist.Contains(address) && !Server.Whitelist.Contains(data.Name))
// {
// ProgramLog.Admin.Log("Prevented non whitelisted user {0} from accessing the server.", data.Name);
// conn.Kick("You do not have access to this server.");
// return;
// }
// }
data.Apply(player);
{
var lname = player.name.ToLower();
foreach (var otherPlayer in Main.player)
{
// var otherSlot = Terraria.Netplay.Clients[otherPlayer.whoAmI];
if (otherPlayer.name != null && lname == otherPlayer.name.ToLower() && otherPlayer.whoAmI != bufferId) // && otherSlot.State >= SlotState.CONNECTED)
{
player.Kick("A \"" + otherPlayer.name + "\" is already on this server.");
return true;
}
}
}
if (isConnection)
{
if (ctx.Result == HookResult.ASK_PASS)
{
Netplay.Clients[bufferId].State = (int)ConnectionState.AwaitingUserPassword;
// conn.State = SlotState.PLAYER_AUTH;
// var msg = NewNetMessage.PrepareThreadInstance();
// msg.PasswordRequest();
// conn.Send(msg.Output);
//.........这里部分代码省略.........
示例14: ProcessPlayerData
private static void ProcessPlayerData(int bufferId, int start, int length)
{
var buffer = NetMessage.buffer[bufferId];
var player = Main.player[bufferId];
var isConnection = player == null || player.Connection == null || !player.active;
if (isConnection)
{
//player = new Player();
}
player.whoAmI = bufferId;
player.IPAddress = Netplay.Clients[bufferId].Socket.GetRemoteAddress().GetIdentifier();
if (bufferId == Main.myPlayer && !Main.ServerSideCharacter)
{
return;
}
var data = new HookArgs.PlayerDataReceived()
{
IsConnecting = isConnection
};
data.Parse(buffer.reader, start, length);
// Skip(read);
//
// if (data.Hair >= MAX_HAIR_ID)
// {
// data.Hair = 0;
// }
//
var ctx = new HookContext
{
Connection = player.Connection.Socket,
Player = player,
Sender = player,
};
//
HookPoints.PlayerDataReceived.Invoke(ref ctx, ref data);
//
if (ctx.CheckForKick())
return;
if (!data.NameChecked)
{
string error;
if (!data.CheckName(out error))
{
player.Connection.Kick(error);
return;
}
}
// string address = player.IPAddress.Split(':')[0];
// if (!data.BansChecked)
// {
// if (Server.Bans.Contains(address) || Server.Bans.Contains(data.Name))
// {
// ProgramLog.Admin.Log("Prevented banned user {0} from accessing the server.", data.Name);
// conn.Kick("You are banned from this server.");
// return;
// }
// }
//
// if (!data.WhitelistChecked && Server.WhitelistEnabled)
// {
// if (!Server.Whitelist.Contains(address) && !Server.Whitelist.Contains(data.Name))
// {
// ProgramLog.Admin.Log("Prevented non whitelisted user {0} from accessing the server.", data.Name);
// conn.Kick("You do not have access to this server.");
// return;
// }
// }
data.Apply(player);
{
var lname = player.Name.ToLower();
foreach (var otherPlayer in Main.player)
{
// var otherSlot = Terraria.Netplay.Clients[otherPlayer.whoAmI];
if (otherPlayer.Name != null && lname == otherPlayer.Name.ToLower() && otherPlayer.whoAmI != bufferId) // && otherSlot.State >= SlotState.CONNECTED)
{
player.Kick("A \"" + otherPlayer.Name + "\" is already on this server.");
return;
}
}
}
if (isConnection)
{
if (ctx.Result == HookResult.ASK_PASS)
{
Netplay.Clients[bufferId].State = -2;
// conn.State = SlotState.PLAYER_AUTH;
// var msg = NewNetMessage.PrepareThreadInstance();
// msg.PasswordRequest();
// conn.Send(msg.Output);
//.........这里部分代码省略.........
示例15: OnNameCollision
public static bool OnNameCollision(Terraria.Player connectee, int bufferId)
{
var ctx = new HookContext();
var args = new HookArgs.NameConflict()
{
Connectee = connectee,
BufferId = bufferId
};
HookPoints.NameConflict.Invoke(ref ctx, ref args);
if (ctx.CheckForKick()) return false;
return ctx.Result == HookResult.DEFAULT; //Continue on to kicking
}