mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2025-01-19 06:32:41 +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.entity.EntityType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import net.wesjd.anvilgui.AnvilGUI;
|
import net.wesjd.anvilgui.AnvilGUI;
|
||||||
import world.bentobox.bentobox.api.panels.PanelItem;
|
import world.bentobox.bentobox.api.panels.PanelItem;
|
||||||
@ -116,6 +117,10 @@ public class EditChallengeGUI extends CommonGUI
|
|||||||
|
|
||||||
panelBuilder.item(44, this.returnButton);
|
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();
|
panelBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -917,14 +922,14 @@ public class EditChallengeGUI extends CommonGUI
|
|||||||
|
|
||||||
icon = new ItemStack(Material.WRITTEN_BOOK);
|
icon = new ItemStack(Material.WRITTEN_BOOK);
|
||||||
clickHandler = (panel, user, clickType, slot) -> {
|
clickHandler = (panel, user, clickType, slot) -> {
|
||||||
new AnvilGUI(this.addon.getPlugin(),
|
new StringListGUI(this.user, this.challenge.getRewardText(), lineLength, (status, value) -> {
|
||||||
this.user.getPlayer(),
|
if (status)
|
||||||
this.challenge.getRewardText(),
|
{
|
||||||
(player, reply) -> {
|
this.challenge.setRewardText(value.stream().map(s -> s + "|").collect(Collectors.joining()));
|
||||||
this.challenge.setRewardText(reply);
|
}
|
||||||
this.build();
|
|
||||||
return reply;
|
this.build();
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@ -1114,14 +1119,14 @@ public class EditChallengeGUI extends CommonGUI
|
|||||||
|
|
||||||
icon = new ItemStack(Material.WRITTEN_BOOK);
|
icon = new ItemStack(Material.WRITTEN_BOOK);
|
||||||
clickHandler = (panel, user, clickType, slot) -> {
|
clickHandler = (panel, user, clickType, slot) -> {
|
||||||
new AnvilGUI(this.addon.getPlugin(),
|
new StringListGUI(this.user, this.challenge.getRepeatRewardText(), lineLength, (status, value) -> {
|
||||||
this.user.getPlayer(),
|
if (status)
|
||||||
this.challenge.getRepeatRewardText(),
|
{
|
||||||
(player, reply) -> {
|
this.challenge.setRepeatRewardText(value.stream().map(s -> s + "|").collect(Collectors.joining()));
|
||||||
this.challenge.setRepeatRewardText(reply);
|
}
|
||||||
this.build();
|
|
||||||
return reply;
|
this.build();
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
@ -103,6 +103,10 @@ public class EditLevelGUI extends CommonGUI
|
|||||||
|
|
||||||
panelBuilder.item(44, this.returnButton);
|
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();
|
panelBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,14 +426,15 @@ public class EditLevelGUI extends CommonGUI
|
|||||||
"[value]", "|" + this.challengeLevel.getUnlockMessage()));
|
"[value]", "|" + this.challengeLevel.getUnlockMessage()));
|
||||||
icon = new ItemStack(Material.WRITABLE_BOOK);
|
icon = new ItemStack(Material.WRITABLE_BOOK);
|
||||||
clickHandler = (panel, user, clickType, slot) -> {
|
clickHandler = (panel, user, clickType, slot) -> {
|
||||||
new AnvilGUI(this.addon.getPlugin(),
|
new StringListGUI(this.user, this.challengeLevel.getUnlockMessage(), lineLength, (status, value) -> {
|
||||||
this.user.getPlayer(),
|
if (status)
|
||||||
this.challengeLevel.getUnlockMessage(),
|
{
|
||||||
(player, reply) -> {
|
this.challengeLevel.setUnlockMessage(value.stream().map(s -> s + "|").collect(Collectors.joining()));
|
||||||
this.challengeLevel.setUnlockMessage(reply);
|
}
|
||||||
this.build();
|
|
||||||
return reply;
|
this.build();
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
glow = false;
|
glow = false;
|
||||||
@ -492,14 +497,15 @@ public class EditLevelGUI extends CommonGUI
|
|||||||
"[value]", "|" + this.challengeLevel.getRewardText()));
|
"[value]", "|" + this.challengeLevel.getRewardText()));
|
||||||
icon = new ItemStack(Material.WRITTEN_BOOK);
|
icon = new ItemStack(Material.WRITTEN_BOOK);
|
||||||
clickHandler = (panel, user, clickType, slot) -> {
|
clickHandler = (panel, user, clickType, slot) -> {
|
||||||
new AnvilGUI(this.addon.getPlugin(),
|
new StringListGUI(this.user, this.challengeLevel.getRewardText(), lineLength, (status, value) -> {
|
||||||
this.user.getPlayer(),
|
if (status)
|
||||||
this.challengeLevel.getRewardText(),
|
{
|
||||||
(player, reply) -> {
|
this.challengeLevel.setRewardText(value.stream().map(s -> s + "|").collect(Collectors.joining()));
|
||||||
this.challengeLevel.setRewardText(reply);
|
}
|
||||||
this.build();
|
|
||||||
return reply;
|
this.build();
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
glow = false;
|
glow = false;
|
||||||
|
@ -30,6 +30,12 @@ import world.bentobox.challenges.utils.GuiUtils;
|
|||||||
*/
|
*/
|
||||||
public class StringListGUI
|
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)
|
public StringListGUI(User user, Collection<String> value, int lineLength, BiConsumer<Boolean, List<String>> consumer)
|
||||||
{
|
{
|
||||||
this(user, new ArrayList<>(value), lineLength, consumer);
|
this(user, new ArrayList<>(value), lineLength, consumer);
|
||||||
|
Loading…
Reference in New Issue
Block a user