2011-07-18 22:06:02 +02:00
|
|
|
package com.massivecraft.factions.struct;
|
2011-02-06 13:36:11 +01:00
|
|
|
|
2011-07-18 22:06:02 +02:00
|
|
|
import com.massivecraft.factions.Conf;
|
2015-01-22 00:58:33 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2011-02-12 18:05:05 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public enum Role {
|
2018-01-05 02:17:26 +01:00
|
|
|
ADMIN(3, TL.ROLE_ADMIN),
|
|
|
|
MODERATOR(2, TL.ROLE_MODERATOR),
|
|
|
|
NORMAL(1, TL.ROLE_NORMAL),
|
|
|
|
RECRUIT(0, TL.ROLE_RECRUIT);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
public final int value;
|
|
|
|
public final String nicename;
|
2015-01-22 00:58:33 +01:00
|
|
|
public final TL translation;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2017-12-19 11:18:13 +01:00
|
|
|
Role(final int value, final TL translation) {
|
2014-07-01 22:10:18 +02:00
|
|
|
this.value = value;
|
2015-01-22 00:58:33 +01:00
|
|
|
this.nicename = translation.toString();
|
|
|
|
this.translation = translation;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isAtLeast(Role role) {
|
|
|
|
return this.value >= role.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isAtMost(Role role) {
|
|
|
|
return this.value <= role.value;
|
|
|
|
}
|
|
|
|
|
2018-01-05 02:17:26 +01:00
|
|
|
public static Role getRelative(Role role, int relative) {
|
|
|
|
return Role.getByValue(role.value + relative);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Role getByValue(int value) {
|
|
|
|
switch (value) {
|
|
|
|
case 0:
|
|
|
|
return RECRUIT;
|
|
|
|
case 1:
|
|
|
|
return NORMAL;
|
|
|
|
case 2:
|
|
|
|
return MODERATOR;
|
2018-01-05 02:40:27 +01:00
|
|
|
case 3:
|
|
|
|
return ADMIN;
|
2018-01-05 02:17:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2018-01-05 02:37:21 +01:00
|
|
|
public static Role fromString(String check) {
|
|
|
|
switch (check.toLowerCase()) {
|
|
|
|
case "admin":
|
|
|
|
return ADMIN;
|
|
|
|
case "mod":
|
|
|
|
case "moderator":
|
|
|
|
return MODERATOR;
|
|
|
|
case "normal":
|
|
|
|
case "member":
|
|
|
|
return NORMAL;
|
|
|
|
case "recruit":
|
|
|
|
case "rec":
|
|
|
|
return RECRUIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return this.nicename;
|
|
|
|
}
|
|
|
|
|
2018-01-05 02:40:27 +01:00
|
|
|
public TL getTranslation() {
|
2015-01-22 00:58:33 +01:00
|
|
|
return translation;
|
|
|
|
}
|
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public String getPrefix() {
|
|
|
|
if (this == Role.ADMIN) {
|
|
|
|
return Conf.prefixAdmin;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this == Role.MODERATOR) {
|
|
|
|
return Conf.prefixMod;
|
|
|
|
}
|
|
|
|
|
2018-01-05 02:17:26 +01:00
|
|
|
if (this == Role.NORMAL) {
|
|
|
|
return Conf.prefixNormal;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this == Role.RECRUIT) {
|
|
|
|
return Conf.prefixRecruit;
|
|
|
|
}
|
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
return "";
|
|
|
|
}
|
2011-02-06 13:36:11 +01:00
|
|
|
}
|