96 lines
2.1 KiB
Java
96 lines
2.1 KiB
Java
package com.massivecraft.factions.struct;
|
|
|
|
import com.massivecraft.factions.Conf;
|
|
import com.massivecraft.factions.zcore.util.TL;
|
|
|
|
public enum Role {
|
|
ADMIN(3, TL.ROLE_ADMIN),
|
|
MODERATOR(2, TL.ROLE_MODERATOR),
|
|
NORMAL(1, TL.ROLE_NORMAL),
|
|
RECRUIT(0, TL.ROLE_RECRUIT);
|
|
|
|
public final int value;
|
|
public final String nicename;
|
|
public final TL translation;
|
|
|
|
Role(final int value, final TL translation) {
|
|
this.value = value;
|
|
this.nicename = translation.toString();
|
|
this.translation = translation;
|
|
}
|
|
|
|
public boolean isAtLeast(Role role) {
|
|
return this.value >= role.value;
|
|
}
|
|
|
|
public boolean isAtMost(Role role) {
|
|
return this.value <= role.value;
|
|
}
|
|
|
|
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;
|
|
case 3:
|
|
return ADMIN;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return this.nicename;
|
|
}
|
|
|
|
public TL getTranslation() {
|
|
return translation;
|
|
}
|
|
|
|
public String getPrefix() {
|
|
if (this == Role.ADMIN) {
|
|
return Conf.prefixAdmin;
|
|
}
|
|
|
|
if (this == Role.MODERATOR) {
|
|
return Conf.prefixMod;
|
|
}
|
|
|
|
if (this == Role.NORMAL) {
|
|
return Conf.prefixNormal;
|
|
}
|
|
|
|
if (this == Role.RECRUIT) {
|
|
return Conf.prefixRecruit;
|
|
}
|
|
|
|
return "";
|
|
}
|
|
}
|