mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-14 12:11:30 +01:00
Add /trc options to the base /npc lookclose command
This commit is contained in:
parent
b0f1290b58
commit
166aa3d739
@ -1147,26 +1147,39 @@ public class NPCCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "lookclose --(random|r)look [true|false] --(random|r)pitchrange [min,max] --(random|r)yawrange [min,max]",
|
usage = "lookclose --range [range] (-r[ealistic looking]) --(random|r)look [true|false] --(random|r)pitchrange [min,max] --(random|r)yawrange [min,max]",
|
||||||
desc = "Toggle whether a NPC will look when a player is near",
|
desc = "Toggle whether a NPC will look when a player is near",
|
||||||
modifiers = { "lookclose", "look", "rotate" },
|
modifiers = { "lookclose", "look", "rotate" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
|
flags = "r",
|
||||||
permission = "citizens.npc.lookclose")
|
permission = "citizens.npc.lookclose")
|
||||||
public void lookClose(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void lookClose(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
boolean toggle = true;
|
boolean toggle = true;
|
||||||
|
LookClose trait = npc.getOrAddTrait(LookClose.class);
|
||||||
if (args.hasAnyValueFlag("randomlook", "rlook")) {
|
if (args.hasAnyValueFlag("randomlook", "rlook")) {
|
||||||
boolean enableRandomLook = Boolean.parseBoolean(args.getFlag("randomlook", args.getFlag("rlook")));
|
boolean enableRandomLook = Boolean.parseBoolean(args.getFlag("randomlook", args.getFlag("rlook")));
|
||||||
npc.getOrAddTrait(LookClose.class).setRandomLook(enableRandomLook);
|
trait.setRandomLook(enableRandomLook);
|
||||||
Messaging.sendTr(sender,
|
Messaging.sendTr(sender,
|
||||||
enableRandomLook ? Messages.LOOKCLOSE_RANDOM_SET : Messages.LOOKCLOSE_RANDOM_STOPPED,
|
enableRandomLook ? Messages.LOOKCLOSE_RANDOM_SET : Messages.LOOKCLOSE_RANDOM_STOPPED,
|
||||||
npc.getName());
|
npc.getName());
|
||||||
toggle = false;
|
toggle = false;
|
||||||
}
|
}
|
||||||
|
if (args.hasValueFlag("range")) {
|
||||||
|
trait.setRange(args.getFlagDouble("range"));
|
||||||
|
Messaging.sendTr(sender, Messages.LOOKCLOSE_RANGE_SET, args.getFlagDouble("range"));
|
||||||
|
toggle = false;
|
||||||
|
}
|
||||||
|
if (args.hasFlag('r')) {
|
||||||
|
trait.setRealisticLooking(!trait.useRealisticLooking());
|
||||||
|
Messaging.sendTr(sender, trait.useRealisticLooking() ? Messages.LOOKCLOSE_REALISTIC_LOOK_SET
|
||||||
|
: Messages.LOOKCLOSE_REALISTIC_LOOK_UNSET, npc.getName());
|
||||||
|
toggle = false;
|
||||||
|
}
|
||||||
if (args.hasAnyValueFlag("randomlookdelay", "rlookdelay")) {
|
if (args.hasAnyValueFlag("randomlookdelay", "rlookdelay")) {
|
||||||
int delay = Integer.parseInt(args.getFlag("randomlookdelay", args.getFlag("rlookdelay")));
|
int delay = Integer.parseInt(args.getFlag("randomlookdelay", args.getFlag("rlookdelay")));
|
||||||
delay = Math.max(1, delay);
|
delay = Math.max(1, delay);
|
||||||
npc.getOrAddTrait(LookClose.class).setRandomLookDelay(delay);
|
trait.setRandomLookDelay(delay);
|
||||||
Messaging.sendTr(sender, Messages.LOOKCLOSE_RANDOM_DELAY_SET, npc.getName(), delay);
|
Messaging.sendTr(sender, Messages.LOOKCLOSE_RANDOM_DELAY_SET, npc.getName(), delay);
|
||||||
toggle = false;
|
toggle = false;
|
||||||
}
|
}
|
||||||
@ -1177,7 +1190,7 @@ public class NPCCommands {
|
|||||||
float min = Float.parseFloat(parts[0]), max = Float.parseFloat(parts[1]);
|
float min = Float.parseFloat(parts[0]), max = Float.parseFloat(parts[1]);
|
||||||
if (min > max)
|
if (min > max)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
npc.getOrAddTrait(LookClose.class).setRandomLookPitchRange(min, max);
|
trait.setRandomLookPitchRange(min, max);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new CommandException(Messaging.tr(Messages.ERROR_SETTING_LOOKCLOSE_RANGE, flag));
|
throw new CommandException(Messaging.tr(Messages.ERROR_SETTING_LOOKCLOSE_RANGE, flag));
|
||||||
}
|
}
|
||||||
@ -1191,7 +1204,7 @@ public class NPCCommands {
|
|||||||
float min = Float.parseFloat(parts[0]), max = Float.parseFloat(parts[1]);
|
float min = Float.parseFloat(parts[0]), max = Float.parseFloat(parts[1]);
|
||||||
if (min > max)
|
if (min > max)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
npc.getOrAddTrait(LookClose.class).setRandomLookYawRange(min, max);
|
trait.setRandomLookYawRange(min, max);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new CommandException(Messaging.tr(Messages.ERROR_SETTING_LOOKCLOSE_RANGE, flag));
|
throw new CommandException(Messaging.tr(Messages.ERROR_SETTING_LOOKCLOSE_RANGE, flag));
|
||||||
}
|
}
|
||||||
@ -1199,8 +1212,7 @@ public class NPCCommands {
|
|||||||
toggle = false;
|
toggle = false;
|
||||||
}
|
}
|
||||||
if (toggle) {
|
if (toggle) {
|
||||||
Messaging.sendTr(sender,
|
Messaging.sendTr(sender, trait.toggle() ? Messages.LOOKCLOSE_SET : Messages.LOOKCLOSE_STOPPED,
|
||||||
npc.getOrAddTrait(LookClose.class).toggle() ? Messages.LOOKCLOSE_SET : Messages.LOOKCLOSE_STOPPED,
|
|
||||||
npc.getName());
|
npc.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,8 +257,8 @@ public class LookClose extends Trait implements Toggleable, CommandConfigurable
|
|||||||
/**
|
/**
|
||||||
* Sets the maximum range in blocks to look at other Entities
|
* Sets the maximum range in blocks to look at other Entities
|
||||||
*/
|
*/
|
||||||
public void setRange(int range) {
|
public void setRange(double d) {
|
||||||
this.range = range;
|
this.range = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -221,6 +221,9 @@ public class Messages {
|
|||||||
public static final String LOOKCLOSE_RANDOM_SET = "citizens.commands.npc.lookclose.random-set";
|
public static final String LOOKCLOSE_RANDOM_SET = "citizens.commands.npc.lookclose.random-set";
|
||||||
public static final String LOOKCLOSE_RANDOM_STOPPED = "citizens.commands.npc.lookclose.random-stopped";
|
public static final String LOOKCLOSE_RANDOM_STOPPED = "citizens.commands.npc.lookclose.random-stopped";
|
||||||
public static final String LOOKCLOSE_RANDOM_YAW_RANGE_SET = "citizens.commands.npc.lookclose.random-yaw-range-set";
|
public static final String LOOKCLOSE_RANDOM_YAW_RANGE_SET = "citizens.commands.npc.lookclose.random-yaw-range-set";
|
||||||
|
public static final String LOOKCLOSE_RANGE_SET = "citizens.commands.npc.lookclose.range-set";
|
||||||
|
public static final String LOOKCLOSE_REALISTIC_LOOK_SET = "citizens.commands.npc.lookclose.rl-set";
|
||||||
|
public static final String LOOKCLOSE_REALISTIC_LOOK_UNSET = "citizens.commands.npc.lookclose.rl-unset";
|
||||||
public static final String LOOKCLOSE_SET = "citizens.commands.npc.lookclose.set";
|
public static final String LOOKCLOSE_SET = "citizens.commands.npc.lookclose.set";
|
||||||
public static final String LOOKCLOSE_STOPPED = "citizens.commands.npc.lookclose.stopped";
|
public static final String LOOKCLOSE_STOPPED = "citizens.commands.npc.lookclose.stopped";
|
||||||
public static final String METADATA_SET = "citizens.commands.npc.metadata.set";
|
public static final String METADATA_SET = "citizens.commands.npc.metadata.set";
|
||||||
|
@ -128,6 +128,9 @@ citizens.commands.npc.leashable.stopped=[[{0}]] is no longer leashable.
|
|||||||
citizens.commands.npc.llama.strength-set=Llama strength set to [[{0}]].
|
citizens.commands.npc.llama.strength-set=Llama strength set to [[{0}]].
|
||||||
citizens.commands.npc.llama.color-set=Llama color set to [[{0}]].
|
citizens.commands.npc.llama.color-set=Llama color set to [[{0}]].
|
||||||
citizens.commands.npc.llama.invalid-color=Invalid llama color given. Valid colors are: [[{0}]].
|
citizens.commands.npc.llama.invalid-color=Invalid llama color given. Valid colors are: [[{0}]].
|
||||||
|
citizens.commands.npc.lookclose.range-set=[[{0}]]''s lookclose range set to [[{1}]] blocks.
|
||||||
|
citizens.commands.npc.lookclose.rl-set=[[{0}]] will no longer look through blocks at players.
|
||||||
|
citizens.commands.npc.lookclose.rl-unset=[[{0}]] will now always look at players, even through blocks.
|
||||||
citizens.commands.npc.lookclose.random-look-delay-set=[[{0}]] will now randomly look every [[{1}]] ticks.
|
citizens.commands.npc.lookclose.random-look-delay-set=[[{0}]] will now randomly look every [[{1}]] ticks.
|
||||||
citizens.commands.npc.lookclose.random-pitch-range-set=[[{0}]] will now randomly choose a pitch in the range [{1}].
|
citizens.commands.npc.lookclose.random-pitch-range-set=[[{0}]] will now randomly choose a pitch in the range [{1}].
|
||||||
citizens.commands.npc.lookclose.random-yaw-range-set=[[{0}]] will now randomly choose a yaw in the range [{1}].
|
citizens.commands.npc.lookclose.random-yaw-range-set=[[{0}]] will now randomly choose a yaw in the range [{1}].
|
||||||
|
Loading…
Reference in New Issue
Block a user