com.sk89q.worldguard.protection.flags.DefaultFlag Java Examples

The following examples show how to use com.sk89q.worldguard.protection.flags.DefaultFlag. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HookWorldGuard_V6_1.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
public static void registerFlags(Expansion expansion) {
    try {
        Class<?> class_DefaultFlag = DefaultFlag.class;
        Class<?> class_Field = Field.class;

        final Flag<?>[] defaultFlagList = DefaultFlag.flagsList;
        int defaultFlagListLength = defaultFlagList.length;

        Flag<?>[] flagArray = new Flag[defaultFlagListLength + 2];
        System.arraycopy(defaultFlagList, 0, flagArray, 0, defaultFlagListLength);
        flagArray[defaultFlagListLength] = mobCombatFlag;
        flagArray[defaultFlagListLength + 1] = noTaggingFlag;

        Field field_DefaultFlag_flagsList = class_DefaultFlag.getField("flagsList");
        Field field_Field_modifiers = class_Field.getDeclaredField("modifiers");
        field_Field_modifiers.setAccessible(true);
        field_Field_modifiers.setInt(field_DefaultFlag_flagsList, field_DefaultFlag_flagsList.getModifiers() & ~Modifier.FINAL);
        field_DefaultFlag_flagsList.set(null, flagArray);
    } catch(ReflectiveOperationException ex) {
        Logger logger = expansion.getLogger();
        logger.log(Level.WARNING, "An error occurred while trying to register WorldGuard flags.", ex);
    }
}
 
Example #2
Source File: DependencyManager.java    From NovaGuilds with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void run() throws Exception {
	if(!Config.REGION_WORLDGUARD.getBoolean()) {
		LoggerUtils.info("Skipping WorldGuardFlag Injector. Disabled in config");
		return;
	}

	plugin.getRegionManager().createWorldGuardFlag();
	FieldAccessor<Flag[]> defaultFlagFlagListField = Reflections.getField(DefaultFlag.class, "flagsList", Flag[].class);
	defaultFlagFlagListField.setNotFinal();
	Flag[] array = defaultFlagFlagListField.get(null);
	List<Flag> list = new ArrayList<>();
	Collections.addAll(list, array);
	list.add((StateFlag) RegionManager.WORLDGUARD_FLAG);
	defaultFlagFlagListField.set(list.toArray(new Flag[list.size()]));
	LoggerUtils.info("Successfully injected WorldGuard Flag");
}
 
Example #3
Source File: WorldGuardHandler.java    From Shopkeepers with GNU General Public License v3.0 6 votes vote down vote up
public static boolean isShopAllowed(Player player, Location loc) {
	Plugin plugin = getPlugin();
	if (plugin != null) {
		WorldGuardPlugin wgPlugin = (WorldGuardPlugin) plugin;
		boolean allowShopFlag = wgPlugin.getRegionManager(loc.getWorld()).getApplicableRegions(loc).testState(null, DefaultFlag.ENABLE_SHOP);
		if (Settings.requireWorldGuardAllowShopFlag) {
			// allow shops ONLY in regions with the ENABLE_SHOP flag set:
			return allowShopFlag;
		} else {
			// allow shops in regions where the ENABLE_SHOP flag is set OR the player can build:
			return allowShopFlag || wgPlugin.canBuild(player, loc);
		}
	} else {
		return true;
	}
}
 
Example #4
Source File: HookWorldGuard_V6_2.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public static boolean allowsPVP(Location location) {
    ApplicableRegionSet regions = getRegions(location);
    StateFlag.State state = regions.queryState(null, DefaultFlag.PVP);
    return (state != StateFlag.State.DENY);
}
 
Example #5
Source File: HookWorldGuard_V6_1.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public static boolean allowsPVP(Location location) {
    ApplicableRegionSet regions = getRegions(location);
    StateFlag.State state = regions.queryState(null, DefaultFlag.PVP);
    return (state != StateFlag.State.DENY);
}
 
Example #6
Source File: WorldGuardHandler5.java    From AreaShop with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Flag<?> fuzzyMatchFlag(String flagName) {
	return DefaultFlag.fuzzyMatchFlag(flagName);
}
 
Example #7
Source File: WorldGuardHandler6.java    From AreaShop with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Flag<?> fuzzyMatchFlag(String flagName) {
	return DefaultFlag.fuzzyMatchFlag(flagName);
}
 
Example #8
Source File: WorldGuardHandler6_1_3.java    From AreaShop with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Flag<?> fuzzyMatchFlag(String flagName) {
	return DefaultFlag.fuzzyMatchFlag(WorldGuardPlugin.inst().getFlagRegistry(), flagName);
}