├── .github └── workflows │ └── dotnet.yml ├── .gitignore ├── .gitmodules ├── FORCE.sln ├── LICENSE ├── README.md ├── plugins └── FORCE.Plugin.AutoGreeter │ ├── AdminCommands.cs │ ├── FORCE.Plugin.AutoGreeter.csproj │ └── Plugin.cs └── src ├── FORCE.Core.Plugin ├── Attributes │ ├── CommandAttribute.cs │ ├── CommandGroupAttribute.cs │ ├── PersistentAttribute.cs │ ├── PluginAttribute.cs │ ├── RemainderAttribute.cs │ ├── RequireRoleAttribute.cs │ ├── SummaryAttribute.cs │ └── UsageAttribute.cs ├── CommandContext.cs ├── ContextBase.cs ├── FORCE.Core.Plugin.csproj ├── FORCE.Core.Plugin.csproj.DotSettings ├── Models │ └── PluginDisplayInfo.cs └── PluginBase.cs ├── FORCE.Core.Shared ├── ColorScheme.cs ├── FORCE.Core.Shared.csproj ├── IColoredString.cs ├── PlayerList.cs ├── PlayerRole.cs └── TmServer.cs ├── FORCE.Core ├── Extensions │ ├── EnumerableExtensions.cs │ └── TypeExtensions.cs ├── FORCE.Core.csproj ├── Files │ └── Settings.json ├── Force.cs ├── Models │ └── ForceSettings.cs └── Plugin │ ├── Builders │ ├── CommandBuilder.cs │ ├── CommandGroupBuilder.cs │ ├── CommandParameterBuilder.cs │ └── PluginBuilder.cs │ ├── CommandHandler.cs │ ├── Models │ ├── ClassInfo.cs │ ├── CommandGroupInfo.cs │ ├── CommandInfo.cs │ ├── CommandParameterInfo.cs │ ├── PersistentMember.cs │ └── PluginInfo.cs │ └── PluginManager.cs └── FORCE ├── FORCE.csproj └── Program.cs /.github/workflows/dotnet.yml: -------------------------------------------------------------------------------- 1 | name: .NET 2 | 3 | on: 4 | push: 5 | branches: 6 | - '**' 7 | pull_request: 8 | branches: 9 | - '**' 10 | 11 | jobs: 12 | build: 13 | 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | with: 19 | submodules: true 20 | - name: Setup .NET 21 | uses: actions/setup-dotnet@v1 22 | with: 23 | dotnet-version: 6.0.x 24 | - name: Restore dependencies 25 | run: dotnet restore 26 | - name: Build 27 | run: dotnet build --no-restore 28 | - name: Test 29 | run: dotnet test --no-build --verbosity normal 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/csharp,visualstudio,rider,jetbrains 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=csharp,visualstudio,rider,jetbrains 4 | 5 | ### Csharp ### 6 | ## Ignore Visual Studio temporary files, build results, and 7 | ## files generated by popular Visual Studio add-ons. 8 | ## 9 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 10 | 11 | # User-specific files 12 | *.rsuser 13 | *.suo 14 | *.user 15 | *.userosscache 16 | *.sln.docstates 17 | 18 | # User-specific files (MonoDevelop/Xamarin Studio) 19 | *.userprefs 20 | 21 | # Mono auto generated files 22 | mono_crash.* 23 | 24 | # Build results 25 | [Dd]ebug/ 26 | [Dd]ebugPublic/ 27 | [Rr]elease/ 28 | [Rr]eleases/ 29 | x64/ 30 | x86/ 31 | [Ww][Ii][Nn]32/ 32 | [Aa][Rr][Mm]/ 33 | [Aa][Rr][Mm]64/ 34 | bld/ 35 | [Bb]in/ 36 | [Oo]bj/ 37 | [Ll]og/ 38 | [Ll]ogs/ 39 | 40 | # Visual Studio 2015/2017 cache/options directory 41 | .vs/ 42 | # Uncomment if you have tasks that create the project's static files in wwwroot 43 | #wwwroot/ 44 | 45 | # Visual Studio 2017 auto generated files 46 | Generated\ Files/ 47 | 48 | # MSTest test Results 49 | [Tt]est[Rr]esult*/ 50 | [Bb]uild[Ll]og.* 51 | 52 | # NUnit 53 | *.VisualState.xml 54 | TestResult.xml 55 | nunit-*.xml 56 | 57 | # Build Results of an ATL Project 58 | [Dd]ebugPS/ 59 | [Rr]eleasePS/ 60 | dlldata.c 61 | 62 | # Benchmark Results 63 | BenchmarkDotNet.Artifacts/ 64 | 65 | # .NET Core 66 | project.lock.json 67 | project.fragment.lock.json 68 | artifacts/ 69 | 70 | # ASP.NET Scaffolding 71 | ScaffoldingReadMe.txt 72 | 73 | # StyleCop 74 | StyleCopReport.xml 75 | 76 | # Files built by Visual Studio 77 | *_i.c 78 | *_p.c 79 | *_h.h 80 | *.ilk 81 | *.meta 82 | *.obj 83 | *.iobj 84 | *.pch 85 | *.pdb 86 | *.ipdb 87 | *.pgc 88 | *.pgd 89 | *.rsp 90 | *.sbr 91 | *.tlb 92 | *.tli 93 | *.tlh 94 | *.tmp 95 | *.tmp_proj 96 | *_wpftmp.csproj 97 | *.log 98 | *.tlog 99 | *.vspscc 100 | *.vssscc 101 | .builds 102 | *.pidb 103 | *.svclog 104 | *.scc 105 | 106 | # Chutzpah Test files 107 | _Chutzpah* 108 | 109 | # Visual C++ cache files 110 | ipch/ 111 | *.aps 112 | *.ncb 113 | *.opendb 114 | *.opensdf 115 | *.sdf 116 | *.cachefile 117 | *.VC.db 118 | *.VC.VC.opendb 119 | 120 | # Visual Studio profiler 121 | *.psess 122 | *.vsp 123 | *.vspx 124 | *.sap 125 | 126 | # Visual Studio Trace Files 127 | *.e2e 128 | 129 | # TFS 2012 Local Workspace 130 | $tf/ 131 | 132 | # Guidance Automation Toolkit 133 | *.gpState 134 | 135 | # ReSharper is a .NET coding add-in 136 | _ReSharper*/ 137 | *.[Rr]e[Ss]harper 138 | *.DotSettings.user 139 | 140 | # TeamCity is a build add-in 141 | _TeamCity* 142 | 143 | # DotCover is a Code Coverage Tool 144 | *.dotCover 145 | 146 | # AxoCover is a Code Coverage Tool 147 | .axoCover/* 148 | !.axoCover/settings.json 149 | 150 | # Coverlet is a free, cross platform Code Coverage Tool 151 | coverage*.json 152 | coverage*.xml 153 | coverage*.info 154 | 155 | # Visual Studio code coverage results 156 | *.coverage 157 | *.coveragexml 158 | 159 | # NCrunch 160 | _NCrunch_* 161 | .*crunch*.local.xml 162 | nCrunchTemp_* 163 | 164 | # MightyMoose 165 | *.mm.* 166 | AutoTest.Net/ 167 | 168 | # Web workbench (sass) 169 | .sass-cache/ 170 | 171 | # Installshield output folder 172 | [Ee]xpress/ 173 | 174 | # DocProject is a documentation generator add-in 175 | DocProject/buildhelp/ 176 | DocProject/Help/*.HxT 177 | DocProject/Help/*.HxC 178 | DocProject/Help/*.hhc 179 | DocProject/Help/*.hhk 180 | DocProject/Help/*.hhp 181 | DocProject/Help/Html2 182 | DocProject/Help/html 183 | 184 | # Click-Once directory 185 | publish/ 186 | 187 | # Publish Web Output 188 | *.[Pp]ublish.xml 189 | *.azurePubxml 190 | # Note: Comment the next line if you want to checkin your web deploy settings, 191 | # but database connection strings (with potential passwords) will be unencrypted 192 | *.pubxml 193 | *.publishproj 194 | 195 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 196 | # checkin your Azure Web App publish settings, but sensitive information contained 197 | # in these scripts will be unencrypted 198 | PublishScripts/ 199 | 200 | # NuGet Packages 201 | *.nupkg 202 | # NuGet Symbol Packages 203 | *.snupkg 204 | # The packages folder can be ignored because of Package Restore 205 | **/[Pp]ackages/* 206 | # except build/, which is used as an MSBuild target. 207 | !**/[Pp]ackages/build/ 208 | # Uncomment if necessary however generally it will be regenerated when needed 209 | #!**/[Pp]ackages/repositories.config 210 | # NuGet v3's project.json files produces more ignorable files 211 | *.nuget.props 212 | *.nuget.targets 213 | 214 | # Microsoft Azure Build Output 215 | csx/ 216 | *.build.csdef 217 | 218 | # Microsoft Azure Emulator 219 | ecf/ 220 | rcf/ 221 | 222 | # Windows Store app package directories and files 223 | AppPackages/ 224 | BundleArtifacts/ 225 | Package.StoreAssociation.xml 226 | _pkginfo.txt 227 | *.appx 228 | *.appxbundle 229 | *.appxupload 230 | 231 | # Visual Studio cache files 232 | # files ending in .cache can be ignored 233 | *.[Cc]ache 234 | # but keep track of directories ending in .cache 235 | !?*.[Cc]ache/ 236 | 237 | # Others 238 | ClientBin/ 239 | ~$* 240 | *~ 241 | *.dbmdl 242 | *.dbproj.schemaview 243 | *.jfm 244 | *.pfx 245 | *.publishsettings 246 | orleans.codegen.cs 247 | 248 | # Including strong name files can present a security risk 249 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 250 | #*.snk 251 | 252 | # Since there are multiple workflows, uncomment next line to ignore bower_components 253 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 254 | #bower_components/ 255 | 256 | # RIA/Silverlight projects 257 | Generated_Code/ 258 | 259 | # Backup & report files from converting an old project file 260 | # to a newer Visual Studio version. Backup files are not needed, 261 | # because we have git ;-) 262 | _UpgradeReport_Files/ 263 | Backup*/ 264 | UpgradeLog*.XML 265 | UpgradeLog*.htm 266 | ServiceFabricBackup/ 267 | *.rptproj.bak 268 | 269 | # SQL Server files 270 | *.mdf 271 | *.ldf 272 | *.ndf 273 | 274 | # Business Intelligence projects 275 | *.rdl.data 276 | *.bim.layout 277 | *.bim_*.settings 278 | *.rptproj.rsuser 279 | *- [Bb]ackup.rdl 280 | *- [Bb]ackup ([0-9]).rdl 281 | *- [Bb]ackup ([0-9][0-9]).rdl 282 | 283 | # Microsoft Fakes 284 | FakesAssemblies/ 285 | 286 | # GhostDoc plugin setting file 287 | *.GhostDoc.xml 288 | 289 | # Node.js Tools for Visual Studio 290 | .ntvs_analysis.dat 291 | node_modules/ 292 | 293 | # Visual Studio 6 build log 294 | *.plg 295 | 296 | # Visual Studio 6 workspace options file 297 | *.opt 298 | 299 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 300 | *.vbw 301 | 302 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 303 | *.vbp 304 | 305 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 306 | *.dsw 307 | *.dsp 308 | 309 | # Visual Studio 6 technical files 310 | 311 | # Visual Studio LightSwitch build output 312 | **/*.HTMLClient/GeneratedArtifacts 313 | **/*.DesktopClient/GeneratedArtifacts 314 | **/*.DesktopClient/ModelManifest.xml 315 | **/*.Server/GeneratedArtifacts 316 | **/*.Server/ModelManifest.xml 317 | _Pvt_Extensions 318 | 319 | # Paket dependency manager 320 | .paket/paket.exe 321 | paket-files/ 322 | 323 | # FAKE - F# Make 324 | .fake/ 325 | 326 | # CodeRush personal settings 327 | .cr/personal 328 | 329 | # Python Tools for Visual Studio (PTVS) 330 | __pycache__/ 331 | *.pyc 332 | 333 | # Cake - Uncomment if you are using it 334 | # tools/** 335 | # !tools/packages.config 336 | 337 | # Tabs Studio 338 | *.tss 339 | 340 | # Telerik's JustMock configuration file 341 | *.jmconfig 342 | 343 | # BizTalk build output 344 | *.btp.cs 345 | *.btm.cs 346 | *.odx.cs 347 | *.xsd.cs 348 | 349 | # OpenCover UI analysis results 350 | OpenCover/ 351 | 352 | # Azure Stream Analytics local run output 353 | ASALocalRun/ 354 | 355 | # MSBuild Binary and Structured Log 356 | *.binlog 357 | 358 | # NVidia Nsight GPU debugger configuration file 359 | *.nvuser 360 | 361 | # MFractors (Xamarin productivity tool) working folder 362 | .mfractor/ 363 | 364 | # Local History for Visual Studio 365 | .localhistory/ 366 | 367 | # Visual Studio History (VSHistory) files 368 | .vshistory/ 369 | 370 | # BeatPulse healthcheck temp database 371 | healthchecksdb 372 | 373 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 374 | MigrationBackup/ 375 | 376 | # Ionide (cross platform F# VS Code tools) working folder 377 | .ionide/ 378 | 379 | # Fody - auto-generated XML schema 380 | FodyWeavers.xsd 381 | 382 | # VS Code files for those working on multiple tools 383 | .vscode/* 384 | !.vscode/settings.json 385 | !.vscode/tasks.json 386 | !.vscode/launch.json 387 | !.vscode/extensions.json 388 | *.code-workspace 389 | 390 | # Local History for Visual Studio Code 391 | .history/ 392 | 393 | # Windows Installer files from build outputs 394 | *.cab 395 | *.msi 396 | *.msix 397 | *.msm 398 | *.msp 399 | 400 | # JetBrains Rider 401 | *.sln.iml 402 | 403 | ### JetBrains ### 404 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 405 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 406 | 407 | # User-specific stuff 408 | .idea/**/workspace.xml 409 | .idea/**/tasks.xml 410 | .idea/**/usage.statistics.xml 411 | .idea/**/dictionaries 412 | .idea/**/shelf 413 | 414 | # AWS User-specific 415 | .idea/**/aws.xml 416 | 417 | # Generated files 418 | .idea/**/contentModel.xml 419 | 420 | # Sensitive or high-churn files 421 | .idea/**/dataSources/ 422 | .idea/**/dataSources.ids 423 | .idea/**/dataSources.local.xml 424 | .idea/**/sqlDataSources.xml 425 | .idea/**/dynamic.xml 426 | .idea/**/uiDesigner.xml 427 | .idea/**/dbnavigator.xml 428 | 429 | # Gradle 430 | .idea/**/gradle.xml 431 | .idea/**/libraries 432 | 433 | # Gradle and Maven with auto-import 434 | # When using Gradle or Maven with auto-import, you should exclude module files, 435 | # since they will be recreated, and may cause churn. Uncomment if using 436 | # auto-import. 437 | # .idea/artifacts 438 | # .idea/compiler.xml 439 | # .idea/jarRepositories.xml 440 | # .idea/modules.xml 441 | # .idea/*.iml 442 | # .idea/modules 443 | # *.iml 444 | # *.ipr 445 | 446 | # CMake 447 | cmake-build-*/ 448 | 449 | # Mongo Explorer plugin 450 | .idea/**/mongoSettings.xml 451 | 452 | # File-based project format 453 | *.iws 454 | 455 | # IntelliJ 456 | out/ 457 | 458 | # mpeltonen/sbt-idea plugin 459 | .idea_modules/ 460 | 461 | # JIRA plugin 462 | atlassian-ide-plugin.xml 463 | 464 | # Cursive Clojure plugin 465 | .idea/replstate.xml 466 | 467 | # SonarLint plugin 468 | .idea/sonarlint/ 469 | 470 | # Crashlytics plugin (for Android Studio and IntelliJ) 471 | com_crashlytics_export_strings.xml 472 | crashlytics.properties 473 | crashlytics-build.properties 474 | fabric.properties 475 | 476 | # Editor-based Rest Client 477 | .idea/httpRequests 478 | 479 | # Android studio 3.1+ serialized cache file 480 | .idea/caches/build_file_checksums.ser 481 | 482 | ### JetBrains Patch ### 483 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 484 | 485 | # *.iml 486 | # modules.xml 487 | # .idea/misc.xml 488 | # *.ipr 489 | 490 | # Sonarlint plugin 491 | # https://plugins.jetbrains.com/plugin/7973-sonarlint 492 | .idea/**/sonarlint/ 493 | 494 | # SonarQube Plugin 495 | # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin 496 | .idea/**/sonarIssues.xml 497 | 498 | # Markdown Navigator plugin 499 | # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced 500 | .idea/**/markdown-navigator.xml 501 | .idea/**/markdown-navigator-enh.xml 502 | .idea/**/markdown-navigator/ 503 | 504 | # Cache file creation bug 505 | # See https://youtrack.jetbrains.com/issue/JBR-2257 506 | .idea/$CACHE_FILE$ 507 | 508 | # CodeStream plugin 509 | # https://plugins.jetbrains.com/plugin/12206-codestream 510 | .idea/codestream.xml 511 | 512 | ### Rider ### 513 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 514 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 515 | 516 | # User-specific stuff 517 | 518 | # AWS User-specific 519 | 520 | # Generated files 521 | 522 | # Sensitive or high-churn files 523 | 524 | # Gradle 525 | 526 | # Gradle and Maven with auto-import 527 | # When using Gradle or Maven with auto-import, you should exclude module files, 528 | # since they will be recreated, and may cause churn. Uncomment if using 529 | # auto-import. 530 | # .idea/artifacts 531 | # .idea/compiler.xml 532 | # .idea/jarRepositories.xml 533 | # .idea/modules.xml 534 | # .idea/*.iml 535 | # .idea/modules 536 | # *.iml 537 | # *.ipr 538 | 539 | # CMake 540 | 541 | # Mongo Explorer plugin 542 | 543 | # File-based project format 544 | 545 | # IntelliJ 546 | 547 | # mpeltonen/sbt-idea plugin 548 | 549 | # JIRA plugin 550 | 551 | # Cursive Clojure plugin 552 | 553 | # SonarLint plugin 554 | 555 | # Crashlytics plugin (for Android Studio and IntelliJ) 556 | 557 | # Editor-based Rest Client 558 | 559 | # Android studio 3.1+ serialized cache file 560 | 561 | ### VisualStudio ### 562 | 563 | # User-specific files 564 | 565 | # User-specific files (MonoDevelop/Xamarin Studio) 566 | 567 | # Mono auto generated files 568 | 569 | # Build results 570 | 571 | # Visual Studio 2015/2017 cache/options directory 572 | # Uncomment if you have tasks that create the project's static files in wwwroot 573 | 574 | # Visual Studio 2017 auto generated files 575 | 576 | # MSTest test Results 577 | 578 | # NUnit 579 | 580 | # Build Results of an ATL Project 581 | 582 | # Benchmark Results 583 | 584 | # .NET Core 585 | 586 | # ASP.NET Scaffolding 587 | 588 | # StyleCop 589 | 590 | # Files built by Visual Studio 591 | 592 | # Chutzpah Test files 593 | 594 | # Visual C++ cache files 595 | 596 | # Visual Studio profiler 597 | 598 | # Visual Studio Trace Files 599 | 600 | # TFS 2012 Local Workspace 601 | 602 | # Guidance Automation Toolkit 603 | 604 | # ReSharper is a .NET coding add-in 605 | 606 | # TeamCity is a build add-in 607 | 608 | # DotCover is a Code Coverage Tool 609 | 610 | # AxoCover is a Code Coverage Tool 611 | 612 | # Coverlet is a free, cross platform Code Coverage Tool 613 | 614 | # Visual Studio code coverage results 615 | 616 | # NCrunch 617 | 618 | # MightyMoose 619 | 620 | # Web workbench (sass) 621 | 622 | # Installshield output folder 623 | 624 | # DocProject is a documentation generator add-in 625 | 626 | # Click-Once directory 627 | 628 | # Publish Web Output 629 | # Note: Comment the next line if you want to checkin your web deploy settings, 630 | # but database connection strings (with potential passwords) will be unencrypted 631 | 632 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 633 | # checkin your Azure Web App publish settings, but sensitive information contained 634 | # in these scripts will be unencrypted 635 | 636 | # NuGet Packages 637 | # NuGet Symbol Packages 638 | # The packages folder can be ignored because of Package Restore 639 | # except build/, which is used as an MSBuild target. 640 | # Uncomment if necessary however generally it will be regenerated when needed 641 | # NuGet v3's project.json files produces more ignorable files 642 | 643 | # Microsoft Azure Build Output 644 | 645 | # Microsoft Azure Emulator 646 | 647 | # Windows Store app package directories and files 648 | 649 | # Visual Studio cache files 650 | # files ending in .cache can be ignored 651 | # but keep track of directories ending in .cache 652 | 653 | # Others 654 | 655 | # Including strong name files can present a security risk 656 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 657 | 658 | # Since there are multiple workflows, uncomment next line to ignore bower_components 659 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 660 | 661 | # RIA/Silverlight projects 662 | 663 | # Backup & report files from converting an old project file 664 | # to a newer Visual Studio version. Backup files are not needed, 665 | # because we have git ;-) 666 | 667 | # SQL Server files 668 | 669 | # Business Intelligence projects 670 | 671 | # Microsoft Fakes 672 | 673 | # GhostDoc plugin setting file 674 | 675 | # Node.js Tools for Visual Studio 676 | 677 | # Visual Studio 6 build log 678 | 679 | # Visual Studio 6 workspace options file 680 | 681 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 682 | 683 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 684 | 685 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 686 | 687 | # Visual Studio 6 technical files 688 | 689 | # Visual Studio LightSwitch build output 690 | 691 | # Paket dependency manager 692 | 693 | # FAKE - F# Make 694 | 695 | # CodeRush personal settings 696 | 697 | # Python Tools for Visual Studio (PTVS) 698 | 699 | # Cake - Uncomment if you are using it 700 | # tools/** 701 | # !tools/packages.config 702 | 703 | # Tabs Studio 704 | 705 | # Telerik's JustMock configuration file 706 | 707 | # BizTalk build output 708 | 709 | # OpenCover UI analysis results 710 | 711 | # Azure Stream Analytics local run output 712 | 713 | # MSBuild Binary and Structured Log 714 | 715 | # NVidia Nsight GPU debugger configuration file 716 | 717 | # MFractors (Xamarin productivity tool) working folder 718 | 719 | # Local History for Visual Studio 720 | 721 | # Visual Studio History (VSHistory) files 722 | 723 | # BeatPulse healthcheck temp database 724 | 725 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 726 | 727 | # Ionide (cross platform F# VS Code tools) working folder 728 | 729 | # Fody - auto-generated XML schema 730 | 731 | # VS Code files for those working on multiple tools 732 | 733 | # Local History for Visual Studio Code 734 | 735 | # Windows Installer files from build outputs 736 | 737 | # JetBrains Rider 738 | 739 | ### VisualStudio Patch ### 740 | # Additional files built by Visual Studio 741 | 742 | # End of https://www.toptal.com/developers/gitignore/api/csharp,visualstudio,rider,jetbrains 743 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src/submodules/GbxRemote.Net"] 2 | path = submodules/GbxRemote.Net 3 | url = https://github.com/FORCE-TM/GbxRemote.Net 4 | branch = force 5 | -------------------------------------------------------------------------------- /FORCE.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.31903.59 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FORCE", "src\FORCE\FORCE.csproj", "{1CF3137E-1951-4C68-B35D-41F2FB8B7C90}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "submodules", "submodules", "{D2D42CC4-5199-492C-BABB-711D34FF67D5}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GbxRemote.Net", "submodules\GbxRemote.Net\GbxRemote.Net\GbxRemote.Net.csproj", "{BEEA3F0E-C7AF-4FBD-BD0A-19E516E91981}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FORCE.Core", "src\FORCE.Core\FORCE.Core.csproj", "{BE90A4CE-2529-45BA-AC2F-A49F2A82B669}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FORCE.Core.Shared", "src\FORCE.Core.Shared\FORCE.Core.Shared.csproj", "{2A019C59-3F83-44A5-B5FB-B17AA240DBEE}" 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FORCE.Core.Plugin", "src\FORCE.Core.Plugin\FORCE.Core.Plugin.csproj", "{67EE63AF-6080-4515-A146-AE0318955D0C}" 17 | EndProject 18 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9D32CD6A-0AEF-42E9-A4F5-6B4213354125}" 19 | EndProject 20 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "plugins", "plugins", "{F7EA0D56-D6A9-44F8-8617-319413E7100E}" 21 | EndProject 22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FORCE.Plugin.AutoGreeter", "plugins\FORCE.Plugin.AutoGreeter\FORCE.Plugin.AutoGreeter.csproj", "{9212AFF1-417C-4653-AE8B-A8EB92329346}" 23 | EndProject 24 | Global 25 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 26 | Debug|Any CPU = Debug|Any CPU 27 | Release|Any CPU = Release|Any CPU 28 | EndGlobalSection 29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 30 | {1CF3137E-1951-4C68-B35D-41F2FB8B7C90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {1CF3137E-1951-4C68-B35D-41F2FB8B7C90}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {1CF3137E-1951-4C68-B35D-41F2FB8B7C90}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {1CF3137E-1951-4C68-B35D-41F2FB8B7C90}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {BEEA3F0E-C7AF-4FBD-BD0A-19E516E91981}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {BEEA3F0E-C7AF-4FBD-BD0A-19E516E91981}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {BEEA3F0E-C7AF-4FBD-BD0A-19E516E91981}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {BEEA3F0E-C7AF-4FBD-BD0A-19E516E91981}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {BE90A4CE-2529-45BA-AC2F-A49F2A82B669}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {BE90A4CE-2529-45BA-AC2F-A49F2A82B669}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {BE90A4CE-2529-45BA-AC2F-A49F2A82B669}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {BE90A4CE-2529-45BA-AC2F-A49F2A82B669}.Release|Any CPU.Build.0 = Release|Any CPU 42 | {2A019C59-3F83-44A5-B5FB-B17AA240DBEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {2A019C59-3F83-44A5-B5FB-B17AA240DBEE}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {2A019C59-3F83-44A5-B5FB-B17AA240DBEE}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {2A019C59-3F83-44A5-B5FB-B17AA240DBEE}.Release|Any CPU.Build.0 = Release|Any CPU 46 | {67EE63AF-6080-4515-A146-AE0318955D0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 47 | {67EE63AF-6080-4515-A146-AE0318955D0C}.Debug|Any CPU.Build.0 = Debug|Any CPU 48 | {67EE63AF-6080-4515-A146-AE0318955D0C}.Release|Any CPU.ActiveCfg = Release|Any CPU 49 | {67EE63AF-6080-4515-A146-AE0318955D0C}.Release|Any CPU.Build.0 = Release|Any CPU 50 | {9212AFF1-417C-4653-AE8B-A8EB92329346}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 | {9212AFF1-417C-4653-AE8B-A8EB92329346}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 | {9212AFF1-417C-4653-AE8B-A8EB92329346}.Release|Any CPU.ActiveCfg = Release|Any CPU 53 | {9212AFF1-417C-4653-AE8B-A8EB92329346}.Release|Any CPU.Build.0 = Release|Any CPU 54 | EndGlobalSection 55 | GlobalSection(SolutionProperties) = preSolution 56 | HideSolutionNode = FALSE 57 | EndGlobalSection 58 | GlobalSection(NestedProjects) = preSolution 59 | {BEEA3F0E-C7AF-4FBD-BD0A-19E516E91981} = {D2D42CC4-5199-492C-BABB-711D34FF67D5} 60 | {1CF3137E-1951-4C68-B35D-41F2FB8B7C90} = {9D32CD6A-0AEF-42E9-A4F5-6B4213354125} 61 | {BE90A4CE-2529-45BA-AC2F-A49F2A82B669} = {9D32CD6A-0AEF-42E9-A4F5-6B4213354125} 62 | {67EE63AF-6080-4515-A146-AE0318955D0C} = {9D32CD6A-0AEF-42E9-A4F5-6B4213354125} 63 | {2A019C59-3F83-44A5-B5FB-B17AA240DBEE} = {9D32CD6A-0AEF-42E9-A4F5-6B4213354125} 64 | {9212AFF1-417C-4653-AE8B-A8EB92329346} = {F7EA0D56-D6A9-44F8-8617-319413E7100E} 65 | EndGlobalSection 66 | GlobalSection(ExtensibilityGlobals) = postSolution 67 | SolutionGuid = {162F8D76-A06C-4ABA-B026-2156C62B487F} 68 | EndGlobalSection 69 | EndGlobal 70 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FORCE™ 2 | 💜 A modern, community-driven server controller for TrackMania Forever 3 | -------------------------------------------------------------------------------- /plugins/FORCE.Plugin.AutoGreeter/AdminCommands.cs: -------------------------------------------------------------------------------- 1 | using FORCE.Core.Plugin; 2 | using FORCE.Core.Shared; 3 | 4 | namespace FORCE.Plugin.AutoGreeter; 5 | 6 | [CommandGroup("autogreeter", "autogreet", "greeter", "ag")] 7 | [RequireRole(PlayerRole.Admin)] 8 | public class AdminCommands 9 | { 10 | [Command("message", "msg")] 11 | [Summary("Set a new welcome message")] 12 | public async Task MessageAsync(CommandContext command, 13 | [Remainder] [Usage("new_message")] [Summary("The new auto welcome message (Use %player% for the player nickname)")] 14 | string newMessage) 15 | { 16 | // TODO 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /plugins/FORCE.Plugin.AutoGreeter/FORCE.Plugin.AutoGreeter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | False 8 | ..\..\src\FORCE\bin\Debug\net6.0\Plugins\AutoGreeter 9 | false 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /plugins/FORCE.Plugin.AutoGreeter/Plugin.cs: -------------------------------------------------------------------------------- 1 | using FORCE.Core.Plugin; 2 | 3 | namespace FORCE.Plugin.AutoGreeter; 4 | 5 | [Plugin("AutoGreeter", "1.0.0", "Laiteux")] 6 | [Summary(@"Automatically says ""Hey"" when a player connects, and provides commands for players to greet others")] 7 | public class Plugin : PluginBase 8 | { 9 | [Persistent] 10 | private string? _lastLoggedInPlayer; 11 | 12 | public override async Task OnPluginLoadAsync(bool reload) 13 | { 14 | Server.OnPlayerConnect += async (login, _) => 15 | { 16 | _lastLoggedInPlayer = login; 17 | 18 | await GreetAsync(null, login); 19 | }; 20 | 21 | if (!reload) 22 | await Server.ChatSendServerMessageAsync($"$G>> Loaded {Plugin.ToColoredString(ColorScheme)} $G(:"); 23 | } 24 | 25 | [Command("hey", "hi", "hello", "yo")] 26 | [Summary(@"Say ""Hey"" to the specified player (or the last who logged in)")] 27 | public async Task GreetAsync(CommandContext? command, 28 | [Summary("Login of the player to greet (if not specified, it will greet the last player who logged in)")] 29 | string? login = null) 30 | { 31 | var player = Server.Players![(login ?? _lastLoggedInPlayer)!]; 32 | 33 | if (player == null) 34 | { 35 | if (command != null) 36 | { 37 | if (login == null) 38 | await command.ReplyAsync("$F00No last logged in player found."); 39 | else 40 | await command.ReplyAsync($"$F00Player $FFF{login} $F00not found."); 41 | } 42 | 43 | return; 44 | } 45 | 46 | // Means it was called from the event 47 | if (command == null) 48 | { 49 | await Server.ChatSendServerMessageAsync($"$G>> Hey $FFF{player.NickName}$Z$S! Enjoy your stay (:"); 50 | } 51 | else 52 | { 53 | // That is so that "hey" will become "Hey" 54 | string greeting = char.ToUpper(command.Name[0]) + command.Name[1..].ToLower(); 55 | 56 | if (player.Login == command.Author.Login) 57 | { 58 | if (login == null) 59 | await command.SendAsAuthorAsync($"{greeting} everyone!"); 60 | else 61 | await command.ReplyAsync("$F00You can not greet yourself."); 62 | } 63 | else 64 | { 65 | await command.SendAsAuthorAsync($"{greeting} $FFF{player.NickName}$Z$S!"); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/FORCE.Core.Plugin/Attributes/CommandAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace FORCE.Core.Plugin; 2 | 3 | /// 4 | /// Indicates that a method is a plugin command.
5 | /// This attribute is required in order for a command to be discoverable.
6 | /// In order to add a group prefix to a command, its parent class must be decorated with . 7 | ///
8 | [AttributeUsage(AttributeTargets.Method)] 9 | public sealed class CommandAttribute : Attribute, ICommandAttribute 10 | { 11 | /// 12 | /// Name of the command. Aliases can be added. 13 | public CommandAttribute(params string[] names) 14 | { 15 | Names = names; 16 | } 17 | 18 | /// 19 | public string[] Names { get; } 20 | } 21 | 22 | public interface ICommandAttribute 23 | { 24 | /// 25 | /// The name and aliases of the command. 26 | /// 27 | public string[] Names { get; } 28 | } 29 | -------------------------------------------------------------------------------- /src/FORCE.Core.Plugin/Attributes/CommandGroupAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace FORCE.Core.Plugin; 2 | 3 | /// 4 | /// Indicates that a class is a command group. This is optional.
5 | /// Command groups allow to add a prefix to all of the commands in a class. 6 | ///
7 | [AttributeUsage(AttributeTargets.Class)] 8 | public sealed class CommandGroupAttribute : Attribute, ICommandGroupAttribute 9 | { 10 | /// 11 | /// Prefix of the command group. Aliases can be added. 12 | public CommandGroupAttribute(params string[] prefixes) 13 | { 14 | Prefixes = prefixes; 15 | } 16 | 17 | /// 18 | public string[] Prefixes { get; } 19 | } 20 | 21 | public interface ICommandGroupAttribute 22 | { 23 | /// 24 | /// The prefix and aliases of the command group. 25 | /// 26 | public string[] Prefixes { get; } 27 | } 28 | -------------------------------------------------------------------------------- /src/FORCE.Core.Plugin/Attributes/PersistentAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace FORCE.Core.Plugin; 2 | 3 | /// 4 | /// Indicates that the value of a field or property should be preserved after a plugin reloads. 5 | /// 6 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] 7 | public sealed class PersistentAttribute : Attribute, IPersistentAttribute 8 | { 9 | /// 10 | public PersistentAttribute() 11 | { 12 | IsPersistent = true; 13 | } 14 | 15 | /// 16 | public bool IsPersistent { get; } 17 | } 18 | 19 | public interface IPersistentAttribute 20 | { 21 | public bool IsPersistent { get; } 22 | } 23 | -------------------------------------------------------------------------------- /src/FORCE.Core.Plugin/Attributes/PluginAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace FORCE.Core.Plugin; 2 | 3 | /// 4 | /// Indicates the , and of a FORCE plugin.
5 | /// This attribute is required in order for a plugin to be discoverable.
6 | /// This same class must also inherit from .
7 | /// There can only be one plugin class per assembly, or at least per assembly module. 8 | ///
9 | [AttributeUsage(AttributeTargets.Class)] 10 | public sealed class PluginAttribute : Attribute, IPluginAttribute 11 | { 12 | /// 13 | /// Display name of the plugin. 14 | /// Version of the plugin. This must be a valid string. 15 | /// Display name of the plugin author. Optional. 16 | public PluginAttribute(string name, string version, string? author = null) 17 | { 18 | Name = name; 19 | Version = new Version(version); 20 | Author = author; 21 | } 22 | 23 | /// 24 | public string Name { get; } 25 | 26 | /// 27 | public Version Version { get; } 28 | 29 | /// 30 | public string? Author { get; } 31 | } 32 | 33 | public interface IPluginAttribute 34 | { 35 | /// 36 | /// The plugin display name. 37 | /// 38 | public string Name { get; } 39 | 40 | /// 41 | /// The plugin version. 42 | /// 43 | public Version Version { get; } 44 | 45 | /// 46 | /// The plugin author. Nullable. 47 | /// 48 | public string? Author { get; } 49 | } 50 | -------------------------------------------------------------------------------- /src/FORCE.Core.Plugin/Attributes/RemainderAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace FORCE.Core.Plugin; 2 | 3 | /// 4 | /// Indicates that starting from a parameter, the command arguments should not be split anymore.
5 | /// The parameter must be of type , and there can not be more parameters after it. 6 | ///
7 | [AttributeUsage(AttributeTargets.Parameter)] 8 | public sealed class RemainderAttribute : Attribute, IRemainderAttribute 9 | { 10 | /// 11 | public RemainderAttribute() 12 | { 13 | IsRemainder = true; 14 | } 15 | 16 | /// 17 | public bool IsRemainder { get; } 18 | } 19 | 20 | public interface IRemainderAttribute 21 | { 22 | public bool IsRemainder { get; } 23 | } 24 | -------------------------------------------------------------------------------- /src/FORCE.Core.Plugin/Attributes/RequireRoleAttribute.cs: -------------------------------------------------------------------------------- 1 | using FORCE.Core.Shared; 2 | 3 | namespace FORCE.Core.Plugin; 4 | 5 | /// 6 | /// Indicates that one command or all commands from a class require a player to have a role in order to use them.
7 | /// By default, a command can be used by anyone without requiring a role. 8 | ///
9 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] 10 | public sealed class RequireRoleAttribute : Attribute, IRequireRoleAttribute 11 | { 12 | /// 13 | /// Role from which a player will be able to use a command. 14 | /// Whether or not to hide the existence of a command to unauthorized players. 15 | public RequireRoleAttribute(PlayerRole role, bool hideIfUnauthorized = true) 16 | { 17 | RequiredRole = role; 18 | HideIfUnauthorized = hideIfUnauthorized; 19 | } 20 | 21 | /// 22 | public PlayerRole? RequiredRole { get; } 23 | 24 | /// 25 | public bool HideIfUnauthorized { get; } 26 | } 27 | 28 | public interface IRequireRoleAttribute 29 | { 30 | /// 31 | /// The role from which a player will be able to use a command. 32 | /// 33 | public PlayerRole? RequiredRole { get; } 34 | 35 | /// 36 | /// Whether or not to hide the existence of a command to unauthorized players. 37 | /// 38 | public bool HideIfUnauthorized { get; } 39 | } 40 | -------------------------------------------------------------------------------- /src/FORCE.Core.Plugin/Attributes/SummaryAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace FORCE.Core.Plugin; 2 | 3 | /// 4 | /// Adds a summary to your plugin, command group, command or command parameter. This is optional. 5 | /// 6 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Parameter)] 7 | public sealed class SummaryAttribute : Attribute, ISummaryAttribute 8 | { 9 | /// 10 | public SummaryAttribute(string text) 11 | { 12 | Summary = text; 13 | } 14 | 15 | /// 16 | public string? Summary { get; } 17 | } 18 | 19 | public interface ISummaryAttribute 20 | { 21 | public string? Summary { get; } 22 | } 23 | -------------------------------------------------------------------------------- /src/FORCE.Core.Plugin/Attributes/UsageAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace FORCE.Core.Plugin; 2 | 3 | /// 4 | /// Overrides the usage name of a command parameter, which will be shown in a command usage help.
5 | /// By default, the usage name of a parameter is its variable name.
6 | /// Example of a useful case: /myplugin status <on|off> 7 | ///
8 | [AttributeUsage(AttributeTargets.Parameter)] 9 | public class UsageAttribute : Attribute, IUsageAttribute 10 | { 11 | /// 12 | /// Custom usage name of a command parameter. 13 | public UsageAttribute(string name) 14 | { 15 | UsageName = name; 16 | } 17 | 18 | /// 19 | public string? UsageName { get; } 20 | } 21 | 22 | public interface IUsageAttribute 23 | { 24 | /// 25 | /// The custom usage name of a command parameter. 26 | /// 27 | public string? UsageName { get; } 28 | } 29 | -------------------------------------------------------------------------------- /src/FORCE.Core.Plugin/CommandContext.cs: -------------------------------------------------------------------------------- 1 | using GbxRemoteNet; 2 | 3 | namespace FORCE.Core.Plugin; 4 | 5 | /// 6 | /// Class containing info about the executed command, as well as some utility methods to interact with the server.
7 | /// In order for a command method to be valid, its first parameter must always be of type . 8 | ///
9 | public class CommandContext : ContextBase 10 | { 11 | /// 12 | /// Name of the command that was typed by the .
13 | /// If command is part of a group, this will also contain the typed group prefix. 14 | ///
15 | public string Name { get; set; } = null!; 16 | 17 | /// 18 | /// Player who executed the command. 19 | /// 20 | public PlayerDetailedInfo Author { get; set; } = null!; 21 | 22 | /// 23 | /// Send a private message to the . 24 | /// 25 | /// Message to send. 26 | /// Whether to prefix the message with a single arrow "> ". Used as to distinguish between public and private messages. 27 | public async Task ReplyAsync(string message, bool arrowPrefix = true) 28 | => await Server.ChatSendServerMessageToIdAsync((arrowPrefix ? "$G> " : null) + message, Author.PlayerId); 29 | 30 | /// 31 | /// Send a public message that everyone will see. 32 | /// 33 | /// Message to send. 34 | /// Whether to prefix the message with a double arrow ">> ". Used as to distinguish between public and private messages. 35 | public async Task SendAsync(string message, bool arrowPrefix = true) 36 | => await Server.ChatSendServerMessageAsync((arrowPrefix ? "$G>> " : null) + message); 37 | 38 | /// 39 | /// Send a message prefixed with the nickname, just like if he would talk in chat. 40 | /// 41 | /// Message to send. 42 | public async Task SendAsAuthorAsync(string message) 43 | => await SendAsync($"$G[{Author.NickName}$Z$S] {message}", false); 44 | } 45 | -------------------------------------------------------------------------------- /src/FORCE.Core.Plugin/ContextBase.cs: -------------------------------------------------------------------------------- 1 | using FORCE.Core.Shared; 2 | 3 | namespace FORCE.Core.Plugin; 4 | 5 | /// 6 | /// Class containing some objects for plugins to interact with.
7 | /// ⚠️ You are NOT supposed to inherit this! This is for internal purposes only.
8 | /// Perhaps you may be looking for or even instead? 9 | ///
10 | public class ContextBase 11 | { 12 | /// 13 | public PluginDisplayInfo Plugin { get; set; } = null!; 14 | 15 | /// 16 | public TmServer Server { get; set; } = null!; 17 | 18 | /// 19 | public ColorScheme ColorScheme { get; set; } = null!; 20 | } 21 | -------------------------------------------------------------------------------- /src/FORCE.Core.Plugin/FORCE.Core.Plugin.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/FORCE.Core.Plugin/FORCE.Core.Plugin.csproj.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True 3 | True -------------------------------------------------------------------------------- /src/FORCE.Core.Plugin/Models/PluginDisplayInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using FORCE.Core.Shared; 3 | 4 | namespace FORCE.Core.Plugin; 5 | 6 | /// 7 | /// A class containing primary information about a plugin, such as its , , or . 8 | /// 9 | public class PluginDisplayInfo : IPluginAttribute, ISummaryAttribute, IColoredString 10 | { 11 | /// 12 | public string Name { get; set; } = null!; 13 | 14 | /// 15 | public Version Version { get; set; } = null!; 16 | 17 | /// 18 | public string? Author { get; set; } 19 | 20 | /// 21 | public string? Summary { get; set; } 22 | 23 | public override string ToString() 24 | { 25 | var nameBuilder = new StringBuilder(); 26 | 27 | nameBuilder.Append(Name + " v" + Version); 28 | 29 | if (!string.IsNullOrWhiteSpace(Author)) 30 | { 31 | nameBuilder.Append(" by " + Author); 32 | } 33 | 34 | return nameBuilder.ToString(); 35 | } 36 | 37 | public string ToColoredString(ColorScheme scheme) 38 | { 39 | var sb = new StringBuilder(); 40 | 41 | sb.Append(scheme.AccentColor + Name); 42 | sb.Append(scheme.BaseColor + " v"); 43 | sb.Append(scheme.AccentColor + Version); 44 | 45 | if (!string.IsNullOrWhiteSpace(Author)) 46 | { 47 | sb.Append(scheme.BaseColor + " by "); 48 | sb.Append(scheme.AccentColor + Author); 49 | } 50 | 51 | return sb.ToString(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/FORCE.Core.Plugin/PluginBase.cs: -------------------------------------------------------------------------------- 1 | namespace FORCE.Core.Plugin; 2 | 3 | /// 4 | /// A plugin must inherit from this class in order to be discoverable.
5 | /// The plugin class must also be decorated with .
6 | /// There can only be one plugin class per assembly, or at least per assembly module. 7 | ///
8 | public abstract class PluginBase : ContextBase 9 | { 10 | /// 11 | /// Method invoked when the plugin was loaded, and is ready to process commands.
12 | /// This method can be used to subscribe to some events. 13 | ///
14 | /// Whether the plugin was just reloaded or not. 15 | public virtual Task OnPluginLoadAsync(bool reload) 16 | => Task.CompletedTask; 17 | 18 | /// 19 | /// Method invoked when the plugin is being unloaded.
20 | /// Do not worry about unsubscribing from events, this is already being done behind the scenes. 21 | ///
22 | /// Whether the plugin is being reloaded or not. 23 | public virtual Task OnPluginUnloadAsync(bool reload) 24 | => Task.CompletedTask; 25 | } 26 | -------------------------------------------------------------------------------- /src/FORCE.Core.Shared/ColorScheme.cs: -------------------------------------------------------------------------------- 1 | namespace FORCE.Core.Shared; 2 | 3 | /// 4 | /// Color scheme used by a TrackMania server.
5 | /// This is used as to ensure some uniformity in the colors plugins are using. 6 | ///
7 | public class ColorScheme 8 | { 9 | // TODO: Replace strings with a TmColor class 10 | // TODO: Add SuccessColor, ErrorColor and more... 11 | 12 | public string BaseColor { get; set; } 13 | 14 | public string AccentColor { get; set; } 15 | } 16 | -------------------------------------------------------------------------------- /src/FORCE.Core.Shared/FORCE.Core.Shared.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/FORCE.Core.Shared/IColoredString.cs: -------------------------------------------------------------------------------- 1 | namespace FORCE.Core.Shared; 2 | 3 | /// 4 | /// Forces an object to implement a method, which is then used to return a TrackMania-colored version string of it. 5 | /// 6 | public interface IColoredString 7 | { 8 | // This is only here to add a warning if the class does not override the ToString method 9 | public string ToString(); 10 | 11 | /// A TrackMania-colored version of this , using the provided . 12 | public string ToColoredString(ColorScheme scheme); 13 | } 14 | -------------------------------------------------------------------------------- /src/FORCE.Core.Shared/PlayerList.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using GbxRemoteNet; 3 | using GbxRemoteNet.XmlRpc; 4 | using GbxRemoteNet.XmlRpc.ExtraTypes; 5 | using GbxRemoteNet.XmlRpc.Types; 6 | 7 | namespace FORCE.Core.Shared; 8 | 9 | /// 10 | /// A read-only collection of , containing the online players of the server.
11 | /// This collection can be accessed both by using a player login () or UID (). 12 | ///
13 | public sealed class PlayerList : IReadOnlyCollection 14 | { 15 | private readonly List _players; 16 | private readonly GbxRemoteClient _tmServer; 17 | 18 | public PlayerList(GbxRemoteClient tmServer) 19 | { 20 | _players = new(); 21 | 22 | _tmServer = tmServer; 23 | 24 | LoadOnlinePlayersAsync().GetAwaiter().GetResult(); 25 | 26 | _tmServer.OnPlayerInfoChanged += newPlayerInfo => 27 | { 28 | var player = this[newPlayerInfo.PlayerId]; 29 | 30 | if (player != null) 31 | { 32 | player.TeamId = newPlayerInfo.TeamId; 33 | player.IsSpectator = newPlayerInfo.SpectatorStatus.Spectator; 34 | player.IsReferee = newPlayerInfo.Flags.IsReferee; 35 | } 36 | 37 | return Task.CompletedTask; 38 | }; 39 | } 40 | 41 | private async Task LoadOnlinePlayersAsync() 42 | { 43 | var players = await _tmServer.GetPlayerListAsync(); 44 | 45 | var multicall = new MultiCall(); 46 | 47 | foreach (var player in players) 48 | { 49 | multicall.Add(_tmServer.GetDetailedPlayerInfoAsync, player.Login); 50 | } 51 | 52 | object[] results = await _tmServer.MultiCallAsync(multicall); 53 | 54 | foreach (var result in results.Cast()) 55 | { 56 | var player = (PlayerDetailedInfo)XmlRpcTypes.ToNativeStruct(new XmlRpcStruct(result)); 57 | 58 | _players.Add(player); 59 | } 60 | } 61 | 62 | internal async Task HandlePlayerConnectAsync(string login) 63 | { 64 | var player = await _tmServer.GetDetailedPlayerInfoAsync(login); 65 | 66 | _players.Add(player); 67 | } 68 | 69 | internal Task HandlePlayerDisconnectAsync(string login) 70 | { 71 | _players.RemoveAll(p => p.Login == login); 72 | 73 | return Task.CompletedTask; 74 | } 75 | 76 | public PlayerDetailedInfo? this[int uid] 77 | => _players.SingleOrDefault(p => p.PlayerId == uid); 78 | 79 | public PlayerDetailedInfo? this[string login] 80 | => _players.SingleOrDefault(p => p.Login.Equals(login, StringComparison.OrdinalIgnoreCase)); 81 | 82 | public IEnumerator GetEnumerator() => _players.GetEnumerator(); 83 | IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); 84 | 85 | /// 86 | /// Just a shortcut method for: _players.Where(p => p.IsSpectator) 87 | /// 88 | public IEnumerable GetSpectators() => _players.Where(p => p.IsSpectator); 89 | 90 | public int Count => _players.Count; 91 | 92 | /// 93 | /// Just a shortcut method for: _players.Count(p => p.IsSpectator) 94 | /// 95 | public int SpectatorCount => _players.Count(p => p.IsSpectator); 96 | } 97 | -------------------------------------------------------------------------------- /src/FORCE.Core.Shared/PlayerRole.cs: -------------------------------------------------------------------------------- 1 | namespace FORCE.Core.Shared; 2 | 3 | /// 4 | /// Role of a player on the server. 5 | /// 6 | public enum PlayerRole 7 | { 8 | None, 9 | Operator, 10 | Admin, 11 | MasterAdmin 12 | } 13 | -------------------------------------------------------------------------------- /src/FORCE.Core.Shared/TmServer.cs: -------------------------------------------------------------------------------- 1 | using GbxRemoteNet; 2 | 3 | namespace FORCE.Core.Shared; 4 | 5 | /// 6 | /// A all-in-one class for calling server methods and subscribing to callback events. 7 | /// 8 | public sealed class TmServer : GbxRemoteClient 9 | { 10 | /// 11 | public PlayerList? Players { get; private set; } 12 | 13 | public TmServer(string host, int port) : base(host, port) 14 | { 15 | this.WithOptions(new GbxRemoteClientOptions() 16 | { 17 | ConnectionRetries = 2, 18 | ConnectionRetryTimeout = TimeSpan.FromSeconds(1), 19 | CallbackInvoker = CustomCallbackInvoker 20 | }); 21 | 22 | OnConnected += () => 23 | { 24 | Players = new(this); 25 | 26 | return Task.CompletedTask; 27 | }; 28 | } 29 | 30 | private async Task CustomCallbackInvoker(Delegate @delegate, params object[] args) 31 | { 32 | // Handle the player connection/disconnection events first, 33 | // as we must ensure Players is updated before any plugin receives these events. 34 | if (@delegate is PlayerConnectAction) 35 | await Players!.HandlePlayerConnectAsync((string)args[0]); 36 | else if (@delegate is PlayerDisconnectAction) 37 | await Players!.HandlePlayerDisconnectAsync((string)args[0]); 38 | 39 | // Then we can invoke all the methods subscribed to the event. 40 | // No need to check for null, as all GbxRemoteClient events are null-safe by default: 41 | // https://github.com/FORCE-TM/GbxRemote.Net/commit/5e07a17243e91d016b75175cbefae10390d40cef 42 | @delegate.DynamicInvoke(args); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/FORCE.Core/Extensions/EnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace FORCE.Core.Extensions; 2 | 3 | internal static class EnumerableExtensions 4 | { 5 | public static void ForEach(this IEnumerable source, Action action) 6 | { 7 | foreach (TSource item in source) 8 | { 9 | action(item); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/FORCE.Core/Extensions/TypeExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace FORCE.Core.Extensions; 4 | 5 | internal static class TypeExtensions 6 | { 7 | public static bool TryGetCustomAttribute(this MemberInfo element, out T attribute) where T : Attribute 8 | { 9 | return (attribute = element.GetCustomAttribute()!) != null; 10 | } 11 | 12 | public static bool TryGetCustomAttribute(this ParameterInfo element, out T attribute) where T : Attribute 13 | { 14 | return (attribute = element.GetCustomAttribute()!) != null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/FORCE.Core/FORCE.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | PreserveNewest 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/FORCE.Core/Files/Settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Server": { 3 | "Host": "127.0.0.1", 4 | "Port": 5000 5 | }, 6 | "ColorScheme": { 7 | "BaseColor": "$FF0", 8 | "AccentColor": "$0AF" 9 | }, 10 | "Plugins": { 11 | "Directory": "Plugins", 12 | "Enabled": [ 13 | //"Example\\Disabled.Plugin.dll", 14 | "AutoGreeter\\Debug\\FORCE.Plugin.AutoGreeter.dll" 15 | ] 16 | } 17 | } -------------------------------------------------------------------------------- /src/FORCE.Core/Force.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json; 2 | using FORCE.Core.Models; 3 | using FORCE.Core.Plugin; 4 | using FORCE.Core.Shared; 5 | 6 | namespace FORCE.Core; 7 | 8 | public class Force 9 | { 10 | public ForceSettings Settings { get; } 11 | public TmServer Server { get; } 12 | 13 | internal PluginManager PluginManager { get; } 14 | internal CommandHandler CommandHandler { get; } 15 | 16 | public Force() 17 | { 18 | Settings = JsonSerializer.Deserialize(File.ReadAllText(Path.Combine("Files", "Settings.json")), 19 | new JsonSerializerOptions() { ReadCommentHandling = JsonCommentHandling.Skip })!; 20 | 21 | Server = new TmServer(Settings.Server.Host, Settings.Server.Port); 22 | 23 | PluginManager = new PluginManager(this); 24 | CommandHandler = new CommandHandler(this); 25 | } 26 | 27 | public async Task StartAsync() 28 | { 29 | LoadPlugins(); 30 | 31 | await Server.EnableCallbacksAsync(); 32 | 33 | CommandHandler.StartListening(); 34 | } 35 | 36 | private void LoadPlugins() 37 | { 38 | string pluginsDirectory = Path.Combine(Directory.GetCurrentDirectory(), Settings.Plugins.Directory); 39 | 40 | foreach (string pluginFile in Settings.Plugins.Enabled) 41 | { 42 | string pluginPath = Path.Combine(pluginsDirectory, pluginFile); 43 | 44 | if (PluginManager.TryBuildPluginFromAssemblyPath(pluginPath, out var plugin)) 45 | { 46 | PluginManager.LoadPlugin(plugin); 47 | 48 | Console.WriteLine($"Loaded {plugin}"); 49 | 50 | foreach (var command in plugin.Commands) 51 | { 52 | if (command.Disabled) 53 | Console.ForegroundColor = ConsoleColor.Red; 54 | else 55 | Console.ResetColor(); 56 | 57 | Console.WriteLine($" {command}"); 58 | } 59 | 60 | Console.WriteLine(); 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/FORCE.Core/Models/ForceSettings.cs: -------------------------------------------------------------------------------- 1 | using FORCE.Core.Shared; 2 | 3 | namespace FORCE.Core.Models; 4 | 5 | #pragma warning disable CS8618 6 | 7 | public class ForceSettings 8 | { 9 | public ForceServerSettings Server { get; set; } 10 | public ColorScheme ColorScheme { get; set; } 11 | 12 | public ForcePluginsSettings Plugins { get; set; } 13 | } 14 | 15 | public class ForceServerSettings 16 | { 17 | public string Host { get; set; } 18 | public int Port { get; set; } 19 | } 20 | 21 | public class ForcePluginsSettings 22 | { 23 | public string Directory { get; set; } 24 | public string[] Enabled { get; set; } 25 | } 26 | -------------------------------------------------------------------------------- /src/FORCE.Core/Plugin/Builders/CommandBuilder.cs: -------------------------------------------------------------------------------- 1 | using FORCE.Core.Plugin.Models; 2 | using FORCE.Core.Shared; 3 | 4 | namespace FORCE.Core.Plugin.Builders; 5 | 6 | internal class CommandBuilder : ICommandAttribute, ISummaryAttribute, IRequireRoleAttribute 7 | { 8 | private readonly List _parameters; 9 | private CommandGroupInfo? _commandGroup; 10 | 11 | public string[] Names { get; } 12 | public string? Summary { get; private set; } 13 | public PlayerRole? RequiredRole { get; private set; } 14 | public bool HideIfUnauthorized { get; private set; } 15 | 16 | public CommandBuilder(ICommandAttribute command) 17 | { 18 | Names = command.Names; 19 | _parameters = new List(); 20 | } 21 | 22 | public CommandBuilder WithGroup(CommandGroupInfo commandGroup) 23 | { 24 | _commandGroup = commandGroup; 25 | return this; 26 | } 27 | 28 | public CommandBuilder WithSummary(ISummaryAttribute summary) 29 | { 30 | Summary = summary.Summary; 31 | return this; 32 | } 33 | 34 | public CommandBuilder WithRequireRole(IRequireRoleAttribute requireRole) 35 | { 36 | RequiredRole = requireRole.RequiredRole; 37 | HideIfUnauthorized = requireRole.HideIfUnauthorized; 38 | return this; 39 | } 40 | 41 | public CommandBuilder WithParameters(IEnumerable parameters) 42 | { 43 | _parameters.AddRange(parameters); 44 | return this; 45 | } 46 | 47 | public CommandInfo Build() => new() 48 | { 49 | Names = Names, 50 | Summary = Summary, 51 | RequiredRole = RequiredRole, 52 | HideIfUnauthorized = HideIfUnauthorized, 53 | Group = _commandGroup, 54 | Parameters = _parameters 55 | }; 56 | } 57 | -------------------------------------------------------------------------------- /src/FORCE.Core/Plugin/Builders/CommandGroupBuilder.cs: -------------------------------------------------------------------------------- 1 | using FORCE.Core.Plugin.Models; 2 | using FORCE.Core.Shared; 3 | 4 | namespace FORCE.Core.Plugin.Builders; 5 | 6 | internal class CommandGroupBuilder : ICommandGroupAttribute, ISummaryAttribute, IRequireRoleAttribute 7 | { 8 | public string[] Prefixes { get; } 9 | public string? Summary { get; private set; } 10 | public PlayerRole? RequiredRole { get; private set; } 11 | public bool HideIfUnauthorized { get; private set; } 12 | 13 | public CommandGroupBuilder(ICommandGroupAttribute commandGroup) 14 | { 15 | foreach (string prefix in commandGroup.Prefixes) 16 | if (prefix.Contains(' ')) 17 | throw new InvalidOperationException($"Command group prefix can not contain any space. Prefix: {prefix}"); 18 | 19 | Prefixes = commandGroup.Prefixes; 20 | } 21 | 22 | public CommandGroupBuilder WithSummary(ISummaryAttribute summary) 23 | { 24 | Summary = summary.Summary; 25 | return this; 26 | } 27 | 28 | public CommandGroupBuilder WithRequireRole(IRequireRoleAttribute requireRole) 29 | { 30 | RequiredRole = requireRole.RequiredRole; 31 | HideIfUnauthorized = requireRole.HideIfUnauthorized; 32 | return this; 33 | } 34 | 35 | public CommandGroupInfo Build() => new() 36 | { 37 | Prefixes = Prefixes, 38 | Summary = Summary, 39 | RequiredRole = RequiredRole, 40 | HideIfUnauthorized = HideIfUnauthorized 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /src/FORCE.Core/Plugin/Builders/CommandParameterBuilder.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using FORCE.Core.Plugin.Models; 3 | 4 | namespace FORCE.Core.Plugin.Builders; 5 | 6 | internal class CommandParameterBuilder : IUsageAttribute, ISummaryAttribute, IRemainderAttribute 7 | { 8 | private readonly ParameterInfo _parameter; 9 | private readonly string _parameterPath; 10 | private readonly int _implParameterCount; 11 | 12 | public string? UsageName { get; private set; } 13 | public string? Summary { get; private set; } 14 | public bool IsRemainder { get; private set; } 15 | 16 | public CommandParameterBuilder(ParameterInfo parameter) 17 | { 18 | _parameterPath = $"Parameter: {parameter.Name} in {parameter.Member.DeclaringType!.Name}.{parameter.Member.Name}"; 19 | 20 | if (parameter.Position == 0 && parameter.ParameterType != typeof(CommandContext)) 21 | throw new InvalidOperationException($"The first parameter of a command must be of type {nameof(CommandContext)}. {_parameterPath}"); 22 | 23 | if (parameter.Position != 0 && parameter.ParameterType != typeof(string)) 24 | throw new InvalidOperationException($"At the moment, only parameters of type {typeof(string)} are supported in commands. {_parameterPath}"); 25 | 26 | _parameter = parameter; 27 | _implParameterCount = ((MethodInfo)parameter.Member).GetParameters().Length; 28 | } 29 | 30 | public CommandParameterBuilder WithUsage(IUsageAttribute usage) 31 | { 32 | UsageName = usage.UsageName; 33 | return this; 34 | } 35 | 36 | public CommandParameterBuilder WithSummary(ISummaryAttribute summary) 37 | { 38 | Summary = summary.Summary; 39 | return this; 40 | } 41 | 42 | public CommandParameterBuilder WithRemainder(IRemainderAttribute remainder) 43 | { 44 | if (remainder.IsRemainder) 45 | { 46 | if (_parameter.Position != _implParameterCount - 1) 47 | throw new InvalidOperationException($"{nameof(RemainderAttribute)} can only be used on the last parameter of a command. {_parameterPath}"); 48 | 49 | if (_parameter.ParameterType != typeof(string)) 50 | throw new InvalidOperationException($"{nameof(RemainderAttribute)} can only be used on parameters of type {typeof(string)}. {_parameterPath}"); 51 | } 52 | 53 | IsRemainder = remainder.IsRemainder; 54 | return this; 55 | } 56 | 57 | public CommandParameterInfo Build() => new() 58 | { 59 | Type = _parameter.ParameterType, 60 | Name = _parameter.Name!, 61 | DefaultValue = _parameter.DefaultValue, 62 | HasDefaultValue = _parameter.HasDefaultValue, 63 | UsageName = UsageName, 64 | Summary = Summary, 65 | IsRemainder = IsRemainder 66 | }; 67 | } 68 | -------------------------------------------------------------------------------- /src/FORCE.Core/Plugin/Builders/PluginBuilder.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using FORCE.Core.Extensions; 3 | using FORCE.Core.Plugin.Models; 4 | 5 | namespace FORCE.Core.Plugin.Builders; 6 | 7 | // Heavily inspired by Discord.Net: https://github.com/discord-net/Discord.Net/blob/73399459eacbc15187edf4dc9e26fd934b8a7fad/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs 8 | internal class PluginBuilder 9 | { 10 | private readonly Module _module; 11 | private readonly Force _force; 12 | private readonly List _commands; 13 | 14 | public PluginBuilder(Module module, Force force) 15 | { 16 | _module = module; 17 | _force = force; 18 | _commands = new List(); 19 | } 20 | 21 | public PluginInfo Build() 22 | { 23 | var pluginClass = new ClassInfo(_module.GetTypes().SingleOrDefault(IsValidPluginClass)!); 24 | 25 | if (pluginClass.Type == null) 26 | throw new InvalidOperationException($"None, or more than one class inheriting {nameof(PluginBase)} were found in this module."); 27 | 28 | if (!pluginClass.Type.TryGetCustomAttribute(out var pluginAttribute)) 29 | throw new InvalidOperationException($"Plugin class must be decorated with {nameof(PluginAttribute)}. Class: {pluginClass.Type.FullName}"); 30 | 31 | var summaryAttribute = pluginClass.Type.GetCustomAttribute(); 32 | 33 | foreach (var commandClass in _module.GetTypes().Where(IsValidCommandClass).Select(c => new ClassInfo(c))) 34 | { 35 | if (pluginClass.Type == commandClass.Type) 36 | pluginClass = commandClass; 37 | 38 | CommandGroupInfo? commandGroup = null; 39 | 40 | if (commandClass.Type.TryGetCustomAttribute(out var commandGroupAttribute)) 41 | commandGroup = BuildCommandGroup(commandClass, commandGroupAttribute); 42 | 43 | _commands.AddRange(BuildCommands(commandClass, commandGroup)); 44 | } 45 | 46 | var plugin = new PluginInfo() 47 | { 48 | Name = pluginAttribute.Name, 49 | Version = pluginAttribute.Version, 50 | Author = pluginAttribute.Author, 51 | Summary = summaryAttribute?.Summary, 52 | Commands = _commands, 53 | Class = pluginClass 54 | }; 55 | 56 | plugin.SetContext(new ContextBase() 57 | { 58 | Plugin = plugin, 59 | Server = _force.Server, 60 | ColorScheme = _force.Settings.ColorScheme 61 | }); 62 | 63 | _commands.ForEach(c => c.Plugin = plugin); 64 | 65 | return plugin; 66 | } 67 | 68 | private CommandGroupInfo BuildCommandGroup(ClassInfo commandClass, CommandGroupAttribute commandGroupAttribute) 69 | { 70 | var commandGroupBuilder = new CommandGroupBuilder(commandGroupAttribute); 71 | 72 | foreach (var attribute in commandClass.Type.GetCustomAttributes()) 73 | { 74 | switch (attribute) 75 | { 76 | case SummaryAttribute summary: 77 | commandGroupBuilder.WithSummary(summary); 78 | break; 79 | case RequireRoleAttribute requireRole: 80 | commandGroupBuilder.WithRequireRole(requireRole); 81 | break; 82 | } 83 | } 84 | 85 | return commandGroupBuilder.Build(); 86 | } 87 | 88 | private IEnumerable BuildCommands(ClassInfo commandClass, CommandGroupInfo? commandGroup = null) 89 | { 90 | if (commandGroup != null) 91 | commandGroup.Class = commandClass; 92 | 93 | foreach (var commandMethod in commandClass.Type.GetMethods()) 94 | { 95 | if (!commandMethod.TryGetCustomAttribute(out var commandAttribute)) 96 | continue; 97 | 98 | var commandBuilder = new CommandBuilder(commandAttribute); 99 | 100 | foreach (var attribute in commandMethod.GetCustomAttributes()) 101 | { 102 | switch (attribute) 103 | { 104 | case SummaryAttribute summary: 105 | commandBuilder.WithSummary(summary); 106 | break; 107 | case RequireRoleAttribute requireRole: 108 | commandBuilder.WithRequireRole(requireRole); 109 | break; 110 | } 111 | } 112 | 113 | commandBuilder.WithParameters(BuildCommandParameters(commandMethod)); 114 | 115 | if (commandGroup != null) 116 | commandBuilder.WithGroup(commandGroup); 117 | 118 | var command = commandBuilder.Build(); 119 | 120 | command.Class = commandClass; 121 | command.Method = commandMethod; 122 | 123 | yield return command; 124 | } 125 | } 126 | 127 | private IEnumerable BuildCommandParameters(MethodInfo commandMethod) 128 | { 129 | foreach (var parameter in commandMethod.GetParameters()) 130 | { 131 | var commandParameterBuilder = new CommandParameterBuilder(parameter); 132 | 133 | if (parameter.ParameterType == typeof(CommandContext)) 134 | continue; 135 | 136 | foreach (var attribute in parameter.GetCustomAttributes()) 137 | { 138 | switch (attribute) 139 | { 140 | case UsageAttribute usage: 141 | commandParameterBuilder.WithUsage(usage); 142 | break; 143 | case SummaryAttribute summary: 144 | commandParameterBuilder.WithSummary(summary); 145 | break; 146 | case RemainderAttribute remainder: 147 | commandParameterBuilder.WithRemainder(remainder); 148 | break; 149 | } 150 | } 151 | 152 | yield return commandParameterBuilder.Build(); 153 | } 154 | } 155 | 156 | public static bool IsValidPluginModule(Module module) => 157 | module.GetTypes().Any(IsValidPluginClass); 158 | 159 | public static bool IsValidPluginClass(Type type) => 160 | type.IsClass && 161 | type.IsPublic && 162 | !type.IsAbstract && 163 | !type.ContainsGenericParameters && 164 | typeof(PluginBase).IsAssignableFrom(type); 165 | 166 | public static bool IsValidCommandClass(Type type) => 167 | type.IsClass && 168 | type.IsPublic && 169 | !type.IsAbstract && 170 | !type.ContainsGenericParameters && 171 | type.GetMethods().Any(m => m.GetCustomAttributes().Any(a => a is CommandAttribute)); 172 | } 173 | -------------------------------------------------------------------------------- /src/FORCE.Core/Plugin/CommandHandler.cs: -------------------------------------------------------------------------------- 1 | using BoomTown.FuzzySharp; 2 | using FORCE.Core.Extensions; 3 | using FORCE.Core.Plugin.Models; 4 | 5 | namespace FORCE.Core.Plugin; 6 | 7 | internal class CommandHandler 8 | { 9 | private readonly Force _force; 10 | private readonly List _commands; 11 | 12 | public CommandHandler(Force force) 13 | { 14 | _force = force; 15 | 16 | _commands = _force.PluginManager.GetLoadedPlugins().SelectMany(p => p.Commands).ToList(); 17 | 18 | _force.PluginManager.OnPluginLoaded += plugin 19 | => _commands.AddRange(plugin.Commands); 20 | 21 | _force.PluginManager.OnPluginUnloaded += plugin 22 | => _commands.RemoveAll(c => c.Plugin == plugin); 23 | } 24 | 25 | public void StartListening() 26 | => _force.Server.OnPlayerChat += HandleCommandAsync; 27 | 28 | public void StopListening() 29 | => _force.Server.OnPlayerChat -= HandleCommandAsync; 30 | 31 | private async Task HandleCommandAsync(int playerUid, string playerLogin, string text, bool _) 32 | { 33 | if (playerUid == 0) // server 34 | return; 35 | 36 | if (!text.StartsWith('/') || (text = text.TrimStart('/')).Length == 0) 37 | return; 38 | 39 | if (!TryMatchCommand(text, out CommandInfo? command, out string? commandName, out string? suggestion)) 40 | { 41 | string errorMessage = $"$G> $F00There is no such command as $FFF/{commandName ?? text}"; 42 | 43 | if (suggestion != null) 44 | errorMessage += $"$F00, did you mean $FFF/{suggestion}$F00?"; 45 | 46 | await _force.Server.ChatSendServerMessageToIdAsync(errorMessage, playerUid); 47 | 48 | return; 49 | } 50 | 51 | if (!TryGetParameters(text, command!, commandName!, out var parameters)) 52 | { 53 | string errorMessage = $"$G> $F00Usage: $FFF{command}"; 54 | 55 | await _force.Server.ChatSendServerMessageToIdAsync(errorMessage, playerUid); 56 | 57 | return; 58 | } 59 | 60 | var commandContext = new CommandContext() 61 | { 62 | Name = commandName!, 63 | Author = _force.Server.Players![playerUid]!, 64 | Plugin = command!.Plugin, 65 | Server = _force.Server, 66 | ColorScheme = _force.Settings.ColorScheme 67 | }; 68 | 69 | await (Task)command.Method.Invoke(command.Class.GetInstance(), parameters!.Prepend(commandContext).ToArray())!; 70 | } 71 | 72 | private bool TryMatchCommand(string text, out CommandInfo? command, out string? commandName, out string? suggestion) 73 | { 74 | command = null; commandName = null; suggestion = null; 75 | int matchRatio = 0, suggestionRatio = 0; 76 | 77 | string[] textSplit = text.Split(' ', StringSplitOptions.RemoveEmptyEntries); 78 | 79 | // Prioritize groups in case a command would be named the same as a group and would match first 80 | foreach (var pluginCommand in _commands.Where(c => !c.Disabled).OrderByDescending(c => c.IsInGroup)) 81 | { 82 | string[] matchNames = pluginCommand.IsInGroup 83 | ? pluginCommand.Group!.Prefixes 84 | .SelectMany(prefix => pluginCommand.Names.Select(name => string.Join(' ', prefix, name))) 85 | .ToArray() 86 | : pluginCommand.Names; 87 | 88 | string userCommandName = textSplit.Length > 1 && pluginCommand.IsInGroup 89 | ? string.Join(' ', textSplit[0], textSplit[1]) 90 | : textSplit[0]; 91 | 92 | var (matchName, maxRatio) = matchNames 93 | .ToDictionary(m => m, m => Fuzzy.Ratio(m, userCommandName)) 94 | .MaxBy(x => x.Value); 95 | 96 | if (maxRatio >= 75 && maxRatio > matchRatio) 97 | { 98 | (command, commandName, matchRatio) = (pluginCommand, userCommandName, maxRatio); 99 | } 100 | else if (maxRatio >= 50 && matchRatio == 0 && maxRatio > suggestionRatio) 101 | { 102 | (commandName, suggestion, suggestionRatio) = (userCommandName, matchName, maxRatio); 103 | } 104 | } 105 | 106 | return command != null; 107 | } 108 | 109 | private bool TryGetParameters(string text, CommandInfo command, string commandName, out List? parameters) 110 | { 111 | var userParameters = text 112 | .Split(' ') 113 | .Skip(commandName.Count(c => c == ' ') + 1) 114 | .Select(p => (object)p) 115 | .ToList(); 116 | 117 | if (userParameters.Count < command.Parameters.Count(p => !p.HasDefaultValue)) 118 | { 119 | parameters = null!; 120 | return false; 121 | } 122 | 123 | if (userParameters.Count > command.Parameters.Count) 124 | { 125 | // Remove extra parameters 126 | userParameters = userParameters.SkipLast(userParameters.Count - command.Parameters.Count).ToList(); 127 | } 128 | else if (command.Parameters.Count > userParameters.Count) 129 | { 130 | // Add default parameters 131 | command.Parameters.Skip(userParameters.Count).ForEach(p => userParameters.Add(p.DefaultValue!)); 132 | } 133 | 134 | parameters = userParameters; 135 | return true; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/FORCE.Core/Plugin/Models/ClassInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace FORCE.Core.Plugin.Models; 4 | 5 | internal class ClassInfo 6 | { 7 | public ClassInfo(Type type) 8 | { 9 | Type = type; 10 | } 11 | 12 | public Type Type { get; } 13 | 14 | private object? _instance; 15 | public bool Instanced => _instance != null; 16 | public object GetInstance() => _instance ??= Activator.CreateInstance(Type)!; 17 | public T GetInstance() => ((T)GetInstance())!; 18 | 19 | private const BindingFlags pmBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; 20 | 21 | public IEnumerable GetPersistentMembers() 22 | { 23 | var instance = GetInstance(); 24 | 25 | var members = instance.GetType().GetFields(pmBindingFlags).Cast() 26 | .Concat(instance.GetType().GetProperties(pmBindingFlags)); 27 | 28 | foreach (var member in members.Where(m => m.GetCustomAttribute() != null)) 29 | { 30 | yield return new PersistentMember(member, instance); 31 | } 32 | } 33 | 34 | public void SetPersistentMembers(IEnumerable persistentMembers) 35 | { 36 | var instance = GetInstance(); 37 | 38 | foreach (var pm in persistentMembers) 39 | { 40 | if (pm.MemberType == MemberTypes.Field) 41 | instance.GetType().GetField(pm.Name, pmBindingFlags)?.SetValue(instance, pm.Value); 42 | else if (pm.MemberType == MemberTypes.Property) 43 | instance.GetType().GetProperty(pm.Name, pmBindingFlags)?.SetValue(instance, pm.Value); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/FORCE.Core/Plugin/Models/CommandGroupInfo.cs: -------------------------------------------------------------------------------- 1 | using FORCE.Core.Shared; 2 | 3 | namespace FORCE.Core.Plugin.Models; 4 | 5 | internal class CommandGroupInfo : ICommandGroupAttribute, ISummaryAttribute, IRequireRoleAttribute 6 | { 7 | public string[] Prefixes { get; set; } = null!; 8 | public string? Summary { get; set; } 9 | public PlayerRole? RequiredRole { get; set; } 10 | public bool HideIfUnauthorized { get; set; } 11 | public ClassInfo Class { get; set; } = null!; 12 | 13 | public bool Disabled { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /src/FORCE.Core/Plugin/Models/CommandInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Text; 3 | using FORCE.Core.Shared; 4 | 5 | namespace FORCE.Core.Plugin.Models; 6 | 7 | internal class CommandInfo : ICommandAttribute, ISummaryAttribute, IRequireRoleAttribute 8 | { 9 | public string[] Names { get; set; } = null!; 10 | public string? Summary { get; set; } 11 | public PlayerRole? RequiredRole { get; set; } 12 | public bool HideIfUnauthorized { get; set; } 13 | public CommandGroupInfo? Group { get; set; } 14 | public bool IsInGroup => Group != null; 15 | public List Parameters { get; set; } = null!; 16 | public PluginInfo Plugin { get; set; } = null!; 17 | public ClassInfo Class { get; set; } = null!; 18 | public MethodInfo Method { get; set; } = null!; 19 | 20 | private bool _disabled; 21 | public bool Disabled 22 | { 23 | get => _disabled || (IsInGroup && Group!.Disabled); 24 | set => _disabled = value; 25 | } 26 | 27 | public override string ToString() 28 | { 29 | var commandBuilder = new StringBuilder(); 30 | 31 | commandBuilder.Append('/'); 32 | 33 | if (IsInGroup) 34 | { 35 | commandBuilder.Append(Group!.Prefixes.First()); 36 | commandBuilder.Append(' '); 37 | } 38 | 39 | commandBuilder.Append(Names.First()); 40 | 41 | foreach (var parameter in Parameters) 42 | { 43 | commandBuilder.Append(' '); 44 | commandBuilder.Append(parameter.HasDefaultValue ? '[' : '<'); 45 | commandBuilder.Append(parameter.UsageName ?? parameter.Name); 46 | 47 | if (parameter.HasDefaultValue && parameter.DefaultValue is not null) 48 | { 49 | commandBuilder.Append('='); 50 | 51 | if (parameter.DefaultValue is string) 52 | { 53 | commandBuilder.Append('"'); 54 | commandBuilder.Append(parameter.DefaultValue); 55 | commandBuilder.Append('"'); 56 | } 57 | else 58 | { 59 | commandBuilder.Append(parameter.DefaultValue); 60 | } 61 | } 62 | else if (parameter.IsRemainder) 63 | { 64 | commandBuilder.Append("..."); 65 | } 66 | 67 | commandBuilder.Append(parameter.HasDefaultValue ? ']' : '>'); 68 | } 69 | 70 | return commandBuilder.ToString(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/FORCE.Core/Plugin/Models/CommandParameterInfo.cs: -------------------------------------------------------------------------------- 1 | namespace FORCE.Core.Plugin.Models; 2 | 3 | internal class CommandParameterInfo : IUsageAttribute, ISummaryAttribute, IRemainderAttribute 4 | { 5 | public Type Type { get; set; } = null!; 6 | public string Name { get; set; } = null!; 7 | public object? DefaultValue { get; set; } 8 | public bool HasDefaultValue { get; set; } 9 | public string? UsageName { get; set; } 10 | public string? Summary { get; set; } 11 | public bool IsRemainder { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /src/FORCE.Core/Plugin/Models/PersistentMember.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace FORCE.Core.Plugin.Models; 4 | 5 | public class PersistentMember 6 | { 7 | public PersistentMember(MemberInfo member, object instance) 8 | { 9 | MemberType = member.MemberType; 10 | 11 | Name = member.Name; 12 | 13 | Value = MemberType switch 14 | { 15 | MemberTypes.Field => ((FieldInfo)member).GetValue(instance), 16 | MemberTypes.Property => ((PropertyInfo)member).GetValue(instance), 17 | _ => null! // Unreachable, considering the PersistentAttribute can only be used on Fields and Properties 18 | }; 19 | } 20 | 21 | public MemberTypes MemberType { get; } 22 | public string Name { get; } 23 | public object? Value { get; } 24 | } 25 | -------------------------------------------------------------------------------- /src/FORCE.Core/Plugin/Models/PluginInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.Loader; 3 | 4 | namespace FORCE.Core.Plugin.Models; 5 | 6 | internal class PluginInfo : PluginDisplayInfo 7 | { 8 | public List Commands { get; set; } = null!; 9 | public ClassInfo Class { get; set; } = null!; 10 | public AssemblyLoadContext AssemblyLoadContext { get; set; } = null!; 11 | public Assembly Assembly => AssemblyLoadContext.Assemblies.Single(); 12 | 13 | public IEnumerable GetEnabledCommands() 14 | => Commands.Where(c => !c.Disabled); 15 | 16 | public void SetContext(ContextBase context) 17 | { 18 | var pluginInstance = Class.GetInstance(); 19 | 20 | pluginInstance.Plugin = context.Plugin; 21 | pluginInstance.Server = context.Server; 22 | pluginInstance.ColorScheme = context.ColorScheme; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/FORCE.Core/Plugin/PluginManager.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Loader; 2 | using FORCE.Core.Plugin.Builders; 3 | using FORCE.Core.Plugin.Models; 4 | 5 | namespace FORCE.Core.Plugin; 6 | 7 | internal class PluginManager 8 | { 9 | public event Action? OnPluginLoaded; 10 | public event Action? OnPluginUnloaded; 11 | 12 | private readonly Force _force; 13 | private readonly List _plugins; 14 | 15 | public PluginManager(Force force) 16 | { 17 | _force = force; 18 | _plugins = new List(); 19 | } 20 | 21 | public List GetLoadedPlugins() 22 | => _plugins; 23 | 24 | public void LoadPlugin(PluginInfo plugin, bool reload = false) 25 | { 26 | _plugins.Add(plugin); 27 | 28 | plugin.Class.GetInstance().OnPluginLoadAsync(reload); 29 | 30 | OnPluginLoaded?.Invoke(plugin); 31 | } 32 | 33 | public bool UnloadPlugin(PluginInfo plugin, bool reload = false) 34 | { 35 | if (!_plugins.Remove(plugin)) 36 | return false; 37 | 38 | plugin.AssemblyLoadContext.Unload(); 39 | plugin.Class.GetInstance().OnPluginUnloadAsync(reload); 40 | 41 | // TODO: Remove subscribed event handlers 42 | // Only after OnPluginUnload, to make sure the plugin can not register any new event 43 | 44 | OnPluginUnloaded?.Invoke(plugin); 45 | 46 | return true; 47 | } 48 | 49 | public bool ReloadPlugin(PluginInfo plugin) 50 | { 51 | if (!UnloadPlugin(plugin, true)) 52 | return false; 53 | 54 | if (!TryBuildPluginFromAssemblyPath(plugin.Assembly.Location, out var reloadedPlugin)) 55 | return false; 56 | 57 | LoadPersistentMembers(plugin, reloadedPlugin); 58 | 59 | LoadPlugin(reloadedPlugin, true); 60 | return true; 61 | } 62 | 63 | public bool TryBuildPluginFromAssemblyPath(string assemblyPath, out PluginInfo plugin) 64 | { 65 | var assemblyLoadContext = new AssemblyLoadContext(null, true); 66 | var assembly = assemblyLoadContext.LoadFromAssemblyPath(assemblyPath); 67 | var module = assembly.Modules.SingleOrDefault(PluginBuilder.IsValidPluginModule); 68 | 69 | if (module == null) 70 | { 71 | plugin = null!; 72 | return false; 73 | } 74 | 75 | var pluginBuilder = new PluginBuilder(module, _force); 76 | plugin = pluginBuilder.Build(); 77 | 78 | plugin.AssemblyLoadContext = assemblyLoadContext; 79 | 80 | return true; 81 | } 82 | 83 | private void LoadPersistentMembers(PluginInfo unloadedPlugin, PluginInfo reloadedPlugin) 84 | { 85 | var oldPersistentMembers = unloadedPlugin.GetEnabledCommands() 86 | .Select(c => c.Class) 87 | .Append(unloadedPlugin.Class) 88 | .Distinct() 89 | .Where(c => c.Instanced) 90 | .ToDictionary(c => c.Type.FullName!, c => c.GetPersistentMembers()); 91 | 92 | foreach (var commandClass in reloadedPlugin.GetEnabledCommands().Select(c => c.Class).Append(reloadedPlugin.Class).Distinct()) 93 | { 94 | if (oldPersistentMembers.TryGetValue(commandClass.Type.FullName!, out var persistentMembers)) 95 | { 96 | commandClass.SetPersistentMembers(persistentMembers); 97 | } 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/FORCE/FORCE.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/FORCE/Program.cs: -------------------------------------------------------------------------------- 1 | using FORCE.Core; 2 | using GbxRemoteNet; 3 | 4 | namespace FORCE; 5 | 6 | internal static class Program 7 | { 8 | public static async Task Main() 9 | { 10 | var force = new Force(); 11 | 12 | if (!await ConnectAndAuthenticateAsync(force.Server)) 13 | return; 14 | 15 | Console.WriteLine(); 16 | await force.StartAsync(); 17 | 18 | await Task.Delay(-1); 19 | } 20 | 21 | private static async Task ConnectAndAuthenticateAsync(GbxRemoteClient server) 22 | { 23 | Console.WriteLine("Connecting..."); 24 | 25 | if (!await server.ConnectAsync()) 26 | { 27 | Console.WriteLine("Could not establish connection to the server."); 28 | return false; 29 | } 30 | 31 | Console.WriteLine("Authenticating..."); 32 | 33 | try 34 | { 35 | await server.AuthenticateAsync("SuperAdmin", "SuperAdmin"); 36 | } 37 | catch (Exception ex) 38 | { 39 | Console.WriteLine($"Could not authenticate to the server: {ex.Message}"); 40 | return false; 41 | } 42 | 43 | Console.WriteLine("Successfully connected and authenticated!"); 44 | return true; 45 | } 46 | } 47 | --------------------------------------------------------------------------------