API cleanup: Associate all group check types with their bypass

permissions.
This commit is contained in:
asofold 2012-11-03 09:33:10 +01:00
parent 01a8fe94ec
commit b8f886f59c
2 changed files with 75 additions and 60 deletions

View File

@ -40,9 +40,9 @@ import fr.neatmonster.nocheatplus.players.Permissions;
* Type of checks (containing configuration and dataFactory classes, name and permission). * Type of checks (containing configuration and dataFactory classes, name and permission).
*/ */
public enum CheckType { public enum CheckType {
ALL, ALL(Permissions.CHECKS),
BLOCKBREAK(BlockBreakConfig.factory, BlockBreakData.factory), BLOCKBREAK(BlockBreakConfig.factory, BlockBreakData.factory, Permissions.BLOCKBREAK),
BLOCKBREAK_DIRECTION(BLOCKBREAK, Permissions.BLOCKBREAK_DIRECTION), BLOCKBREAK_DIRECTION(BLOCKBREAK, Permissions.BLOCKBREAK_DIRECTION),
BLOCKBREAK_FASTBREAK(BLOCKBREAK, Permissions.BLOCKBREAK_FASTBREAK), BLOCKBREAK_FASTBREAK(BLOCKBREAK, Permissions.BLOCKBREAK_FASTBREAK),
BLOCKBREAK_FREQUENCY(BLOCKBREAK, Permissions.BLOCKBREAK_FREQUENCY), BLOCKBREAK_FREQUENCY(BLOCKBREAK, Permissions.BLOCKBREAK_FREQUENCY),
@ -50,18 +50,18 @@ public enum CheckType {
BLOCKBREAK_REACH(BLOCKBREAK, Permissions.BLOCKBREAK_REACH), BLOCKBREAK_REACH(BLOCKBREAK, Permissions.BLOCKBREAK_REACH),
BLOCKBREAK_WRONGBLOCK(BLOCKBREAK, Permissions.BLOCKBREAK_WRONGBLOCK), BLOCKBREAK_WRONGBLOCK(BLOCKBREAK, Permissions.BLOCKBREAK_WRONGBLOCK),
BLOCKINTERACT(BlockInteractConfig.factory, BlockInteractData.factory), BLOCKINTERACT(BlockInteractConfig.factory, BlockInteractData.factory, Permissions.BLOCKINTERACT),
BLOCKINTERACT_DIRECTION(BLOCKINTERACT, Permissions.BLOCKINTERACT_DIRECTION), BLOCKINTERACT_DIRECTION(BLOCKINTERACT, Permissions.BLOCKINTERACT_DIRECTION),
BLOCKINTERACT_REACH(BLOCKINTERACT, Permissions.BLOCKINTERACT_REACH), BLOCKINTERACT_REACH(BLOCKINTERACT, Permissions.BLOCKINTERACT_REACH),
BLOCKPLACE(BlockPlaceConfig.factory, BlockPlaceData.factory), BLOCKPLACE(BlockPlaceConfig.factory, BlockPlaceData.factory, Permissions.BLOCKPLACE),
BLOCKPLACE_DIRECTION(BLOCKPLACE, Permissions.BLOCKPLACE_DIRECTION), BLOCKPLACE_DIRECTION(BLOCKPLACE, Permissions.BLOCKPLACE_DIRECTION),
BLOCKPLACE_FASTPLACE(BLOCKPLACE, Permissions.BLOCKPLACE_FASTPLACE), BLOCKPLACE_FASTPLACE(BLOCKPLACE, Permissions.BLOCKPLACE_FASTPLACE),
BLOCKPLACE_NOSWING(BLOCKPLACE, Permissions.BLOCKPLACE_NOSWING), BLOCKPLACE_NOSWING(BLOCKPLACE, Permissions.BLOCKPLACE_NOSWING),
BLOCKPLACE_REACH(BLOCKPLACE, Permissions.BLOCKBREAK_REACH), BLOCKPLACE_REACH(BLOCKPLACE, Permissions.BLOCKBREAK_REACH),
BLOCKPLACE_SPEED(BLOCKPLACE, Permissions.BLOCKPLACE_SPEED), BLOCKPLACE_SPEED(BLOCKPLACE, Permissions.BLOCKPLACE_SPEED),
CHAT(ChatConfig.factory, ChatData.factory), CHAT(ChatConfig.factory, ChatData.factory, Permissions.CHAT),
CHAT_CAPTCHA(CHAT, Permissions.CHAT_CAPTCHA), CHAT_CAPTCHA(CHAT, Permissions.CHAT_CAPTCHA),
CHAT_COLOR(CHAT, Permissions.CHAT_COLOR), CHAT_COLOR(CHAT, Permissions.CHAT_COLOR),
CHAT_COMMANDS(CHAT, Permissions.CHAT_COMMANDS), CHAT_COMMANDS(CHAT, Permissions.CHAT_COMMANDS),
@ -70,10 +70,10 @@ public enum CheckType {
CHAT_RELOG(CHAT, Permissions.CHAT_RELOG), CHAT_RELOG(CHAT, Permissions.CHAT_RELOG),
COMBINED(CombinedConfig.factory, CombinedData.factory), COMBINED(CombinedConfig.factory, CombinedData.factory, Permissions.COMBINED),
COMBINED_IMPROBABLE(COMBINED, Permissions.COMBINED_IMPROBABLE), COMBINED_IMPROBABLE(COMBINED, Permissions.COMBINED_IMPROBABLE),
FIGHT(FightConfig.factory, FightData.factory), FIGHT(FightConfig.factory, FightData.factory, Permissions.FIGHT),
FIGHT_ANGLE(FIGHT, Permissions.FIGHT_ANGLE), FIGHT_ANGLE(FIGHT, Permissions.FIGHT_ANGLE),
FIGHT_CRITICAL(FIGHT, Permissions.FIGHT_CRITICAL), FIGHT_CRITICAL(FIGHT, Permissions.FIGHT_CRITICAL),
FIGHT_DIRECTION(FIGHT, Permissions.FIGHT_DIRECTION), FIGHT_DIRECTION(FIGHT, Permissions.FIGHT_DIRECTION),
@ -84,14 +84,14 @@ public enum CheckType {
FIGHT_SELFHIT(FIGHT, Permissions.FIGHT_SELFHIT), FIGHT_SELFHIT(FIGHT, Permissions.FIGHT_SELFHIT),
FIGHT_SPEED(FIGHT, Permissions.FIGHT_SPEED), FIGHT_SPEED(FIGHT, Permissions.FIGHT_SPEED),
INVENTORY(InventoryConfig.factory, InventoryData.factory), INVENTORY(InventoryConfig.factory, InventoryData.factory, Permissions.INVENTORY),
INVENTORY_DROP(INVENTORY, Permissions.INVENTORY_DROP), INVENTORY_DROP(INVENTORY, Permissions.INVENTORY_DROP),
INVENTORY_FASTCLICK(INVENTORY, Permissions.INVENTORY_FASTCLICK), INVENTORY_FASTCLICK(INVENTORY, Permissions.INVENTORY_FASTCLICK),
INVENTORY_INSTANTBOW(INVENTORY, Permissions.INVENTORY_INSTANTBOW), INVENTORY_INSTANTBOW(INVENTORY, Permissions.INVENTORY_INSTANTBOW),
INVENTORY_INSTANTEAT(INVENTORY, Permissions.INVENTORY_INSTANTEAT), INVENTORY_INSTANTEAT(INVENTORY, Permissions.INVENTORY_INSTANTEAT),
INVENTORY_ITEMS(INVENTORY, Permissions.INVENTORY_ITEMS), INVENTORY_ITEMS(INVENTORY, Permissions.INVENTORY_ITEMS),
MOVING(MovingConfig.factory, MovingData.factory), MOVING(MovingConfig.factory, MovingData.factory, Permissions.MOVING),
MOVING_CREATIVEFLY(MOVING, Permissions.MOVING_CREATIVEFLY), MOVING_CREATIVEFLY(MOVING, Permissions.MOVING_CREATIVEFLY),
MOVING_MOREPACKETS(MOVING, Permissions.MOVING_MOREPACKETS), MOVING_MOREPACKETS(MOVING, Permissions.MOVING_MOREPACKETS),
MOVING_MOREPACKETSVEHICLE(MOVING, Permissions.MOVING_MOREPACKETSVEHICLE), MOVING_MOREPACKETSVEHICLE(MOVING, Permissions.MOVING_MOREPACKETSVEHICLE),
@ -101,50 +101,65 @@ public enum CheckType {
UNKNOWN; UNKNOWN;
/** The group. */ /** If not null, this is the check group usually. */
private CheckType parent = null; private final CheckType parent;
/** The configFactory. */ /** The check config factory (access CheckConfig instances by CheckType). */
private CheckConfigFactory configFactory = null; private final CheckConfigFactory configFactory;
/** The dataFactory. */ /** The check data factory (access CheckData instances by CheckType). */
private CheckDataFactory dataFactory = null; private final CheckDataFactory dataFactory;
/** The permission. */ /** The bypass permission. */
private String permission = null; private final String permission;
/** /**
* Instantiates a new check type. * Special purpose check types (likely not actual checks).
*/ */
private CheckType() {} private CheckType() {
this(null, null, null);
}
/**
* Special purpose for grouping (ALL).
* @param permission
*/
private CheckType(final String permission){
this(null, null, permission);
}
/**
* Constructor for root checks or check groups, that are not grouped under another check type.
* @param configFactory
* @param dataFactory
* @param permission
*/
private CheckType(final CheckConfigFactory configFactory, final CheckDataFactory dataFactory, final String permission) {
this(null, permission, configFactory, dataFactory);
}
/** /**
* Instantiates a new check type. * Constructor for sub-checks grouped under another check type.
* * @param parent
* @param configFactory * @param permission
* the configFactory */
* @param dataFactory private CheckType(final CheckType parent, final String permission) {
* the dataFactory this(parent, permission, parent.getConfigFactory(), parent.getDataFactory());
*/ }
private CheckType(final CheckConfigFactory configFactory, final CheckDataFactory dataFactory) {
this.configFactory = configFactory;
this.dataFactory = dataFactory;
}
/** /**
* Instantiates a new check type. * Root constructor.
* * @param parent Super check type (usually the group).
* @param parent * @param permission Bypass permission.
* the parent * @param configFactory Check config factory.
* @param permission * @param dataFactory Check data factory.
* the permission */
*/ private CheckType(final CheckType parent, final String permission, final CheckConfigFactory configFactory, final CheckDataFactory dataFactory) {
private CheckType(final CheckType parent, final String permission) { this.parent = parent;
this.parent = parent; this.permission = permission;
configFactory = parent.getConfigFactory(); this.configFactory = configFactory;
dataFactory = parent.getDataFactory(); this.dataFactory = dataFactory;
this.permission = permission; }
}
/** /**
* Gets the configFactory. * Gets the configFactory.
@ -183,7 +198,7 @@ public enum CheckType {
} }
/** /**
* Gets the permission. * Gets the bypass permission for this check type.
* *
* @return the permission * @return the permission
*/ */

View File

@ -52,7 +52,7 @@ public class Permissions {
// Permissions for the individual checks. // Permissions for the individual checks.
private static final String CHECKS = NOCHEATPLUS + ".checks"; public static final String CHECKS = NOCHEATPLUS + ".checks";
/* /*
* 888 88b, 888 888 888 88b, 888 * 888 88b, 888 888 888 88b, 888
@ -61,7 +61,7 @@ public class Permissions {
* 888 88b, 888 Y888 888P Y888 , 888 b 888 88b, 888 888 , ,ee 888 888 b * 888 88b, 888 Y888 888P Y888 , 888 b 888 88b, 888 888 , ,ee 888 888 b
* 888 88P' 888 "88 88" "88,e8' 888 8b 888 88P' 888 "YeeP" "88 888 888 8b * 888 88P' 888 "88 88" "88,e8' 888 8b 888 88P' 888 "YeeP" "88 888 888 8b
*/ */
private static final String BLOCKBREAK = CHECKS + ".blockbreak"; public static final String BLOCKBREAK = CHECKS + ".blockbreak";
public static final String BLOCKBREAK_BREAK = BLOCKBREAK + ".break"; public static final String BLOCKBREAK_BREAK = BLOCKBREAK + ".break";
public static final String BLOCKBREAK_BREAK_LIQUID = BLOCKBREAK_BREAK + ".liquid"; public static final String BLOCKBREAK_BREAK_LIQUID = BLOCKBREAK_BREAK + ".liquid";
public static final String BLOCKBREAK_DIRECTION = BLOCKBREAK + ".direction"; public static final String BLOCKBREAK_DIRECTION = BLOCKBREAK + ".direction";
@ -78,7 +78,7 @@ public class Permissions {
* 888 88b, 888 Y888 888P Y888 , 888 b 888 888 888 888 888 , 888 ,ee 888 Y888 , 888 * 888 88b, 888 Y888 888P Y888 , 888 b 888 888 888 888 888 , 888 ,ee 888 Y888 , 888
* 888 88P' 888 "88 88" "88,e8' 888 8b 888 888 888 888 "YeeP" 888 "88 888 "88,e8' 888 * 888 88P' 888 "88 88" "88,e8' 888 8b 888 888 888 888 "YeeP" 888 "88 888 "88,e8' 888
*/ */
private static final String BLOCKINTERACT = CHECKS + ".blockinteract"; public static final String BLOCKINTERACT = CHECKS + ".blockinteract";
public static final String BLOCKINTERACT_DIRECTION = BLOCKINTERACT + ".direction"; public static final String BLOCKINTERACT_DIRECTION = BLOCKINTERACT + ".direction";
public static final String BLOCKINTERACT_REACH = BLOCKINTERACT + ".reach"; public static final String BLOCKINTERACT_REACH = BLOCKINTERACT + ".reach";
@ -89,9 +89,9 @@ public class Permissions {
* 888 88b, 888 Y888 888P Y888 , 888 b 888 888 ,ee 888 Y888 , 888 , * 888 88b, 888 Y888 888P Y888 , 888 b 888 888 ,ee 888 Y888 , 888 ,
* 888 88P' 888 "88 88" "88,e8' 888 8b 888 888 "88 888 "88,e8' "YeeP" * 888 88P' 888 "88 88" "88,e8' 888 8b 888 888 "88 888 "88,e8' "YeeP"
*/ */
private static final String BLOCKPLACE = CHECKS + ".blockplace"; public static final String BLOCKPLACE = CHECKS + ".blockplace";
public static final String BLOCKPLACE_AGAINST = BLOCKPLACE + ".against"; public static final String BLOCKPLACE_AGAINST = BLOCKPLACE + ".against";
public static final String BLOCKPLACE_AGAINST_AIR = BLOCKPLACE_AGAINST + ".air"; public static final String BLOCKPLACE_AGAINST_AIR = BLOCKPLACE_AGAINST + ".air";
public static final String BLOCKPLACE_AGAINST_LIQUIDS = BLOCKPLACE_AGAINST + ".liquids"; public static final String BLOCKPLACE_AGAINST_LIQUIDS = BLOCKPLACE_AGAINST + ".liquids";
public static final String BLOCKPLACE_DIRECTION = BLOCKPLACE + ".direction"; public static final String BLOCKPLACE_DIRECTION = BLOCKPLACE + ".direction";
public static final String BLOCKPLACE_FASTPLACE = BLOCKPLACE + ".fastplace"; public static final String BLOCKPLACE_FASTPLACE = BLOCKPLACE + ".fastplace";
@ -106,19 +106,19 @@ public class Permissions {
* Y888 ,d 888 888 ,ee 888 888 * Y888 ,d 888 888 ,ee 888 888
* "88,d88 888 888 "88 888 888 * "88,d88 888 888 "88 888 888
*/ */
private static final String CHAT = CHECKS + ".chat"; public static final String CHAT = CHECKS + ".chat";
public static final String CHAT_CAPTCHA = CHAT + ".captcha"; public static final String CHAT_CAPTCHA = CHAT + ".captcha";
public static final String CHAT_COLOR = CHAT + ".color"; public static final String CHAT_COLOR = CHAT + ".color";
public static final String CHAT_COMMANDS = CHAT + ".commands"; public static final String CHAT_COMMANDS = CHAT + ".commands";
public static final String CHAT_TEXT = CHAT + ".text"; public static final String CHAT_TEXT = CHAT + ".text";
public static final String CHAT_LOGINS = CHAT + ".logins"; public static final String CHAT_LOGINS = CHAT + ".logins";
public static final String CHAT_RELOG = CHAT + ".relog"; public static final String CHAT_RELOG = CHAT + ".relog";
/* /*
* Combined ! * Combined !
*/ */
private static final String COMBINED = CHECKS + ".combined"; public static final String COMBINED = CHECKS + ".combined";
public static final String COMBINED_IMPROBABLE = COMBINED + ".improbable"; public static final String COMBINED_IMPROBABLE = COMBINED + ".improbable";
/* /*
* 888'Y88 ,e, 888 d8 * 888'Y88 ,e, 888 d8
@ -129,7 +129,7 @@ public class Permissions {
* , 88P * , 88P
* "8",P" * "8",P"
*/ */
private static final String FIGHT = CHECKS + ".fight"; public static final String FIGHT = CHECKS + ".fight";
public static final String FIGHT_ANGLE = FIGHT + ".angle"; public static final String FIGHT_ANGLE = FIGHT + ".angle";
public static final String FIGHT_CRITICAL = FIGHT + ".critical"; public static final String FIGHT_CRITICAL = FIGHT + ".critical";
public static final String FIGHT_DIRECTION = FIGHT + ".direction"; public static final String FIGHT_DIRECTION = FIGHT + ".direction";
@ -149,7 +149,7 @@ public class Permissions {
* 888 * 888
* 888 * 888
*/ */
private static final String INVENTORY = CHECKS + ".inventory"; public static final String INVENTORY = CHECKS + ".inventory";
public static final String INVENTORY_DROP = INVENTORY + ".drop"; public static final String INVENTORY_DROP = INVENTORY + ".drop";
public static final String INVENTORY_FASTCLICK = INVENTORY + ".fastclick"; public static final String INVENTORY_FASTCLICK = INVENTORY + ".fastclick";
public static final String INVENTORY_INSTANTBOW = INVENTORY + ".instantbow"; public static final String INVENTORY_INSTANTBOW = INVENTORY + ".instantbow";
@ -165,7 +165,7 @@ public class Permissions {
* , 88P * , 88P
* "8",P" * "8",P"
*/ */
private static final String MOVING = CHECKS + ".moving"; public static final String MOVING = CHECKS + ".moving";
public static final String MOVING_BOATSANYWHERE = MOVING + ".boatsanywhere"; public static final String MOVING_BOATSANYWHERE = MOVING + ".boatsanywhere";
public static final String MOVING_CREATIVEFLY = MOVING + ".creativefly"; public static final String MOVING_CREATIVEFLY = MOVING + ".creativefly";
public static final String MOVING_MOREPACKETS = MOVING + ".morepackets"; public static final String MOVING_MOREPACKETS = MOVING + ".morepackets";