mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-10 12:50:27 +01:00
Implement ability to change text via Chat instead of AnvilGUI (#97).
It was necessary as Anvil has limited char input, while chat is almost unlimited.
This commit is contained in:
parent
507c68d683
commit
a41859459f
@ -7,6 +7,7 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.wesjd.anvilgui.AnvilGUI;
|
||||
import world.bentobox.bentobox.api.panels.PanelItem;
|
||||
@ -116,6 +117,10 @@ public class EditChallengeGUI extends CommonGUI
|
||||
|
||||
panelBuilder.item(44, this.returnButton);
|
||||
|
||||
// Every time when this GUI is build, save challenge
|
||||
// This will ensure that all main things will be always stored
|
||||
this.addon.getChallengesManager().saveChallenge(this.challenge);
|
||||
|
||||
panelBuilder.build();
|
||||
}
|
||||
|
||||
@ -917,13 +922,13 @@ public class EditChallengeGUI extends CommonGUI
|
||||
|
||||
icon = new ItemStack(Material.WRITTEN_BOOK);
|
||||
clickHandler = (panel, user, clickType, slot) -> {
|
||||
new AnvilGUI(this.addon.getPlugin(),
|
||||
this.user.getPlayer(),
|
||||
this.challenge.getRewardText(),
|
||||
(player, reply) -> {
|
||||
this.challenge.setRewardText(reply);
|
||||
new StringListGUI(this.user, this.challenge.getRewardText(), lineLength, (status, value) -> {
|
||||
if (status)
|
||||
{
|
||||
this.challenge.setRewardText(value.stream().map(s -> s + "|").collect(Collectors.joining()));
|
||||
}
|
||||
|
||||
this.build();
|
||||
return reply;
|
||||
});
|
||||
|
||||
return true;
|
||||
@ -1114,13 +1119,13 @@ public class EditChallengeGUI extends CommonGUI
|
||||
|
||||
icon = new ItemStack(Material.WRITTEN_BOOK);
|
||||
clickHandler = (panel, user, clickType, slot) -> {
|
||||
new AnvilGUI(this.addon.getPlugin(),
|
||||
this.user.getPlayer(),
|
||||
this.challenge.getRepeatRewardText(),
|
||||
(player, reply) -> {
|
||||
this.challenge.setRepeatRewardText(reply);
|
||||
new StringListGUI(this.user, this.challenge.getRepeatRewardText(), lineLength, (status, value) -> {
|
||||
if (status)
|
||||
{
|
||||
this.challenge.setRepeatRewardText(value.stream().map(s -> s + "|").collect(Collectors.joining()));
|
||||
}
|
||||
|
||||
this.build();
|
||||
return reply;
|
||||
});
|
||||
|
||||
return true;
|
||||
|
@ -103,6 +103,10 @@ public class EditLevelGUI extends CommonGUI
|
||||
|
||||
panelBuilder.item(44, this.returnButton);
|
||||
|
||||
// Save challenge level every time this gui is build.
|
||||
// It will ensure that changes are stored in database.
|
||||
this.addon.getChallengesManager().saveLevel(this.challengeLevel);
|
||||
|
||||
panelBuilder.build();
|
||||
}
|
||||
|
||||
@ -422,14 +426,15 @@ public class EditLevelGUI extends CommonGUI
|
||||
"[value]", "|" + this.challengeLevel.getUnlockMessage()));
|
||||
icon = new ItemStack(Material.WRITABLE_BOOK);
|
||||
clickHandler = (panel, user, clickType, slot) -> {
|
||||
new AnvilGUI(this.addon.getPlugin(),
|
||||
this.user.getPlayer(),
|
||||
this.challengeLevel.getUnlockMessage(),
|
||||
(player, reply) -> {
|
||||
this.challengeLevel.setUnlockMessage(reply);
|
||||
new StringListGUI(this.user, this.challengeLevel.getUnlockMessage(), lineLength, (status, value) -> {
|
||||
if (status)
|
||||
{
|
||||
this.challengeLevel.setUnlockMessage(value.stream().map(s -> s + "|").collect(Collectors.joining()));
|
||||
}
|
||||
|
||||
this.build();
|
||||
return reply;
|
||||
});
|
||||
|
||||
return true;
|
||||
};
|
||||
glow = false;
|
||||
@ -492,14 +497,15 @@ public class EditLevelGUI extends CommonGUI
|
||||
"[value]", "|" + this.challengeLevel.getRewardText()));
|
||||
icon = new ItemStack(Material.WRITTEN_BOOK);
|
||||
clickHandler = (panel, user, clickType, slot) -> {
|
||||
new AnvilGUI(this.addon.getPlugin(),
|
||||
this.user.getPlayer(),
|
||||
this.challengeLevel.getRewardText(),
|
||||
(player, reply) -> {
|
||||
this.challengeLevel.setRewardText(reply);
|
||||
new StringListGUI(this.user, this.challengeLevel.getRewardText(), lineLength, (status, value) -> {
|
||||
if (status)
|
||||
{
|
||||
this.challengeLevel.setRewardText(value.stream().map(s -> s + "|").collect(Collectors.joining()));
|
||||
}
|
||||
|
||||
this.build();
|
||||
return reply;
|
||||
});
|
||||
|
||||
return true;
|
||||
};
|
||||
glow = false;
|
||||
|
@ -30,6 +30,12 @@ import world.bentobox.challenges.utils.GuiUtils;
|
||||
*/
|
||||
public class StringListGUI
|
||||
{
|
||||
public StringListGUI(User user, String value, int lineLength, BiConsumer<Boolean, List<String>> consumer)
|
||||
{
|
||||
this(user, Collections.singleton(value), lineLength, consumer);
|
||||
}
|
||||
|
||||
|
||||
public StringListGUI(User user, Collection<String> value, int lineLength, BiConsumer<Boolean, List<String>> consumer)
|
||||
{
|
||||
this(user, new ArrayList<>(value), lineLength, consumer);
|
||||
|
Loading…
Reference in New Issue
Block a user