CompleteTaskSetCommand class
Пакет: com.hypixel.hytale.builtin.adventure.objectives.commands
Файл: com/hypixel/hytale/builtin/adventure/objectives/commands/ObjectiveCompleteCommand.java
extends: AbstractPlayerCommand
Поля (4)
| Модификаторы | Тип | Имя |
|---|---|---|
|
private final RequiredArg<String> |
objectiveArg |
|
String |
var6 |
|
Objective |
var7 |
|
ObjectiveTask[] |
var8 |
Методы (5)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
protected void |
executeprotected void execute(@Nonnull CommandContext var1, @Nonnull Store<EntityStore> var2, @Nonnull Ref<EntityStore> var3, @Nonnull PlayerRef var4, @Nonnull World var5) |
|
|
for for(ObjectiveTask var12 : var8) |
|
|
if if(var7 == null) |
|
|
if if(var8 != null && var8.length != 0) |
abstract |
|
super super("taskSet", "server.commands.objective.complete.taskSet") |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.adventure.objectives.commands;
class="kw">import com.hypixel.hytale.builtin.adventure.objectives.Objective;
class="kw">import com.hypixel.hytale.builtin.adventure.objectives.ObjectiveDataStore;
class="kw">import com.hypixel.hytale.builtin.adventure.objectives.ObjectivePlugin;
class="kw">import com.hypixel.hytale.builtin.adventure.objectives.task.ObjectiveTask;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.command.system.CommandContext;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.AbstractCommandCollection;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
class="kw">import com.hypixel.hytale.server.core.entity.entities.Player;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import java.util.Set;
class="kw">import java.util.UUID;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class ObjectiveCompleteCommand class="kw">extends AbstractCommandCollection {
@Nonnull
class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_OBJECTIVE_OBJECTIVE_NOT_FOUND = Message.translation("server.commands.objective.objectiveNotFound");
@Nonnull
class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_OBJECTIVE_NO_TASK_FOR_INDEX = Message.translation("server.commands.objective.noTaskForIndex");
@Nonnull
class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_OBJECTIVE_TASK_ALREADY_COMPLETED = Message.translation("server.commands.objective.taskAlreadyCompleted");
class="kw">public ObjectiveCompleteCommand() {
super("complete", "server.commands.objective.complete");
this.addSubCommand(new ObjectiveCompleteCommand.CompleteTaskCommand());
this.addSubCommand(new ObjectiveCompleteCommand.CompleteTaskSetCommand());
this.addSubCommand(new ObjectiveCompleteCommand.CompleteObjectiveCommand());
}
@Nullable
class="kw">private class="kw">static Objective getObjectiveFromId(@Nonnull Ref<EntityStore> var0, @Nonnull String var1, @Nonnull ComponentAccessor<EntityStore> var2) {
Player var3 = var2.getComponent(var0, Player.getComponentType());
if (var3 == null) {
class="kw">return null;
}
Set var4 = var3.getPlayerConfigData().getActiveObjectiveUUIDs();
ObjectiveDataStore var5 = ObjectivePlugin.get().getObjectiveDataStore();
for (UUID var7 : var4) {
Objective var8 = var5.getObjective(var7);
if (var8 != null && var8.getObjectiveId().equals(var1)) {
class="kw">return var8;
}
}
class="kw">return null;
}
class="kw">public class="kw">static class CompleteObjectiveCommand class="kw">extends AbstractPlayerCommand {
@Nonnull
class="kw">private class="kw">final RequiredArg<String> objectiveArg = this.withRequiredArg(
"objectiveId", "server.commands.objective.complete.objective.arg.objectiveId.desc", ArgTypes.STRING
);
class="kw">public CompleteObjectiveCommand() {
super("objective", "server.commands.objective.complete.objective");
}
@Override
class="kw">protected void execute(
@Nonnull CommandContext var1, @Nonnull Store<EntityStore> var2, @Nonnull Ref<EntityStore> var3, @Nonnull PlayerRef var4, @Nonnull World var5
) {
String var6 = this.objectiveArg.get(var1);
Objective var7 = ObjectiveCompleteCommand.getObjectiveFromId(var3, var6, var2);
if (var7 == null) {
var1.sendMessage(ObjectiveCompleteCommand.MESSAGE_COMMANDS_OBJECTIVE_OBJECTIVE_NOT_FOUND.param("id", var6));
} else {
ObjectiveTask[] var8 = var7.getCurrentTasks();
if (var8 == null) {
var1.sendMessage(ObjectiveCompleteCommand.MESSAGE_COMMANDS_OBJECTIVE_NO_TASK_FOR_INDEX);
} else {
for (ObjectiveTask var12 : var8) {
var12.completeTransactionRecords();
}
var7.complete(var2);
}
}
}
}
class="kw">public class="kw">static class CompleteTaskCommand class="kw">extends AbstractPlayerCommand {
@Nonnull
class="kw">private class="kw">final RequiredArg<String> objectiveArg = this.withRequiredArg(
"objectiveId", "server.commands.objective.complete.task.arg.objectiveId.desc", ArgTypes.STRING
);
@Nonnull
class="kw">private class="kw">final RequiredArg<Integer> taskIndexArg = this.withRequiredArg(
"taskIndex", "server.commands.objective.complete.task.arg.taskIndex.desc", ArgTypes.INTEGER
);
class="kw">public CompleteTaskCommand() {
super("task", "server.commands.objective.complete.task");
}
@Override
class="kw">protected void execute(
@Nonnull CommandContext var1, @Nonnull Store<EntityStore> var2, @Nonnull Ref<EntityStore> var3, @Nonnull PlayerRef var4, @Nonnull World var5
) {
String var6 = this.objectiveArg.get(var1);
int var7 = this.taskIndexArg.get(var1);
Objective var8 = ObjectiveCompleteCommand.getObjectiveFromId(var3, var6, var2);
if (var8 == null) {
var1.sendMessage(ObjectiveCompleteCommand.MESSAGE_COMMANDS_OBJECTIVE_OBJECTIVE_NOT_FOUND.param("id", var6));
} else {
ObjectiveTask[] var9 = var8.getCurrentTasks();
if (var7 >= var9.length) {
var1.sendMessage(ObjectiveCompleteCommand.MESSAGE_COMMANDS_OBJECTIVE_NO_TASK_FOR_INDEX);
} else if (var9[var7].isComplete()) {
var1.sendMessage(ObjectiveCompleteCommand.MESSAGE_COMMANDS_OBJECTIVE_TASK_ALREADY_COMPLETED);
} else {
var9[var7].complete(var8, var2);
var8.checkTaskSetCompletion(var2);
}
}
}
}
class="kw">public class="kw">static class CompleteTaskSetCommand class="kw">extends AbstractPlayerCommand {
@Nonnull
class="kw">private class="kw">final RequiredArg<String> objectiveArg = this.withRequiredArg(
"objectiveId", "server.commands.objective.complete.taskSet.arg.objectiveId.desc", ArgTypes.STRING
);
class="kw">public CompleteTaskSetCommand() {
super("taskSet", "server.commands.objective.complete.taskSet");
}
@Override
class="kw">protected void execute(
@Nonnull CommandContext var1, @Nonnull Store<EntityStore> var2, @Nonnull Ref<EntityStore> var3, @Nonnull PlayerRef var4, @Nonnull World var5
) {
String var6 = this.objectiveArg.get(var1);
Objective var7 = ObjectiveCompleteCommand.getObjectiveFromId(var3, var6, var2);
if (var7 == null) {
var1.sendMessage(ObjectiveCompleteCommand.MESSAGE_COMMANDS_OBJECTIVE_OBJECTIVE_NOT_FOUND.param("id", var6));
} else {
ObjectiveTask[] var8 = var7.getCurrentTasks();
if (var8 != null && var8.length != 0) {
for (ObjectiveTask var12 : var8) {
var12.complete(var7, var2);
}
var7.checkTaskSetCompletion(var2);
} else {
var1.sendMessage(ObjectiveCompleteCommand.MESSAGE_COMMANDS_OBJECTIVE_NO_TASK_FOR_INDEX);
}
}
}
}
}