Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set player UUID in config of private server request #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void execute(CommandContext args, CommandSource sender) {
}

player.sendMessage(Messages.colour(NamedTextColor.GOLD, "Requesting private server..."));
if (!requester.request(player.getUsername()))
if (!requester.request(player))
player.sendMessage(Messages.colour(NamedTextColor.RED, "An error occured while requesting your private server!"));

return;
Expand All @@ -96,7 +96,7 @@ public void execute(CommandContext args, CommandSource sender) {
}

sender.sendMessage(Messages.colour(NamedTextColor.GOLD, "Requesting private server for " + target.getUsername() + "..."));
if (!requester.request(target.getUsername()))
if (!requester.request(target))
sender.sendMessage(Messages.colour(NamedTextColor.RED, "An error occured while requesting a private server!"));

return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ private Map<String, Object> generateTemplate() {
return null;
}

public boolean request(String name) {
public boolean request(Player player) {
try {
KubernetesClient client = new DefaultKubernetesClient();

CustomResourceDefinitionContext context = new CustomResourceDefinitionContext.Builder().withName("helmcharts.helm.cattle.io").withGroup("helm.cattle.io").withScope("Namespaced").withVersion("v1").withPlural("helmcharts").build();

String name = player.getUsername();
String uuid = player.getUniqueId().toString();

Map<String, Object> template = generateTemplate();
JSONObject helmChartJSONObject = new JSONObject(template);

Expand All @@ -65,6 +68,7 @@ public boolean request(String name) {
metadata.put("name", "private-" + name.toLowerCase().replaceAll("_", "-") + "-server");
setValues.put("config.serverName", name);
setValues.put("config.operators", name);
setValues.put("config.operatorsUuids", uuid);

client.customResource(context).create("minecraft", helmChartJSONObject.toString());
client.close();
Expand Down