Crossfire JXClient, Trunk  R20561
PlayerLoginSkinEvent.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff.
19  * Copyright (C) 2006-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.skin.events;
23 
28 import org.jetbrains.annotations.NotNull;
29 import org.jetbrains.annotations.Nullable;
30 
35 public class PlayerLoginSkinEvent implements SkinEvent {
36 
41  private final boolean login;
42 
46  @NotNull
47  private final CommandList commandList;
48 
52  @NotNull
53  private final ItemSet itemSet;
54 
58  @NotNull
60 
61  @Override
62  public void itemAdded(@NotNull final CfItem item) {
63  // ignore
64  }
65 
66  @Override
67  public void itemMoved(@NotNull final CfItem item) {
68  // ignore
69  }
70 
71  @Override
72  public void itemChanged(@NotNull final CfItem item) {
73  // ignore
74  }
75 
76  @Override
77  public void itemRemoved(@NotNull final CfItem item) {
78  // ignore
79  }
80 
81  @Override
82  public void playerChanged(@Nullable final CfItem player) {
83  //noinspection VariableNotUsedInsideIf
84  if (player == null) {
85  if (!login) {
86  commandList.execute();
87  }
88  } else {
89  if (login) {
90  commandList.execute();
91  }
92  }
93  }
94 
95  @Override
96  public void openContainerChanged(final int tag) {
97  // ignore
98  }
99 
100  };
101 
109  public PlayerLoginSkinEvent(final boolean login, @NotNull final CommandList commandList, @NotNull final ItemSet itemSet) {
110  this.login = login;
111  this.commandList = commandList;
112  this.itemSet = itemSet;
113  this.itemSet.addItemSetListener(itemSetListener);
114  }
115 
119  @Override
120  public void dispose() {
121  itemSet.removeItemSetListener(itemSetListener);
122  }
123 
124 }
void dispose()
Will be called when the skin is disposed.Should release resources.
Interface for events attached to skins.
Definition: SkinEvent.java:28
void addItemSetListener(@NotNull final ItemSetListener listener)
Adds an ItemSetListener to be notified about changes.
Definition: ItemSet.java:93
A SkinEvent that executes a CommandList at connection setup.
void removeItemSetListener(@NotNull final ItemSetListener listener)
Removes an ItemSetListener to be notified about changes.
Definition: ItemSet.java:101
Interface for listeners in ItemSet related events.
PlayerLoginSkinEvent(final boolean login, @NotNull final CommandList commandList, @NotNull final ItemSet itemSet)
Creates a new instance.
final ItemSetListener itemSetListener
The ItemSetListener attached to itemSet.
final boolean login
Whether to generate login events (.
Model class maintaining the CfItems known to the player.
Definition: ItemSet.java:43
The representation of a Crossfire Item, client-side.
Definition: CfItem.java:36
void execute()
Execute the command list by calling GUICommand#execute() for each command in order.