Skip to content

Commit b4766e9

Browse files
author
Librazy
committed
clean up deprecation and enable -Xlint:deprecation
1 parent 4eac9c5 commit b4766e9

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

Diff for: build.gradle

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,11 @@ repositories {
3838
dependencies {
3939
compile 'org.spigotmc:spigot-api:1.11.2-R0.1-SNAPSHOT'
4040
compile 'net.milkbowl.vault:VaultAPI:1.6'
41-
compile 'org.librazy:NyaaUtilsLangChecker:1.0-SNAPSHOT'
4241
processor 'org.librazy:NyaaUtilsLangChecker:1.0-SNAPSHOT'
4342
}
4443

4544
compileJava {
46-
options.compilerArgs += ["-Xplugin:NyaaUtilsLangAnnotationProcessor"]
45+
options.compilerArgs += ["-Xplugin:NyaaUtilsLangAnnotationProcessor", "-Xlint:deprecation"]
4746
}
4847

4948
publishing {

Diff for: src/main/java/cat/nyaa/nyaacore/CommandReceiver.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.text.DecimalFormat;
2323
import java.util.*;
2424

25+
@SuppressWarnings("unused")
2526
public abstract class CommandReceiver<T extends JavaPlugin> implements CommandExecutor, TabCompleter {
2627
//==== Error Definitions ====//
2728
private static class NotPlayerException extends RuntimeException {
@@ -111,7 +112,7 @@ public CommandReceiver(T plugin, LanguageRepository i18n) {
111112
if (!(params.length == 2 &&
112113
params[0] == CommandSender.class &&
113114
params[1] == Arguments.class)) {
114-
plugin.getLogger().warning(i18n.get("internal.error.bad_subcommand", m.toString()));
115+
plugin.getLogger().warning(i18n.getFormatted("internal.error.bad_subcommand", m.toString()));
115116
} else {
116117
m.setAccessible(true);
117118
subCommands.put(anno.value().toLowerCase(), m);
@@ -135,12 +136,12 @@ public CommandReceiver(T plugin, LanguageRepository i18n) {
135136
f.set(this, obj);
136137
}
137138
} catch (ReflectiveOperationException ex) {
138-
plugin.getLogger().warning(i18n.get("internal.error.bad_subcommand", f.toString()));
139+
plugin.getLogger().warning(i18n.getFormatted("internal.error.bad_subcommand", f.toString()));
139140
obj = null;
140141
ex.printStackTrace();
141142
}
142143
} else {
143-
plugin.getLogger().warning(i18n.get("internal.error.bad_subcommand", f.toString()));
144+
plugin.getLogger().warning(i18n.getFormatted("internal.error.bad_subcommand", f.toString()));
144145
}
145146
}
146147
}
@@ -261,9 +262,9 @@ private String getHelpContent(@LangKey(type = LangKeyType.SUFFIX, skipCheck = tr
261262
}
262263
key += "." + type;
263264
if (i18n.hasKey(key)) {
264-
return i18n.get(key);
265+
return i18n.getFormatted(key);
265266
} else {
266-
return i18n.get("manual.no_" + type);
267+
return i18n.getFormatted("manual.no_" + type);
267268
}
268269
}
269270

@@ -289,7 +290,7 @@ public static Player asPlayer(CommandSender target) {
289290
}
290291

291292
public void msg(CommandSender target, @LangKey String template, Object... args) {
292-
target.sendMessage(i18n.get(template, args));
293+
target.sendMessage(i18n.getFormatted(template, args));
293294
}
294295

295296
public static ItemStack getItemInHand(CommandSender se) {
@@ -322,6 +323,7 @@ public static ItemStack getItemInOffHand(CommandSender se) {
322323
}
323324
}
324325

326+
@SuppressWarnings("unused")
325327
public static class Arguments {
326328

327329
private List<String> parsedArguments = new ArrayList<>();

Diff for: src/main/java/cat/nyaa/nyaacore/LanguageRepository.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public void load() {
152152
plugin.getLogger().warning("Cannot save language file: " + codeName + ".yml");
153153
}
154154

155-
plugin.getLogger().info(get("internal.info.using_language", codeName));
155+
plugin.getLogger().info(getFormatted("internal.info.using_language", codeName));
156156
}
157157

158158
/**

Diff for: src/main/java/cat/nyaa/nyaacore/Message.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public Message append(String text) {
4141
}
4242

4343
public Message appendFormat(LanguageRepository i18n, @LangKey String template, Object... obj) {
44-
return append(i18n.get(template, obj));
44+
return append(i18n.getFormatted(template, obj));
4545
}
4646

4747
public Message append(ItemStack item) {

Diff for: src/main/java/cat/nyaa/nyaacore/internationalization/I18nEntity.java

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ public static String getSpawnEggName(ItemStack egg, String locale) {
148148
* @throws InvocationTargetException when either method throws an exception.
149149
* @throws IllegalAccessException when does not have access to these methods.
150150
*/
151+
@SuppressWarnings("deprecation")
151152
public static EntityType getEntityType(ItemStack egg) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
152153
Object nmsStack = Class.forName("org.bukkit.craftbukkit." + Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3] + "." + "inventory.CraftItemStack").getMethod("asNMSCopy", ItemStack.class).invoke(null, egg);
153154
Object tag = nmsStack.getClass().getMethod("getTag").invoke(nmsStack);

0 commit comments

Comments
 (0)