finalized strikesystem
This commit is contained in:
@ -127,11 +127,11 @@ public class Lobby extends InstanceContainer {
|
||||
if(this.isJoining) return;
|
||||
|
||||
LocalTime now = LocalTime.now(ZoneId.of("Europe/Berlin"));
|
||||
LocalTime start = LocalTime.of(16, 0);
|
||||
LocalTime end = LocalTime.of(21, 0);
|
||||
LocalTime start = LocalTime.of(9, 0); // TODO 17 uhr
|
||||
LocalTime end = LocalTime.of(21, 0); // TODO 21 uhr
|
||||
|
||||
if (now.isBefore(start) || now.isAfter(end)) {
|
||||
event.getPlayer().sendActionBar(Component.text("Der Beitritt ist nur zwischen 16 und 21 Uhr möglich.", NamedTextColor.RED));
|
||||
event.getPlayer().sendActionBar(Component.text("Der Beitritt ist nur zwischen 17 und 21 Uhr möglich.", NamedTextColor.RED));
|
||||
event.getPlayer().playSound(Sound.sound(SoundEvent.BLOCK_NOTE_BLOCK_BASS, Sound.Source.PLAYER, 1f, 0.5f));
|
||||
return;
|
||||
}
|
||||
|
@ -71,9 +71,10 @@ public class Main {
|
||||
p.setRespawnPoint(lobby.spawnPoint);
|
||||
MinecraftServer.getSchedulerManager().scheduleTask(
|
||||
() -> {
|
||||
ConnectInfo.cords(p);
|
||||
ConnectInfo.tickets(lobby.team.name(), p);
|
||||
},
|
||||
TaskSchedule.seconds(3),
|
||||
TaskSchedule.seconds(1),
|
||||
TaskSchedule.stop()
|
||||
);
|
||||
}
|
||||
|
@ -3,12 +3,22 @@ package eu.mhsl.craftattack.teamLobby.util;
|
||||
import eu.mhsl.craftattack.teamLobby.http.ReqResp;
|
||||
import eu.mhsl.craftattack.teamLobby.http.Request;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentBuilder;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.timer.TaskSchedule;
|
||||
|
||||
import java.net.http.HttpRequest;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ConnectInfo {
|
||||
public static int availableTickets = 0;
|
||||
@ -44,4 +54,67 @@ public class ConnectInfo {
|
||||
|
||||
new Thread(task).start();
|
||||
}
|
||||
|
||||
record LocationDto(String world, double x, double y, double z, float yaw, float pitch) {
|
||||
public Pos toPos() {
|
||||
return new Pos(this.x, this.y, this.z, this.yaw, this.pitch);
|
||||
}
|
||||
}
|
||||
|
||||
record LeakInfoDto(String name, LocationDto location, long leakedAt) {
|
||||
public Instant leakedAtInstant() {
|
||||
return Instant.ofEpochMilli(this.leakedAt);
|
||||
}
|
||||
|
||||
public Pos pos() {
|
||||
return this.location.toPos();
|
||||
}
|
||||
}
|
||||
|
||||
public static void cords(Player player) {
|
||||
var task = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
HttpRequest request = Request.builder(Request.server(
|
||||
"strike/cords",
|
||||
uriBuilder -> {}
|
||||
)).GET().build();
|
||||
|
||||
record Status(String status, Map<String, LeakInfoDto> response) {}
|
||||
ReqResp<Status> ticket = Request.execute(request, Status.class);
|
||||
|
||||
System.out.println(ticket.data().response.toString());
|
||||
ComponentBuilder<TextComponent, TextComponent.Builder> text = Component.text()
|
||||
.append(Component.text("Aktuell geleakte Koordinaten:", NamedTextColor.AQUA));
|
||||
|
||||
ticket.data().response().forEach((uuidStr, leakInfo) -> {
|
||||
appendCordLeak(text, leakInfo);
|
||||
});
|
||||
|
||||
player.sendMessage(text.build());
|
||||
}
|
||||
};
|
||||
|
||||
new Thread(task).start();
|
||||
}
|
||||
|
||||
private static void appendCordLeak(ComponentBuilder<TextComponent, TextComponent.Builder> text, LeakInfoDto info) {
|
||||
String timestamp = DateTimeFormatter.ofPattern("dd.MM HH:mm")
|
||||
.withZone(ZoneId.of("Europe/Berlin"))
|
||||
.format(Instant.ofEpochMilli(info.leakedAt));
|
||||
|
||||
text.appendNewline();
|
||||
text.append(Component.text(info.name(), NamedTextColor.DARK_AQUA));
|
||||
text.append(Component.text(": ", NamedTextColor.GRAY));
|
||||
text.append(Component.text(
|
||||
String.format("(%s) %d, %d, %d - Uhrzeit: %s",
|
||||
info.location().world(),
|
||||
(int) info.pos().x(),
|
||||
(int) info.pos().y(),
|
||||
(int) info.pos().z(),
|
||||
timestamp
|
||||
),
|
||||
NamedTextColor.AQUA
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user