Remove hashcode dependence

This commit is contained in:
AlexTheCoder 2017-08-02 19:17:57 -04:00
parent d390a9a492
commit 9c5e5457f5
3 changed files with 7 additions and 7 deletions

View File

@ -25,7 +25,7 @@ public class GroupPermission
return false;
}
return _identifier.hashCode() == ((GroupPermission)o)._identifier.hashCode();
return _identifier.equals(((GroupPermission)o)._identifier);
}
public static GroupPermission of(String identifier)

View File

@ -2,9 +2,9 @@ package mineplex.core.account.permissions;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import org.bukkit.ChatColor;
@ -16,7 +16,7 @@ public class PermissionGroup
private final ChatColor _color;
private final int _forumId;
private final boolean _canBePrimary;
private final Set<Integer> _inherited;
private final Set<String> _inherited;
public PermissionGroup(String identifier, String display, String description, ChatColor color, int forumId, boolean canBePrimary, String... inherited)
{
@ -26,7 +26,7 @@ public class PermissionGroup
_color = Objects.requireNonNull(color, "Group color cannot be null");
_forumId = forumId;
_canBePrimary = canBePrimary;
_inherited = Collections.unmodifiableSet(Arrays.asList(inherited).stream().map(i -> i.hashCode()).collect(Collectors.toSet()));
_inherited = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(inherited)));
}
public String getIdentifier()
@ -81,7 +81,7 @@ public class PermissionGroup
public boolean inherits(PermissionGroup group)
{
return _inherited.contains(group._id.hashCode());
return _inherited.contains(group._id);
}
@Override
@ -104,6 +104,6 @@ public class PermissionGroup
return false;
}
return ((PermissionGroup)o)._id.hashCode() == _id.hashCode();
return ((PermissionGroup)o)._id.equals(_id);
}
}

View File

@ -163,7 +163,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
_clientManager.loadClientByName(name, loadedClient ->
{
if (rank.getIdentifier().equals("player") || loadedClient.getPrimaryGroup().getIdentifier().equals("player") || !_clientManager.getPermissionManager().inheritsFully(loadedClient.getPrimaryGroup(), rank) || loadedClient.getPrimaryGroup().hashCode() == rank.hashCode())
if (rank.getIdentifier().equals("player") || loadedClient.getPrimaryGroup().getIdentifier().equals("player") || !_clientManager.getPermissionManager().inheritsFully(loadedClient.getPrimaryGroup(), rank) || loadedClient.getPrimaryGroup().equals(rank))
{
_clientManager.setPrimaryGroup(client.getAccountId(), rank, () -> _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.getIdentifier() + "Permanent", 1, true));