Stripped out stupid shit
Commented packets we dont know about yet.
This commit is contained in:
parent
dea360869b
commit
c17b661166
13 changed files with 178 additions and 478 deletions
|
|
@ -24,7 +24,6 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using TShockAPI.PluginUpdater;
|
||||
using Terraria;
|
||||
using TShockAPI.DB;
|
||||
|
||||
|
|
@ -1259,7 +1258,6 @@ namespace TShockAPI
|
|||
{
|
||||
args.Player.SendInfoMessage("Starting plugin update process:");
|
||||
args.Player.SendInfoMessage("This may take a while, do not turn off the server!");
|
||||
new PluginUpdaterThread(args.Player);
|
||||
}
|
||||
|
||||
private static void ManageRest(CommandArgs args)
|
||||
|
|
@ -2900,13 +2898,13 @@ namespace TShockAPI
|
|||
// worth the effort as chances are very low that overwriting the wire for a few
|
||||
// nanoseconds will cause much trouble.
|
||||
Tile tile = Main.tile[boundaryPoint.X, boundaryPoint.Y];
|
||||
bool oldWireState = tile.wire;
|
||||
tile.wire = true;
|
||||
bool oldWireState = tile.wire();
|
||||
tile.wire(true);
|
||||
|
||||
try {
|
||||
args.Player.SendTileSquare(boundaryPoint.X, boundaryPoint.Y, 1);
|
||||
} finally {
|
||||
tile.wire = oldWireState;
|
||||
tile.wire(oldWireState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3829,7 +3827,7 @@ namespace TShockAPI
|
|||
case "tree":
|
||||
for (int i = x - 1; i < x + 2; i++)
|
||||
{
|
||||
Main.tile[i, y].active = true;
|
||||
Main.tile[i, y].active(true);
|
||||
Main.tile[i, y].type = 2;
|
||||
Main.tile[i, y].wall = 0;
|
||||
}
|
||||
|
|
@ -3840,20 +3838,20 @@ namespace TShockAPI
|
|||
case "epictree":
|
||||
for (int i = x - 1; i < x + 2; i++)
|
||||
{
|
||||
Main.tile[i, y].active = true;
|
||||
Main.tile[i, y].active(true);
|
||||
Main.tile[i, y].type = 2;
|
||||
Main.tile[i, y].wall = 0;
|
||||
}
|
||||
Main.tile[x, y - 1].wall = 0;
|
||||
Main.tile[x, y - 1].liquid = 0;
|
||||
Main.tile[x, y - 1].active = true;
|
||||
Main.tile[x, y - 1].active(true);
|
||||
WorldGen.GrowEpicTree(x, y);
|
||||
name = "Epic Tree";
|
||||
break;
|
||||
case "mushroom":
|
||||
for (int i = x - 1; i < x + 2; i++)
|
||||
{
|
||||
Main.tile[i, y].active = true;
|
||||
Main.tile[i, y].active(true);
|
||||
Main.tile[i, y].type = 70;
|
||||
Main.tile[i, y].wall = 0;
|
||||
}
|
||||
|
|
@ -3867,7 +3865,7 @@ namespace TShockAPI
|
|||
name = "Cactus";
|
||||
break;
|
||||
case "herb":
|
||||
Main.tile[x, y].active = true;
|
||||
Main.tile[x, y].active(true);
|
||||
Main.tile[x, y].frameX = 36;
|
||||
Main.tile[x, y].type = 83;
|
||||
WorldGen.GrowAlch(x, y);
|
||||
|
|
|
|||
|
|
@ -499,7 +499,7 @@ namespace TShockAPI
|
|||
{
|
||||
for (int j = num3; j < num4; j++)
|
||||
{
|
||||
if (Main.tile[i, j] != null && Main.tile[i, j].active && Main.tileSolid[(int)Main.tile[i, j].type] && !Main.tileSolidTop[(int)Main.tile[i, j].type] &&(((int)Main.tile[i,j].type !=53) && ((int)Main.tile[i,j].type !=112) && ((int)Main.tile[i,j].type !=116) && ((int)Main.tile[i,j].type !=123)) && !Main.tile[i,j].lava)
|
||||
if (Main.tile[i, j] != null && Main.tile[i, j].active() && Main.tileSolid[(int)Main.tile[i, j].type] && !Main.tileSolidTop[(int)Main.tile[i, j].type] &&(((int)Main.tile[i,j].type !=53) && ((int)Main.tile[i,j].type !=112) && ((int)Main.tile[i,j].type !=116) && ((int)Main.tile[i,j].type !=123)) && !Main.tile[i,j].lava())
|
||||
{
|
||||
Vector2 vector;
|
||||
vector.X = (float)(i * 16);
|
||||
|
|
@ -1143,33 +1143,33 @@ namespace TShockAPI
|
|||
{PacketTypes.PlayerInfo, HandlePlayerInfo},
|
||||
{PacketTypes.PlayerUpdate, HandlePlayerUpdate},
|
||||
{PacketTypes.Tile, HandleTile},
|
||||
{PacketTypes.TileSendSquare, HandleSendTileSquare},
|
||||
/*{PacketTypes.TileSendSquare, HandleSendTileSquare},
|
||||
{PacketTypes.ProjectileNew, HandleProjectileNew},
|
||||
{PacketTypes.TogglePvp, HandleTogglePvp},
|
||||
{PacketTypes.PlayerTeam, HandlePlayerTeam},
|
||||
{PacketTypes.TileKill, HandleTileKill},
|
||||
{PacketTypes.PlayerKillMe, HandlePlayerKillMe},
|
||||
{PacketTypes.LiquidSet, HandleLiquidSet},
|
||||
{PacketTypes.LiquidSet, HandleLiquidSet},*/
|
||||
{PacketTypes.PlayerSpawn, HandleSpawn},
|
||||
{PacketTypes.ChestGetContents, HandleChestOpen},
|
||||
/*{PacketTypes.ChestGetContents, HandleChestOpen},
|
||||
{PacketTypes.ChestItem, HandleChestItem},
|
||||
{PacketTypes.SignNew, HandleSign},
|
||||
{PacketTypes.SignNew, HandleSign},*/
|
||||
{PacketTypes.PlayerSlot, HandlePlayerSlot},
|
||||
{PacketTypes.TileGetSection, HandleGetSection},
|
||||
{PacketTypes.UpdateNPCHome, UpdateNPCHome},
|
||||
/*{PacketTypes.UpdateNPCHome, UpdateNPCHome},
|
||||
{PacketTypes.PlayerAddBuff, HandlePlayerBuff},
|
||||
{PacketTypes.ItemDrop, HandleItemDrop},
|
||||
{PacketTypes.ItemDrop, HandleItemDrop},*/
|
||||
{PacketTypes.PlayerHp, HandlePlayerHp},
|
||||
{PacketTypes.PlayerMana, HandlePlayerMana},
|
||||
/*{PacketTypes.PlayerMana, HandlePlayerMana},
|
||||
{PacketTypes.PlayerDamage, HandlePlayerDamage},
|
||||
{PacketTypes.NpcStrike, HandleNpcStrike},
|
||||
{PacketTypes.NpcSpecial, HandleSpecial},
|
||||
{PacketTypes.PlayerAnimation, HandlePlayerAnimation},
|
||||
{PacketTypes.PlayerBuff, HandlePlayerBuffUpdate},
|
||||
{PacketTypes.PasswordSend, HandlePassword},
|
||||
{PacketTypes.PasswordSend, HandlePassword},*/
|
||||
{PacketTypes.ContinueConnecting2, HandleConnecting},
|
||||
{PacketTypes.ProjectileDestroy, HandleProjectileKill},
|
||||
{PacketTypes.SpawnBossorInvasion, HandleSpawnBoss}
|
||||
/*{PacketTypes.ProjectileDestroy, HandleProjectileKill},
|
||||
{PacketTypes.SpawnBossorInvasion, HandleSpawnBoss}*/
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -1333,13 +1333,13 @@ namespace TShockAPI
|
|||
if (user != null && !TShock.Config.DisableLoginBeforeJoin)
|
||||
{
|
||||
args.Player.RequiresPassword = true;
|
||||
NetMessage.SendData((int) PacketTypes.PasswordRequired, args.Player.Index);
|
||||
//NetMessage.SendData((int) PacketTypes.PasswordRequired, args.Player.Index);
|
||||
return true;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(TShock.Config.ServerPassword))
|
||||
{
|
||||
args.Player.RequiresPassword = true;
|
||||
NetMessage.SendData((int) PacketTypes.PasswordRequired, args.Player.Index);
|
||||
//NetMessage.SendData((int) PacketTypes.PasswordRequired, args.Player.Index);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1462,7 +1462,7 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
|
||||
NetMessage.SendData((int) PacketTypes.TimeSet, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
|
||||
//NetMessage.SendData((int) PacketTypes.TimeSet, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
|
||||
|
||||
if (TShock.Config.EnableGeoIP && TShock.Geo != null)
|
||||
{
|
||||
|
|
@ -1905,7 +1905,7 @@ namespace TShockAPI
|
|||
args.Player.TilePlaceThreshold++;
|
||||
var coords = new Vector2(tileX, tileY);
|
||||
if (!args.Player.TilesCreated.ContainsKey(coords))
|
||||
args.Player.TilesCreated.Add(coords, Main.tile[tileX, tileY].Data);
|
||||
args.Player.TilesCreated.Add(coords, Main.tile[tileX, tileY]);
|
||||
}
|
||||
|
||||
if ((type == 0 || type == 4 || type == 2) && Main.tileSolid[Main.tile[tileX, tileY].type] &&
|
||||
|
|
@ -1914,13 +1914,13 @@ namespace TShockAPI
|
|||
args.Player.TileKillThreshold++;
|
||||
var coords = new Vector2(tileX, tileY);
|
||||
if (!args.Player.TilesDestroyed.ContainsKey(coords))
|
||||
args.Player.TilesDestroyed.Add(coords, Main.tile[tileX, tileY].Data);
|
||||
args.Player.TilesDestroyed.Add(coords, Main.tile[tileX, tileY]);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool HandleTogglePvp(GetDataHandlerArgs args)
|
||||
/*private static bool HandleTogglePvp(GetDataHandlerArgs args)
|
||||
{
|
||||
byte id = args.Data.ReadInt8();
|
||||
bool pvp = args.Data.ReadBoolean();
|
||||
|
|
@ -1959,7 +1959,7 @@ namespace TShockAPI
|
|||
NetMessage.SendData((int) PacketTypes.TogglePvp, -1, -1, "", args.Player.Index);
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
private static bool HandlePlayerTeam(GetDataHandlerArgs args)
|
||||
{
|
||||
|
|
@ -1975,7 +1975,7 @@ namespace TShockAPI
|
|||
|
||||
args.TPlayer.team = team;
|
||||
|
||||
NetMessage.SendData((int)PacketTypes.PlayerTeam, -1, -1, "", args.Player.Index);
|
||||
//NetMessage.SendData((int)PacketTypes.PlayerTeam, -1, -1, "", args.Player.Index);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2502,7 +2502,7 @@ namespace TShockAPI
|
|||
|
||||
if (TShock.CheckIgnores(args.Player))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.ChestItem, "", id, slot);
|
||||
//args.Player.SendData(PacketTypes.ChestItem, "", id, slot);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2537,19 +2537,19 @@ namespace TShockAPI
|
|||
|
||||
if (TShock.CheckTilePermission(args.Player, x, y))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.SignNew, "", id);
|
||||
//args.Player.SendData(PacketTypes.SignNew, "", id);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (TShock.CheckRangePermission(args.Player, x, y))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.SignNew, "", id);
|
||||
//args.Player.SendData(PacketTypes.SignNew, "", id);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool UpdateNPCHome(GetDataHandlerArgs args)
|
||||
/*private static bool UpdateNPCHome(GetDataHandlerArgs args)
|
||||
{
|
||||
var id = args.Data.ReadInt16();
|
||||
var x = args.Data.ReadInt16();
|
||||
|
|
@ -2581,11 +2581,11 @@ namespace TShockAPI
|
|||
args.Player.SendData(PacketTypes.UpdateNPCHome, "", id, Main.npc[id].homeTileX, Main.npc[id].homeTileY,
|
||||
Convert.ToByte(Main.npc[id].homeless));
|
||||
return true;
|
||||
}*/
|
||||
}*//*
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
private static bool HandlePlayerBuff(GetDataHandlerArgs args)
|
||||
/*private static bool HandlePlayerBuff(GetDataHandlerArgs args)
|
||||
{
|
||||
var id = args.Data.ReadInt8();
|
||||
var type = args.Data.ReadInt8();
|
||||
|
|
@ -2622,9 +2622,9 @@ namespace TShockAPI
|
|||
|
||||
args.Player.SendData(PacketTypes.PlayerBuff, "", id);
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
private static bool HandleItemDrop(GetDataHandlerArgs args)
|
||||
/*private static bool HandleItemDrop(GetDataHandlerArgs args)
|
||||
{
|
||||
var id = args.Data.ReadInt16();
|
||||
var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
|
||||
|
|
@ -2674,7 +2674,7 @@ namespace TShockAPI
|
|||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
private static bool HandlePlayerDamage(GetDataHandlerArgs args)
|
||||
{
|
||||
|
|
@ -2757,20 +2757,20 @@ namespace TShockAPI
|
|||
if (dmg > TShock.Config.MaxDamage && !args.Player.Group.HasPermission(Permissions.ignoredamagecap))
|
||||
{
|
||||
args.Player.Disable(String.Format("NPC damage exceeded {0}.", TShock.Config.MaxDamage ) );
|
||||
args.Player.SendData(PacketTypes.NpcUpdate, "", id);
|
||||
//args.Player.SendData(PacketTypes.NpcUpdate, "", id);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (TShock.CheckIgnores(args.Player))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.NpcUpdate, "", id);
|
||||
//args.Player.SendData(PacketTypes.NpcUpdate, "", id);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Main.npc[id].townNPC && !args.Player.Group.HasPermission(Permissions.movenpc))
|
||||
{
|
||||
args.Player.SendMessage( "You don't have permission to move this NPC.", Color.Yellow);
|
||||
args.Player.SendData(PacketTypes.NpcUpdate, "", id);
|
||||
//args.Player.SendData(PacketTypes.NpcUpdate, "", id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2778,13 +2778,13 @@ namespace TShockAPI
|
|||
TShock.CheckRangePermission(args.Player, (int) (Main.npc[id].position.X/16f), (int) (Main.npc[id].position.Y/16f),
|
||||
128))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.NpcUpdate, "", id);
|
||||
//args.Player.SendData(PacketTypes.NpcUpdate, "", id);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
|
||||
{
|
||||
args.Player.SendData(PacketTypes.NpcUpdate, "", id);
|
||||
//args.Player.SendData(PacketTypes.NpcUpdate, "", id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2817,13 +2817,13 @@ namespace TShockAPI
|
|||
|
||||
if (TShock.CheckIgnores(args.Player))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.PlayerAnimation, "", args.Player.Index);
|
||||
//args.Player.SendData(PacketTypes.PlayerAnimation, "", args.Player.Index);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
|
||||
{
|
||||
args.Player.SendData(PacketTypes.PlayerAnimation, "", args.Player.Index);
|
||||
//args.Player.SendData(PacketTypes.PlayerAnimation, "", args.Player.Index);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2860,7 +2860,7 @@ namespace TShockAPI
|
|||
args.TPlayer.buffTime[i] = 0;
|
||||
}
|
||||
}
|
||||
NetMessage.SendData((int) PacketTypes.PlayerBuff, -1, args.Player.Index, "", args.Player.Index);
|
||||
//NetMessage.SendData((int) PacketTypes.PlayerBuff, -1, args.Player.Index, "", args.Player.Index);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ namespace TShockAPI.Net
|
|||
{
|
||||
public override PacketTypes ID
|
||||
{
|
||||
get { return PacketTypes.ProjectileNew; }
|
||||
get{ return 0; }
|
||||
//PacketTypes.ProjectileNew; }
|
||||
}
|
||||
|
||||
public short Index { get; set; }
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ using System.ComponentModel;
|
|||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using Hooks;
|
||||
using Terraria;
|
||||
using TerrariaApi.Server;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
|
|
@ -34,6 +34,8 @@ namespace TShockAPI
|
|||
/// </summary>
|
||||
public int BytesPerUpdate { get; set; }
|
||||
|
||||
private readonly TShock plugin;
|
||||
|
||||
private PacketBuffer[] buffers = new PacketBuffer[Netplay.serverSock.Length];
|
||||
|
||||
private int[] Bytes = new int[52];
|
||||
|
|
@ -45,8 +47,9 @@ namespace TShockAPI
|
|||
Command flush;
|
||||
#endif
|
||||
|
||||
public PacketBufferer()
|
||||
public PacketBufferer(TShock p)
|
||||
{
|
||||
plugin = p;
|
||||
BytesPerUpdate = 0xFFFF;
|
||||
for (int i = 0; i < buffers.Length; i++)
|
||||
buffers[i] = new PacketBuffer();
|
||||
|
|
@ -58,9 +61,9 @@ namespace TShockAPI
|
|||
Commands.ChatCommands.Add(flush);
|
||||
#endif
|
||||
|
||||
NetHooks.SendBytes += ServerHooks_SendBytes;
|
||||
ServerHooks.SocketReset += ServerHooks_SocketReset;
|
||||
GameHooks.PostUpdate += GameHooks_Update;
|
||||
ServerApi.Hooks.NetSendBytes.Register(plugin, ServerHooks_SendBytes);
|
||||
ServerApi.Hooks.ServerSocketReset.Register(plugin, ServerHooks_SocketReset);
|
||||
ServerApi.Hooks.GamePostUpdate.Register(plugin, GameHooks_Update);
|
||||
}
|
||||
|
||||
~PacketBufferer()
|
||||
|
|
@ -82,9 +85,9 @@ namespace TShockAPI
|
|||
Commands.ChatCommands.Remove(dump);
|
||||
Commands.ChatCommands.Remove(flush);
|
||||
#endif
|
||||
NetHooks.SendBytes -= ServerHooks_SendBytes;
|
||||
ServerHooks.SocketReset -= ServerHooks_SocketReset;
|
||||
GameHooks.PostUpdate -= GameHooks_Update;
|
||||
ServerApi.Hooks.NetSendBytes.Deregister(plugin, ServerHooks_SendBytes);
|
||||
ServerApi.Hooks.ServerSocketReset.Deregister(plugin, ServerHooks_SocketReset);
|
||||
ServerApi.Hooks.GamePostUpdate.Deregister(plugin, GameHooks_Update);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +110,7 @@ namespace TShockAPI
|
|||
Compressed = new int[52];
|
||||
}
|
||||
|
||||
private void GameHooks_Update()
|
||||
private void GameHooks_Update(EventArgs args)
|
||||
{
|
||||
FlushAll();
|
||||
}
|
||||
|
|
@ -148,9 +151,9 @@ namespace TShockAPI
|
|||
}
|
||||
|
||||
|
||||
private void ServerHooks_SocketReset(ServerSock socket)
|
||||
private void ServerHooks_SocketReset(SocketResetEventArgs args)
|
||||
{
|
||||
buffers[socket.whoAmI] = new PacketBuffer();
|
||||
buffers[args.Socket.whoAmI] = new PacketBuffer();
|
||||
}
|
||||
|
||||
public bool SendBytes(ServerSock socket, byte[] buffer)
|
||||
|
|
@ -217,10 +220,10 @@ namespace TShockAPI
|
|||
return false;
|
||||
}
|
||||
|
||||
private void ServerHooks_SendBytes(ServerSock socket, byte[] buffer, int offset, int count, HandledEventArgs e)
|
||||
private void ServerHooks_SendBytes(SendBytesEventArgs args)
|
||||
{
|
||||
e.Handled = true;
|
||||
BufferBytes(socket, buffer, offset, count);
|
||||
args.Handled = true;
|
||||
BufferBytes(args.Socket, args.Buffer, args.Offset, args.Count);
|
||||
}
|
||||
|
||||
#if DEBUG_NET
|
||||
|
|
|
|||
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
TShock, a server mod for Terraria
|
||||
Copyright (C) 2011-2013 Nyx Studios (fka. The TShock Team)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Terraria;
|
||||
|
||||
namespace TShockAPI.PluginUpdater
|
||||
{
|
||||
class PluginUpdaterThread
|
||||
{
|
||||
private TSPlayer invoker;
|
||||
public PluginUpdaterThread(TSPlayer player)
|
||||
{
|
||||
invoker = player;
|
||||
PluginVersionCheck.PluginUpdate += PluginUpdate;
|
||||
HandleUpdate();
|
||||
}
|
||||
|
||||
private void HandleUpdate()
|
||||
{
|
||||
foreach(PluginContainer cont in ProgramServer.Plugins)
|
||||
new Thread(PluginVersionCheck.CheckPlugin).Start(cont.Plugin);
|
||||
}
|
||||
|
||||
private int Updates = 0;
|
||||
private void PluginUpdate(UpdateArgs args)
|
||||
{
|
||||
Updates++;
|
||||
if(args.Success && String.IsNullOrEmpty(args.Error))
|
||||
{
|
||||
invoker.SendSuccessMessage(String.Format("{0} was downloaded successfully.", args.Plugin.Name));
|
||||
}
|
||||
else if(args.Success)
|
||||
{
|
||||
invoker.SendSuccessMessage(String.Format("{0} was skipped. Reason: {1}", args.Plugin.Name, args.Error));
|
||||
}
|
||||
else
|
||||
{
|
||||
invoker.SendSuccessMessage(String.Format("{0} failed to downloaded. Error: {1}", args.Plugin.Name, args.Error));
|
||||
}
|
||||
|
||||
if(Updates >= Terraria.ProgramServer.Plugins.Count)
|
||||
{
|
||||
PluginVersionCheck.PluginUpdate -= PluginUpdate;
|
||||
|
||||
invoker.SendSuccessMessage("All plugins have been downloaded. Now copying them to the plugin folder...");
|
||||
|
||||
string folder = Path.Combine(TShock.SavePath, "UpdatedPlugins");
|
||||
string dest = Path.Combine(TShock.SavePath, "..", "ServerPlugins");
|
||||
|
||||
foreach (string dir in Directory.GetDirectories(folder, "*", System.IO.SearchOption.AllDirectories))
|
||||
{
|
||||
string new_folder = dest + dir.Substring(folder.Length);
|
||||
if (!Directory.Exists(new_folder))
|
||||
Directory.CreateDirectory(new_folder);
|
||||
}
|
||||
|
||||
foreach (string file_name in Directory.GetFiles(folder, "*.*", System.IO.SearchOption.AllDirectories))
|
||||
{
|
||||
TSPlayer.Server.SendSuccessMessage(String.Format("Copied {0}", file_name));
|
||||
File.Copy(file_name, dest + file_name.Substring(folder.Length), true);
|
||||
}
|
||||
|
||||
|
||||
Directory.Delete(folder, true);
|
||||
|
||||
invoker.SendSuccessMessage("All plugins have been processed. Restart the server to have access to the new plugins.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
/*
|
||||
TShock, a server mod for Terraria
|
||||
Copyright (C) 2011-2013 Nyx Studios (fka. The TShock Team)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using JsonLoader;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace TShockAPI.PluginUpdater
|
||||
{
|
||||
public class PluginVersionCheck
|
||||
{
|
||||
public delegate void PluginUpdateD(UpdateArgs e);
|
||||
public static event PluginUpdateD PluginUpdate;
|
||||
public static void OnPluginUpdate(UpdateArgs args)
|
||||
{
|
||||
if (PluginUpdate == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PluginUpdate(args);
|
||||
}
|
||||
|
||||
public static void CheckPlugin(object p)
|
||||
{
|
||||
TerrariaPlugin plugin = (TerrariaPlugin)p;
|
||||
UpdateArgs args = new UpdateArgs {Plugin = plugin, Success = true, Error = ""};
|
||||
List<string> files = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
if (!String.IsNullOrEmpty(plugin.UpdateURL))
|
||||
{
|
||||
var request = HttpWebRequest.Create(plugin.UpdateURL);
|
||||
VersionInfo vi;
|
||||
|
||||
request.Timeout = 5000;
|
||||
using (var response = request.GetResponse())
|
||||
{
|
||||
using (var reader = new StreamReader(response.GetResponseStream()))
|
||||
{
|
||||
vi = JsonConvert.DeserializeObject<VersionInfo>(reader.ReadToEnd());
|
||||
}
|
||||
}
|
||||
|
||||
System.Version v = System.Version.Parse((vi.version.ToString()));
|
||||
|
||||
if (!v.Equals(plugin.Version))
|
||||
{
|
||||
DownloadPackage pkg;
|
||||
request = HttpWebRequest.Create(vi.url);
|
||||
|
||||
request.Timeout = 5000;
|
||||
using (var response = request.GetResponse())
|
||||
{
|
||||
using (var reader = new StreamReader(response.GetResponseStream()))
|
||||
{
|
||||
pkg = JsonConvert.DeserializeObject<DownloadPackage>(reader.ReadToEnd());
|
||||
}
|
||||
}
|
||||
|
||||
foreach (PluginFile f in pkg.files)
|
||||
{
|
||||
using (WebClient Client = new WebClient())
|
||||
{
|
||||
string dir = Path.Combine(TShock.SavePath, "UpdatedPlugins");
|
||||
if (!Directory.Exists(dir))
|
||||
Directory.CreateDirectory(dir);
|
||||
|
||||
Client.DownloadFile(f.url,
|
||||
Path.Combine(dir, f.destination));
|
||||
|
||||
files.Add(Path.Combine(dir, f.destination));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Error = "Plugin is up to date.";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Error = "Plugin has no updater recorded.";
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
args.Success = false;
|
||||
args.Error = e.Message;
|
||||
if(files.Count > 0)
|
||||
{
|
||||
foreach(string s in files)
|
||||
{
|
||||
File.Delete(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OnPluginUpdate(args);
|
||||
}
|
||||
}
|
||||
|
||||
public class UpdateArgs
|
||||
{
|
||||
public TerrariaPlugin Plugin { get; set; }
|
||||
public bool Success { get; set; }
|
||||
public string Error { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
TShock, a server mod for Terraria
|
||||
Copyright (C) 2011-2013 Nyx Studios (fka. The TShock Team)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JsonLoader
|
||||
{
|
||||
class VersionInfo
|
||||
{
|
||||
public Version version;
|
||||
public string url;
|
||||
}
|
||||
|
||||
public class Version
|
||||
{
|
||||
public int Major;
|
||||
public int Minor;
|
||||
public int Build;
|
||||
public int Revision;
|
||||
public int MajorRevision;
|
||||
public int MinorRevision;
|
||||
|
||||
public Version()
|
||||
{
|
||||
SetVersion(0,0,0,0);
|
||||
}
|
||||
|
||||
public Version(int m)
|
||||
{
|
||||
SetVersion(m, 0, 0, 0);
|
||||
}
|
||||
|
||||
public Version(int ma, int mi)
|
||||
{
|
||||
SetVersion(ma, mi, 0, 0);
|
||||
}
|
||||
|
||||
public Version(int ma, int mi, int b)
|
||||
{
|
||||
SetVersion(ma, mi, b, 0);
|
||||
}
|
||||
|
||||
public Version(int ma, int mi, int b, int r)
|
||||
{
|
||||
SetVersion(ma, mi, b, r);
|
||||
}
|
||||
|
||||
private void SetVersion(int ma, int mi, int b, int r)
|
||||
{
|
||||
Major = ma;
|
||||
Minor = mi;
|
||||
Build = b;
|
||||
Revision = r;
|
||||
}
|
||||
|
||||
public string ToString()
|
||||
{
|
||||
return String.Format("{0}.{1}.{2}.{3}", Major, Minor, Build, Revision);
|
||||
}
|
||||
}
|
||||
|
||||
class DownloadPackage
|
||||
{
|
||||
public List<PluginFile> files;
|
||||
}
|
||||
|
||||
class PluginFile
|
||||
{
|
||||
public string url;
|
||||
public string destination = "";
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using Terraria;
|
||||
using TerrariaApi.Server;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
|
|
@ -45,7 +46,7 @@ namespace TShockAPI
|
|||
/// <summary>
|
||||
/// SaveWorld event handler which notifies users that the server may lag
|
||||
/// </summary>
|
||||
public void OnSaveWorld(bool resettime = false, HandledEventArgs e = null)
|
||||
public void OnSaveWorld(WorldSaveEventArgs args)
|
||||
{
|
||||
// Protect against internal errors causing save failures
|
||||
// These can be caused by an unexpected error such as a bad or out of date plugin
|
||||
|
|
@ -120,7 +121,7 @@ namespace TShockAPI
|
|||
{
|
||||
if (task.direct)
|
||||
{
|
||||
OnSaveWorld();
|
||||
OnSaveWorld(new WorldSaveEventArgs());
|
||||
WorldGen.realsaveWorld(task.resetTime);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -61,12 +61,12 @@ namespace TShockAPI
|
|||
/// <summary>
|
||||
/// A queue of tiles destroyed by the player for reverting.
|
||||
/// </summary>
|
||||
public Dictionary<Vector2, TileData> TilesDestroyed { get; protected set; }
|
||||
public Dictionary<Vector2, Tile> TilesDestroyed { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// A queue of tiles placed by the player for reverting.
|
||||
/// </summary>
|
||||
public Dictionary<Vector2, TileData> TilesCreated { get; protected set; }
|
||||
public Dictionary<Vector2, Tile> TilesCreated { get; protected set; }
|
||||
|
||||
public int FirstMaxHP { get; set; }
|
||||
|
||||
|
|
@ -405,8 +405,8 @@ namespace TShockAPI
|
|||
|
||||
public TSPlayer(int index)
|
||||
{
|
||||
TilesDestroyed = new Dictionary<Vector2, TileData>();
|
||||
TilesCreated = new Dictionary<Vector2, TileData>();
|
||||
TilesDestroyed = new Dictionary<Vector2, Tile>();
|
||||
TilesCreated = new Dictionary<Vector2, Tile>();
|
||||
Index = index;
|
||||
Group = Group.DefaultGroup;
|
||||
IceTiles = new List<Point>();
|
||||
|
|
@ -415,8 +415,8 @@ namespace TShockAPI
|
|||
|
||||
protected TSPlayer(String playerName)
|
||||
{
|
||||
TilesDestroyed = new Dictionary<Vector2, TileData>();
|
||||
TilesCreated = new Dictionary<Vector2, TileData>();
|
||||
TilesDestroyed = new Dictionary<Vector2, Tile>();
|
||||
TilesCreated = new Dictionary<Vector2, Tile>();
|
||||
Index = -1;
|
||||
FakePlayer = new Player {name = playerName, whoAmi = -1};
|
||||
Group = Group.DefaultGroup;
|
||||
|
|
@ -567,7 +567,7 @@ namespace TShockAPI
|
|||
m_y=Main.maxTilesY - size;
|
||||
}
|
||||
|
||||
SendData(PacketTypes.TileSendSquare, "", size, m_x, m_y);
|
||||
//SendData(PacketTypes.TileSendSquare, "", size, m_x, m_y);
|
||||
return true;
|
||||
}
|
||||
catch (IndexOutOfRangeException)
|
||||
|
|
@ -604,8 +604,8 @@ namespace TShockAPI
|
|||
Main.item[itemid].stack = stack;
|
||||
Main.item[itemid].owner = Index;
|
||||
Main.item[itemid].prefix = (byte) prefix;
|
||||
NetMessage.SendData((int) PacketTypes.ItemDrop, -1, -1, "", itemid, 0f, 0f, 0f);
|
||||
NetMessage.SendData((int) PacketTypes.ItemOwner, -1, -1, "", itemid, 0f, 0f, 0f);
|
||||
//NetMessage.SendData((int) PacketTypes.ItemDrop, -1, -1, "", itemid, 0f, 0f, 0f);
|
||||
//NetMessage.SendData((int) PacketTypes.ItemOwner, -1, -1, "", itemid, 0f, 0f, 0f);
|
||||
}
|
||||
|
||||
public virtual void SendInfoMessage(string msg)
|
||||
|
|
@ -671,14 +671,14 @@ namespace TShockAPI
|
|||
|
||||
public virtual void DamagePlayer(int damage)
|
||||
{
|
||||
NetMessage.SendData((int) PacketTypes.PlayerDamage, -1, -1, "", Index, ((new Random()).Next(-1, 1)), damage,
|
||||
(float) 0);
|
||||
//NetMessage.SendData((int) PacketTypes.PlayerDamage, -1, -1, "", Index, ((new Random()).Next(-1, 1)), damage,
|
||||
// (float) 0);
|
||||
}
|
||||
|
||||
public virtual void SetTeam(int team)
|
||||
{
|
||||
Main.player[Index].team = team;
|
||||
SendData(PacketTypes.PlayerTeam, "", Index);
|
||||
//SendData(PacketTypes.PlayerTeam, "", Index);
|
||||
}
|
||||
|
||||
public virtual void Disable(string reason = "")
|
||||
|
|
@ -705,7 +705,7 @@ namespace TShockAPI
|
|||
SendMessage("You are now being annoyed.", Color.Red);
|
||||
while ((DateTime.UtcNow - launch).TotalSeconds < time2 && startname == Name)
|
||||
{
|
||||
SendData(PacketTypes.NpcSpecial, number: Index, number2: 2f);
|
||||
//SendData(PacketTypes.NpcSpecial, number: Index, number2: 2f);
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
}
|
||||
|
|
@ -715,7 +715,7 @@ namespace TShockAPI
|
|||
if ((DateTime.UtcNow - LastThreat).TotalMilliseconds < 5000 && !bypass)
|
||||
return;
|
||||
|
||||
SendData(PacketTypes.PlayerAddBuff, number: Index, number2: type, number3: time);
|
||||
//SendData(PacketTypes.PlayerAddBuff, number: Index, number2: type, number3: time);
|
||||
}
|
||||
|
||||
//Todo: Separate this into a few functions. SendTo, SendToAll, etc
|
||||
|
|
@ -881,7 +881,7 @@ namespace TShockAPI
|
|||
{
|
||||
Main.dayTime = dayTime;
|
||||
Main.time = time;
|
||||
NetMessage.SendData((int) PacketTypes.TimeSet, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
|
||||
//NetMessage.SendData((int) PacketTypes.TimeSet, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
|
||||
NetMessage.syncPlayers();
|
||||
}
|
||||
|
||||
|
|
@ -907,15 +907,15 @@ namespace TShockAPI
|
|||
Main.rand = new Random();
|
||||
|
||||
Main.npc[npcid].StrikeNPC(damage, knockBack, hitDirection);
|
||||
NetMessage.SendData((int) PacketTypes.NpcStrike, -1, -1, "", npcid, damage, knockBack, hitDirection);
|
||||
//NetMessage.SendData((int) PacketTypes.NpcStrike, -1, -1, "", npcid, damage, knockBack, hitDirection);
|
||||
}
|
||||
|
||||
public void RevertTiles(Dictionary<Vector2, TileData> tiles)
|
||||
public void RevertTiles(Dictionary<Vector2, Tile> tiles)
|
||||
{
|
||||
// Update Main.Tile first so that when tile sqaure is sent it is correct
|
||||
foreach (KeyValuePair<Vector2, TileData> entry in tiles)
|
||||
foreach (KeyValuePair<Vector2, Tile> entry in tiles)
|
||||
{
|
||||
Main.tile[(int) entry.Key.X, (int) entry.Key.Y].Data = entry.Value;
|
||||
Main.tile[(int) entry.Key.X, (int) entry.Key.Y] = entry.Value;
|
||||
}
|
||||
// Send all players updated tile sqaures
|
||||
foreach (Vector2 coords in tiles.Keys)
|
||||
|
|
|
|||
|
|
@ -27,19 +27,19 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using Hooks;
|
||||
using MaxMind;
|
||||
using Mono.Data.Sqlite;
|
||||
using MySql.Data.MySqlClient;
|
||||
using Newtonsoft.Json;
|
||||
using Rests;
|
||||
using Terraria;
|
||||
using TerrariaApi.Server;
|
||||
using TShockAPI.DB;
|
||||
using TShockAPI.Net;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
[APIVersion(1, 13)]
|
||||
[ApiVersion(1, 14)]
|
||||
public class TShock : TerrariaPlugin
|
||||
{
|
||||
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
|
|
@ -231,25 +231,25 @@ namespace TShockAPI
|
|||
|
||||
Log.ConsoleInfo(string.Format("|> Version {0} ({1}) now running.", Version, VersionCodename));
|
||||
|
||||
GameHooks.PostInitialize += OnPostInit;
|
||||
GameHooks.Update += OnUpdate;
|
||||
GameHooks.HardUpdate += OnHardUpdate;
|
||||
GameHooks.StatueSpawn += OnStatueSpawn;
|
||||
ServerHooks.Connect += OnConnect;
|
||||
ServerHooks.Join += OnJoin;
|
||||
ServerHooks.Leave += OnLeave;
|
||||
ServerHooks.Chat += OnChat;
|
||||
ServerHooks.Command += ServerHooks_OnCommand;
|
||||
NetHooks.GetData += OnGetData;
|
||||
NetHooks.SendData += NetHooks_SendData;
|
||||
NetHooks.GreetPlayer += OnGreetPlayer;
|
||||
NpcHooks.StrikeNpc += NpcHooks_OnStrikeNpc;
|
||||
NpcHooks.SetDefaultsInt += OnNpcSetDefaults;
|
||||
ProjectileHooks.SetDefaults += OnProjectileSetDefaults;
|
||||
WorldHooks.StartHardMode += OnStartHardMode;
|
||||
WorldHooks.SaveWorld += SaveManager.Instance.OnSaveWorld;
|
||||
WorldHooks.ChristmasCheck += OnXmasCheck;
|
||||
NetHooks.NameCollision += NetHooks_NameCollision;
|
||||
ServerApi.Hooks.GamePostInitialize.Register(this, OnPostInit);
|
||||
ServerApi.Hooks.GameUpdate.Register(this, OnUpdate);
|
||||
ServerApi.Hooks.GameHardmodeTileUpdate.Register(this, OnHardUpdate);
|
||||
ServerApi.Hooks.GameStatueSpawn.Register(this, OnStatueSpawn);
|
||||
ServerApi.Hooks.ServerConnect.Register(this, OnConnect);
|
||||
ServerApi.Hooks.ServerJoin.Register(this, OnJoin);
|
||||
ServerApi.Hooks.ServerLeave.Register(this, OnLeave);
|
||||
ServerApi.Hooks.ServerChat.Register(this, OnChat);
|
||||
ServerApi.Hooks.ServerCommand.Register(this, ServerHooks_OnCommand);
|
||||
ServerApi.Hooks.NetGetData.Register(this, OnGetData);
|
||||
ServerApi.Hooks.NetSendData.Register(this, NetHooks_SendData);
|
||||
ServerApi.Hooks.NetGreetPlayer.Register(this, OnGreetPlayer);
|
||||
ServerApi.Hooks.NpcStrike.Register(this, NpcHooks_OnStrikeNpc);
|
||||
ServerApi.Hooks.NpcSetDefaultsInt.Register(this, OnNpcSetDefaults);
|
||||
ServerApi.Hooks.ProjectileSetDefaults.Register(this, OnProjectileSetDefaults);
|
||||
ServerApi.Hooks.WorldStartHardMode.Register(this, OnStartHardMode);
|
||||
ServerApi.Hooks.WorldSave.Register(this, SaveManager.Instance.OnSaveWorld);
|
||||
ServerApi.Hooks.WorldChristmasCheck.Register(this, OnXmasCheck);
|
||||
ServerApi.Hooks.NetNameCollision.Register(this, NetHooks_NameCollision);
|
||||
TShockAPI.Hooks.PlayerHooks.PlayerPostLogin += OnPlayerLogin;
|
||||
|
||||
GetDataHandlers.InitGetDataHandler();
|
||||
|
|
@ -260,7 +260,7 @@ namespace TShockAPI
|
|||
RestApi.Start();
|
||||
|
||||
if (Config.BufferPackets)
|
||||
PacketBuffer = new PacketBufferer();
|
||||
PacketBuffer = new PacketBufferer(this);
|
||||
|
||||
Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
|
||||
Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));
|
||||
|
|
@ -306,25 +306,26 @@ namespace TShockAPI
|
|||
}
|
||||
SaveManager.Instance.Dispose();
|
||||
|
||||
GameHooks.PostInitialize -= OnPostInit;
|
||||
GameHooks.Update -= OnUpdate;
|
||||
GameHooks.HardUpdate -= OnHardUpdate;
|
||||
GameHooks.StatueSpawn -= OnStatueSpawn;
|
||||
ServerHooks.Connect -= OnConnect;
|
||||
ServerHooks.Join -= OnJoin;
|
||||
ServerHooks.Leave -= OnLeave;
|
||||
ServerHooks.Chat -= OnChat;
|
||||
ServerHooks.Command -= ServerHooks_OnCommand;
|
||||
NetHooks.GetData -= OnGetData;
|
||||
NetHooks.SendData -= NetHooks_SendData;
|
||||
NetHooks.GreetPlayer -= OnGreetPlayer;
|
||||
NpcHooks.StrikeNpc -= NpcHooks_OnStrikeNpc;
|
||||
NpcHooks.SetDefaultsInt -= OnNpcSetDefaults;
|
||||
ProjectileHooks.SetDefaults -= OnProjectileSetDefaults;
|
||||
WorldHooks.StartHardMode -= OnStartHardMode;
|
||||
WorldHooks.SaveWorld -= SaveManager.Instance.OnSaveWorld;
|
||||
WorldHooks.ChristmasCheck -= OnXmasCheck;
|
||||
NetHooks.NameCollision -= NetHooks_NameCollision;
|
||||
|
||||
ServerApi.Hooks.GamePostInitialize.Deregister(this, OnPostInit);
|
||||
ServerApi.Hooks.GameUpdate.Deregister(this, OnUpdate);
|
||||
ServerApi.Hooks.GameHardmodeTileUpdate.Deregister(this, OnHardUpdate);
|
||||
ServerApi.Hooks.GameStatueSpawn.Deregister(this, OnStatueSpawn);
|
||||
ServerApi.Hooks.ServerConnect.Deregister(this, OnConnect);
|
||||
ServerApi.Hooks.ServerJoin.Deregister(this, OnJoin);
|
||||
ServerApi.Hooks.ServerLeave.Deregister(this, OnLeave);
|
||||
ServerApi.Hooks.ServerChat.Deregister(this, OnChat);
|
||||
ServerApi.Hooks.ServerCommand.Deregister(this, ServerHooks_OnCommand);
|
||||
ServerApi.Hooks.NetGetData.Deregister(this, OnGetData);
|
||||
ServerApi.Hooks.NetSendData.Deregister(this, NetHooks_SendData);
|
||||
ServerApi.Hooks.NetGreetPlayer.Deregister(this, OnGreetPlayer);
|
||||
ServerApi.Hooks.NpcStrike.Deregister(this, NpcHooks_OnStrikeNpc);
|
||||
ServerApi.Hooks.NpcSetDefaultsInt.Deregister(this, OnNpcSetDefaults);
|
||||
ServerApi.Hooks.ProjectileSetDefaults.Deregister(this, OnProjectileSetDefaults);
|
||||
ServerApi.Hooks.WorldStartHardMode.Deregister(this, OnStartHardMode);
|
||||
ServerApi.Hooks.WorldSave.Deregister(this, SaveManager.Instance.OnSaveWorld);
|
||||
ServerApi.Hooks.WorldChristmasCheck.Deregister(this, OnXmasCheck);
|
||||
ServerApi.Hooks.NetNameCollision.Deregister(this, NetHooks_NameCollision);
|
||||
TShockAPI.Hooks.PlayerHooks.PlayerPostLogin -= OnPlayerLogin;
|
||||
|
||||
if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
|
||||
|
|
@ -362,34 +363,34 @@ namespace TShockAPI
|
|||
Users.UpdateLogin(u);
|
||||
}
|
||||
|
||||
private void NetHooks_NameCollision(int who, string name, HandledEventArgs e)
|
||||
private void NetHooks_NameCollision(NameCollisionEventArgs args)
|
||||
{
|
||||
string ip = TShock.Utils.GetRealIP(Netplay.serverSock[who].tcpClient.Client.RemoteEndPoint.ToString());
|
||||
string ip = TShock.Utils.GetRealIP(Netplay.serverSock[args.Who].tcpClient.Client.RemoteEndPoint.ToString());
|
||||
foreach (TSPlayer ply in TShock.Players)
|
||||
{
|
||||
if (ply == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (ply.Name == name && ply.Index != who)
|
||||
if (ply.Name == args.Name && ply.Index != args.Who)
|
||||
{
|
||||
if (ply.IP == ip)
|
||||
{
|
||||
if (ply.State < 2)
|
||||
{
|
||||
Utils.ForceKick(ply, "Name collision and this client has no world data.", true, false);
|
||||
e.Handled = true;
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Handled = false;
|
||||
args.Handled = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
e.Handled = false;
|
||||
args.Handled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -533,7 +534,7 @@ namespace TShockAPI
|
|||
|
||||
public static int AuthToken = -1;
|
||||
|
||||
private void OnPostInit()
|
||||
private void OnPostInit(EventArgs args)
|
||||
{
|
||||
SetConsoleTitle();
|
||||
if (!File.Exists(Path.Combine(SavePath, "auth.lck")) && !File.Exists(Path.Combine(SavePath, "authcode.txt")))
|
||||
|
|
@ -597,7 +598,7 @@ namespace TShockAPI
|
|||
private DateTime LastCheck = DateTime.UtcNow;
|
||||
private DateTime LastSave = DateTime.UtcNow;
|
||||
|
||||
private void OnUpdate()
|
||||
private void OnUpdate(EventArgs args)
|
||||
{
|
||||
UpdateManager.UpdateProcedureCheck();
|
||||
if (Backups.IsBackupTime)
|
||||
|
|
@ -737,7 +738,7 @@ namespace TShockAPI
|
|||
Config.MaxSlots, Netplay.serverListenIP, Netplay.serverPort, Version);
|
||||
}
|
||||
|
||||
private void OnHardUpdate( HardUpdateEventArgs args )
|
||||
private void OnHardUpdate(HardmodeTileUpdateEventArgs args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
|
@ -767,14 +768,14 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
private void OnConnect(int ply, HandledEventArgs handler)
|
||||
private void OnConnect(ConnectEventArgs args)
|
||||
{
|
||||
var player = new TSPlayer(ply);
|
||||
var player = new TSPlayer(args.Who);
|
||||
|
||||
if (Utils.ActivePlayers() + 1 > Config.MaxSlots + Config.ReservedSlots)
|
||||
{
|
||||
Utils.ForceKick(player, Config.ServerFullNoReservedReason, true, false);
|
||||
handler.Handled = true;
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -790,7 +791,7 @@ namespace TShockAPI
|
|||
DateTime exp;
|
||||
string duration = DateTime.TryParse(ban.Expiration, out exp) ? String.Format("until {0}", exp.ToString("G")) : "forever";
|
||||
Utils.ForceKick(player, string.Format("You are banned {0}: {1}", duration, ban.Reason), true, false);
|
||||
handler.Handled = true;
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -798,7 +799,7 @@ namespace TShockAPI
|
|||
if (!FileTools.OnWhitelist(player.IP))
|
||||
{
|
||||
Utils.ForceKick(player, Config.WhitelistKickReason, true, false);
|
||||
handler.Handled = true;
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -811,20 +812,20 @@ namespace TShockAPI
|
|||
if (Config.KickProxyUsers)
|
||||
{
|
||||
Utils.ForceKick(player, "Proxies are not allowed.", true, false);
|
||||
handler.Handled = true;
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Players[ply] = player;
|
||||
Players[args.Who] = player;
|
||||
}
|
||||
|
||||
private void OnJoin(int ply, HandledEventArgs handler)
|
||||
private void OnJoin(JoinEventArgs args)
|
||||
{
|
||||
var player = Players[ply];
|
||||
var player = Players[args.Who];
|
||||
if (player == null)
|
||||
{
|
||||
handler.Handled = true;
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -848,16 +849,16 @@ namespace TShockAPI
|
|||
DateTime exp;
|
||||
string duration = DateTime.TryParse(ban.Expiration, out exp) ? String.Format("until {0}", exp.ToString("G")) : "forever";
|
||||
Utils.ForceKick(player, string.Format("You are banned {0}: {1}", duration, ban.Reason), true, false);
|
||||
handler.Handled = true;
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLeave(int ply)
|
||||
private void OnLeave(LeaveEventArgs args)
|
||||
{
|
||||
|
||||
var tsplr = Players[ply];
|
||||
Players[ply] = null;
|
||||
var tsplr = Players[args.Who];
|
||||
Players[args.Who] = null;
|
||||
|
||||
if (tsplr != null && tsplr.ReceivedInfo)
|
||||
{
|
||||
|
|
@ -880,15 +881,15 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
private void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
|
||||
private void OnChat(ServerChatEventArgs args)
|
||||
{
|
||||
if (e.Handled)
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
var tsplr = Players[msg.whoAmI];
|
||||
var tsplr = Players[args.Who];
|
||||
if (tsplr == null)
|
||||
{
|
||||
e.Handled = true;
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -898,11 +899,11 @@ namespace TShockAPI
|
|||
return;
|
||||
}*/
|
||||
|
||||
if (text.StartsWith("/"))
|
||||
if (args.Text.StartsWith("/"))
|
||||
{
|
||||
try
|
||||
{
|
||||
e.Handled = Commands.HandleCommand(tsplr, text);
|
||||
args.Handled = Commands.HandleCommand(tsplr, args.Text);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -913,18 +914,18 @@ namespace TShockAPI
|
|||
else if (!tsplr.mute && !TShock.Config.EnableChatAboveHeads)
|
||||
{
|
||||
Utils.Broadcast(
|
||||
String.Format(Config.ChatFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix, text),
|
||||
String.Format(Config.ChatFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix, args.Text),
|
||||
tsplr.Group.R, tsplr.Group.G, tsplr.Group.B);
|
||||
e.Handled = true;
|
||||
args.Handled = true;
|
||||
} else if (!tsplr.mute && TShock.Config.EnableChatAboveHeads)
|
||||
{
|
||||
Utils.Broadcast(ply, String.Format(Config.ChatAboveHeadsFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix, text), tsplr.Group.R, tsplr.Group.G, tsplr.Group.B);
|
||||
e.Handled = true;
|
||||
Utils.Broadcast(args.Who, String.Format(Config.ChatAboveHeadsFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix, args.Text), tsplr.Group.R, tsplr.Group.G, tsplr.Group.B);
|
||||
args.Handled = true;
|
||||
}
|
||||
else if (tsplr.mute)
|
||||
{
|
||||
tsplr.SendErrorMessage("You are muted!");
|
||||
e.Handled = true;
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -933,9 +934,9 @@ namespace TShockAPI
|
|||
/// </summary>
|
||||
/// <param name="cmd"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ServerHooks_OnCommand(string text, HandledEventArgs e)
|
||||
private void ServerHooks_OnCommand(CommandEventArgs args)
|
||||
{
|
||||
if (e.Handled)
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
// Damn you ThreadStatic and Redigit
|
||||
|
|
@ -948,7 +949,7 @@ namespace TShockAPI
|
|||
WorldGen.genRand = new Random();
|
||||
}
|
||||
|
||||
if (text.StartsWith("playing") || text.StartsWith("/playing"))
|
||||
if (args.Command.StartsWith("playing") || args.Command.StartsWith("/playing"))
|
||||
{
|
||||
int count = 0;
|
||||
foreach (TSPlayer player in Players)
|
||||
|
|
@ -962,20 +963,20 @@ namespace TShockAPI
|
|||
}
|
||||
TSPlayer.Server.SendInfoMessage(string.Format("{0} players connected.", count));
|
||||
}
|
||||
else if (text == "autosave")
|
||||
else if (args.Command == "autosave")
|
||||
{
|
||||
Main.autoSave = Config.AutoSave = !Config.AutoSave;
|
||||
Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
|
||||
}
|
||||
else if (text.StartsWith("/"))
|
||||
else if (args.Command.StartsWith("/"))
|
||||
{
|
||||
Commands.HandleCommand(TSPlayer.Server, text);
|
||||
Commands.HandleCommand(TSPlayer.Server, args.Command);
|
||||
}
|
||||
else
|
||||
{
|
||||
Commands.HandleCommand(TSPlayer.Server, "/" + text);
|
||||
Commands.HandleCommand(TSPlayer.Server, "/" + args.Command);
|
||||
}
|
||||
e.Handled = true;
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnGetData(GetDataEventArgs e)
|
||||
|
|
@ -1000,7 +1001,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (player.RequiresPassword && type != PacketTypes.PasswordSend)
|
||||
if (player.RequiresPassword/* && type != PacketTypes.PasswordSend*/)
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
|
|
@ -1027,12 +1028,12 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
private void OnGreetPlayer(int who, HandledEventArgs e)
|
||||
private void OnGreetPlayer(GreetPlayerEventArgs args)
|
||||
{
|
||||
var player = Players[who];
|
||||
var player = Players[args.Who];
|
||||
if (player == null)
|
||||
{
|
||||
e.Handled = true;
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
player.LoginMS= DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
||||
|
|
@ -1075,7 +1076,7 @@ namespace TShockAPI
|
|||
player.Teleport((int) pos.X, (int) pos.Y + 3);
|
||||
}}
|
||||
|
||||
e.Handled = true;
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void NpcHooks_OnStrikeNpc(NpcStrikeEventArgs e)
|
||||
|
|
@ -1152,7 +1153,7 @@ namespace TShockAPI
|
|||
|
||||
private void NetHooks_SendData(SendDataEventArgs e)
|
||||
{
|
||||
if (e.MsgID == PacketTypes.Disconnect)
|
||||
if (e.MsgId == PacketTypes.Disconnect)
|
||||
{
|
||||
Action<ServerSock, string> senddisconnect = (sock, str) =>
|
||||
{
|
||||
|
|
@ -1182,7 +1183,7 @@ namespace TShockAPI
|
|||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
if (e.MsgID == PacketTypes.WorldInfo)
|
||||
if (e.MsgId == PacketTypes.WorldInfo)
|
||||
{
|
||||
if (e.remoteClient == -1) return;
|
||||
var player = Players[e.remoteClient];
|
||||
|
|
|
|||
|
|
@ -79,9 +79,6 @@
|
|||
<Compile Include="Hooks\GeneralHooks.cs" />
|
||||
<Compile Include="Hooks\PlayerHooks.cs" />
|
||||
<Compile Include="PaginationTools.cs" />
|
||||
<Compile Include="PluginUpdater\PluginUpdaterThread.cs" />
|
||||
<Compile Include="PluginUpdater\PluginVersionCheck.cs" />
|
||||
<Compile Include="PluginUpdater\VersionInfo.cs" />
|
||||
<Compile Include="Rest\RestPermissions.cs" />
|
||||
<Compile Include="SaveManager.cs" />
|
||||
<Compile Include="DB\BanManager.cs" />
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ namespace TShockAPI
|
|||
/// <returns>The state of the tile</returns>
|
||||
private bool TileClear(int tileX, int tileY)
|
||||
{
|
||||
return !Main.tile[tileX, tileY].active;
|
||||
return !Main.tile[tileX, tileY].active();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue