cheahjs / TerrariaAPI-Server

Fork is now over at https://github.com/NyxStudios/TerrariaAPI-Server
https://tshock.co
32 stars 24 forks source link

Reflective Commands for TShock and plugins - automatically add commands to Commands.ChatCommands (TShockAPI and TerrariaServer) #13

Closed SnirkImmington closed 11 years ago

SnirkImmington commented 11 years ago

This adds the virtual bool ReflectiveCommands to plugins, which toggles it. Most of it is going to be implemented in TShock, which I have made a pull request for as well.

When TShock is loading commands, it will scan plugins with this enabled for command methods, and automatically add them to Commands.ChatCommands.

Command methods are public and are labeled with a CommandAttribute to tell TShock to reflectively search for them. For example:

[Command(Permissions.kick, "kick")]
public static void Kick(CommandArgs args)

This has been done to each of TShock's native commands in my push to TShock, and the changes which will affect plugins are mostly done in TShock itself.

Olink commented 11 years ago

None of these changes seem necessary for your plugin....certainly not cluttering the boot up screen with garbage about plugin descriptions, and certainly not adding a bool...if a plugin doesnt wish to utilize this, any reflection based approach would work without said bool. These changes seem superficial and my vote is no.

hakusaro commented 11 years ago

Waiting on the PR to be resubmitted to TShock/TShock. Side note: why doesn't this repo have an associated general-devel branch?

MarioE commented 11 years ago

First, I don't think we should be introducing TShock-specific things into TerrariaAPI-Server. Second, it actually isn't necessary to modify TerrariaAPI-Server to use the reflectively added commands. You can do it entirely in TShock by checking for the field "ReflectiveCommands" using reflection, and then adding the commands if necessary.

Olink commented 11 years ago

My question is if TShock should be responsible for this, surely that would imply that we expect all plugins to follow our suit, which we dont. I think it is fine to make a utility tool, aka, the mysql dll that you can release. If a plugin dev wishes to use fancy reflection, he would have to include your release in his project ala the thread post. Then he has to deal with the issues where it doesnt work.

hakusaro commented 11 years ago

I'm with @MarioE on this issue - it should probably be entirely relegated to TShock.

Olink commented 11 years ago

Im against @nicatronTg , which is that this shouldnt be in tshock, but be its own utility tool that plugin developers can take advantage of themselves.

hakusaro commented 11 years ago

[If any place, it shouldn't be in the API] is what I meant.

Lucas Nicodemus via Web

On Tue, Jul 16, 2013 at 10:21 AM, Zack notifications@github.com wrote:

Im against nicatron, which is that this shouldnt be in tshock, but be its own utility tool that plugin developers can take advantage of themselves.

— Reply to this email directly or view it on GitHubhttps://github.com/Deathmax/TerrariaAPI-Server/pull/13#issuecomment-21053921 .