-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModConfig.cs
171 lines (160 loc) · 6.6 KB
/
ModConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
using Newtonsoft.Json;
using System.ComponentModel;
using Terraria;
using Terraria.Localization;
using Terraria.ModLoader.Config;
namespace PresentOpener
{
public class PresentOpenerConfig : ModConfig
{
public override bool Autoload(ref string name) //Autoloading config with a name
{
name = Language.GetTextValue("Mods.PresentOpener.common.ConfigName"); //I'd like to personally thank TheStachelFisch for imploding this config with Localization.
return true;
}
public override ConfigScope Mode => ConfigScope.ServerSide; //Server sided config.
[Label(Language.GetTextValue("Mods.PresentOpener.common.PresentMenuConfig"))] //This is how you make a folder, essentially it's just a separate class.
public PresentMenu presentmenu = new PresentMenu();
[Label(Language.GetTextValue("Mods.PresentOpener.common.GoodieBagMenuConfig"))]
public GoodieMenu goodiemenu = new GoodieMenu();
[Label(Language.GetTextValue("Mods.PresentOpener.common.ModdedItemsMenuConfig"))]
public ModdedMenu moddedmenu = new ModdedMenu();
[SeparatePage] //To force the class into a new page, making the folder.
public class PresentMenu
{
[Header(Language.GetTextValue("common.ResetScalesConfigHeader"))]
[Label(Language.GetTextValue("common.ResetScalesConfigLabel"))]
[DefaultValue(false)]
public bool DisablePresentConfig { get; set; }
[Header(Language.GetTextValue("common.ConfigurableCategoryConfigHeader"))]
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.SnowGlobeChanceConfig"))]
public float SnowGlobeScale { get; set; } = 1.5f;
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.CoalChanceConfig"))]
public float CoalScale { get; set; } = 0.5f;
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.DogWhistleChanceScale"))]
public float WhistleScale { get; set; } = 1.25f;
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.RareItemsScaleConfigHeader"))]
[Tooltip(Language.GetTextValue("common.RareItemsScaleConfigTooltipPresentMenu"))]
public float PresentRareItemScale { get; set; } = 1.25f;
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.ToolboxChanceScale"))]
public float ToolboxScale { get; set; } = 1.25f;
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.ReinderAntlersChanceScale"))]
public float AntlersScale { get; set; } = 0.75f;
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.HollyChanceScale"))]
public float HollyScale { get; set; } = 0.75f;
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.VanityClothesChanceScale"))]
public float VanityScale { get; set; } = 0.75f;
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.FoodChanceScale"))]
public float FoodScale { get; set; } = 1f;
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.EggnogChanceScale"))]
public float EggnogScale { get; set; } = 1f;
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.StarAniseChanceScale"))]
public float StarAniseScale { get; set; } = 1f;
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.BlockChanceScale"))]
public float BlockScale { get; set; } = 1f;
}
[SeparatePage]
public class GoodieMenu
{
[Header(Language.GetTextValue("common.ResetScalesConfigHeader"))]
[Label(Language.GetTextValue("common.ResetScalesConfigLabel"))]
[DefaultValue(false)]
public bool DisableGoodieConfig { get; set; }
[Header(Language.GetTextValue("common.ConfigurableCategoryConfigHeader"))]
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.RareItemsScaleConfigHeader"))]
[Tooltip(Language.GetTextValue("common.RareItemsScaleConfigTooltipGoodieMenu"))]
public float GoodieRareItemScale { get; set; } = 1.25f;
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.RottenEggChanceScale"))]
public float RottenEggScale { get; set; } = 0.75f;
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.PaintingChanceScale"))]
public float PaintingScale { get; set; } = 0.75f;
[Range(0.25f, 4f)]
[Increment(0.25f)]
[Label(Language.GetTextValue("common.CostumeChanceScale"))]
public float CostumeScale { get; set; } = 0.75f;
}
[SeparatePage]
public class ModdedMenu
{
[Header(Language.GetTextValue("common.ResetScalesConfigHeader"))]
[Label(Language.GetTextValue("common.ResetScalesConfigLabel"))]
public bool DisableModdedConfigs { get; set; }
[Header(Language.GetTextValue("common.ModdedMenuThoriumHeader"))]
[Label(Language.GetTextValue("common.MistletoeChanceScale"))]
[Range(0.25f, 4f)]
[Increment(0.25f)]
public float ThoriumMistleScale { get; set; } = 1f;
[Header(Language.GetTextValue("common.ModdedMenuSpiritHeader"))]
[Label(Language.GetTextValue("common.AppleChanceScale"))]
[Tooltip(Language.GetTextValue("common.AppleChanceScaleTooltip"))]
[Range(0.25f, 4f)]
[Increment(0.25f)]
public float AppleScale { get; set; } = 0.5f;
[Label(Language.GetTextValue("common.CandyChanceScale"))]
[Tooltip(Language.GetTextValue("common.CandyChanceScaleTooltip"))]
[Range(0.25f, 4f)]
[Increment(0.25f)]
public float SpiritCandyScale { get; set; } = 1f;
[Label(Language.GetTextValue("common.MysteryCandyChanceScale"))]
[Range(0.25f, 4f)]
[Increment(0.25f)]
public float MysteryCandyScale { get; set; } = 1f;
[Label(Language.GetTextValue("common.SpiritDevMaskChanceScale"))]
[Tooltip(Language.GetTextValue("common.SpiritDevMaskChanceScale"))]
[Range(0.25f, 4f)]
[Increment(0.25f)]
public float SpiritDevMaskScale { get; set; } = 0.75f;
}
public bool IsPlayerLocalServerOwner(Player player) //coming back to this code after 3 months and I still can't follow it but it works I guess
{
for (int plr = 0; plr < Main.maxPlayers; plr++)
{
System.Console.WriteLine(Netplay.Clients[plr].Socket.GetRemoteAddress());
if (Netplay.Clients[plr].State == 10 && Main.player[plr] == player && Netplay.Clients[plr].Socket.GetRemoteAddress().IsLocalHost())
{
return true;
}
}
return false;
}
public override bool AcceptClientChanges(ModConfig pendingConfig, int whoAmI, ref string message)
{
if (!IsPlayerLocalServerOwner(Main.LocalPlayer)) //If the player is not the Host of a server, deny them changing the config
{
message = Language.GetTextValue("common.NotServerHostError");
return false;
}
else return true;
}
}
}