-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathTranslatableException.java
More file actions
47 lines (38 loc) · 1.08 KB
/
TranslatableException.java
File metadata and controls
47 lines (38 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package net.ess3.api;
import com.earth2me.essentials.utils.AdventureUtil;
import static com.earth2me.essentials.I18n.tlLiteral;
/**
* This exception should be thrown during commands with messages that should be translated.
*/
public class TranslatableException extends Exception {
private final String tlKey;
private final Object[] args;
public TranslatableException(String tlKey, Object... args) {
this(null, tlKey, args);
}
public TranslatableException(Throwable cause, String tlKey, Object... args) {
this.tlKey = tlKey;
this.args = args;
if (cause != null) {
initCause(cause);
}
}
/**
* Sets a cause.
*/
public TranslatableException setCause(Throwable cause) {
initCause(cause);
return this;
}
public String getTlKey() {
return tlKey;
}
public Object[] getArgs() {
return args;
}
@Override
public String getMessage() {
final String literal = tlLiteral(tlKey, args);
return AdventureUtil.miniToLegacy(literal);
}
}