Skip to content

Commit

Permalink
Add /waypoints opendoors
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jul 12, 2019
1 parent 0547176 commit 0e328ee
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
19 changes: 17 additions & 2 deletions main/src/main/java/net/citizensnpcs/commands/WaypointCommands.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.citizensnpcs.commands;

import org.bukkit.command.CommandSender;

import net.citizensnpcs.Citizens;
import net.citizensnpcs.api.command.Command;
import net.citizensnpcs.api.command.CommandContext;
Expand All @@ -10,8 +12,6 @@
import net.citizensnpcs.trait.waypoint.Waypoints;
import net.citizensnpcs.util.Messages;

import org.bukkit.command.CommandSender;

@Requirements(ownership = true, selected = true)
public class WaypointCommands {
public WaypointCommands(Citizens plugin) {
Expand All @@ -31,6 +31,21 @@ public void disableTeleporting(CommandContext args, CommandSender sender, NPC np
Messaging.sendTr(sender, Messages.WAYPOINT_TELEPORTING_DISABLED);
}

@Command(
aliases = { "waypoints", "waypoint", "wp" },
usage = "opendoors",
desc = "Enables opening doors when pathfinding (temporary command)",
modifiers = { "opendoors" },
min = 1,
max = 1,
permission = "citizens.waypoints.opendoors")
public void openDoors(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
boolean opensDoors = !npc.data().get(NPC.PATHFINDER_OPEN_DOORS_METADATA, false);
npc.data().setPersistent(NPC.PATHFINDER_OPEN_DOORS_METADATA, opensDoors);
Messaging.sendTr(sender,
opensDoors ? Messages.PATHFINDER_OPEN_DOORS_ENABLED : Messages.PATHFINDER_OPEN_DOORS_DISABLED);
}

@Command(
aliases = { "waypoints", "waypoint", "wp" },
usage = "provider [provider name] (-d)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ public class CitizensNavigator implements Navigator, Runnable {
public CitizensNavigator(NPC npc) {
this.npc = npc;
defaultParams.examiner(new SwimmingExaminer(npc));
if (Setting.NEW_PATHFINDER_OPENS_DOORS.asBoolean()) {
defaultParams.examiner(new DoorExaminer());
}
}

@Override
Expand Down Expand Up @@ -329,6 +326,10 @@ private void stopNavigating(CancelReason reason) {

private void switchParams() {
localParams = defaultParams.clone();
if (!npc.data().has(NPC.PATHFINDER_OPEN_DOORS_METADATA) ? Setting.NEW_PATHFINDER_OPENS_DOORS.asBoolean()
: npc.data().<Boolean> get(NPC.PATHFINDER_OPEN_DOORS_METADATA)) {
localParams.examiner(new DoorExaminer());
}
}

private void switchStrategyTo(PathStrategy newStrategy) {
Expand Down
2 changes: 2 additions & 0 deletions main/src/main/java/net/citizensnpcs/util/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ public class Messages {
public static final String PARROT_VARIANT_SET = "citizens.commands.npc.parrot.variant-set";
public static final String PASSIVE_SET = "citizens.commands.npc.passive.set";
public static final String PASSIVE_UNSET = "citizens.commands.npc.passive.unset";
public static final String PATHFINDER_OPEN_DOORS_DISABLED = "citizens.commands.waypoints.opendoors.disabled";
public static final String PATHFINDER_OPEN_DOORS_ENABLED = "citizens.commands.waypoints.opendoors.enabled";
public static final String PATHFINDING_OPTIONS_ATTACK_RANGE_SET = "citizens.commands.npc.pathopt.attack-range-set";
public static final String PATHFINDING_OPTIONS_AVOID_WATER_SET = "citizens.commands.npc.pathopt.avoid-water-set";
public static final String PATHFINDING_OPTIONS_AVOID_WATER_UNSET = "citizens.commands.npc.pathopt.avoid-water-unset";
Expand Down
2 changes: 2 additions & 0 deletions main/src/main/resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ citizens.commands.traitc.missing=Trait not found.
citizens.commands.traitc.not-configurable=That trait is not configurable.
citizens.commands.traitc.not-on-npc=The NPC doesn''t have that trait.
citizens.commands.unknown-command=Unknown command. Did you mean:
citizens.commands.waypoints.opendoors.enabled=[[{0}]] will now open doors while pathfinding.
citizens.commands.waypoints.opendoors.disabled=[[{0}]] will no longer doors while pathfinding.
citizens.commands.wolf.traits-updated=[[{0}]]''s Traits were updated. Angry:[[{1}]], Sitting:[[{2}]], Tamed:[[{3}]], Collar Color:[[{4}]]
citizens.conversations.selection.invalid-choice=[[{0}]] is not a valid option.
citizens.economy.error-loading=Unable to use economy handling. Has Vault been enabled?
Expand Down

0 comments on commit 0e328ee

Please sign in to comment.