Added TSPlayer class to contain variables that are player specific
This commit is contained in:
parent
947540cb1f
commit
39bc48968a
3 changed files with 31 additions and 6 deletions
23
TShockAPI/TSPlayer.cs
Normal file
23
TShockAPI/TSPlayer.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace TShockAPI
|
||||||
|
{
|
||||||
|
class TSPlayer
|
||||||
|
{
|
||||||
|
public uint tileThreshold;
|
||||||
|
private int player;
|
||||||
|
|
||||||
|
public TSPlayer(int ply)
|
||||||
|
{
|
||||||
|
player = ply;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Terraria.Player GetPlayer()
|
||||||
|
{
|
||||||
|
return Terraria.Main.player[player];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,7 +11,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
public class TShock : TerrariaPlugin
|
public class TShock : TerrariaPlugin
|
||||||
{
|
{
|
||||||
uint[] tileThreshold = new uint[Main.maxPlayers];
|
TSPlayer[] players = new TSPlayer[Main.maxPlayers];
|
||||||
|
|
||||||
public static string saveDir = "./tshock/";
|
public static string saveDir = "./tshock/";
|
||||||
|
|
||||||
|
|
@ -160,7 +160,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
if (type == 0 && BlacklistTiles[Main.tile[x, y].type] && Main.player[e.Msg.whoAmI].active)
|
if (type == 0 && BlacklistTiles[Main.tile[x, y].type] && Main.player[e.Msg.whoAmI].active)
|
||||||
{
|
{
|
||||||
tileThreshold[e.Msg.whoAmI]++;
|
players[e.Msg.whoAmI].tileThreshold++;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -240,6 +240,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
Tools.Kick(ply, "Not on whitelist.");
|
Tools.Kick(ply, "Not on whitelist.");
|
||||||
}
|
}
|
||||||
|
players[ply] = new TSPlayer(ply);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnLoadContent(Microsoft.Xna.Framework.Content.ContentManager obj)
|
void OnLoadContent(Microsoft.Xna.Framework.Content.ContentManager obj)
|
||||||
|
|
@ -261,7 +262,7 @@ namespace TShockAPI
|
||||||
for (uint i = 0; i < Main.maxPlayers; i++)
|
for (uint i = 0; i < Main.maxPlayers; i++)
|
||||||
{
|
{
|
||||||
if (Main.player[i].active == false) { continue; }
|
if (Main.player[i].active == false) { continue; }
|
||||||
if (tileThreshold[i] >= 5)
|
if (players[i].tileThreshold >= 5)
|
||||||
{
|
{
|
||||||
if (Main.player[i] != null)
|
if (Main.player[i] != null)
|
||||||
{
|
{
|
||||||
|
|
@ -269,11 +270,11 @@ namespace TShockAPI
|
||||||
Tools.Kick((int)i, "Kill tile abuse detected.");
|
Tools.Kick((int)i, "Kill tile abuse detected.");
|
||||||
Tools.Broadcast(Main.player[i].name + " was " + (ConfigurationManager.banTnt ? "banned" : "kicked") + " for kill tile abuse.");
|
Tools.Broadcast(Main.player[i].name + " was " + (ConfigurationManager.banTnt ? "banned" : "kicked") + " for kill tile abuse.");
|
||||||
}
|
}
|
||||||
tileThreshold[i] = 0;
|
players[i].tileThreshold = 0;
|
||||||
}
|
}
|
||||||
else if (tileThreshold[i] > 0)
|
else if (players[i].tileThreshold > 0)
|
||||||
{
|
{
|
||||||
tileThreshold[i] = 0;
|
players[i].tileThreshold = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@
|
||||||
<Compile Include="Tools.cs" />
|
<Compile Include="Tools.cs" />
|
||||||
<Compile Include="TShock.cs" />
|
<Compile Include="TShock.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="TSPlayer.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue