This commit is contained in:
Sebastian Moser
2025-04-22 22:59:04 +02:00
parent 12fcb7050a
commit a4e3c42595
21 changed files with 544 additions and 59 deletions

View File

@@ -12,8 +12,8 @@ stdenv.mkDerivation rec {
src = fetchFromGitHub {
owner = "resurrecting-open-source-projects";
repo = "cbm";
rev = "master";
sha256 = "sha256-Ubm8jky8nbJZWVSlqipg22ZjlnsgdVmoQWxYi9cyags=";
rev = "b6bc84bd9702d711466348a7af5c25d4c4f0bbf5";
sha256 = "sha256-rL9ttGK4CIPFHXmNBgVq1QzLkMDGtgF+1eoCH1bwvG0=";
};
nativeBuildInputs = [

View File

@@ -0,0 +1,27 @@
{ lib
, python3Packages
}:
python3Packages.buildPythonApplication {
pname = "minecraft-server-whitelist-all-players";
version = "1.0";
pyproject = false;
propagatedBuildInputs = with python3Packages; [ requests ];
dontUnpack = true;
src = ./.;
meta = with lib; {
description = "A small python script to generate a whitelist.json from all players that ever joined the server.";
longDescription = ''
A small python script to generate a whitelist.json from the playerdata directory of a minecraft server. It adds all players that were ever on the server to this generated whitelist.json file.
You need to specify the playerdata directory containing all the players .dat files as the first argument to the script.
'';
homepage = "https://github.com/c2vi/nixos/tree/master/mods/nurPkgs";
license = licenses.gpl2Only;
#maintainers = [ ];
platforms = platforms.all;
};
}

View File

@@ -0,0 +1,55 @@
#!/usr/bin/env python3
import requests
import json
import argparse
import os
whiteListJson = []
parser = argparse.ArgumentParser(
prog='whitelist-all-players',
description='A small python script, which reads all .dat files in the playerdataDir and generates a whitelist.json in that directory.',
epilog='')
parser.add_argument('playerdataDir', default=os.getcwd(), nargs='?', help='the playerdataDir (in the folder of your minecraft server the path ./world/playerdata). This will be enumerated to get a list of player uuids. The default is the current workdin directory.')
args = parser.parse_args()
print("playerdataDir:", args.playerdataDir)
x = os.listdir(args.playerdataDir)
for i in x:
if i.endswith(".dat"):
#creating a blank set
whiteListEntry = {"uuid":"", "name":""}
#creating UUID string without the .dat extension
usrUUID = i[:-4]
print("processing uuid:", usrUUID)
#adding player UUID to entry
whiteListEntry["uuid"] = usrUUID
#taking the dashes out of the UUID to work with the API
trimmedUUID = usrUUID.replace("-", "")
#getting API response
response = requests.get(f"https://api.minecraftservices.com/minecraft/profile/lookup/" + trimmedUUID).json()
#adding player's current username to entry
try:
whiteListEntry["name"] = response["name"]
except:
print("uuid has no name...")
print(response)
continue
print("found name:", whiteListEntry["name"])
#adding entry to master JSON file
whiteListJson.append(whiteListEntry)
#creating a whitelist.json file
f = open("whitelist.json", 'w')
#converting master json to pretty print and then writing it to the file
f.write(json.dumps(whiteListJson, indent = 2, sort_keys=True))
#closing file
f.close()

View File

@@ -5,16 +5,16 @@
rustPlatform.buildRustPackage rec {
pname = "vcs-cli-utils";
version = "0.3.2";
version = "1.0.4";
src = fetchFromGitHub {
owner = "henkelmax";
repo = "svc-cli-utils";
rev = "82e0af5b5e4cb0aa60bfeea4f9b1d3929fe4e1f8";
sha256 = "sha256-ojuRqtUTNz/ZOuxx3ab1y9NknEfJNWPMXBf3kfIwfXM=";
rev = "${version}";
sha256 = "sha256-vRqYQd5OaYXAc74Jlg8twBGDr9YxP+Mk1ZY9JGJTmvc=";
};
cargoHash = "sha256-VvA7xlj7zcuHDNi4+TRSDheCchjpiK519OgNTJj2hPI=";
cargoHash = "sha256-xz+pi6awwDeiISGqJs5DxqFdryc5mY8wMuds1ZXRr1Q=";
meta = with lib; {
description = "Command line utilities for the Simple Voice Chat Minecraft Mod";