Skip to content

Citizens Integration#17

Open
EmiCB wants to merge 8 commits intomasterfrom
feature/citizens-support
Open

Citizens Integration#17
EmiCB wants to merge 8 commits intomasterfrom
feature/citizens-support

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.

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.

Geph and others added 2 commits April 17, 2022 20:07
Co-authored-by: Jack Henhapl <jackah2@illinois.edu>
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