PDA

View Full Version : (317-377) Ranks



Shaun
July 4th, 2010, 11:09
Why do people use integers for ranks that they need to explicitly check later? I don't get it. This is far simpler and more intuitive, in my opinion.


/**
* Contain/handle possible player ranks
*
* @author Shaun
*
*/
public enum Rank
{
GUEST(0),
MEMBER(0),
MODERATOR(1),
ADMINISTRATOR(2),
DEVELOPER(2),
OWNER(2);

private final int CROWN_LEVEL; // crown level of the rank (0-2, normal being the lowest, admin crown the highest)

/**
* Initiate rank
*
* @param crownLevel
* crown level of the rank (0-2, normal being the lowest, admin
* crown the highest)
*/
Rank(int crownLevel)
{
this.CROWN_LEVEL = crownLevel;
}

/**
* @return staff/crown level of the rank
*/
public int getCrownLevel()
{
return CROWN_LEVEL;
}
}
Note that they are ordered by importance, least to greatest.

Oh, you might want to add
Rank playerRank; to Player.java and in the constructor set to
playerRank = Rank.GUEST;
Oh yeah, we need to fix the crowns now.
In Client, find
handler.players[i2].sendpm(Misc.playerNameToInt64(playerName) in packet 126 (PMs) and replace that line with
handler.players[i2].sendpm(Misc.playerNameToInt64(playerName), playerRank.getCrownLevel(), pmchatText, pmchatTextSize);
then in void run where you write the playerLevel, replace that with
out.write(playerRank.getCrownLevel());

Z0MG how do I SAIVE AND LOED NAOOO???
Simple.

characterfile.write("character-rank = ", 0, 17);
characterfile.write(c.playerRank.toString(), 0, c.playerRank.toString().length());
characterfile.newLine();

else if (token.equals("character-rank"))
{
c.playerRank = Rank.valueOf(token2);
}
So now, lets pretend we want to print someone's rank(admin, mod, etc). Instead of checking playerLevel == 1, mod, we just print out the playerRank.toString()

Need something to be mod up?

if (playerRank.getCrownLevel() >= 1)

What about owner of dev only?

if (playerRank == Rank.OWNER)

if (playerRank == Rank.DEVELOPER)

YAY!

Chick
July 7th, 2010, 10:29
Thats Hard lol Ill pass.

bluefire
July 8th, 2010, 13:20
nice! 7.5/10 kinda messy but very nice!

Mohammad
July 10th, 2010, 14:22
Thats Hard lol Ill pass.

If you think that's hard i suggest you to pass in life too what a fail.

Good job it's really good for beginners!

-V.
July 11th, 2010, 10:49
What the fuck is a "Guest"?

Mish
July 11th, 2010, 10:54
What the fuck is a "Guest"?
Yeah wtf lol.

Relapse
July 11th, 2010, 15:51
You could look at it a couple of ways.

1.Guest is someone thats really new to the server... lets say has only played for a day or two. Its different from a member who is dedicated, you would want to differentiate the two so if you were looking for staff you would rather choose a dedicated member over a new person.

2. Guest = non donators (Ftp)
Members = donators (P2p)

Thats just the way I see it

e-scape
July 11th, 2010, 15:54
But actually this seems too much of a hassle to do. It definitely looks alot nicer, but is it really better. It does the same thing.

Aaron
July 11th, 2010, 16:07
Very nice, 8/10;)

Shaun
July 14th, 2010, 16:19
@Above
Thanks!