Skip to content

Commit 14f03f8

Browse files
Add @translatable, remove @checkenv (#1)
* Add @translatable, remove @checkenv * Add foldMethod * Add prefix and suffix
1 parent d78b7ff commit 14f03f8

File tree

5 files changed

+78
-66
lines changed

5 files changed

+78
-66
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = 1.0
1+
version = 2.0

header.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ Minecraft Dev for IntelliJ Annotations
22

33
https://minecraftdev.org
44

5-
Copyright (c) 2020 minecraft-dev
5+
Copyright (c) 2023 minecraft-dev
66

77
MIT License

src/main/java/com/demonwav/mcdev/annotations/CheckEnv.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/main/java/com/demonwav/mcdev/annotations/Env.java

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Minecraft Dev for IntelliJ Annotations
3+
*
4+
* https://minecraftdev.org
5+
*
6+
* Copyright (c) 2023 minecraft-dev
7+
*
8+
* MIT License
9+
*/
10+
11+
package com.demonwav.mcdev.annotations;
12+
13+
import java.lang.annotation.Documented;
14+
import java.lang.annotation.ElementType;
15+
import java.lang.annotation.Retention;
16+
import java.lang.annotation.RetentionPolicy;
17+
import java.lang.annotation.Target;
18+
19+
/**
20+
* Used to tell MinecraftDev that a {@code String} parameter to a method should point to an entry in the mod's
21+
* translation files. If there is an {@code Object} varargs parameter to that method, it is assumed that those are the
22+
* arguments to this translation.
23+
*
24+
* <p>Example:
25+
* <pre>
26+
* {@code
27+
* public static Component errorMessage(@Translatable String translationKey, Object... args) {
28+
* return Component.translatable(translationKey, args).styled(style -> style.withColor(Formatting.RED));
29+
* }
30+
* }
31+
* </pre>
32+
*/
33+
@Retention(RetentionPolicy.CLASS)
34+
@Target(ElementType.PARAMETER)
35+
@Documented
36+
public @interface Translatable {
37+
/**
38+
* Defaults to {@code true}. If this value is {@code false}, MinecraftDev will not create a warning if the
39+
* translation key doesn't point to a valid translation. This is intended for use when a {@code String} <i>maybe</i>
40+
* points to a translation, but not necessarily.
41+
*/
42+
boolean required() default true;
43+
44+
/**
45+
* Whether to fold the entire method call. Defaults to {@code false}.
46+
*/
47+
boolean foldMethod() default false;
48+
49+
/**
50+
* The prefix that will be added to this argument.
51+
*
52+
* <p>Example:
53+
* <pre>
54+
* {@code
55+
* public static Component itemTranslatable(@Translatable(prefix = "item.") String translationKey) {
56+
* return Component.translatable("item." + translationKey);
57+
* }
58+
* }
59+
* </pre>
60+
*/
61+
String prefix() default "";
62+
63+
/**
64+
* The suffix that will be added to this argument.
65+
*
66+
* <p>Example:
67+
* <pre>
68+
* {@code
69+
* public static Component translatableWithSuffix(@Translatable(prefix = ".suffix") String translationKey) {
70+
* return Component.translatable(translationKey + ".suffix");
71+
* }
72+
* }
73+
* </pre>
74+
*/
75+
String suffix() default "";
76+
}

0 commit comments

Comments
 (0)