-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HERO's Mod & Config Optimization (#14)
* Added HERO's Mod server config permissions. * Moved Sell Item config into server scope.
- Loading branch information
1 parent
e2bab49
commit b9bf446
Showing
6 changed files
with
86 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ obj | |
App.config | ||
/.vs/AutoTrash/v16/.suo | ||
/AutoTrash.sln | ||
*.v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,47 @@ | ||
using Microsoft.Xna.Framework; | ||
using System.ComponentModel; | ||
using Terraria; | ||
using Terraria.ModLoader.Config; | ||
|
||
namespace AutoTrash | ||
{ | ||
class AutoTrashServerConfig : ModConfig | ||
{ | ||
public override ConfigScope Mode => ConfigScope.ServerSide; | ||
|
||
[DefaultValue(15)] | ||
[Label("AutoSell % sell value")] | ||
[Tooltip("Customize the sell value of a item, default merchant sell value is 20%, mod's default sell value is ~15%")] | ||
[Range(1, 100)] | ||
public int SellValue; | ||
} | ||
public int SellValue { get; set; } | ||
|
||
[DefaultValue(false)] | ||
[Label("Sell items instead")] | ||
[Tooltip("Will sell items on pickup instead of trashing them")] | ||
public bool SellInstead { get; set; } | ||
|
||
public override bool AcceptClientChanges(ModConfig pendingConfig, int whoAmI, ref string message) | ||
{ | ||
string deny = "You do not have proper permission."; | ||
string accept = "Your changes have been accepted."; | ||
|
||
if (AutoTrash.instance.herosmod != null) | ||
{ | ||
if (AutoTrash.instance.herosmod.Call("HasPermission", whoAmI, AutoTrash.heropermission) is bool result && result) | ||
{ | ||
message = accept; | ||
return true; | ||
} | ||
} | ||
else | ||
{ | ||
message = accept; | ||
return true; | ||
} | ||
message = deny; | ||
return false; | ||
} | ||
|
||
} | ||
|
||
} |