Compare commits

...

2 commits

Author SHA1 Message Date
45b024654a Ship 1.0.11 with the farmland feature 2025-05-07 12:21:23 -07:00
419c05dbac Add farmland drop 2025-05-07 12:15:23 -07:00
5 changed files with 142 additions and 19 deletions

View file

@ -275,7 +275,7 @@ namespace AriasServerUtils
{
ServerUtilities.config.AdminsBypassMaxHomes = bypass;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", bypass));
}
return TextCommandResult.Success();
@ -289,7 +289,7 @@ namespace AriasServerUtils
ServerUtilities.config.MaxBackCache = max;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", max));
}
return TextCommandResult.Success();
@ -302,7 +302,7 @@ namespace AriasServerUtils
ServerUtilities.config.MaxHomes = maxHomes;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", maxHomes));
}
return TextCommandResult.Success();
@ -311,19 +311,32 @@ namespace AriasServerUtils
internal static TextCommandResult HandleUpdateASUMgrWarps(TextCommandCallingArgs args)
{
if (args[0] is bool mgr)
{
ServerUtilities.config.onlyAdminsCreateWarps = mgr;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", mgr));
}
else ServerUtilities.config.onlyAdminsCreateWarps = true;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", true));
}
internal static TextCommandResult HandleUpdateASUPSP(TextCommandCallingArgs args)
{
if (args[0] is int psp) ServerUtilities.config.PlayerSleepingPercentage = psp;
ServerUtilities.MarkDirty();
if (args[0] is int psp)
{
ServerUtilities.config.PlayerSleepingPercentage = psp;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", psp));
}
return TextCommandResult.Success();
}
internal static TextCommandResult HandleWarp(TextCommandCallingArgs args)
@ -431,7 +444,7 @@ namespace AriasServerUtils
ServerUtilities.config.MaxRTPBlockDistance = maxDist;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", maxDist));
}
return TextCommandResult.Success();
@ -444,7 +457,7 @@ namespace AriasServerUtils
ServerUtilities.config.Cooldowns[CooldownType.Back] = CD;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", CD));
}
else
{
@ -462,7 +475,7 @@ namespace AriasServerUtils
ServerUtilities.config.Cooldowns[CooldownType.Warp] = CD;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", CD));
}
else
{
@ -480,7 +493,7 @@ namespace AriasServerUtils
ServerUtilities.config.Cooldowns[CooldownType.Home] = CD;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", CD));
}
else
{
@ -498,7 +511,7 @@ namespace AriasServerUtils
ServerUtilities.config.Cooldowns[CooldownType.Spawn] = CD;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", CD));
}
else
{
@ -516,7 +529,7 @@ namespace AriasServerUtils
ServerUtilities.config.Cooldowns[CooldownType.RTP] = CD;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", CD));
}
else
{
@ -542,7 +555,7 @@ namespace AriasServerUtils
// Update the bypass
ServerUtilities.config.AdminsBypassCooldowns = bypass;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", bypass));
}
else return TextCommandResult.Success();
}
@ -554,11 +567,43 @@ namespace AriasServerUtils
// Update the flag
ServerUtilities.config.AdminsBypassRTPMaxDistance = bypass;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", bypass));
}
else return TextCommandResult.Success();
}
internal static TextCommandResult HandleUpdateASUFarmlandDowngrade(TextCommandCallingArgs args)
{
if (args[0] is bool downgrade)
{
// Update the flag
ServerUtilities.config.EnableFarmlandDowngrade = downgrade;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", downgrade));
}
else
{
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:farmland-downgrade", ServerUtilities.config.EnableFarmlandDowngrade));
}
}
internal static TextCommandResult HandleUpdateASUFarmlandDrop(TextCommandCallingArgs args)
{
if (args[0] is bool drop)
{
// Update the flag
ServerUtilities.config.EnableFarmlandDrop = drop;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig", drop));
}
else
{
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:farmland-drop", ServerUtilities.config.EnableFarmlandDrop));
}
}
internal static TextCommandResult HandleListCooldowns(TextCommandCallingArgs args)
{
string sReturn = "SERVER COOLDOWN SETTINGS\n";
@ -588,5 +633,53 @@ namespace AriasServerUtils
}
return TextCommandResult.Success();
}
internal static void CheckBreakFarmland(IServerPlayer byPlayer, BlockSelection blockSel, ref float dropQuantityMultiplier, ref EnumHandling handling)
{
if (!ServerUtilities.config.EnableFarmlandDrop)
{
return; // Default behavior
}
if (blockSel.Block is BlockFarmland farmland)
{
BlockEntityFarmland beFarmland = farmland.GetBlockEntity<BlockEntityFarmland>(blockSel.Position);
string farmlandType = blockSel.Block.LastCodePart();
if (ServerUtilities.config.EnableFarmlandDowngrade)
{
switch (farmlandType)
{
case "verylow":
{ // barren
break; // Can't downgrade further
}
case "low":
{
farmlandType = "verylow";
break;
}
case "medium":
{
farmlandType = "low";
break;
}
case "compost":
{ // high
farmlandType = "medium";
break;
}
case "high":
{ // Terra preta
farmlandType = "compost";
break;
}
}
}
byPlayer.Entity.World.SpawnItemEntity(new ItemStack(byPlayer.Entity.World.GetBlock(new AssetLocation($"soil-{farmlandType}-none"))), blockSel.Position.ToVec3d().Add(0.5, 0.5, 0.5));
}
}
}
}

View file

@ -22,7 +22,7 @@ namespace AriasServerUtils
{ CooldownType.RTP, "30s" },
{ CooldownType.Back, "5s" }
};
private static readonly int CURRENT_VERSION = 5;
private static readonly int CURRENT_VERSION = 6;
public int Version { get; set; } = 0;
@ -36,11 +36,25 @@ namespace AriasServerUtils
public int MaxRTPBlockDistance { get; set; } = 50000;
public Dictionary<CooldownType, string> Cooldowns { get; set; } = new Dictionary<CooldownType, string>();
/// <summary>
/// If true, attempts to downgrade the soil quality when breaking farmland.
/// </summary>
public bool EnableFarmlandDowngrade { get; set; } = false;
/// <summary>
/// If true, farmland will drop as soil when broken.
/// </summary>
public bool EnableFarmlandDrop { get; set; } = true;
public Dictionary<CooldownType, string> GetDefaultCooldowns()
{
return m_defaultCD;
}
/// <summary>
/// Performs some checks against known possible invalid values and sets them to sane values.
/// </summary>
public void SanityCheck()
{
foreach (var cd in GetDefaultCooldowns())

View file

@ -94,6 +94,7 @@ namespace AriasServerUtils
api.Event.PlayerJoin += OnPlayerJoin;
api.Event.PlayerDisconnect += OnPlayerDC;
api.Event.ChunkColumnLoaded += RTPFactory.ChunkLoaded;
api.Event.BreakBlock += Events.CheckBreakFarmland;
//api.Event.PlayerLeave += OnPlayerDC;
@ -181,6 +182,18 @@ namespace AriasServerUtils
.WithDescription("Update RTP Max block distance. Plus and/or minus this distance from player current position (Default is 50000)")
.HandleWith(Events.HandleUpdateASURTPMax)
.EndSubCommand()
.BeginSubCommand("farmlandDowngrade")
.RequiresPrivilege(Privilege.controlserver)
.WithArgs(parsers.OptionalBool("downgrade"))
.WithDescription("Enables or disables farmland downgrade when breaking farmland")
.HandleWith(Events.HandleUpdateASUFarmlandDowngrade)
.EndSubCommand()
.BeginSubCommand("farmlandDrop")
.RequiresPrivilege(Privilege.controlserver)
.WithArgs(parsers.OptionalBool("drop"))
.WithDescription("Enables or disables dropping soil when breaking farmland")
.HandleWith(Events.HandleUpdateASUFarmlandDrop)
.EndSubCommand()
.BeginSubCommand("cooldowns")
.WithDescription("Commands related to all the various cooldowns")
.BeginSubCommand("back")

View file

@ -20,9 +20,12 @@
"help": "All Aria's Server Utilities Commands: \n\nMax Homes: {0}; \nAdmins can bypass max homes: {1}\nMax back positions: {2}\n\n{3}",
"updatedconfig": "[ASU] server config updated",
"updatedconfig": "[ASU] server config updated with the new value: {0}",
"config-value-reset": "[ASU] server config value reset to default",
"farmland-downgrade": "The current farmland downgrade setting is {0}",
"farmland-drop": "The current farmland drop setting is {0}",
"warp-tp": "Teleported to warp [{0}]",
"warp-set": "Warp [{0}] created!",
"warp-no": "You lack permissions to manage a warp",

View file

@ -3,8 +3,8 @@
"modid": "ariasserverutils",
"name": "Aria's Server Utilities",
"authors": ["zontreck"],
"description": "A collection of server utilities\n\nBuild Date: 05-3-2025 @ 2:23 PM MST",
"version": "1.0.10",
"description": "A collection of server utilities\n\nBuild Date: 05-7-2025 @ 12:21 PM MST",
"version": "1.0.11",
"dependencies": {
"game": ""
}