com.sk89q.worldguard.protection.flags.registry.FlagRegistry Java Examples

The following examples show how to use com.sk89q.worldguard.protection.flags.registry.FlagRegistry. 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: WorldGuardApi.java    From ClaimChunk with MIT License 6 votes vote down vote up
static boolean _init(ClaimChunk claimChunk) {
    FLAG_CHUNK_CLAIM = new StateFlag(CHUNK_CLAIM_FLAG_NAME,
            claimChunk.chConfig().getBool("worldguard", "allowClaimsInRegionsByDefault"));

    try {
        FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
        registry.register(FLAG_CHUNK_CLAIM);
        return true;
    } catch (FlagConflictException ignored) {
        Utils.err("Flag \"%s\" is already registered with WorldGuard. Another plugin conflicts with us!", CHUNK_CLAIM_FLAG_NAME);
    } catch (Exception e) {
        Utils.err("Failed to initialize WorldGuard support");
        e.printStackTrace();
    }
    return false;
}
 
Example #2
Source File: RadiationPlugin.java    From CraftserveRadiation with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoad() {
    FlagRegistry flagRegistry = WorldGuard.getInstance().getFlagRegistry();
    if (flagRegistry == null) {
        throw new IllegalStateException("Flag registry is not set! Plugin must shut down...");
    }

    this.radiationFlag = this.getOrCreateRadiationFlag(flagRegistry);
}
 
Example #3
Source File: RadiationPlugin.java    From CraftserveRadiation with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private Flag<Boolean> getOrCreateRadiationFlag(FlagRegistry flagRegistry) {
    Objects.requireNonNull(flagRegistry, "flagRegistry");

    Flag<Boolean> flag = (Flag<Boolean>) flagRegistry.get(RADIATION_FLAG.getName());
    if (flag != null) {
        return flag;
    }

    flag = RADIATION_FLAG;
    flagRegistry.register(flag);
    return flag;
}
 
Example #4
Source File: WorldGuardIntegration.java    From QuickShop-Reremake with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void load() {
    FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
    try {
        // create a flag with the name "my-custom-flag", defaulting to true
        registry.register(this.createFlag);
        registry.register(this.tradeFlag);
        plugin.getLogger().info(ChatColor.GREEN + getName() + " flags register successfully.");
        Util.debugLog("Success register " + getName() + " flags.");
    } catch (FlagConflictException e) {
        e.printStackTrace();
    }
}
 
Example #5
Source File: WorldGuardCompat.java    From StackMob-3 with GNU General Public License v3.0 5 votes vote down vote up
public void registerFlag(){
    FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
    try {
        registry.register(ENTITY_FLAG);
        sm.getLogger().info("Registered WorldGuard region flag.");
    } catch (FlagConflictException e) {
        sm.getLogger().warning("A conflict occurred while trying to register the WorldGuard flag.");
        e.printStackTrace();
    }
}
 
Example #6
Source File: WorldGuardCommunicator.java    From WorldGuardExtraFlagsPlugin with MIT License 5 votes vote down vote up
default public void onLoad(Plugin plugin) throws Exception
{
	FlagRegistry flagRegistry = this.getFlagRegistry();
	flagRegistry.register(Flags.TELEPORT_ON_ENTRY);
	flagRegistry.register(Flags.TELEPORT_ON_EXIT);
	flagRegistry.register(Flags.COMMAND_ON_ENTRY);
	flagRegistry.register(Flags.COMMAND_ON_EXIT);
	flagRegistry.register(Flags.CONSOLE_COMMAND_ON_ENTRY);
	flagRegistry.register(Flags.CONSOLE_COMMAND_ON_EXIT);
	flagRegistry.register(Flags.WALK_SPEED);
	flagRegistry.register(Flags.KEEP_INVENTORY);
	flagRegistry.register(Flags.KEEP_EXP);
	flagRegistry.register(Flags.CHAT_PREFIX);
	flagRegistry.register(Flags.CHAT_SUFFIX);
	flagRegistry.register(Flags.BLOCKED_EFFECTS);
	flagRegistry.register(Flags.GODMODE);
	flagRegistry.register(Flags.RESPAWN_LOCATION);
	flagRegistry.register(Flags.WORLDEDIT);
	flagRegistry.register(Flags.GIVE_EFFECTS);
	flagRegistry.register(Flags.FLY);
	flagRegistry.register(Flags.PLAY_SOUNDS);
	flagRegistry.register(Flags.MYTHICMOB_EGGS);
	flagRegistry.register(Flags.FROSTWALKER);
	flagRegistry.register(Flags.NETHER_PORTALS);
	flagRegistry.register(Flags.ALLOW_BLOCK_PLACE);
	flagRegistry.register(Flags.DENY_BLOCK_PLACE);
	flagRegistry.register(Flags.ALLOW_BLOCK_BREAK);
	flagRegistry.register(Flags.DENY_BLOCK_BREAK);
	flagRegistry.register(Flags.GLIDE);
	flagRegistry.register(Flags.CHUNK_UNLOAD);
	flagRegistry.register(Flags.ITEM_DURABILITY);
	flagRegistry.register(Flags.JOIN_LOCATION);
}
 
Example #7
Source File: WorldGuardHook.java    From FunnyGuilds with Apache License 2.0 5 votes vote down vote up
public static void initWorldGuard() {
    WorldGuardHook.worldGuard = WorldGuardPlugin.inst();
    noPointsFlag = new StateFlag("fg-no-points", false);
    
    try {
        ((FlagRegistry) GET_FLAG_REGISTRY.invoke(GET_INSTANCE.invoke(null))).register(noPointsFlag);
    }
    catch (FlagConflictException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
        FunnyGuilds.getInstance().getPluginLogger().error("An error occurred while registering an \"fg-no-points\" worldguard flag", ex);
    }
}
 
Example #8
Source File: WorldGuardSevenCommunicator.java    From WorldGuardExtraFlagsPlugin with MIT License 4 votes vote down vote up
@Override
public FlagRegistry getFlagRegistry()
{
	return WorldGuard.getInstance().getFlagRegistry();
}
 
Example #9
Source File: WorldGuardSixCommunicator.java    From WorldGuardExtraFlagsPlugin with MIT License 4 votes vote down vote up
@Override
public FlagRegistry getFlagRegistry()
{
	return WorldGuardPlugin.inst().getFlagRegistry();
}
 
Example #10
Source File: HookWorldGuard_V6_2.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public static void registerFlags(Expansion expansion) {
    WorldGuardPlugin api = getAPI();
    FlagRegistry registry = api.getFlagRegistry();
    registry.register(mobCombatFlag);
    registry.register(noTaggingFlag);
}
 
Example #11
Source File: WorldGuardCommunicator.java    From WorldGuardExtraFlagsPlugin with MIT License votes vote down vote up
public FlagRegistry getFlagRegistry();