Random Improvements and Fixes

This commit is contained in:
Zidonuke 2011-12-20 03:31:47 -05:00
parent 0ac0dd02f8
commit 82fb69f9d4
5 changed files with 31 additions and 28 deletions

View file

@ -141,9 +141,6 @@ namespace TShockAPI
[Description("This will save the world if Terraria crashes from an unhandled exception.")] [Description("This will save the world if Terraria crashes from an unhandled exception.")]
public bool SaveWorldOnCrash = true; public bool SaveWorldOnCrash = true;
[Description("This is kick players who have custom items in their inventory (via a mod)")]
public bool KickCustomItems = false;
[Description("This will announce a player's location on join")] [Description("This will announce a player's location on join")]
public bool EnableGeoIP = false; public bool EnableGeoIP = false;

View file

@ -27,11 +27,11 @@ namespace TShockAPI.DB
creator.EnsureExists(table); creator.EnsureExists(table);
//Add default groups //Add default groups
AddGroup("default", "canwater,canlava,warp,canbuild"); AddGroup("default", "warp,canbuild");
AddGroup("newadmin", "default", "kick,editspawn,reservedslot"); AddGroup("newadmin", "default", "kick,editspawn,reservedslot");
AddGroup("admin", "newadmin", "ban,unban,whitelist,causeevents,spawnboss,spawnmob,managewarp,time,tp,pvpfun,kill,logs,immunetokick,tphere"); AddGroup("admin", "newadmin", "ban,unban,whitelist,causeevents,spawnboss,spawnmob,managewarp,time,tp,pvpfun,kill,logs,immunetokick,tphere");
AddGroup("trustedadmin", "admin", "maintenance,cfg,butcher,item,heal,immunetoban,ignorecheatdetection,ignoregriefdetection,usebanneditem,manageusers"); AddGroup("trustedadmin", "admin", "maintenance,cfg,butcher,item,heal,immunetoban,ignorecheatdetection,usebanneditem,manageusers");
AddGroup("vip", "default", "canwater,canlava,warp,canbuild,reservedslot"); AddGroup("vip", "default", "reservedslot");
String file = Path.Combine(TShock.SavePath, "groups.txt"); String file = Path.Combine(TShock.SavePath, "groups.txt");
if (File.Exists(file)) if (File.Exists(file))

View file

@ -25,6 +25,7 @@ using Terraria;
using TShockAPI.Net; using TShockAPI.Net;
using System.IO.Streams; using System.IO.Streams;
using System.Net;
namespace TShockAPI namespace TShockAPI
{ {
@ -211,6 +212,28 @@ namespace TShockAPI
} }
args.Player.Difficulty = difficulty; args.Player.Difficulty = difficulty;
args.Player.ReceivedInfo = true; args.Player.ReceivedInfo = true;
NetMessage.SendData((int)PacketTypes.TimeSet, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
if (TShock.Config.EnableGeoIP && TShock.Geo != null)
{
var code = TShock.Geo.TryGetCountryCode(IPAddress.Parse(args.Player.IP));
args.Player.Country = code == null ? "N/A" : MaxMind.GeoIPCountry.GetCountryNameByCode(code);
if (code == "A1")
if (TShock.Config.KickProxyUsers)
TShock.Utils.Kick(args.Player, "Proxies are not allowed");
Log.Info(string.Format("{0} ({1}) from '{2}' group from '{3}' joined.", args.Player.Name, args.Player.IP, args.Player.Group.Name, args.Player.Country));
TShock.Utils.Broadcast(args.Player.Name + " has joined from the " + args.Player.Country, Color.Yellow);
}
else
{
Log.Info(string.Format("{0} ({1}) from '{2}' group joined.", args.Player.Name, args.Player.IP, args.Player.Group.Name));
TShock.Utils.Broadcast(args.Player.Name + " has joined", Color.Yellow);
}
if (TShock.Config.DisplayIPToAdmins)
TShock.Utils.SendLogs(string.Format("{0} has joined. IP: {1}", args.Player.Name, args.Player.IP), Color.Blue);
return false; return false;
} }

View file

@ -262,7 +262,8 @@ namespace TShockAPI
{ {
try try
{ {
SendData(PacketTypes.TileSendSquare, "", size, (x - (size / 2)), (y - (size / 2))); int num = (size - 1) / 2;
SendData(PacketTypes.TileSendSquare, "", size, (float)(x - num), (float)(y - num));
return true; return true;
} }
catch (Exception ex) catch (Exception ex)

View file

@ -715,30 +715,14 @@ namespace TShockAPI
return; return;
} }
NetMessage.SendData((int)PacketTypes.TimeSet, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
NetMessage.syncPlayers();
if (Config.EnableGeoIP && Geo != null)
{
var code = Geo.TryGetCountryCode(IPAddress.Parse(player.IP));
player.Country = code == null ? "N/A" : MaxMind.GeoIPCountry.GetCountryNameByCode(code);
if (code == "A1")
if (TShock.Config.KickProxyUsers)
TShock.Utils.Kick(player, "Proxies are not allowed");
Log.Info(string.Format("{0} ({1}) from '{2}' group from '{3}' joined.", player.Name, player.IP, player.Group.Name, player.Country));
TShock.Utils.Broadcast(player.Name + " has joined from the " + player.Country, Color.Yellow);
}
else
{
Log.Info(string.Format("{0} ({1}) from '{2}' group joined.", player.Name, player.IP, player.Group.Name));
TShock.Utils.Broadcast(player.Name + " has joined", Color.Yellow);
}
TShock.Utils.ShowFileToUser(player, "motd.txt"); TShock.Utils.ShowFileToUser(player, "motd.txt");
if (HackedHealth(player)) if (HackedHealth(player))
{ {
TShock.Utils.HandleCheater(player, "Health/Mana cheat detected. Please use a different character."); TShock.Utils.HandleCheater(player, "Health/Mana cheat detected. Please use a different character.");
} }
NetMessage.syncPlayers();
if (Config.AlwaysPvP) if (Config.AlwaysPvP)
{ {
player.SetPvP(true); player.SetPvP(true);
@ -756,8 +740,6 @@ namespace TShockAPI
player.Teleport((int)pos.X, (int)pos.Y); player.Teleport((int)pos.X, (int)pos.Y);
player.SendTileSquare((int)pos.X, (int)pos.Y); player.SendTileSquare((int)pos.X, (int)pos.Y);
} }
if (Config.DisplayIPToAdmins)
Utils.SendLogs(string.Format("{0} has joined. IP: {1}", player.Name, player.IP), Color.Blue);
e.Handled = true; e.Handled = true;
} }