55 lines
2.0 KiB
Java
55 lines
2.0 KiB
Java
package world.bentobox.bentobox.blueprints.conversation;
|
|
|
|
import java.util.List;
|
|
|
|
import org.bukkit.conversations.ConversationContext;
|
|
import org.bukkit.conversations.MessagePrompt;
|
|
import org.bukkit.conversations.Prompt;
|
|
import org.bukkit.entity.Player;
|
|
import org.eclipse.jdt.annotation.NonNull;
|
|
|
|
import world.bentobox.bentobox.BentoBox;
|
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
|
import world.bentobox.bentobox.api.user.User;
|
|
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBundle;
|
|
import world.bentobox.bentobox.panels.BlueprintManagementPanel;
|
|
|
|
public class DescriptionSuccessPrompt extends MessagePrompt {
|
|
|
|
private final GameModeAddon addon;
|
|
private final BlueprintBundle bb;
|
|
|
|
/**
|
|
* @param addon game mode addon
|
|
* @param bb blueprint bundle
|
|
*/
|
|
public DescriptionSuccessPrompt(GameModeAddon addon, BlueprintBundle bb) {
|
|
this.addon = addon;
|
|
this.bb = bb;
|
|
}
|
|
|
|
@Override
|
|
public @NonNull String getPromptText(ConversationContext context) {
|
|
User user = User.getInstance((Player)context.getForWhom());
|
|
@SuppressWarnings("unchecked")
|
|
List<String> description = (List<String>)context.getSessionData("description");
|
|
if (description != null) {
|
|
bb.setDescription(description);
|
|
BentoBox.getInstance().getBlueprintsManager().addBlueprintBundle(addon, bb);
|
|
BentoBox.getInstance().getBlueprintsManager().saveBlueprintBundle(addon, bb);
|
|
new BlueprintManagementPanel(BentoBox.getInstance(), user, addon).openBB(bb);
|
|
// Set the name
|
|
// if successfully
|
|
return user.getTranslation("commands.admin.blueprint.management.description.success");
|
|
} else {
|
|
return user.getTranslation("commands.admin.blueprint.management.description.cancelling");
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected Prompt getNextPrompt(@NonNull ConversationContext context) {
|
|
return Prompt.END_OF_CONVERSATION;
|
|
}
|
|
|
|
}
|