World Guard Custom Flags

Discussion in 'Plugin Development' started by Onlineids, May 30, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Onlineids

    Does anyone know how to create custom world guard flags? I don't want to rely on other plugins so don't point me towards this
     
  2. Offline

    Shevchik

  3. Offline

    Onlineids

  4. Offline

    Shevchik

    Code:java
    1. try {
    2. Field field = DefaultFlag.class.getDeclaredField("flagsList");
    3. Field modifiersField = Field.class.getDeclaredField("modifiers");
    4. modifiersField.setAccessible(true);
    5. modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
    6. field.setAccessible(true);
    7. List<Flag<?>> flags = new ArrayList<Flag<?>>(Arrays.asList(DefaultFlag.getFlags()));
    8. flags.add(flagtoinject);
    9. field.set(null, flags.toArray(new Flag[flags.size()]));
    10. WorldGuardPlugin.class.cast(Bukkit.getPluginManager().getPlugin("WorldGuard")).getGlobalRegionManager().preload();
    11. } catch (Exception e) {
    12. e.printStackTrace();
    13. }
    14.  

    That will inject any Flag instance to worldguard flag list.
     
    Onlineids likes this.
  5. Offline

    MoseMister

    Shevchik

    Thats just telling him how to inject the flag into worldguard ..... i think what he is asking is how to make the flag in the first place
     
  6. Offline

    Shevchik

    HE could use the guide from worldguardcustomflags plugin, because the custom flag creation will be almost the same with one exception: you need to extend Flag not the CustomFlag.
     
  7. Offline

    Onlineids

    Yea I figured it out thanks
     
Thread Status:
Not open for further replies.

Share This Page