Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
domialex committed Apr 27, 2021
0 parents commit b7b0a6e
Show file tree
Hide file tree
Showing 54 changed files with 2,575 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
open_collective: domialex
custom: ["https://paypal.me/domialex"]
54 changes: 54 additions & 0 deletions .github/GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatchTag
assembly-informational-format: '{Major}.{Minor}.{Patch}'
mode: ContinuousDelivery
increment: Inherit
continuous-delivery-fallback-tag: ci
tag-prefix: '[vV]'
major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
patch-version-bump-message: '\+semver:\s?(fix|patch)'
no-bump-message: '\+semver:\s?(none|skip)'
legacy-semver-padding: 4
build-metadata-padding: 4
commits-since-version-source-padding: 4
commit-message-incrementing: Enabled
commit-date-format: 'yyyy-MM-dd'
branches:
main:
regex: ^master$|^main$
mode: ContinuousDelivery
tag: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
tracks-release-branches: false
is-release-branch: false
feature:
regex: ^features?[/-]
mode: ContinuousDelivery
tag: beta
increment: Patch
prevent-increment-of-merged-branch-version: false
track-merge-target: false
tracks-release-branches: false
is-release-branch: false
pull-request:
regex: ^(pull|pull\-requests|pr)[/-]
mode: ContinuousDelivery
tag: pr
increment: Inherit
prevent-increment-of-merged-branch-version: false
tag-number-pattern: '[/-](?<number>\d+)[-/]'
track-merge-target: false
tracks-release-branches: false
is-release-branch: false
hotfix:
regex: ^hotfix(es)?[/-]
mode: ContinuousDelivery
tag: beta
increment: Patch
prevent-increment-of-merged-branch-version: false
track-merge-target: false
tracks-release-branches: false
is-release-branch: false
27 changes: 27 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
labels:
- 'chore'
- 'refactor'
- 'clean'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
template: |
## Changes
$CHANGES
## Contributors
$CONTRIBUTORS
83 changes: 83 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Release

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build:

runs-on: windows-latest

steps:

- name: 1 - Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: 2 - GitVersion - Install
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'

- name: 3 - GitVersion - Execute
id: gitversion
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
configFilePath: .github/GitVersion.yml
additionalArguments: '/updateprojectfiles'

- name: 4 - .NET - Setup
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x

- name: 5 - .Net - Restore
run: |
cd ./src
dotnet restore
- name: 6 - .Net - Publish
run: |
cd ./src
dotnet publish -r win-x64 -c Release --self-contained true -p:PublishSingleFile=true -p:DebugType=None -p:IsWebConfigTransformDisabled=true -p:PublishTrimmed=true -p:IncludeNativeLibrariesForSelfExtract=true
- name: 7 - Build Artifact
uses: actions/upload-artifact@v2
with:
name: Minecraft-Monitor-win-x64
path: ./src/bin/Release/net5.0/win-x64/publish

- name: 8 - Zip Artifact
uses: papeloto/action-zip@v1
with:
files: ./src/bin/Release/net5.0/win-x64/publish
dest: Minecraft-Monitor.zip

- name: 9 - Draft Release
if: github.ref == 'refs/heads/main'
uses: release-drafter/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: 'Release v${{ steps.gitversion.outputs.majorMinorPatch }}'
tag: v${{ steps.gitversion.outputs.majorMinorPatch }}
version: v${{ steps.gitversion.outputs.majorMinorPatch }}
publish: false
prerelease: false

- name: 10 - Upload Artifact to Release
if: github.ref == 'refs/heads/main'
uses: xresloader/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: Minecraft-Monitor.zip
tag_name: v${{ steps.gitversion.outputs.majorMinorPatch }}
draft: true
verbose: true
overwrite: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vscode/
bin/
obj/
*.db
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Dominique Alexandre

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<h1><img src="./docs/icon.png" valign="middle"> Minecraft Monitor</h1>

[![](https://img.shields.io/github/v/release/domialex/Minecraft-Monitor?style=flat-square)](https://github.com/domialex/Minecraft-Monitor/releases)
[![](https://img.shields.io/github/downloads/domialex/Minecraft-Monitor/total?style=flat-square)](https://github.com/domialex/Minecraft-Monitor/releases)

A simple **Minecraft** web map that shows the players' positions in real-time.

Works on **vanilla** or **modded** servers (1.13+).

| Real-time player positions | Player inventories (work in progress) |
| ---|---|
| ![](./docs/preview.png) | ![](./docs/inventory.png) |

**Minecraft Monitor** gathers the necessary data from a Minecraft server using an RCON connection and shows the players' positions on a map using an existing [Minecraft-Overviewer](http://docs.overviewer.org) configuration.

## Usage
1. Download and extract [**Minecraft Monitor**](https://github.com/domialex/Minecraft-Monitor/releases) somewhere.
2. Configure **appsettings.json** to change the default admin password and the URL you want to bind to your server.
3. Run **Minecraft Monitor.exe** and navigate to the dashboard: http://localhost:5000/dashboard (default url)

*Remember to configure your Minecraft server to accept RCON connections in the **server.properties** file:*
```ini
enable-rcon=true
rcon.port=25575
rcon.password=yourpassword
```

*For internet-facing installations, remember to forward your port to the server.*

*If you're on **Linux**, simply clone the repository, build and run with dotnet CLI.*

## Work in progress
- Add the player's inventories in the popup
- Wrap Overviewer completely for easier setup

## Thanks
- [Minecraft-Overviewer](https://github.com/overviewer/Minecraft-Overviewer)
- [MudBlazor](https://github.com/Garderoben/MudBlazor)
- [RconSharp.NetStandard](https://github.com/wgraham17/rconsharp)

## Support
If you want to show your appreciation, the sponsor button is at the top right of the page 😄.
Binary file added docs/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/inventory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@using Minecraft_Monitor.Pages

<CascadingAuthenticationState>

<Router AppAssembly="@typeof(Program).Assembly">

<Found Context="routeData">

<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">

<NotAuthorized>
<LoginForm />
</NotAuthorized>

</AuthorizeRouteView>

</Found>

<NotFound>
<Map />
</NotFound>

</Router>

</CascadingAuthenticationState>
70 changes: 70 additions & 0 deletions src/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace Minecraft_Monitor.Controllers
{
/// <summary>
/// https://github.com/dotnet/AspNetCore.Docs/issues/15919#issuecomment-581457534
/// </summary>
[Route("[controller]/[action]")]
public class AccountController : Controller
{
public static string SignInRoute = "/account/signin?t=";
public static string Purpose = "SignIn";
private readonly IDataProtector dataProtectionProvider;
private readonly UserManager<IdentityUser> userManager;
private readonly SignInManager<IdentityUser> signInManager;

public AccountController(IDataProtectionProvider dataProtectionProvider,
UserManager<IdentityUser> userManager,
SignInManager<IdentityUser> signInManager)
{
this.dataProtectionProvider = dataProtectionProvider.CreateProtector(Purpose);
this.userManager = userManager;
this.signInManager = signInManager;
}

[HttpGet]
public async Task<IActionResult> SignIn(string t)
{
if (string.IsNullOrWhiteSpace(t))
{
return BadRequest();
}

try
{
var data = dataProtectionProvider.Unprotect(t);
var parts = data.Split('|');
var identityUser = await userManager.FindByIdAsync(parts[0]);
var isTokenValid = await userManager.VerifyUserTokenAsync(identityUser, TokenOptions.DefaultProvider, Purpose, parts[1]);

if (isTokenValid)
{
await signInManager.SignInAsync(identityUser, true);

return Redirect("/dashboard");
}
}
catch
{

}

return Unauthorized();
}

[Authorize]
[HttpGet]
public new async Task<IActionResult> SignOut()
{
await signInManager.SignOutAsync();

return Redirect("/");
}
}
}
44 changes: 44 additions & 0 deletions src/Controllers/PlayersController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Minecraft_Monitor.Models;
using System.Collections.Generic;
using System.Threading.Tasks;
using System;

namespace Minecraft_Monitor.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class PlayersController : ControllerBase
{
private readonly MinecraftMonitorContext minecraftMonitorContext;
public PlayersController(MinecraftMonitorContext minecraftMonitorContext)
{
this.minecraftMonitorContext = minecraftMonitorContext;
}

[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult<IList<Player>>> GetAllAsync()
{
var players = await minecraftMonitorContext.Players.ToListAsync();

return players;
}

[HttpGet("{id}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<Player>> GetByIdAsync(Guid id)
{
var player = await minecraftMonitorContext.Players.FindAsync(id);
if (player == null)
{
return NotFound();
}

return player;
}
}
}
Loading

0 comments on commit b7b0a6e

Please sign in to comment.