Migrating
Nothing has been removed yet — every old name still works as a deprecated
delegate. But @Deprecated(forRemoval = true) means they will go, so move when
convenient.
The replacement names below do not exist in 1.0.2, the current release. On
1.0.2, registerCommand and getPlayer() are the only options and this page
does not apply to you yet.
These docs describe 1.0.3 as it is being developed.
Registration: registerCommand → trackCommand
The old names were easy to mix up, which is why they were replaced:
registerCommandnever actually touched the server. It only recorded the command — the name promised more than it did.unregisterCommands()removed only reloadable commands, despite a name that reads as "remove everything".
| Deprecated | Use instead |
|---|---|
registerCommand(cmd) | trackCommand(cmd) |
registerCommands() | flushRegistrations() |
unregisterCommands() | unregisterReloadableCommands() |
// Before
this.commands.registerCommand(new HealCommand(this));
this.commands.registerCommands();
// After
this.commands.trackCommand(new HealCommand(this));
this.commands.flushRegistrations();
Dispatch: getPlayer → getSenderAsPlayer
getPlayer() returned the sender while getOptionalPlayer(name) resolved
an argument. They read as a nullable/non-null pair of one concept and were
unrelated.
| Deprecated | Use instead | Reads |
|---|---|---|
getPlayer() | getSenderAsPlayer() | the sender |
getOptionalPlayer(name) | resolvePlayer(name) | an argument |
Silencing the warnings
@Deprecated(forRemoval = true) emits a removal warning, which
@SuppressWarnings("deprecation") does not silence. You need:
@SuppressWarnings("removal")
Better to just migrate — the replacements are one-for-one.
Checklist
- Replace
registerCommand/registerCommandswithtrackCommand/flushRegistrations - Replace
unregisterCommands()withunregisterReloadableCommands() - Replace
getPlayer()withgetSenderAsPlayer(), and null-check it - Replace
getOptionalPlayer(name)withresolvePlayer(name) - Confirm you call
unregisterAll(this), notunregisterAll(), unless you really do host other plugins' commands - Rebuild and confirm relocation still applies (Shading)