added admin-passthrough
added time-lock
This commit is contained in:
@@ -30,6 +30,8 @@ import net.minestom.server.world.DimensionType;
|
|||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -73,7 +75,6 @@ public class Lobby extends InstanceContainer {
|
|||||||
MinecraftServer.getInstanceManager().registerInstance(this);
|
MinecraftServer.getInstanceManager().registerInstance(this);
|
||||||
this.team = team;
|
this.team = team;
|
||||||
|
|
||||||
//noinspection UnstableApiUsage
|
|
||||||
this.eventNode()
|
this.eventNode()
|
||||||
.addListener(PlayerBlockBreakEvent.class, CommonHandler::cancel)
|
.addListener(PlayerBlockBreakEvent.class, CommonHandler::cancel)
|
||||||
.addListener(AddEntityToInstanceEvent.class, this::onPlayerChange)
|
.addListener(AddEntityToInstanceEvent.class, this::onPlayerChange)
|
||||||
@@ -124,11 +125,23 @@ public class Lobby extends InstanceContainer {
|
|||||||
private synchronized void onBlockInteract(PlayerBlockInteractEvent event) {
|
private synchronized void onBlockInteract(PlayerBlockInteractEvent event) {
|
||||||
if(!event.getBlockPosition().sameBlock(this.buttonLocation)) return;
|
if(!event.getBlockPosition().sameBlock(this.buttonLocation)) return;
|
||||||
if(this.isJoining) return;
|
if(this.isJoining) return;
|
||||||
|
|
||||||
|
LocalTime now = LocalTime.now(ZoneId.of("Europe/Berlin"));
|
||||||
|
LocalTime start = LocalTime.of(16, 0);
|
||||||
|
LocalTime end = LocalTime.of(21, 0);
|
||||||
|
|
||||||
|
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().playSound(Sound.sound(SoundEvent.BLOCK_NOTE_BLOCK_BASS, Sound.Source.PLAYER, 1f, 0.5f));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(!this.isComplete) {
|
if(!this.isComplete) {
|
||||||
event.getPlayer().playSound(Sound.sound(SoundEvent.UI_BUTTON_CLICK, Sound.Source.PLAYER, 1f, 1f));
|
event.getPlayer().playSound(Sound.sound(SoundEvent.UI_BUTTON_CLICK, Sound.Source.PLAYER, 1f, 1f));
|
||||||
this.everyMember(p -> p.sendActionBar(Component.text("Dein Team ist nicht vollständig!", NamedTextColor.RED)));
|
this.everyMember(p -> p.sendActionBar(Component.text("Dein Team ist nicht vollständig!", NamedTextColor.RED)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isJoining = true;
|
this.isJoining = true;
|
||||||
this.connect();
|
this.connect();
|
||||||
this.update();
|
this.update();
|
||||||
@@ -169,7 +182,6 @@ public class Lobby extends InstanceContainer {
|
|||||||
|
|
||||||
private void particleTick() {
|
private void particleTick() {
|
||||||
if(!this.isComplete) return;
|
if(!this.isComplete) return;
|
||||||
|
|
||||||
this.everyMember(p -> p.sendPacket(this.isJoining ? this.progressParticles : this.availableParticles));
|
this.everyMember(p -> p.sendPacket(this.isJoining ? this.progressParticles : this.availableParticles));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,9 +2,12 @@ package eu.mhsl.craftattack.teamLobby;
|
|||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import eu.mhsl.craftattack.teamLobby.data.Team;
|
import eu.mhsl.craftattack.teamLobby.data.Team;
|
||||||
|
import eu.mhsl.craftattack.teamLobby.http.ReqResp;
|
||||||
import eu.mhsl.craftattack.teamLobby.http.Request;
|
import eu.mhsl.craftattack.teamLobby.http.Request;
|
||||||
|
import eu.mhsl.craftattack.teamLobby.util.PluginMessageUtil;
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
|
import net.minestom.server.instance.InstanceContainer;
|
||||||
import net.minestom.server.timer.TaskSchedule;
|
import net.minestom.server.timer.TaskSchedule;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -34,9 +37,24 @@ public class LobbyManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull Lobby getPlayerInstance(Player player) {
|
public @NotNull InstanceContainer getPlayerInstance(Player player) {
|
||||||
UUID playerId = player.getUuid();
|
UUID playerId = player.getUuid();
|
||||||
|
|
||||||
|
HttpRequest request = Request.builder(Request.server(
|
||||||
|
"adminmarker/isAdmin",
|
||||||
|
uriBuilder -> uriBuilder.addParameter("player", player.getUuid().toString())
|
||||||
|
)).GET().build();
|
||||||
|
|
||||||
|
record Status(String status, boolean response) {}
|
||||||
|
ReqResp<Status> ticket = Request.execute(request, Status.class);
|
||||||
|
if(ticket.data().response) {
|
||||||
|
MinecraftServer.getSchedulerManager().scheduleTask(
|
||||||
|
() -> PluginMessageUtil.connect(player, "server"),
|
||||||
|
TaskSchedule.seconds(1),
|
||||||
|
TaskSchedule.stop());
|
||||||
|
return MinecraftServer.getInstanceManager().createInstanceContainer();
|
||||||
|
}
|
||||||
|
|
||||||
Team targetTeam;
|
Team targetTeam;
|
||||||
synchronized(this.teamLock) {
|
synchronized(this.teamLock) {
|
||||||
targetTeam = this.teams.stream()
|
targetTeam = this.teams.stream()
|
||||||
|
@@ -5,6 +5,7 @@ import eu.mhsl.craftattack.teamLobby.util.DisconnectInfo;
|
|||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
|
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
|
||||||
|
import net.minestom.server.instance.InstanceContainer;
|
||||||
import net.minestom.server.timer.TaskSchedule;
|
import net.minestom.server.timer.TaskSchedule;
|
||||||
import org.spongepowered.configurate.ConfigurateException;
|
import org.spongepowered.configurate.ConfigurateException;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
@@ -64,16 +65,18 @@ public class Main {
|
|||||||
try {
|
try {
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
System.out.printf("Player %s joined: %s%n", p.getUsername(), p.getUuid());
|
System.out.printf("Player %s joined: %s%n", p.getUsername(), p.getUuid());
|
||||||
Lobby lobby = lobbyManager.getPlayerInstance(p);
|
InstanceContainer container = lobbyManager.getPlayerInstance(p);
|
||||||
event.setSpawningInstance(lobby);
|
event.setSpawningInstance(container);
|
||||||
p.setRespawnPoint(lobby.spawnPoint);
|
if(container instanceof Lobby lobby) {
|
||||||
MinecraftServer.getSchedulerManager().scheduleTask(
|
p.setRespawnPoint(lobby.spawnPoint);
|
||||||
() -> {
|
MinecraftServer.getSchedulerManager().scheduleTask(
|
||||||
ConnectInfo.tickets(lobby.team.name(), p);
|
() -> {
|
||||||
},
|
ConnectInfo.tickets(lobby.team.name(), p);
|
||||||
TaskSchedule.seconds(3),
|
},
|
||||||
TaskSchedule.stop()
|
TaskSchedule.seconds(3),
|
||||||
);
|
TaskSchedule.stop()
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
new DisconnectInfo(
|
new DisconnectInfo(
|
||||||
"Login abgelehnt",
|
"Login abgelehnt",
|
||||||
|
Reference in New Issue
Block a user