Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API to disable WE functions in areas #4

Closed
madmaxoft opened this issue Dec 26, 2013 · 15 comments
Closed

Add API to disable WE functions in areas #4

madmaxoft opened this issue Dec 26, 2013 · 15 comments

Comments

@madmaxoft
Copy link
Member

Plugins such as ProtectionAreas and Gallery are now vulnerable to players with WorldEdit rights, since WorldEdit can overwrite the areas protected by those plugins.

I'm asking for an API to set (rectangular) regions where WorldEdit cannot be used. The basic version would cover a static list of regions shared among all players. An advanced version would have a per-player list of regions.

@NiLSPACE
Copy link
Member

If the gallery plugin or the protectionareas plugin is loaded before the worldedit plugin, wouldn't they block the WorldEdit plugin?

@madmaxoft
Copy link
Member Author

Not the WE commands, such as copy and paste.

@NiLSPACE
Copy link
Member

Hmm that's true. Shall I create a hook-like system? like
HOOK_PLAYER_COMMAND
and the function would be like:
function OnPlayerUsedCommand(Player, Command, Params)
or should I create a different hook for every command?

@madmaxoft
Copy link
Member Author

Nay, I think it's enough to create a list of areas where WE is not allowed to change blocks; then each WE command checks the list and if the player's selection contains any intersection with that list, the command will not be carried out.
Then the other plugins could simply manipulate the list using an API - AddExclusionArea(MinX, MaxX, MinY, MaxY, MinZ, MaxZ) -> ID, DelExclusionArea(ID)

@bennasar99
Copy link
Contributor

Why dont allow worldedit only on owned player areas?

@NiLSPACE
Copy link
Member

Because WorldEdit isn't a security plugin :)

@madmaxoft
Copy link
Member Author

WorldEdit doesn't provide any security (and it also shouldn't, there's other plugins for this). However, it shouldn't break those plugins' security either, and that's what this issue is about.

@NiLSPACE
Copy link
Member

First implentation is done. To add an area use AddExclusionArea(MinX, MaxX, MinY, MaxY, MinZ, MaxZ, WorldName)
WorldName is currently unused. It returns the ID of the area.
To delete it use DelExclusionArea(ID)

@NiLSPACE
Copy link
Member

I do think we should use a callback so you can make an per-player area protection.

@madmaxoft
Copy link
Member Author

Yes, the callback makes much more sense for per-player protection

@madmaxoft
Copy link
Member Author

Copying the input from the forum here:
The callback should be used once for each operation. The usage might look something like this:

-- Register the callback for a_World
cPluginManager.Get():GetPlugin("WorldEdit"):Call(
  "RegisterCallback", "WECallback", PLUGIN, a_World
);

-- The callback
function WECallback(
  a_MinX, a_MaxX, a_MinY, a_MaxY, a_MinZ, a_MaxZ,
  a_Player, a_World, a_Operation
)
  -- Prevent the user from pasting in X < 0
  if ((a_MaxX < 0) and (a_Operation == "paste")) then
    -- Prevent and give the user a reason that WE displays
    return true, "Prevented by an example WE callback";
  end
  return false;  -- Allow
end

Or if WE internally has a cCuboid for the selection, it could simply pass that instead of the coord ranges. The clients will most probably use cCuboid for intersections and others anyway.

@NiLSPACE
Copy link
Member

I implented everything exept for the return message. But it shouldn't be too hard. but on the other hand the callback function itself could send the message instead of the WE plugin.

@madmaxoft
Copy link
Member Author

Okay, let's make the callback send the message. It has enough information to format it anyway.

@NiLSPACE
Copy link
Member

Then shall I close the issue?

@madmaxoft
Copy link
Member Author

No, I'll close it for you :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants