public static void AddBan(int plr) { #if Full_API var ctx = new HookContext() { Sender = HookContext.ConsoleSender }; var args = new HookArgs.AddBan() { RemoteAddress = Terraria.Netplay.Clients[plr].RemoteAddress() }; HookPoints.AddBan.Invoke(ref ctx, ref args); if (ctx.Result == HookResult.DEFAULT) { string remote = Terraria.Netplay.Clients[plr].RemoteAddress(); string ip = remote; for (int i = 0; i < remote.Length; i++) { if (remote.Substring(i, 1) == ":") { ip = remote.Substring(0, i); } } using (StreamWriter streamWriter = new StreamWriter(Terraria.Netplay.BanFilePath, true)) { streamWriter.WriteLine("//" + Terraria.Main.player[plr].name); streamWriter.WriteLine(ip); } } #endif }
public static void AddBan(int plr) { #if Full_API var ctx = new HookContext() { Sender = HookContext.ConsoleSender }; var args = new HookArgs.AddBan() { RemoteAddress = Terraria.Netplay.Clients[plr].RemoteAddress() }; HookPoints.AddBan.Invoke(ref ctx, ref args); if (ctx.Result == HookResult.DEFAULT) { var remoteAddress = Terraria.Netplay.Clients [plr].Socket.GetRemoteAddress(); using (StreamWriter streamWriter = new StreamWriter(Terraria.Netplay.BanFilePath, true)) { streamWriter.WriteLine("//" + Terraria.Main.player [plr].name); streamWriter.WriteLine(remoteAddress.GetIdentifier()); } } #endif }