Skip to content

Commit 0e36b74

Browse files
committed
Add a config entry to Elevator to use the action bar for floor notices
1 parent cb8ae47 commit 0e36b74

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

  • craftbook-bukkit/src/main/java/org/enginehub/craftbook/bukkit/mechanics
  • craftbook-core/src/main/java/org/enginehub/craftbook/mechanics

craftbook-bukkit/src/main/java/org/enginehub/craftbook/bukkit/mechanics/BukkitElevator.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ private void activateElevator(CraftBookPlayer player, Player bukkitPlayer, Block
327327
}
328328
}
329329

330-
public static void teleportFinish(CraftBookPlayer player, Block destination, BlockFace shift) {
330+
private void teleportFinish(CraftBookPlayer player, Block destination, BlockFace shift) {
331331
BukkitChangedSign destinationSign = null;
332332
if (!SignUtil.isSign(destination)) {
333333
if (Tag.BUTTONS.isTagged(destination.getType()) && destination.getBlockData() instanceof Switch attachable) {
@@ -356,13 +356,20 @@ public static void teleportFinish(CraftBookPlayer player, Block destination, Blo
356356
}
357357

358358
String title = PlainTextComponentSerializer.plainText().serialize(destinationSign.getLine(0));
359+
com.sk89q.worldedit.util.formatting.text.Component floorNotice;
359360
if (!title.isEmpty()) {
360-
player.printInfo(TranslatableComponent.of("craftbook.elevator.floor-notice", TextComponent.of(title, TextColor.WHITE)));
361+
floorNotice = TranslatableComponent.of("craftbook.elevator.floor-notice", TextComponent.of(title, TextColor.WHITE));
361362
} else {
362-
player.printInfo(TranslatableComponent.of(shift.getModY() > 0
363+
floorNotice = TranslatableComponent.of(shift.getModY() > 0
363364
? "craftbook.elevator.moved-up"
364365
: "craftbook.elevator.moved-down"
365-
));
366+
);
367+
}
368+
369+
if (actionBar) {
370+
player.printActionBar(floorNotice.color(TextColor.YELLOW));
371+
} else {
372+
player.printInfo(floorNotice);
366373
}
367374
}
368375

craftbook-core/src/main/java/org/enginehub/craftbook/mechanics/Elevator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public String getLabel() {
7373
protected int elevatorRedstoneRadius;
7474
protected boolean elevatorButtonEnabled;
7575
protected boolean elevatorLoop;
76+
protected boolean actionBar;
7677

7778
@Override
7879
public void loadFromConfiguration(YAMLProcessor config) {
@@ -87,5 +88,8 @@ public void loadFromConfiguration(YAMLProcessor config) {
8788

8889
config.setComment("allow-looping", "Allows elevators to loop the world height. The heighest lift up will go to the next lift on the bottom of the world and vice versa.");
8990
elevatorLoop = config.getBoolean("allow-looping", false);
91+
92+
config.setComment("use-action-bar", "Whether to use the action bar or the player's chat for floor messages.");
93+
actionBar = config.getBoolean("use-action-bar", true);
9094
}
9195
}

0 commit comments

Comments
 (0)