Merge pull request #453 from TShock/general-devel

3.9.0.0526
This commit is contained in:
Zack 2012-05-25 23:04:02 -07:00
commit b76018b070
70 changed files with 431 additions and 320 deletions

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,7 +1,7 @@
extensions: .cs
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

336
TShockAPI/Commands.cs Executable file → Normal file
View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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
@ -135,7 +135,6 @@ namespace TShockAPI
add(Permissions.maintenance, CheckUpdates, "checkupdates");
add(Permissions.causeevents, DropMeteor, "dropmeteor");
add(Permissions.causeevents, Star, "star");
add(Permissions.causeevents, Ore, "genore");
add(Permissions.causeevents, Fullmoon, "fullmoon");
add(Permissions.causeevents, Bloodmoon, "bloodmoon");
add(Permissions.causeevents, Invade, "invade");
@ -182,7 +181,7 @@ namespace TShockAPI
add(Permissions.manageregion, Region, "region");
add(Permissions.manageregion, DebugRegions, "debugreg");
add(null, Help, "help");
add(null, Playing, "playing", "online", "who", "version");
add(null, ListConnectedPlayers, "playing", "online", "who", "version");
add(null, AuthToken, "auth");
add(Permissions.cantalkinthird, ThirdPerson, "me");
add(Permissions.canpartychat, PartyChat, "p");
@ -193,7 +192,7 @@ namespace TShockAPI
ChatCommands.Add(new Command(Permissions.canchangepassword, PasswordUser, "password") {DoLog = false});
ChatCommands.Add(new Command(Permissions.canregister, RegisterUser, "register") {DoLog = false});
ChatCommands.Add(new Command(Permissions.rootonly, ManageUsers, "user") {DoLog = false});
add(Permissions.rootonly, GrabUserUserInfo, "userinfo", "ui");
add(Permissions.userinfo, GrabUserUserInfo, "userinfo", "ui");
add(Permissions.rootonly, AuthVerify, "auth-verify");
ChatCommands.Add(new Command(Permissions.canlogin, AttemptLogin, "login") {DoLog = false});
add(Permissions.cfg, Broadcast, "broadcast", "bc", "say");
@ -216,6 +215,8 @@ namespace TShockAPI
add(Permissions.converthardmode, ConvertCorruption, "convertcorruption");
add(Permissions.converthardmode, ConvertHallow, "converthallow");
add(Permissions.converthardmode, RemoveSpecial, "removespecial");
add(Permissions.savessi, SaveSSI, "savessi");
add(Permissions.savessi, OverrideSSI, "overridessi", "ossi");
}
public static bool HandleCommand(TSPlayer player, string text)
@ -877,7 +878,7 @@ namespace TShockAPI
var ban = TShock.Bans.GetBanByName(plStr);
if (ban != null)
{
if (TShock.Bans.RemoveBan(ban.IP, true))
if (TShock.Bans.RemoveBan(ban.Name, true))
args.Player.SendMessage(string.Format("Unbanned {0} ({1})!", ban.Name, ban.IP), Color.Red);
else
args.Player.SendMessage(string.Format("Failed to unban {0} ({1})!", ban.Name, ban.IP), Color.Red);
@ -976,6 +977,48 @@ namespace TShockAPI
args.Player.SendMessage("You now " + (args.Player.DisplayLogs ? "receive" : "stopped receiving") + " logs");
}
public static void SaveSSI(CommandArgs args )
{
if (TShock.Config.ServerSideInventory)
{
args.Player.SendMessage("SSI has been saved.", Color.Green);
foreach (TSPlayer player in TShock.Players)
{
if (player != null && player.IsLoggedIn && !player.IgnoreActionsForClearingTrashCan)
{
TShock.InventoryDB.InsertPlayerData(player);
}
}
}
}
public static void OverrideSSI( CommandArgs args )
{
if( args.Parameters.Count < 1 )
{
args.Player.SendMessage("Correct usage: /overridessi(/ossi) <player name>", Color.Red);
return;
}
var players = TShock.Utils.FindPlayer(args.Parameters[0]);
if( players.Count < 1 )
{
args.Player.SendMessage("No players match " + args.Parameters[0], Color.Red);
}
else if( players.Count > 1 )
{
args.Player.SendMessage( players.Count + " players matched " + args.Parameters[0], Color.Red);
}
else if (TShock.Config.ServerSideInventory)
{
if( players[0] != null && players[0].IsLoggedIn && !players[0].IgnoreActionsForClearingTrashCan)
{
args.Player.SendMessage( players[0].Name + " has been exempted and updated.", Color.Green);
TShock.InventoryDB.InsertPlayerData(players[0]);
}
}
}
#endregion Player Management Commands
#region Server Maintenence Commands
@ -1002,12 +1045,13 @@ namespace TShockAPI
{
if (player != null && player.IsLoggedIn && !player.IgnoreActionsForClearingTrashCan)
{
TShock.InventoryDB.InsertPlayerData(player);
player.SaveServerInventory();
}
}
}
TShock.Utils.StopServer();
string reason = ((args.Parameters.Count > 0) ? "Server shutting down: " + String.Join(" ", args.Parameters) : "Server shutting down!");
TShock.Utils.StopServer(true, reason);
}
//Added restart command
private static void Restart(CommandArgs args)
@ -1029,7 +1073,8 @@ namespace TShockAPI
}
}
TShock.Utils.StopServer();
string reason = ((args.Parameters.Count > 0) ? "Server shutting down: " + String.Join(" ", args.Parameters) : "Server shutting down!");
TShock.Utils.StopServer(true, reason);
System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
Environment.Exit(0);
}
@ -1037,7 +1082,8 @@ namespace TShockAPI
private static void OffNoSave(CommandArgs args)
{
TShock.Utils.StopServer(false);
string reason = ((args.Parameters.Count > 0) ? "Server shutting down: " + String.Join(" ", args.Parameters) : "Server shutting down!");
TShock.Utils.StopServer(false, reason);
}
private static void CheckUpdates(CommandArgs args)
@ -1071,181 +1117,6 @@ namespace TShockAPI
Projectile.NewProjectile(vector.X, vector.Y, speedX, speedY, 12, 0x3e8, 10f, Main.myPlayer);
}
private static void Ore(CommandArgs args)
{
if (WorldGen.genRand == null)
WorldGen.genRand = new Random();
TSPlayer ply = args.Player;
int num = WorldGen.altarCount % 3;
int num2 = WorldGen.altarCount / 3 + 1;
float num3 = (float)(Main.maxTilesX / 4200);
int num4 = 1 - num;
num3 = num3 * 310f - (float)(85 * num);
num3 *= 0.85f;
num3 /= (float)num2;
if (args.Parameters.Count < 1)
{
ply.SendMessage("Picking a random ore!", Color.Green); //should this be a help message instead?
num = WorldGen.genRand.Next(6);
}
else if (args.Parameters[0] == "cobalt")
{
num = 0;
}
else if (args.Parameters[0] == "mythril")
{
num = 1;
}
else if (args.Parameters[0] == "copper")
{
num = 3;
}
else if (args.Parameters[0] == "iron")
{
num = 4;
}
else if (args.Parameters[0] == "silver")
{
num = 6;
}
else if (args.Parameters[0] == "gold")
{
num = 5;
}
else if (args.Parameters[0] == "demonite")
{
num = 7;
}
else if (args.Parameters[0] == "sapphire")
{
num = 8;
}
else if (args.Parameters[0] == "ruby")
{
num = 9;
}
else if (args.Parameters[0] == "emerald")
{
num = 10;
}
else if (args.Parameters[0] == "topaz")
{
num = 11;
}
else if (args.Parameters[0] == "amethyst")
{
num = 12;
}
else if (args.Parameters[0] == "diamond")
{
num = 13;
}
else
{
num = 2;
}
if (num == 0)
{
num = 107;
num3 *= 1.05f;
}
else if (num == 1)
{
num = 108;
}
else if (num == 3)
{
num = 7;
num3 *= 1.1f;
}
else if (num == 4)
{
num = 6;
num3 *= 1.1f;
}
else if (num == 5)
{
num = 8;
num3 *= 1.1f;
}
else if (num == 6)
{
num = 9;
num3 *= 1.1f;
}
else if (num == 7)
{
num = 22;
num3 *= 1;
}
else if (num == 8)
{
num = 63;
num3 *= .80f;
}
else if (num == 9)
{
num = 64;
num3 *=1;
}
else if (num == 10)
{
num = 65;
num3 *= 1;
}
else if (num == 11)
{
num = 66;
num3 *= 1;
}
else if (num == 12)
{
num = 67;
num3 *= 1;
}
else if (num == 13)
{
num = 68;
num3 *= 1;
}
else
{
num = 111;
}
if (args.Parameters.Count > 1)
{
float.TryParse(args.Parameters[1], out num3);
num3 = Math.Min(num3, 1000f);
}
int num5 = 0;
while ((float)num5 < num3)
{
int i2 = WorldGen.genRand.Next(100, Main.maxTilesX - 100);
double num6 = Main.worldSurface;
if ((num == 108) || (num == 6) || (num == 7) || (num == 8) || (num == 9) ||((num > 62) && (num < 69)))
{
num6 = Main.rockLayer;
}
if ((num == 111) || (num == 22) || (num == 68))
{
num6 = (Main.rockLayer + Main.rockLayer + (double)Main.maxTilesY) / 3.0;
}
int j2 = WorldGen.genRand.Next((int)num6, Main.maxTilesY - 150);
WorldGen.OreRunner(i2, j2, (double)WorldGen.genRand.Next(5, 9 + num4), WorldGen.genRand.Next(5, 9 + num4), num);
num5++;
}
ply.SendMessage(String.Format("Spawned {0} tiles of {1}", Math.Floor(num3), num), Color.Green );
}
private static void Fullmoon(CommandArgs args)
{
TSPlayer.Server.SetFullMoon(true);
@ -1984,16 +1855,42 @@ namespace TShockAPI
String groupname = args.Parameters[0];
args.Parameters.RemoveAt(0);
string response = "";
if (com.Equals("add"))
{
String response = TShock.Groups.AddPermissions(groupname, args.Parameters);
if( groupname == "*" )
{
int count = 0;
foreach( Group g in TShock.Groups )
{
response = TShock.Groups.AddPermissions(g.Name, args.Parameters);
if (!response.StartsWith("Error:"))
count++;
}
args.Player.SendMessage(String.Format("{0} groups were modified.", count ), Color.Green );
return;
}
response = TShock.Groups.AddPermissions(groupname, args.Parameters);
if (response.Length > 0)
args.Player.SendMessage(response, Color.Green);
return;
}
else if (com.Equals("del") || com.Equals("delete"))
{
String response = TShock.Groups.DeletePermissions(groupname, args.Parameters);
if (com.Equals("del") || com.Equals("delete"))
{
if (groupname == "*")
{
int count = 0;
foreach (Group g in TShock.Groups)
{
response = TShock.Groups.DeletePermissions(g.Name, args.Parameters);
if (!response.StartsWith("Error:"))
count++;
}
args.Player.SendMessage(String.Format("{0} groups were modified.", count), Color.Green);
return;
}
response = TShock.Groups.DeletePermissions(groupname, args.Parameters);
if (response.Length > 0)
args.Player.SendMessage(response, Color.Green);
return;
@ -2285,6 +2182,10 @@ namespace TShockAPI
private static void Save(CommandArgs args)
{
SaveManager.Instance.SaveWorld(false);
foreach (TSPlayer tsply in TShock.Players)
{
tsply.SaveServerInventory();
}
}
private static void Settle(CommandArgs args)
@ -2813,6 +2714,26 @@ namespace TShockAPI
break;
}
case "z":
{
if (args.Parameters.Count == 3)
{
string regionName = args.Parameters[1];
int z = 0;
if (int.TryParse(args.Parameters[2], out z ) )
{
if (TShock.Regions.SetZ(regionName, z))
args.Player.SendMessage("Region's z is now " + z, Color.Yellow);
else
args.Player.SendMessage("Could not find specified region", Color.Red);
}
else
args.Player.SendMessage("Invalid syntax! Proper syntax: /region z [name] [#]", Color.Red);
}
else
args.Player.SendMessage("Invalid syntax! Proper syntax: /region z [name] [#]", Color.Red);
break;
}
case "resize":
case "expand":
{
@ -2930,7 +2851,7 @@ namespace TShockAPI
}
}
private static void Playing(CommandArgs args)
private static void ListConnectedPlayers(CommandArgs args)
{
string response = args.Player.Group.HasPermission(Permissions.seeids)
? TShock.Utils.GetPlayersWithIds()
@ -3190,20 +3111,20 @@ namespace TShockAPI
private static void Butcher(CommandArgs args)
{
if (args.Parameters.Count > 1)
if (args.Parameters.Count > 2)
{
args.Player.SendMessage("Invalid syntax! Proper syntax: /butcher [killFriendly(true/false)]", Color.Red);
args.Player.SendMessage("Invalid syntax! Proper syntax: /butcher [killTownNPCs(true/false)]", Color.Red);
return;
}
bool killFriendly = true;
if (args.Parameters.Count == 1)
bool.TryParse(args.Parameters[0], out killFriendly);
bool killTownNPCs = false;
if (args.Parameters.Count == 2)
bool.TryParse(args.Parameters[1], out killTownNPCs);
int killcount = 0;
for (int i = 0; i < Main.npc.Length; i++)
{
if (Main.npc[i].active && Main.npc[i].type != 0 && !Main.npc[i].townNPC && (!Main.npc[i].friendly || killFriendly))
if (Main.npc[i].active && Main.npc[i].type != 0 && (!Main.npc[i].townNPC || killTownNPCs))
{
TSPlayer.Server.StrikeNPC(i, 99999, 90f, 1);
killcount++;
@ -3211,7 +3132,7 @@ namespace TShockAPI
}
TShock.Utils.Broadcast(string.Format("Killed {0} NPCs.", killcount));
}
private static void Item(CommandArgs args)
{
if (args.Parameters.Count < 1)
@ -3254,8 +3175,14 @@ namespace TShockAPI
{
if (itemAmount == 0 || itemAmount > item.maxStack)
itemAmount = item.maxStack;
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));
if (args.Player.GiveItemCheck(item.type, item.name, item.width, item.height, itemAmount, prefix))
{
args.Player.SendMessage(string.Format("Gave {0} {1}(s).", itemAmount, item.name));
}
else
{
args.Player.SendMessage("The item is banned and the config prevents you from spawning banned items.", Color.Red);
}
}
else
{
@ -3332,9 +3259,16 @@ namespace TShockAPI
{
if (itemAmount == 0 || itemAmount > item.maxStack)
itemAmount = item.maxStack;
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));
plr.SendMessage(string.Format("{0} gave you {1} {2}(s).", args.Player.Name, itemAmount, item.name));
if (plr.GiveItemCheck(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));
plr.SendMessage(string.Format("{0} gave you {1} {2}(s).", args.Player.Name, itemAmount, item.name));
}
else
{
args.Player.SendMessage("The item is banned and the config prevents spawning banned items.", Color.Red);
}
}
else
{

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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
@ -118,6 +118,8 @@ namespace TShockAPI
[Description("String that is used when kicking people when the server is full.")] public string ServerFullReason =
"Server is full";
[Description("String that is used when a user is kicked due to not being on the whitelist.")] public string WhitelistKickReason = "You are not on the whitelist.";
[Description("String that is used when kicking people when the server is full with no reserved slots.")] public string
ServerFullNoReservedReason = "Server is full. No reserved slots open.";
@ -214,7 +216,21 @@ namespace TShockAPI
[Description("Allow Ice placement even when user does not have canbuild")] public bool AllowIce = false;
public static ConfigFile Read(string path)
[Description("Allows corrutption to spread when a world is hardmode.")] public bool AllowCorruptionCreep = true;
[Description("Allows hallow to spread when a world is hardmode.")] public bool AllowHallowCreep = true;
[Description("How many things a statue can spawn within 200 pixels(?) before it stops spawning. Default = 3")] public int StatueSpawn200 = 3;
[Description("How many things a statue can spawn within 600 pixels(?) before it stops spawning. Default = 6")] public int StatueSpawn600 = 6;
[Description("How many things a statue spawns can exist in the world before it stops spawning. Default = 10")] public int StatueSpawnWorld = 10;
[Description("Prevent banned items from being /i or /give")] public bool PreventBannedItemSpawn = false;
[Description("Prevent banks on SSI")] public bool DisablePiggybanksOnSSI = false;
public static ConfigFile Read(string path)
{
if (!File.Exists(path))
return new ConfigFile();

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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
@ -46,7 +46,8 @@ namespace TShockAPI.DB
new SqlColumn("UserIds", MySqlDbType.Text),
new SqlColumn("Protected", MySqlDbType.Int32),
new SqlColumn("Groups", MySqlDbType.Text),
new SqlColumn("Owner", MySqlDbType.VarChar, 50)
new SqlColumn("Owner", MySqlDbType.VarChar, 50),
new SqlColumn("Z", MySqlDbType.Int32){ DefaultValue = "0" }
);
var creator = new SqlTableCreator(db,
db.GetSqlType() == SqlType.Sqlite
@ -75,10 +76,11 @@ namespace TShockAPI.DB
string name = reader.Get<string>("RegionName");
string owner = reader.Get<string>("Owner");
string groups = reader.Get<string>("Groups");
int z = reader.Get<int>("Z");
string[] splitids = mergedids.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries);
Region r = new Region(new Rectangle(X1, Y1, width, height), name, owner, Protected != 0, Main.worldID.ToString());
Region r = new Region(new Rectangle(X1, Y1, width, height), name, owner, Protected != 0, Main.worldID.ToString(), z);
r.SetAllowedGroups(groups);
try
{
@ -127,8 +129,9 @@ namespace TShockAPI.DB
string[] SplitIDs = MergedIDs.Split(',');
string owner = reader.Get<string>("Owner");
string groups = reader.Get<string>("Groups");
int z = reader.Get<int>("Z");
Region r = new Region(new Rectangle(X1, Y1, width, height), name, owner, Protected != 0, Main.worldID.ToString());
Region r = new Region(new Rectangle(X1, Y1, width, height), name, owner, Protected != 0, Main.worldID.ToString(), z);
r.SetAllowedGroups(groups);
try
{
@ -156,7 +159,7 @@ namespace TShockAPI.DB
}
}
public bool AddRegion(int tx, int ty, int width, int height, string regionname, string owner, string worldid)
public bool AddRegion(int tx, int ty, int width, int height, string regionname, string owner, string worldid, int z = 0)
{
if (GetRegionByName(regionname) != null)
{
@ -165,9 +168,9 @@ namespace TShockAPI.DB
try
{
database.Query(
"INSERT INTO Regions (X1, Y1, width, height, RegionName, WorldID, UserIds, Protected, Groups, Owner) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9);",
tx, ty, width, height, regionname, worldid, "", 1, "", owner);
Regions.Add(new Region(new Rectangle(tx, ty, width, height), regionname, owner, true, worldid));
"INSERT INTO Regions (X1, Y1, width, height, RegionName, WorldID, UserIds, Protected, Groups, Owner, Z) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10);",
tx, ty, width, height, regionname, worldid, "", 1, "", owner, z);
Regions.Add(new Region(new Rectangle(tx, ty, width, height), regionname, owner, true, worldid, z));
return true;
}
catch (Exception ex)
@ -234,14 +237,21 @@ namespace TShockAPI.DB
{
return false;
}
Region top = null;
for (int i = 0; i < Regions.Count; i++)
{
if (Regions[i].InArea(x,y) && !Regions[i].HasPermissionToBuildInRegion(ply))
if (Regions[i].InArea(x,y) )
{
return false;
if (top == null)
top = Regions[i];
else
{
if (Regions[i].Z > top.Z)
top = Regions[i];
}
}
}
return true;
return top == null || top.HasPermissionToBuildInRegion(ply);
}
public bool InArea(int x, int y)
@ -490,6 +500,41 @@ namespace TShockAPI.DB
}
return false;
}
public Region GetTopRegion( List<Region> regions )
{
Region ret = null;
foreach( Region r in regions)
{
if (ret == null)
ret = r;
else
{
if (r.Z > ret.Z)
ret = r;
}
}
return ret;
}
public bool SetZ( string name, int z )
{
try
{
database.Query("UPDATE Regions SET Z=@0 WHERE RegionName=@1 AND WorldID=@2", z, name,
Main.worldID.ToString());
var region = GetRegionByName(name);
if (region != null)
region.Z = z;
return true;
}
catch (Exception ex)
{
Log.Error(ex.ToString());
return false;
}
}
}
public class Region
@ -501,8 +546,9 @@ namespace TShockAPI.DB
public string WorldID { get; set; }
public List<int> AllowedIDs { get; set; }
public List<string> AllowedGroups { get; set; }
public int Z { get; set; }
public Region(Rectangle region, string name, string owner, bool disablebuild, string RegionWorldIDz)
public Region(Rectangle region, string name, string owner, bool disablebuild, string RegionWorldIDz, int z)
: this()
{
Area = region;
@ -510,6 +556,7 @@ namespace TShockAPI.DB
Owner = owner;
DisableBuild = disablebuild;
WorldID = RegionWorldIDz;
Z = z;
}
public Region()
@ -520,6 +567,7 @@ namespace TShockAPI.DB
WorldID = string.Empty;
AllowedIDs = new List<int>();
AllowedGroups = new List<string>();
Z = 0;
}
public bool InArea(Rectangle point)

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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
@ -52,7 +52,14 @@ namespace TShockAPI.DB
{
if (reader.Read())
{
return new Vector2(reader.Get<int>("X"), reader.Get<int>("Y"));
int checkX=reader.Get<int>("X");
int checkY=reader.Get<int>("Y");
//fix leftover inconsistancies
if (checkX==0)
checkX++;
if (checkY==0)
checkY++;
return new Vector2(checkX, checkY);
}
}
}
@ -92,6 +99,7 @@ namespace TShockAPI.DB
{
try
{
if ((X != 0) && ( Y !=0)) //invalid pos!
database.Query("INSERT INTO RememberedPos (Name, IP, X, Y, WorldID) VALUES (@0, @1, @2, @3, @4);", name, IP, X, Y , Main.worldID.ToString());
}
catch (Exception ex)
@ -103,6 +111,7 @@ namespace TShockAPI.DB
{
try
{
if ((X != 0) && ( Y !=0)) //invalid pos!
database.Query("UPDATE RememberedPos SET X = @0, Y = @1, IP = @2 WHERE Name = @3 AND WorldID = @4;", X, Y, IP, name, Main.worldID.ToString());
}
catch (Exception ex)

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -19,7 +19,7 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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
@ -472,11 +472,19 @@ namespace TShockAPI
{
num4 = Main.maxTilesY;
}
for (int c = num; c < num2; c++)
{
for (int d = num3; d< num4; d++)
{
if (Main.tile[c,d].liquid != 0)
return false;
}
}
for (int i = num; i < num2; i++)
{
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].liquid == 0 )&& !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);
@ -1214,7 +1222,7 @@ namespace TShockAPI
if (max > 400 && max > args.Player.FirstMaxHP)
{
TShock.Utils.ForceKick(args.Player, "Hacked Client Detected.");
TShock.Utils.ForceKick(args.Player, "Hacked Client Detected.", true);
return false;
}
@ -1240,7 +1248,7 @@ namespace TShockAPI
if (max > 400 && max > args.Player.FirstMaxMP)
{
TShock.Utils.ForceKick(args.Player, "Hacked Client Detected.");
TShock.Utils.ForceKick(args.Player, "Hacked Client Detected.", true);
return false;
}
@ -1258,7 +1266,7 @@ namespace TShockAPI
if (OnPlayerInfo(playerid, hair, male, difficulty, name))
{
TShock.Utils.ForceKick(args.Player, "A plugin cancelled the event.");
TShock.Utils.ForceKick(args.Player, "A plugin cancelled the event.", true);
return true;
}
@ -1269,13 +1277,13 @@ namespace TShockAPI
}*/
if (name.Trim().Length == 0)
{
TShock.Utils.ForceKick(args.Player, "Empty Name.");
TShock.Utils.ForceKick(args.Player, "Empty Name.", true);
return true;
}
var ban = TShock.Bans.GetBanByName(name);
if (ban != null)
{
TShock.Utils.ForceKick(args.Player, string.Format("You are banned: {0}", ban.Reason));
TShock.Utils.ForceKick(args.Player, string.Format("You are banned: {0}", ban.Reason), true);
return true;
}
if (args.Player.ReceivedInfo)
@ -1284,12 +1292,12 @@ namespace TShockAPI
}
if (TShock.Config.MediumcoreOnly && difficulty < 1)
{
TShock.Utils.ForceKick(args.Player, "Server is set to mediumcore and above characters only!");
TShock.Utils.ForceKick(args.Player, "Server is set to mediumcore and above characters only!", true);
return true;
}
if (TShock.Config.HardcoreOnly && difficulty < 2)
{
TShock.Utils.ForceKick(args.Player, "Server is set to hardcore characters only!");
TShock.Utils.ForceKick(args.Player, "Server is set to hardcore characters only!", true);
return true;
}
args.Player.Difficulty = difficulty;
@ -1328,7 +1336,7 @@ namespace TShockAPI
string password = Encoding.UTF8.GetString(args.Data.ReadBytes((int) (args.Data.Length - args.Data.Position - 1)));
var user = TShock.Users.GetUserByName(args.Player.Name);
if (user != null)
if (user != null && !TShock.Config.DisableLoginBeforeJoin)
{
string encrPass = TShock.Utils.HashPassword(password);
if (user.Password.ToUpper() == encrPass.ToUpper())
@ -1390,11 +1398,11 @@ namespace TShockAPI
NetMessage.SendData((int) PacketTypes.WorldInfo, args.Player.Index);
return true;
}
TShock.Utils.ForceKick(args.Player, "Incorrect Server Password");
TShock.Utils.ForceKick(args.Player, "Incorrect Server Password", true);
return true;
}
TShock.Utils.ForceKick(args.Player, "Bad Password Attempt");
TShock.Utils.ForceKick(args.Player, "Bad Password Attempt", true);
return true;
}
@ -1406,7 +1414,7 @@ namespace TShockAPI
args.Player.RequestedSection = true;
if (TShock.HackedHealth(args.Player) && !args.Player.Group.HasPermission(Permissions.ignorestathackdetection))
{
TShock.Utils.ForceKick(args.Player, "You have Hacked Health/Mana, Please use a different character.");
TShock.Utils.ForceKick(args.Player, "You have Hacked Health/Mana, Please use a different character.", true);
}
if (!args.Player.Group.HasPermission(Permissions.ignorestackhackdetection))
@ -1417,8 +1425,7 @@ namespace TShockAPI
if (TShock.Utils.ActivePlayers() + 1 > TShock.Config.MaxSlots &&
!args.Player.Group.HasPermission(Permissions.reservedslot))
{
args.Player.SilentKickInProgress = true;
TShock.Utils.ForceKick(args.Player, TShock.Config.ServerFullReason);
TShock.Utils.ForceKick(args.Player, TShock.Config.ServerFullReason, true);
return true;
}
@ -1675,29 +1682,29 @@ namespace TShockAPI
{
return true;
}
if (tiletype == 29 && tiletype == 97 && TShock.Config.ServerSideInventory)
if ((tiletype == 29 || tiletype == 97) && TShock.Config.ServerSideInventory && TShock.Config.DisablePiggybanksOnSSI)
{
args.Player.SendMessage("You cannot place this tile, Server side inventory is enabled.", Color.Red);
args.Player.SendMessage("You cannot place this tile, server side inventory is enabled.", Color.Red);
args.Player.SendTileSquare(tileX, tileY);
return true;
}
if (tiletype == 48 && !args.Player.Group.HasPermission(Permissions.usebanneditem) &&
TShock.Itembans.ItemIsBanned("Spike", args.Player))
{
args.Player.Disable("Using banned spikes without permissions");
args.Player.Disable("Used banned spikes without permission.");
args.Player.SendTileSquare(tileX, tileY);
return true;
}
if (type == 1 && tiletype == 21 && TShock.Utils.MaxChests())
{
args.Player.SendMessage("Reached world's max chest limit, unable to place more!", Color.Red);
args.Player.SendMessage("Reached the world's max chest limit, unable to place more.", Color.Red);
args.Player.SendTileSquare(tileX, tileY);
return true;
}
if (tiletype == 141 && !args.Player.Group.HasPermission(Permissions.usebanneditem) &&
TShock.Itembans.ItemIsBanned("Explosives", args.Player))
{
args.Player.Disable("Using banned explosives tile without permissions");
args.Player.Disable("Used banned explosives tile without permission.");
args.Player.SendTileSquare(tileX, tileY);
return true;
}
@ -1728,14 +1735,14 @@ namespace TShockAPI
if (args.Player.TileKillThreshold >= TShock.Config.TileKillThreshold)
{
args.Player.Disable("Reached TileKill threshold");
args.Player.Disable("Reached TileKill threshold.");
args.Player.SendTileSquare(tileX, tileY);
return true;
}
if (args.Player.TilePlaceThreshold >= TShock.Config.TilePlaceThreshold)
{
args.Player.Disable("Reached TilePlace threshold");
args.Player.Disable("Reached TilePlace threshold.");
args.Player.SendTileSquare(tileX, tileY);
return true;
}
@ -2259,7 +2266,7 @@ namespace TShockAPI
if (TShock.Config.BanOnMediumcoreDeath)
{
if (!TShock.Utils.Ban(args.Player, TShock.Config.MediumcoreBanReason))
TShock.Utils.ForceKick(args.Player, "Death results in a ban, but can't ban you");
TShock.Utils.ForceKick(args.Player, "Death results in a ban, but can't ban you.", true);
}
else
{

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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
@ -28,6 +28,8 @@ namespace TShockAPI
{
//Permissions with blank descriptions basically means its described by the commands it gives access to.
[Description("Allows player to get user info")] public static readonly string userinfo;
[Description("")] public static readonly string causeevents;
[Description("Required to be able to build (modify tiles and liquid)")] public static readonly string canbuild;
@ -161,12 +163,21 @@ namespace TShockAPI
[Description("User can see the id of players with /who")]
public static readonly string seeids;
[Description("User can save all the players SSI state.")]
public static readonly string savessi;
[Description("User can use rest api calls.")]
public static readonly string restapi;
static Permissions()
{
foreach (var field in typeof (Permissions).GetFields())
{
field.SetValue(null, field.Name);
}
//Backwards compatability.
restapi = "api";
}
private static List<Command> GetCommands(string perm)

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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
@ -48,5 +48,5 @@ using System.Runtime.InteropServices;
// Build Number
// MMdd of the build
[assembly: AssemblyVersion("3.8.0.0304")]
[assembly: AssemblyFileVersion("3.8.0.0304")]
[assembly: AssemblyVersion("3.9.0.0526")]
[assembly: AssemblyFileVersion("3.9.0.0526")]

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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
@ -119,6 +119,29 @@ namespace TShockAPI
}
}
/// <summary>
/// Saves the player's inventory to SSI
/// </summary>
/// <returns>bool - True/false if it saved successfully</returns>
public bool SaveServerInventory()
{
if (!TShock.Config.ServerSideInventory)
{
return false;
}
try
{
PlayerData.CopyInventory(this);
TShock.InventoryDB.InsertPlayerData(this);
return true;
} catch (Exception e)
{
Log.Error(e.Message);
return false;
}
}
/// <summary>
/// Terraria Player
/// </summary>
@ -359,9 +382,19 @@ namespace TShockAPI
return false;
}
public bool GiveItemCheck(int type, string name, int width, int height, int stack, int prefix = 0)
{
if (TShock.Itembans.ItemIsBanned(name) && TShock.Config.PreventBannedItemSpawn)
return false;
GiveItem(type,name,width,height,stack,prefix);
return true;
}
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, prefix);
// This is for special pickaxe/hammers/swords etc
Main.item[itemid].SetDefaults(name);
// The set default overrides the wet and stack set by NewItem

45
TShockAPI/TShock.cs Executable file → Normal file
View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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
@ -37,14 +37,14 @@ using TShockAPI.Net;
namespace TShockAPI
{
[APIVersion(1, 11)]
[APIVersion(1, 12)]
public class TShock : TerrariaPlugin
{
private const string LogFormatDefault = "yyyyMMddHHmmss";
private static string LogFormat = LogFormatDefault;
private static bool LogClear = false;
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
public static readonly string VersionCodename = "Squashing bugs, and adding suggestions";
public static readonly string VersionCodename = "Zack time: 1 week = 3 months";
public static string SavePath = "tshock";
@ -77,6 +77,7 @@ namespace TShockAPI
/// </summary>
public static event Action Initialized;
public static List<int> TakenPlayerIDs = new List<int>();
public override Version Version
{
@ -203,6 +204,8 @@ namespace TShockAPI
GameHooks.PostInitialize += OnPostInit;
GameHooks.Update += OnUpdate;
GameHooks.HardUpdate += OnHardUpdate;
GameHooks.StatueSpawn += OnStatueSpawn;
ServerHooks.Connect += OnConnect;
ServerHooks.Join += OnJoin;
ServerHooks.Leave += OnLeave;
@ -256,7 +259,7 @@ namespace TShockAPI
{Error = "Invalid username/password combination provided. Please re-submit your query with a correct pair."};
}
if (!Utils.GetGroup(userAccount.Group).HasPermission("api") && userAccount.Group != "superadmin")
if (!Utils.GetGroup(userAccount.Group).HasPermission(Permissions.restapi) && userAccount.Group != "superadmin")
{
return new RestObject("403")
{
@ -281,6 +284,8 @@ namespace TShockAPI
GameHooks.PostInitialize -= OnPostInit;
GameHooks.Update -= OnUpdate;
GameHooks.HardUpdate -= OnHardUpdate;
GameHooks.StatueSpawn -= OnStatueSpawn;
ServerHooks.Connect -= OnConnect;
ServerHooks.Join -= OnJoin;
ServerHooks.Leave -= OnLeave;
@ -623,6 +628,36 @@ namespace TShockAPI
Config.MaxSlots, Netplay.serverListenIP, Config.ServerPort, Version);
}
private void OnHardUpdate( HardUpdateEventArgs args )
{
if (args.Handled)
return;
if (!Config.AllowCorruptionCreep && ( args.Type == 23 || args.Type == 25 || args.Type == 0 ||
args.Type == 112 || args.Type == 23 || args.Type == 32 ) )
{
args.Handled = true;
return;
}
if (!Config.AllowHallowCreep && (args.Type == 109 || args.Type == 117 || args.Type == 116 ) )
{
args.Handled = true;
}
}
private void OnStatueSpawn( StatueSpawnEventArgs args )
{
if( args.Within200 < Config.StatueSpawn200 && args.Within600 < Config.StatueSpawn600 && args.WorldWide < Config.StatueSpawnWorld )
{
args.Handled = true;
}
else
{
args.Handled = false;
}
}
private void OnConnect(int ply, HandledEventArgs handler)
{
var player = new TSPlayer(ply);
@ -656,7 +691,7 @@ namespace TShockAPI
if (!FileTools.OnWhitelist(player.IP))
{
Utils.ForceKick(player, "Not on whitelist.");
Utils.ForceKick(player, Config.WhitelistKickReason);
handler.Handled = true;
return;
}

View file

@ -1,7 +1,7 @@
extensions: .cs
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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
@ -86,7 +86,7 @@ namespace TShockAPI
sb.Append(", ");
}
sb.Append(player.Name);
string id = "( " + Convert.ToString(TShock.Users.GetUserID(player.UserAccountName)) + " )";
string id = "(ID: " + Convert.ToString(TShock.Users.GetUserID(player.UserAccountName)) + ", IX:" + player.Index + ")";
sb.Append(id);
}
}
@ -187,7 +187,7 @@ namespace TShockAPI
}
/// <summary>
/// Finds a player ID based on name
/// Finds a TSPlayer based on name or id
/// </summary>
/// <param name="ply">Player name</param>
/// <returns></returns>
@ -203,6 +203,18 @@ namespace TShockAPI
if (player == null)
continue;
try
{
if (Convert.ToInt32(ply) == player.Index && player.Active)
{
return new List<TSPlayer> { player };
}
}
catch (Exception e)
{
// Conversion failed
}
string name = player.Name.ToLower();
if (name.Equals(ply))
return new List<TSPlayer> {player};
@ -543,9 +555,9 @@ namespace TShockAPI
/// <param name="ply">int player</param>
/// <param name="reason">string reason</param>
/// <param name="silent">bool silent (default: false)</param>
public void ForceKick(TSPlayer player, string reason, bool silent = false)
public void ForceKick(TSPlayer player, string reason, bool silent = false, bool saveSSI = false)
{
Kick(player, reason, true, silent);
Kick(player, reason, true, silent, null, saveSSI);
}
#if COMPAT_SIGS
@ -556,14 +568,15 @@ namespace TShockAPI
}
#endif
/// <summary>
/// Kicks a player from the server.
/// Kicks a player from the server..
/// </summary>
/// <param name="ply">int player</param>
/// <param name="reason">string reason</param>
/// <param name="force">bool force (default: false)</param>
/// <param name="silent">bool silent (default: false)</param>
/// <param name="adminUserName">bool silent (default: null)</param>
public bool Kick(TSPlayer player, string reason, bool force = false, bool silent = false, string adminUserName = null)
/// <param name="adminUserName">string adminUserName (default: null)</param>
/// <param name="saveSSI">bool saveSSI (default: false)</param>
public bool Kick(TSPlayer player, string reason, bool force = false, bool silent = false, string adminUserName = null, bool saveSSI = false)
{
if (!player.ConnectionAlive)
return true;
@ -571,13 +584,18 @@ namespace TShockAPI
{
string playerName = player.Name;
player.SilentKickInProgress = silent;
if (player.IsLoggedIn && saveSSI)
player.SaveServerInventory();
player.Disconnect(string.Format("Kicked: {0}", reason));
Log.ConsoleInfo(string.Format("Kicked {0} for : {1}", playerName, reason));
string verb = force ? "force " : "";
if (string.IsNullOrWhiteSpace(adminUserName))
Broadcast(string.Format("{0} was {1}kicked for {2}", playerName, verb, reason.ToLower()));
else
Broadcast(string.Format("{0} {1}kicked {2} for {3}", adminUserName, verb, playerName, reason.ToLower()));
if (!silent)
{
if (string.IsNullOrWhiteSpace(adminUserName))
Broadcast(string.Format("{0} was {1}kicked for {2}", playerName, verb, reason.ToLower()));
else
Broadcast(string.Format("{0} {1}kicked {2} for {3}", adminUserName, verb, playerName, reason.ToLower()));
}
return true;
}
return false;

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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

View file

@ -1,6 +1,6 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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
@ -54,12 +54,12 @@ namespace UnitTests
[TestMethod]
public void AddRegion()
{
Region r = new Region( new Rectangle(100,100,100,100), "test", "test", true, "test");
Region r = new Region( new Rectangle(100,100,100,100), "test", "test", true, "test", 0);
Assert.IsTrue(manager.AddRegion(r.Area.X, r.Area.Y, r.Area.Width, r.Area.Height, r.Name, r.Owner, r.WorldID));
Assert.AreEqual(1, manager.Regions.Count);
Assert.IsNotNull(manager.ZacksGetRegionByName("test"));
Region r2 = new Region(new Rectangle(201, 201, 100, 100), "test2", "test2", true, "test");
Region r2 = new Region(new Rectangle(201, 201, 100, 100), "test2", "test2", true, "test", 0);
manager.AddRegion(r2.Area.X, r2.Area.Y, r2.Area.Width, r2.Area.Height, r2.Name, r2.Owner, r2.WorldID);
Assert.AreEqual(2, manager.Regions.Count);
Assert.IsNotNull(manager.ZacksGetRegionByName("test2"));

View file

@ -1,7 +1,7 @@
extensions: .cs
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
Copyright (C) 2011-2012 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