Skip to content
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

Merged
merged 5 commits into from
Jul 12, 2019
Merged

Added Team color support to use in newer mc versions #43

merged 5 commits into from
Jul 12, 2019

Conversation

florianpreuss
Copy link
Contributor

  • Added property "color" to permission groups
  • Added team color support to use into newer mc versions

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

@@ -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));
Copy link
Contributor

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) {
Copy link
Contributor

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;
Copy link
Contributor

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("§", "")));
Copy link
Contributor

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("§", "")));
Copy link
Contributor

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

@juliarn juliarn merged commit dcabd0a into CloudNetService:development Jul 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants