Skip to content

Commit 70ccdf5

Browse files
Suggestions update
Yeah, a way too long reaction but anyway.
1 parent 2623aea commit 70ccdf5

File tree

1 file changed

+42
-32
lines changed

1 file changed

+42
-32
lines changed
Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,62 @@
1+
/*
2+
* Copyright or © or Copr. ZLib contributors (2015 - 2016)
3+
*
4+
* This software is governed by the CeCILL-B license under French law and
5+
* abiding by the rules of distribution of free software. You can use,
6+
* modify and/ or redistribute the software under the terms of the CeCILL-B
7+
* license as circulated by CEA, CNRS and INRIA at the following URL
8+
* "http://www.cecill.info".
9+
*
10+
* As a counterpart to the access to the source code and rights to copy,
11+
* modify and redistribute granted by the license, users are provided only
12+
* with a limited warranty and the software's author, the holder of the
13+
* economic rights, and the successive licensors have only limited
14+
* liability.
15+
*
16+
* In this respect, the user's attention is drawn to the risks associated
17+
* with loading, using, modifying and/or developing or reproducing the
18+
* software by the user in light of its specific status of free software,
19+
* that may mean that it is complicated to manipulate, and that also
20+
* therefore means that it is reserved for developers and experienced
21+
* professionals having in-depth computer knowledge. Users are therefore
22+
* encouraged to load and test the software's suitability as regards their
23+
* requirements in conditions enabling the security of their systems and/or
24+
* data to be ensured and, more generally, to use and operate it in the
25+
* same conditions as regards security.
26+
*
27+
* The fact that you are presently reading this means that you have had
28+
* knowledge of the CeCILL-B license and that you accept its terms.
29+
*/
130
package fr.zcraft.zlib.components.gui;
231

32+
import org.apache.commons.lang.NotImplementedException;
333
import org.bukkit.entity.Player;
434
import org.bukkit.inventory.ItemStack;
535

636
import fr.zcraft.zlib.components.gui.ExplorerGui;
737
import fr.zcraft.zlib.components.gui.Gui;
838
import fr.zcraft.zlib.tools.Callback;
939

10-
public abstract class ArrayPromptGui<T> extends ExplorerGui<T> {
11-
40+
public abstract class ArrayPromptGui<T> extends ExplorerGui<T>
41+
{
1242
private Callback<T> cb;
1343
private String title;
1444
private T[] data;
1545
private boolean closeOnChoice;
1646

1747
/**
18-
* @param callback
19-
* Callback called when the player made a choice
2048
* @param player
2149
* The player making the choice
2250
* @param title
2351
* The gui title
2452
* @param data
2553
* An array of datas to display
26-
* @param renderer
27-
* Interface for building gui's ItemStack from array values
2854
* @param closeOnChoice
29-
* Close the interface when the player has choosen if true
55+
* If true, close the interface when the player has choosen
56+
* @param callback
57+
* Callback called when the player made a choice
3058
*/
31-
public <A> ArrayPromptGui(Callback<T> callback, Player player, String title, T[] data, boolean closeOnChoice) {
59+
public <A> ArrayPromptGui(Player player, String title, T[] data, boolean closeOnChoice, Callback<T> callback) {
3260
this.cb = callback;
3361
this.title = title;
3462
this.data = data;
@@ -38,24 +66,22 @@ public <A> ArrayPromptGui(Callback<T> callback, Player player, String title, T[]
3866
}
3967

4068
/**
41-
* @see #onChoice(Object)
69+
* @see #onClick(Object)
4270
*
4371
* Constructor with no callback argument. Note that you must override
44-
* the onChoice method by using this constructor
72+
* the onClick method if you use this constructor
4573
*
4674
* @param player
4775
* The player making the choice
4876
* @param title
4977
* The gui title
5078
* @param data
5179
* An array of datas to display
52-
* @param renderer
53-
* Interface for building gui's ItemStack from array values
5480
* @param closeOnChoice
5581
* Close the interface when the player has choosen if true
5682
*/
5783
public <A> ArrayPromptGui(Player player, String title, T[] data, boolean closeOnChoice) {
58-
this(null, player, title, data, closeOnChoice);
84+
this(player, title, data, closeOnChoice, null);
5985
}
6086

6187
/**
@@ -70,8 +96,8 @@ public <A> ArrayPromptGui(Player player, String title, T[] data, boolean closeOn
7096
*
7197
* @param data
7298
*/
73-
public void onChoice(T data) {
74-
System.err.println("Damn ! I'm not properly implemented : override me or use a callback.");
99+
public void onClick(T data) {
100+
throw new NotImplementedException("Override this method or use a callback.");
75101
}
76102

77103
@Override
@@ -80,7 +106,7 @@ protected void onRightClick(T data) {
80106
if (cb != null)
81107
cb.call(data);
82108
else
83-
onChoice(data);
109+
onClick(data);
84110

85111
if (closeOnChoice)
86112
close();
@@ -92,20 +118,4 @@ protected void onUpdate() {
92118
setMode(Mode.READONLY);
93119
setData(data);
94120
}
95-
96-
public Callback<T> getCallback() {
97-
return cb;
98-
}
99-
100-
public String getPurpose() {
101-
return title;
102-
}
103-
104-
public T[] getData() {
105-
return data;
106-
}
107-
108-
public boolean closeOnChoice() {
109-
return closeOnChoice;
110-
}
111121
}

0 commit comments

Comments
 (0)