-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support outdated md5 chat libs in component parser
Fixes #357
- Loading branch information
1 parent
d0ba292
commit 7dd0ed2
Showing
2 changed files
with
47 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
core/src/main/java/com/rexcantor64/triton/utils/ModernComponentGetters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.rexcantor64.triton.utils; | ||
|
||
import net.md_5.bungee.api.chat.BaseComponent; | ||
import net.md_5.bungee.api.chat.KeybindComponent; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Avoid loading "modern" (as in, not 1.8.8) md_5's chat library classes on old Spigot versions. | ||
* This will be removed in Triton v4 (where Adventure is used instead). | ||
*/ | ||
public class ModernComponentGetters { | ||
|
||
public static Optional<String> getKeybind(BaseComponent component) { | ||
if (component instanceof KeybindComponent) { | ||
return Optional.ofNullable(((KeybindComponent) component).getKeybind()); | ||
} | ||
return Optional.empty(); | ||
} | ||
|
||
public static BaseComponent newKeybindComponent(String keybind) { | ||
return new KeybindComponent(keybind); | ||
} | ||
|
||
} |