Backup Context now can get MinecraftServer for ServerCommandContext

2.x-1.16
szymon 2020-08-11 09:41:46 +02:00
parent a93e87729b
commit 1ea2dc2969
2 changed files with 8 additions and 6 deletions

View File

@ -41,7 +41,6 @@ public class StartBackupCommand {
BackupHelper.create( BackupHelper.create(
new BackupContext.Builder() new BackupContext.Builder()
.setCommandSource(ctx.getSource()) .setCommandSource(ctx.getSource())
.setServer(ctx.getSource().getMinecraftServer())
.setComment(StringArgumentType.getString(ctx, "comment")) .setComment(StringArgumentType.getString(ctx, "comment"))
.guessInitiator() .guessInitiator()
.setSave() .setSave()
@ -58,7 +57,6 @@ public class StartBackupCommand {
BackupHelper.create( BackupHelper.create(
new BackupContext.Builder() new BackupContext.Builder()
.setCommandSource(source) .setCommandSource(source)
.setServer(source.getMinecraftServer())
.guessInitiator() .guessInitiator()
.setSave() .setSave()
.build() .build()

View File

@ -29,7 +29,7 @@ public class BackupContext {
private final boolean save; private final boolean save;
private final String comment; private final String comment;
protected BackupContext(@NotNull MinecraftServer server, ServerCommandSource commandSource, @NotNull BackupInitiator initiator, boolean save, String comment) { protected BackupContext(@NotNull MinecraftServer server, ServerCommandSource commandSource, @NotNull BackupInitiator initiator, boolean save, String comment) {
this.server = server; this.server = server;
this.commandSource = commandSource; this.commandSource = commandSource;
this.initiator = initiator; this.initiator = initiator;
@ -117,8 +117,12 @@ public class BackupContext {
initiator = BackupInitiator.Null; initiator = BackupInitiator.Null;
} }
if(server == null) if(server == null) {
setServer(commandSource.getMinecraftServer()); if(commandSource != null)
setServer(commandSource.getMinecraftServer());
else
throw new RuntimeException("Both MinecraftServer and ServerCommandSource weren't provided!");
}
return new BackupContext(server, commandSource, initiator, save, comment); return new BackupContext(server, commandSource, initiator, save, comment);
} }
@ -129,7 +133,7 @@ public class BackupContext {
ServerConsole ("Server Console", "from"), ServerConsole ("Server Console", "from"),
Timer ("Timer", "by"), Timer ("Timer", "by"),
Shutdown ("Server Shutdown", "by"), Shutdown ("Server Shutdown", "by"),
Restore ("Backup Restore", "by"), Restore ("Backup Restoration", "because of"),
Null ("Null (That shouldn't have happened)", "form"); Null ("Null (That shouldn't have happened)", "form");
private final String name; private final String name;