Dieser Commit ist enthalten in:
Ursprung
d48185a57f
Commit
18bb819372
@ -21,6 +21,7 @@ package de.steamwar.lobby;
|
||||
|
||||
import de.steamwar.lobby.display.Hologram;
|
||||
import de.steamwar.lobby.portal.Portal;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
|
||||
@ -31,17 +32,29 @@ public class Config {
|
||||
}
|
||||
|
||||
private final FileConfiguration yml;
|
||||
private Location waitingHallSpawn;
|
||||
|
||||
public Config(FileConfiguration yml) {
|
||||
this.yml = yml;
|
||||
|
||||
yml.getList("portals", Portal.getPortals());
|
||||
yml.getList("holograms", Hologram.getHolograms());
|
||||
waitingHallSpawn = yml.getLocation("waitingHallSpawn");
|
||||
}
|
||||
|
||||
public Location getWaitingHallSpawn() {
|
||||
return waitingHallSpawn;
|
||||
}
|
||||
|
||||
public void setWaitingHallSpawn(Location waitingHallSpawn) {
|
||||
this.waitingHallSpawn = waitingHallSpawn;
|
||||
save();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
yml.set("portals", Portal.getPortals());
|
||||
yml.set("holograms", Hologram.getHolograms());
|
||||
yml.set("waitingHallSpawn", waitingHallSpawn);
|
||||
|
||||
LobbySystem.getPlugin().saveConfig();
|
||||
}
|
||||
|
@ -20,8 +20,11 @@
|
||||
package de.steamwar.lobby;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import de.steamwar.comms.BungeeReceiver;
|
||||
import de.steamwar.comms.PacketIdManager;
|
||||
import de.steamwar.comms.packets.FightInfoPacket;
|
||||
import de.steamwar.lobby.portal.FightserverPortal;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
@ -32,7 +35,12 @@ public class Fightserver {
|
||||
|
||||
private static final Map<String, Fightserver> servers = new HashMap<>();
|
||||
|
||||
public static void newFightInfo(ByteArrayDataInput in) {
|
||||
public static void init() {
|
||||
BungeeReceiver.registerHandler(PacketIdManager.FIGHT_INFO, Fightserver::newFightInfo);
|
||||
Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), Fightserver::removeStopped, 20, 20);
|
||||
}
|
||||
|
||||
private static void newFightInfo(ByteArrayDataInput in) {
|
||||
FightInfoPacket fightInfo = new FightInfoPacket(in);
|
||||
Fightserver server = servers.get(fightInfo.getServerName());
|
||||
if (server == null) {
|
||||
@ -42,7 +50,7 @@ public class Fightserver {
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeStopped() {
|
||||
private static void removeStopped() {
|
||||
Instant timeout = Instant.now().minus(5, ChronoUnit.SECONDS);
|
||||
|
||||
Iterator<Map.Entry<String, Fightserver>> it = servers.entrySet().iterator();
|
||||
|
@ -42,7 +42,8 @@ public class LobbySystem extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
message = new Message("de.steamwar.lobby.LobbySystem", getClassLoader());
|
||||
|
||||
new Fightservers();
|
||||
Fightserver.init();
|
||||
new WaitingHall();
|
||||
new Portals();
|
||||
new PortalCommand();
|
||||
new HologramCommand();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2022 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
@ -19,14 +19,19 @@
|
||||
|
||||
package de.steamwar.lobby;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import de.steamwar.comms.BungeeReceiver;
|
||||
import de.steamwar.comms.PacketIdManager;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
public class Fightservers {
|
||||
public class WaitingHall {
|
||||
public WaitingHall() {
|
||||
BungeeReceiver.registerHandler(PacketIdManager.STARTING_SERVER, this::serverStarting);
|
||||
}
|
||||
|
||||
public Fightservers() {
|
||||
BungeeReceiver.registerHandler(PacketIdManager.FIGHT_INFO, Fightserver::newFightInfo);
|
||||
Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), Fightserver::removeStopped, 20, 20);
|
||||
private void serverStarting(ByteArrayDataInput in) {
|
||||
Bukkit.getPlayer(SteamwarUser.get(in.readInt()).getUUID()).teleport(LobbySystem.config().getWaitingHallSpawn(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
}
|
||||
}
|
@ -61,4 +61,9 @@ public class ModifyCommand extends SWCommand implements Listener {
|
||||
public void onLeave(PlayerQuitEvent event) {
|
||||
modifying.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
@Register("waitinghallspawn")
|
||||
public void setWaitingHallSpawn(Player player) {
|
||||
LobbySystem.config().setWaitingHallSpawn(player.getLocation());
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class PlayerSpawn extends BasicListener {
|
||||
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
player.setWalkSpeed(0.5f);
|
||||
player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
|
||||
player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation().clone().add(0.5, 0, 0.5));
|
||||
player.setHealth(20);
|
||||
player.setFoodLevel(20);
|
||||
giveItems(player);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren