├── .editorconfig
├── .gitattributes
├── .gitignore
├── .gitmodules
├── Jenkinsfile
├── LICENSE.md
├── ProjectEarthServerAPI.sln
├── ProjectEarthServerAPI
├── Authentication
│ └── GenoaAuthenticationHandler.cs
├── Controllers
│ ├── AdventureController.cs
│ ├── CdnTileController.cs
│ ├── CraftingController.cs
│ ├── LocationController.cs
│ ├── LocatorController.cs
│ ├── MultiplayerController.cs
│ ├── PlayerController.cs
│ ├── ResourcePackController.cs
│ ├── SigninController.cs
│ ├── SmeltingController.cs
│ └── TappablesController.cs
├── Models
│ ├── CDN
│ │ └── ResourcePackResponse.cs
│ ├── Features
│ │ ├── CatalogResponse.cs
│ │ ├── CraftingRequest.cs
│ │ ├── CraftingResponse.cs
│ │ ├── Item.cs
│ │ ├── JournalResponse.cs
│ │ ├── ProductCatalogResponse.cs
│ │ ├── Recipes.cs
│ │ ├── SmeltingRequest.cs
│ │ ├── SmeltingResponse.cs
│ │ └── UtilityBlocksResponse.cs
│ ├── Login
│ │ ├── FeaturesResponse.cs
│ │ ├── LocatorResponse.cs
│ │ ├── SettingsResponse.cs
│ │ ├── SigninRequest.cs
│ │ └── SigninResponse.cs
│ ├── Multiplayer
│ │ ├── Adventure
│ │ │ ├── AdventureRequestResult.cs
│ │ │ └── PlayerAdventureRequest.cs
│ │ ├── Buildplate
│ │ │ ├── BuildplateListResponse.cs
│ │ │ ├── BuildplateServerRequest.cs
│ │ │ ├── BuildplateServerResponse.cs
│ │ │ └── PlayerBuildplateList.cs
│ │ ├── MultiplayerInventoryResponse.cs
│ │ ├── ServerAuthInformation.cs
│ │ └── ServerCommandRequest.cs
│ ├── Player
│ │ ├── BoostsResponse.cs
│ │ ├── ChallengesResponse.cs
│ │ ├── InventoryResponse.cs
│ │ ├── LocationResponse.cs
│ │ ├── ProfileResponse.cs
│ │ ├── RubyResponse.cs
│ │ ├── ScrollsResponse.cs
│ │ ├── TappableRequest.cs
│ │ ├── TappableResponse.cs
│ │ └── TokenResponse.cs
│ ├── Rewards.cs
│ ├── Token.cs
│ └── Updates.cs
├── Program.cs
├── ProjectEarthServerAPI.csproj
├── Properties
│ └── launchSettings.json
├── Startup.cs
├── Util
│ ├── AdventureUtils.cs
│ ├── BoostUtils.cs
│ ├── BuildplateUtils.cs
│ ├── ChallengeUtils.cs
│ ├── CraftingUtils.cs
│ ├── DateTimeConverter.cs
│ ├── ETag.cs
│ ├── GenericUtils.cs
│ ├── InventoryUtils.cs
│ ├── JournalUtils.cs
│ ├── MultiplayerItemConverters.cs
│ ├── MultiplayerUtils.cs
│ ├── ProfileUtils.cs
│ ├── RewardUtils.cs
│ ├── RubyUtils.cs
│ ├── ServerConfig.cs
│ ├── SmeltingUtils.cs
│ ├── StateSingleton.cs
│ ├── StringToUuidConv.cs
│ ├── TappableUtils.cs
│ ├── Tile.cs
│ ├── TokenUtils.cs
│ └── UtilityBlockUtils.cs
├── appsettings.Development.json
└── appsettings.json
├── README.md
└── build.sh
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Remove the line below if you want to inherit .editorconfig settings from higher directories
2 | root = true
3 |
4 | # C# files
5 | [*.cs]
6 | indent_style = tab
7 | indent_size = tab
8 | tab_size = 4
9 |
10 | # New line preferences
11 | end_of_line = crlf
12 | insert_final_newline = true
13 |
14 |
15 | #### C# Coding Conventions ####
16 |
17 | # Expression-bodied members
18 | csharp_style_expression_bodied_accessors = true:silent
19 | csharp_style_expression_bodied_constructors = false:silent
20 | csharp_style_expression_bodied_indexers = true:silent
21 | csharp_style_expression_bodied_lambdas = true:silent
22 | csharp_style_expression_bodied_local_functions = false:silent
23 | csharp_style_expression_bodied_methods = false:silent
24 | csharp_style_expression_bodied_operators = false:silent
25 | csharp_style_expression_bodied_properties = true:silent
26 |
27 | # Pattern matching preferences
28 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
29 | csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
30 | csharp_style_prefer_not_pattern = true:suggestion
31 | csharp_style_prefer_pattern_matching = true:silent
32 | csharp_style_prefer_switch_expression = true:suggestion
33 |
34 | # Null-checking preferences
35 | csharp_style_conditional_delegate_call = true:suggestion
36 |
37 | # Code-block preferences
38 | csharp_prefer_braces = true:silent
39 |
40 | # Expression-level preferences
41 | csharp_prefer_simple_default_expression = true:suggestion
42 | csharp_style_deconstructed_variable_declaration = true:suggestion
43 | csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
44 | csharp_style_inlined_variable_declaration = true:suggestion
45 | csharp_style_pattern_local_over_anonymous_function = true:suggestion
46 | csharp_style_prefer_index_operator = true:suggestion
47 | csharp_style_prefer_range_operator = true:suggestion
48 | csharp_style_throw_expression = true:suggestion
49 | csharp_style_unused_value_assignment_preference = discard_variable:suggestion
50 | csharp_style_unused_value_expression_statement_preference = discard_variable:silent
51 |
52 | # 'using' directive preferences
53 | csharp_using_directive_placement = outside_namespace:silent
54 |
55 | #### C# Formatting Rules ####
56 |
57 | # New line preferences
58 | csharp_new_line_before_catch = true
59 | csharp_new_line_before_else = true
60 | csharp_new_line_before_finally = true
61 | csharp_new_line_before_members_in_anonymous_types = true
62 | csharp_new_line_before_members_in_object_initializers = true
63 | csharp_new_line_before_open_brace = all
64 | csharp_new_line_between_query_expression_clauses = true
65 |
66 | # Indentation preferences
67 | csharp_indent_block_contents = true
68 | csharp_indent_braces = false
69 | csharp_indent_case_contents = true
70 | csharp_indent_case_contents_when_block = true
71 | csharp_indent_labels = no_change
72 | csharp_indent_switch_labels = true
73 |
74 | # Space preferences
75 | csharp_space_after_cast = false
76 | csharp_space_after_colon_in_inheritance_clause = true
77 | csharp_space_after_comma = true
78 | csharp_space_after_dot = false
79 | csharp_space_after_keywords_in_control_flow_statements = true
80 | csharp_space_after_semicolon_in_for_statement = true
81 | csharp_space_around_binary_operators = before_and_after
82 | csharp_space_around_declaration_statements = false
83 | csharp_space_before_colon_in_inheritance_clause = true
84 | csharp_space_before_comma = false
85 | csharp_space_before_dot = false
86 | csharp_space_before_open_square_brackets = false
87 | csharp_space_before_semicolon_in_for_statement = false
88 | csharp_space_between_empty_square_brackets = false
89 | csharp_space_between_method_call_empty_parameter_list_parentheses = false
90 | csharp_space_between_method_call_name_and_opening_parenthesis = false
91 | csharp_space_between_method_call_parameter_list_parentheses = false
92 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
93 | csharp_space_between_method_declaration_name_and_open_parenthesis = false
94 | csharp_space_between_method_declaration_parameter_list_parentheses = false
95 | csharp_space_between_parentheses = false
96 | csharp_space_between_square_brackets = false
97 | csharp_space_within_single_line_array_initializer_braces = false
98 |
99 | # Wrapping preferences
100 | csharp_preserve_single_line_blocks = true
101 | csharp_preserve_single_line_statements = true
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.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 | *.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 |
30 | # Visual Studio 2015/2017 cache/options directory
31 | .vs/
32 | # Uncomment if you have tasks that create the project's static files in wwwroot
33 | #wwwroot/
34 |
35 | # Visual Studio 2017 auto generated files
36 | Generated\ Files/
37 |
38 | # Visual Studio Code dust
39 | .vscode/
40 |
41 | # MSTest test Results
42 | [Tt]est[Rr]esult*/
43 | [Bb]uild[Ll]og.*
44 |
45 | # NUNIT
46 | *.VisualState.xml
47 | TestResult.xml
48 |
49 | # Build Results of an ATL Project
50 | [Dd]ebugPS/
51 | [Rr]eleasePS/
52 | dlldata.c
53 |
54 | # Benchmark Results
55 | BenchmarkDotNet.Artifacts/
56 |
57 | # .NET Core
58 | project.lock.json
59 | project.fragment.lock.json
60 | artifacts/
61 |
62 | # StyleCop
63 | StyleCopReport.xml
64 |
65 | # Files built by Visual Studio
66 | *_i.c
67 | *_p.c
68 | *_h.h
69 | *.ilk
70 | *.meta
71 | *.obj
72 | *.iobj
73 | *.pch
74 | *.pdb
75 | *.ipdb
76 | *.pgc
77 | *.pgd
78 | *.rsp
79 | *.sbr
80 | *.tlb
81 | *.tli
82 | *.tlh
83 | *.tmp
84 | *.tmp_proj
85 | *_wpftmp.csproj
86 | *.log
87 | *.vspscc
88 | *.vssscc
89 | .builds
90 | *.pidb
91 | *.svclog
92 | *.scc
93 |
94 | # Chutzpah Test files
95 | _Chutzpah*
96 |
97 | # Visual C++ cache files
98 | ipch/
99 | *.aps
100 | *.ncb
101 | *.opendb
102 | *.opensdf
103 | *.sdf
104 | *.cachefile
105 | *.VC.db
106 | *.VC.VC.opendb
107 |
108 | # Visual Studio profiler
109 | *.psess
110 | *.vsp
111 | *.vspx
112 | *.sap
113 |
114 | # Visual Studio Trace Files
115 | *.e2e
116 |
117 | # TFS 2012 Local Workspace
118 | $tf/
119 |
120 | # Guidance Automation Toolkit
121 | *.gpState
122 |
123 | # ReSharper is a .NET coding add-in
124 | _ReSharper*/
125 | *.[Rr]e[Ss]harper
126 | *.DotSettings.user
127 |
128 | # JustCode is a .NET coding add-in
129 | .JustCode
130 |
131 | # TeamCity is a build add-in
132 | _TeamCity*
133 |
134 | # DotCover is a Code Coverage Tool
135 | *.dotCover
136 |
137 | # AxoCover is a Code Coverage Tool
138 | .axoCover/*
139 | !.axoCover/settings.json
140 |
141 | # Visual Studio code coverage results
142 | *.coverage
143 | *.coveragexml
144 |
145 | # NCrunch
146 | _NCrunch_*
147 | .*crunch*.local.xml
148 | nCrunchTemp_*
149 |
150 | # MightyMoose
151 | *.mm.*
152 | AutoTest.Net/
153 |
154 | # Web workbench (sass)
155 | .sass-cache/
156 |
157 | # Installshield output folder
158 | [Ee]xpress/
159 |
160 | # DocProject is a documentation generator add-in
161 | DocProject/buildhelp/
162 | DocProject/Help/*.HxT
163 | DocProject/Help/*.HxC
164 | DocProject/Help/*.hhc
165 | DocProject/Help/*.hhk
166 | DocProject/Help/*.hhp
167 | DocProject/Help/Html2
168 | DocProject/Help/html
169 |
170 | # Click-Once directory
171 | publish/
172 |
173 | # Publish Web Output
174 | *.[Pp]ublish.xml
175 | *.azurePubxml
176 | # Note: Comment the next line if you want to checkin your web deploy settings,
177 | # but database connection strings (with potential passwords) will be unencrypted
178 | *.pubxml
179 | *.publishproj
180 |
181 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
182 | # checkin your Azure Web App publish settings, but sensitive information contained
183 | # in these scripts will be unencrypted
184 | PublishScripts/
185 |
186 | # NuGet Packages
187 | *.nupkg
188 | # The packages folder can be ignored because of Package Restore
189 | **/[Pp]ackages/*
190 | # except build/, which is used as an MSBuild target.
191 | !**/[Pp]ackages/build/
192 | # Uncomment if necessary however generally it will be regenerated when needed
193 | #!**/[Pp]ackages/repositories.config
194 | # NuGet v3's project.json files produces more ignorable files
195 | *.nuget.props
196 | *.nuget.targets
197 |
198 | # Microsoft Azure Build Output
199 | csx/
200 | *.build.csdef
201 |
202 | # Microsoft Azure Emulator
203 | ecf/
204 | rcf/
205 |
206 | # Windows Store app package directories and files
207 | AppPackages/
208 | BundleArtifacts/
209 | Package.StoreAssociation.xml
210 | _pkginfo.txt
211 | *.appx
212 |
213 | # Visual Studio cache files
214 | # files ending in .cache can be ignored
215 | *.[Cc]ache
216 | # but keep track of directories ending in .cache
217 | !?*.[Cc]ache/
218 |
219 | # Others
220 | ClientBin/
221 | ~$*
222 | *~
223 | *.dbmdl
224 | *.dbproj.schemaview
225 | *.jfm
226 | *.pfx
227 | *.publishsettings
228 | orleans.codegen.cs
229 |
230 | # Including strong name files can present a security risk
231 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
232 | #*.snk
233 |
234 | # Since there are multiple workflows, uncomment next line to ignore bower_components
235 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
236 | #bower_components/
237 |
238 | # RIA/Silverlight projects
239 | Generated_Code/
240 |
241 | # Backup & report files from converting an old project file
242 | # to a newer Visual Studio version. Backup files are not needed,
243 | # because we have git ;-)
244 | _UpgradeReport_Files/
245 | Backup*/
246 | UpgradeLog*.XML
247 | UpgradeLog*.htm
248 | ServiceFabricBackup/
249 | *.rptproj.bak
250 |
251 | # SQL Server files
252 | *.mdf
253 | *.ldf
254 | *.ndf
255 |
256 | # Business Intelligence projects
257 | *.rdl.data
258 | *.bim.layout
259 | *.bim_*.settings
260 | *.rptproj.rsuser
261 | *- Backup*.rdl
262 |
263 | # Microsoft Fakes
264 | FakesAssemblies/
265 |
266 | # GhostDoc plugin setting file
267 | *.GhostDoc.xml
268 |
269 | # Node.js Tools for Visual Studio
270 | .ntvs_analysis.dat
271 | node_modules/
272 |
273 | # Visual Studio 6 build log
274 | *.plg
275 |
276 | # Visual Studio 6 workspace options file
277 | *.opt
278 |
279 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
280 | *.vbw
281 |
282 | # Visual Studio LightSwitch build output
283 | **/*.HTMLClient/GeneratedArtifacts
284 | **/*.DesktopClient/GeneratedArtifacts
285 | **/*.DesktopClient/ModelManifest.xml
286 | **/*.Server/GeneratedArtifacts
287 | **/*.Server/ModelManifest.xml
288 | _Pvt_Extensions
289 |
290 | # Paket dependency manager
291 | .paket/paket.exe
292 | paket-files/
293 |
294 | # FAKE - F# Make
295 | .fake/
296 |
297 | # JetBrains Rider
298 | .idea/
299 | *.sln.iml
300 |
301 | # CodeRush personal settings
302 | .cr/personal
303 |
304 | # Python Tools for Visual Studio (PTVS)
305 | __pycache__/
306 | *.pyc
307 |
308 | # Cake - Uncomment if you are using it
309 | # tools/**
310 | # !tools/packages.config
311 |
312 | # Tabs Studio
313 | *.tss
314 |
315 | # Telerik's JustMock configuration file
316 | *.jmconfig
317 |
318 | # BizTalk build output
319 | *.btp.cs
320 | *.btm.cs
321 | *.odx.cs
322 | *.xsd.cs
323 |
324 | # OpenCover UI analysis results
325 | OpenCover/
326 |
327 | # Azure Stream Analytics local run output
328 | ASALocalRun/
329 |
330 | # MSBuild Binary and Structured Log
331 | *.binlog
332 |
333 | # NVidia Nsight GPU debugger configuration file
334 | *.nvuser
335 |
336 | # MFractors (Xamarin productivity tool) working folder
337 | .mfractor/
338 |
339 | # Local History for Visual Studio
340 | .localhistory/
341 |
342 | # BeatPulse healthcheck temp database
343 | healthchecksdb
344 | /ProjectEarthServerAPI/Properties/ServiceDependencies/projectearthdev - Web Deploy/profile.arm.json
345 | /ProjectEarthServerAPI/logs
346 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "ProjectEarthServerAPI/data"]
2 | path = ProjectEarthServerAPI/data
3 | url = https://github.com/Project-Earth-Team/ApiData.git
4 |
--------------------------------------------------------------------------------
/Jenkinsfile:
--------------------------------------------------------------------------------
1 | pipeline{
2 | agent any
3 | tools {
4 | dotnetsdk '.NET 5'
5 | }
6 |
7 | stages {
8 | stage('Build'){
9 | steps{
10 | sh 'dotnet publish -r linux-x64 -p:PublishSingleFile=true --self-contained false'
11 | }
12 | post{
13 | success{
14 | archiveArtifacts artifacts: 'ProjectEarthServerAPI/bin/Debug/net5.0/linux-x64/publish/ProjectEarthServerAPI'
15 | archiveArtifacts artifacts: 'ProjectEarthServerAPI/bin/Debug/net5.0/linux-x64/publish/ProjectEarthServerAPI.pdb'
16 | }
17 | }
18 | }
19 | }
20 |
21 | post {
22 | always {
23 | script {
24 | def changeLogSets = currentBuild.changeSets
25 | def message = "**Changes:**"
26 |
27 | if (changeLogSets.size() == 0) {
28 | message += "\n*No changes.*"
29 | } else {
30 | def repositoryUrl = scm.userRemoteConfigs[0].url.replace(".git", "")
31 | def count = 0;
32 | def extra = 0;
33 | for (int i = 0; i < changeLogSets.size(); i++) {
34 | def entries = changeLogSets[i].items
35 | for (int j = 0; j < entries.length; j++) {
36 | if (count <= 10) {
37 | def entry = entries[j]
38 | def commitId = entry.commitId.substring(0, 6)
39 | message += "\n - [`${commitId}`](${repositoryUrl}/commit/${entry.commitId}) ${entry.msg}"
40 | count++
41 | } else {
42 | extra++;
43 | }
44 | }
45 | }
46 |
47 | if (extra != 0) {
48 | message += "\n - ${extra} more commits"
49 | }
50 | }
51 |
52 | env.changes = message
53 | }
54 | deleteDir()
55 | withCredentials([string(credentialsId: 'projectearth-discord-webhook', variable: 'DISCORD_WEBHOOK')]) {
56 | discordSend description: "**Build:** [${currentBuild.id}](${env.BUILD_URL})\n**Status:** [${currentBuild.currentResult}](${env.BUILD_URL})\n${changes}\n\n[**Artifacts on Jenkins**](https://ci.rtm516.co.uk/job/ProjectEarth/job/Api/job/master/)", footer: 'rtm516\'s Jenkins', link: env.BUILD_URL, successful: currentBuild.resultIsBetterOrEqualTo('SUCCESS'), title: "${env.JOB_NAME} #${currentBuild.id}", webhookURL: DISCORD_WEBHOOK
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Project-Earth-Api
2 | Copyright (C) 2021 Project Earth Team
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Affero General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Affero General Public License for more details.
13 |
14 | You should have received a copy of the GNU Affero General Public License
15 | along with this program. If not, see .
16 |
--------------------------------------------------------------------------------
/ProjectEarthServerAPI.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30717.126
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectEarthServerAPI", "ProjectEarthServerAPI\ProjectEarthServerAPI.csproj", "{EE1E1340-AFE0-4CEB-BA24-7B70AEB384C5}"
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 | {EE1E1340-AFE0-4CEB-BA24-7B70AEB384C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {EE1E1340-AFE0-4CEB-BA24-7B70AEB384C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {EE1E1340-AFE0-4CEB-BA24-7B70AEB384C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {EE1E1340-AFE0-4CEB-BA24-7B70AEB384C5}.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 = {80785D1B-4FAA-4CBD-B1D6-548D49FA54E0}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ProjectEarthServerAPI/Authentication/GenoaAuthenticationHandler.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Authentication;
2 | using Microsoft.AspNetCore.Authorization;
3 | using Microsoft.AspNetCore.Http;
4 | using Microsoft.Extensions.Logging;
5 | using Microsoft.Extensions.Options;
6 | using System;
7 | using System.Net.Http.Headers;
8 | using System.Security.Claims;
9 | using System.Text.Encodings.Web;
10 | using System.Threading.Tasks;
11 |
12 | namespace ProjectEarthServerAPI.Authentication
13 | {
14 | public class GenoaAuthenticationHandler : AuthenticationHandler
15 | {
16 | public GenoaAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { }
17 |
18 | protected override async Task HandleAuthenticateAsync()
19 | {
20 | // skip authentication if endpoint has [AllowAnonymous] attribute
21 | var endpoint = Context.GetEndpoint();
22 | if (endpoint?.Metadata?.GetMetadata() != null)
23 | return AuthenticateResult.NoResult();
24 |
25 | // Check if we should really authenticate
26 | if (endpoint?.Metadata?.GetMetadata() == null)
27 | return AuthenticateResult.NoResult();
28 |
29 | if (!Request.Headers.ContainsKey("Authorization"))
30 | return AuthenticateResult.Fail("Missing Authorization Header");
31 |
32 | string id;
33 | try
34 | {
35 | var authHeader = AuthenticationHeaderValue.Parse(Request.Headers["Authorization"]);
36 | if (authHeader.Scheme.Equals("Genoa"))
37 | {
38 | id = authHeader.Parameter;
39 | }
40 | else
41 | {
42 | return AuthenticateResult.Fail("Invalid Authorization Header");
43 | }
44 | }
45 | catch
46 | {
47 | return AuthenticateResult.Fail("Invalid Authorization Header");
48 | }
49 |
50 | var claims = new[] {new Claim(ClaimTypes.NameIdentifier, id),};
51 |
52 | var identity = new ClaimsIdentity(claims, Scheme.Name);
53 | var principal = new ClaimsPrincipal(identity);
54 | var ticket = new AuthenticationTicket(principal, Scheme.Name);
55 |
56 | return AuthenticateResult.Success(ticket);
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/ProjectEarthServerAPI/Controllers/AdventureController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Security.Claims;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Authorization;
6 | using Microsoft.AspNetCore.Mvc;
7 | using Newtonsoft.Json;
8 | using ProjectEarthServerAPI.Models;
9 | using ProjectEarthServerAPI.Models.Multiplayer.Adventure;
10 | using ProjectEarthServerAPI.Util;
11 |
12 | namespace ProjectEarthServerAPI.Controllers
13 | {
14 | [Authorize]
15 | [ApiVersion("1.1")]
16 | public class AdventureScrollsController : Controller
17 | {
18 | [Route("1/api/v{version:apiVersion}/adventures/scrolls")]
19 | public ContentResult Get()
20 | {
21 | var responseobj = new ScrollsResponse();
22 | var response = JsonConvert.SerializeObject(responseobj);
23 | return Content(response, "application/json");
24 | } // TODO: Fixed String
25 |
26 | [Route("1/api/v{version:apiVersion}/adventures/scrolls/{crystalId}")]
27 | public async Task PostRedeemCrystal(Guid crystalId)
28 | {
29 | var playerId = User.FindFirstValue(ClaimTypes.NameIdentifier);
30 |
31 | var stream = new StreamReader(Request.Body);
32 | var body = await stream.ReadToEndAsync();
33 |
34 | var req = JsonConvert.DeserializeObject(body);
35 | var resp = AdventureUtils.RedeemCrystal(playerId, req, crystalId);
36 |
37 | return Content(JsonConvert.SerializeObject(resp), "application/json");
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/ProjectEarthServerAPI/Controllers/CdnTileController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.Extensions.Logging;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using Newtonsoft.Json;
8 | using System.IO;
9 | using ProjectEarthServerAPI.Util;
10 | using ProjectEarthServerAPI.Models;
11 |
12 | namespace ProjectEarthServerAPI.Controllers
13 | {
14 | [ApiVersion("1.1")]
15 | [Route("cdn/tile/16/{_}/{tilePos1}_{tilePos2}_16.png")]
16 | [ResponseCache(Duration = 11200)]
17 | public class CdnTileController : ControllerBase
18 | {
19 | public IActionResult Get(int _, int tilePos1, int tilePos2) // _ used because we dont care :|
20 | {
21 | String targetTilePath = $"./data/tiles/16/{tilePos1}/{tilePos1}_{tilePos2}_16.png";
22 |
23 | if (!System.IO.File.Exists(targetTilePath))
24 | {
25 | var boo = Tile.DownloadTile(tilePos1, tilePos2, @"./data/tiles/16/");
26 |
27 | //Lets download that lovely tile now, Shall we?
28 | if (boo == false)
29 | {
30 | return Content("hi!");
31 | } // Error 400 on Tile download error
32 | }
33 |
34 | //String targetTilePath = $"./data/tiles/creeper_tile.png";
35 | byte[] fileData = System.IO.File.ReadAllBytes(targetTilePath); //Namespaces
36 | var cd = new System.Net.Mime.ContentDisposition {FileName = tilePos1 + "_" + tilePos2 + "_16.png", Inline = true};
37 | Response.Headers.Add("Content-Disposition", cd.ToString());
38 |
39 |
40 | return File(fileData, "application/octet-stream", tilePos1 + "_" + tilePos2 + "_16.png");
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/ProjectEarthServerAPI/Controllers/CraftingController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Threading.Tasks;
6 | using Newtonsoft.Json;
7 | using ProjectEarthServerAPI.Models.Features;
8 | using ProjectEarthServerAPI.Util;
9 | using Microsoft.AspNetCore.Authorization;
10 | using System.Security.Claims;
11 | using ProjectEarthServerAPI.Models;
12 | using Serilog;
13 |
14 | namespace ProjectEarthServerAPI.Controllers
15 | {
16 | // TODO: Not done. Rewards need inventory implementation, timers for crafting process, and recipeId -> recipe time checks
17 | [Authorize]
18 | public class CraftingController : Controller
19 | {
20 | [ApiVersion("1.1")]
21 | [Route("1/api/v{version:apiVersion}/crafting/{slot}/start")]
22 | public async Task PostNewCraftingJob(int slot)
23 | {
24 | string authtoken = User.FindFirstValue(ClaimTypes.NameIdentifier);
25 |
26 | var stream = new StreamReader(Request.Body);
27 | var body = await stream.ReadToEndAsync();
28 |
29 | var req = JsonConvert.DeserializeObject(body);
30 |
31 | var craftingJob = CraftingUtils.StartCraftingJob(authtoken, slot, req);
32 |
33 |
34 | var updateResponse = new CraftingUpdates {updates = new Updates()};
35 |
36 | var nextStreamId = GenericUtils.GetNextStreamVersion();
37 |
38 | updateResponse.updates.crafting = nextStreamId;
39 | updateResponse.updates.inventory = nextStreamId;
40 |
41 | return Content(JsonConvert.SerializeObject(updateResponse), "application/json");
42 | //return Accepted(Content(returnUpdates, "application/json"));
43 | }
44 |
45 | [ApiVersion("1.1")]
46 | [Route("1/api/v{version:apiVersion}/crafting/finish/price")]
47 | public IActionResult GetCraftingPrice(int slot)
48 | {
49 | TimeSpan remainingTime = TimeSpan.Parse(Request.Query["remainingTime"]);
50 | var returnPrice = new CraftingPriceResponse {result = new CraftingPrice {cost = 1, discount = 0, validTime = remainingTime}, updates = new Updates()};
51 |
52 | return Content(JsonConvert.SerializeObject(returnPrice), "application/json");
53 | }
54 |
55 |
56 | [ApiVersion("1.1")]
57 | [Route("1/api/v{version:apiVersion}/crafting/{slot}")]
58 | public IActionResult GetCraftingStatus(int slot)
59 | {
60 | string authtoken = User.FindFirstValue(ClaimTypes.NameIdentifier);
61 |
62 | var craftingStatus = CraftingUtils.GetCraftingJobInfo(authtoken, slot);
63 |
64 | return Content(JsonConvert.SerializeObject(craftingStatus), "application/json");
65 | //return Accepted(Content(returnTokens, "application/json"));
66 | }
67 |
68 | [ApiVersion("1.1")]
69 | [Route("1/api/v{version:apiVersion}/crafting/{slot}/collectItems")]
70 | public IActionResult GetCollectCraftingItems(int slot)
71 | {
72 | string authtoken = User.FindFirstValue(ClaimTypes.NameIdentifier);
73 |
74 | var returnUpdates = CraftingUtils.FinishCraftingJob(authtoken, slot);
75 |
76 | return Content(JsonConvert.SerializeObject(returnUpdates), "application/json");
77 | //return Accepted(Content(returnTokens, "application/json"));
78 | }
79 |
80 | [ApiVersion("1.1")]
81 | [Route("1/api/v{version:apiVersion}/crafting/{slot}/stop")]
82 | public IActionResult GetStopCraftingJob(int slot)
83 | {
84 | string authtoken = User.FindFirstValue(ClaimTypes.NameIdentifier);
85 |
86 | var returnUpdates = CraftingUtils.CancelCraftingJob(authtoken, slot);
87 |
88 | //return Accepted();
89 |
90 | return Content(JsonConvert.SerializeObject(returnUpdates), "application/json");
91 | //return Accepted(Content(returnTokens, "application/json"));
92 | }
93 |
94 | [ApiVersion("1.1")]
95 | [Route("1/api/v{version:apiVersion}/crafting/{slot}/unlock")]
96 | public IActionResult GetUnlockCraftingSlot(int slot)
97 | {
98 | string authtoken = User.FindFirstValue(ClaimTypes.NameIdentifier);
99 |
100 | var returnUpdates = CraftingUtils.UnlockCraftingSlot(authtoken, slot);
101 |
102 | return Content(JsonConvert.SerializeObject(returnUpdates), "application/json");
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/ProjectEarthServerAPI/Controllers/LocationController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using System;
3 | using System.Collections.Generic;
4 | using ProjectEarthServerAPI.Models;
5 | using Newtonsoft.Json;
6 | using ProjectEarthServerAPI.Util;
7 | using Microsoft.AspNetCore.Authorization;
8 | using ProjectEarthServerAPI.Models.Features;
9 | using Uma.Uuid;
10 |
11 | namespace ProjectEarthServerAPI.Controllers
12 | {
13 | [Authorize]
14 | [ApiVersion("1.1")]
15 | [Route("1/api/v{version:apiVersion}/locations/{latitude}/{longitude}")]
16 | public class LocationController : Controller
17 | {
18 | private static Random random = new Random();
19 |
20 | public ContentResult Get(double latitude, double longitude)
21 | {
22 | var currentTime = DateTime.UtcNow;
23 | //Nab tile loc
24 | int[] cords = Tile.getTileForCords(latitude, longitude);
25 | List tappables = new List();
26 | int numTappablesToSpawn = random.Next(StateSingleton.Instance.config.minTappableSpawnAmount,
27 | StateSingleton.Instance.config.maxTappableSpawnAmount);
28 | for (int i = 0; i < numTappablesToSpawn; i++)
29 | {
30 | var tappable = TappableUtils.createTappableInRadiusOfCoordinates(longitude, latitude);
31 | //add the tappable to the list
32 | tappables.Add(tappable);
33 | //add its GUID to the singleton so we can grab the correct reward pool later
34 | StateSingleton.Instance.activeTappableTypes.Add(Guid.Parse(tappable.id), tappable.icon);
35 | }
36 |
37 |
38 | //Create our final response
39 | LocationResponse.Root locationResp = new LocationResponse.Root
40 | {
41 | result = new LocationResponse.Result
42 | {
43 | killSwitchedTileIds = new List