diff --git a/Build/TerrariaServer.XML b/Build/TerrariaServer.XML new file mode 100644 index 00000000..1b7deea8 --- /dev/null +++ b/Build/TerrariaServer.XML @@ -0,0 +1,90 @@ + + + + TerrariaServer + + + + + Hooks interface + + + + + List of players + + + + + See generic HandlerList + + + + + Works like an event. Allows for registering delegates with a higher or lower priority. + + + + + + Register a handler + + Delegate to be called + Priority of the delegate + Should the handler receive a call even if it has been handled + + + + Attempts to damage the player. + + int - how much damage to give + + + + Sends message to specified player + + string - text to send + Color - color for the text + + + + Meant to only be used by TServer. + + + + + The character name of the player. + + + + + Return a list of interfaces this plugin exposes. + + + + + + Called before initialize passing all the interfaces gathered from plugins + + + + + + Gets the T interface from the collection. Returns null if its not found. + + + + + + + + Called when the player first connects. They are not fully in the game yet, for that see Greet. + + + + + Called when the player is actually loaded into the game. + + + + diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 9306ef4c..c9346ffc 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -75,6 +75,8 @@ namespace TShockAPI public PlayerData PlayerData; public bool RequiresPassword; public bool SilentKickInProgress; + public List IceTiles { get; set; } + public bool RealPlayer { @@ -86,7 +88,7 @@ namespace TShockAPI get { return RealPlayer && - (Netplay.serverSock[Index] != null && Netplay.serverSock[Index].active && !Netplay.serverSock[Index].kill); + (Netplay.serverSock[Index] != null && Netplay.serverSock[Index].active && !Netplay.serverSock[Index].kill); } } @@ -105,8 +107,8 @@ namespace TShockAPI CacheIP = RealPlayer ? (Netplay.serverSock[Index].tcpClient.Connected - ? TShock.Utils.GetRealIP(Netplay.serverSock[Index].tcpClient.Client.RemoteEndPoint.ToString()) - : "") + ? TShock.Utils.GetRealIP(Netplay.serverSock[Index].tcpClient.Client.RemoteEndPoint.ToString()) + : "") : ""; else return CacheIP; @@ -213,28 +215,28 @@ namespace TShockAPI using (var ms = new MemoryStream()) { var msg = new WorldInfoMsg - { - Time = (int) Main.time, - DayTime = Main.dayTime, - MoonPhase = (byte) Main.moonPhase, - BloodMoon = Main.bloodMoon, - MaxTilesX = Main.maxTilesX, - MaxTilesY = Main.maxTilesY, - SpawnX = tilex, - SpawnY = tiley, - WorldSurface = (int) Main.worldSurface, - RockLayer = (int) Main.rockLayer, - //Sending a fake world id causes the client to not be able to find a stored spawnx/y. - //This fixes the bed spawn point bug. With a fake world id it wont be able to find the bed spawn. - WorldID = !fakeid ? Main.worldID : -1, - WorldFlags = (WorldGen.shadowOrbSmashed ? WorldInfoFlag.OrbSmashed : WorldInfoFlag.None) | - (NPC.downedBoss1 ? WorldInfoFlag.DownedBoss1 : WorldInfoFlag.None) | - (NPC.downedBoss2 ? WorldInfoFlag.DownedBoss2 : WorldInfoFlag.None) | - (NPC.downedBoss3 ? WorldInfoFlag.DownedBoss3 : WorldInfoFlag.None) | - (Main.hardMode ? WorldInfoFlag.HardMode : WorldInfoFlag.None) | - (NPC.downedClown ? WorldInfoFlag.DownedClown : WorldInfoFlag.None), - WorldName = Main.worldName - }; + { + Time = (int) Main.time, + DayTime = Main.dayTime, + MoonPhase = (byte) Main.moonPhase, + BloodMoon = Main.bloodMoon, + MaxTilesX = Main.maxTilesX, + MaxTilesY = Main.maxTilesY, + SpawnX = tilex, + SpawnY = tiley, + WorldSurface = (int) Main.worldSurface, + RockLayer = (int) Main.rockLayer, + //Sending a fake world id causes the client to not be able to find a stored spawnx/y. + //This fixes the bed spawn point bug. With a fake world id it wont be able to find the bed spawn. + WorldID = !fakeid ? Main.worldID : -1, + WorldFlags = (WorldGen.shadowOrbSmashed ? WorldInfoFlag.OrbSmashed : WorldInfoFlag.None) | + (NPC.downedBoss1 ? WorldInfoFlag.DownedBoss1 : WorldInfoFlag.None) | + (NPC.downedBoss2 ? WorldInfoFlag.DownedBoss2 : WorldInfoFlag.None) | + (NPC.downedBoss3 ? WorldInfoFlag.DownedBoss3 : WorldInfoFlag.None) | + (Main.hardMode ? WorldInfoFlag.HardMode : WorldInfoFlag.None) | + (NPC.downedClown ? WorldInfoFlag.DownedClown : WorldInfoFlag.None), + WorldName = Main.worldName + }; msg.PackFull(ms); SendRawData(ms.ToArray()); } @@ -277,11 +279,11 @@ namespace TShockAPI using (var ms = new MemoryStream()) { var msg = new SpawnMsg - { - PlayerIndex = (byte) Index, - TileX = tilex, - TileY = tiley - }; + { + PlayerIndex = (byte) Index, + TileX = tilex, + TileY = tiley + }; msg.PackFull(ms); SendRawData(ms.ToArray()); } @@ -292,10 +294,10 @@ namespace TShockAPI using (var ms = new MemoryStream()) { var msg = new ProjectileRemoveMsg - { - Index = (short) index, - Owner = (byte) owner - }; + { + Index = (short) index, + Owner = (byte) owner + }; msg.PackFull(ms); SendRawData(ms.ToArray()); } @@ -323,7 +325,7 @@ namespace TShockAPI Main.item[itemid].SetDefaults(name); // The set default overrides the wet and stack set by NewItem Main.item[itemid].wet = Collision.WetCollision(Main.item[itemid].position, Main.item[itemid].width, - Main.item[itemid].height); + Main.item[itemid].height); Main.item[itemid].stack = stack; Main.item[itemid].owner = Index; Main.item[itemid].prefix = (byte) prefix; @@ -349,7 +351,7 @@ namespace TShockAPI public virtual void DamagePlayer(int damage) { NetMessage.SendData((int) PacketTypes.PlayerDamage, -1, -1, "", Index, ((new Random()).Next(-1, 1)), damage, - (float) 0); + (float) 0); } public virtual void SetTeam(int team) @@ -364,14 +366,14 @@ namespace TShockAPI SetBuff(33, 330, true); //Weak SetBuff(32, 330, true); //Slow SetBuff(23, 330, true); //Cursed - if (!string.IsNullOrEmpty(reason)) - Log.ConsoleInfo(string.Format("Player {0} has been disabled for {1}", Name, reason)); + if (!string.IsNullOrEmpty(reason)) + Log.ConsoleInfo(string.Format("Player {0} has been disabled for {1}", Name, reason)); - var trace = new StackTrace(); - StackFrame frame = null; - frame = trace.GetFrame(1); - if (frame != null && frame.GetMethod().DeclaringType != null) - Log.Debug(frame.GetMethod().DeclaringType.Name + " called Disable()"); + var trace = new StackTrace(); + StackFrame frame = null; + frame = trace.GetFrame(1); + if (frame != null && frame.GetMethod().DeclaringType != null) + Log.Debug(frame.GetMethod().DeclaringType.Name + " called Disable()"); } public virtual void Whoopie(object time) @@ -397,7 +399,7 @@ namespace TShockAPI //Todo: Separate this into a few functions. SendTo, SendToAll, etc public virtual void SendData(PacketTypes msgType, string text = "", int number = 0, float number2 = 0f, - float number3 = 0f, float number4 = 0f, int number5 = 0) + float number3 = 0f, float number4 = 0f, int number5 = 0) { if (RealPlayer && !ConnectionAlive) return; @@ -489,14 +491,14 @@ namespace TShockAPI } public void SpawnNPC(int type, string name, int amount, int startTileX, int startTileY, int tileXRange = 100, - int tileYRange = 50) + int tileYRange = 50) { for (int i = 0; i < amount; i++) { int spawnTileX; int spawnTileY; TShock.Utils.GetRandomClearTileWithInRange(startTileX, startTileY, tileXRange, tileYRange, out spawnTileX, - out spawnTileY); + out spawnTileY); int npcid = NPC.NewNPC(spawnTileX*16, spawnTileY*16, type, 0); // This is for special slimes Main.npc[npcid].SetDefaults(name); diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 27620793..5e440afe 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1088,10 +1088,32 @@ namespace TShockAPI public static bool CheckTilePermission( TSPlayer player, int tileX, int tileY, byte tileType ) { - if (!player.Group.HasPermission(Permissions.canbuild) && !(TShock.Config.AllowIce && tileType == 127) ) + if (!player.Group.HasPermission(Permissions.canbuild)) { - player.SendMessage("You do not have permission to build!", Color.Red); - return true; + if (TShock.Config.AllowIce && tileType == 0) + { + foreach (Point p in player.IceTiles) + { + if (p.X == tileX) + { + if (p.Y == tileY) + { + player.IceTiles.Remove(p); + return false; + } + } + } + } + + if (TShock.Config.AllowIce && tileType == 127) + { + player.IceTiles.Add(new Point(tileX, tileY)); + } + else + { + player.SendMessage("You do not have permission to build!", Color.Red); + return true; + } } if (!player.Group.HasPermission(Permissions.editspawn) && !Regions.CanBuild(tileX, tileY, player) && Regions.InArea(tileX, tileY))