├── .gitignore
├── 3rdPartyLicenses
├── CODE_OF_CONDUCT.md
├── Images
└── PB_logo.ico
├── LICENSE
├── Libraries
├── I18N.West.dll
├── I18N.dll
├── Newtonsoft.Json.dll
└── UnityEngine.dll
├── PointBlank.sln
├── PointBlank
├── API
│ ├── Collections
│ │ ├── ConfigurationList.cs
│ │ └── TranslationList.cs
│ ├── Commands
│ │ ├── EAllowedCaller.cs
│ │ ├── EAllowedServerState.cs
│ │ ├── ECommandRunError.cs
│ │ ├── PointBlankCommand.cs
│ │ ├── PointBlankCommandEvents.cs
│ │ └── PointBlankCommandManager.cs
│ ├── DataManagment
│ │ ├── ConfData.cs
│ │ ├── EDataType.cs
│ │ ├── ESQLDataType.cs
│ │ ├── JsonData.cs
│ │ ├── SQLData.cs
│ │ ├── UniversalData.cs
│ │ ├── WebsiteData.cs
│ │ └── XMLData.cs
│ ├── Detour
│ │ ├── DetourAttribute.cs
│ │ └── DetourManager.cs
│ ├── Discord
│ │ ├── DiscordAPI.cs
│ │ ├── DiscordClient.cs
│ │ ├── DiscordWebhook.cs
│ │ ├── EDiscordHttpCodes.cs
│ │ └── EDiscordJsonCodes.cs
│ ├── Extension
│ │ └── PointBlankExtensionAttribute.cs
│ ├── Groups
│ │ ├── PointBlankGroup.cs
│ │ ├── PointBlankGroupEvents.cs
│ │ └── PointBlankGroupManager.cs
│ ├── IPC
│ │ ├── EIPCType.cs
│ │ ├── IPCEvents.cs
│ │ └── IPCManager.cs
│ ├── Implements
│ │ ├── NetFramework.cs
│ │ ├── PointBlank.cs
│ │ └── UnityEngine.cs
│ ├── Interfaces
│ │ ├── IConfigurable.cs
│ │ └── ITranslatable.cs
│ ├── Player
│ │ ├── PointBlankPlayer.cs
│ │ ├── PointBlankPlayerComponent.cs
│ │ └── PointBlankPlayerEvents.cs
│ ├── Plugins
│ │ ├── PointBlankPlugin.cs
│ │ ├── PointBlankPluginEvents.cs
│ │ └── PointBlankPluginManager.cs
│ ├── PointBlankConsole.cs
│ ├── PointBlankLogging.cs
│ ├── PointBlankReflect.cs
│ ├── PointBlankTools.cs
│ ├── Server
│ │ └── PointBlankServer.cs
│ ├── Services
│ │ ├── PointBlankService.cs
│ │ ├── PointBlankServiceEvents.cs
│ │ └── PointBlankServiceManager.cs
│ ├── Storage
│ │ ├── Compressions
│ │ │ ├── GZip.cs
│ │ │ └── Huffman.cs
│ │ ├── ECompression.cs
│ │ └── PointBlankStorage.cs
│ └── Tasks
│ │ └── PointBlankTask.cs
├── Enviroment.cs
├── Framework
│ ├── Configurations
│ │ └── PointBlankConfigurations.cs
│ ├── InterfaceManager.cs
│ ├── Objects
│ │ └── RuntimeObject.cs
│ ├── Permissions
│ │ └── Ring
│ │ │ ├── RingPermission.cs
│ │ │ ├── RingPermissionAttribute.cs
│ │ │ └── RingPermissionRing.cs
│ ├── ServiceManager.cs
│ ├── Translations
│ │ └── ServiceTranslations.cs
│ └── Wrappers
│ │ └── ServiceWrapper.cs
├── PointBlank.cs
├── PointBlank.csproj
├── PointBlank.csproj.DotSettings
├── PointBlankInfo.cs
├── Properties
│ └── AssemblyInfo.cs
└── Services
│ ├── CommandManager
│ ├── CommandManager.cs
│ └── CommandWrapper.cs
│ ├── DetourManager
│ ├── DetourManager.cs
│ ├── DetourWrapper.cs
│ └── RedirectionHelper.cs
│ ├── GroupManager
│ └── GroupManager.cs
│ ├── IPCManager
│ └── IPCManager.cs
│ ├── PluginManager
│ ├── PluginConfiguration.cs
│ ├── PluginManager.cs
│ └── PluginWrapper.cs
│ ├── TaskManager
│ └── TaskManager.cs
│ └── UpdateChecker
│ └── UpdateChecker.cs
├── PointBlankSecurity
├── API
│ ├── License
│ │ └── LicenseVerifier.cs
│ └── Security
│ │ ├── EHashType.cs
│ │ └── Hashing.cs
├── PointBlankSecurity.csproj
└── Properties
│ └── AssemblyInfo.cs
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
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 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # MSTest test Results
33 | [Tt]est[Rr]esult*/
34 | [Bb]uild[Ll]og.*
35 |
36 | # NUNIT
37 | *.VisualState.xml
38 | TestResult.xml
39 |
40 | # Build Results of an ATL Project
41 | [Dd]ebugPS/
42 | [Rr]eleasePS/
43 | dlldata.c
44 |
45 | # .NET Core
46 | project.lock.json
47 | project.fragment.lock.json
48 | artifacts/
49 | **/Properties/launchSettings.json
50 |
51 | *_i.c
52 | *_p.c
53 | *_i.h
54 | *.ilk
55 | *.meta
56 | *.obj
57 | *.pch
58 | *.pdb
59 | *.pgc
60 | *.pgd
61 | *.rsp
62 | *.sbr
63 | *.tlb
64 | *.tli
65 | *.tlh
66 | *.tmp
67 | *.tmp_proj
68 | *.log
69 | *.vspscc
70 | *.vssscc
71 | .builds
72 | *.pidb
73 | *.svclog
74 | *.scc
75 |
76 | # Chutzpah Test files
77 | _Chutzpah*
78 |
79 | # Visual C++ cache files
80 | ipch/
81 | *.aps
82 | *.ncb
83 | *.opendb
84 | *.opensdf
85 | *.sdf
86 | *.cachefile
87 | *.VC.db
88 | *.VC.VC.opendb
89 |
90 | # Visual Studio profiler
91 | *.psess
92 | *.vsp
93 | *.vspx
94 | *.sap
95 |
96 | # TFS 2012 Local Workspace
97 | $tf/
98 |
99 | # Guidance Automation Toolkit
100 | *.gpState
101 |
102 | # ReSharper is a .NET coding add-in
103 | _ReSharper*/
104 | *.[Rr]e[Ss]harper
105 | *.DotSettings.user
106 |
107 | # JustCode is a .NET coding add-in
108 | .JustCode
109 |
110 | # TeamCity is a build add-in
111 | _TeamCity*
112 |
113 | # DotCover is a Code Coverage Tool
114 | *.dotCover
115 |
116 | # Visual Studio code coverage results
117 | *.coverage
118 | *.coveragexml
119 |
120 | # NCrunch
121 | _NCrunch_*
122 | .*crunch*.local.xml
123 | nCrunchTemp_*
124 |
125 | # MightyMoose
126 | *.mm.*
127 | AutoTest.Net/
128 |
129 | # Web workbench (sass)
130 | .sass-cache/
131 |
132 | # Installshield output folder
133 | [Ee]xpress/
134 |
135 | # DocProject is a documentation generator add-in
136 | DocProject/buildhelp/
137 | DocProject/Help/*.HxT
138 | DocProject/Help/*.HxC
139 | DocProject/Help/*.hhc
140 | DocProject/Help/*.hhk
141 | DocProject/Help/*.hhp
142 | DocProject/Help/Html2
143 | DocProject/Help/html
144 |
145 | # Click-Once directory
146 | publish/
147 |
148 | # Publish Web Output
149 | *.[Pp]ublish.xml
150 | *.azurePubxml
151 | # TODO: Comment the next line if you want to checkin your web deploy settings
152 | # but database connection strings (with potential passwords) will be unencrypted
153 | *.pubxml
154 | *.publishproj
155 |
156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
157 | # checkin your Azure Web App publish settings, but sensitive information contained
158 | # in these scripts will be unencrypted
159 | PublishScripts/
160 |
161 | # NuGet Packages
162 | *.nupkg
163 | # The packages folder can be ignored because of Package Restore
164 | **/packages/*
165 | # except build/, which is used as an MSBuild target.
166 | !**/packages/build/
167 | # Uncomment if necessary however generally it will be regenerated when needed
168 | #!**/packages/repositories.config
169 | # NuGet v3's project.json files produces more ignorable files
170 | *.nuget.props
171 | *.nuget.targets
172 |
173 | # Microsoft Azure Build Output
174 | csx/
175 | *.build.csdef
176 |
177 | # Microsoft Azure Emulator
178 | ecf/
179 | rcf/
180 |
181 | # Windows Store app package directories and files
182 | AppPackages/
183 | BundleArtifacts/
184 | Package.StoreAssociation.xml
185 | _pkginfo.txt
186 |
187 | # Visual Studio cache files
188 | # files ending in .cache can be ignored
189 | *.[Cc]ache
190 | # but keep track of directories ending in .cache
191 | !*.[Cc]ache/
192 |
193 | # Others
194 | ClientBin/
195 | ~$*
196 | *~
197 | *.dbmdl
198 | *.dbproj.schemaview
199 | *.jfm
200 | *.pfx
201 | *.publishsettings
202 | orleans.codegen.cs
203 |
204 | # Since there are multiple workflows, uncomment next line to ignore bower_components
205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
206 | #bower_components/
207 |
208 | # RIA/Silverlight projects
209 | Generated_Code/
210 |
211 | # Backup & report files from converting an old project file
212 | # to a newer Visual Studio version. Backup files are not needed,
213 | # because we have git ;-)
214 | _UpgradeReport_Files/
215 | Backup*/
216 | UpgradeLog*.XML
217 | UpgradeLog*.htm
218 |
219 | # SQL Server files
220 | *.mdf
221 | *.ldf
222 | *.ndf
223 |
224 | # Business Intelligence projects
225 | *.rdl.data
226 | *.bim.layout
227 | *.bim_*.settings
228 |
229 | # Microsoft Fakes
230 | FakesAssemblies/
231 |
232 | # GhostDoc plugin setting file
233 | *.GhostDoc.xml
234 |
235 | # Node.js Tools for Visual Studio
236 | .ntvs_analysis.dat
237 | node_modules/
238 |
239 | # Typescript v1 declaration files
240 | typings/
241 |
242 | # Visual Studio 6 build log
243 | *.plg
244 |
245 | # Visual Studio 6 workspace options file
246 | *.opt
247 |
248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
249 | *.vbw
250 |
251 | # Visual Studio LightSwitch build output
252 | **/*.HTMLClient/GeneratedArtifacts
253 | **/*.DesktopClient/GeneratedArtifacts
254 | **/*.DesktopClient/ModelManifest.xml
255 | **/*.Server/GeneratedArtifacts
256 | **/*.Server/ModelManifest.xml
257 | _Pvt_Extensions
258 |
259 | # Paket dependency manager
260 | .paket/paket.exe
261 | paket-files/
262 |
263 | # FAKE - F# Make
264 | .fake/
265 |
266 | # JetBrains Rider
267 | .idea/
268 | *.sln.iml
269 |
270 | # CodeRush
271 | .cr/
272 |
273 | # Python Tools for Visual Studio (PTVS)
274 | __pycache__/
275 | *.pyc
276 |
277 | # Cake - Uncomment if you are using it
278 | # tools/**
279 | # !tools/packages.config
280 |
281 | # Telerik's JustMock configuration file
282 | *.jmconfig
283 |
284 | # BizTalk build output
285 | *.btp.cs
286 | *.btm.cs
287 | *.odx.cs
288 | *.xsd.cs
--------------------------------------------------------------------------------
/3rdPartyLicenses:
--------------------------------------------------------------------------------
1 | PointBlank uses 3rd party software and API in order to keep functionality.
2 | The required legal notices of the used codes are reproduced below as we are obligated to provide such notices:
3 |
4 | - Steamworks.NET:
5 | ###############################################################################################################
6 | Copyright (c) 2015 Riley Labrecque
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy
9 | of this software and associated documentation files (the "Software"), to deal
10 | in the Software without restriction, including without limitation the rights
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | copies of the Software, and to permit persons to whom the Software is
13 | furnished to do so, subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in
16 | all copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | THE SOFTWARE.
25 | ###############################################################################################################
26 |
27 | -Json.NET:
28 | ###############################################################################################################
29 | Copyright (c) 2007 James Newton-King
30 |
31 | Permission is hereby granted, free of charge, to any person obtaining a copy of this
32 | software and associated documentation files (the "Software"), to deal in the Software
33 | without restriction, including without limitation the rights to use, copy, modify,
34 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
35 | permit persons to whom the Software is furnished to do so, subject to the following
36 | conditions:
37 |
38 | The above copyright notice and this permission notice shall be included in all copies
39 | or substantial portions of the Software.
40 |
41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
42 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
43 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
44 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
45 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
46 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47 | ###############################################################################################################
48 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6 |
7 | ## Our Standards
8 |
9 | Examples of behavior that contributes to creating a positive environment include:
10 |
11 | * Using welcoming and inclusive language
12 | * Being respectful of differing viewpoints and experiences
13 | * Gracefully accepting constructive criticism
14 | * Focusing on what is best for the community
15 | * Showing empathy towards other community members
16 |
17 | Examples of unacceptable behavior by participants include:
18 |
19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances
20 | * Trolling, insulting/derogatory comments, and personal or political attacks
21 | * Public or private harassment
22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission
23 | * Other conduct which could reasonably be considered inappropriate in a professional setting
24 |
25 | ## Our Responsibilities
26 |
27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28 |
29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30 |
31 | ## Scope
32 |
33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34 |
35 | ## Enforcement
36 |
37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at eliteinfinity1337@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38 |
39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40 |
41 | ## Attribution
42 |
43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44 |
45 | [homepage]: http://contributor-covenant.org
46 | [version]: http://contributor-covenant.org/version/1/4/
47 |
--------------------------------------------------------------------------------
/Images/PB_logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PointBlankMod/PointBlank/6bada801330bb6fb5808981b608096f8a9b79dcc/Images/PB_logo.ico
--------------------------------------------------------------------------------
/Libraries/I18N.West.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PointBlankMod/PointBlank/6bada801330bb6fb5808981b608096f8a9b79dcc/Libraries/I18N.West.dll
--------------------------------------------------------------------------------
/Libraries/I18N.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PointBlankMod/PointBlank/6bada801330bb6fb5808981b608096f8a9b79dcc/Libraries/I18N.dll
--------------------------------------------------------------------------------
/Libraries/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PointBlankMod/PointBlank/6bada801330bb6fb5808981b608096f8a9b79dcc/Libraries/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/Libraries/UnityEngine.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PointBlankMod/PointBlank/6bada801330bb6fb5808981b608096f8a9b79dcc/Libraries/UnityEngine.dll
--------------------------------------------------------------------------------
/PointBlank.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26430.16
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PointBlank", "PointBlank\PointBlank.csproj", "{1C15ECF9-39AF-4D7E-9493-47FF754514BA}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PointBlankSecurity", "PointBlankSecurity\PointBlankSecurity.csproj", "{1D66EA7A-036C-4C75-AF4A-1D89F7DE91A4}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {1C15ECF9-39AF-4D7E-9493-47FF754514BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {1C15ECF9-39AF-4D7E-9493-47FF754514BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {1C15ECF9-39AF-4D7E-9493-47FF754514BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {1C15ECF9-39AF-4D7E-9493-47FF754514BA}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {1D66EA7A-036C-4C75-AF4A-1D89F7DE91A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {1D66EA7A-036C-4C75-AF4A-1D89F7DE91A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {1D66EA7A-036C-4C75-AF4A-1D89F7DE91A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {1D66EA7A-036C-4C75-AF4A-1D89F7DE91A4}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/PointBlank/API/Collections/TranslationList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Diagnostics;
5 | using System.Reflection;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Security.Permissions;
9 | using PointBlank.Framework.Permissions.Ring;
10 |
11 | namespace PointBlank.API.Collections
12 | {
13 | ///
14 | /// Custom collection for tranlsations
15 | ///
16 | [RingPermission(SecurityAction.Demand, ring = RingPermissionRing.None)]
17 | public class TranslationList : ICollection
18 | {
19 | #region Properties
20 | ///
21 | /// The list of transaltions
22 | ///
23 | protected Dictionary Translations { get; private set; }
24 |
25 | ///
26 | /// Gets/Sets the translation text using the key provided
27 | ///
28 | /// The key to find the translation
29 | /// The translation text
30 | public string this[string key]
31 | {
32 | get => Translations[key];
33 | set => Translations[key] = value;
34 | }
35 |
36 | ///
37 | /// Gets/Sets the translation KeyValuePair using the index provided
38 | ///
39 | /// The index to find the translation
40 | /// The translation KeyValuePair
41 | public KeyValuePair this[int index]
42 | {
43 | get => Translations.ElementAt(index);
44 | set => Translations[Translations.ElementAt(index).Key] = value.Value;
45 | }
46 |
47 | ///
48 | /// Returns the amount of items in the translation list
49 | ///
50 | public int Count => Translations.Count;
51 |
52 | public object SyncRoot => throw new NotImplementedException();
53 |
54 | public bool IsSynchronized => throw new NotImplementedException();
55 | #endregion
56 |
57 | ///
58 | /// Custom collection for tranlsations
59 | ///
60 | public TranslationList()
61 | {
62 | StackTrace stack = new StackTrace(false);
63 | if (stack.FrameCount <= 0)
64 | {
65 | Translations = new Dictionary();
66 | return;
67 | }
68 | MethodBase jumpMethod = stack.GetFrame(1).GetMethod();
69 |
70 | if (!Memory.TranslationCollection.ContainsKey(jumpMethod))
71 | {
72 | Translations = new Dictionary();
73 | Memory.TranslationCollection.Add(jumpMethod, this);
74 | return;
75 | }
76 | Translations = Memory.TranslationCollection[jumpMethod].Translations;
77 | }
78 |
79 | #region Collection Functions
80 | ///
81 | /// Adds a translation entry using the key and value
82 | ///
83 | /// Key to save it as
84 | /// Value of the text
85 | public void Add(string key, string value)
86 | {
87 | if (!Translations.ContainsKey(key))
88 | Translations.Add(key, value);
89 | }
90 | ///
91 | /// Adds a translation entry using the KeyValuePair
92 | ///
93 | /// The KeyValuePair to extract the data from
94 | public void Add(KeyValuePair kvp) => this.Add(kvp.Key, kvp.Value);
95 |
96 | ///
97 | /// Removes a translation entry using the key
98 | ///
99 | /// Key of translation entry
100 | public void Remove(string key)
101 | {
102 | if (Translations.ContainsKey(key))
103 | Translations.Remove(key);
104 | }
105 | ///
106 | /// Removes a translation entry using the index
107 | ///
108 | /// Index of the entry
109 | public void RemoveAt(int index) => this.Remove(this[index].Key);
110 |
111 | ///
112 | /// Adds a range of translations using the KeyValuePair list
113 | ///
114 | /// The list of translations to add
115 | public void AddRange(IEnumerable> list)
116 | {
117 | foreach (KeyValuePair x in list)
118 | this.Add(x.Key, x.Value);
119 | }
120 | ///
121 | /// Adds a range of translations using the Translation list
122 | ///
123 | /// The list of translations to add
124 | public void AddRange(TranslationList list)
125 | {
126 | for (int i = 0; i < list.Count; i++)
127 | this.Add(list[i]);
128 | }
129 |
130 | ///
131 | /// Does the translation key exist
132 | ///
133 | /// The key of the translation
134 | /// If the translation key exists
135 | public bool ContainsKey(string key) => Translations.ContainsKey(key);
136 |
137 | ///
138 | /// Gets the enumerator and returns it
139 | ///
140 | /// Enumerator for translation list
141 | IEnumerator IEnumerable.GetEnumerator() => Translations.GetEnumerator();
142 |
143 | ///
144 | /// Copies the KeyValuePairs to the array
145 | ///
146 | /// Copy destination
147 | /// Start from index
148 | public void CopyTo(Array array, int index)
149 | {
150 | for (int i = 0; i < (this.Count - index); i++)
151 | array.SetValue(this[index + i], i);
152 | }
153 | #endregion
154 |
155 | #region SubClasses
156 | private static class Memory
157 | {
158 | public static Dictionary TranslationCollection = new Dictionary();
159 | }
160 | #endregion
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/PointBlank/API/Commands/EAllowedCaller.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace PointBlank.API.Commands
7 | {
8 | ///
9 | /// The allowed caller
10 | ///
11 | public enum EAllowedCaller
12 | {
13 | SERVER,
14 | PLAYER,
15 | BOTH
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/PointBlank/API/Commands/EAllowedServerState.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace PointBlank.API.Commands
7 | {
8 | ///
9 | /// The server state
10 | ///
11 | public enum EAllowedServerState
12 | {
13 | RUNNING,
14 | LOADING,
15 | BOTH
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/PointBlank/API/Commands/ECommandRunError.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace PointBlank.API.Commands
7 | {
8 | ///
9 | /// Error codes for executing a command
10 | ///
11 | public enum ECommandRunError
12 | {
13 | NONE,
14 | COMMAND_NOT_EXIST,
15 | NO_PERMISSION,
16 | SERVER_RUNNING,
17 | SERVER_LOADING,
18 | NOT_CONSOLE,
19 | NOT_PLAYER,
20 | ARGUMENT_COUNT,
21 | COOLDOWN,
22 | NO_EXECUTE,
23 | EXCEPTION
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/PointBlank/API/Commands/PointBlankCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using PointBlank.API.Plugins;
6 | using PointBlank.API.Player;
7 | using CM = PointBlank.Services.CommandManager.CommandManager;
8 |
9 | namespace PointBlank.API.Commands
10 | {
11 | ///
12 | /// Custom command class
13 | ///
14 | public abstract class PointBlankCommand
15 | {
16 | #region Properties
17 | ///
18 | /// The command instance
19 | ///
20 | public static PointBlankCommand Instance { get; internal set; }
21 |
22 | ///
23 | /// The commands used to execute this command
24 | ///
25 | public string[] Commands => CM.Commands.FirstOrDefault(a => a.CommandClass == this).Commands;
26 |
27 | ///
28 | /// The permissions needed to execute the command
29 | ///
30 | public string Permission => CM.Commands.FirstOrDefault(a => a.CommandClass == this).Permission;
31 |
32 | ///
33 | /// The cooldown needed to execute the command
34 | ///
35 | public int Cooldown => CM.Commands.FirstOrDefault(a => a.CommandClass == this).Cooldown;
36 |
37 | ///
38 | /// Is the command enabled
39 | ///
40 | public bool Enabled => CM.Commands.FirstOrDefault(a => a.CommandClass == this).Enabled;
41 | #endregion
42 |
43 | #region Abstract Properties
44 | ///
45 | /// If the player types any of the commands into the console it will run this command
46 | ///
47 | public abstract string[] DefaultCommands { get; }
48 |
49 | ///
50 | /// The translation key for the command help message
51 | ///
52 | public abstract string Help { get; }
53 |
54 | ///
55 | /// The translation key for the command usage message
56 | ///
57 | public abstract string Usage { get; }
58 |
59 | ///
60 | /// The permission needed to run the command
61 | ///
62 | public abstract string DefaultPermission { get; }
63 | #endregion
64 |
65 | #region Virtual Properties
66 | ///
67 | /// The minimum amount of parameters required for the command
68 | ///
69 | public virtual int MinimumParams => 0;
70 |
71 | ///
72 | /// The default cooldown(-1 to not override cooldown)
73 | ///
74 | public virtual int DefaultCooldown => -1;
75 |
76 | ///
77 | /// At what state is the command allowed to be executed
78 | ///
79 | public virtual EAllowedServerState AllowedServerState => EAllowedServerState.BOTH;
80 |
81 | ///
82 | /// Who can execute the command
83 | ///
84 | public virtual EAllowedCaller AllowedCaller => EAllowedCaller.BOTH;
85 | #endregion
86 |
87 | #region Abstract Functions
88 | ///
89 | /// Called when the player executes the command
90 | ///
91 | /// The arguments the player inputted
92 | /// The player executing the command
93 | public abstract void Execute(PointBlankPlayer executor, string[] args);
94 | #endregion
95 |
96 | public PointBlankCommand()
97 | {
98 | Instance = this;
99 | }
100 |
101 | #region Functions
102 | ///
103 | /// Translates a key and data to text depending on the translation
104 | ///
105 | /// The key of the translation
106 | /// The data to modify the translation
107 | /// The translated text
108 | public string Translate(string key, params object[] data) => PointBlankPlugin.GetInstance(this).Translate(key, data);
109 |
110 | ///
111 | /// Easy to use configuration value extractor
112 | ///
113 | /// The configuration value type
114 | /// The key of the configuration value
115 | /// The configuration value with specified type
116 | public T Configure(string key) => PointBlankPlugin.GetInstance(this).Configure(key);
117 | #endregion
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/PointBlank/API/Commands/PointBlankCommandEvents.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace PointBlank.API.Commands
7 | {
8 | ///
9 | /// Class for command events
10 | ///
11 | public static class PointBlankCommandEvents
12 | {
13 | #region Handlers
14 | ///
15 | /// Handler for command enable/disable
16 | ///
17 | /// The affected command
18 | public delegate void CommandStatusChangedHandler(PointBlankCommand command);
19 |
20 | ///
21 | /// Handler for command calls
22 | ///
23 | /// The affected command
24 | /// The arguments passed
25 | /// Should the command be executed
26 | /// The user that executed the command(null if it was the server)
27 | public delegate void CommandCalledHandler(PointBlankCommand command, string[] args, Player.PointBlankPlayer executor, ref bool allowExecute);
28 | #endregion
29 |
30 | #region Events
31 | ///
32 | /// Called when a command is enabled
33 | ///
34 | public static event CommandStatusChangedHandler OnCommandEnabled;
35 | ///
36 | /// Called when a command is disabled
37 | ///
38 | public static event CommandStatusChangedHandler OnCommandDisabled;
39 |
40 | ///
41 | /// Called when a command is executed
42 | ///
43 | public static event CommandCalledHandler OnCommandExecuted;
44 | #endregion
45 |
46 | #region Functions
47 | internal static void RunCommandEnable(PointBlankCommand command)
48 | {
49 | OnCommandEnabled?.Invoke(command);
50 | }
51 | internal static void RunCommandDisable(PointBlankCommand command)
52 | {
53 | OnCommandDisabled?.Invoke(command);
54 | }
55 |
56 | internal static void RunCommandExecute(PointBlankCommand command, string[] args, Player.PointBlankPlayer executor, ref bool allowExecute)
57 | {
58 | OnCommandExecuted?.Invoke(command, args, executor, ref allowExecute);
59 | }
60 | #endregion
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/PointBlank/API/Commands/PointBlankCommandManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using PointBlank.Services.CommandManager;
6 | using CM = PointBlank.Services.CommandManager.CommandManager;
7 |
8 | namespace PointBlank.API.Commands
9 | {
10 | ///
11 | /// All functions for managing commands
12 | ///
13 | public static class PointBlankCommandManager
14 | {
15 | #region Properties
16 | ///
17 | /// List of commands
18 | ///
19 | public static PointBlankCommand[] Commands => CM.Commands.Select(a => a.CommandClass).ToArray();
20 | #endregion
21 |
22 | #region Functions
23 | ///
24 | /// Gets a command using a class
25 | ///
26 | /// The class to get the command with
27 | /// The command
28 | public static T GetCommand() where T : PointBlankCommand => (T)Commands.FirstOrDefault(a => a.GetType() == typeof(T));
29 |
30 | ///
31 | /// Gets a command based on type
32 | ///
33 | /// The type to find the command by
34 | /// The command
35 | public static PointBlankCommand GetCommand(Type Class) => Commands.FirstOrDefault(a => a.GetType() == Class);
36 |
37 | ///
38 | /// Enables a command
39 | ///
40 | /// The command to enable
41 | public static void EnableCommand(PointBlankCommand command)
42 | {
43 | CommandWrapper wrapper = CM.Commands.FirstOrDefault(a => a.CommandClass == command);
44 |
45 | wrapper?.Enable();
46 | }
47 |
48 | ///
49 | /// Disables a command
50 | ///
51 | /// The command to disable
52 | public static void DisableCommand(PointBlankCommand command)
53 | {
54 | CommandWrapper wrapper = CM.Commands.FirstOrDefault(a => a.CommandClass == command);
55 |
56 | wrapper?.Disable();
57 | }
58 |
59 | ///
60 | /// Emulates command execution
61 | ///
62 | /// The command to execute
63 | public static ECommandRunError ExecuteCommand(string command, Player.PointBlankPlayer executor)
64 | {
65 | CM cmd = (CM)Enviroment.services["CommandManager.CommandManager"].ServiceClass;
66 |
67 | return cmd.ExecuteCommand(command, executor);
68 | }
69 | #endregion
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/PointBlank/API/DataManagment/EDataType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Security.Permissions;
6 | using PointBlank.Framework.Permissions.Ring;
7 |
8 | namespace PointBlank.API.DataManagment
9 | {
10 | [RingPermission(SecurityAction.Demand, ring = RingPermissionRing.None)]
11 | public enum EDataType
12 | {
13 | JSON,
14 | XML,
15 | //CONF, // Not done yet
16 | UNKNOWN
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/PointBlank/API/DataManagment/ESQLDataType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Security.Permissions;
6 | using PointBlank.Framework.Permissions.Ring;
7 |
8 | namespace PointBlank.API.DataManagment
9 | {
10 | [RingPermission(SecurityAction.Demand, ring = RingPermissionRing.None)]
11 | public enum ESQLDataType
12 | {
13 | INT,
14 | TINYINT,
15 | SMALLINT,
16 | MEDIUMINT,
17 | BIGINT,
18 | FLOAT_10_2,
19 | FLOAT_10_10,
20 | FLOAT_10_20,
21 | FLOAT_10_24,
22 | FLOAT_32_2,
23 | FLOAT_32_10,
24 | FLOAT_32_20,
25 | FLOAT_32_24,
26 | FLOAT_64_2,
27 | FLOAT_64_10,
28 | FLOAT_64_20,
29 | FLOAT_64_24,
30 | FLOAT_128_2,
31 | FLOAT_128_10,
32 | FLOAT_128_20,
33 | FLOAT_128_24,
34 | FLOAT_255_2,
35 | FLOAT_255_10,
36 | FLOAT_255_20,
37 | FLOAT_255_24,
38 | DOUBLE_16_4,
39 | DOUBLE_16_10,
40 | DOUBLE_16_20,
41 | DOUBLE_16_30,
42 | DOUBLE_16_40,
43 | DOUBLE_16_50,
44 | DOUBLE_16_53,
45 | DOUBLE_32_4,
46 | DOUBLE_32_10,
47 | DOUBLE_32_20,
48 | DOUBLE_32_30,
49 | DOUBLE_32_40,
50 | DOUBLE_32_50,
51 | DOUBLE_32_53,
52 | DOUBLE_64_4,
53 | DOUBLE_64_10,
54 | DOUBLE_64_20,
55 | DOUBLE_64_30,
56 | DOUBLE_64_40,
57 | DOUBLE_64_50,
58 | DOUBLE_64_53,
59 | DOUBLE_128_4,
60 | DOUBLE_128_10,
61 | DOUBLE_128_20,
62 | DOUBLE_128_30,
63 | DOUBLE_128_40,
64 | DOUBLE_128_50,
65 | DOUBLE_128_53,
66 | DOUBLE_255_4,
67 | DOUBLE_255_10,
68 | DOUBLE_255_20,
69 | DOUBLE_255_30,
70 | DOUBLE_255_40,
71 | DOUBLE_255_50,
72 | DOUBLE_255_53,
73 | DECIMAL_16_16,
74 | DECIMAL_16_32,
75 | DECIMAL_16_64,
76 | DECIMAL_16_128,
77 | DECIMAL_16_255,
78 | DECIMAL_32_16,
79 | DECIMAL_32_32,
80 | DECIMAL_32_64,
81 | DECIMAL_32_128,
82 | DECIMAL_32_255,
83 | DECIMAL_64_16,
84 | DECIMAL_64_32,
85 | DECIMAL_64_64,
86 | DECIMAL_64_128,
87 | DECIMAL_64_255,
88 | DECIMAL_128_16,
89 | DECIMAL_128_32,
90 | DECIMAL_128_64,
91 | DECIMAL_128_128,
92 | DECIMAL_128_255,
93 | DECIMAL_255_16,
94 | DECIMAL_255_32,
95 | DECIMAL_255_64,
96 | DECIMAL_255_128,
97 | DECIMAL_255_255,
98 | DATE,
99 | DATETIME,
100 | TIMESTAMP,
101 | TIME,
102 | CHAR_16,
103 | CHAR_32,
104 | CHAR_64,
105 | CHAR_128,
106 | CHAR_255,
107 | VARCHAR_16,
108 | VARCHAR_32,
109 | VARCHAR_64,
110 | VARCHAR_128,
111 | VARCHAR_255,
112 | TEXT,
113 | TINYTEXT,
114 | MEDIUMTEXT,
115 | LONGTEXT,
116 | ENUM
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/PointBlank/API/DataManagment/JsonData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Collections.Generic;
4 | using System.Security.Permissions;
5 | using System.Linq;
6 | using System.Text;
7 | using Newtonsoft.Json;
8 | using Newtonsoft.Json.Linq;
9 | using PointBlank.Framework.Permissions.Ring;
10 |
11 | namespace PointBlank.API.DataManagment
12 | {
13 | ///
14 | /// JSON data managment
15 | ///
16 | [RingPermission(SecurityAction.Demand, ring = RingPermissionRing.None)]
17 | public class JsonData
18 | {
19 | #region Properties
20 | ///
21 | /// Path to JSON file
22 | ///
23 | public string Path { get; private set; }
24 | ///
25 | /// JSON document
26 | ///
27 | public JObject Document { get; private set; }
28 | ///
29 | /// The XML document root node
30 | ///
31 | //public JArray RootNode { get; private set; }
32 |
33 | ///
34 | /// Was the JSON just created
35 | ///
36 | public bool CreatedNew { get; private set; }
37 | #endregion
38 |
39 | ///
40 | /// JSON data managment
41 | ///
42 | /// The path to json file
43 | internal JsonData(string path)
44 | {
45 | this.Path = path; // Set the path
46 | this.CreatedNew = !File.Exists(path); // Check if we have to create the file
47 |
48 | Reload(); // Run the reload
49 | }
50 |
51 | ///
52 | /// JSON data managment
53 | ///
54 | /// The json document
55 | internal JsonData(JObject doc, string path)
56 | {
57 | this.Path = path; // Set the path
58 | this.CreatedNew = !File.Exists(path); // Check if we have to create the file
59 | this.Document = doc; // Set the doc
60 | }
61 |
62 | #region Static Functions
63 | ///
64 | /// Checks if the file is JSON
65 | ///
66 | /// The path to the file
67 | /// If the file is JSON
68 | public static bool CheckFile(string filepath)
69 | {
70 | if (!File.Exists(filepath))
71 | return false;
72 |
73 | try
74 | {
75 | JObject.Parse(File.ReadAllText(filepath)); // Try to parse
76 |
77 | return true; // Parse successful, file valid
78 | }
79 | #pragma warning disable CS0168 // Variable is declared but never used
80 | catch (Exception ex)
81 | #pragma warning restore CS0168 // Variable is declared but never used
82 | {
83 | return false; // Failed to validate
84 | }
85 | }
86 |
87 | ///
88 | /// Serializes a class instance into a JSON
89 | ///
90 | /// The instance of the class
91 | /// The JSON string
92 | public static string Serialize(object instance) => JsonConvert.SerializeObject(instance); // Serialize the object
93 |
94 | ///
95 | /// Serializes a class into a JSON
96 | ///
97 | /// The class to serialize
98 | /// The JSON string
99 | public static string Serialize()
100 | {
101 | return JsonConvert.SerializeObject(Activator.CreateInstance()); // Instentate the class and serialize the instance
102 | }
103 |
104 | ///
105 | /// Deserializes JSON into an instance of a class
106 | ///
107 | /// The JSON
108 | /// The type to deserialize to
109 | /// Instance of the deserialized file
110 | public static object Deserialize(string json, Type type) => JsonConvert.DeserializeObject(json, type); // Deserialize the file
111 |
112 | ///
113 | /// Deserialize JSON into an instance of a class
114 | ///
115 | /// The class
116 | /// The JSON
117 | /// Instance of the class deserialized from JSON
118 | public static T Deserialize(string json) => JsonConvert.DeserializeObject(json); // Deserialize the JSON
119 | #endregion
120 |
121 | #region Public Functions
122 | ///
123 | /// Reloads the JSON file
124 | ///
125 | public void Reload() => Document = CreatedNew ? new JObject() : JObject.Parse(File.ReadAllText(Path));
126 |
127 | ///
128 | /// Saves the JSON file
129 | ///
130 | internal void Save() => File.WriteAllText(Path, Document.ToString(Formatting.Indented)); // Write the file
131 |
132 | ///
133 | /// Verifies the document and adds missing information specified in information
134 | ///
135 | /// The information to check from
136 | public void Verify(Dictionary information)
137 | {
138 | foreach(string key in information.Keys)
139 | if (!CheckKey(key))
140 | Document.Add(key, information[key]);
141 | }
142 |
143 | ///
144 | /// Adds a name + value to an array
145 | ///
146 | /// The array to add to
147 | /// The name/key
148 | /// The value
149 | public void AddToArray(JArray array, string name, object value)
150 | {
151 | array.Add(new JObject(
152 | new JProperty(name, value)
153 | ));
154 | }
155 |
156 | ///
157 | /// Checks if the key exists in the document
158 | ///
159 | /// The key you want to check
160 | /// If it exists in the document
161 | public bool CheckKey(string key) => (Document[key] != null && Document[key].Type != JTokenType.Null);
162 | #endregion
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/PointBlank/API/DataManagment/UniversalData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Security.Permissions;
7 | using PointBlank.Framework.Permissions.Ring;
8 | using Newtonsoft.Json;
9 | using Newtonsoft.Json.Linq;
10 | using PointBlank.API;
11 | using PointBlank.Framework;
12 | using PT = System.IO.Path;
13 |
14 | namespace PointBlank.API.DataManagment
15 | {
16 | ///
17 | /// Universal data managment
18 | ///
19 | [RingPermission(SecurityAction.Demand, ring = RingPermissionRing.None)]
20 | public class UniversalData
21 | {
22 | #region Properties
23 | ///
24 | /// The path to the file(if linked to file)
25 | ///
26 | public string Path { get; private set; }
27 | ///
28 | /// The type of data that was inputted(SQL, XML, JSON)
29 | ///
30 | public EDataType DataType { get; private set; }
31 |
32 | ///
33 | /// The XML data(if the file is a XML)
34 | ///
35 | public XMLData XML { get; private set; }
36 | ///
37 | /// The JSON data(if the file is a JSON)
38 | ///
39 | public JsonData JSON { get; private set; }
40 | ///
41 | /// The CONF data(if the file is a CONF)
42 | ///
43 | //public ConfData CONF { get; private set; }
44 |
45 | ///
46 | /// Check if a new file was created
47 | ///
48 | public bool CreatedNew { get; private set; }
49 | #endregion
50 |
51 | ///
52 | /// Universal data managment
53 | ///
54 | /// The path to the data file
55 | public UniversalData(string path, EDataType DefaultDataType = EDataType.JSON)
56 | {
57 | this.Path = path + ".dat"; // Set the path
58 | this.CreatedNew = !File.Exists(Path); // Check if the file has to be created
59 |
60 | if (!Directory.Exists(PT.GetDirectoryName(Path)))
61 | Directory.CreateDirectory(PT.GetDirectoryName(Path));
62 | if (CreatedNew)
63 | {
64 | DataType = DefaultDataType; // Set the data type
65 |
66 | switch (DefaultDataType)
67 | {
68 | case EDataType.JSON:
69 | JSON = new JsonData(Path); // Create the JSON file
70 | break;
71 | case EDataType.XML:
72 | XML = new XMLData(Path); // Create the XML file
73 | break;
74 | }
75 |
76 | return; // No need to continue
77 | }
78 |
79 | if (XMLData.CheckFile(Path))
80 | {
81 | DataType = EDataType.XML; // An XML file
82 | XML = new XMLData(Path);
83 | }
84 | else if (JsonData.CheckFile(Path))
85 | {
86 | DataType = EDataType.JSON; // A JSON file
87 | JSON = new JsonData(Path);
88 | }
89 | else
90 | {
91 | DataType = EDataType.UNKNOWN; // Unknown type/corrupted file
92 | }
93 | }
94 |
95 | #region Public Functions
96 | ///
97 | /// Gets the data in the format of your choosing
98 | ///
99 | /// The format of the data
100 | /// The data in the format you chose
101 | public object GetData(EDataType ExtractType)
102 | {
103 | if (DataType == EDataType.UNKNOWN || ExtractType == EDataType.UNKNOWN) // Unknown data type error
104 | return null;
105 |
106 | switch (DataType)
107 | {
108 | case EDataType.JSON:
109 | if (ExtractType == EDataType.XML)
110 | return JSONToXML(); // Convert the JSON to XML
111 | return JSON; // Return the JSON
112 | case EDataType.XML:
113 | if (ExtractType == EDataType.JSON)
114 | return XMLToJSON(); // Convert the XML to JSON
115 | return XML; // Return the XML
116 | }
117 |
118 | return null;
119 | }
120 |
121 | ///
122 | /// Saves the data depending on the format the server chose
123 | ///
124 | public void Save()
125 | {
126 | /*switch ((EDataType)Enviroment.FrameworkConfig[typeof(PointBlank)].Configurations["ConfigFormat"])
127 | {
128 | case EDataType.JSON:
129 | if (DataType == EDataType.XML || XML != null)
130 | XMLToJSON(); // Convert to JSON
131 |
132 | JSON.Save(); // Save the JSON
133 | break;
134 | case EDataType.XML:
135 | if (DataType == EDataType.JSON || JSON != null)
136 | JSONToXML(); // Convert to XML
137 |
138 | XML.Save(); // Save the XML
139 | break;
140 | }*/
141 | JSON.Save();
142 | }
143 | #endregion
144 |
145 | #region Converter Functions
146 | private XMLData JSONToXML()
147 | {
148 | XMLData tmpXML = new XMLData(JsonConvert.DeserializeXmlNode(JSON.Document.ToString(), "Data"), Path); // Deserialize the JSON to XML
149 |
150 | if(XML == null)
151 | {
152 | XML = tmpXML; // If the XML is null just set the tmpXML to it
153 | return XML;
154 | }
155 |
156 | XML.Merge(tmpXML.Document); // Merge the XMLs
157 |
158 | return XML;
159 | }
160 |
161 | private JsonData XMLToJSON()
162 | {
163 | string sJson = JsonConvert.SerializeXmlNode(XML.Document, Formatting.None, true); // Deserialize the XML to JSON
164 | JsonData tmpJSON = null;
165 |
166 | if (!string.IsNullOrEmpty(sJson) && sJson != "null")
167 | tmpJSON = new JsonData(JObject.Parse(sJson), Path); // Parse the JSON
168 | else
169 | tmpJSON = new JsonData(Path); // Create a new JSON
170 | if(JSON == null)
171 | {
172 | JSON = tmpJSON; // If the JSON is null just set the tmpJSON to it
173 | return JSON;
174 | }
175 |
176 | JSON.Document.Merge(tmpJSON); // Merge both JSONs
177 |
178 | return JSON;
179 | }
180 | #endregion
181 | }
182 | }
183 |
--------------------------------------------------------------------------------
/PointBlank/API/Detour/DetourAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace PointBlank.API.Detour
8 | {
9 | ///
10 | /// Used to detour a specific function
11 | ///
12 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
13 | public class DetourAttribute : Attribute
14 | {
15 | #region Properties
16 | ///
17 | /// The class that contains the method
18 | ///
19 | public Type Class { get; private set; }
20 | ///
21 | /// The name of the method
22 | ///
23 | public string MethodName { get; private set; }
24 | ///
25 | /// The methodinfo of the method
26 | ///
27 | public MethodInfo Method { get; private set; }
28 | ///
29 | /// The flags to find the method
30 | ///
31 | public BindingFlags Flags { get; private set; }
32 | ///
33 | /// Was the method found
34 | ///
35 | public bool MethodFound { get; private set; }
36 | #endregion
37 |
38 | ///
39 | /// Used to detour a specific function
40 | ///
41 | /// The class containing the method
42 | /// The name of the method to replace
43 | /// The flags of the method to replace
44 | public DetourAttribute(Type tClass, string method, BindingFlags flags, int index = 0)
45 | {
46 | // Set the variables
47 | Class = tClass;
48 | MethodName = method;
49 | Flags = flags;
50 |
51 | try
52 | {
53 | Method = Class.GetMethods(flags).Where(a => a.Name == method).ToArray()[index];
54 | MethodFound = true;
55 | }
56 | catch (Exception ex)
57 | {
58 | PointBlankLogging.LogError("Method not found! " + MethodName + " in class " + Class.FullName, ex, false, false);
59 | MethodFound = false;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/PointBlank/API/Detour/DetourManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Collections.Generic;
4 | using System.Diagnostics;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Security.Permissions;
8 | using PointBlank.Framework.Permissions.Ring;
9 | using PointBlank.Services.DetourManager;
10 | using DM = PointBlank.Services.DetourManager.DetourManager;
11 |
12 | namespace PointBlank.API.Detour
13 | {
14 | ///
15 | /// Contains function for managing detours
16 | ///
17 | [RingPermission(SecurityAction.Demand, ring = RingPermissionRing.None)]
18 | public static class DetourManager
19 | {
20 | #region Public Functions
21 | ///
22 | /// Calls the original method that was detoured
23 | ///
24 | /// The original method
25 | /// The instance for the method(null if static)
26 | /// The arguments for the method
27 | /// The value that the original function returns
28 | public static object CallOriginal(MethodInfo method, object instance = null, params object[] args)
29 | {
30 | // Set the variables
31 | DetourWrapper wrapper = DM.Detours.First(a => a.Value.Original == method).Value;
32 |
33 | // Do the checks
34 | if (wrapper == null)
35 | throw new Exception("The detour specified was not found!");
36 |
37 | return wrapper.CallOriginal(args, instance);
38 | }
39 |
40 | ///
41 | /// Calls the original method that was detoured
42 | ///
43 | /// The instance for the method(null if static)
44 | /// The arguments for the method
45 | /// The value tahat the original function returns
46 | public static object CallOriginal(object instance = null, params object[] args)
47 | {
48 | StackTrace trace = new StackTrace(false);
49 |
50 | if (trace.FrameCount < 1)
51 | throw new Exception("Invalid trace back to the original method! Please provide the methodinfo instead!");
52 |
53 | MethodBase modded = trace.GetFrame(1).GetMethod();
54 | MethodInfo original = null;
55 |
56 | if (!Attribute.IsDefined(modded, typeof(DetourAttribute)))
57 | modded = trace.GetFrame(2).GetMethod();
58 | DetourAttribute att = (DetourAttribute)Attribute.GetCustomAttribute(modded, typeof(DetourAttribute));
59 |
60 | if (att == null)
61 | throw new Exception("This method can only be called from an overwritten method!");
62 | if (!att.MethodFound)
63 | throw new Exception("The original method was never found!");
64 | original = att.Method;
65 |
66 | DetourWrapper wrapper = DM.Detours.First(a => a.Value.Original == original).Value;
67 |
68 | if (wrapper == null)
69 | throw new Exception("The detour specified was not found!");
70 |
71 | return wrapper.CallOriginal(args, instance);
72 | }
73 |
74 | ///
75 | /// Enables the detour of a method(WARNING: The method needs to have been detoured atleast once!)
76 | ///
77 | /// The original method that was detoured
78 | /// If the detour was enabled successfully
79 | public static bool EnableDetour(MethodInfo method)
80 | {
81 | // Set the variables
82 | DetourWrapper wrapper = DM.Detours.First(a => a.Value.Original == method).Value;
83 |
84 | // Do the checks
85 | if (wrapper == null)
86 | return false;
87 |
88 | return wrapper.Detour();
89 | }
90 |
91 | ///
92 | /// Disables the detour of a method(WARNING: The method needs to have been detoured atleast once!)
93 | ///
94 | /// The original method that was detoured
95 | /// If the detour was disabled successfully
96 | public static bool DisableDetour(MethodInfo method)
97 | {
98 | // Set the variables
99 | DetourWrapper wrapper = DM.Detours.First(a => a.Value.Original == method).Value;
100 |
101 | // Do the checks
102 | if (wrapper == null)
103 | return false;
104 |
105 | return wrapper.Revert();
106 | }
107 | #endregion
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/PointBlank/API/Discord/DiscordClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Net;
4 | using System.Net.Security;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using Newtonsoft.Json.Linq;
9 |
10 | namespace PointBlank.API.Discord
11 | {
12 | ///
13 | /// Used for interacting with discord via the https code
14 | ///
15 | public class DiscordClient : WebClient
16 | {
17 | #region Properties
18 | ///
19 | /// The current URL of the website
20 | ///
21 | public Uri URL { get; private set; }
22 |
23 | ///
24 | /// The last http code received
25 | ///
26 | public EDiscordHttpCodes LastHTTPCode { get; private set; }
27 | ///
28 | /// The last json code received
29 | ///
30 | public EDiscordJsonCodes LastJSONCode { get; private set; }
31 | #endregion
32 |
33 | public DiscordClient()
34 | {
35 | base.Headers[HttpRequestHeader.ContentType] = "application/json";
36 | }
37 |
38 | #region Private Functions
39 | private void ParseJsonCode(string response)
40 | {
41 | JObject obj = JObject.Parse(response);
42 |
43 | if(obj["code"] != null)
44 | {
45 | LastJSONCode = (EDiscordJsonCodes)(int)(obj["code"]);
46 | return;
47 | }
48 | LastJSONCode = 0;
49 | }
50 | #endregion
51 |
52 | #region Override Functions
53 | protected override WebRequest GetWebRequest(Uri address)
54 | {
55 | ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(PointBlank.ValidateCertificate);
56 |
57 | WebRequest request = base.GetWebRequest(address);
58 |
59 | return request;
60 | }
61 |
62 | protected override WebResponse GetWebResponse(WebRequest request)
63 | {
64 | WebResponse response = null;
65 |
66 | try
67 | {
68 | response = base.GetWebResponse(request);
69 |
70 | LastHTTPCode = (EDiscordHttpCodes)((HttpWebResponse)response).StatusCode;
71 | if(LastHTTPCode != EDiscordHttpCodes.NO_CONTENT)
72 | using (StreamReader reader = new StreamReader(((HttpWebResponse)response).GetResponseStream()))
73 | ParseJsonCode(reader.ReadToEnd());
74 | }
75 | catch (WebException ex)
76 | {
77 | LastHTTPCode = (EDiscordHttpCodes)((HttpWebResponse)ex.Response).StatusCode;
78 | if (LastHTTPCode != EDiscordHttpCodes.NO_CONTENT)
79 | using (StreamReader reader = new StreamReader(((HttpWebResponse)response).GetResponseStream()))
80 | ParseJsonCode(reader.ReadToEnd());
81 | }
82 | URL = response.ResponseUri;
83 |
84 | return response;
85 | }
86 |
87 | protected override void OnUploadStringCompleted(UploadStringCompletedEventArgs e)
88 | {
89 | if(e.Error != null)
90 | {
91 |
92 | LastHTTPCode = (EDiscordHttpCodes)((HttpWebResponse)((WebException)e.Error).Response).StatusCode;
93 | if (LastHTTPCode == EDiscordHttpCodes.NO_CONTENT) return;
94 | using (StreamReader reader = new StreamReader(((HttpWebResponse)((WebException)e.Error).Response).GetResponseStream()))
95 | ParseJsonCode(reader.ReadToEnd());
96 | return;
97 | }
98 |
99 | base.OnUploadStringCompleted(e);
100 | }
101 | #endregion
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/PointBlank/API/Discord/DiscordWebhook.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using Newtonsoft.Json;
7 | using Newtonsoft.Json.Linq;
8 |
9 | namespace PointBlank.API.Discord
10 | {
11 | ///
12 | /// Used for interacting with discord webhooks
13 | ///
14 | public class DiscordWebhook : IDisposable
15 | {
16 | #region Variables
17 | private Queue