use of net.countercraft.movecraft.craft.PilotedCraft in project Movecraft by APDevTeam.
the class NameSign method onCraftDetect.
@EventHandler
public void onCraftDetect(@NotNull CraftDetectEvent event) {
Craft c = event.getCraft();
if (c instanceof PilotedCraft) {
PilotedCraft pilotedCraft = (PilotedCraft) c;
if (Settings.RequireNamePerm && !pilotedCraft.getPilot().hasPermission("movecraft.name.place"))
return;
}
World w = c.getWorld();
for (MovecraftLocation location : c.getHitBox()) {
var block = location.toBukkit(w).getBlock();
if (!Tag.SIGNS.isTagged(block.getType())) {
continue;
}
BlockState state = block.getState();
if (!(state instanceof Sign)) {
return;
}
Sign sign = (Sign) state;
if (sign.getLine(0).equalsIgnoreCase(HEADER)) {
String name = Arrays.stream(sign.getLines()).skip(1).filter(f -> f != null && !f.trim().isEmpty()).collect(Collectors.joining(" "));
c.setName(name);
return;
}
}
}
Aggregations