Skip to content

Commit

Permalink
clean code, fix config read
Browse files Browse the repository at this point in the history
  • Loading branch information
Megghy committed Nov 15, 2022
1 parent 1c1db9e commit a15a680
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 107 deletions.
8 changes: 4 additions & 4 deletions VeinMiner.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Global
{45F39A34-EFCD-4732-87B5-E7A1E759B234}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45F39A34-EFCD-4732-87B5-E7A1E759B234}.Debug|x64.ActiveCfg = Debug|x64
{45F39A34-EFCD-4732-87B5-E7A1E759B234}.Debug|x64.Build.0 = Debug|x64
{45F39A34-EFCD-4732-87B5-E7A1E759B234}.Release|Any CPU.ActiveCfg = Release|x64
{45F39A34-EFCD-4732-87B5-E7A1E759B234}.Release|Any CPU.Build.0 = Release|x64
{45F39A34-EFCD-4732-87B5-E7A1E759B234}.Release|x64.ActiveCfg = Release|x64
{45F39A34-EFCD-4732-87B5-E7A1E759B234}.Release|x64.Build.0 = Release|x64
{45F39A34-EFCD-4732-87B5-E7A1E759B234}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45F39A34-EFCD-4732-87B5-E7A1E759B234}.Release|Any CPU.Build.0 = Release|Any CPU
{45F39A34-EFCD-4732-87B5-E7A1E759B234}.Release|x64.ActiveCfg = Release|Any CPU
{45F39A34-EFCD-4732-87B5-E7A1E759B234}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
42 changes: 24 additions & 18 deletions VeinMiner/Config.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using TShockAPI;
using TShockAPI.Hooks;

Expand All @@ -13,26 +13,32 @@ public static void Load(ReloadEventArgs args = null)
{
try
{
if (!File.Exists(Path.Combine(TShock.SavePath, "VeinMiner.json"))) FileTools.CreateIfNot(Path.Combine(TShock.SavePath, "VeinMiner.json"), JsonConvert.SerializeObject(VeinMiner.Config, Formatting.Indented));
FileTools.CreateIfNot(Path.Combine(TShock.SavePath, "VeinMiner.json"), JsonConvert.SerializeObject(new Config()
{
Exchange = new()
{
new()
{
OnlyGiveItem = true,
MinSize = 10,
Type = 169,
Item = new() { { 953, 1 }, { 2425, 5 } }
}
},
Tile = new() { 7, 166, 6, 167, 9, 168, 8, 169, 37, 22, 204, 56, 58, 107, 221, 108, 222, 111, 223, 211, 408, 123, 224, 404, 178, 63, 64, 65, 66, 67, 68 }
}, Formatting.Indented));

VeinMiner.Config = JsonConvert.DeserializeObject<Config>(File.ReadAllText(Path.Combine(TShock.SavePath, "VeinMiner.json")));
if (args != null) TShock.Log.ConsoleInfo($"<VeinMiner> Config reloaded.");
if (args != null)
TShock.Log.ConsoleInfo($"<VeinMiner> Config reloaded.");
}
catch (Exception ex) { TShock.Log.Error(ex.Message); TShock.Log.ConsoleError("<VeinMiner> Failed to read config file."); }
}
public bool Enable = true;
public bool Broadcast = true;
public bool PutInInventory = true;
public List<int> Tile = new() { 7, 166, 6, 167, 9, 168, 8, 169, 37, 22, 204, 56, 58, 107, 221, 108, 222, 111, 223, 211, 408, 123, 224, 404, 178, 63, 64, 65, 66, 67, 68 };
public List<Exchange> Exchange = new()
{
new()
{
OnlyGiveItem = true,
MinSize = 10,
Type = 169,
Item = new() { { 953, 1 }, { 2425, 5 } }
}
};
public bool Enable { get; set; } = true;
public bool Broadcast { get; set; } = true;
public bool PutInInventory { get; set; } = true;
public List<int> Tile { get; set; } = new();
public List<Exchange> Exchange { get; set; } = new();
}
public struct Exchange
{
Expand Down
40 changes: 0 additions & 40 deletions VeinMiner/Properties/AssemblyInfo.cs

This file was deleted.

9 changes: 2 additions & 7 deletions VeinMiner/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria;
using TShockAPI;

namespace VeinMiner
Expand All @@ -12,7 +7,7 @@ class Utils
{
public static Item GetItemFromTile(int x, int y)
{
WorldGen.KillTile_GetItemDrops(x,y, Main.tile[x, y], out int id, out int stack, out _, out _);
WorldGen.KillTile_GetItemDrops(x, y, Main.tile[x, y], out int id, out int stack, out _, out _);
Item item = new();
item.SetDefaults(id);
item.stack = stack;
Expand Down
2 changes: 1 addition & 1 deletion VeinMiner/VeinMiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class VeinMiner : TerrariaPlugin
{
public override string Name => "VeinMiner";
public override Version Version => System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
public override string Author => "Megghy|YSpoof";
public override string Author => "Megghy|YSpoof";
public override string Description => "VeinMiner by Megghy but with TShock 5 support!";
internal static Config Config = new();
public VeinMiner(Main game) : base(game)
Expand Down
26 changes: 13 additions & 13 deletions VeinMiner/VeinMiner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Platforms>x64</Platforms>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>.\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutputPath>.\</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.346202">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="MySql.Data" Version="8.0.31" />
<None Remove="C:\Users\MegghyUwU\.nuget\packages\tshock\5.0.0\contentFiles\any\net6.0\HttpServer.dll" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="TShock" Version="5.0.0" />
</ItemGroup>
<PropertyGroup>
<PlatformTarget>x64</PlatformTarget>
<AssemblyVersion>1.6.0.2</AssemblyVersion>
<FileVersion>1.6.0.2</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningLevel>7</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<WarningLevel>7</WarningLevel>
</PropertyGroup>
</Project>
17 changes: 0 additions & 17 deletions VeinMiner/app.config

This file was deleted.

7 changes: 0 additions & 7 deletions VeinMiner/packages.config

This file was deleted.

0 comments on commit a15a680

Please sign in to comment.