Refactor TechareaCommand to support per-player REntityServer instances and add periodic tick updates
All checks were successful
SteamWarCI Build successful
All checks were successful
SteamWarCI Build successful
This commit is contained in:
@@ -23,27 +23,38 @@ import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.entity.CWireframe;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TechareaCommand extends SWCommand {
|
||||
private final REntityServer server = new REntityServer();
|
||||
private final CWireframe wireframe = new CWireframe(server);
|
||||
private final Map<UUID, REntityServer> servers = new HashMap<>();
|
||||
|
||||
public TechareaCommand() {
|
||||
super("techarea");
|
||||
|
||||
wireframe.setPos1(Config.BlueInsetRegion.getMinLocation(Config.world));
|
||||
wireframe.setPos2(Config.BlueInsetRegion.getMaxLocation(Config.world));
|
||||
wireframe.setBlock(Material.RED_CONCRETE.createBlockData());
|
||||
Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> servers.forEach((uuid, rEntityServer) -> rEntityServer.tick()), 2, 2);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player player) {
|
||||
if (server.getPlayers().contains(player)) {
|
||||
server.removePlayer(player);
|
||||
if (servers.containsKey(player.getUniqueId())) {
|
||||
servers.get(player.getUniqueId()).close();
|
||||
} else {
|
||||
REntityServer server = new REntityServer();
|
||||
CWireframe wireframe = new CWireframe(server);
|
||||
|
||||
wireframe.setPos1(Config.BlueInsetRegion.getMinLocation(Config.world));
|
||||
wireframe.setPos2(Config.BlueInsetRegion.getMaxLocation(Config.world));
|
||||
wireframe.setBlock(Material.RED_CONCRETE.createBlockData());
|
||||
|
||||
server.addPlayer(player);
|
||||
servers.put(player.getUniqueId(), server);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user