fix(gui): repair help book formatting and pagination

- fixed numbered list on page 1

- split content into 9 pages to prevent text cutoff

- fixed unique constraint error by overwriting existing shops at location
This commit is contained in:
2026-02-04 21:59:07 -05:00
parent 087bf7eb40
commit e8e4e35b6e
3 changed files with 42 additions and 31 deletions

View File

@@ -32,10 +32,12 @@ public class HelpBook {
.append(Component.text("1. type ", NamedTextColor.BLACK)) .append(Component.text("1. type ", NamedTextColor.BLACK))
.append(Component.text("/oyes on", NamedTextColor.BLUE)) .append(Component.text("/oyes on", NamedTextColor.BLUE))
.append(Component.newline()) .append(Component.newline())
.append(Component.text("2. place a chest", NamedTextColor.BLACK))
.append(Component.newline())
.append(Component.text("3. place a wall sign", NamedTextColor.BLACK)) .append(Component.text("3. place a wall sign", NamedTextColor.BLACK))
.build()); .build());
// page 2: setup wizard // page 2: setup wizard (intro)
pages.add(Component.text() pages.add(Component.text()
.append(Component.text("setup wizard", NamedTextColor.GOLD, TextDecoration.BOLD)) .append(Component.text("setup wizard", NamedTextColor.GOLD, TextDecoration.BOLD))
.append(Component.newline()) .append(Component.newline())
@@ -49,7 +51,15 @@ public class HelpBook {
.append(Component.text("/oyes setup", NamedTextColor.BLUE)) .append(Component.text("/oyes setup", NamedTextColor.BLUE))
.append(Component.newline()) .append(Component.newline())
.append(Component.newline()) .append(Component.newline())
.append(Component.text("or just write ", NamedTextColor.GRAY)) .append(Component.text("...or turn the page", NamedTextColor.DARK_GRAY))
.build());
// page 3: setup wizard (sign trigger)
pages.add(Component.text()
.append(Component.text("sign trigger", NamedTextColor.GOLD, TextDecoration.BOLD))
.append(Component.newline())
.append(Component.newline())
.append(Component.text("just write ", NamedTextColor.GRAY))
.append(Component.text("setup", NamedTextColor.BLUE, TextDecoration.BOLD)) .append(Component.text("setup", NamedTextColor.BLUE, TextDecoration.BOLD))
.append(Component.text(" on the first line of the sign.", NamedTextColor.GRAY)) .append(Component.text(" on the first line of the sign.", NamedTextColor.GRAY))
.append(Component.newline()) .append(Component.newline())
@@ -59,13 +69,12 @@ public class HelpBook {
NamedTextColor.DARK_GRAY)) NamedTextColor.DARK_GRAY))
.build()); .build());
// page 2: the sign format // page 4: manual creation
pages.add(Component.text() pages.add(Component.text()
.append(Component.text("creating a shop", NamedTextColor.GOLD, TextDecoration.BOLD)) .append(Component.text("manual setup", NamedTextColor.GOLD, TextDecoration.BOLD))
.append(Component.newline()) .append(Component.newline())
.append(Component.newline()) .append(Component.newline())
.append(Component.text("write your trade on the sign like this:", .append(Component.text("write exactly this:", NamedTextColor.DARK_GRAY))
NamedTextColor.DARK_GRAY))
.append(Component.newline()) .append(Component.newline())
.append(Component.newline()) .append(Component.newline())
.append(Component.text("line 1: ", NamedTextColor.GRAY)) .append(Component.text("line 1: ", NamedTextColor.GRAY))
@@ -76,18 +85,14 @@ public class HelpBook {
.append(Component.newline()) .append(Component.newline())
.append(Component.text("line 3: ", NamedTextColor.GRAY)) .append(Component.text("line 3: ", NamedTextColor.GRAY))
.append(Component.text("64 dirt", NamedTextColor.BLACK)) .append(Component.text("64 dirt", NamedTextColor.BLACK))
.append(Component.newline())
.append(Component.newline())
.append(Component.text("(order doesn't matter, it shows a confirmation)",
NamedTextColor.DARK_GRAY))
.build()); .build());
// page 3: auto detection // page 5: auto detection
pages.add(Component.text() pages.add(Component.text()
.append(Component.text("auto detection", NamedTextColor.GOLD, TextDecoration.BOLD)) .append(Component.text("auto detection", NamedTextColor.GOLD, TextDecoration.BOLD))
.append(Component.newline()) .append(Component.newline())
.append(Component.newline()) .append(Component.newline())
.append(Component.text("lazy? just put your items in the chest and write:", .append(Component.text("lazy? just put items in the chest and write:",
NamedTextColor.DARK_GRAY)) NamedTextColor.DARK_GRAY))
.append(Component.newline()) .append(Component.newline())
.append(Component.newline()) .append(Component.newline())
@@ -96,29 +101,28 @@ public class HelpBook {
.append(Component.text("for 10 gold", NamedTextColor.BLACK)) .append(Component.text("for 10 gold", NamedTextColor.BLACK))
.append(Component.newline()) .append(Component.newline())
.append(Component.newline()) .append(Component.newline())
.append(Component.text( .append(Component.text("the plugin will check the chest contents.",
"the plugin will see what's in the chest and fill it in for you.",
NamedTextColor.DARK_GRAY)) NamedTextColor.DARK_GRAY))
.build()); .build());
// page 4: protection and ownership // page 6: ownership
pages.add(Component.text() pages.add(Component.text()
.append(Component.text("ownership rules", NamedTextColor.GOLD, TextDecoration.BOLD)) .append(Component.text("ownership rules", NamedTextColor.GOLD, TextDecoration.BOLD))
.append(Component.newline()) .append(Component.newline())
.append(Component.newline()) .append(Component.newline())
.append(Component.text( .append(Component.text(
"to prevent stealing, you can only make shops on containers you placed ", "you can only make shops on containers you placed ",
NamedTextColor.DARK_GRAY)) NamedTextColor.DARK_GRAY))
.append(Component.text("this session", NamedTextColor.BLACK, TextDecoration.ITALIC)) .append(Component.text("this session", NamedTextColor.BLACK, TextDecoration.ITALIC))
.append(Component.text(".", NamedTextColor.DARK_GRAY)) .append(Component.text(".", NamedTextColor.DARK_GRAY))
.append(Component.newline()) .append(Component.newline())
.append(Component.newline()) .append(Component.newline())
.append(Component.text( .append(Component.text(
"if the server restarts, you can't turn old chests into shops. place a fresh one!", "prevents stealing old chests!",
NamedTextColor.DARK_GRAY)) NamedTextColor.DARK_GRAY))
.build()); .build());
// page 5: containers // page 7: containers
pages.add(Component.text() pages.add(Component.text()
.append(Component.text("supported blocks", NamedTextColor.GOLD, TextDecoration.BOLD)) .append(Component.text("supported blocks", NamedTextColor.GOLD, TextDecoration.BOLD))
.append(Component.newline()) .append(Component.newline())
@@ -130,40 +134,38 @@ public class HelpBook {
.append(Component.text("- trapped chests", NamedTextColor.BLACK)) .append(Component.text("- trapped chests", NamedTextColor.BLACK))
.append(Component.newline()) .append(Component.newline())
.append(Component.newline()) .append(Component.newline())
.append(Component.text("double chests are fully supported. both halves are protected.", .append(Component.text("double chests supported.", NamedTextColor.DARK_GRAY))
NamedTextColor.DARK_GRAY))
.build()); .build());
// page 6: utility commands // page 8: commands
pages.add(Component.text() pages.add(Component.text()
.append(Component.text("handy commands", NamedTextColor.GOLD, TextDecoration.BOLD)) .append(Component.text("commands", NamedTextColor.GOLD, TextDecoration.BOLD))
.append(Component.newline()) .append(Component.newline())
.append(Component.newline()) .append(Component.newline())
.append(Component.text("/oyes notify", NamedTextColor.BLUE)) .append(Component.text("/oyes notify", NamedTextColor.BLUE))
.append(Component.newline()) .append(Component.newline())
.append(Component.text("get alerts when your shops run out of items.", .append(Component.text("get low stock alerts.", NamedTextColor.DARK_GRAY))
NamedTextColor.DARK_GRAY))
.append(Component.newline()) .append(Component.newline())
.append(Component.newline()) .append(Component.newline())
.append(Component.text("/oyes info", NamedTextColor.BLUE)) .append(Component.text("/oyes info", NamedTextColor.BLUE))
.append(Component.newline()) .append(Component.newline())
.append(Component.text("see who made this plugin.", NamedTextColor.DARK_GRAY)) .append(Component.text("plugin info.", NamedTextColor.DARK_GRAY))
.build()); .build());
// page 7: tips // page 9: tips
pages.add(Component.text() pages.add(Component.text()
.append(Component.text("pro tips", NamedTextColor.GOLD, TextDecoration.BOLD)) .append(Component.text("pro tips", NamedTextColor.GOLD, TextDecoration.BOLD))
.append(Component.newline()) .append(Component.newline())
.append(Component.newline()) .append(Component.newline())
.append(Component.text("- use wall signs only.", NamedTextColor.BLACK)) .append(Component.text("- use wall signs.", NamedTextColor.BLACK))
.append(Component.newline()) .append(Component.newline())
.append(Component.text("- use abbreviations like ", NamedTextColor.BLACK)) .append(Component.text("- abbreviations: ", NamedTextColor.BLACK))
.append(Component.text("dia", NamedTextColor.BLUE)) .append(Component.text("dia", NamedTextColor.BLUE))
.append(Component.text(" for diamond.", NamedTextColor.BLACK)) .append(Component.text(" = diamond.", NamedTextColor.BLACK))
.append(Component.newline()) .append(Component.newline())
.append(Component.text("- shops are ", NamedTextColor.BLACK)) .append(Component.text("- shops are ", NamedTextColor.BLACK))
.append(Component.text("off", NamedTextColor.RED)) .append(Component.text("off", NamedTextColor.RED))
.append(Component.text(" by default to prevent accidents.", NamedTextColor.BLACK)) .append(Component.text(" by default.", NamedTextColor.BLACK))
.build()); .build());
Book book = Book.book(Component.text("oyeshops manual"), Component.text("oyeshops"), pages); Book book = Book.book(Component.text("oyeshops manual"), Component.text("oyeshops"), pages);

View File

@@ -122,6 +122,9 @@ public class SetupDialog {
System.currentTimeMillis()); System.currentTimeMillis());
// 4. finalize shop immediately // 4. finalize shop immediately
plugin.getLogger().info(
"DEBUG: SetupDialog creating shop at "
+ signBlock.getLocation());
plugin.getServer().getScheduler() plugin.getServer().getScheduler()
.runTask(plugin, () -> { .runTask(plugin, () -> {
plugin.getShopActivationListener() plugin.getShopActivationListener()

View File

@@ -202,14 +202,20 @@ public class ShopActivationListener implements Listener {
plugin.getShopRepository().deleteShopByLocation(signLocation); plugin.getShopRepository().deleteShopByLocation(signLocation);
int shopId = plugin.getShopRepository().createShop(shop); int shopId = plugin.getShopRepository().createShop(shop);
plugin.getLogger().info("DEBUG: created shop id " + shopId + " at " + signLocation);
plugin.getServer().getScheduler().runTask(plugin, () -> { plugin.getServer().getScheduler().runTask(plugin, () -> {
// re-verify sign on main thread // re-verify sign on main thread
if (!(signLocation.getBlock().getState() instanceof Sign finalSign)) if (!(signLocation.getBlock().getState() instanceof Sign finalSign)) {
plugin.getLogger().info("DEBUG: sign missing at " + signLocation);
return; return;
}
Shop registeredShop = new Shop(shopId, signLocation, player.getUniqueId(), trade, 0, true, Shop registeredShop = new Shop(shopId, signLocation, player.getUniqueId(), trade, 0, true,
createdAt); createdAt);
plugin.getShopRegistry().register(registeredShop); plugin.getShopRegistry().register(registeredShop);
plugin.getLogger().info("DEBUG: registered shop " + shopId + " in registry");
rewriteSignLines(finalSign, trade); rewriteSignLines(finalSign, trade);
player.sendMessage(Component.text("shop #" + shopId + " initialized!", NamedTextColor.GREEN)); player.sendMessage(Component.text("shop #" + shopId + " initialized!", NamedTextColor.GREEN));
}); });