Skip to content

Commit

Permalink
feat: show debug info for admins when a fare gate sign is left-clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
sotterbeck committed Aug 11, 2024
1 parent 9eef59a commit 810767d
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
package de.sotterbeck.iumetro.entrypoint.papermc.faregate.sign;

import de.sotterbeck.iumetro.entrypoint.papermc.common.Components;
import de.sotterbeck.iumetro.entrypoint.papermc.common.sign.SignClickEvent;
import de.sotterbeck.iumetro.entrypoint.papermc.common.sign.SignClickHandler;
import de.sotterbeck.iumetro.entrypoint.papermc.faregate.FareGateKeyFactory;
import de.sotterbeck.iumetro.usecase.faregate.FareGateControlInteractor;
import de.sotterbeck.iumetro.usecase.faregate.FareGateControlRequestModel;
import de.sotterbeck.iumetro.usecase.faregate.PositionDto;
import org.bukkit.block.Sign;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;

public class FareGateSignClickHandler implements SignClickHandler {

private final FareGateControlInteractor fareGateControlInteractor;
private final FareGateKeyFactory fareGateKeyFactory;

public FareGateSignClickHandler(FareGateControlInteractor fareGateControlInteractor) {
public FareGateSignClickHandler(FareGateControlInteractor fareGateControlInteractor, FareGateKeyFactory fareGateKeyFactory) {
this.fareGateControlInteractor = fareGateControlInteractor;
this.fareGateKeyFactory = fareGateKeyFactory;
}

@Override
Expand All @@ -30,4 +36,20 @@ public void onRightClick(SignClickEvent event) {
fareGateControlInteractor.openGate(request);
}

@Override
public void onLeftClick(SignClickEvent event) {
if (!event.player().hasPermission("iumetro.admin")) {
return;
}
Sign sign = event.sign();
PersistentDataContainer container = sign.getPersistentDataContainer();

String type = container.get(fareGateKeyFactory.getFareGateTypeKey(), PersistentDataType.STRING);
String stationId = container.get(fareGateKeyFactory.getStationKey(), PersistentDataType.STRING);

String debugInfo = "<gold><bold>[DEBUG]</bold><yellow> type: <white>%s <yellow>stationId: <white>%s".formatted(type, stationId);

event.player().sendActionBar(Components.mm(debugInfo));
}

}

0 comments on commit 810767d

Please sign in to comment.