forked from Patrikkk/DieMob
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- removed waste - code cleaned - better practices implemented - /dm alias now works - /dm reload, help & clear added - better error handling
- Loading branch information
Showing
8 changed files
with
146 additions
and
3,127 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 |
---|---|---|
@@ -1,41 +1,34 @@ | ||
using Auxiliary; | ||
using Auxiliary.Configuration; | ||
using MongoDB.Driver; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using TShockAPI; | ||
|
||
namespace DieMob.Api | ||
{ | ||
public class DiemobApi | ||
{ | ||
public class DiemobApi | ||
{ | ||
|
||
public void DeleteDiemob(string regionName) | ||
{ | ||
StorageProvider.GetMongoCollection<DieMobRegion>("DieMobRegions").FindOneAndDeleteAsync(x => x.Region == regionName); | ||
} | ||
public void DeleteDiemob(string regionName) => StorageProvider.GetMongoCollection<DieMobRegion>("DieMobRegions").FindOneAndDeleteAsync(x => x.Region == regionName); | ||
|
||
public List<DieMobRegion> RetrieveAllRegions() | ||
{ | ||
return StorageProvider.GetMongoCollection<DieMobRegion>("DieMobRegions").Find(x => true).ToList(); | ||
public List<DieMobRegion> RetrieveAllRegions() => StorageProvider.GetMongoCollection<DieMobRegion>("DieMobRegions").Find(x => true).ToList(); | ||
|
||
} | ||
public async Task<DieMobRegion> RetrieveRegion(string regionName) => await IModel.GetAsync(GetRequest.Bson<DieMobRegion>(x => x.Region == regionName)); | ||
|
||
public async Task<DieMobRegion> RetrieveRegion(string regionName) | ||
{ | ||
return await IModel.GetAsync(GetRequest.Bson<DieMobRegion>(x => x.Region == regionName)); | ||
} | ||
|
||
public async Task<DieMobRegion> CreateDieMobRegion(string regionName) | ||
=> await IModel.GetAsync(GetRequest.Bson<DieMobRegion>(x => x.Region == regionName), x => | ||
{ | ||
x.Region = TShock.Regions.GetRegionByName(regionName).Name; | ||
x.AffectFriendlyNPCs = false; | ||
x.AffectStatueSpawns = true; | ||
x.ReplaceMobs = new(); | ||
x.Type = RegionType.Kill; | ||
}); | ||
|
||
public async Task<DieMobRegion> CreateDieMobRegion(string regionName) | ||
=> await IModel.GetAsync(GetRequest.Bson<DieMobRegion>(x => x.Region == regionName), x => | ||
{ | ||
x.Region = TShock.Regions.GetRegionByName(regionName).Name; | ||
x.AffectFriendlyNPCs = false; | ||
x.AffectStatueSpawns = true; | ||
x.ReplaceMobs = new(); | ||
x.Type = RegionType.Kill; | ||
}); | ||
public void ReloadDieMob() => Configuration<DiemobSettings>.Load(nameof(DieMob)); | ||
|
||
|
||
} | ||
} | ||
} |
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,9 +1,9 @@ | ||
namespace DieMob | ||
{ | ||
public enum RegionType | ||
{ | ||
Kill = 0, | ||
Repel = 1, | ||
Passive = 2 | ||
} | ||
public enum RegionType | ||
{ | ||
Kill = 0, | ||
Repel = 1, | ||
Passive = 2 | ||
} | ||
} |
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
Oops, something went wrong.