EDIT: considering refactoring, as I've added PvPRank class(this snippet does not contain the updates yet)
TODO: refactor client rights management, will update
(If you don't want to wait, I'm sure plenty of you have the capabilities to refactor the data in the client, I believe in you)
If it helps anyone build on the idea, current idea is that Staff chat icons will be mandatory, unique rank icons(only 1 visible) will be optional..
With this, another idea is the possibility of people having a maximum of 2 chat icons...
I.E. (donor icon) (mod icon) username: chat example
I.E. (youtube) (super donor) username: I like turtles
The reason I'm posting this thread "incomplete" is that there's a whole lot of possibilities as to how the ranks/rights can be displayed/handled.
This is a 'decent' starting place, I think, a general base to be expanded upon. The hierarchy of the previous format was just awful, and I've never liked it.
Unique rights such as donator ranks in my opinion, should be completely separated from anything involving actual staff rights and management.
Blah blah, anyways, I'd like to point out that when I say "incomplete", it's really just properly using the data client sided that needs to be done...
If you're lazy or a minimalist, and don't want to expand further on this, that can be done easily by just replacing the field "myPrivilege" and where it's called.
Note: it may look like a good bit with the spoilers, and all that jazz...
But, if ya' click them, you'll see they actually are tiny lil 'snippets'. :p:whistle:
/**
* @author Elliot Hayes - "Lumiere" <br> [email protected]
* <br> <a href="https://www.rune-server.ee/members/lumiere/">Rune-Server Profile</a>
*/
public final class PlayerRights {
/**
* The {@link StaffRank} of the {@link #player}
*/
private final StaffRank staffRank;
/**
* An {@link ArrayList} containing every {@link UniqueRank} of the {@link #player}
*/
private final ArrayList<UniqueRank> uniqueRanks;
/**
* Constructs a new {@link PlayerRights} instance
*
* @[Only registered and activated users can see links. Click Here To Register...] staffRank
* @[Only registered and activated users can see links. Click Here To Register...] uniqueRanks
*/
public PlayerRights(StaffRank staffRank, ArrayList<UniqueRank> uniqueRanks) {
this.staffRank = staffRank;
this.uniqueRanks = uniqueRanks;
}
/**
* Gets the {@link #staffRank} of the {@link PlayerRights}
*
* @[Only registered and activated users can see links. Click Here To Register...] {@link #staffRank}
*/
public final StaffRank getStaffRank() {
return staffRank;
}
/**
* Gets the {@link #uniqueRanks} of the {@link PlayerRights}
*
* @[Only registered and activated users can see links. Click Here To Register...] {@link #uniqueRanks}
*/
public final ArrayList<UniqueRank> getUniqueRanks() {
return uniqueRanks;
}
}
Spoiler for Getter/Setter for Player:
Code:
public final PlayerRights getPlayerRights() {
return playerRights;
}
public final PlayerAttribute setPlayerRights(PlayerRights playerRights) {
this.playerRights = playerRights;
return this;
}
public final PlayerAttribute setPlayerRights(StaffRank staffRank, ArrayList<UniqueRank> arrayList) {
this.playerRights = new PlayerRights(staffRank, arrayList);
return this;
}
IN "LoginResponsePacket" CLASS, ENSURE THAT IT USES THE NEW "PlayerRights" CLASS
Spoiler for PlayerSession:
Code:
//Write the response and flush the channel
ChannelFuture future = channel.writeAndFlush(new LoginResponsePacket(response, player.getAttribute().getPlayerRights()));
Quick and simple way to test the data sent to client, add this above the call to the 'LoginResponses.evaluate()' method
Have yet to properly implement commands or anything to assign values to these things, so this is the easy route
Code:
//TODO for testing purposes, remove at later date
final ArrayList<UniqueRank> uniqueRanks = new ArrayList<UniqueRank>();
uniqueRanks.addAll( Sets.immutableEnumSet( UniqueRank.DIAMOND_SUPPORTER, UniqueRank.YOUTUBER ) );
if ( player.getUsername().equalsIgnoreCase( "lumiere" ) )
player.getAttribute().setPlayerRights( StaffRank.DEVELOPER, uniqueRanks );
To "finish" up, you need to handle the data received by the client, I still need to replace where 'myPrivilege' is called, remove the field, etcetc
So, with that being said, as you can see for testing purposes, I'm still assigning myPrivilege a value, as it is still being used...
And I just made the field for the Staff rank an integer in the Player class
final int totalUniqueRights = socketStream.read();
for (int i = 0; i < totalUniqueRights; i++ )
localPlayer.getUniqueRights().add( socketStream.read() );
Feel free to make changes where necessary... For example; some prefer "Donator" over "Supporter", just change the names.
EDIT: Right now, you could use StaffRank.ordinal(), and the values should match, 0 = player, 1 = mod, so on..
However in doing so, you won't have any ranks above Dev/Owner(3), and so what is left is implementing UniqueRights separately and their chat icons in the Client.