@@ -81,7 +81,7 @@ public static String[] colorize(String[] list) {
8181 * @return the array list
8282 */
8383 public static ArrayList <String > comptoString (ArrayList <TextComponent > comps ) {
84- ArrayList <String > txt = new ArrayList <String >();
84+ ArrayList <String > txt = new ArrayList <>();
8585 for (TextComponent comp : comps ) {
8686 txt .add (MessageAPI .compToString (comp ));
8787 }
@@ -146,41 +146,15 @@ public static String[] convert(ArrayList<String> list) {
146146
147147 }
148148
149- public static ItemStack [] convertItems (List <Item > list ) {
150- if (list == null ) {
151- return null ;
152- }
153- ItemStack [] string = new ItemStack [list .size ()];
154- for (int i = 0 ; i < list .size (); i ++) {
155- string [i ] = list .get (i ).getItemStack ();
156- }
157- return string ;
158-
159- }
160-
161- public static ItemStack [] convertItems (Collection <ItemStack > list ) {
162- if (list == null ) {
163- return null ;
164- }
165- ItemStack [] string = new ItemStack [list .size ()];
166- int i = 0 ;
167- for (ItemStack item : list ) {
168- string [i ] = item ;
169- i ++;
170- }
171- return string ;
172-
173- }
174-
175149 /**
176150 * Convert.
177151 *
178152 * @param set1 the set
179153 * @return the array list
180154 */
181155 public static ArrayList <String > convert (Set <String > set1 ) {
182- Set <String > set = new HashSet <String >(set1 );
183- ArrayList <String > list = new ArrayList <String >();
156+ Set <String > set = new HashSet <>(set1 );
157+ ArrayList <String > list = new ArrayList <>();
184158 for (String st : set ) {
185159 list .add (st );
186160 }
@@ -198,15 +172,14 @@ public static ArrayList<String> convert(String[] list) {
198172 if (list == null ) {
199173 return null ;
200174 }
201- ArrayList <String > newlist = new ArrayList <String >();
175+ ArrayList <String > newlist = new ArrayList <>();
202176 for (String element : list ) {
203177 newlist .add (element );
204178 }
205179 if (newlist == null ) {
206180 return null ;
207- } else {
208- return newlist ;
209181 }
182+ return newlist ;
210183 }
211184
212185 public static BaseComponent [] convertBaseComponent (ArrayList <BaseComponent > list ) {
@@ -224,13 +197,39 @@ public static ArrayList<BaseComponent> convertBaseComponent(BaseComponent[] list
224197 if (list == null ) {
225198 return null ;
226199 }
227- ArrayList <BaseComponent > newlist = new ArrayList <BaseComponent >();
200+ ArrayList <BaseComponent > newlist = new ArrayList <>();
228201 for (BaseComponent element : list ) {
229202 newlist .add (element );
230203 }
231204 return newlist ;
232205 }
233206
207+ public static ItemStack [] convertItems (Collection <ItemStack > list ) {
208+ if (list == null ) {
209+ return null ;
210+ }
211+ ItemStack [] string = new ItemStack [list .size ()];
212+ int i = 0 ;
213+ for (ItemStack item : list ) {
214+ string [i ] = item ;
215+ i ++;
216+ }
217+ return string ;
218+
219+ }
220+
221+ public static ItemStack [] convertItems (List <Item > list ) {
222+ if (list == null ) {
223+ return null ;
224+ }
225+ ItemStack [] string = new ItemStack [list .size ()];
226+ for (int i = 0 ; i < list .size (); i ++) {
227+ string [i ] = list .get (i ).getItemStack ();
228+ }
229+ return string ;
230+
231+ }
232+
234233 /**
235234 * Sets the to array.
236235 *
@@ -247,9 +246,23 @@ public static String[] convertSet(Set<String> set) {
247246 }
248247 if (array == null ) {
249248 return null ;
250- } else {
251- return array ;
252249 }
250+ return array ;
251+ }
252+
253+ public static HashMap <String , String > fromString (String str ) {
254+ HashMap <String , String > map = new HashMap <>();
255+ if (!str .equals ("" )) {
256+ for (String entry : str .split ("%entry%" )) {
257+ String [] values = entry .split ("%pair%" );
258+ if (values .length > 1 ) {
259+ String key = values [0 ];
260+ String value = values [1 ];
261+ map .put (key , value );
262+ }
263+ }
264+ }
265+ return map ;
253266 }
254267
255268 public static String makeString (HashMap <String , String > placeholders ) {
@@ -267,21 +280,6 @@ public static String makeString(HashMap<String, String> placeholders) {
267280 return str ;
268281 }
269282
270- public static HashMap <String , String > fromString (String str ) {
271- HashMap <String , String > map = new HashMap <String , String >();
272- if (!str .equals ("" )) {
273- for (String entry : str .split ("%entry%" )) {
274- String [] values = entry .split ("%pair%" );
275- if (values .length > 1 ) {
276- String key = values [0 ];
277- String value = values [1 ];
278- map .put (key , value );
279- }
280- }
281- }
282- return map ;
283- }
284-
285283 /**
286284 * Make string.
287285 *
@@ -341,7 +339,7 @@ public static String pickRandom(ArrayList<String> list) {
341339 * @return the array list
342340 */
343341 public static ArrayList <String > removeDuplicates (ArrayList <String > list ) {
344- Set <String > set = new HashSet <String >();
342+ Set <String > set = new HashSet <>();
345343 set .addAll (list );
346344 list .clear ();
347345 list .addAll (set );
@@ -378,7 +376,7 @@ public static List<String> replace(List<String> list, String toReplace, String r
378376 * @return the array list
379377 */
380378 public static ArrayList <String > replaceIgnoreCase (ArrayList <String > list , String toReplace , String replaceWith ) {
381- ArrayList <String > newList = new ArrayList <String >();
379+ ArrayList <String > newList = new ArrayList <>();
382380 for (String msg : list ) {
383381 newList .add (MessageAPI .replaceIgnoreCase (msg , toReplace , replaceWith ));
384382 }
@@ -392,23 +390,21 @@ public static ArrayList<String> sort(ArrayList<String> list) {
392390
393391 public static HashMap <String , Integer > sortByValuesStr (HashMap <String , Integer > unsortMap , final boolean order ) {
394392
395- List <Entry <String , Integer >> list = new LinkedList <Entry < String , Integer > >(unsortMap .entrySet ());
393+ List <Entry <String , Integer >> list = new LinkedList <>(unsortMap .entrySet ());
396394
397395 // Sorting the list based on values
398396 Collections .sort (list , new Comparator <Entry <String , Integer >>() {
399397 @ Override
400398 public int compare (Entry <String , Integer > o1 , Entry <String , Integer > o2 ) {
401399 if (order ) {
402400 return o1 .getValue ().compareTo (o2 .getValue ());
403- } else {
404- return o2 .getValue ().compareTo (o1 .getValue ());
405-
406401 }
402+ return o2 .getValue ().compareTo (o1 .getValue ());
407403 }
408404 });
409405
410406 // Maintaining insertion order with the help of LinkedList
411- HashMap <String , Integer > sortedMap = new LinkedHashMap <String , Integer >();
407+ HashMap <String , Integer > sortedMap = new LinkedHashMap <>();
412408 for (Entry <String , Integer > entry : list ) {
413409 sortedMap .put (entry .getKey (), entry .getValue ());
414410 }
@@ -418,10 +414,10 @@ public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
418414
419415 public static LinkedHashMap <String , ItemStack > sortByValuesStrItem (HashMap <String , ItemStack > unsortMap ) {
420416
421- ArrayList <String > sortedKeys = sort (new ArrayList <String >(unsortMap .keySet ()));
417+ ArrayList <String > sortedKeys = sort (new ArrayList <>(unsortMap .keySet ()));
422418
423419 // Maintaining insertion order with the help of LinkedList
424- LinkedHashMap <String , ItemStack > sortedMap = new LinkedHashMap <String , ItemStack >();
420+ LinkedHashMap <String , ItemStack > sortedMap = new LinkedHashMap <>();
425421 for (String key : sortedKeys ) {
426422 sortedMap .put (key , unsortMap .get (key ));
427423 }
0 commit comments