1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package nl.tudelft.goal.ut2004.visualizer.gui.action;
18
19 import java.awt.event.ActionEvent;
20 import java.awt.event.ActionListener;
21
22 import nl.tudelft.goal.ut2004.visualizer.controller.ServerController;
23 import nl.tudelft.goal.ut2004.visualizer.gui.widgets.WaypointBox;
24
25 import cz.cuni.amis.pogamut.base3d.worldview.object.Location;
26 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Respawn;
27 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player;
28 import cz.cuni.amis.pogamut.ut2004.communication.worldview.map.Waypoint;
29 import cz.cuni.amis.pogamut.ut2004.server.IUT2004Server;
30
31
32
33
34
35
36
37
38
39
40 public class RespawnAction implements ActionListener {
41
42 private final Player player;
43
44 private final WaypointBox navpoints;
45
46 public RespawnAction(Player player, WaypointBox navpoints) {
47 this.player = player;
48 this.navpoints = navpoints;
49 }
50
51 @Override
52 public void actionPerformed(ActionEvent e) {
53 ServerController controller = ServerController.getInstance();
54 IUT2004Server server = controller.getServer();
55 assert server != null;
56
57 Waypoint waypoint = navpoints.getSelected();
58 Location location = null;
59 if (waypoint != null) {
60 location = waypoint.getLocation();
61 }
62
63 Respawn respawn = new Respawn(player.getId(), location, null);
64 server.getAct().act(respawn);
65 }
66
67 }