Merge branch 'general-devel-mono' of github.com:TShock/TShock into general-devel
This commit is contained in:
commit
55b706db8d
19 changed files with 276 additions and 66 deletions
|
|
@ -7,7 +7,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using Community.CsharpSqlite.SQLiteClient;
|
using Mono.Data.Sqlite;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
<MapFileExtensions>true</MapFileExtensions>
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
<ApplicationRevision>0</ApplicationRevision>
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
@ -49,8 +50,8 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Community.CsharpSqlite.SQLiteClient">
|
<Reference Include="Mono.Data.Sqlite">
|
||||||
<HintPath>..\SqlBins\Community.CsharpSqlite.SQLiteClient.dll</HintPath>
|
<HintPath>..\SqlBins\Mono.Data.Sqlite.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
<Reference Include="MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
|
|
||||||
BIN
SqlBins/Mono.Data.Sqlite.dll
Normal file
BIN
SqlBins/Mono.Data.Sqlite.dll
Normal file
Binary file not shown.
BIN
SqlBins/sqlite3.dll
Normal file
BIN
SqlBins/sqlite3.dll
Normal file
Binary file not shown.
|
|
@ -198,6 +198,8 @@ namespace TShockAPI
|
||||||
add(Permissions.hardmode, StartHardMode, "hardmode");
|
add(Permissions.hardmode, StartHardMode, "hardmode");
|
||||||
add(Permissions.hardmode, DisableHardMode, "stophardmode", "disablehardmode");
|
add(Permissions.hardmode, DisableHardMode, "stophardmode", "disablehardmode");
|
||||||
add(Permissions.cfg, ServerInfo, "stats");
|
add(Permissions.cfg, ServerInfo, "stats");
|
||||||
|
add(Permissions.converthardmode, ConvertCorruption, "convertcorruption");
|
||||||
|
add(Permissions.converthardmode, ConvertHallow, "converthallow");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool HandleCommand(TSPlayer player, string text)
|
public static bool HandleCommand(TSPlayer player, string text)
|
||||||
|
|
@ -1223,6 +1225,58 @@ namespace TShockAPI
|
||||||
Main.hardMode = false;
|
Main.hardMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ConvertCorruption(CommandArgs args)
|
||||||
|
{
|
||||||
|
TShock.Utils.Broadcast("Server is might lag for a moment.", Color.Red);
|
||||||
|
for (int x = 0; x < Main.maxTilesX; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < Main.maxTilesY; y++)
|
||||||
|
{
|
||||||
|
switch (Main.tile[x, y].type)
|
||||||
|
{
|
||||||
|
case 25:
|
||||||
|
Main.tile[x, y].type = 117;
|
||||||
|
break;
|
||||||
|
case 23:
|
||||||
|
Main.tile[x, y].type = 109;
|
||||||
|
break;
|
||||||
|
case 112:
|
||||||
|
Main.tile[x, y].type = 116;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TShock.Utils.Broadcast("Corruption conversion done.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConvertHallow(CommandArgs args)
|
||||||
|
{
|
||||||
|
TShock.Utils.Broadcast("Server is might lag for a moment.", Color.Red);
|
||||||
|
for (int x = 0; x < Main.maxTilesX; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < Main.maxTilesY; y++)
|
||||||
|
{
|
||||||
|
switch (Main.tile[x, y].type)
|
||||||
|
{
|
||||||
|
case 117:
|
||||||
|
Main.tile[x, y].type = 25;
|
||||||
|
break;
|
||||||
|
case 109:
|
||||||
|
Main.tile[x, y].type = 23;
|
||||||
|
break;
|
||||||
|
case 116:
|
||||||
|
Main.tile[x, y].type = 112;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TShock.Utils.Broadcast("Hallow conversion done.");
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Cause Events and Spawn Monsters Commands
|
#endregion Cause Events and Spawn Monsters Commands
|
||||||
|
|
||||||
#region Teleport Commands
|
#region Teleport Commands
|
||||||
|
|
@ -1271,7 +1325,7 @@ namespace TShockAPI
|
||||||
args.Player.SendMessage("Invalid player!", Color.Red);
|
args.Player.SendMessage("Invalid player!", Color.Red);
|
||||||
else if (players.Count > 1)
|
else if (players.Count > 1)
|
||||||
args.Player.SendMessage("More than one player matched!", Color.Red);
|
args.Player.SendMessage("More than one player matched!", Color.Red);
|
||||||
else if (!args.Player.TPAllow && !args.Player.Group.HasPermission(Permissions.tpall))
|
else if (!players[0].TPAllow && !args.Player.Group.HasPermission(Permissions.tpall))
|
||||||
{
|
{
|
||||||
var plr = players[0];
|
var plr = players[0];
|
||||||
args.Player.SendMessage(plr.Name + " Has Selected For Users Not To Teleport To Them");
|
args.Player.SendMessage(plr.Name + " Has Selected For Users Not To Teleport To Them");
|
||||||
|
|
@ -2497,7 +2551,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (args.Parameters.Count < 1)
|
if (args.Parameters.Count < 1)
|
||||||
{
|
{
|
||||||
args.Player.SendMessage("Invalid syntax! Proper syntax: /item <item name/id> [item amount]", Color.Red);
|
args.Player.SendMessage("Invalid syntax! Proper syntax: /item <item name/id> [item amount] [prefix id/name]", Color.Red);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.Parameters[0].Length == 0)
|
if (args.Parameters[0].Length == 0)
|
||||||
|
|
@ -2506,7 +2560,16 @@ namespace TShockAPI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int itemAmount = 0;
|
int itemAmount = 0;
|
||||||
int.TryParse(args.Parameters[args.Parameters.Count - 1], out itemAmount);
|
int prefix = 0;
|
||||||
|
if (args.Parameters.Count == 2)
|
||||||
|
int.TryParse(args.Parameters[1], out itemAmount);
|
||||||
|
else if (args.Parameters.Count == 3)
|
||||||
|
{
|
||||||
|
int.TryParse(args.Parameters[1], out itemAmount);
|
||||||
|
var found = TShock.Utils.GetPrefixByIdOrName(args.Parameters[2]);
|
||||||
|
if (found.Count == 1)
|
||||||
|
prefix = found[0];
|
||||||
|
}
|
||||||
var items = TShock.Utils.GetItemByIdOrName(args.Parameters[0]);
|
var items = TShock.Utils.GetItemByIdOrName(args.Parameters[0]);
|
||||||
if (items.Count == 0)
|
if (items.Count == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -2525,7 +2588,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (itemAmount == 0 || itemAmount > item.maxStack)
|
if (itemAmount == 0 || itemAmount > item.maxStack)
|
||||||
itemAmount = item.maxStack;
|
itemAmount = item.maxStack;
|
||||||
args.Player.GiveItem(item.type, item.name, item.width, item.height, itemAmount);
|
args.Player.GiveItem(item.type, item.name, item.width, item.height, itemAmount, prefix);
|
||||||
args.Player.SendMessage(string.Format("Gave {0} {1}(s).", itemAmount, item.name));
|
args.Player.SendMessage(string.Format("Gave {0} {1}(s).", itemAmount, item.name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -2544,7 +2607,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (args.Parameters.Count < 2)
|
if (args.Parameters.Count < 2)
|
||||||
{
|
{
|
||||||
args.Player.SendMessage("Invalid syntax! Proper syntax: /give <item type/id> <player> [item amount]", Color.Red);
|
args.Player.SendMessage("Invalid syntax! Proper syntax: /give <item type/id> <player> [item amount] [prefix id/name]", Color.Red);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.Parameters[0].Length == 0)
|
if (args.Parameters[0].Length == 0)
|
||||||
|
|
@ -2558,13 +2621,20 @@ namespace TShockAPI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int itemAmount = 0;
|
int itemAmount = 0;
|
||||||
|
int prefix = 0;
|
||||||
var items = TShock.Utils.GetItemByIdOrName(args.Parameters[0]);
|
var items = TShock.Utils.GetItemByIdOrName(args.Parameters[0]);
|
||||||
args.Parameters.RemoveAt(0);
|
args.Parameters.RemoveAt(0);
|
||||||
string plStr = args.Parameters[0];
|
string plStr = args.Parameters[0];
|
||||||
args.Parameters.RemoveAt(0);
|
args.Parameters.RemoveAt(0);
|
||||||
if (args.Parameters.Count > 0)
|
if (args.Parameters.Count == 1)
|
||||||
int.TryParse(args.Parameters[args.Parameters.Count - 1], out itemAmount);
|
int.TryParse(args.Parameters[0], out itemAmount);
|
||||||
|
else if (args.Parameters.Count == 2)
|
||||||
|
{
|
||||||
|
int.TryParse(args.Parameters[0], out itemAmount);
|
||||||
|
var found = TShock.Utils.GetPrefixByIdOrName(args.Parameters[1]);
|
||||||
|
if (found.Count == 1)
|
||||||
|
prefix = found[0];
|
||||||
|
}
|
||||||
|
|
||||||
if (items.Count == 0)
|
if (items.Count == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -2595,7 +2665,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (itemAmount == 0 || itemAmount > item.maxStack)
|
if (itemAmount == 0 || itemAmount > item.maxStack)
|
||||||
itemAmount = item.maxStack;
|
itemAmount = item.maxStack;
|
||||||
plr.GiveItem(item.type, item.name, item.width, item.height, itemAmount);
|
plr.GiveItem(item.type, item.name, item.width, item.height, itemAmount, prefix);
|
||||||
args.Player.SendMessage(string.Format("Gave {0} {1} {2}(s).", plr.Name, itemAmount, item.name));
|
args.Player.SendMessage(string.Format("Gave {0} {1} {2}(s).", plr.Name, itemAmount, item.name));
|
||||||
plr.SendMessage(string.Format("{0} gave you {1} {2}(s).", args.Player.Name, itemAmount, item.name));
|
plr.SendMessage(string.Format("{0} gave you {1} {2}(s).", args.Player.Name, itemAmount, item.name));
|
||||||
}
|
}
|
||||||
|
|
@ -2618,39 +2688,29 @@ namespace TShockAPI
|
||||||
int radius = 50;
|
int radius = 50;
|
||||||
if (args.Parameters.Count > 0)
|
if (args.Parameters.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (args.Parameters[0].ToLower() == "all")
|
if (args.Parameters[0].ToLower() == "all")
|
||||||
{
|
{
|
||||||
|
|
||||||
radius = Int32.MaxValue / 16;
|
radius = Int32.MaxValue / 16;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
radius = Convert.ToInt32(args.Parameters[0]);
|
radius = Convert.ToInt32(args.Parameters[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception) { args.Player.SendMessage("Please either enter the keyword \"all\", or the block radius you wish to delete all items from.", Color.Red); return; }
|
catch (Exception) { args.Player.SendMessage("Please either enter the keyword \"all\", or the block radius you wish to delete all items from.", Color.Red); return; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < 200; i++)
|
for (int i = 0; i < 200; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((Math.Sqrt(Math.Pow(Main.item[i].position.X - args.Player.X, 2) + Math.Pow(Main.item[i].position.Y - args.Player.Y, 2)) < radius * 16) && (Main.item[i].active))
|
if ((Math.Sqrt(Math.Pow(Main.item[i].position.X - args.Player.X, 2) + Math.Pow(Main.item[i].position.Y - args.Player.Y, 2)) < radius * 16) && (Main.item[i].active))
|
||||||
{
|
{
|
||||||
|
|
||||||
Main.item[i].active = false;
|
Main.item[i].active = false;
|
||||||
NetMessage.SendData(0x15, -1, -1, "", i, 0f, 0f, 0f, 0);
|
NetMessage.SendData(0x15, -1, -1, "", i, 0f, 0f, 0f, 0);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
args.Player.SendMessage("All " + count.ToString() + " items within a radius of " + radius.ToString() + " have been deleted.");
|
args.Player.SendMessage("All " + count.ToString() + " items within a radius of " + radius.ToString() + " have been deleted.");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,18 @@ namespace TShockAPI
|
||||||
[Description("Disabling this prevents players from being banned or kicked based on item stacks.")]
|
[Description("Disabling this prevents players from being banned or kicked based on item stacks.")]
|
||||||
public bool EnableItemStackChecks = true;
|
public bool EnableItemStackChecks = true;
|
||||||
|
|
||||||
|
[Description("Kicks users using a proxy as identified with the GeoIP database")]
|
||||||
|
public bool KickProxyUsers = true;
|
||||||
|
|
||||||
|
[Description("Kicks banned users by their name")]
|
||||||
|
public bool EnableNameBans = false;
|
||||||
|
|
||||||
|
[Description("Kicks banned users by their IP")]
|
||||||
|
public bool EnableIPBans = true;
|
||||||
|
|
||||||
|
[Description("Disables hardmode, can't never be activated. Overrides /starthardmode")]
|
||||||
|
public bool DisableHardmode = false;
|
||||||
|
|
||||||
public static ConfigFile Read(string path)
|
public static ConfigFile Read(string path)
|
||||||
{
|
{
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ namespace TShockAPI
|
||||||
{PacketTypes.TileGetSection, HandleGetSection},
|
{PacketTypes.TileGetSection, HandleGetSection},
|
||||||
{PacketTypes.UpdateNPCHome, UpdateNPCHome },
|
{PacketTypes.UpdateNPCHome, UpdateNPCHome },
|
||||||
{PacketTypes.PlayerAddBuff, HandlePlayerBuff},
|
{PacketTypes.PlayerAddBuff, HandlePlayerBuff},
|
||||||
|
{PacketTypes.ItemDrop, HandleItemDrop}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,7 +157,7 @@ namespace TShockAPI
|
||||||
var itemname = it.name;
|
var itemname = it.name;
|
||||||
|
|
||||||
if (!args.Player.Group.HasPermission(Permissions.usebanneditem) && TShock.Itembans.ItemIsBanned(itemname))
|
if (!args.Player.Group.HasPermission(Permissions.usebanneditem) && TShock.Itembans.ItemIsBanned(itemname))
|
||||||
args.Player.Disconnect("Using banned item: " + itemname + ", remove it and rejoin");;
|
args.Player.Disconnect("Using banned item: " + itemname + ", remove it and rejoin");
|
||||||
if (stack>it.maxStack)
|
if (stack>it.maxStack)
|
||||||
{
|
{
|
||||||
string reason = string.Format("Item Stack Hack Detected: player has {0} {1}(s) in one stack", stack,itemname);
|
string reason = string.Format("Item Stack Hack Detected: player has {0} {1}(s) in one stack", stack,itemname);
|
||||||
|
|
@ -266,7 +267,7 @@ namespace TShockAPI
|
||||||
args.Player.LastTileChangeNotify = DateTime.UtcNow;
|
args.Player.LastTileChangeNotify = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
args.Player.SendTileSquare(x, y);
|
args.Player.SendTileSquare(x, y);
|
||||||
return true;
|
continue;
|
||||||
}
|
}
|
||||||
if (TShock.Config.DisableBuild)
|
if (TShock.Config.DisableBuild)
|
||||||
{
|
{
|
||||||
|
|
@ -278,7 +279,7 @@ namespace TShockAPI
|
||||||
args.Player.LastTileChangeNotify = DateTime.UtcNow;
|
args.Player.LastTileChangeNotify = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
args.Player.SendTileSquare(x, y);
|
args.Player.SendTileSquare(x, y);
|
||||||
return true;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TShock.Config.SpawnProtection)
|
if (TShock.Config.SpawnProtection)
|
||||||
|
|
@ -294,7 +295,7 @@ namespace TShockAPI
|
||||||
args.Player.LastTileChangeNotify = DateTime.UtcNow;
|
args.Player.LastTileChangeNotify = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
args.Player.SendTileSquare(x, y);
|
args.Player.SendTileSquare(x, y);
|
||||||
return true;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -389,6 +390,11 @@ namespace TShockAPI
|
||||||
tile.type = 112;
|
tile.type = 112;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
else if (tile.type == 112 && newtile.Type == 53)
|
||||||
|
{
|
||||||
|
tile.type = 53;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -537,7 +543,7 @@ namespace TShockAPI
|
||||||
args.Player.TileThreshold++;
|
args.Player.TileThreshold++;
|
||||||
var coords = new Vector2(x, y);
|
var coords = new Vector2(x, y);
|
||||||
if (!args.Player.TilesDestroyed.ContainsKey(coords))
|
if (!args.Player.TilesDestroyed.ContainsKey(coords))
|
||||||
args.Player.TilesDestroyed.Add(coords, Main.tile[x, y].Data);
|
args.Player.TilesDestroyed.Add(coords, Main.tile[x, y]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((DateTime.UtcNow - args.Player.LastExplosive).TotalMilliseconds < 1000)
|
if ((DateTime.UtcNow - args.Player.LastExplosive).TotalMilliseconds < 1000)
|
||||||
|
|
@ -616,12 +622,24 @@ namespace TShockAPI
|
||||||
byte owner = args.Data.ReadInt8();
|
byte owner = args.Data.ReadInt8();
|
||||||
byte type = args.Data.ReadInt8();
|
byte type = args.Data.ReadInt8();
|
||||||
|
|
||||||
if (ident > Main.maxProjectiles || ident < 0)
|
var index = TShock.Utils.SearchProjectile(ident);
|
||||||
|
|
||||||
|
if (index > Main.maxProjectiles || index < 0)
|
||||||
{
|
{
|
||||||
TShock.Utils.HandleGriefer(args.Player, TShock.Config.ExplosiveAbuseReason);
|
TShock.Utils.HandleGriefer(args.Player, TShock.Config.ExplosiveAbuseReason);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dmg > 125) // random number, if false positives, increase
|
||||||
|
{
|
||||||
|
TShock.Utils.SendLogs(string.Format("{0} sent a projectile with more than 125 damage.", args.Player.Name), Color.Red);
|
||||||
|
if (dmg > 175)
|
||||||
|
{
|
||||||
|
TShock.Utils.HandleCheater(args.Player, TShock.Config.ProjectileAbuseReason);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (type == 23)
|
if (type == 23)
|
||||||
{
|
{
|
||||||
if (velx == 0f && vely == 0f && dmg == 99)
|
if (velx == 0f && vely == 0f && dmg == 99)
|
||||||
|
|
@ -633,32 +651,34 @@ namespace TShockAPI
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (type == 29 || type == 28 || type == 37) //need more explosives from 1.1
|
if (type == 29 || type == 28 || type == 37) //need more explosives from 1.1
|
||||||
{
|
{
|
||||||
Log.Debug(string.Format("Explosive(PlyXY:{0}_{1}, Type:{2})", args.Player.TileX, args.Player.TileY, type));
|
Log.Debug(string.Format("Explosive(PlyXY:{0}_{1}, Type:{2})", args.Player.TileX, args.Player.TileY, type));
|
||||||
if (TShock.Config.DisableExplosives && (!args.Player.Group.HasPermission(Permissions.useexplosives) || !args.Player.Group.HasPermission(Permissions.ignoregriefdetection)))
|
if (TShock.Config.DisableExplosives && (!args.Player.Group.HasPermission(Permissions.useexplosives) && !args.Player.Group.HasPermission(Permissions.ignoregriefdetection)))
|
||||||
{
|
{
|
||||||
Main.projectile[ident].type = 0;
|
//Main.projectile[index].SetDefaults(0);
|
||||||
Main.projectile[ident].owner = 255;
|
Main.projectile[index].type = 0;
|
||||||
args.Player.SendData(PacketTypes.ProjectileNew, "", ident);
|
//Main.projectile[index].owner = 255;
|
||||||
|
//Main.projectile[index].position = new Vector2(0f, 0f);
|
||||||
|
Main.projectile[index].identity = ident;
|
||||||
|
args.Player.SendData(PacketTypes.ProjectileNew, "", index);
|
||||||
args.Player.SendMessage("Explosives are disabled!", Color.Red);
|
args.Player.SendMessage("Explosives are disabled!", Color.Red);
|
||||||
args.Player.LastExplosive = DateTime.UtcNow;
|
args.Player.LastExplosive = DateTime.UtcNow;
|
||||||
//return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return TShock.Utils.HandleExplosivesUser(args.Player, TShock.Config.ExplosiveAbuseReason);
|
return TShock.Utils.HandleExplosivesUser(args.Player, TShock.Config.ExplosiveAbuseReason);
|
||||||
}
|
}
|
||||||
if (args.Player.Index != owner)//ignores projectiles whose senders aren't the same as their owners
|
if (args.Player.Index != owner)//ignores projectiles whose senders aren't the same as their owners
|
||||||
{
|
{
|
||||||
TShock.Players[args.Player.Index].SendData(PacketTypes.ProjectileNew, "", ident);//update projectile on senders end so he knows it didnt get created
|
TShock.Players[args.Player.Index].SendData(PacketTypes.ProjectileNew, "", index);//update projectile on senders end so he knows it didnt get created
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Projectile proj = new Projectile();
|
Projectile proj = new Projectile();
|
||||||
proj.SetDefaults(type);
|
proj.SetDefaults(type);
|
||||||
if (proj.hostile)//ignores all hostile projectiles from the client they shouldn't be sending them anyways
|
if (proj.hostile)//ignores all hostile projectiles from the client they shouldn't be sending them anyways
|
||||||
{
|
{
|
||||||
TShock.Players[args.Player.Index].SendData(PacketTypes.ProjectileNew, "", ident);
|
TShock.Players[args.Player.Index].SendData(PacketTypes.ProjectileNew, "", index);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -717,7 +737,7 @@ namespace TShockAPI
|
||||||
int tileY = Math.Abs(y);
|
int tileY = Math.Abs(y);
|
||||||
|
|
||||||
bool bucket = false;
|
bool bucket = false;
|
||||||
for (int i = 0; i < 44; i++)
|
for (int i = 0; i < 49; i++)
|
||||||
{
|
{
|
||||||
if (args.TPlayer.inventory[i].type >= 205 && args.TPlayer.inventory[i].type <= 207)
|
if (args.TPlayer.inventory[i].type >= 205 && args.TPlayer.inventory[i].type <= 207)
|
||||||
{
|
{
|
||||||
|
|
@ -911,5 +931,29 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
return !args.Player.Group.HasPermission(Permissions.ignoregriefdetection);
|
return !args.Player.Group.HasPermission(Permissions.ignoregriefdetection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool HandleItemDrop(GetDataHandlerArgs args)
|
||||||
|
{
|
||||||
|
var id = args.Data.ReadInt16();
|
||||||
|
var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
|
||||||
|
var vel = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
|
||||||
|
var stacks = args.Data.ReadInt8();
|
||||||
|
var prefix = args.Data.ReadInt8();
|
||||||
|
var type = args.Data.ReadInt16();
|
||||||
|
|
||||||
|
var item = new Item();
|
||||||
|
item.netDefaults(type);
|
||||||
|
if (TShock.Config.EnableItemStackChecks)
|
||||||
|
{
|
||||||
|
if (stacks > item.maxStack)
|
||||||
|
{
|
||||||
|
TShock.Utils.HandleCheater(args.Player, "Dropped illegal stack of item");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (TShock.Itembans.ItemIsBanned(item.name))
|
||||||
|
TShock.Utils.HandleCheater(args.Player, "Dropped banned item");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,10 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (socket.tcpClient.Client != null && socket.tcpClient.Client.Poll(0, SelectMode.SelectWrite))
|
if (socket.tcpClient.Client != null && socket.tcpClient.Client.Poll(0, SelectMode.SelectWrite))
|
||||||
{
|
{
|
||||||
socket.tcpClient.Client.Send(buffer, offset, count, SocketFlags.None);
|
if (Main.runningMono)
|
||||||
|
socket.networkStream.Write(buffer, offset, count);
|
||||||
|
else
|
||||||
|
socket.tcpClient.Client.Send(buffer, offset, count, SocketFlags.None);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -179,6 +182,9 @@ namespace TShockAPI
|
||||||
catch (SocketException)
|
catch (SocketException)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
catch (IOException)
|
||||||
|
{
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,9 @@ namespace TShockAPI
|
||||||
[Description("Users can tp to anyone")]
|
[Description("Users can tp to anyone")]
|
||||||
public static readonly string tpall;
|
public static readonly string tpall;
|
||||||
|
|
||||||
|
[Description("User can convert hallow into corruption and vice-versa")]
|
||||||
|
public static readonly string converthardmode;
|
||||||
|
|
||||||
static Permissions()
|
static Permissions()
|
||||||
{
|
{
|
||||||
foreach (var field in typeof(Permissions).GetFields())
|
foreach (var field in typeof(Permissions).GetFields())
|
||||||
|
|
|
||||||
|
|
@ -36,5 +36,5 @@ using System.Runtime.InteropServices;
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
|
|
||||||
[assembly: AssemblyVersion("3.3.4.1213")]
|
[assembly: AssemblyVersion("3.3.4.1218")]
|
||||||
[assembly: AssemblyFileVersion("3.3.4.1213")]
|
[assembly: AssemblyFileVersion("3.3.4.1218")]
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ namespace TShockAPI
|
||||||
public static readonly TSServerPlayer Server = new TSServerPlayer();
|
public static readonly TSServerPlayer Server = new TSServerPlayer();
|
||||||
public static readonly TSPlayer All = new TSPlayer("All");
|
public static readonly TSPlayer All = new TSPlayer("All");
|
||||||
public int TileThreshold { get; set; }
|
public int TileThreshold { get; set; }
|
||||||
public Dictionary<Vector2, TileData> TilesDestroyed { get; protected set; }
|
public Dictionary<Vector2, Tile> TilesDestroyed { get; protected set; }
|
||||||
public bool SyncHP { get; set; }
|
public bool SyncHP { get; set; }
|
||||||
public bool SyncMP { get; set; }
|
public bool SyncMP { get; set; }
|
||||||
public Group Group { get; set; }
|
public Group Group { get; set; }
|
||||||
|
|
@ -62,6 +62,7 @@ namespace TShockAPI
|
||||||
public bool ForceSpawn = false;
|
public bool ForceSpawn = false;
|
||||||
public string Country = "??";
|
public string Country = "??";
|
||||||
public int Difficulty;
|
public int Difficulty;
|
||||||
|
private string CacheIP;
|
||||||
|
|
||||||
public bool RealPlayer
|
public bool RealPlayer
|
||||||
{
|
{
|
||||||
|
|
@ -75,7 +76,10 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return RealPlayer ? TShock.Utils.GetRealIP(Netplay.serverSock[Index].tcpClient.Client.RemoteEndPoint.ToString()) : "";
|
if (string.IsNullOrEmpty(CacheIP))
|
||||||
|
return CacheIP = RealPlayer ? (Netplay.serverSock[Index].tcpClient.Connected ? TShock.Utils.GetRealIP(Netplay.serverSock[Index].tcpClient.Client.RemoteEndPoint.ToString()) : "") : "";
|
||||||
|
else
|
||||||
|
return CacheIP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -145,14 +149,14 @@ namespace TShockAPI
|
||||||
|
|
||||||
public TSPlayer(int index)
|
public TSPlayer(int index)
|
||||||
{
|
{
|
||||||
TilesDestroyed = new Dictionary<Vector2, TileData>();
|
TilesDestroyed = new Dictionary<Vector2, Tile>();
|
||||||
Index = index;
|
Index = index;
|
||||||
Group = new Group("null");
|
Group = new Group("null");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TSPlayer(String playerName)
|
protected TSPlayer(String playerName)
|
||||||
{
|
{
|
||||||
TilesDestroyed = new Dictionary<Vector2, TileData>();
|
TilesDestroyed = new Dictionary<Vector2, Tile>();
|
||||||
Index = -1;
|
Index = -1;
|
||||||
FakePlayer = new Player { name = playerName, whoAmi = -1 };
|
FakePlayer = new Player { name = playerName, whoAmi = -1 };
|
||||||
Group = new Group("null");
|
Group = new Group("null");
|
||||||
|
|
@ -268,15 +272,16 @@ namespace TShockAPI
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void GiveItem(int type, string name, int width, int height, int stack)
|
public virtual void GiveItem(int type, string name, int width, int height, int stack, int prefix = 0)
|
||||||
{
|
{
|
||||||
int itemid = Item.NewItem((int)X, (int)Y, width, height, type, stack, true);
|
int itemid = Item.NewItem((int)X, (int)Y, width, height, type, stack, true, prefix);
|
||||||
// This is for special pickaxe/hammers/swords etc
|
// This is for special pickaxe/hammers/swords etc
|
||||||
Main.item[itemid].SetDefaults(name);
|
Main.item[itemid].SetDefaults(name);
|
||||||
// The set default overrides the wet and stack set by NewItem
|
// 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].wet = Collision.WetCollision(Main.item[itemid].position, Main.item[itemid].width, Main.item[itemid].height);
|
||||||
Main.item[itemid].stack = stack;
|
Main.item[itemid].stack = stack;
|
||||||
Main.item[itemid].owner = Index;
|
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.ItemDrop, -1, -1, "", itemid, 0f, 0f, 0f);
|
||||||
NetMessage.SendData((int)PacketTypes.ItemOwner, -1, -1, "", itemid, 0f, 0f, 0f);
|
NetMessage.SendData((int)PacketTypes.ItemOwner, -1, -1, "", itemid, 0f, 0f, 0f);
|
||||||
}
|
}
|
||||||
|
|
@ -418,12 +423,12 @@ namespace TShockAPI
|
||||||
NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", npcid, damage, knockBack, hitDirection);
|
NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", npcid, damage, knockBack, hitDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RevertKillTile(Dictionary<Vector2, TileData> destroyedTiles)
|
public void RevertKillTile(Dictionary<Vector2, Tile> destroyedTiles)
|
||||||
{
|
{
|
||||||
// Update Main.Tile first so that when tile sqaure is sent it is correct
|
// Update Main.Tile first so that when tile sqaure is sent it is correct
|
||||||
foreach (KeyValuePair<Vector2, TileData> entry in destroyedTiles)
|
foreach (KeyValuePair<Vector2, Tile> entry in destroyedTiles)
|
||||||
{
|
{
|
||||||
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;
|
||||||
Log.Debug(string.Format("Reverted DestroyedTile(TileXY:{0}_{1}, Type:{2})",
|
Log.Debug(string.Format("Reverted DestroyedTile(TileXY:{0}_{1}, Type:{2})",
|
||||||
entry.Key.X, entry.Key.Y, Main.tile[(int)entry.Key.X, (int)entry.Key.Y].type));
|
entry.Key.X, entry.Key.Y, Main.tile[(int)entry.Key.X, (int)entry.Key.Y].type));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ using TShockAPI.Net;
|
||||||
|
|
||||||
namespace TShockAPI
|
namespace TShockAPI
|
||||||
{
|
{
|
||||||
[APIVersion(1, 9)]
|
[APIVersion(1, 10)]
|
||||||
public class TShock : TerrariaPlugin
|
public class TShock : TerrariaPlugin
|
||||||
{
|
{
|
||||||
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
|
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
|
|
@ -109,6 +109,8 @@ namespace TShockAPI
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
|
HandleCommandLine(Environment.GetCommandLineArgs());
|
||||||
|
|
||||||
if (!Directory.Exists(SavePath))
|
if (!Directory.Exists(SavePath))
|
||||||
Directory.CreateDirectory(SavePath);
|
Directory.CreateDirectory(SavePath);
|
||||||
|
|
||||||
|
|
@ -121,7 +123,6 @@ namespace TShockAPI
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
|
if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
|
||||||
{
|
{
|
||||||
Log.ConsoleInfo("TShock was improperly shut down. Please avoid this in the future, world corruption may result from this.");
|
Log.ConsoleInfo("TShock was improperly shut down. Please avoid this in the future, world corruption may result from this.");
|
||||||
|
|
@ -132,7 +133,7 @@ namespace TShockAPI
|
||||||
ConfigFile.ConfigRead += OnConfigRead;
|
ConfigFile.ConfigRead += OnConfigRead;
|
||||||
FileTools.SetupConfig();
|
FileTools.SetupConfig();
|
||||||
|
|
||||||
HandleCommandLine(Environment.GetCommandLineArgs());
|
HandleCommandLine_Port(Environment.GetCommandLineArgs());
|
||||||
|
|
||||||
if (Config.StorageType.ToLower() == "sqlite")
|
if (Config.StorageType.ToLower() == "sqlite")
|
||||||
{
|
{
|
||||||
|
|
@ -199,6 +200,7 @@ namespace TShockAPI
|
||||||
NetHooks.GreetPlayer += OnGreetPlayer;
|
NetHooks.GreetPlayer += OnGreetPlayer;
|
||||||
NpcHooks.StrikeNpc += NpcHooks_OnStrikeNpc;
|
NpcHooks.StrikeNpc += NpcHooks_OnStrikeNpc;
|
||||||
ProjectileHooks.SetDefaults += OnProjectileSetDefaults;
|
ProjectileHooks.SetDefaults += OnProjectileSetDefaults;
|
||||||
|
WorldHooks.StartHardMode += OnStartHardMode;
|
||||||
|
|
||||||
GetDataHandlers.InitGetDataHandler();
|
GetDataHandlers.InitGetDataHandler();
|
||||||
Commands.InitCommands();
|
Commands.InitCommands();
|
||||||
|
|
@ -384,6 +386,13 @@ namespace TShockAPI
|
||||||
Log.ConsoleInfo("World path has been set to " + path);
|
Log.ConsoleInfo("World path has been set to " + path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleCommandLine_Port(string[] parms)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < parms.Length; i++)
|
||||||
|
{
|
||||||
if (parms[i].ToLower() == "-port")
|
if (parms[i].ToLower() == "-port")
|
||||||
{
|
{
|
||||||
int port = Convert.ToInt32(parms[++i]);
|
int port = Convert.ToInt32(parms[++i]);
|
||||||
|
|
@ -508,7 +517,14 @@ namespace TShockAPI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ban = Bans.GetBanByIp(player.IP);
|
var ipban = Bans.GetBanByIp(player.IP);
|
||||||
|
var nameban = Bans.GetBanByName(player.Name);
|
||||||
|
Ban ban = null;
|
||||||
|
if (ipban != null && Config.EnableIPBans)
|
||||||
|
ban = ipban;
|
||||||
|
else if (nameban != null && Config.EnableIPBans)
|
||||||
|
ban = nameban;
|
||||||
|
|
||||||
if (ban != null)
|
if (ban != null)
|
||||||
{
|
{
|
||||||
TShock.Utils.ForceKick(player, string.Format("You are banned: {0}", ban.Reason));
|
TShock.Utils.ForceKick(player, string.Format("You are banned: {0}", ban.Reason));
|
||||||
|
|
@ -718,6 +734,9 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
var code = Geo.TryGetCountryCode(IPAddress.Parse(player.IP));
|
var code = Geo.TryGetCountryCode(IPAddress.Parse(player.IP));
|
||||||
player.Country = code == null ? "N/A" : MaxMind.GeoIPCountry.GetCountryNameByCode(code);
|
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));
|
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 + " is from the " + player.Country, Color.Yellow);
|
TShock.Utils.Broadcast(player.Name + " is from the " + player.Country, Color.Yellow);
|
||||||
}
|
}
|
||||||
|
|
@ -850,6 +869,12 @@ namespace TShockAPI
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnStartHardMode(HandledEventArgs e)
|
||||||
|
{
|
||||||
|
if (Config.DisableHardmode)
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Useful stuff:
|
* Useful stuff:
|
||||||
* */
|
* */
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
//Method #2 - allows impartial matching
|
//Method #2 - allows impartial matching
|
||||||
var found = new List<Item>();
|
var found = new List<Item>();
|
||||||
for (int i = 1; i < Main.maxItemTypes; i++)
|
for (int i = -24; i < Main.maxItemTypes; i++)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -284,7 +284,7 @@ namespace TShockAPI
|
||||||
public List<NPC> GetNPCByName(string name)
|
public List<NPC> GetNPCByName(string name)
|
||||||
{
|
{
|
||||||
//Method #1 - must be exact match, allows support for different coloured slimes
|
//Method #1 - must be exact match, allows support for different coloured slimes
|
||||||
for (int i = 1; i < Main.maxNPCTypes; i++)
|
for (int i = -17; i < Main.maxNPCTypes; i++)
|
||||||
{
|
{
|
||||||
NPC npc = new NPC();
|
NPC npc = new NPC();
|
||||||
npc.SetDefaults(name);
|
npc.SetDefaults(name);
|
||||||
|
|
@ -309,10 +309,12 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
return (id > 0 && id < Main.maxBuffs) ? Main.buffName[id] : "null";
|
return (id > 0 && id < Main.maxBuffs) ? Main.buffName[id] : "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetBuffDescription(int id)
|
public string GetBuffDescription(int id)
|
||||||
{
|
{
|
||||||
return (id > 0 && id < Main.maxBuffs) ? Main.buffTip[id] : "null";
|
return (id > 0 && id < Main.maxBuffs) ? Main.buffTip[id] : "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<int> GetBuffByName(string name)
|
public List<int> GetBuffByName(string name)
|
||||||
{
|
{
|
||||||
for (int i = 1; i < Main.maxBuffs; i++)
|
for (int i = 1; i < Main.maxBuffs; i++)
|
||||||
|
|
@ -329,6 +331,51 @@ namespace TShockAPI
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetPrefixById(int id)
|
||||||
|
{
|
||||||
|
var item = new Item();
|
||||||
|
item.SetDefaults(0);
|
||||||
|
item.prefix = (byte)id;
|
||||||
|
item.AffixName();
|
||||||
|
return item.name.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<int> GetPrefixByName(string name)
|
||||||
|
{
|
||||||
|
Item item = new Item();
|
||||||
|
item.SetDefaults(0);
|
||||||
|
for (int i = 1; i < 83; i++)
|
||||||
|
{
|
||||||
|
item.prefix = (byte) i;
|
||||||
|
if (item.AffixName().Trim() == name)
|
||||||
|
return new List<int> { i };
|
||||||
|
}
|
||||||
|
var found = new List<int>();
|
||||||
|
for (int i = 1; i < 83; i++)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
item.prefix = (byte) i;
|
||||||
|
if (item.AffixName().Trim().ToLower() == name.ToLower())
|
||||||
|
return new List<int> { i };
|
||||||
|
if (item.AffixName().Trim().ToLower().StartsWith(name.ToLower()))
|
||||||
|
found.Add(i);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<int> GetPrefixByIdOrName(string idOrName)
|
||||||
|
{
|
||||||
|
int type = -1;
|
||||||
|
if (int.TryParse(idOrName, out type) && type > 0 && type < 84)
|
||||||
|
{
|
||||||
|
return new List<int> {type};
|
||||||
|
}
|
||||||
|
return GetPrefixByName(idOrName);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Kicks all player from the server without checking for immunetokick permission.
|
/// Kicks all player from the server without checking for immunetokick permission.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -590,5 +637,15 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int SearchProjectile(short identity)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||||
|
{
|
||||||
|
if (Main.projectile[i].identity == identity)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -3,7 +3,7 @@ using System.Data;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Community.CsharpSqlite.SQLiteClient;
|
using Mono.Data.Sqlite;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using TShockAPI;
|
using TShockAPI;
|
||||||
using TShockAPI.DB;
|
using TShockAPI.DB;
|
||||||
|
|
@ -43,7 +43,7 @@ namespace UnitTests
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void FindBanTest()
|
public void FindBanTest()
|
||||||
{
|
{
|
||||||
Assert.IsNotNull(Bans.GetBanByIp("127.0.0.1"));
|
D:\SVNs\TShock_GitHub\UnitTests\BanManagerTest.orderedtest Assert.IsNotNull(Bans.GetBanByIp("127.0.0.1"));
|
||||||
TShock.Config.EnableBanOnUsernames = true;
|
TShock.Config.EnableBanOnUsernames = true;
|
||||||
Assert.IsNotNull(Bans.GetBanByName("BanTest"));
|
Assert.IsNotNull(Bans.GetBanByName("BanTest"));
|
||||||
TShock.Config.EnableBanOnUsernames = false;
|
TShock.Config.EnableBanOnUsernames = false;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ using System.Data;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Community.CsharpSqlite.SQLiteClient;
|
using Mono.Data.Sqlite;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using TShockAPI;
|
using TShockAPI;
|
||||||
using TShockAPI.DB;
|
using TShockAPI.DB;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ using System.Diagnostics;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Community.CsharpSqlite.SQLiteClient;
|
using Mono.Data.Sqlite;
|
||||||
using TShockAPI.DB;
|
using TShockAPI.DB;
|
||||||
using TShockAPI;
|
using TShockAPI;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using TShockAPI;
|
using TShockAPI;
|
||||||
using Community.CsharpSqlite.SQLiteClient;
|
using Mono.Data.Sqlite;
|
||||||
using TShockAPI.DB;
|
using TShockAPI.DB;
|
||||||
using Region = TShockAPI.DB.Region;
|
using Region = TShockAPI.DB.Region;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,13 +48,10 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Community.CsharpSqlite">
|
|
||||||
<HintPath>..\SqlBins\Community.CsharpSqlite.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Community.CsharpSqlite.SQLiteClient">
|
|
||||||
<HintPath>..\SqlBins\Community.CsharpSqlite.SQLiteClient.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||||
|
<Reference Include="Mono.Data.Sqlite">
|
||||||
|
<HintPath>..\SqlBins\Mono.Data.Sqlite.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="MySql.Data">
|
<Reference Include="MySql.Data">
|
||||||
<HintPath>..\SqlBins\MySql.Data.dll</HintPath>
|
<HintPath>..\SqlBins\MySql.Data.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue