Jabelpeeps / Sentries

A near-total re-write of the classic Sentry plugin for bukkit/spigot.
3 stars 1 forks source link

Access to set the target? #10

Open Nutty101 opened 7 years ago

Nutty101 commented 7 years ago

While we can via reflection, I would like to avoid that. Could you set the modifier to Public on the method setAttackTarget in the trait for me? Per many requests, I am adding the functionality of this to my Police plugin.

Jabelpeeps commented 7 years ago

Hi, the problem with setting the attack Target directly via that method is that targets are set and unset fairly fluidly by the state machine in SentryStatus.

If you want to have the Sentry attack certain players according to their status in your plugin, it would be better to add an implementation of the SentryTarget interface, and then add instances of it to public Set<TargetType> targets (a field in SentryTrait).

Even better, write a command to add, remove, list, your new TargetType, there are several examples in this folder.

There are javadoc comments in various places that should help you, let me know if you have any difficulties.

Nutty101 commented 7 years ago

Humm, I wouldn't want it to ever get saved with the NPC, or show up as a target type a user could add. So the bridge isn't really an option. The SentryTarget might function, except that exposes it on the list of target types. I move the targets around quite a bit based on internal analytics. So a user can become a target and removed from the target list quite quickly.

Will have to think on that, as I really want this to be transparent on the plugin side. If I add a target class, it gets exposed and not sure that helps with the LOS settings either. Since I do not want something else to choose if they should be attacked or not.