VolmitSoftware / Adapt

Adapt Vanilla Gameplay with better skills and implementations than anywhere else!
https://docs.volmit.com/adapt
GNU General Public License v3.0
84 stars 59 forks source link

Add WorldGuard flag and create a region protection API #393

Closed Sliman4 closed 1 year ago

Sliman4 commented 1 year ago

This PR moves region protection code to a separate package (com.volmit.adapt.api.protection), adds protection API (DefaultProtectors.registerProtector(Protector)) so other plugins can add their own implementations, and adds use-adaptations flag. If the flag is not defined in the WG region, the default value is allow if requireWorldguardBuildPermToUseAdaptations: false or if the player has build permission in the region, I think that's how it worked before this PR.

Sliman4 commented 1 year ago

Also added "protectionOverrides": {"adaptation-name": {"WorldGuard": false}} in plugins/Adapt/adapt/adapt.json so users can enable or disable region protections per-adaptation

NextdoorPsycho commented 1 year ago

Are you sure this works? Adding "whatever-adaptation-names-here" in the config doesn't update anything? or maybe I misunderstood what this was to do.

Sliman4 commented 1 year ago

If requireWorldguardBuildPermToUseAdaptations = true and protectionOverrides.<adaptation-name>.WorldGuard = false, then this adaptation won't require the worldguard permission to use, but all other adaptations will preserve the default true value. Or if requireWorldguardBuildPermToUseAdaptations = false and protectionOverrides.<adaptation-name>.WorldGuard = true, it will require worldguard permission for this adaptation. While testing, make sure that you're not /op (you don't have the worldguard bypass permission) and you're not the region owner.

NextdoorPsycho commented 1 year ago

I get that, can you please show me an example in the config of adding multiple skills, something that you're using in your used case so I can try to use it on my end, and once I validate that it's working properly and I understand how you're using it I'll add it to the documentation and then make an update for it

NextdoorPsycho commented 1 year ago

additionally, it doesn't seem like it updates and adds the world guard flags

NextdoorPsycho commented 1 year ago

oH wait i get it, you arent doing an independent flag, but you are doing a single flag for worldguard, use-adaptations is plural for the region, I get it. i thought you were saying you added it for every skill.

Sliman4 commented 1 year ago

but this does not add the flag node to worldguard? Were you able to?

"protectionOverrides": {"rift-blink": {"WorldGuard": false}}

Allows players to use rift-blink in worldguard regions even if requireWorldguardBuildPermToUseAdaptations is enabled

Sliman4 commented 1 year ago

Btw I just found a bug with rift-blink, when you unlearn this adaptation (or do anything else to make hasAdaptation return false) while jumping, you can press spacebar again, and you'll fly. I found this bug trying to test teleportation from the edge of the region, when you cross the region border before pressing the spacebar the second time

NextdoorPsycho commented 1 year ago

Btw I just found a bug with rift-blink, when you unlearn this adaptation (or do anything else to make hasAdaptation return false) while jumping, you can press spacebar again, and you'll fly. I found this bug trying to test teleportation from the edge of the region, when you cross the region border before pressing the spacebar the second time

sigh ok sounds good ill look at that

NextdoorPsycho commented 1 year ago

but this does not add the flag node to worldguard? Were you able to?

"protectionOverrides": {"rift-blink": {"WorldGuard": false}}

Allows players to use rift-blink in worldguard regions even if requireWorldguardBuildPermToUseAdaptations is enabled

Yea this is wrong, you cant add a specific node to the worldguard segment in the config. "protectionOverrides": {"rift-blink": {"WorldGuard": false}} is what I'm referencing. i can make it iterated and add ALL keys to the registry like every adaptation and it can be independent, but that snippet does nothing

Sliman4 commented 1 year ago

It doesn't create the rift-blink flag, it basically says "the worldguard flag is not needed for rift-blink". Or if you want it to also be available in faction claims (#396), you can set "protectionOverrides": {"rift-blink": {"WorldGuard": false, "Factions": false}}, it means "skip worldguard and factions checks for rift-blink"