Skip to content

Commit 884b138

Browse files
committed
Removed unnecessary utility methods
1 parent f6513c2 commit 884b138

File tree

1 file changed

+8
-56
lines changed
  • src/main/java/me/despical/commandframework/utils

1 file changed

+8
-56
lines changed

src/main/java/me/despical/commandframework/utils/Utils.java

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,12 @@ private Utils() {
4848
* @return the int represented by the string, or zero if conversion fails
4949
*/
5050
public static int getInt(String string) {
51-
return getInt(string, 0);
52-
}
53-
54-
/**
55-
* Convert a String to an int, returning a default value if the conversion
56-
* fails. If the string is null, the default value is returned.
57-
*
58-
* @param string the string to convert, may be null
59-
* @param def the default value
60-
* @return the int represented by the string, or the default if conversion fails
61-
*/
62-
public static int getInt(String string, int def) {
63-
if (string == null) return def;
51+
if (string == null) return 0;
6452

6553
try {
6654
return Integer.parseInt(string);
6755
} catch (NumberFormatException ignored) {
68-
return def;
56+
return 0;
6957
}
7058
}
7159

@@ -77,24 +65,12 @@ public static int getInt(String string, int def) {
7765
* @return the double represented by the string, or zero if conversion fails
7866
*/
7967
public static double getDouble(String string) {
80-
return getDouble(string, 0);
81-
}
82-
83-
/**
84-
* Convert a String to a double, returning a default value if the conversion
85-
* fails. If the string is null, the default value is returned.
86-
*
87-
* @param string the string to convert, may be null
88-
* @param def the default value
89-
* @return the double represented by the string, or the default if conversion fails
90-
*/
91-
public static double getDouble(String string, double def) {
92-
if (string == null) return def;
68+
if (string == null) return 0d;
9369

9470
try {
9571
return Double.parseDouble(string);
9672
} catch (NumberFormatException ignored) {
97-
return def;
73+
return 0d;
9874
}
9975
}
10076

@@ -106,24 +82,12 @@ public static double getDouble(String string, double def) {
10682
* @return the long represented by the string, or zero if conversion fails
10783
*/
10884
public static long getLong(String string) {
109-
return getLong(string, 0);
110-
}
111-
112-
/**
113-
* Convert a String to a long, returning a default value if the conversion
114-
* fails. If the string is null, the default value is returned.
115-
*
116-
* @param string the string to convert, may be null
117-
* @param def the default value
118-
* @return the long represented by the string, or the default if conversion fails
119-
*/
120-
public static long getLong(String string, long def) {
121-
if (string == null) return def;
85+
if (string == null) return 0L;
12286

12387
try {
12488
return Long.parseLong(string);
12589
} catch (NumberFormatException ignored) {
126-
return def;
90+
return 0L;
12791
}
12892
}
12993

@@ -135,24 +99,12 @@ public static long getLong(String string, long def) {
13599
* @return the float represented by the string, or zero if conversion fails
136100
*/
137101
public static float getFloat(String string) {
138-
return getFloat(string, 0);
139-
}
140-
141-
/**
142-
* Convert a String to a float, returning a default value if the conversion
143-
* fails. If the string is null, the default value is returned.
144-
*
145-
* @param string the string to convert, may be null
146-
* @param def the default value
147-
* @return the float represented by the string, or the default if conversion fails
148-
*/
149-
public static float getFloat(String string, float def) {
150-
if (string == null) return def;
102+
if (string == null) return 0F;
151103

152104
try {
153105
return Float.parseFloat(string);
154106
} catch (NumberFormatException ignored) {
155-
return def;
107+
return 0F;
156108
}
157109
}
158110

0 commit comments

Comments
 (0)