Skip to content

Commit 04be9a1

Browse files
committedNov 26, 2020
Add project files.
1 parent 329aaf0 commit 04be9a1

File tree

6 files changed

+553
-0
lines changed

6 files changed

+553
-0
lines changed
 

‎.gitignore.txt

+346
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
##
4+
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5+
6+
# User-specific files
7+
*.rsuser
8+
*.suo
9+
*.user
10+
*.userosscache
11+
*.sln.docstates
12+
13+
# User-specific files (MonoDevelop/Xamarin Studio)
14+
*.userprefs
15+
16+
# Build results
17+
[Dd]ebug/
18+
[Dd]ebugPublic/
19+
[Rr]elease/
20+
[Rr]eleases/
21+
x64/
22+
x86/
23+
[Aa][Rr][Mm]/
24+
[Aa][Rr][Mm]64/
25+
bld/
26+
[Bb]in/
27+
[Oo]bj/
28+
[Ll]og/
29+
azure-pipelines.yml
30+
LICENSE
31+
README.MD
32+
*.sln
33+
34+
# Visual Studio 2015/2017 cache/options directory
35+
.vs/
36+
# Uncomment if you have tasks that create the project's static files in wwwroot
37+
#wwwroot/
38+
39+
# Visual Studio 2017 auto generated files
40+
Generated\ Files/
41+
42+
# MSTest test Results
43+
[Tt]est[Rr]esult*/
44+
[Bb]uild[Ll]og.*
45+
46+
# NUNIT
47+
*.VisualState.xml
48+
TestResult.xml
49+
50+
# Build Results of an ATL Project
51+
[Dd]ebugPS/
52+
[Rr]eleasePS/
53+
dlldata.c
54+
[Pp]roperties
55+
56+
# Benchmark Results
57+
BenchmarkDotNet.Artifacts/
58+
59+
# .NET Core
60+
project.lock.json
61+
project.fragment.lock.json
62+
artifacts/
63+
64+
# StyleCop
65+
StyleCopReport.xml
66+
67+
# Files built by Visual Studio
68+
*_i.c
69+
*_p.c
70+
*_h.h
71+
*.ilk
72+
*.meta
73+
*.sln
74+
*.obj
75+
*.iobj
76+
*.pch
77+
*.pdb
78+
*.ipdb
79+
*.pgc
80+
*.pgd
81+
*.rsp
82+
*.sbr
83+
*.tlb
84+
*.tli
85+
*.tlh
86+
*.tmp
87+
*.tmp_proj
88+
*_wpftmp.csproj
89+
*.log
90+
*.vspscc
91+
*.vssscc
92+
.builds
93+
*.pidb
94+
*.svclog
95+
*.scc
96+
97+
# Chutzpah Test files
98+
_Chutzpah*
99+
100+
# Visual C++ cache files
101+
ipch/
102+
*.aps
103+
*.ncb
104+
*.opendb
105+
*.opensdf
106+
*.sdf
107+
*.cachefile
108+
*.VC.db
109+
*.VC.VC.opendb
110+
111+
# Visual Studio profiler
112+
*.psess
113+
*.vsp
114+
*.vspx
115+
*.sap
116+
117+
# Visual Studio Trace Files
118+
*.e2e
119+
120+
# TFS 2012 Local Workspace
121+
$tf/
122+
123+
# Guidance Automation Toolkit
124+
*.gpState
125+
126+
# ReSharper is a .NET coding add-in
127+
_ReSharper*/
128+
*.[Rr]e[Ss]harper
129+
*.DotSettings.user
130+
131+
# JustCode is a .NET coding add-in
132+
.JustCode
133+
134+
# TeamCity is a build add-in
135+
_TeamCity*
136+
137+
# DotCover is a Code Coverage Tool
138+
*.dotCover
139+
140+
# AxoCover is a Code Coverage Tool
141+
.axoCover/*
142+
!.axoCover/settings.json
143+
144+
# Visual Studio code coverage results
145+
*.coverage
146+
*.coveragexml
147+
148+
# NCrunch
149+
_NCrunch_*
150+
.*crunch*.local.xml
151+
nCrunchTemp_*
152+
153+
# MightyMoose
154+
*.mm.*
155+
AutoTest.Net/
156+
157+
# Web workbench (sass)
158+
.sass-cache/
159+
160+
# Installshield output folder
161+
[Ee]xpress/
162+
163+
# DocProject is a documentation generator add-in
164+
DocProject/buildhelp/
165+
DocProject/Help/*.HxT
166+
DocProject/Help/*.HxC
167+
DocProject/Help/*.hhc
168+
DocProject/Help/*.hhk
169+
DocProject/Help/*.hhp
170+
DocProject/Help/Html2
171+
DocProject/Help/html
172+
173+
# Click-Once directory
174+
publish/
175+
176+
# Publish Web Output
177+
*.[Pp]ublish.xml
178+
*.azurePubxml
179+
# Note: Comment the next line if you want to checkin your web deploy settings,
180+
# but database connection strings (with potential passwords) will be unencrypted
181+
*.pubxml
182+
*.publishproj
183+
184+
# Microsoft Azure Web App publish settings. Comment the next line if you want to
185+
# checkin your Azure Web App publish settings, but sensitive information contained
186+
# in these scripts will be unencrypted
187+
PublishScripts/
188+
189+
# NuGet Packages
190+
*.nupkg
191+
# The packages folder can be ignored because of Package Restore
192+
**/[Pp]ackages/*
193+
# except build/, which is used as an MSBuild target.
194+
!**/[Pp]ackages/build/
195+
# Uncomment if necessary however generally it will be regenerated when needed
196+
#!**/[Pp]ackages/repositories.config
197+
# NuGet v3's project.json files produces more ignorable files
198+
*.nuget.props
199+
*.nuget.targets
200+
201+
# Microsoft Azure Build Output
202+
csx/
203+
*.build.csdef
204+
205+
# Microsoft Azure Emulator
206+
ecf/
207+
rcf/
208+
209+
# Windows Store app package directories and files
210+
AppPackages/
211+
BundleArtifacts/
212+
Package.StoreAssociation.xml
213+
_pkginfo.txt
214+
*.appx
215+
216+
# Visual Studio cache files
217+
# files ending in .cache can be ignored
218+
*.[Cc]ache
219+
# but keep track of directories ending in .cache
220+
!?*.[Cc]ache/
221+
222+
# Others
223+
ClientBin/
224+
~$*
225+
*~
226+
*.dbmdl
227+
*.dbproj.schemaview
228+
*.jfm
229+
*.pfx
230+
*.publishsettings
231+
orleans.codegen.cs
232+
233+
# Including strong name files can present a security risk
234+
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
235+
#*.snk
236+
237+
# Since there are multiple workflows, uncomment next line to ignore bower_components
238+
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239+
#bower_components/
240+
241+
# RIA/Silverlight projects
242+
Generated_Code/
243+
244+
# Backup & report files from converting an old project file
245+
# to a newer Visual Studio version. Backup files are not needed,
246+
# because we have git ;-)
247+
_UpgradeReport_Files/
248+
Backup*/
249+
UpgradeLog*.XML
250+
UpgradeLog*.htm
251+
ServiceFabricBackup/
252+
*.rptproj.bak
253+
254+
# SQL Server files
255+
*.mdf
256+
*.ldf
257+
*.ndf
258+
259+
# Business Intelligence projects
260+
*.rdl.data
261+
*.bim.layout
262+
*.bim_*.settings
263+
*.rptproj.rsuser
264+
*- Backup*.rdl
265+
266+
# Microsoft Fakes
267+
FakesAssemblies/
268+
269+
# GhostDoc plugin setting file
270+
*.GhostDoc.xml
271+
272+
# Node.js Tools for Visual Studio
273+
.ntvs_analysis.dat
274+
node_modules/
275+
276+
# Visual Studio 6 build log
277+
*.plg
278+
279+
# Visual Studio 6 workspace options file
280+
*.opt
281+
282+
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
283+
*.vbw
284+
285+
# Visual Studio LightSwitch build output
286+
**/*.HTMLClient/GeneratedArtifacts
287+
**/*.DesktopClient/GeneratedArtifacts
288+
**/*.DesktopClient/ModelManifest.xml
289+
**/*.Server/GeneratedArtifacts
290+
**/*.Server/ModelManifest.xml
291+
_Pvt_Extensions
292+
293+
# Paket dependency manager
294+
.paket/paket.exe
295+
paket-files/
296+
297+
# FAKE - F# Make
298+
.fake/
299+
300+
# JetBrains Rider
301+
.idea/
302+
*.sln.iml
303+
304+
# CodeRush personal settings
305+
.cr/personal
306+
307+
# Python Tools for Visual Studio (PTVS)
308+
__pycache__/
309+
*.pyc
310+
311+
# Cake - Uncomment if you are using it
312+
# tools/**
313+
# !tools/packages.config
314+
315+
# Tabs Studio
316+
*.tss
317+
318+
# Telerik's JustMock configuration file
319+
*.jmconfig
320+
321+
# BizTalk build output
322+
*.btp.cs
323+
*.btm.cs
324+
*.odx.cs
325+
*.xsd.cs
326+
327+
# OpenCover UI analysis results
328+
OpenCover/
329+
330+
# Azure Stream Analytics local run output
331+
ASALocalRun/
332+
333+
# MSBuild Binary and Structured Log
334+
*.binlog
335+
336+
# NVidia Nsight GPU debugger configuration file
337+
*.nvuser
338+
339+
# MFractors (Xamarin productivity tool) working folder
340+
.mfractor/
341+
342+
# Local History for Visual Studio
343+
.localhistory/
344+
345+
# BeatPulse healthcheck temp database
346+
healthchecksdb

‎ChatColor.sln

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30709.132
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChatColor", "ChatColor\ChatColor.csproj", "{3A6DF0A7-201A-4D96-9A32-7A133F8A0670}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{3A6DF0A7-201A-4D96-9A32-7A133F8A0670}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{3A6DF0A7-201A-4D96-9A32-7A133F8A0670}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{3A6DF0A7-201A-4D96-9A32-7A133F8A0670}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{3A6DF0A7-201A-4D96-9A32-7A133F8A0670}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {75EAC197-ABC6-4608-B8AB-9B14617B9E5E}
24+
EndGlobalSection
25+
EndGlobal

‎ChatColor/ChatColor.csproj

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<Reference Include="Obsidian.API">
13+
<HintPath>..\..\ObsidianRepo\Obsidian.API\bin\Debug\net5.0\Obsidian.API.dll</HintPath>
14+
</Reference>
15+
</ItemGroup>
16+
17+
</Project>

‎ChatColor/Config.cs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Serialization;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Text;
6+
7+
namespace ChatColor
8+
{
9+
[JsonObject(MemberSerialization.OptIn, NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
10+
public class Config
11+
{
12+
[JsonProperty(Required = Required.Always)]
13+
public bool Enabled { get; set; } = true;
14+
15+
[JsonProperty(Required = Required.Always)]
16+
public string ChatFormat { get; set; } = "<{PLAYER}> {MESSAGE}";
17+
}
18+
}

‎ChatColor/Globals.cs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Obsidian.API.Plugins;
2+
using Obsidian.API.Plugins.Services;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace ChatColor
10+
{
11+
public class Globals
12+
{
13+
public static Config Config { get; set; }
14+
public static IFileReader FileReader { get; set; }
15+
public static IFileWriter FileWriter { get; set; }
16+
public static string WorkingDirectory { get; set; }
17+
public static IPluginInfo PluginInfo { get; set; }
18+
}
19+
}

‎ChatColor/Plugin.cs

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
using Newtonsoft.Json;
2+
using Obsidian.API;
3+
using Obsidian.API.Events;
4+
using Obsidian.API.Plugins;
5+
using Obsidian.API.Plugins.Services;
6+
using Obsidian.CommandFramework;
7+
using Obsidian.CommandFramework.Attributes;
8+
using Obsidian.CommandFramework.Entities;
9+
using System;
10+
using System.IO;
11+
using System.Threading.Tasks;
12+
13+
namespace ChatColor
14+
{
15+
[Plugin(Name = "ChatColor", Version = "0.1", ProjectUrl = "https://github.com/ObsidianPlugins/ChatColor",
16+
Authors = "Roxxel")]
17+
public class Plugin : PluginBase
18+
{
19+
[Inject] public ILogger Logger { get; set; }
20+
[Inject] public IFileReader FileReader { get; set; }
21+
[Inject] public IFileWriter FileWriter { get; set; }
22+
23+
public async Task OnLoad(IServer server)
24+
{
25+
Globals.FileReader = FileReader;
26+
Globals.FileWriter = FileWriter;
27+
Globals.WorkingDirectory = Info.Name;
28+
Globals.PluginInfo = this.Info;
29+
30+
31+
if (FileWriter.IsUsable)
32+
{
33+
string path = Path.Combine("ChatColor", "config.json");
34+
if (!FileWriter.FileExists(path))
35+
{
36+
await FileWriter.WriteAllTextAsync(path, JsonConvert.SerializeObject(new Config(), Formatting.Indented));
37+
Logger.Log("&aNew config file was generated, please fill it up and reload plugin. &d/cc reload");
38+
}
39+
try
40+
{
41+
Globals.Config = JsonConvert.DeserializeObject<Config>(FileReader.ReadAllText(path));
42+
43+
}
44+
catch (Exception e)
45+
{
46+
Logger.LogError($"&cThere was an error while reloading plugin:\n{e.Message}\n{e.StackTrace}");
47+
Globals.Config = new Config();
48+
}
49+
}
50+
else
51+
{
52+
Logger.LogError("&File writer isn't usable");
53+
}
54+
server.RegisterCommandClass<MainCommands>();
55+
Logger.Log($"Loaded {Info.Name}!");
56+
await Task.CompletedTask;
57+
}
58+
59+
60+
public async Task OnIncomingChatMessage(IncomingChatMessageEventArgs args)
61+
{
62+
if (Globals.Config != null && Globals.Config.Enabled)
63+
{
64+
args.Cancel = true;
65+
foreach (var player in args.Server.Players)
66+
{
67+
await player.SendMessageAsync(Globals.Config.ChatFormat
68+
.Replace("{PLAYER}", args.Player.Username)
69+
.Replace("{MESSAGE}", args.Message));
70+
}
71+
}
72+
await Task.CompletedTask;
73+
}
74+
75+
76+
}
77+
public class MainCommands : BaseCommandClass
78+
{
79+
[CommandGroup("cc")]
80+
public class ChatColorCommands
81+
{
82+
[Command("reload")]
83+
[RequirePermission(PermissionCheckType.All, true, "chatcolor.reload")]
84+
public async Task ReloadConfig(ObsidianContext ctx)
85+
{
86+
87+
if (Globals.FileWriter.IsUsable)
88+
{
89+
string path = Path.Combine("ChatColor", "config.json");
90+
if (!Globals.FileWriter.FileExists(path))
91+
{
92+
await Globals.FileWriter.WriteAllTextAsync(path, JsonConvert.SerializeObject(new Config(), Formatting.Indented));
93+
await ctx.Player.SendMessageAsync("&aNew config file was generated, please fill it up and reload plugin. &d/cc reload");
94+
}
95+
try
96+
{
97+
Globals.Config = JsonConvert.DeserializeObject<Config>(Globals.FileReader.ReadAllText(path));
98+
if (Globals.FileWriter.FileExists(path))
99+
await ctx.Player.SendMessageAsync("&aConfig reloaded successfully");
100+
}
101+
catch (Exception e)
102+
{
103+
await ctx.Player.SendMessageAsync($"&cThere was an error while reloading plugin:\n{e.Message}\n{e.StackTrace}");
104+
Globals.Config = new Config();
105+
}
106+
}
107+
else
108+
{
109+
await ctx.Player.SendMessageAsync("&cFile writer isn't usable");
110+
}
111+
}
112+
113+
[GroupCommand]
114+
[RequirePermission(PermissionCheckType.All, true, "chatcolor.main")]
115+
public async Task ChatColor(ObsidianContext ctx)
116+
{
117+
var chatFormat = Globals.Config.ChatFormat
118+
.Replace("{PLAYER}", ctx.Player.Username)
119+
.Replace("{MESSAGE}", "Woop dee doo");
120+
121+
await ctx.Player.SendMessageAsync($"&dChatColor &av{Globals.PluginInfo.Version}\n" +
122+
$"&bCurrent chat format:&r {chatFormat}");
123+
}
124+
}
125+
}
126+
127+
128+
}

0 commit comments

Comments
 (0)
Please sign in to comment.