View Javadoc

1   package nl.tudelft.goal.ut2004.visualizer.gui.action;
2   
3   import java.awt.event.ActionEvent;
4   import java.awt.event.ActionListener;
5   
6   import nl.tudelft.goal.ut2004.visualizer.controller.ServerController;
7   
8   
9   import cz.cuni.amis.pogamut.unreal.communication.messages.gbinfomessages.IPlayer;
10  import cz.cuni.amis.pogamut.unreal.communication.worldview.map.IUnrealWaypoint;
11  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.AddInventory;
12  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.SetGameSpeed;
13  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.SpawnActor;
14  import cz.cuni.amis.pogamut.ut2004.server.IUT2004Server;
15  
16  public class AddInventoryAction implements ActionListener {
17  	private final IPlayer player;
18  	private final String item;
19  
20  	public AddInventoryAction(IPlayer player, String item) {
21  		this.player = player;
22  		this.item = item;
23  	}
24  
25  	@Override
26  	public void actionPerformed(ActionEvent e) {
27  		ServerController controller = ServerController.getInstance();
28  		IUT2004Server server = controller.getServer();
29  		assert server != null;
30  
31  		AddInventory addInventory = new AddInventory(player.getId(), item);
32  
33  		server.getAct().act(addInventory);
34  	}
35  
36  }