Changed the TSPlayer class.
This commit is contained in:
parent
17b2ed7eea
commit
c3bf304c0c
5 changed files with 53 additions and 58 deletions
|
|
@ -71,16 +71,16 @@ namespace TShockAPI
|
|||
|
||||
public bool Run(string msg, TSPlayer ply, List<string> parms)
|
||||
{
|
||||
if (!ply.group.HasPermission(permission))
|
||||
if (!ply.Group.HasPermission(permission))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CommandArgs args = new CommandArgs();
|
||||
args.Message = msg;
|
||||
args.PlayerX = (int)ply.GetPlayer().position.X;
|
||||
args.PlayerY = (int)ply.GetPlayer().position.Y;
|
||||
args.PlayerID = ply.GetPlayerID();
|
||||
args.PlayerX = (int)ply.Player.position.X;
|
||||
args.PlayerY = (int)ply.Player.position.Y;
|
||||
args.PlayerID = ply.Index;
|
||||
args.Parameters = parms;
|
||||
|
||||
command(args);
|
||||
|
|
@ -94,7 +94,7 @@ namespace TShockAPI
|
|||
|
||||
public bool CanRun(TSPlayer ply)
|
||||
{
|
||||
if (!ply.group.HasPermission(permission))
|
||||
if (!ply.Group.HasPermission(permission))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,27 +22,22 @@ namespace TShockAPI
|
|||
{
|
||||
public class TSPlayer
|
||||
{
|
||||
public uint tileThreshold;
|
||||
public Dictionary<TShock.Position, Tile> tilesDestroyed = new Dictionary<TShock.Position, Tile>();
|
||||
public bool syncHP;
|
||||
public bool syncMP;
|
||||
public Group group;
|
||||
public bool receivedInfo;
|
||||
private int player;
|
||||
public uint TileThreshold { get; set; }
|
||||
public Dictionary<TShock.Position, Tile> TilesDestroyed { get; set; }
|
||||
public bool SyncHP { get; set; }
|
||||
public bool SyncMP { get; set; }
|
||||
public Group Group { get; set; }
|
||||
public bool ReceivedInfo { get; set; }
|
||||
|
||||
public int Index {get;private set;}
|
||||
public Player Player
|
||||
{
|
||||
get { return Main.player[Index]; }
|
||||
}
|
||||
|
||||
public TSPlayer(int ply)
|
||||
{
|
||||
player = ply;
|
||||
}
|
||||
|
||||
public Player GetPlayer()
|
||||
{
|
||||
return Main.player[player];
|
||||
}
|
||||
|
||||
public int GetPlayerID()
|
||||
{
|
||||
return player;
|
||||
TilesDestroyed = new Dictionary<TShock.Position, Tile>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -280,12 +280,12 @@ namespace TShockAPI
|
|||
Tools.ForceKick(e.Msg.whoAmI, "Player doesn't exist");
|
||||
return true;
|
||||
}
|
||||
if (players[e.Msg.whoAmI].receivedInfo)
|
||||
if (players[e.Msg.whoAmI].ReceivedInfo)
|
||||
{
|
||||
return Tools.HandleGriefer(e.Msg.whoAmI, "Sent client info more than once");
|
||||
}
|
||||
|
||||
players[e.Msg.whoAmI].receivedInfo = true;
|
||||
players[e.Msg.whoAmI].ReceivedInfo = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -341,7 +341,7 @@ namespace TShockAPI
|
|||
}
|
||||
if (ConfigurationManager.disableBuild)
|
||||
{
|
||||
if (!players[e.Msg.whoAmI].group.HasPermission("editspawn"))
|
||||
if (!players[e.Msg.whoAmI].Group.HasPermission("editspawn"))
|
||||
{
|
||||
Tools.SendMessage(e.Msg.whoAmI, "World protected from changes.", Color.Red);
|
||||
RevertPlayerChanges(e.Msg.whoAmI, type, x, y);
|
||||
|
|
@ -350,7 +350,7 @@ namespace TShockAPI
|
|||
}
|
||||
if (ConfigurationManager.spawnProtect)
|
||||
{
|
||||
if (!players[e.Msg.whoAmI].group.HasPermission("editspawn"))
|
||||
if (!players[e.Msg.whoAmI].Group.HasPermission("editspawn"))
|
||||
{
|
||||
var flag = CheckSpawn(x, y);
|
||||
if (flag)
|
||||
|
|
@ -364,8 +364,8 @@ namespace TShockAPI
|
|||
|
||||
if (type == 0 && BlacklistTiles[Main.tile[x, y].type] && Main.player[e.Msg.whoAmI].active)
|
||||
{
|
||||
players[e.Msg.whoAmI].tileThreshold++;
|
||||
players[e.Msg.whoAmI].tilesDestroyed.Add(new Position(x, y), Main.tile[x, y]);
|
||||
players[e.Msg.whoAmI].TileThreshold++;
|
||||
players[e.Msg.whoAmI].TilesDestroyed.Add(new Position(x, y), Main.tile[x, y]);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -495,14 +495,14 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
if (lava && !players[e.Msg.whoAmI].group.HasPermission("canlava"))
|
||||
if (lava && !players[e.Msg.whoAmI].Group.HasPermission("canlava"))
|
||||
{
|
||||
Tools.SendMessage(e.Msg.whoAmI, "You do not have permission to use lava", Color.Red);
|
||||
Tools.SendLogs(string.Format("{0} tried using lava", Main.player[e.Msg.whoAmI].name), Color.Red);
|
||||
|
||||
return true;
|
||||
}
|
||||
if (!lava && !players[e.Msg.whoAmI].group.HasPermission("canwater"))
|
||||
if (!lava && !players[e.Msg.whoAmI].Group.HasPermission("canwater"))
|
||||
{
|
||||
Tools.SendMessage(e.Msg.whoAmI, "You do not have permission to use water", Color.Red);
|
||||
Tools.SendLogs(string.Format("{0} tried using water", Main.player[e.Msg.whoAmI].name), Color.Red);
|
||||
|
|
@ -533,7 +533,7 @@ namespace TShockAPI
|
|||
|
||||
if (ConfigurationManager.spawnProtect)
|
||||
{
|
||||
if (!players[e.Msg.whoAmI].group.HasPermission("editspawn"))
|
||||
if (!players[e.Msg.whoAmI].Group.HasPermission("editspawn"))
|
||||
{
|
||||
var flag = CheckSpawn(x, y);
|
||||
if (flag)
|
||||
|
|
@ -570,7 +570,7 @@ namespace TShockAPI
|
|||
if (Main.netMode != 2)
|
||||
return;
|
||||
|
||||
Log.Info(string.Format("{0} ({1}) from '{2}' group joined.", Tools.FindPlayer(who), Tools.GetPlayerIP(who), players[who].group.GetName()));
|
||||
Log.Info(string.Format("{0} ({1}) from '{2}' group joined.", Tools.FindPlayer(who), Tools.GetPlayerIP(who), players[who].Group.GetName()));
|
||||
|
||||
Tools.ShowMOTD(who);
|
||||
if (HackedHealth(who))
|
||||
|
|
@ -582,7 +582,7 @@ namespace TShockAPI
|
|||
Main.player[who].hostile = true;
|
||||
NetMessage.SendData(30, -1, -1, "", who);
|
||||
}
|
||||
if (players[who].group.HasPermission("causeevents") && ConfigurationManager.infiniteInvasion)
|
||||
if (players[who].Group.HasPermission("causeevents") && ConfigurationManager.infiniteInvasion)
|
||||
{
|
||||
StartInvasion();
|
||||
}
|
||||
|
|
@ -600,7 +600,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (players[ply].group.HasPermission("adminchat") && !text.StartsWith("/"))
|
||||
if (players[ply].Group.HasPermission("adminchat") && !text.StartsWith("/"))
|
||||
{
|
||||
Tools.Broadcast(ConfigurationManager.adminChatPrefix + "<" + Main.player[ply].name + "> " + text, (byte)ConfigurationManager.adminChatRGB[0], (byte)ConfigurationManager.adminChatRGB[1], (byte)ConfigurationManager.adminChatRGB[2]);
|
||||
e.Handled = true;
|
||||
|
|
@ -660,10 +660,10 @@ namespace TShockAPI
|
|||
|
||||
string ip = Tools.GetPlayerIP(ply);
|
||||
players[ply] = new TSPlayer(ply);
|
||||
players[ply].group = Tools.GetGroupForIP(ip);
|
||||
players[ply].Group = Tools.GetGroupForIP(ip);
|
||||
|
||||
if (Tools.activePlayers() + 1 > ConfigurationManager.maxSlots &&
|
||||
!players[ply].group.HasPermission("reservedslot"))
|
||||
if (Tools.ActivePlayers() + 1 > ConfigurationManager.maxSlots &&
|
||||
!players[ply].Group.HasPermission("reservedslot"))
|
||||
{
|
||||
Tools.ForceKick(ply, "Server is full");
|
||||
handler.Handled = true;
|
||||
|
|
@ -726,24 +726,24 @@ namespace TShockAPI
|
|||
{
|
||||
if (Main.player[i].active == false)
|
||||
continue;
|
||||
if (players[i].tileThreshold >= 20)
|
||||
if (players[i].TileThreshold >= 20)
|
||||
{
|
||||
if (Tools.HandleTntUser(i, "Kill tile abuse detected."))
|
||||
{
|
||||
RevertKillTile(i);
|
||||
players[i].tileThreshold = 0;
|
||||
players[i].tilesDestroyed.Clear();
|
||||
players[i].TileThreshold = 0;
|
||||
players[i].TilesDestroyed.Clear();
|
||||
}
|
||||
else if (players[i].tileThreshold > 0)
|
||||
else if (players[i].TileThreshold > 0)
|
||||
{
|
||||
players[i].tileThreshold = 0;
|
||||
players[i].tilesDestroyed.Clear();
|
||||
players[i].TileThreshold = 0;
|
||||
players[i].TilesDestroyed.Clear();
|
||||
}
|
||||
|
||||
}
|
||||
else if (players[i].tileThreshold > 0)
|
||||
else if (players[i].TileThreshold > 0)
|
||||
{
|
||||
players[i].tileThreshold = 0;
|
||||
players[i].TileThreshold = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -779,7 +779,7 @@ namespace TShockAPI
|
|||
}
|
||||
else
|
||||
{
|
||||
Main.invasionSize = 100 + (ConfigurationManager.invasionMultiplier * Tools.activePlayers());
|
||||
Main.invasionSize = 100 + (ConfigurationManager.invasionMultiplier * Tools.ActivePlayers());
|
||||
}
|
||||
|
||||
Main.invasionWarn = 0;
|
||||
|
|
@ -913,11 +913,11 @@ namespace TShockAPI
|
|||
|
||||
public static void RevertKillTile(int ply)
|
||||
{
|
||||
Tile[] tiles = new Tile[players[ply].tilesDestroyed.Count];
|
||||
players[ply].tilesDestroyed.Values.CopyTo(tiles, 0);
|
||||
Position[] positions = new Position[players[ply].tilesDestroyed.Count];
|
||||
players[ply].tilesDestroyed.Keys.CopyTo(positions, 0);
|
||||
for (int i = (players[ply].tilesDestroyed.Count - 1); i >= 0; i--)
|
||||
Tile[] tiles = new Tile[players[ply].TilesDestroyed.Count];
|
||||
players[ply].TilesDestroyed.Values.CopyTo(tiles, 0);
|
||||
Position[] positions = new Position[players[ply].TilesDestroyed.Count];
|
||||
players[ply].TilesDestroyed.Keys.CopyTo(positions, 0);
|
||||
for (int i = (players[ply].TilesDestroyed.Count - 1); i >= 0; i--)
|
||||
{
|
||||
Main.tile[(int)positions[i].X, (int)positions[i].Y] = tiles[i];
|
||||
NetMessage.SendData(17, -1, -1, "", 1, positions[i].X, positions[i].Y, (float)0);
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ namespace TShockAPI
|
|||
{
|
||||
if (TShock.players[i] == null)
|
||||
continue;
|
||||
if (!TShock.players[i].group.HasPermission("logs"))
|
||||
if (!TShock.players[i].Group.HasPermission("logs"))
|
||||
continue;
|
||||
|
||||
SendMessage(i, log, color);
|
||||
|
|
@ -162,7 +162,7 @@ namespace TShockAPI
|
|||
/// The number of active players on the server.
|
||||
/// </summary>
|
||||
/// <returns>int playerCount</returns>
|
||||
public static int activePlayers()
|
||||
public static int ActivePlayers()
|
||||
{
|
||||
int num = 0;
|
||||
for (int i = 0; i < Main.maxPlayers; i++)
|
||||
|
|
@ -265,7 +265,7 @@ namespace TShockAPI
|
|||
{
|
||||
if (!Netplay.serverSock[ply].active || Netplay.serverSock[ply].kill)
|
||||
return true;
|
||||
if (!TShock.players[ply].group.HasPermission("immunetokick"))
|
||||
if (!TShock.players[ply].Group.HasPermission("immunetokick"))
|
||||
{
|
||||
string playerName = Main.player[ply].name;
|
||||
NetMessage.SendData(0x2, ply, -1, string.Format("Kicked: {0}", reason), 0x0, 0f, 0f, 0f);
|
||||
|
|
@ -288,7 +288,7 @@ namespace TShockAPI
|
|||
{
|
||||
if (!Netplay.serverSock[plr].active || Netplay.serverSock[plr].kill)
|
||||
return true;
|
||||
if (!TShock.players[plr].group.HasPermission("immunetoban"))
|
||||
if (!TShock.players[plr].Group.HasPermission("immunetoban"))
|
||||
{
|
||||
string ip = GetPlayerIP(plr);
|
||||
string playerName = Main.player[plr].name;
|
||||
|
|
@ -326,7 +326,7 @@ namespace TShockAPI
|
|||
|
||||
private static bool HandleBadPlayer(int ply, string overridePermission, bool ban, bool kick, string reason)
|
||||
{
|
||||
if (!TShock.players[ply].group.HasPermission(overridePermission))
|
||||
if (!TShock.players[ply].Group.HasPermission(overridePermission))
|
||||
{
|
||||
if (ban)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ namespace TShockAPI
|
|||
{
|
||||
if (Main.player[i].active)
|
||||
{
|
||||
if (!TShock.players[i].group.HasPermission("maintenance"))
|
||||
if (!TShock.players[i].Group.HasPermission("maintenance"))
|
||||
return;
|
||||
Tools.SendMessage(i, "The server is out of date. To update, type /updatenow.");
|
||||
for (int j = 4; j < changes.Length; j++)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue