Hidendra / LWC

Lightweight Protection for Chests, Furnaces, Dispensers, and more for the Minecraft server mod Bukkit
Other
167 stars 123 forks source link

Integration with Towny Resident Cleanup to remove old LWC protections #448

Open GrandRiver opened 11 years ago

GrandRiver commented 11 years ago

I'm wondering if there is any way LWC can be integrated with Towny's resident clean-up routines. We currently have Towny delete old residents/players who do not log into the server after 30 days, the resident is deleted from their town and their plots removed. Would it be possible to integrate LWC into this and delete any protections that have been created by players that Towny deletes?

Hidendra commented 11 years ago

Not really mainly because last time I checked Towny doesn't send any events when it does stuff like that.

It would be very easy for Towny to do just this on its end, however.

GrandRiver commented 11 years ago

Alright, I'll throw the ball to their court then. :)

SERVERCONSOLE commented 11 years ago

If you have everything in MySQL, you could write a simple query that would compare data in the appropriate tables and delete protections for any users not found in towny - or whatever parameters you want to set. You could just run it periodically form PHPMyAdmin or set up a recurring script if you want.

"You" being the user, not the plugin. Although, I suppose there could be a way to add this to the plugin with the appropriate config settings (table names, record IDs etc.)

GrandRiver commented 11 years ago

Just two things to keep in mind going that route...

1 - I don't know how to write such a script (derp).

2 - Although we have our server set up taking advantage of MySQL wherever our plugins have the option, not all servers do (I would assume most don't unless they have a really good hosting plan and/or have the technical know-how to set it up).

I threw the idea over to the Towny devs suggesting this and other plugin integration options as well. After I posted this here I thought maybe it would be a good idea to have configurable options to remove other old user data from other plugins as well (ie. Essentials Player Files, Permission Groups, Economy Accounts, Player Data Files, etc.) to keep things cleaned-up and organized on people's servers. We'll see where it goes.

SERVERCONSOLE commented 11 years ago

It could be built in to LWC but the user would have to configure the table name for the non LWC plugins. LWC could use defaults but then they would have to keep up with what the defaults are.

For the query you could use something like:

DELETE * FROM lwc-protections WHERE (lwc-protections.owner="username") AND (SELECT * FROM TOWNY_RESIDENTS.name="username" IS NULL)

DO NOT USE THE ABOVE EXAMPLE - It should be syntactically incorrect and should fail, but if it works it may not do what you expect. (In a most devastating way)

SERVERCONSOLE commented 11 years ago

Maybe a new plugin that manages user data across plugins. Hidendra, you up for it? ;o)