-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Team color support to use in newer mc versions #43
Added Team color support to use in newer mc versions #43
Conversation
@@ -110,16 +112,29 @@ private void addTeamEntry(Player target, Player all, IPermissionGroup permission | |||
if (team == null) team = all.getScoreboard().registerNewTeam(teamName); | |||
|
|||
try { | |||
Optional<Method> setColor = Optional.ofNullable(team.getClass().getDeclaredMethod("setColor", ChatColor.class)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getDeclaredMethod() will never return Null, you could remove the optional. You can also cache the field, you dont need to request it everytime.
if (setColor.isPresent()) { | ||
Method method = setColor.get(); | ||
method.setAccessible(true); | ||
if (permissionGroup.getColor().length() != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nullcheck would be better here, dont check the length
import java.lang.reflect.Method; | ||
import java.util.Optional; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this import is unused
String suffix = permissionGroup.getSuffix(); | ||
|
||
if (color != null && !color.isEmpty()) | ||
method.invoke(team, ChatColor.getByChar(color.replaceAll("&", "").replaceAll("§", ""))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check if the ChatColor is null or not, and add brackets after the if-statement.
if (color != null) { | ||
permissionGroup.setColor(color); | ||
CloudPermissionsPermissionManagement.getInstance().updateGroup(permissionGroup); | ||
method.invoke(team, ChatColor.getByChar(color.replaceAll("&", "").replaceAll("§", ""))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also check if the chatcolor is null
Fixed white color name in mc version 1.13-1.14 issue
Perhaps prefix now can contain 2 other chars instead of the two player name color codes