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

Citizens Integration #17

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Citizens Integration #17

wants to merge 8 commits into from

Conversation

EmiCB
Copy link
Member

@EmiCB EmiCB commented Apr 15, 2022

Portals now supports Citizens!

New Features:

  • /portal allowcitizens <portal_name> allows Citizens NPCs to use the specified portal
  • allowcitizens status saves in config

Notes:

  • teleportation only works if the NPC's waypoint is 1 block behind the portal (otherwise it won't step on the correct block)
  • Citizens swim up in portals with the WATER filler
  • Citizens walk around portals with the LAVA filler

resolves #15

Copy link
Member

@jackah2 jackah2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, just want a few things added. Thanks for working on this!

super(plugin, baseCommand, subCommand);
super.description("Toggles Citizens NPCs' ability to travel through the portal.");
super.arguments("portal");
super.requiresPlayer();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look this command requires the sender to be a player


@Override
protected boolean onCommand(CommandSender sender, String[] args) {
Player player = (Player) sender;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused

*
* @param event The Citizens NavigationCompleteEvent
*/
@EventHandler(priority = EventPriority.NORMAL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick but you don't need to specify the priority here; it'll default to NORMAL. Unless you were having issues without the priority then it's ok

@Override
protected boolean onCommand(CommandSender sender, String[] args) {
Player player = (Player) sender;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Citizens isn't loaded you should send a message to the user and return early.

Messenger.msg(sender, Messenger.ReplaceMessage.SUGGEST_DELETE, "/portal remove " + portal.getName());
return true;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the portal's filler is water or lava I'd send a message to the user telling them about the consequences as noted in the README. I'd do the same thing in the setfiller sub-command if the portal allows citizens and the new fill type is water/lava.

@@ -69,6 +67,11 @@ private void registerStuff() {
pm.registerEvents(new PortalBlockChangeListener(), this);
pm.registerEvents(new PortalDamageListener(), this);

// check if Citizens is enabled
if (pm.isPluginEnabled("Citizens")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few comments later about conditionally doing stuff in commands if Citizens is enabled so I'd store pm.isPluginEnabled("Citizens") as an instance variable in here for use across the plugin.

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

Successfully merging this pull request may close these issues.

Allow entities to travel through portals
4 participants