Refactor for new configuration
This commit is contained in:
parent
a03647ce38
commit
9423febd0a
26 changed files with 351 additions and 433 deletions
|
|
@ -68,7 +68,7 @@ namespace TShockAPI
|
|||
if (worldpath != null && !Directory.Exists(worldpath))
|
||||
Directory.CreateDirectory(worldpath);
|
||||
|
||||
if (TShock.Config.ShowBackupAutosaveMessages)
|
||||
if (TShock.Config.Settings.ShowBackupAutosaveMessages)
|
||||
{
|
||||
TSPlayer.All.SendInfoMessage("Server map saving, potential lag spike.");
|
||||
|
||||
|
|
@ -105,4 +105,4 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ namespace TShockAPI
|
|||
if (args.Player.IsBeingDisabled())
|
||||
{
|
||||
// If the player has moved outside the disabled zone...
|
||||
if (distance > TShock.Config.MaxRangeForDisabled)
|
||||
if (distance > TShock.Config.Settings.MaxRangeForDisabled)
|
||||
{
|
||||
// We need to tell them they were disabled and why, then revert the change.
|
||||
if (args.Player.IsDisabledForStackDetection)
|
||||
|
|
@ -177,11 +177,11 @@ namespace TShockAPI
|
|||
}
|
||||
else if (args.Player.IsDisabledForSSC)
|
||||
{
|
||||
args.Player.SendErrorMessage("Disabled. You need to {0}login to load your saved data.", TShock.Config.CommandSpecifier);
|
||||
args.Player.SendErrorMessage("Disabled. You need to {0}login to load your saved data.", TShock.Config.Settings.CommandSpecifier);
|
||||
}
|
||||
else if (TShock.Config.RequireLogin && !args.Player.IsLoggedIn)
|
||||
else if (TShock.Config.Settings.RequireLogin && !args.Player.IsLoggedIn)
|
||||
{
|
||||
args.Player.SendErrorMessage("Account needed! Please {0}register or {0}login to play!", TShock.Config.CommandSpecifier);
|
||||
args.Player.SendErrorMessage("Account needed! Please {0}register or {0}login to play!", TShock.Config.Settings.CommandSpecifier);
|
||||
}
|
||||
else if (args.Player.IsDisabledPendingTrashRemoval)
|
||||
{
|
||||
|
|
@ -257,7 +257,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (args.Player.Dead && TShock.Config.PreventDeadModification)
|
||||
if (args.Player.Dead && TShock.Config.Settings.PreventDeadModification)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (pdm) {0} {1} {2}", args.Player.Name, action, editData);
|
||||
args.Player.SendTileSquare(tileX, tileY, 4);
|
||||
|
|
@ -345,7 +345,7 @@ namespace TShockAPI
|
|||
}
|
||||
else if (action == EditAction.PlaceTile || action == EditAction.ReplaceTile || action == EditAction.PlaceWall || action == EditAction.ReplaceWall)
|
||||
{
|
||||
if ((action == EditAction.PlaceTile && TShock.Config.PreventInvalidPlaceStyle) &&
|
||||
if ((action == EditAction.PlaceTile && TShock.Config.Settings.PreventInvalidPlaceStyle) &&
|
||||
(MaxPlaceStyles.ContainsKey(editData) && style > MaxPlaceStyles[editData]) &&
|
||||
(ExtraneousPlaceStyles.ContainsKey(editData) && style > ExtraneousPlaceStyles[editData]))
|
||||
{
|
||||
|
|
@ -436,7 +436,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (TShock.Config.AllowCutTilesAndBreakables && Main.tileCut[tile.type])
|
||||
if (TShock.Config.Settings.AllowCutTilesAndBreakables && Main.tileCut[tile.type])
|
||||
{
|
||||
if (action == EditAction.KillWall || action == EditAction.ReplaceWall)
|
||||
{
|
||||
|
|
@ -496,11 +496,11 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (args.Player.TileKillThreshold >= TShock.Config.TileKillThreshold)
|
||||
if (args.Player.TileKillThreshold >= TShock.Config.Settings.TileKillThreshold)
|
||||
{
|
||||
if (TShock.Config.KickOnTileKillThresholdBroken)
|
||||
if (TShock.Config.Settings.KickOnTileKillThresholdBroken)
|
||||
{
|
||||
args.Player.Kick(string.Format("Tile kill threshold exceeded {0}.", TShock.Config.TileKillThreshold));
|
||||
args.Player.Kick(string.Format("Tile kill threshold exceeded {0}.", TShock.Config.Settings.TileKillThreshold));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -514,11 +514,11 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (args.Player.TilePlaceThreshold >= TShock.Config.TilePlaceThreshold)
|
||||
if (args.Player.TilePlaceThreshold >= TShock.Config.Settings.TilePlaceThreshold)
|
||||
{
|
||||
if (TShock.Config.KickOnTilePlaceThresholdBroken)
|
||||
if (TShock.Config.Settings.KickOnTilePlaceThresholdBroken)
|
||||
{
|
||||
args.Player.Kick(string.Format("Tile place threshold exceeded {0}.", TShock.Config.TilePlaceThreshold));
|
||||
args.Player.Kick(string.Format("Tile place threshold exceeded {0}.", TShock.Config.Settings.TilePlaceThreshold));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -719,7 +719,7 @@ namespace TShockAPI
|
|||
}
|
||||
|
||||
// TODO: Remove item ban part of this check
|
||||
if ((Main.ServerSideCharacter) && (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - args.Player.LoginMS < TShock.ServerSideCharacterConfig.LogonDiscardThreshold))
|
||||
if ((Main.ServerSideCharacter) && (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - args.Player.LoginMS < TShock.ServerSideCharacterConfig.Settings.LogonDiscardThreshold))
|
||||
{
|
||||
//Player is probably trying to sneak items onto the server in their hands!!!
|
||||
TShock.Log.ConsoleInfo("Player {0} tried to sneak {1} onto the server!", args.Player.Name, item.Name);
|
||||
|
|
@ -771,10 +771,10 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (damage > TShock.Config.MaxProjDamage && !args.Player.HasPermission(Permissions.ignoredamagecap))
|
||||
if (damage > TShock.Config.Settings.MaxProjDamage && !args.Player.HasPermission(Permissions.ignoredamagecap))
|
||||
{
|
||||
args.Player.Disable(String.Format("Projectile damage is higher than {0}.", TShock.Config.MaxProjDamage), DisableFlags.WriteToLogAndConsole);
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from projectile damage limit from {0} {1}/{2}", args.Player.Name, damage, TShock.Config.MaxProjDamage);
|
||||
args.Player.Disable(String.Format("Projectile damage is higher than {0}.", TShock.Config.Settings.MaxProjDamage), DisableFlags.WriteToLogAndConsole);
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from projectile damage limit from {0} {1}/{2}", args.Player.Name, damage, TShock.Config.Settings.MaxProjDamage);
|
||||
args.Player.RemoveProjectile(ident, owner);
|
||||
args.Handled = true;
|
||||
return;
|
||||
|
|
@ -836,7 +836,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (!TShock.Config.IgnoreProjUpdate && !args.Player.HasPermission(Permissions.ignoreprojectiledetection))
|
||||
if (!TShock.Config.Settings.IgnoreProjUpdate && !args.Player.HasPermission(Permissions.ignoreprojectiledetection))
|
||||
{
|
||||
if (type == ProjectileID.BlowupSmokeMoonlord
|
||||
|| type == ProjectileID.PhantasmalEye
|
||||
|
|
@ -863,11 +863,11 @@ namespace TShockAPI
|
|||
// return;
|
||||
}
|
||||
|
||||
if (args.Player.ProjectileThreshold >= TShock.Config.ProjectileThreshold)
|
||||
if (args.Player.ProjectileThreshold >= TShock.Config.Settings.ProjectileThreshold)
|
||||
{
|
||||
if (TShock.Config.KickOnProjectileThresholdBroken)
|
||||
if (TShock.Config.Settings.KickOnProjectileThresholdBroken)
|
||||
{
|
||||
args.Player.Kick(string.Format("Projectile update threshold exceeded {0}.", TShock.Config.ProjectileThreshold));
|
||||
args.Player.Kick(string.Format("Projectile update threshold exceeded {0}.", TShock.Config.Settings.ProjectileThreshold));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -875,7 +875,7 @@ namespace TShockAPI
|
|||
args.Player.RemoveProjectile(ident, owner);
|
||||
}
|
||||
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from projectile update threshold from {0} {1}/{2}", args.Player.Name, args.Player.ProjectileThreshold, TShock.Config.ProjectileThreshold);
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from projectile update threshold from {0} {1}/{2}", args.Player.Name, args.Player.ProjectileThreshold, TShock.Config.Settings.ProjectileThreshold);
|
||||
TShock.Log.ConsoleDebug("If this player wasn't hacking, please report the projectile update threshold they were disabled for to TShock so we can improve this!");
|
||||
args.Handled = true;
|
||||
return;
|
||||
|
|
@ -891,7 +891,7 @@ namespace TShockAPI
|
|||
|
||||
if (!args.Player.HasPermission(Permissions.ignoreprojectiledetection))
|
||||
{
|
||||
if (type == ProjectileID.CrystalShard && TShock.Config.ProjIgnoreShrapnel) // Ignore crystal shards
|
||||
if (type == ProjectileID.CrystalShard && TShock.Config.Settings.ProjIgnoreShrapnel) // Ignore crystal shards
|
||||
{
|
||||
TShock.Log.Debug("Ignoring shrapnel per config..");
|
||||
}
|
||||
|
|
@ -930,19 +930,19 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (damage >= TShock.Config.MaxDamage && !args.Player.HasPermission(Permissions.ignoredamagecap))
|
||||
if (damage >= TShock.Config.Settings.MaxDamage && !args.Player.HasPermission(Permissions.ignoredamagecap))
|
||||
{
|
||||
if (TShock.Config.KickOnDamageThresholdBroken)
|
||||
if (TShock.Config.Settings.KickOnDamageThresholdBroken)
|
||||
{
|
||||
args.Player.Kick(string.Format("NPC damage exceeded {0}.", TShock.Config.MaxDamage));
|
||||
args.Player.Kick(string.Format("NPC damage exceeded {0}.", TShock.Config.Settings.MaxDamage));
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Player.Disable(String.Format("NPC damage exceeded {0}.", TShock.Config.MaxDamage), DisableFlags.WriteToLogAndConsole);
|
||||
args.Player.Disable(String.Format("NPC damage exceeded {0}.", TShock.Config.Settings.MaxDamage), DisableFlags.WriteToLogAndConsole);
|
||||
args.Player.SendData(PacketTypes.NpcUpdate, "", id);
|
||||
}
|
||||
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnNPCStrike rejected from damage threshold from {0} {1}/{2}", args.Player.Name, damage, TShock.Config.MaxDamage);
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnNPCStrike rejected from damage threshold from {0} {1}/{2}", args.Player.Name, damage, TShock.Config.Settings.MaxDamage);
|
||||
TShock.Log.ConsoleDebug("If this player wasn't hacking, please report the damage threshold they were disabled for to TShock so we can improve this!");
|
||||
args.Handled = true;
|
||||
return;
|
||||
|
|
@ -956,7 +956,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (TShock.Config.RangeChecks &&
|
||||
if (TShock.Config.Settings.RangeChecks &&
|
||||
!args.Player.IsInRange((int)(Main.npc[id].position.X / 16f), (int)(Main.npc[id].position.Y / 16f), 128))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnNPCStrike rejected from range checks from {0}", args.Player.Name);
|
||||
|
|
@ -1029,7 +1029,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (!args.Player.HasBuildPermission(Main.chest[id].x, Main.chest[id].y) && TShock.Config.RegionProtectChests)
|
||||
if (!args.Player.HasBuildPermission(Main.chest[id].x, Main.chest[id].y) && TShock.Config.Settings.RegionProtectChests)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnChestItemChange rejected from region protection? from {0}", args.Player.Name);
|
||||
args.Handled = true;
|
||||
|
|
@ -1063,7 +1063,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (!args.Player.HasBuildPermission(args.X, args.Y) && TShock.Config.RegionProtectChests)
|
||||
if (!args.Player.HasBuildPermission(args.X, args.Y) && TShock.Config.Settings.RegionProtectChests)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnChestOpen rejected from region check from {0}", args.Player.Name);
|
||||
args.Handled = true;
|
||||
|
|
@ -1083,7 +1083,7 @@ namespace TShockAPI
|
|||
int tileY = args.TileY;
|
||||
int flag = args.Flag;
|
||||
|
||||
if (!TShock.Utils.TilePlacementValid(tileX, tileY) || (args.Player.Dead && TShock.Config.PreventDeadModification))
|
||||
if (!TShock.Utils.TilePlacementValid(tileX, tileY) || (args.Player.Dead && TShock.Config.Settings.PreventDeadModification))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlaceChest rejected from invalid check from {0}", args.Player.Name);
|
||||
args.Handled = true;
|
||||
|
|
@ -1209,7 +1209,7 @@ namespace TShockAPI
|
|||
byte amount = args.Amount;
|
||||
LiquidType type = args.Type;
|
||||
|
||||
if (!TShock.Utils.TilePlacementValid(tileX, tileY) || (args.Player.Dead && TShock.Config.PreventDeadModification))
|
||||
if (!TShock.Utils.TilePlacementValid(tileX, tileY) || (args.Player.Dead && TShock.Config.Settings.PreventDeadModification))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected invalid check from {0}", args.Player.Name);
|
||||
args.Handled = true;
|
||||
|
|
@ -1224,11 +1224,11 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (args.Player.TileLiquidThreshold >= TShock.Config.TileLiquidThreshold)
|
||||
if (args.Player.TileLiquidThreshold >= TShock.Config.Settings.TileLiquidThreshold)
|
||||
{
|
||||
if (TShock.Config.KickOnTileLiquidThresholdBroken)
|
||||
if (TShock.Config.Settings.KickOnTileLiquidThresholdBroken)
|
||||
{
|
||||
args.Player.Kick(string.Format("Reached TileLiquid threshold {0}.", TShock.Config.TileLiquidThreshold));
|
||||
args.Player.Kick(string.Format("Reached TileLiquid threshold {0}.", TShock.Config.Settings.TileLiquidThreshold));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1236,7 +1236,7 @@ namespace TShockAPI
|
|||
args.Player.SendTileSquare(tileX, tileY, 1);
|
||||
}
|
||||
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected from liquid threshold from {0} {1}/{2}", args.Player.Name, args.Player.TileLiquidThreshold, TShock.Config.TileLiquidThreshold);
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected from liquid threshold from {0} {1}/{2}", args.Player.Name, args.Player.TileLiquidThreshold, TShock.Config.Settings.TileLiquidThreshold);
|
||||
TShock.Log.ConsoleDebug("If this player wasn't hacking, please report the tile liquid threshold they were disabled for to TShock so we can improve this!");
|
||||
args.Handled = true;
|
||||
return;
|
||||
|
|
@ -1261,8 +1261,8 @@ namespace TShockAPI
|
|||
}
|
||||
|
||||
var recentBombs = args.Player.RecentlyCreatedProjectiles.Where(p => projectileTypesThatPerformThisOperation.Contains(Main.projectile[p.Index].type));
|
||||
wasThereABombNearby = recentBombs.Any(r => Math.Abs(args.TileX - (Main.projectile[r.Index].position.X / 16.0f)) < TShock.Config.BombExplosionRadius
|
||||
&& Math.Abs(args.TileY - (Main.projectile[r.Index].position.Y / 16.0f)) < TShock.Config.BombExplosionRadius);
|
||||
wasThereABombNearby = recentBombs.Any(r => Math.Abs(args.TileX - (Main.projectile[r.Index].position.X / 16.0f)) < TShock.Config.Settings.BombExplosionRadius
|
||||
&& Math.Abs(args.TileY - (Main.projectile[r.Index].position.Y / 16.0f)) < TShock.Config.Settings.BombExplosionRadius);
|
||||
}
|
||||
|
||||
// Liquid anti-cheat
|
||||
|
|
@ -1561,7 +1561,7 @@ namespace TShockAPI
|
|||
// Why 0.2?
|
||||
// @bartico6: Because heal other player only happens when you are using the spectre armor with the hood,
|
||||
// and the healing you can do with that is 20% of your damage.
|
||||
if (amount >= TShock.Config.MaxDamage * 0.2)
|
||||
if (amount >= TShock.Config.Settings.MaxDamage * 0.2)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnHealOtherPlayer 0.2 check from {0}", args.Player.Name);
|
||||
args.Player.Disable("HealOtherPlayer cheat attempt!", DisableFlags.WriteToLogAndConsole);
|
||||
|
|
@ -1569,17 +1569,17 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (args.Player.HealOtherThreshold >= TShock.Config.HealOtherThreshold)
|
||||
if (args.Player.HealOtherThreshold >= TShock.Config.Settings.HealOtherThreshold)
|
||||
{
|
||||
if (TShock.Config.KickOnHealOtherThresholdBroken)
|
||||
if (TShock.Config.Settings.KickOnHealOtherThresholdBroken)
|
||||
{
|
||||
args.Player.Kick(string.Format("HealOtherPlayer threshold exceeded {0}.", TShock.Config.HealOtherThreshold));
|
||||
args.Player.Kick(string.Format("HealOtherPlayer threshold exceeded {0}.", TShock.Config.Settings.HealOtherThreshold));
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Player.Disable("Reached HealOtherPlayer threshold.", DisableFlags.WriteToLogAndConsole);
|
||||
}
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnHealOtherPlayer rejected heal other threshold from {0} {1}/{2}", args.Player.Name, args.Player.HealOtherThreshold, TShock.Config.HealOtherThreshold);
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnHealOtherPlayer rejected heal other threshold from {0} {1}/{2}", args.Player.Name, args.Player.HealOtherThreshold, TShock.Config.Settings.HealOtherThreshold);
|
||||
TShock.Log.ConsoleDebug("If this player wasn't hacking, please report the HealOtherPlayer threshold they were disabled for to TShock so we can improve this!");
|
||||
args.Handled = true;
|
||||
return;
|
||||
|
|
@ -1658,7 +1658,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (args.Player.Dead && TShock.Config.PreventDeadModification)
|
||||
if (args.Player.Dead && TShock.Config.Settings.PreventDeadModification)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected dead people don't do things from {0}", args.Player.Name);
|
||||
args.Player.SendTileSquare(x, y, 4);
|
||||
|
|
@ -1725,9 +1725,9 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (args.Player.TilePlaceThreshold >= TShock.Config.TilePlaceThreshold)
|
||||
if (args.Player.TilePlaceThreshold >= TShock.Config.Settings.TilePlaceThreshold)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected tile place threshold from {0} {1}/{2}", args.Player.Name, args.Player.TilePlaceThreshold, TShock.Config.TilePlaceThreshold);
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected tile place threshold from {0} {1}/{2}", args.Player.Name, args.Player.TilePlaceThreshold, TShock.Config.Settings.TilePlaceThreshold);
|
||||
args.Player.Disable("Reached TilePlace threshold.", DisableFlags.WriteToLogAndConsole);
|
||||
args.Player.SendTileSquare(x, y, 4);
|
||||
args.Handled = true;
|
||||
|
|
@ -1844,7 +1844,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (!TShock.Utils.TilePlacementValid(args.X, args.Y) || (args.Player.Dead && TShock.Config.PreventDeadModification))
|
||||
if (!TShock.Utils.TilePlacementValid(args.X, args.Y) || (args.Player.Dead && TShock.Config.Settings.PreventDeadModification))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnGemLockToggle invalid placement/deadmod from {0}", args.Player.Name);
|
||||
args.Handled = true;
|
||||
|
|
@ -1892,7 +1892,7 @@ namespace TShockAPI
|
|||
x = p.X;
|
||||
y = p.Y;
|
||||
|
||||
if (!TShock.Utils.TilePlacementValid(x, y) || (args.Player.Dead && TShock.Config.PreventDeadModification))
|
||||
if (!TShock.Utils.TilePlacementValid(x, y) || (args.Player.Dead && TShock.Config.Settings.PreventDeadModification))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnMassWireOperation rejected valid placement from {0}", args.Player.Name);
|
||||
args.Handled = true;
|
||||
|
|
@ -1933,19 +1933,19 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (damage > TShock.Config.MaxDamage && !args.Player.HasPermission(Permissions.ignoredamagecap) && id != args.Player.Index)
|
||||
if (damage > TShock.Config.Settings.MaxDamage && !args.Player.HasPermission(Permissions.ignoredamagecap) && id != args.Player.Index)
|
||||
{
|
||||
if (TShock.Config.KickOnDamageThresholdBroken)
|
||||
if (TShock.Config.Settings.KickOnDamageThresholdBroken)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlayerDamage rejected damage threshold from {0} {1}/{2}", args.Player.Name, damage, TShock.Config.MaxDamage);
|
||||
args.Player.Kick(string.Format("Player damage exceeded {0}.", TShock.Config.MaxDamage));
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlayerDamage rejected damage threshold from {0} {1}/{2}", args.Player.Name, damage, TShock.Config.Settings.MaxDamage);
|
||||
args.Player.Kick(string.Format("Player damage exceeded {0}.", TShock.Config.Settings.MaxDamage));
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlayerDamage rejected damage threshold2 from {0} {1}/{2}", args.Player.Name, damage, TShock.Config.MaxDamage);
|
||||
args.Player.Disable(String.Format("Player damage exceeded {0}.", TShock.Config.MaxDamage), DisableFlags.WriteToLogAndConsole);
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlayerDamage rejected damage threshold2 from {0} {1}/{2}", args.Player.Name, damage, TShock.Config.Settings.MaxDamage);
|
||||
args.Player.Disable(String.Format("Player damage exceeded {0}.", TShock.Config.Settings.MaxDamage), DisableFlags.WriteToLogAndConsole);
|
||||
}
|
||||
args.Player.SendData(PacketTypes.PlayerHp, "", id);
|
||||
args.Player.SendData(PacketTypes.PlayerUpdate, "", id);
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ namespace TShockAPI
|
|||
/// </summary>
|
||||
public static string Specifier
|
||||
{
|
||||
get { return string.IsNullOrWhiteSpace(TShock.Config.CommandSpecifier) ? "/" : TShock.Config.CommandSpecifier; }
|
||||
get { return string.IsNullOrWhiteSpace(TShock.Config.Settings.CommandSpecifier) ? "/" : TShock.Config.Settings.CommandSpecifier; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -207,7 +207,7 @@ namespace TShockAPI
|
|||
/// </summary>
|
||||
public static string SilentSpecifier
|
||||
{
|
||||
get { return string.IsNullOrWhiteSpace(TShock.Config.CommandSilentSpecifier) ? "." : TShock.Config.CommandSilentSpecifier; }
|
||||
get { return string.IsNullOrWhiteSpace(TShock.Config.Settings.CommandSilentSpecifier) ? "." : TShock.Config.Settings.CommandSilentSpecifier; }
|
||||
}
|
||||
|
||||
private delegate void AddChatCommand(string permission, CommandDelegate command, params string[] names);
|
||||
|
|
@ -756,10 +756,10 @@ namespace TShockAPI
|
|||
|
||||
private static void AttemptLogin(CommandArgs args)
|
||||
{
|
||||
if (args.Player.LoginAttempts > TShock.Config.MaximumLoginAttempts && (TShock.Config.MaximumLoginAttempts != -1))
|
||||
if (args.Player.LoginAttempts > TShock.Config.Settings.MaximumLoginAttempts && (TShock.Config.Settings.MaximumLoginAttempts != -1))
|
||||
{
|
||||
TShock.Log.Warn(String.Format("{0} ({1}) had {2} or more invalid login attempts and was kicked automatically.",
|
||||
args.Player.IP, args.Player.Name, TShock.Config.MaximumLoginAttempts));
|
||||
args.Player.IP, args.Player.Name, TShock.Config.Settings.MaximumLoginAttempts));
|
||||
args.Player.Kick("Too many invalid login attempts.");
|
||||
return;
|
||||
}
|
||||
|
|
@ -773,7 +773,7 @@ namespace TShockAPI
|
|||
UserAccount account = TShock.UserAccounts.GetUserAccountByName(args.Player.Name);
|
||||
string password = "";
|
||||
bool usingUUID = false;
|
||||
if (args.Parameters.Count == 0 && !TShock.Config.DisableUUIDLogin)
|
||||
if (args.Parameters.Count == 0 && !TShock.Config.Settings.DisableUUIDLogin)
|
||||
{
|
||||
if (PlayerHooks.OnPlayerPreLogin(args.Player, args.Player.Name, ""))
|
||||
return;
|
||||
|
|
@ -785,7 +785,7 @@ namespace TShockAPI
|
|||
return;
|
||||
password = args.Parameters[0];
|
||||
}
|
||||
else if (args.Parameters.Count == 2 && TShock.Config.AllowLoginAnyUsername)
|
||||
else if (args.Parameters.Count == 2 && TShock.Config.Settings.AllowLoginAnyUsername)
|
||||
{
|
||||
if (String.IsNullOrEmpty(args.Parameters[0]))
|
||||
{
|
||||
|
|
@ -814,7 +814,7 @@ namespace TShockAPI
|
|||
args.Player.SendErrorMessage("A user account by that name does not exist.");
|
||||
}
|
||||
else if (account.VerifyPassword(password) ||
|
||||
(usingUUID && account.UUID == args.Player.UUID && !TShock.Config.DisableUUIDLogin &&
|
||||
(usingUUID && account.UUID == args.Player.UUID && !TShock.Config.Settings.DisableUUIDLogin &&
|
||||
!String.IsNullOrWhiteSpace(args.Player.UUID)))
|
||||
{
|
||||
args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, account.ID);
|
||||
|
|
@ -847,7 +847,7 @@ namespace TShockAPI
|
|||
args.Player.SendSuccessMessage("Authenticated as " + account.Name + " successfully.");
|
||||
|
||||
TShock.Log.ConsoleInfo(args.Player.Name + " authenticated successfully as user: " + account.Name + ".");
|
||||
if ((args.Player.LoginHarassed) && (TShock.Config.RememberLeavePos))
|
||||
if ((args.Player.LoginHarassed) && (TShock.Config.Settings.RememberLeavePos))
|
||||
{
|
||||
if (TShock.RememberedPos.GetLeavePos(args.Player.Name, args.Player.IP) != Vector2.Zero)
|
||||
{
|
||||
|
|
@ -863,7 +863,7 @@ namespace TShockAPI
|
|||
}
|
||||
else
|
||||
{
|
||||
if (usingUUID && !TShock.Config.DisableUUIDLogin)
|
||||
if (usingUUID && !TShock.Config.Settings.DisableUUIDLogin)
|
||||
{
|
||||
args.Player.SendErrorMessage("UUID does not match this character!");
|
||||
}
|
||||
|
|
@ -916,7 +916,7 @@ namespace TShockAPI
|
|||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
args.Player.SendErrorMessage("Password must be greater than or equal to " + TShock.Config.MinimumPasswordLength + " characters.");
|
||||
args.Player.SendErrorMessage("Password must be greater than or equal to " + TShock.Config.Settings.MinimumPasswordLength + " characters.");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -954,11 +954,11 @@ namespace TShockAPI
|
|||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
args.Player.SendErrorMessage("Password must be greater than or equal to " + TShock.Config.MinimumPasswordLength + " characters.");
|
||||
args.Player.SendErrorMessage("Password must be greater than or equal to " + TShock.Config.Settings.MinimumPasswordLength + " characters.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (args.Parameters.Count == 2 && TShock.Config.AllowRegisterAnyUsername)
|
||||
else if (args.Parameters.Count == 2 && TShock.Config.Settings.AllowRegisterAnyUsername)
|
||||
{
|
||||
account.Name = args.Parameters[0];
|
||||
echoPassword = args.Parameters[1];
|
||||
|
|
@ -968,7 +968,7 @@ namespace TShockAPI
|
|||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
args.Player.SendErrorMessage("Password must be greater than or equal to " + TShock.Config.MinimumPasswordLength + " characters.");
|
||||
args.Player.SendErrorMessage("Password must be greater than or equal to " + TShock.Config.Settings.MinimumPasswordLength + " characters.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -978,7 +978,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
account.Group = TShock.Config.DefaultRegistrationGroupName; // FIXME -- we should get this from the DB. --Why?
|
||||
account.Group = TShock.Config.Settings.DefaultRegistrationGroupName; // FIXME -- we should get this from the DB. --Why?
|
||||
account.UUID = args.Player.UUID;
|
||||
|
||||
if (TShock.UserAccounts.GetUserAccountByName(account.Name) == null && account.Name != TSServerPlayer.AccountName) // Cheap way of checking for existance of a user
|
||||
|
|
@ -1025,7 +1025,7 @@ namespace TShockAPI
|
|||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
args.Player.SendErrorMessage("Password must be greater than or equal to " + TShock.Config.MinimumPasswordLength + " characters.");
|
||||
args.Player.SendErrorMessage("Password must be greater than or equal to " + TShock.Config.Settings.MinimumPasswordLength + " characters.");
|
||||
return;
|
||||
}
|
||||
account.Group = args.Parameters[3];
|
||||
|
|
@ -1096,7 +1096,7 @@ namespace TShockAPI
|
|||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
args.Player.SendErrorMessage("Password must be greater than or equal to " + TShock.Config.MinimumPasswordLength + " characters.");
|
||||
args.Player.SendErrorMessage("Password must be greater than or equal to " + TShock.Config.Settings.MinimumPasswordLength + " characters.");
|
||||
}
|
||||
}
|
||||
// Group changing requires a username or IP address, and a new group to set
|
||||
|
|
@ -1156,7 +1156,7 @@ namespace TShockAPI
|
|||
private static void WorldInfo(CommandArgs args)
|
||||
{
|
||||
args.Player.SendInfoMessage("Information of the currently running world");
|
||||
args.Player.SendInfoMessage("Name: " + (TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName));
|
||||
args.Player.SendInfoMessage("Name: " + (TShock.Config.Settings.UseServerName ? TShock.Config.Settings.ServerName : Main.worldName));
|
||||
args.Player.SendInfoMessage("Size: {0}x{1}", Main.maxTilesX, Main.maxTilesY);
|
||||
args.Player.SendInfoMessage("ID: " + Main.worldID);
|
||||
args.Player.SendInfoMessage("Seed: " + WorldGen.currentWorldSeed);
|
||||
|
|
@ -1772,22 +1772,22 @@ namespace TShockAPI
|
|||
|
||||
private static void ForceHalloween(CommandArgs args)
|
||||
{
|
||||
TShock.Config.ForceHalloween = !TShock.Config.ForceHalloween;
|
||||
TShock.Config.Settings.ForceHalloween = !TShock.Config.Settings.ForceHalloween;
|
||||
Main.checkHalloween();
|
||||
if (args.Silent)
|
||||
args.Player.SendInfoMessage("{0}abled halloween mode!", (TShock.Config.ForceHalloween ? "en" : "dis"));
|
||||
args.Player.SendInfoMessage("{0}abled halloween mode!", (TShock.Config.Settings.ForceHalloween ? "en" : "dis"));
|
||||
else
|
||||
TSPlayer.All.SendInfoMessage("{0} {1}abled halloween mode!", args.Player.Name, (TShock.Config.ForceHalloween ? "en" : "dis"));
|
||||
TSPlayer.All.SendInfoMessage("{0} {1}abled halloween mode!", args.Player.Name, (TShock.Config.Settings.ForceHalloween ? "en" : "dis"));
|
||||
}
|
||||
|
||||
private static void ForceXmas(CommandArgs args)
|
||||
{
|
||||
TShock.Config.ForceXmas = !TShock.Config.ForceXmas;
|
||||
TShock.Config.Settings.ForceXmas = !TShock.Config.Settings.ForceXmas;
|
||||
Main.checkXMas();
|
||||
if (args.Silent)
|
||||
args.Player.SendInfoMessage("{0}abled Christmas mode!", (TShock.Config.ForceXmas ? "en" : "dis"));
|
||||
args.Player.SendInfoMessage("{0}abled Christmas mode!", (TShock.Config.Settings.ForceXmas ? "en" : "dis"));
|
||||
else
|
||||
TSPlayer.All.SendInfoMessage("{0} {1}abled Christmas mode!", args.Player.Name, (TShock.Config.ForceXmas ? "en" : "dis"));
|
||||
TSPlayer.All.SendInfoMessage("{0} {1}abled Christmas mode!", args.Player.Name, (TShock.Config.Settings.ForceXmas ? "en" : "dis"));
|
||||
}
|
||||
|
||||
private static void TempGroup(CommandArgs args)
|
||||
|
|
@ -1898,8 +1898,8 @@ namespace TShockAPI
|
|||
|
||||
TShock.Utils.Broadcast(
|
||||
"(Server Broadcast) " + message,
|
||||
Convert.ToByte(TShock.Config.BroadcastRGB[0]), Convert.ToByte(TShock.Config.BroadcastRGB[1]),
|
||||
Convert.ToByte(TShock.Config.BroadcastRGB[2]));
|
||||
Convert.ToByte(TShock.Config.Settings.BroadcastRGB[0]), Convert.ToByte(TShock.Config.Settings.BroadcastRGB[1]),
|
||||
Convert.ToByte(TShock.Config.Settings.BroadcastRGB[2]));
|
||||
}
|
||||
|
||||
private static void Off(CommandArgs args)
|
||||
|
|
@ -2395,7 +2395,7 @@ namespace TShockAPI
|
|||
TSPlayer.All.SendData(PacketTypes.WorldInfo);
|
||||
args.Player.SendSuccessMessage("Hardmode is now off.");
|
||||
}
|
||||
else if (!TShock.Config.DisableHardmode)
|
||||
else if (!TShock.Config.Settings.DisableHardmode)
|
||||
{
|
||||
WorldGen.StartHardmode();
|
||||
args.Player.SendSuccessMessage("Hardmode is now on.");
|
||||
|
|
@ -4192,7 +4192,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
string passwd = args.Parameters[0];
|
||||
TShock.Config.ServerPassword = passwd;
|
||||
TShock.Config.Settings.ServerPassword = passwd;
|
||||
args.Player.SendSuccessMessage(string.Format("Server password has been changed to: {0}.", passwd));
|
||||
}
|
||||
|
||||
|
|
@ -4220,13 +4220,13 @@ namespace TShockAPI
|
|||
{
|
||||
if (args.Parameters.Count == 0)
|
||||
{
|
||||
args.Player.SendInfoMessage("Current maximum spawns: {0}", TShock.Config.DefaultMaximumSpawns);
|
||||
args.Player.SendInfoMessage("Current maximum spawns: {0}", TShock.Config.Settings.DefaultMaximumSpawns);
|
||||
return;
|
||||
}
|
||||
|
||||
if (String.Equals(args.Parameters[0], "default", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
TShock.Config.DefaultMaximumSpawns = NPC.defaultMaxSpawns = 5;
|
||||
TShock.Config.Settings.DefaultMaximumSpawns = NPC.defaultMaxSpawns = 5;
|
||||
if (args.Silent)
|
||||
{
|
||||
args.Player.SendInfoMessage("Changed the maximum spawns to 5.");
|
||||
|
|
@ -4245,7 +4245,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
TShock.Config.DefaultMaximumSpawns = NPC.defaultMaxSpawns = maxSpawns;
|
||||
TShock.Config.Settings.DefaultMaximumSpawns = NPC.defaultMaxSpawns = maxSpawns;
|
||||
if (args.Silent)
|
||||
{
|
||||
args.Player.SendInfoMessage("Changed the maximum spawns to {0}.", maxSpawns);
|
||||
|
|
@ -4260,13 +4260,13 @@ namespace TShockAPI
|
|||
{
|
||||
if (args.Parameters.Count == 0)
|
||||
{
|
||||
args.Player.SendInfoMessage("Current spawn rate: {0}", TShock.Config.DefaultSpawnRate);
|
||||
args.Player.SendInfoMessage("Current spawn rate: {0}", TShock.Config.Settings.DefaultSpawnRate);
|
||||
return;
|
||||
}
|
||||
|
||||
if (String.Equals(args.Parameters[0], "default", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
TShock.Config.DefaultSpawnRate = NPC.defaultSpawnRate = 600;
|
||||
TShock.Config.Settings.DefaultSpawnRate = NPC.defaultSpawnRate = 600;
|
||||
if (args.Silent)
|
||||
{
|
||||
args.Player.SendInfoMessage("Changed the spawn rate to 600.");
|
||||
|
|
@ -4284,7 +4284,7 @@ namespace TShockAPI
|
|||
args.Player.SendWarningMessage("Invalid spawn rate!");
|
||||
return;
|
||||
}
|
||||
TShock.Config.DefaultSpawnRate = NPC.defaultSpawnRate = spawnRate;
|
||||
TShock.Config.Settings.DefaultSpawnRate = NPC.defaultSpawnRate = spawnRate;
|
||||
if (args.Silent)
|
||||
{
|
||||
args.Player.SendInfoMessage("Changed the spawn rate to {0}.", spawnRate);
|
||||
|
|
@ -5008,14 +5008,14 @@ namespace TShockAPI
|
|||
|
||||
private static void ToggleAntiBuild(CommandArgs args)
|
||||
{
|
||||
TShock.Config.DisableBuild = !TShock.Config.DisableBuild;
|
||||
TSPlayer.All.SendSuccessMessage(string.Format("Anti-build is now {0}.", (TShock.Config.DisableBuild ? "on" : "off")));
|
||||
TShock.Config.Settings.DisableBuild = !TShock.Config.Settings.DisableBuild;
|
||||
TSPlayer.All.SendSuccessMessage(string.Format("Anti-build is now {0}.", (TShock.Config.Settings.DisableBuild ? "on" : "off")));
|
||||
}
|
||||
|
||||
private static void ProtectSpawn(CommandArgs args)
|
||||
{
|
||||
TShock.Config.SpawnProtection = !TShock.Config.SpawnProtection;
|
||||
TSPlayer.All.SendSuccessMessage(string.Format("Spawn is now {0}.", (TShock.Config.SpawnProtection ? "protected" : "open")));
|
||||
TShock.Config.Settings.SpawnProtection = !TShock.Config.Settings.SpawnProtection;
|
||||
TSPlayer.All.SendSuccessMessage(string.Format("Spawn is now {0}.", (TShock.Config.Settings.SpawnProtection ? "protected" : "open")));
|
||||
}
|
||||
|
||||
#endregion World Protection Commands
|
||||
|
|
@ -5121,7 +5121,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
args.Player.SendSuccessMessage("Online Players ({0}/{1})", TShock.Utils.GetActivePlayerCount(), TShock.Config.MaxSlots);
|
||||
args.Player.SendSuccessMessage("Online Players ({0}/{1})", TShock.Utils.GetActivePlayerCount(), TShock.Config.Settings.MaxSlots);
|
||||
|
||||
var players = new List<string>();
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ using Rests;
|
|||
namespace TShockAPI
|
||||
{
|
||||
/// <summary>The config file class, which contains the configuration for a server that is serialized into JSON and deserialized on load.</summary>
|
||||
[Obsolete("Use TShockAPI.Configuration.TShockConfig", true)]
|
||||
public class ConfigFile
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ namespace TShockAPI.DB
|
|||
int res;
|
||||
if (database.GetSqlType() == SqlType.Mysql)
|
||||
{
|
||||
res = database.QueryScalar<int>("SELECT COUNT(name) FROM information_schema.tables WHERE table_schema = @0 and table_name = 'Bans'", TShock.Config.MySqlDbName);
|
||||
res = database.QueryScalar<int>("SELECT COUNT(name) FROM information_schema.tables WHERE table_schema = @0 and table_name = 'Bans'", TShock.Config.Settings.MySqlDbName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ namespace TShockAPI.DB
|
|||
{
|
||||
var inventory = new StringBuilder();
|
||||
|
||||
var items = new List<NetItem>(TShock.ServerSideCharacterConfig.StartingInventory);
|
||||
var items = new List<NetItem>(TShock.ServerSideCharacterConfig.Settings.StartingInventory);
|
||||
if (items.Count < NetItem.MaxInventory)
|
||||
items.AddRange(new NetItem[NetItem.MaxInventory - items.Count]);
|
||||
|
||||
|
|
@ -135,10 +135,10 @@ namespace TShockAPI.DB
|
|||
{
|
||||
database.Query("INSERT INTO tsCharacter (Account, Health, MaxHealth, Mana, MaxMana, Inventory, spawnX, spawnY, questsCompleted) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8);",
|
||||
account.ID,
|
||||
TShock.ServerSideCharacterConfig.StartingHealth,
|
||||
TShock.ServerSideCharacterConfig.StartingHealth,
|
||||
TShock.ServerSideCharacterConfig.StartingMana,
|
||||
TShock.ServerSideCharacterConfig.StartingMana,
|
||||
TShock.ServerSideCharacterConfig.Settings.StartingHealth,
|
||||
TShock.ServerSideCharacterConfig.Settings.StartingHealth,
|
||||
TShock.ServerSideCharacterConfig.Settings.StartingMana,
|
||||
TShock.ServerSideCharacterConfig.Settings.StartingMana,
|
||||
initialItems,
|
||||
-1,
|
||||
-1,
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ namespace TShockAPI.DB
|
|||
// Load Permissions from the DB
|
||||
LoadPermisions();
|
||||
|
||||
Group.DefaultGroup = GetGroupByName(TShock.Config.DefaultGuestGroupName);
|
||||
Group.DefaultGroup = GetGroupByName(TShock.Config.Settings.DefaultGuestGroupName);
|
||||
}
|
||||
|
||||
private void AddDefaultGroup(string name, string parent, string permissions)
|
||||
|
|
@ -271,7 +271,7 @@ namespace TShockAPI.DB
|
|||
group.Parent = parent;
|
||||
}
|
||||
|
||||
string query = (TShock.Config.StorageType.ToLower() == "sqlite")
|
||||
string query = (TShock.Config.Settings.StorageType.ToLower() == "sqlite")
|
||||
? "INSERT OR IGNORE INTO GroupList (GroupName, Parent, Commands, ChatColor) VALUES (@0, @1, @2, @3);"
|
||||
: "INSERT IGNORE INTO GroupList SET GroupName=@0, Parent=@1, Commands=@2, ChatColor=@3";
|
||||
if (database.Query(query, name, parentname, permissions, chatcolor) == 1)
|
||||
|
|
@ -389,15 +389,15 @@ namespace TShockAPI.DB
|
|||
}
|
||||
|
||||
// Read the config file to prevent the possible loss of any unsaved changes
|
||||
TShock.Config = ConfigFile.Read(FileTools.ConfigPath, out bool writeConfig);
|
||||
if (TShock.Config.DefaultGuestGroupName == oldGroup.Name)
|
||||
TShock.Config.Read(FileTools.ConfigPath, out bool writeConfig);
|
||||
if (TShock.Config.Settings.DefaultGuestGroupName == oldGroup.Name)
|
||||
{
|
||||
TShock.Config.DefaultGuestGroupName = newGroup.Name;
|
||||
TShock.Config.Settings.DefaultGuestGroupName = newGroup.Name;
|
||||
Group.DefaultGroup = newGroup;
|
||||
}
|
||||
if (TShock.Config.DefaultRegistrationGroupName == oldGroup.Name)
|
||||
if (TShock.Config.Settings.DefaultRegistrationGroupName == oldGroup.Name)
|
||||
{
|
||||
TShock.Config.DefaultRegistrationGroupName = newGroup.Name;
|
||||
TShock.Config.Settings.DefaultRegistrationGroupName = newGroup.Name;
|
||||
}
|
||||
if (writeConfig)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -496,7 +496,7 @@ namespace TShockAPI.DB
|
|||
return;
|
||||
}
|
||||
|
||||
if (currentWorkFactor < TShock.Config.BCryptWorkFactor)
|
||||
if (currentWorkFactor < TShock.Config.Settings.BCryptWorkFactor)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -513,13 +513,13 @@ namespace TShockAPI.DB
|
|||
/// <param name="password">The plain text password to hash</param>
|
||||
public void CreateBCryptHash(string password)
|
||||
{
|
||||
if (password.Trim().Length < Math.Max(4, TShock.Config.MinimumPasswordLength))
|
||||
if (password.Trim().Length < Math.Max(4, TShock.Config.Settings.MinimumPasswordLength))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("password", "Password must be > " + TShock.Config.MinimumPasswordLength + " characters.");
|
||||
throw new ArgumentOutOfRangeException("password", "Password must be > " + TShock.Config.Settings.MinimumPasswordLength + " characters.");
|
||||
}
|
||||
try
|
||||
{
|
||||
Password = BCrypt.Net.BCrypt.HashPassword(password.Trim(), TShock.Config.BCryptWorkFactor);
|
||||
Password = BCrypt.Net.BCrypt.HashPassword(password.Trim(), TShock.Config.Settings.BCryptWorkFactor);
|
||||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
|
|
@ -533,9 +533,9 @@ namespace TShockAPI.DB
|
|||
/// <param name="workFactor">The work factor to use in generating the password hash</param>
|
||||
public void CreateBCryptHash(string password, int workFactor)
|
||||
{
|
||||
if (password.Trim().Length < Math.Max(4, TShock.Config.MinimumPasswordLength))
|
||||
if (password.Trim().Length < Math.Max(4, TShock.Config.Settings.MinimumPasswordLength))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("password", "Password must be > " + TShock.Config.MinimumPasswordLength + " characters.");
|
||||
throw new ArgumentOutOfRangeException("password", "Password must be > " + TShock.Config.Settings.MinimumPasswordLength + " characters.");
|
||||
}
|
||||
Password = BCrypt.Net.BCrypt.HashPassword(password.Trim(), workFactor);
|
||||
}
|
||||
|
|
@ -563,8 +563,8 @@ namespace TShockAPI.DB
|
|||
if (bytes == null)
|
||||
throw new NullReferenceException("bytes");
|
||||
Func<HashAlgorithm> func;
|
||||
if (!HashTypes.TryGetValue(TShock.Config.HashAlgorithm.ToLower(), out func))
|
||||
throw new NotSupportedException("Hashing algorithm {0} is not supported".SFormat(TShock.Config.HashAlgorithm.ToLower()));
|
||||
if (!HashTypes.TryGetValue(TShock.Config.Settings.HashAlgorithm.ToLower(), out func))
|
||||
throw new NotSupportedException("Hashing algorithm {0} is not supported".SFormat(TShock.Config.Settings.HashAlgorithm.ToLower()));
|
||||
|
||||
using (var hash = func())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using TShockAPI.ServerSideCharacters;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
|
|
@ -110,7 +109,7 @@ namespace TShockAPI
|
|||
bool writeConfig = true; // Default to true if the file doesn't exist
|
||||
if (File.Exists(ConfigPath))
|
||||
{
|
||||
TShock.Config = ConfigFile.Read(ConfigPath, out writeConfig);
|
||||
TShock.Config.Read(ConfigPath, out writeConfig);
|
||||
}
|
||||
if (writeConfig)
|
||||
{
|
||||
|
|
@ -121,21 +120,21 @@ namespace TShockAPI
|
|||
bool writeSSCConfig = true; // Default to true if the file doesn't exist
|
||||
if (File.Exists(ServerSideCharacterConfigPath))
|
||||
{
|
||||
TShock.ServerSideCharacterConfig =
|
||||
ServerSideConfig.Read(ServerSideCharacterConfigPath, out writeSSCConfig);
|
||||
TShock.ServerSideCharacterConfig.Read(ServerSideCharacterConfigPath, out writeSSCConfig);
|
||||
}
|
||||
if (writeSSCConfig)
|
||||
{
|
||||
// Add all the missing config properties in the json file
|
||||
TShock.ServerSideCharacterConfig = new ServerSideConfig
|
||||
TShock.ServerSideCharacterConfig = new Configuration.ServerSideConfig
|
||||
{
|
||||
StartingInventory =
|
||||
Settings = { StartingInventory =
|
||||
new List<NetItem>
|
||||
{
|
||||
new NetItem(-15, 1, 0),
|
||||
new NetItem(-13, 1, 0),
|
||||
new NetItem(-16, 1, 0)
|
||||
}
|
||||
}
|
||||
};
|
||||
TShock.ServerSideCharacterConfig.Write(ServerSideCharacterConfigPath);
|
||||
}
|
||||
|
|
@ -148,7 +147,7 @@ namespace TShockAPI
|
|||
/// <returns>true/false</returns>
|
||||
public static bool OnWhitelist(string ip)
|
||||
{
|
||||
if (!TShock.Config.EnableWhitelist)
|
||||
if (!TShock.Config.Settings.EnableWhitelist)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -173,20 +172,45 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks for a 'Settings' token in the json object. If one is not found, returns a new json object with all tokens of the previous object added
|
||||
/// as children to a root 'Settings' token
|
||||
/// </summary>
|
||||
/// <param name="json"></param>
|
||||
/// <returns></returns>
|
||||
internal static JObject AttemptConfigUpgrade(string json)
|
||||
{
|
||||
JObject cfg = JObject.Parse(json);
|
||||
|
||||
if (cfg.SelectToken("Settings") == null)
|
||||
{
|
||||
JObject newCfg = new JObject
|
||||
{
|
||||
{ "Settings", cfg }
|
||||
};
|
||||
cfg = newCfg;
|
||||
}
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
internal static TSettings LoadConfigAndCheckForMissingFields<TSettings>(string json, out bool anyMissingFields)
|
||||
{
|
||||
return LoadConfigAndCheckForMissingFields<TSettings>(JObject.Parse(json), out anyMissingFields);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse some json text and also return whether any fields are missing from the json
|
||||
/// Parses a JObject into a TSettings object, also emitting a bool indicating if any of the TSetting's fields were missing from the JObject
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the config file object</typeparam>
|
||||
/// <param name="json">The json text to parse</param>
|
||||
/// <typeparam name="TSettings">The type of the config file object</typeparam>
|
||||
/// <param name="jObject">The json object to parse</param>
|
||||
/// <param name="anyMissingFields">Whether any fields are missing from the config</param>
|
||||
/// <returns>The config object</returns>
|
||||
internal static T LoadConfigAndCheckForMissingFields<T>(string json, out bool anyMissingFields)
|
||||
internal static TSettings LoadConfigAndCheckForMissingFields<TSettings>(JObject jObject, out bool anyMissingFields)
|
||||
{
|
||||
JObject jObject = JObject.Parse(json);
|
||||
|
||||
anyMissingFields = false;
|
||||
var configFields = new HashSet<string>(typeof(T).GetFields()
|
||||
var configFields = new HashSet<string>(typeof(Configuration.ConfigFile<TSettings>).GetFields()
|
||||
.Where(field => !field.IsStatic)
|
||||
.Select(field => field.Name));
|
||||
var jsonFields = new HashSet<string>(jObject
|
||||
|
|
@ -196,7 +220,7 @@ namespace TShockAPI
|
|||
.Select(field => field.Name));
|
||||
anyMissingFields = !configFields.SetEquals(jsonFields);
|
||||
|
||||
return jObject.ToObject<T>();
|
||||
return jObject.SelectToken("Settings").ToObject<TSettings>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2305,13 +2305,13 @@ namespace TShockAPI
|
|||
NetMessage.SendData((int)PacketTypes.PlayerInfo, -1, args.Player.Index, NetworkText.FromLiteral(args.Player.Name), args.Player.Index);
|
||||
return true;
|
||||
}
|
||||
if (TShock.Config.MediumcoreOnly && difficulty < 1)
|
||||
if (TShock.Config.Settings.MediumcoreOnly && difficulty < 1)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerInfo rejected mediumcore required");
|
||||
args.Player.Kick("You need to join with a mediumcore player or higher.", true, true);
|
||||
return true;
|
||||
}
|
||||
if (TShock.Config.HardcoreOnly && difficulty < 2)
|
||||
if (TShock.Config.Settings.HardcoreOnly && difficulty < 2)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerInfo rejected hardcore required");
|
||||
args.Player.Kick("You need to join with a hardcore player.", true, true);
|
||||
|
|
@ -2359,7 +2359,7 @@ namespace TShockAPI
|
|||
{
|
||||
args.Player.PlayerData.StoreSlot(slot, type, prefix, stack);
|
||||
}
|
||||
else if (Main.ServerSideCharacter && TShock.Config.DisableLoginBeforeJoin && !bypassTrashCanCheck &&
|
||||
else if (Main.ServerSideCharacter && TShock.Config.Settings.DisableLoginBeforeJoin && !bypassTrashCanCheck &&
|
||||
args.Player.HasSentInventory && !args.Player.HasPermission(Permissions.bypassssc))
|
||||
{
|
||||
// The player might have moved an item to their trash can before they performed a single login attempt yet.
|
||||
|
|
@ -2383,7 +2383,7 @@ namespace TShockAPI
|
|||
args.Player.PlayerData = new PlayerData(args.Player);
|
||||
args.Player.PlayerData.CopyCharacter(args.Player);
|
||||
|
||||
if (account != null && !TShock.Config.DisableUUIDLogin)
|
||||
if (account != null && !TShock.Config.Settings.DisableUUIDLogin)
|
||||
{
|
||||
if (account.UUID == args.Player.UUID)
|
||||
{
|
||||
|
|
@ -2424,13 +2424,13 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
}
|
||||
else if (account != null && !TShock.Config.DisableLoginBeforeJoin)
|
||||
else if (account != null && !TShock.Config.Settings.DisableLoginBeforeJoin)
|
||||
{
|
||||
args.Player.RequiresPassword = true;
|
||||
NetMessage.SendData((int)PacketTypes.PasswordRequired, args.Player.Index);
|
||||
return true;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(TShock.Config.ServerPassword))
|
||||
else if (!string.IsNullOrEmpty(TShock.Config.Settings.ServerPassword))
|
||||
{
|
||||
args.Player.RequiresPassword = true;
|
||||
NetMessage.SendData((int)PacketTypes.PasswordRequired, args.Player.Index);
|
||||
|
|
@ -2448,11 +2448,11 @@ namespace TShockAPI
|
|||
if (OnGetSection(args.Player, args.Data, args.Data.ReadInt32(), args.Data.ReadInt32()))
|
||||
return true;
|
||||
|
||||
if (TShock.Utils.GetActivePlayerCount() + 1 > TShock.Config.MaxSlots &&
|
||||
if (TShock.Utils.GetActivePlayerCount() + 1 > TShock.Config.Settings.MaxSlots &&
|
||||
!args.Player.HasPermission(Permissions.reservedslot))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("GetDataHandlers / HandleGetSection rejected reserve slot");
|
||||
args.Player.Kick(TShock.Config.ServerFullReason, true, true);
|
||||
args.Player.Kick(TShock.Config.Settings.ServerFullReason, true, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2557,7 +2557,7 @@ namespace TShockAPI
|
|||
if (OnPlayerHP(args.Player, args.Data, plr, cur, max) || cur <= 0 || max <= 0 || args.Player.IgnoreSSCPackets)
|
||||
return true;
|
||||
|
||||
if (max > TShock.Config.MaxHP && !args.Player.HasPermission(Permissions.ignorehp))
|
||||
if (max > TShock.Config.Settings.MaxHP && !args.Player.HasPermission(Permissions.ignorehp))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerHp rejected over max hp {0}", args.Player.Name);
|
||||
args.Player.Disable("Maximum HP beyond limit", DisableFlags.WriteToLogAndConsole);
|
||||
|
|
@ -2771,7 +2771,7 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
|
||||
if (TShock.ProjectileBans.ProjectileIsBanned(type, args.Player) && !TShock.Config.IgnoreProjKill)
|
||||
if (TShock.ProjectileBans.ProjectileIsBanned(type, args.Player) && !TShock.Config.Settings.IgnoreProjKill)
|
||||
{
|
||||
// According to 2012 deathmax, this is a workaround to fix skeletron prime issues
|
||||
// https://github.com/Pryaxis/TShock/commit/a5aa9231239926f361b7246651e32144bbf28dda
|
||||
|
|
@ -2808,7 +2808,7 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
|
||||
string pvpMode = TShock.Config.PvPMode.ToLowerInvariant();
|
||||
string pvpMode = TShock.Config.Settings.PvPMode.ToLowerInvariant();
|
||||
if (pvpMode == "disabled" || pvpMode == "always" || (DateTime.UtcNow - args.Player.LastPvPTeamChange).TotalSeconds < 5)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("GetDataHandlers / HandleTogglePvp rejected fastswitch {0}", args.Player.Name);
|
||||
|
|
@ -2869,7 +2869,7 @@ namespace TShockAPI
|
|||
|
||||
args.Player.ActiveChest = id;
|
||||
|
||||
if (!args.Player.HasBuildPermission(x, y) && TShock.Config.RegionProtectChests)
|
||||
if (!args.Player.HasBuildPermission(x, y) && TShock.Config.Settings.RegionProtectChests)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("GetDataHandlers / HandleChestActive rejected build permission and region check {0}", args.Player.Name);
|
||||
args.Player.SendData(PacketTypes.ChestOpen, "", -1);
|
||||
|
|
@ -2923,7 +2923,7 @@ namespace TShockAPI
|
|||
return true;
|
||||
|
||||
var account = TShock.UserAccounts.GetUserAccountByName(args.Player.Name);
|
||||
if (account != null && !TShock.Config.DisableLoginBeforeJoin)
|
||||
if (account != null && !TShock.Config.Settings.DisableLoginBeforeJoin)
|
||||
{
|
||||
if (account.VerifyPassword(password))
|
||||
{
|
||||
|
|
@ -2970,9 +2970,9 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(TShock.Config.ServerPassword))
|
||||
if (!string.IsNullOrEmpty(TShock.Config.Settings.ServerPassword))
|
||||
{
|
||||
if (TShock.Config.ServerPassword == password)
|
||||
if (TShock.Config.Settings.ServerPassword == password)
|
||||
{
|
||||
args.Player.RequiresPassword = false;
|
||||
if (args.Player.State == 1)
|
||||
|
|
@ -3005,9 +3005,9 @@ namespace TShockAPI
|
|||
if (OnPlayerMana(args.Player, args.Data, plr, cur, max) || cur < 0 || max < 0 || args.Player.IgnoreSSCPackets)
|
||||
return true;
|
||||
|
||||
if (max > TShock.Config.MaxMP && !args.Player.HasPermission(Permissions.ignoremp))
|
||||
if (max > TShock.Config.Settings.MaxMP && !args.Player.HasPermission(Permissions.ignoremp))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerMana rejected max mana {0} {1}/{2}", args.Player.Name, max, TShock.Config.MaxMP);
|
||||
TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerMana rejected max mana {0} {1}/{2}", args.Player.Name, max, TShock.Config.Settings.MaxMP);
|
||||
args.Player.Disable("Maximum MP beyond limit", DisableFlags.WriteToLogAndConsole);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -3092,7 +3092,7 @@ namespace TShockAPI
|
|||
{
|
||||
var buff = args.Data.ReadUInt16();
|
||||
|
||||
if (buff == 10 && TShock.Config.DisableInvisPvP && args.TPlayer.hostile)
|
||||
if (buff == 10 && TShock.Config.Settings.DisableInvisPvP && args.TPlayer.hostile)
|
||||
buff = 0;
|
||||
|
||||
if (Netplay.Clients[args.TPlayer.whoAmI].State < 2 && (buff == 156 || buff == 47 || buff == 149))
|
||||
|
|
@ -3125,7 +3125,7 @@ namespace TShockAPI
|
|||
if (OnNPCSpecial(args.Player, args.Data, id, type))
|
||||
return true;
|
||||
|
||||
if (type == 1 && TShock.Config.DisableDungeonGuardian)
|
||||
if (type == 1 && TShock.Config.Settings.DisableDungeonGuardian)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpecial rejected type 1 for {0}", args.Player.Name);
|
||||
args.Player.SendMessage("The Dungeon Guardian returned you to your spawn point.", Color.Purple);
|
||||
|
|
@ -3275,7 +3275,7 @@ namespace TShockAPI
|
|||
thing = String.Format("summoned the {0}", npc.FullName);
|
||||
break;
|
||||
}
|
||||
if (TShock.Config.AnonymousBossInvasions)
|
||||
if (TShock.Config.Settings.AnonymousBossInvasions)
|
||||
TShock.Utils.SendLogs(string.Format("{0} {1}!", args.Player.Name, thing), Color.PaleVioletRed, args.Player);
|
||||
else
|
||||
TShock.Utils.Broadcast(String.Format("{0} {1}!", args.Player.Name, thing), 175, 75, 255);
|
||||
|
|
@ -3712,7 +3712,7 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
|
||||
if (TShock.Config.AnonymousBossInvasions)
|
||||
if (TShock.Config.Settings.AnonymousBossInvasions)
|
||||
TShock.Utils.SendLogs(string.Format("{0} started the Old One's Army event!", args.Player.Name), Color.PaleVioletRed, args.Player);
|
||||
else
|
||||
TShock.Utils.Broadcast(string.Format("{0} started the Old One's Army event!", args.Player.Name), 175, 75, 255);
|
||||
|
|
@ -3754,14 +3754,14 @@ namespace TShockAPI
|
|||
return true;
|
||||
|
||||
args.Player.Dead = true;
|
||||
args.Player.RespawnTimer = TShock.Config.RespawnSeconds;
|
||||
args.Player.RespawnTimer = TShock.Config.Settings.RespawnSeconds;
|
||||
|
||||
foreach (NPC npc in Main.npc)
|
||||
{
|
||||
if (npc.active && (npc.boss || npc.type == 13 || npc.type == 14 || npc.type == 15) &&
|
||||
Math.Abs(args.TPlayer.Center.X - npc.Center.X) + Math.Abs(args.TPlayer.Center.Y - npc.Center.Y) < 4000f)
|
||||
{
|
||||
args.Player.RespawnTimer = TShock.Config.RespawnBossSeconds;
|
||||
args.Player.RespawnTimer = TShock.Config.Settings.RespawnBossSeconds;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -3770,10 +3770,10 @@ namespace TShockAPI
|
|||
if (args.TPlayer.difficulty == 1 || args.TPlayer.difficulty == 2) // Player is not softcore
|
||||
{
|
||||
bool mediumcore = args.TPlayer.difficulty == 1;
|
||||
bool shouldBan = mediumcore ? TShock.Config.BanOnMediumcoreDeath : TShock.Config.BanOnHardcoreDeath;
|
||||
bool shouldKick = mediumcore ? TShock.Config.KickOnMediumcoreDeath : TShock.Config.KickOnHardcoreDeath;
|
||||
string banReason = mediumcore ? TShock.Config.MediumcoreBanReason : TShock.Config.HardcoreBanReason;
|
||||
string kickReason = mediumcore ? TShock.Config.MediumcoreKickReason : TShock.Config.HardcoreKickReason;
|
||||
bool shouldBan = mediumcore ? TShock.Config.Settings.BanOnMediumcoreDeath : TShock.Config.Settings.BanOnHardcoreDeath;
|
||||
bool shouldKick = mediumcore ? TShock.Config.Settings.KickOnMediumcoreDeath : TShock.Config.Settings.KickOnHardcoreDeath;
|
||||
string banReason = mediumcore ? TShock.Config.Settings.MediumcoreBanReason : TShock.Config.Settings.HardcoreBanReason;
|
||||
string kickReason = mediumcore ? TShock.Config.Settings.MediumcoreKickReason : TShock.Config.Settings.HardcoreKickReason;
|
||||
|
||||
if (shouldBan)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -340,11 +340,11 @@ namespace TShockAPI
|
|||
public SuperAdminGroup()
|
||||
: base("superadmin")
|
||||
{
|
||||
R = (byte)TShock.Config.SuperAdminChatRGB[0];
|
||||
G = (byte)TShock.Config.SuperAdminChatRGB[1];
|
||||
B = (byte)TShock.Config.SuperAdminChatRGB[2];
|
||||
Prefix = TShock.Config.SuperAdminChatPrefix;
|
||||
Suffix = TShock.Config.SuperAdminChatSuffix;
|
||||
R = (byte)TShock.Config.Settings.SuperAdminChatRGB[0];
|
||||
G = (byte)TShock.Config.Settings.SuperAdminChatRGB[1];
|
||||
B = (byte)TShock.Config.Settings.SuperAdminChatRGB[2];
|
||||
Prefix = TShock.Config.Settings.SuperAdminChatPrefix;
|
||||
Suffix = TShock.Config.Settings.SuperAdminChatSuffix;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -430,10 +430,10 @@ namespace TShockAPI.Handlers
|
|||
}
|
||||
|
||||
var rectSize = args.Width * args.Length;
|
||||
if (rectSize > TShock.Config.TileRectangleSizeThreshold)
|
||||
if (rectSize > TShock.Config.Settings.TileRectangleSizeThreshold)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / SendTileRect rejected from non-vanilla tilemod from {0}", args.Player.Name);
|
||||
if (TShock.Config.KickOnTileRectangleSizeThresholdBroken)
|
||||
if (TShock.Config.Settings.KickOnTileRectangleSizeThresholdBroken)
|
||||
{
|
||||
args.Player.Kick("Unexpected tile threshold reached");
|
||||
}
|
||||
|
|
@ -509,7 +509,7 @@ namespace TShockAPI.Handlers
|
|||
/// <param name="newTiles">New tiles to be visualised</param>
|
||||
public static void VisualiseTileSetDiff(int tileX, int tileY, int width, int height, NetTile[,] newTiles)
|
||||
{
|
||||
if (TShock.Config.DebugLogs)
|
||||
if (TShock.Config.Settings.DebugLogs)
|
||||
{
|
||||
char pad = '0';
|
||||
for (int y = 0; y < height; y++)
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ namespace TShockAPI
|
|||
/// <param name="args">The standard event arguments.</param>
|
||||
internal void OnSecondlyUpdate(EventArgs args)
|
||||
{
|
||||
DisableFlags disableFlags = TShock.Config.DisableSecondUpdateLogs ? DisableFlags.WriteToConsole : DisableFlags.WriteToLogAndConsole;
|
||||
DisableFlags disableFlags = TShock.Config.Settings.DisableSecondUpdateLogs ? DisableFlags.WriteToConsole : DisableFlags.WriteToLogAndConsole;
|
||||
|
||||
foreach (TSPlayer player in TShock.Players)
|
||||
{
|
||||
|
|
@ -153,7 +153,7 @@ namespace TShockAPI
|
|||
|
||||
internal void OnPlayerUpdate(object sender, PlayerUpdateEventArgs args)
|
||||
{
|
||||
DisableFlags disableFlags = TShock.Config.DisableSecondUpdateLogs ? DisableFlags.WriteToConsole : DisableFlags.WriteToLogAndConsole;
|
||||
DisableFlags disableFlags = TShock.Config.Settings.DisableSecondUpdateLogs ? DisableFlags.WriteToConsole : DisableFlags.WriteToLogAndConsole;
|
||||
bool useItem = args.Control.IsUsingItem;
|
||||
TSPlayer player = args.Player;
|
||||
string itemName = player.TPlayer.inventory[args.SelectedItem].Name;
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ namespace TShockAPI
|
|||
public class PlayerData
|
||||
{
|
||||
public NetItem[] inventory = new NetItem[NetItem.MaxInventory];
|
||||
public int health = TShock.ServerSideCharacterConfig.StartingHealth;
|
||||
public int maxHealth = TShock.ServerSideCharacterConfig.StartingHealth;
|
||||
public int mana = TShock.ServerSideCharacterConfig.StartingMana;
|
||||
public int maxMana = TShock.ServerSideCharacterConfig.StartingMana;
|
||||
public int health = TShock.ServerSideCharacterConfig.Settings.StartingHealth;
|
||||
public int maxHealth = TShock.ServerSideCharacterConfig.Settings.StartingHealth;
|
||||
public int mana = TShock.ServerSideCharacterConfig.Settings.StartingMana;
|
||||
public int maxMana = TShock.ServerSideCharacterConfig.Settings.StartingMana;
|
||||
public bool exists;
|
||||
public int spawnX = -1;
|
||||
public int spawnY = -1;
|
||||
|
|
@ -58,9 +58,9 @@ namespace TShockAPI
|
|||
this.inventory[i] = new NetItem();
|
||||
}
|
||||
|
||||
for (int i = 0; i < TShock.ServerSideCharacterConfig.StartingInventory.Count; i++)
|
||||
for (int i = 0; i < TShock.ServerSideCharacterConfig.Settings.StartingInventory.Count; i++)
|
||||
{
|
||||
var item = TShock.ServerSideCharacterConfig.StartingInventory[i];
|
||||
var item = TShock.ServerSideCharacterConfig.Settings.StartingInventory[i];
|
||||
StoreSlot(i, item.NetId, item.PrefixId, item.Stack);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace TShockAPI
|
|||
|
||||
private void OnGemLockToggle(object sender, GetDataHandlers.GemLockToggleEventArgs e)
|
||||
{
|
||||
if (TShock.Config.RegionProtectGemLocks)
|
||||
if (TShock.Config.Settings.RegionProtectGemLocks)
|
||||
{
|
||||
if (!_regionManager.CanBuild(e.X, e.Y, e.Player))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ namespace Rests
|
|||
tokenBucketTimer = new Timer((e) =>
|
||||
{
|
||||
DegradeBucket();
|
||||
}, null, TimeSpan.Zero, TimeSpan.FromMinutes(Math.Max(TShock.Config.RESTRequestBucketDecreaseIntervalMinutes, 1)));
|
||||
}, null, TimeSpan.Zero, TimeSpan.FromMinutes(Math.Max(TShock.Config.Settings.RESTRequestBucketDecreaseIntervalMinutes, 1)));
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -356,7 +356,7 @@ namespace Rests
|
|||
protected virtual object ExecuteCommand(RestCommand cmd, RestVerbs verbs, IParameterCollection parms, IRequest request, IHttpContext context)
|
||||
{
|
||||
object result = cmd.Execute(verbs, parms, request, context);
|
||||
if (cmd.DoLog && TShock.Config.LogRest)
|
||||
if (cmd.DoLog && TShock.Config.Settings.LogRest)
|
||||
{
|
||||
TShock.Log.ConsoleInfo("Anonymous requested REST endpoint: " + BuildRequestUri(cmd, verbs, parms, false));
|
||||
}
|
||||
|
|
@ -430,4 +430,4 @@ namespace Rests
|
|||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ namespace TShockAPI
|
|||
public void RegisterRestfulCommands()
|
||||
{
|
||||
// Server Commands
|
||||
if (TShock.Config.EnableTokenEndpointAuthentication)
|
||||
if (TShock.Config.Settings.EnableTokenEndpointAuthentication)
|
||||
{
|
||||
Rest.Register(new SecureRestCommand("/v2/server/status", ServerStatusV2));
|
||||
Rest.Register(new SecureRestCommand("/v3/server/motd", ServerMotd));
|
||||
|
|
@ -398,15 +398,15 @@ namespace TShockAPI
|
|||
{
|
||||
var ret = new RestObject()
|
||||
{
|
||||
{"name", TShock.Config.ServerName},
|
||||
{"name", TShock.Config.Settings.ServerName},
|
||||
{"serverversion", Main.versionNumber},
|
||||
{"tshockversion", TShock.VersionNum},
|
||||
{"port", TShock.Config.ServerPort},
|
||||
{"port", TShock.Config.Settings.ServerPort},
|
||||
{"playercount", Main.player.Where(p => null != p && p.active).Count()},
|
||||
{"maxplayers", TShock.Config.MaxSlots},
|
||||
{"world", (TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName)},
|
||||
{"maxplayers", TShock.Config.Settings.MaxSlots},
|
||||
{"world", (TShock.Config.Settings.UseServerName ? TShock.Config.Settings.ServerName : Main.worldName)},
|
||||
{"uptime", (DateTime.Now - System.Diagnostics.Process.GetCurrentProcess().StartTime).ToString(@"d'.'hh':'mm':'ss")},
|
||||
{"serverpassword", !string.IsNullOrEmpty(TShock.Config.ServerPassword)}
|
||||
{"serverpassword", !string.IsNullOrEmpty(TShock.Config.Settings.ServerPassword)}
|
||||
};
|
||||
|
||||
if (GetBool(args.Parameters["players"], false))
|
||||
|
|
@ -424,18 +424,18 @@ namespace TShockAPI
|
|||
if (GetBool(args.Parameters["rules"], false))
|
||||
{
|
||||
var rules = new Dictionary<string, object>();
|
||||
rules.Add("AutoSave", TShock.Config.AutoSave);
|
||||
rules.Add("DisableBuild", TShock.Config.DisableBuild);
|
||||
rules.Add("DisableClownBombs", TShock.Config.DisableClownBombs);
|
||||
rules.Add("DisableDungeonGuardian", TShock.Config.DisableDungeonGuardian);
|
||||
rules.Add("DisableInvisPvP", TShock.Config.DisableInvisPvP);
|
||||
rules.Add("DisableSnowBalls", TShock.Config.DisableSnowBalls);
|
||||
rules.Add("DisableTombstones", TShock.Config.DisableTombstones);
|
||||
rules.Add("EnableWhitelist", TShock.Config.EnableWhitelist);
|
||||
rules.Add("HardcoreOnly", TShock.Config.HardcoreOnly);
|
||||
rules.Add("PvPMode", TShock.Config.PvPMode);
|
||||
rules.Add("SpawnProtection", TShock.Config.SpawnProtection);
|
||||
rules.Add("SpawnProtectionRadius", TShock.Config.SpawnProtectionRadius);
|
||||
rules.Add("AutoSave", TShock.Config.Settings.AutoSave);
|
||||
rules.Add("DisableBuild", TShock.Config.Settings.DisableBuild);
|
||||
rules.Add("DisableClownBombs", TShock.Config.Settings.DisableClownBombs);
|
||||
rules.Add("DisableDungeonGuardian", TShock.Config.Settings.DisableDungeonGuardian);
|
||||
rules.Add("DisableInvisPvP", TShock.Config.Settings.DisableInvisPvP);
|
||||
rules.Add("DisableSnowBalls", TShock.Config.Settings.DisableSnowBalls);
|
||||
rules.Add("DisableTombstones", TShock.Config.Settings.DisableTombstones);
|
||||
rules.Add("EnableWhitelist", TShock.Config.Settings.EnableWhitelist);
|
||||
rules.Add("HardcoreOnly", TShock.Config.Settings.HardcoreOnly);
|
||||
rules.Add("PvPMode", TShock.Config.Settings.PvPMode);
|
||||
rules.Add("SpawnProtection", TShock.Config.Settings.SpawnProtection);
|
||||
rules.Add("SpawnProtectionRadius", TShock.Config.Settings.SpawnProtectionRadius);
|
||||
rules.Add("ServerSideInventory", Main.ServerSideCharacter);
|
||||
|
||||
ret.Add("rules", rules);
|
||||
|
|
@ -496,7 +496,7 @@ namespace TShockAPI
|
|||
|
||||
var group = args.Parameters["group"];
|
||||
if (string.IsNullOrWhiteSpace(group))
|
||||
group = TShock.Config.DefaultRegistrationGroupName;
|
||||
group = TShock.Config.Settings.DefaultRegistrationGroupName;
|
||||
|
||||
var password = args.Parameters["password"];
|
||||
if (string.IsNullOrWhiteSpace(password))
|
||||
|
|
@ -775,7 +775,7 @@ namespace TShockAPI
|
|||
bool autoSave;
|
||||
if (!bool.TryParse(args.Verbs["state"], out autoSave))
|
||||
return RestInvalidParam("state");
|
||||
TShock.Config.AutoSave = autoSave;
|
||||
TShock.Config.Settings.AutoSave = autoSave;
|
||||
|
||||
var resp = RestResponse("AutoSave has been set to " + autoSave);
|
||||
resp.Add("upgrade", "/v3/world/autosave");
|
||||
|
|
@ -791,11 +791,11 @@ namespace TShockAPI
|
|||
bool autoSave;
|
||||
if (!bool.TryParse(args.Parameters["state"], out autoSave))
|
||||
{
|
||||
return RestResponse($"Autosave is currently {(TShock.Config.AutoSave ? "enabled" : "disabled")}");
|
||||
return RestResponse($"Autosave is currently {(TShock.Config.Settings.AutoSave ? "enabled" : "disabled")}");
|
||||
}
|
||||
TShock.Config.AutoSave = autoSave;
|
||||
TShock.Config.Settings.AutoSave = autoSave;
|
||||
|
||||
return RestResponse($"AutoSave has been {(TShock.Config.AutoSave ? "enabled" : "disabled")}");
|
||||
return RestResponse($"AutoSave has been {(TShock.Config.Settings.AutoSave ? "enabled" : "disabled")}");
|
||||
}
|
||||
|
||||
[Description("Save the world.")]
|
||||
|
|
@ -840,7 +840,7 @@ namespace TShockAPI
|
|||
{
|
||||
return new RestObject()
|
||||
{
|
||||
{"name", (TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName)},
|
||||
{"name", (TShock.Config.Settings.UseServerName ? TShock.Config.Settings.ServerName : Main.worldName)},
|
||||
{"size", Main.maxTilesX + "*" + Main.maxTilesY},
|
||||
{"time", Main.time},
|
||||
{"daytime", Main.dayTime},
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ namespace Rests
|
|||
AppTokens.Add(t.Key, t.Value);
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<string, TokenData> t in TShock.Config.ApplicationRestTokens)
|
||||
foreach (KeyValuePair<string, TokenData> t in TShock.Config.Settings.ApplicationRestTokens)
|
||||
{
|
||||
AppTokens.Add(t.Key, t.Value);
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ namespace Rests
|
|||
int tokens = 0;
|
||||
if (tokenBucket.TryGetValue(context.RemoteEndPoint.Address.ToString(), out tokens))
|
||||
{
|
||||
if (tokens >= TShock.Config.RESTMaximumRequestsPerInterval)
|
||||
if (tokens >= TShock.Config.Settings.RESTMaximumRequestsPerInterval)
|
||||
{
|
||||
TShock.Log.ConsoleError("A REST login from {0} was blocked as it currently has {1} tokens", context.RemoteEndPoint.Address.ToString(), tokens);
|
||||
tokenBucket[context.RemoteEndPoint.Address.ToString()] += 1; // Tokens over limit, increment by one and reject request
|
||||
|
|
@ -208,7 +208,7 @@ namespace Rests
|
|||
}
|
||||
|
||||
object result = secureCmd.Execute(verbs, parms, tokenData, request, context);
|
||||
if (cmd.DoLog && TShock.Config.LogRest)
|
||||
if (cmd.DoLog && TShock.Config.Settings.LogRest)
|
||||
TShock.Utils.SendLogs(string.Format(
|
||||
"\"{0}\" requested REST endpoint: {1}", tokenData.Username, this.BuildRequestUri(cmd, verbs, parms, false)),
|
||||
Color.PaleVioletRed);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace TShockAPI
|
|||
/// </summary>
|
||||
public void OnSaveWorld(WorldSaveEventArgs args)
|
||||
{
|
||||
if (TShock.Config.AnnounceSave)
|
||||
if (TShock.Config.Settings.AnnounceSave)
|
||||
{
|
||||
// Protect against internal errors causing save failures
|
||||
// These can be caused by an unexpected error such as a bad or out of date plugin
|
||||
|
|
@ -131,7 +131,7 @@ namespace TShockAPI
|
|||
else
|
||||
WorldFile.SaveWorld(task.resetTime);
|
||||
|
||||
if (TShock.Config.AnnounceSave)
|
||||
if (TShock.Config.Settings.AnnounceSave)
|
||||
TShock.Utils.Broadcast("World saved.", Color.Yellow);
|
||||
|
||||
TShock.Log.Info(string.Format("World saved at ({0})", Main.worldPathName));
|
||||
|
|
|
|||
|
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
TShock, a server mod for Terraria
|
||||
Copyright (C) 2011-2019 Pryaxis & TShock Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace TShockAPI.ServerSideCharacters
|
||||
{
|
||||
public class ServerSideConfig
|
||||
{
|
||||
[Description("Enable server side characters, This stops the client from saving character data! EXPERIMENTAL!!!!!")]
|
||||
public bool Enabled = false;
|
||||
|
||||
[Description("How often SSC should save, in minutes.")]
|
||||
public int ServerSideCharacterSave = 5;
|
||||
|
||||
[Description("Time, in milliseconds, to disallow discarding items after logging in when ServerSideInventory is ON.")]
|
||||
public int LogonDiscardThreshold = 250;
|
||||
|
||||
[Description("The starting default health for new SSC.")]
|
||||
public int StartingHealth = 100;
|
||||
|
||||
[Description("The starting default mana for new SSC.")]
|
||||
public int StartingMana = 20;
|
||||
|
||||
[Description("The starting default inventory for new SSC.")]
|
||||
public List<NetItem> StartingInventory = new List<NetItem>();
|
||||
|
||||
/// <summary>
|
||||
/// Reads a server-side configuration file from a given path
|
||||
/// </summary>
|
||||
/// <param name="path">The path to the config file</param>
|
||||
/// <param name="anyMissingFields">
|
||||
/// Whether the config object has any new fields in it, meaning that the config file has to be
|
||||
/// overwritten.
|
||||
/// </param>
|
||||
/// <returns>ConfigFile object</returns>
|
||||
public static ServerSideConfig Read(string path, out bool anyMissingFields)
|
||||
{
|
||||
using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
using (var reader = new StreamReader(fileStream))
|
||||
{
|
||||
string txt = reader.ReadToEnd();
|
||||
var config = FileTools.LoadConfigAndCheckForMissingFields<ServerSideConfig>(txt, out anyMissingFields);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
public void Write(string path)
|
||||
{
|
||||
using (var writer = new StreamWriter(path))
|
||||
{
|
||||
writer.Write(JsonConvert.SerializeObject(this, Formatting.Indented));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dumps all configuration options to a text file in Markdown format
|
||||
/// </summary>
|
||||
public static void DumpDescriptions()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var defaults = new ServerSideConfig();
|
||||
|
||||
foreach (var field in defaults.GetType().GetFields().OrderBy(f => f.Name))
|
||||
{
|
||||
if (field.IsStatic)
|
||||
continue;
|
||||
|
||||
var name = field.Name;
|
||||
var type = field.FieldType.Name;
|
||||
|
||||
var descattr =
|
||||
field.GetCustomAttributes(false).FirstOrDefault(o => o is DescriptionAttribute) as DescriptionAttribute;
|
||||
var desc = descattr != null && !string.IsNullOrWhiteSpace(descattr.Description) ? descattr.Description : "None";
|
||||
|
||||
var def = field.GetValue(defaults);
|
||||
|
||||
sb.AppendLine("{0} ".SFormat(name));
|
||||
sb.AppendLine("Type: {0} ".SFormat(type));
|
||||
sb.AppendLine("Description: {0} ".SFormat(desc));
|
||||
sb.AppendLine("Default: \"{0}\" ".SFormat(def));
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
File.WriteAllText("ServerSideConfigDescriptions.txt", sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ namespace TShockAPI
|
|||
{
|
||||
private readonly IDbConnection _database;
|
||||
private readonly TextLog _backupLog;
|
||||
private readonly List<LogInfo> _failures = new List<LogInfo>(TShock.Config.RevertToTextLogsOnSqlFailures);
|
||||
private readonly List<LogInfo> _failures = new List<LogInfo>(TShock.Config.Settings.RevertToTextLogsOnSqlFailures);
|
||||
private bool _useTextLog;
|
||||
|
||||
public string FileName { get; set; }
|
||||
|
|
@ -211,7 +211,7 @@ namespace TShockAPI
|
|||
/// <param name="message">The message to be written.</param>
|
||||
public void ConsoleDebug(string message)
|
||||
{
|
||||
if (TShock.Config.DebugLogs)
|
||||
if (TShock.Config.Settings.DebugLogs)
|
||||
{
|
||||
Console.WriteLine("Debug: " + message);
|
||||
Write(message, TraceLevel.Verbose);
|
||||
|
|
@ -234,7 +234,7 @@ namespace TShockAPI
|
|||
/// <param name="message">The message to be written.</param>
|
||||
public void Debug(string message)
|
||||
{
|
||||
if (TShock.Config.DebugLogs)
|
||||
if (TShock.Config.Settings.DebugLogs)
|
||||
Write(message, TraceLevel.Verbose);
|
||||
}
|
||||
|
||||
|
|
@ -245,7 +245,7 @@ namespace TShockAPI
|
|||
/// <param name="args">The format arguments.</param>
|
||||
public void Debug(string format, params object[] args)
|
||||
{
|
||||
if (TShock.Config.DebugLogs)
|
||||
if (TShock.Config.Settings.DebugLogs)
|
||||
Debug(string.Format(format, args));
|
||||
}
|
||||
|
||||
|
|
@ -314,7 +314,7 @@ namespace TShockAPI
|
|||
});
|
||||
}
|
||||
|
||||
if (_failures.Count >= TShock.Config.RevertToTextLogsOnSqlFailures)
|
||||
if (_failures.Count >= TShock.Config.Settings.RevertToTextLogsOnSqlFailures)
|
||||
{
|
||||
_useTextLog = true;
|
||||
_backupLog.ConsoleError("SQL Logging disabled due to errors. Reverting to text logging.");
|
||||
|
|
@ -333,4 +333,4 @@ namespace TShockAPI
|
|||
_backupLog.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ namespace TShockAPI
|
|||
|| IsDisabledForStackDetection
|
||||
|| IsDisabledForBannedWearable
|
||||
|| IsDisabledPendingTrashRemoval
|
||||
|| !IsLoggedIn && TShock.Config.RequireLogin;
|
||||
|| !IsLoggedIn && TShock.Config.Settings.RequireLogin;
|
||||
}
|
||||
|
||||
/// <summary>Checks to see if a player has hacked item stacks in their inventory, and messages them as it checks.</summary>
|
||||
|
|
@ -608,7 +608,7 @@ namespace TShockAPI
|
|||
{
|
||||
int rgX = Math.Abs(TileX - x);
|
||||
int rgY = Math.Abs(TileY - y);
|
||||
if (TShock.Config.RangeChecks && ((rgX > range) || (rgY > range)))
|
||||
if (TShock.Config.Settings.RangeChecks && ((rgX > range) || (rgY > range)))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Rangecheck failed for {0} ({1}, {2}) (rg: {3}/{5}, {4}/{5})", Name, x, y, rgX, rgY, range);
|
||||
return false;
|
||||
|
|
@ -636,12 +636,12 @@ namespace TShockAPI
|
|||
|
||||
// If the player has bypass on build protection or building is enabled; continue
|
||||
// (General build protection takes precedence over spawn protection)
|
||||
if (!TShock.Config.DisableBuild || HasPermission(Permissions.antibuild))
|
||||
if (!TShock.Config.Settings.DisableBuild || HasPermission(Permissions.antibuild))
|
||||
{
|
||||
failure = BuildPermissionFailPoint.SpawnProtect;
|
||||
// If they have spawn protect bypass, or it isn't spawn, or it isn't in spawn; continue
|
||||
// (If they have spawn protect bypass, we don't care if it's spawn or not)
|
||||
if (!TShock.Config.SpawnProtection || HasPermission(Permissions.editspawn) || !Utils.IsInSpawn(x, y))
|
||||
if (!TShock.Config.Settings.SpawnProtection || HasPermission(Permissions.editspawn) || !Utils.IsInSpawn(x, y))
|
||||
{
|
||||
failure = BuildPermissionFailPoint.Regions;
|
||||
// If they have build permission in this region, then they're allowed to continue
|
||||
|
|
@ -730,7 +730,7 @@ namespace TShockAPI
|
|||
{
|
||||
// The goal is to short circuit ASAP.
|
||||
// A subsequent call to HasBuildPermission can figure this out if not explicitly ice.
|
||||
if (!TShock.Config.AllowIce)
|
||||
if (!TShock.Config.Settings.AllowIce)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1103,7 +1103,7 @@ namespace TShockAPI
|
|||
}
|
||||
|
||||
PlayerData = new PlayerData(this);
|
||||
Group = TShock.Groups.GetGroupByName(TShock.Config.DefaultGuestGroupName);
|
||||
Group = TShock.Groups.GetGroupByName(TShock.Config.Settings.DefaultGuestGroupName);
|
||||
tempGroup = null;
|
||||
if (tempGroupTimer != null)
|
||||
{
|
||||
|
|
@ -1312,8 +1312,8 @@ namespace TShockAPI
|
|||
/// <returns>True or false, depending if the item passed the check or not.</returns>
|
||||
public bool GiveItemCheck(int type, string name, int stack, int prefix = 0)
|
||||
{
|
||||
if ((TShock.ItemBans.DataModel.ItemIsBanned(name) && TShock.Config.PreventBannedItemSpawn) &&
|
||||
(TShock.ItemBans.DataModel.ItemIsBanned(name, this) || !TShock.Config.AllowAllowedGroupsToSpawnBannedItems))
|
||||
if ((TShock.ItemBans.DataModel.ItemIsBanned(name) && TShock.Config.Settings.PreventBannedItemSpawn) &&
|
||||
(TShock.ItemBans.DataModel.ItemIsBanned(name, this) || !TShock.Config.Settings.AllowAllowedGroupsToSpawnBannedItems))
|
||||
return false;
|
||||
|
||||
GiveItem(type, stack, prefix);
|
||||
|
|
@ -1502,7 +1502,7 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
foo = foo.Replace("%map%", (TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName));
|
||||
foo = foo.Replace("%map%", (TShock.Config.Settings.UseServerName ? TShock.Config.Settings.ServerName : Main.worldName));
|
||||
foo = foo.Replace("%players%", String.Join(",", players));
|
||||
|
||||
SendMessage(foo, lineColor);
|
||||
|
|
|
|||
|
|
@ -38,12 +38,12 @@ using Terraria.Localization;
|
|||
using TerrariaApi.Server;
|
||||
using TShockAPI.DB;
|
||||
using TShockAPI.Hooks;
|
||||
using TShockAPI.ServerSideCharacters;
|
||||
using Terraria.Utilities;
|
||||
using Microsoft.Xna.Framework;
|
||||
using TShockAPI.Sockets;
|
||||
using TShockAPI.CLI;
|
||||
using TShockAPI.Localization;
|
||||
using TShockAPI.Configuration;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
|
|
@ -101,7 +101,7 @@ namespace TShockAPI
|
|||
/// <summary>Contains the information about what research has been performed in Journey mode.</summary>
|
||||
public static ResearchDatastore ResearchDatastore;
|
||||
/// <summary>Config - Static reference to the config system, for accessing values set in users' config files.</summary>
|
||||
public static ConfigFile Config { get; set; }
|
||||
public static TShockConfig Config { get; set; }
|
||||
/// <summary>ServerSideCharacterConfig - Static reference to the server side character config, for accessing values set by users to modify SSC.</summary>
|
||||
public static ServerSideConfig ServerSideCharacterConfig;
|
||||
/// <summary>DB - Static reference to the database.</summary>
|
||||
|
|
@ -180,11 +180,11 @@ namespace TShockAPI
|
|||
public TShock(Main game)
|
||||
: base(game)
|
||||
{
|
||||
Config = new ConfigFile();
|
||||
Config = new TShockConfig();
|
||||
ServerSideCharacterConfig = new ServerSideConfig();
|
||||
ServerSideCharacterConfig.StartingInventory.Add(new NetItem(-15, 1, 0));
|
||||
ServerSideCharacterConfig.StartingInventory.Add(new NetItem(-13, 1, 0));
|
||||
ServerSideCharacterConfig.StartingInventory.Add(new NetItem(-16, 1, 0));
|
||||
ServerSideCharacterConfig.Settings.StartingInventory.Add(new NetItem(-15, 1, 0));
|
||||
ServerSideCharacterConfig.Settings.StartingInventory.Add(new NetItem(-13, 1, 0));
|
||||
ServerSideCharacterConfig.Settings.StartingInventory.Add(new NetItem(-16, 1, 0));
|
||||
Order = 0;
|
||||
instance = this;
|
||||
}
|
||||
|
|
@ -221,10 +221,10 @@ namespace TShockAPI
|
|||
if (!Directory.Exists(SavePath))
|
||||
Directory.CreateDirectory(SavePath);
|
||||
|
||||
ConfigFile.ConfigRead += OnConfigRead;
|
||||
TShockConfig.OnConfigRead += OnConfigRead;
|
||||
FileTools.SetupConfig();
|
||||
|
||||
Main.ServerSideCharacter = ServerSideCharacterConfig.Enabled;
|
||||
Main.ServerSideCharacter = ServerSideCharacterConfig.Settings.Enabled;
|
||||
|
||||
//TSAPI previously would do this automatically, but the vanilla server wont
|
||||
if (Netplay.ServerIP == null)
|
||||
|
|
@ -233,7 +233,7 @@ namespace TShockAPI
|
|||
DateTime now = DateTime.Now;
|
||||
// Log path was not already set by the command line parameter?
|
||||
if (LogPath == LogPathDefault)
|
||||
LogPath = Config.LogPath;
|
||||
LogPath = Config.Settings.LogPath;
|
||||
try
|
||||
{
|
||||
logFilename = Path.Combine(LogPath, now.ToString(LogFormat) + ".log");
|
||||
|
|
@ -262,25 +262,25 @@ namespace TShockAPI
|
|||
// Further exceptions are written to TShock's log from now on.
|
||||
try
|
||||
{
|
||||
if (Config.StorageType.ToLower() == "sqlite")
|
||||
if (Config.Settings.StorageType.ToLower() == "sqlite")
|
||||
{
|
||||
string sql = Path.Combine(SavePath, Config.SqliteDBPath);
|
||||
string sql = Path.Combine(SavePath, Config.Settings.SqliteDBPath);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(sql));
|
||||
DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
|
||||
}
|
||||
else if (Config.StorageType.ToLower() == "mysql")
|
||||
else if (Config.Settings.StorageType.ToLower() == "mysql")
|
||||
{
|
||||
try
|
||||
{
|
||||
var hostport = Config.MySqlHost.Split(':');
|
||||
var hostport = Config.Settings.MySqlHost.Split(':');
|
||||
DB = new MySqlConnection();
|
||||
DB.ConnectionString =
|
||||
String.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};",
|
||||
hostport[0],
|
||||
hostport.Length > 1 ? hostport[1] : "3306",
|
||||
Config.MySqlDbName,
|
||||
Config.MySqlUsername,
|
||||
Config.MySqlPassword
|
||||
Config.Settings.MySqlDbName,
|
||||
Config.Settings.MySqlUsername,
|
||||
Config.Settings.MySqlPassword
|
||||
);
|
||||
}
|
||||
catch (MySqlException ex)
|
||||
|
|
@ -294,7 +294,7 @@ namespace TShockAPI
|
|||
throw new Exception("Invalid storage type");
|
||||
}
|
||||
|
||||
if (Config.UseSqlLogs)
|
||||
if (Config.Settings.UseSqlLogs)
|
||||
Log = new SqlLog(DB, logFilename, LogClear);
|
||||
else
|
||||
Log = new TextLog(logFilename, LogClear);
|
||||
|
|
@ -312,8 +312,8 @@ namespace TShockAPI
|
|||
HandleCommandLinePostConfigLoad(Environment.GetCommandLineArgs());
|
||||
|
||||
Backups = new BackupManager(Path.Combine(SavePath, "backups"));
|
||||
Backups.KeepFor = Config.BackupKeepFor;
|
||||
Backups.Interval = Config.BackupInterval;
|
||||
Backups.KeepFor = Config.Settings.BackupKeepFor;
|
||||
Backups.Interval = Config.Settings.BackupInterval;
|
||||
Bans = new BanManager(DB);
|
||||
Warps = new WarpManager(DB);
|
||||
Regions = new RegionManager(DB);
|
||||
|
|
@ -324,7 +324,7 @@ namespace TShockAPI
|
|||
RememberedPos = new RememberedPosManager(DB);
|
||||
CharacterDB = new CharacterManager(DB);
|
||||
ResearchDatastore = new ResearchDatastore(DB);
|
||||
RestApi = new SecureRest(Netplay.ServerIP, Config.RestApiPort);
|
||||
RestApi = new SecureRest(Netplay.ServerIP, Config.Settings.RestApiPort);
|
||||
RestManager = new RestManager(RestApi);
|
||||
RestManager.RegisterRestfulCommands();
|
||||
Bouncer = new Bouncer();
|
||||
|
|
@ -332,7 +332,7 @@ namespace TShockAPI
|
|||
ItemBans = new ItemBans(this, DB);
|
||||
|
||||
var geoippath = "GeoIP.dat";
|
||||
if (Config.EnableGeoIP && File.Exists(geoippath))
|
||||
if (Config.Settings.EnableGeoIP && File.Exists(geoippath))
|
||||
Geo = new GeoIPCountry(geoippath);
|
||||
|
||||
Log.ConsoleInfo("TShock {0} ({1}) now running.", Version, VersionCodename);
|
||||
|
|
@ -368,14 +368,13 @@ namespace TShockAPI
|
|||
|
||||
EnglishLanguage.Initialize();
|
||||
|
||||
if (Config.RestApiEnabled)
|
||||
if (Config.Settings.RestApiEnabled)
|
||||
RestApi.Start();
|
||||
|
||||
Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
|
||||
Log.ConsoleInfo("AutoSave " + (Config.Settings.AutoSave ? "Enabled" : "Disabled"));
|
||||
Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));
|
||||
|
||||
if (Initialized != null)
|
||||
Initialized();
|
||||
Initialized?.Invoke();
|
||||
|
||||
Log.ConsoleInfo("Welcome to TShock for Terraria!");
|
||||
Log.ConsoleInfo("TShock comes with no warranty & is free software.");
|
||||
|
|
@ -559,7 +558,7 @@ namespace TShockAPI
|
|||
|
||||
if (args.Chest != null)
|
||||
{
|
||||
if (Config.RegionProtectChests && !Regions.CanBuild((int)args.WorldPosition.X, (int)args.WorldPosition.Y, tsplr))
|
||||
if (Config.Settings.RegionProtectChests && !Regions.CanBuild((int)args.WorldPosition.X, (int)args.WorldPosition.Y, tsplr))
|
||||
{
|
||||
args.Handled = true;
|
||||
return;
|
||||
|
|
@ -580,7 +579,7 @@ namespace TShockAPI
|
|||
if (args.Handled)
|
||||
return;
|
||||
|
||||
if (Config.ForceXmas)
|
||||
if (Config.Settings.ForceXmas)
|
||||
{
|
||||
args.Xmas = true;
|
||||
args.Handled = true;
|
||||
|
|
@ -594,7 +593,7 @@ namespace TShockAPI
|
|||
if (args.Handled)
|
||||
return;
|
||||
|
||||
if (Config.ForceHalloween)
|
||||
if (Config.Settings.ForceHalloween)
|
||||
{
|
||||
args.Halloween = true;
|
||||
args.Handled = true;
|
||||
|
|
@ -630,7 +629,7 @@ namespace TShockAPI
|
|||
|
||||
if (e.IsTerminating)
|
||||
{
|
||||
if (Main.worldPathName != null && Config.SaveWorldOnCrash)
|
||||
if (Main.worldPathName != null && Config.Settings.SaveWorldOnCrash)
|
||||
{
|
||||
Main.ActiveWorldFileData._path += ".crash";
|
||||
SaveManager.Instance.SaveWorld();
|
||||
|
|
@ -768,7 +767,7 @@ namespace TShockAPI
|
|||
if (int.TryParse(p, out port))
|
||||
{
|
||||
Netplay.ListenPort = port;
|
||||
Config.ServerPort = port;
|
||||
Config.Settings.ServerPort = port;
|
||||
OverridePort = true;
|
||||
Log.ConsoleInfo("Port overridden by startup argument. Set to " + port);
|
||||
}
|
||||
|
|
@ -783,7 +782,7 @@ namespace TShockAPI
|
|||
bool enabled;
|
||||
if (bool.TryParse(e, out enabled))
|
||||
{
|
||||
Config.RestApiEnabled = enabled;
|
||||
Config.Settings.RestApiEnabled = enabled;
|
||||
Console.WriteLine("Startup parameter overrode REST enable.");
|
||||
}
|
||||
})
|
||||
|
|
@ -792,7 +791,7 @@ namespace TShockAPI
|
|||
int restPort;
|
||||
if (int.TryParse(p, out restPort))
|
||||
{
|
||||
Config.RestApiPort = restPort;
|
||||
Config.Settings.RestApiPort = restPort;
|
||||
Console.WriteLine("Startup parameter overrode REST port.");
|
||||
}
|
||||
})
|
||||
|
|
@ -801,7 +800,7 @@ namespace TShockAPI
|
|||
int slots;
|
||||
if (int.TryParse(p, out slots))
|
||||
{
|
||||
Config.MaxSlots = slots;
|
||||
Config.Settings.MaxSlots = slots;
|
||||
Console.WriteLine("Startup parameter overrode maximum player slot configuration value.");
|
||||
}
|
||||
});
|
||||
|
|
@ -826,7 +825,7 @@ namespace TShockAPI
|
|||
//CLI defined password overrides a config password
|
||||
_cliPassword = Netplay.ServerPassword;
|
||||
Netplay.ServerPassword = "";
|
||||
Config.ServerPassword = _cliPassword;
|
||||
Config.Settings.ServerPassword = _cliPassword;
|
||||
}
|
||||
|
||||
// Disable the auth system if "setup.lock" is present or a user account already exists
|
||||
|
|
@ -873,9 +872,9 @@ namespace TShockAPI
|
|||
Utils.ComputeMaxStyles();
|
||||
Utils.FixChestStacks();
|
||||
|
||||
if (Config.UseServerName)
|
||||
if (Config.Settings.UseServerName)
|
||||
{
|
||||
Main.worldName = Config.ServerName;
|
||||
Main.worldName = Config.Settings.ServerName;
|
||||
}
|
||||
|
||||
UpdateManager = new UpdateManager();
|
||||
|
|
@ -900,7 +899,7 @@ namespace TShockAPI
|
|||
LastCheck = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
if (Main.ServerSideCharacter && (DateTime.UtcNow - LastSave).TotalMinutes >= ServerSideCharacterConfig.ServerSideCharacterSave)
|
||||
if (Main.ServerSideCharacter && (DateTime.UtcNow - LastSave).TotalMinutes >= ServerSideCharacterConfig.Settings.ServerSideCharacterSave)
|
||||
{
|
||||
foreach (TSPlayer player in Players)
|
||||
{
|
||||
|
|
@ -918,11 +917,11 @@ namespace TShockAPI
|
|||
/// <summary>OnSecondUpdate - Called effectively every second for all time based checks.</summary>
|
||||
private void OnSecondUpdate()
|
||||
{
|
||||
DisableFlags flags = Config.DisableSecondUpdateLogs ? DisableFlags.WriteToConsole : DisableFlags.WriteToLogAndConsole;
|
||||
DisableFlags flags = Config.Settings.DisableSecondUpdateLogs ? DisableFlags.WriteToConsole : DisableFlags.WriteToLogAndConsole;
|
||||
|
||||
if (Config.ForceTime != "normal")
|
||||
if (Config.Settings.ForceTime != "normal")
|
||||
{
|
||||
switch (Config.ForceTime)
|
||||
switch (Config.Settings.ForceTime)
|
||||
{
|
||||
case "day":
|
||||
TSPlayer.Server.SetTime(true, 27000.0);
|
||||
|
|
@ -939,7 +938,7 @@ namespace TShockAPI
|
|||
{
|
||||
if (player.TilesDestroyed != null)
|
||||
{
|
||||
if (player.TileKillThreshold >= Config.TileKillThreshold)
|
||||
if (player.TileKillThreshold >= Config.Settings.TileKillThreshold)
|
||||
{
|
||||
player.Disable("Reached TileKill threshold.", flags);
|
||||
TSPlayer.Server.RevertTiles(player.TilesDestroyed);
|
||||
|
|
@ -956,7 +955,7 @@ namespace TShockAPI
|
|||
|
||||
if (player.TilesCreated != null)
|
||||
{
|
||||
if (player.TilePlaceThreshold >= Config.TilePlaceThreshold)
|
||||
if (player.TilePlaceThreshold >= Config.Settings.TilePlaceThreshold)
|
||||
{
|
||||
player.Disable("Reached TilePlace threshold", flags);
|
||||
lock (player.TilesCreated)
|
||||
|
|
@ -1000,7 +999,7 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
if (player.TileLiquidThreshold >= Config.TileLiquidThreshold)
|
||||
if (player.TileLiquidThreshold >= Config.Settings.TileLiquidThreshold)
|
||||
{
|
||||
player.Disable("Reached TileLiquid threshold", flags);
|
||||
}
|
||||
|
|
@ -1009,7 +1008,7 @@ namespace TShockAPI
|
|||
player.TileLiquidThreshold = 0;
|
||||
}
|
||||
|
||||
if (player.ProjectileThreshold >= Config.ProjectileThreshold)
|
||||
if (player.ProjectileThreshold >= Config.Settings.ProjectileThreshold)
|
||||
{
|
||||
player.Disable("Reached projectile threshold", flags);
|
||||
}
|
||||
|
|
@ -1018,7 +1017,7 @@ namespace TShockAPI
|
|||
player.ProjectileThreshold = 0;
|
||||
}
|
||||
|
||||
if (player.PaintThreshold >= Config.TilePaintThreshold)
|
||||
if (player.PaintThreshold >= Config.Settings.TilePaintThreshold)
|
||||
{
|
||||
player.Disable("Reached paint threshold", flags);
|
||||
}
|
||||
|
|
@ -1027,7 +1026,7 @@ namespace TShockAPI
|
|||
player.PaintThreshold = 0;
|
||||
}
|
||||
|
||||
if (player.HealOtherThreshold >= TShock.Config.HealOtherThreshold)
|
||||
if (player.HealOtherThreshold >= TShock.Config.Settings.HealOtherThreshold)
|
||||
{
|
||||
player.Disable("Reached HealOtherPlayer threshold", flags);
|
||||
}
|
||||
|
|
@ -1093,19 +1092,19 @@ namespace TShockAPI
|
|||
/// <returns>True if allowed, otherwise false</returns>
|
||||
private bool OnCreep(int tileType)
|
||||
{
|
||||
if (!Config.AllowCrimsonCreep && (tileType == TileID.Dirt || tileType == TileID.CrimsonGrass
|
||||
if (!Config.Settings.AllowCrimsonCreep && (tileType == TileID.Dirt || tileType == TileID.CrimsonGrass
|
||||
|| TileID.Sets.Crimson[tileType]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Config.AllowCorruptionCreep && (tileType == TileID.Dirt || tileType == TileID.CorruptThorns
|
||||
if (!Config.Settings.AllowCorruptionCreep && (tileType == TileID.Dirt || tileType == TileID.CorruptThorns
|
||||
|| TileID.Sets.Corrupt[tileType]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Config.AllowHallowCreep && (TileID.Sets.Hallow[tileType]))
|
||||
if (!Config.Settings.AllowHallowCreep && (TileID.Sets.Hallow[tileType]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1117,7 +1116,7 @@ namespace TShockAPI
|
|||
/// <param name="args">args - The StatueSpawnEventArgs object.</param>
|
||||
private void OnStatueSpawn(StatueSpawnEventArgs args)
|
||||
{
|
||||
if (args.Within200 < Config.StatueSpawn200 && args.Within600 < Config.StatueSpawn600 && args.WorldWide < Config.StatueSpawnWorld)
|
||||
if (args.Within200 < Config.Settings.StatueSpawn200 && args.Within600 < Config.Settings.StatueSpawn600 && args.WorldWide < Config.Settings.StatueSpawnWorld)
|
||||
{
|
||||
args.Handled = true;
|
||||
}
|
||||
|
|
@ -1140,16 +1139,16 @@ namespace TShockAPI
|
|||
|
||||
var player = new TSPlayer(args.Who);
|
||||
|
||||
if (Utils.GetActivePlayerCount() + 1 > Config.MaxSlots + Config.ReservedSlots)
|
||||
if (Utils.GetActivePlayerCount() + 1 > Config.Settings.MaxSlots + Config.Settings.ReservedSlots)
|
||||
{
|
||||
player.Kick(Config.ServerFullNoReservedReason, true, true, null, false);
|
||||
player.Kick(Config.Settings.ServerFullNoReservedReason, true, true, null, false);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FileTools.OnWhitelist(player.IP))
|
||||
{
|
||||
player.Kick(Config.WhitelistKickReason, true, true, null, false);
|
||||
player.Kick(Config.Settings.WhitelistKickReason, true, true, null, false);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
|
@ -1160,7 +1159,7 @@ namespace TShockAPI
|
|||
player.Country = code == null ? "N/A" : GeoIPCountry.GetCountryNameByCode(code);
|
||||
if (code == "A1")
|
||||
{
|
||||
if (Config.KickProxyUsers)
|
||||
if (Config.Settings.KickProxyUsers)
|
||||
{
|
||||
player.Kick("Connecting via a proxy is not allowed.", true, true, null, false);
|
||||
args.Handled = true;
|
||||
|
|
@ -1182,7 +1181,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (Config.KickEmptyUUID && String.IsNullOrWhiteSpace(player.UUID))
|
||||
if (Config.Settings.KickEmptyUUID && String.IsNullOrWhiteSpace(player.UUID))
|
||||
{
|
||||
player.Kick("Your client sent a blank UUID. Configure it to send one or use a different client.", true, true, null, false);
|
||||
args.Handled = true;
|
||||
|
|
@ -1222,7 +1221,7 @@ namespace TShockAPI
|
|||
CharacterDB.InsertPlayerData(tsplr);
|
||||
}
|
||||
|
||||
if (Config.RememberLeavePos && !tsplr.LoginHarassed)
|
||||
if (Config.Settings.RememberLeavePos && !tsplr.LoginHarassed)
|
||||
{
|
||||
RememberedPos.InsertLeavePos(tsplr.Name, tsplr.IP, (int)(tsplr.X / 16), (int)(tsplr.Y / 16));
|
||||
}
|
||||
|
|
@ -1242,7 +1241,7 @@ namespace TShockAPI
|
|||
// The last player will leave after this hook is executed.
|
||||
if (Utils.GetActivePlayerCount() == 1)
|
||||
{
|
||||
if (Config.SaveWorldOnLastPlayerExit)
|
||||
if (Config.Settings.SaveWorldOnLastPlayerExit)
|
||||
SaveManager.Instance.SaveWorld();
|
||||
Utils.SetConsoleTitle(true);
|
||||
}
|
||||
|
|
@ -1290,7 +1289,7 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
if ((text.StartsWith(Config.CommandSpecifier) || text.StartsWith(Config.CommandSilentSpecifier))
|
||||
if ((text.StartsWith(Config.Settings.CommandSpecifier) || text.StartsWith(Config.Settings.CommandSilentSpecifier))
|
||||
&& !string.IsNullOrWhiteSpace(text.Substring(1)))
|
||||
{
|
||||
try
|
||||
|
|
@ -1320,9 +1319,9 @@ namespace TShockAPI
|
|||
tsplr.SendErrorMessage("You are muted!");
|
||||
args.Handled = true;
|
||||
}
|
||||
else if (!TShock.Config.EnableChatAboveHeads)
|
||||
else if (!TShock.Config.Settings.EnableChatAboveHeads)
|
||||
{
|
||||
text = String.Format(Config.ChatFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix,
|
||||
text = String.Format(Config.Settings.ChatFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix,
|
||||
args.Text);
|
||||
Hooks.PlayerHooks.OnPlayerChat(tsplr, args.Text, ref text);
|
||||
Utils.Broadcast(text, tsplr.Group.R, tsplr.Group.G, tsplr.Group.B);
|
||||
|
|
@ -1332,7 +1331,7 @@ namespace TShockAPI
|
|||
{
|
||||
Player ply = Main.player[args.Who];
|
||||
string name = ply.name;
|
||||
ply.name = String.Format(Config.ChatAboveHeadsFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix);
|
||||
ply.name = String.Format(Config.Settings.ChatAboveHeadsFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix);
|
||||
//Update the player's name to format text nicely. This needs to be done because Terraria automatically formats messages against our will
|
||||
NetMessage.SendData((int)PacketTypes.PlayerInfo, -1, -1, NetworkText.FromLiteral(ply.name), args.Who, 0, 0, 0, 0);
|
||||
|
||||
|
|
@ -1352,7 +1351,7 @@ namespace TShockAPI
|
|||
NetMessage.SendData((int)PacketTypes.PlayerInfo, -1, -1, NetworkText.FromLiteral(name), args.Who, 0, 0, 0, 0);
|
||||
|
||||
string msg = String.Format("<{0}> {1}",
|
||||
String.Format(Config.ChatAboveHeadsFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix),
|
||||
String.Format(Config.Settings.ChatAboveHeadsFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix),
|
||||
text
|
||||
);
|
||||
|
||||
|
|
@ -1388,8 +1387,8 @@ namespace TShockAPI
|
|||
|
||||
if (args.Command == "autosave")
|
||||
{
|
||||
Main.autoSave = Config.AutoSave = !Config.AutoSave;
|
||||
Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
|
||||
Main.autoSave = Config.Settings.AutoSave = !Config.Settings.AutoSave;
|
||||
Log.ConsoleInfo("AutoSave " + (Config.Settings.AutoSave ? "Enabled" : "Disabled"));
|
||||
}
|
||||
else if (args.Command.StartsWith(Commands.Specifier) || args.Command.StartsWith(Commands.SilentSpecifier))
|
||||
{
|
||||
|
|
@ -1456,28 +1455,28 @@ namespace TShockAPI
|
|||
|
||||
player.LoginMS = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
||||
|
||||
if (Config.EnableGeoIP && TShock.Geo != null)
|
||||
if (Config.Settings.EnableGeoIP && TShock.Geo != null)
|
||||
{
|
||||
Log.Info("{0} ({1}) from '{2}' group from '{3}' joined. ({4}/{5})", player.Name, player.IP,
|
||||
player.Group.Name, player.Country, TShock.Utils.GetActivePlayerCount(),
|
||||
TShock.Config.MaxSlots);
|
||||
TShock.Config.Settings.MaxSlots);
|
||||
if (!player.SilentJoinInProgress)
|
||||
Utils.Broadcast(string.Format("{0} ({1}) has joined.", player.Name, player.Country), Color.Yellow);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Info("{0} ({1}) from '{2}' group joined. ({3}/{4})", player.Name, player.IP,
|
||||
player.Group.Name, TShock.Utils.GetActivePlayerCount(), TShock.Config.MaxSlots);
|
||||
player.Group.Name, TShock.Utils.GetActivePlayerCount(), TShock.Config.Settings.MaxSlots);
|
||||
if (!player.SilentJoinInProgress)
|
||||
Utils.Broadcast(player.Name + " has joined.", Color.Yellow);
|
||||
}
|
||||
|
||||
if (Config.DisplayIPToAdmins)
|
||||
if (Config.Settings.DisplayIPToAdmins)
|
||||
Utils.SendLogs(string.Format("{0} has joined. IP: {1}", player.Name, player.IP), Color.Blue);
|
||||
|
||||
player.SendFileTextAsMessage(FileTools.MotdPath);
|
||||
|
||||
string pvpMode = Config.PvPMode.ToLowerInvariant();
|
||||
string pvpMode = Config.Settings.PvPMode.ToLowerInvariant();
|
||||
if (pvpMode == "always")
|
||||
{
|
||||
player.TPlayer.hostile = true;
|
||||
|
|
@ -1493,7 +1492,7 @@ namespace TShockAPI
|
|||
player.SendErrorMessage(String.Format("Server side characters is enabled! Please {0}register or {0}login to play!", Commands.Specifier));
|
||||
player.LoginHarassed = true;
|
||||
}
|
||||
else if (Config.RequireLogin)
|
||||
else if (Config.Settings.RequireLogin)
|
||||
{
|
||||
player.SendErrorMessage("Please {0}register or {0}login to play!", Commands.Specifier);
|
||||
player.LoginHarassed = true;
|
||||
|
|
@ -1502,7 +1501,7 @@ namespace TShockAPI
|
|||
|
||||
player.LastNetPosition = new Vector2(Main.spawnTileX * 16f, Main.spawnTileY * 16f);
|
||||
|
||||
if (Config.RememberLeavePos && (RememberedPos.GetLeavePos(player.Name, player.IP) != Vector2.Zero) && !player.LoginHarassed)
|
||||
if (Config.Settings.RememberLeavePos && (RememberedPos.GetLeavePos(player.Name, player.IP) != Vector2.Zero) && !player.LoginHarassed)
|
||||
{
|
||||
player.RPPending = 3;
|
||||
player.SendInfoMessage("You will be teleported to your last known location...");
|
||||
|
|
@ -1515,7 +1514,7 @@ namespace TShockAPI
|
|||
/// <param name="e">e - The NpcStrikeEventArgs object.</param>
|
||||
private void NpcHooks_OnStrikeNpc(NpcStrikeEventArgs e)
|
||||
{
|
||||
if (Config.InfiniteInvasion)
|
||||
if (Config.Settings.InfiniteInvasion)
|
||||
{
|
||||
if (Main.invasionSize < 10)
|
||||
{
|
||||
|
|
@ -1530,13 +1529,13 @@ namespace TShockAPI
|
|||
{
|
||||
//tombstone fix.
|
||||
if (e.Info == 43 || (e.Info >= 201 && e.Info <= 205) || (e.Info >= 527 && e.Info <= 531))
|
||||
if (Config.DisableTombstones)
|
||||
if (Config.Settings.DisableTombstones)
|
||||
e.Object.SetDefaults(0);
|
||||
if (e.Info == 75)
|
||||
if (Config.DisableClownBombs)
|
||||
if (Config.Settings.DisableClownBombs)
|
||||
e.Object.SetDefaults(0);
|
||||
if (e.Info == 109)
|
||||
if (Config.DisableSnowBalls)
|
||||
if (Config.Settings.DisableSnowBalls)
|
||||
e.Object.SetDefaults(0);
|
||||
}
|
||||
|
||||
|
|
@ -1587,37 +1586,37 @@ namespace TShockAPI
|
|||
/// <param name="e">e - The HandledEventArgs object.</param>
|
||||
private void OnStartHardMode(HandledEventArgs e)
|
||||
{
|
||||
if (Config.DisableHardmode)
|
||||
if (Config.Settings.DisableHardmode)
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary>OnConfigRead - Fired when the config file has been read.</summary>
|
||||
/// <param name="file">file - The config file object.</param>
|
||||
public void OnConfigRead(ConfigFile file)
|
||||
public void OnConfigRead(ConfigFile<TShockSettings> file)
|
||||
{
|
||||
NPC.defaultMaxSpawns = file.DefaultMaximumSpawns;
|
||||
NPC.defaultSpawnRate = file.DefaultSpawnRate;
|
||||
NPC.defaultMaxSpawns = file.Settings.DefaultMaximumSpawns;
|
||||
NPC.defaultSpawnRate = file.Settings.DefaultSpawnRate;
|
||||
|
||||
Main.autoSave = file.AutoSave;
|
||||
Main.autoSave = file.Settings.AutoSave;
|
||||
if (Backups != null)
|
||||
{
|
||||
Backups.KeepFor = file.BackupKeepFor;
|
||||
Backups.Interval = file.BackupInterval;
|
||||
Backups.KeepFor = file.Settings.BackupKeepFor;
|
||||
Backups.Interval = file.Settings.BackupInterval;
|
||||
}
|
||||
if (!OverridePort)
|
||||
{
|
||||
Netplay.ListenPort = file.ServerPort;
|
||||
Netplay.ListenPort = file.Settings.ServerPort;
|
||||
}
|
||||
|
||||
if (file.MaxSlots > Main.maxPlayers - file.ReservedSlots)
|
||||
file.MaxSlots = Main.maxPlayers - file.ReservedSlots;
|
||||
Main.maxNetPlayers = file.MaxSlots + file.ReservedSlots;
|
||||
if (file.Settings.MaxSlots > Main.maxPlayers - file.Settings.ReservedSlots)
|
||||
file.Settings.MaxSlots = Main.maxPlayers - file.Settings.ReservedSlots;
|
||||
Main.maxNetPlayers = file.Settings.MaxSlots + file.Settings.ReservedSlots;
|
||||
|
||||
Netplay.ServerPassword = "";
|
||||
if (!string.IsNullOrEmpty(_cliPassword))
|
||||
{
|
||||
//This prevents a config reload from removing/updating a CLI-defined password
|
||||
file.ServerPassword = _cliPassword;
|
||||
file.Settings.ServerPassword = _cliPassword;
|
||||
}
|
||||
|
||||
Netplay.SpamCheck = false;
|
||||
|
|
|
|||
|
|
@ -83,6 +83,9 @@
|
|||
<Compile Include="BackupManager.cs" />
|
||||
<Compile Include="CLI\CommandLineParser.cs" />
|
||||
<Compile Include="CLI\FlagSet.cs" />
|
||||
<Compile Include="Configuration\ConfigFile.cs" />
|
||||
<Compile Include="Configuration\IConfigFile.cs" />
|
||||
<Compile Include="Configuration\TShockConfig.cs" />
|
||||
<Compile Include="DB\ProjectileManager.cs" />
|
||||
<Compile Include="DB\RegionManager.cs" />
|
||||
<Compile Include="DB\ResearchDatastore.cs" />
|
||||
|
|
@ -165,7 +168,7 @@
|
|||
<Compile Include="Rest\RestObject.cs" />
|
||||
<Compile Include="Rest\RestVerbs.cs" />
|
||||
<Compile Include="Rest\SecureRest.cs" />
|
||||
<Compile Include="ServerSideCharacters\ServerSideConfig.cs" />
|
||||
<Compile Include="Configuration\ServerSideConfig.cs" />
|
||||
<Compile Include="TSServerPlayer.cs" />
|
||||
<Compile Include="Utils.cs" />
|
||||
<Compile Include="TShock.cs" />
|
||||
|
|
@ -226,7 +229,7 @@
|
|||
</PropertyGroup>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildAction="Both" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_StartDate="2011/6/17" BuildVersion_IncrementBeforeBuild="False" />
|
||||
<UserProperties BuildVersion_IncrementBeforeBuild="False" BuildVersion_StartDate="2011/6/17" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_BuildAction="Both" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ namespace TShockAPI
|
|||
/// <param name="message">The message to be written.</param>
|
||||
public void ConsoleDebug(string message)
|
||||
{
|
||||
if (TShock.Config.DebugLogs)
|
||||
if (TShock.Config.Settings.DebugLogs)
|
||||
{
|
||||
Console.WriteLine("Debug: " + message);
|
||||
Write(message, TraceLevel.Verbose);
|
||||
|
|
@ -201,7 +201,7 @@ namespace TShockAPI
|
|||
/// <param name="message">The message to be written.</param>
|
||||
public void Debug(string message)
|
||||
{
|
||||
if (TShock.Config.DebugLogs)
|
||||
if (TShock.Config.Settings.DebugLogs)
|
||||
Write(message, TraceLevel.Verbose);
|
||||
}
|
||||
|
||||
|
|
@ -212,7 +212,7 @@ namespace TShockAPI
|
|||
/// <param name="args">The format arguments.</param>
|
||||
public void Debug(string format, params object[] args)
|
||||
{
|
||||
if (TShock.Config.DebugLogs)
|
||||
if (TShock.Config.Settings.DebugLogs)
|
||||
Debug(string.Format(format, args));
|
||||
}
|
||||
|
||||
|
|
@ -259,4 +259,4 @@ namespace TShockAPI
|
|||
_logWriter.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ namespace TShockAPI
|
|||
foreach (TSPlayer player in TShock.Players)
|
||||
{
|
||||
if (player != null && player != excludedPlayer && player.Active && player.HasPermission(Permissions.logs) &&
|
||||
player.DisplayLogs && TShock.Config.DisableSpewLogs == false)
|
||||
player.DisplayLogs && TShock.Config.Settings.DisableSpewLogs == false)
|
||||
player.SendMessage(log, color);
|
||||
}
|
||||
}
|
||||
|
|
@ -865,9 +865,9 @@ namespace TShockAPI
|
|||
{
|
||||
PrepareLangForDump();
|
||||
// Lang.setLang(true);
|
||||
ConfigFile.DumpDescriptions();
|
||||
Configuration.TShockConfig.DumpDescriptions();
|
||||
Permissions.DumpDescriptions();
|
||||
ServerSideCharacters.ServerSideConfig.DumpDescriptions();
|
||||
Configuration.ServerSideConfig.DumpDescriptions();
|
||||
RestManager.DumpDescriptions();
|
||||
DumpBuffs("BuffList.txt");
|
||||
DumpItems("Items-1_0.txt", 1, 235);
|
||||
|
|
@ -1146,14 +1146,14 @@ namespace TShockAPI
|
|||
{
|
||||
int invasionSize = 0;
|
||||
|
||||
if (TShock.Config.InfiniteInvasion)
|
||||
if (TShock.Config.Settings.InfiniteInvasion)
|
||||
{
|
||||
// Not really an infinite size
|
||||
invasionSize = 20000000;
|
||||
}
|
||||
else
|
||||
{
|
||||
invasionSize = 100 + (TShock.Config.InvasionMultiplier * GetActivePlayerCount());
|
||||
invasionSize = 100 + (TShock.Config.Settings.InvasionMultiplier * GetActivePlayerCount());
|
||||
}
|
||||
|
||||
// Order matters
|
||||
|
|
@ -1170,7 +1170,7 @@ namespace TShockAPI
|
|||
/// <summary>Verifies that each stack in each chest is valid and not over the max stack count.</summary>
|
||||
internal void FixChestStacks()
|
||||
{
|
||||
if (TShock.Config.IgnoreChestStacksOnLoad)
|
||||
if (TShock.Config.Settings.IgnoreChestStacksOnLoad)
|
||||
return;
|
||||
|
||||
foreach (Chest chest in Main.chest)
|
||||
|
|
@ -1191,9 +1191,9 @@ namespace TShockAPI
|
|||
internal void SetConsoleTitle(bool empty)
|
||||
{
|
||||
Console.Title = string.Format("{0}{1}/{2} on {3} @ {4}:{5} (TShock for Terraria v{6})",
|
||||
!string.IsNullOrWhiteSpace(TShock.Config.ServerName) ? TShock.Config.ServerName + " - " : "",
|
||||
!string.IsNullOrWhiteSpace(TShock.Config.Settings.ServerName) ? TShock.Config.Settings.ServerName + " - " : "",
|
||||
empty ? 0 : GetActivePlayerCount(),
|
||||
TShock.Config.MaxSlots, Main.worldName, Netplay.ServerIP.ToString(), Netplay.ListenPort, TShock.VersionNum);
|
||||
TShock.Config.Settings.MaxSlots, Main.worldName, Netplay.ServerIP.ToString(), Netplay.ListenPort, TShock.VersionNum);
|
||||
}
|
||||
|
||||
/// <summary>Determines the distance between two vectors.</summary>
|
||||
|
|
@ -1216,7 +1216,7 @@ namespace TShockAPI
|
|||
{
|
||||
Vector2 tile = new Vector2(x, y);
|
||||
Vector2 spawn = new Vector2(Main.spawnTileX, Main.spawnTileY);
|
||||
return Distance(spawn, tile) <= TShock.Config.SpawnProtectionRadius;
|
||||
return Distance(spawn, tile) <= TShock.Config.Settings.SpawnProtectionRadius;
|
||||
}
|
||||
|
||||
/// <summary>Computes the max styles...</summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue