mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-26 20:55:44 +01:00
Add option to avoid talk-close to NPCs
This commit is contained in:
parent
0ddfcbd0fa
commit
22fd1da0c8
@ -151,6 +151,7 @@ public class Settings {
|
||||
TABLIST_REMOVE_PACKET_DELAY("npc.tablist.remove-packet-delay", 1),
|
||||
TALK_CLOSE_MAXIMUM_COOLDOWN("npc.text.max-talk-cooldown", 5),
|
||||
TALK_CLOSE_MINIMUM_COOLDOWN("npc.text.min-talk-cooldown", 10),
|
||||
TALK_CLOSE_TO_NPCS("npc.chat.options.talk-to-npcs", true),
|
||||
TALK_ITEM("npc.text.talk-item", "*"),
|
||||
TELEPORT_DELAY("npc.teleport-delay", -1),
|
||||
USE_BOAT_CONTROLS("npc.controllable.use-boat-controls", true),
|
||||
|
@ -79,5 +79,6 @@ public class NPCConfigurator extends InventoryMenuPage {
|
||||
(input) -> evt.npc.setName(input));
|
||||
}
|
||||
}));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ import net.citizensnpcs.api.util.SpigotUtil;
|
||||
slots = { @MenuSlot(
|
||||
filter = InventoryAction.UNKNOWN,
|
||||
pat = 'x',
|
||||
compatMaterial = { "GLASS_PANE", "FIRE" },
|
||||
compatMaterial = { "BARRIER", "FIRE" },
|
||||
title = "<4>Unused") },
|
||||
value = "xxx")
|
||||
public class EndermanEquipperGUI extends InventoryMenuPage {
|
||||
|
@ -63,7 +63,7 @@ import net.citizensnpcs.api.trait.trait.Equipment.EquipmentSlot;
|
||||
slots = { @MenuSlot(
|
||||
filter = InventoryAction.UNKNOWN,
|
||||
pat = 'x',
|
||||
compatMaterial = { "GLASS_PANE", "FIRE" },
|
||||
compatMaterial = { "BARRIER", "FIRE" },
|
||||
title = "<4>Unused") },
|
||||
value = "xxx\nxxx")
|
||||
public class GenericEquipperGUI extends InventoryMenuPage {
|
||||
|
@ -30,7 +30,7 @@ import net.citizensnpcs.trait.Saddle;
|
||||
slots = { @MenuSlot(
|
||||
filter = InventoryAction.UNKNOWN,
|
||||
pat = 'x',
|
||||
compatMaterial = { "GLASS_PANE", "FIRE" },
|
||||
compatMaterial = { "BARRIER", "FIRE" },
|
||||
title = "<4>Unused") },
|
||||
value = "xxx")
|
||||
public class PigEquipperGUI extends InventoryMenuPage {
|
||||
|
@ -3,6 +3,8 @@ package net.citizensnpcs.npc.ai.speech;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.ai.speech.SpeechContext;
|
||||
@ -11,8 +13,6 @@ import net.citizensnpcs.api.ai.speech.VocalChord;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class Chat implements VocalChord {
|
||||
public final String VOCAL_CHORD_NAME = "chat";
|
||||
|
||||
@ -110,10 +110,10 @@ public class Chat implements VocalChord {
|
||||
List<Entity> bystanderEntities = npc.getEntity().getNearbyEntities(Setting.CHAT_RANGE.asDouble(),
|
||||
Setting.CHAT_RANGE.asDouble(), Setting.CHAT_RANGE.asDouble());
|
||||
for (Entity bystander : bystanderEntities) {
|
||||
// Continue if a LivingEntity, which is compatible with
|
||||
// TalkableEntity
|
||||
boolean shouldTalk = true;
|
||||
// Exclude targeted recipients
|
||||
if (!Setting.TALK_CLOSE_TO_NPCS.asBoolean() && CitizensAPI.getNPCRegistry().isNPC(bystander)) {
|
||||
shouldTalk = false;
|
||||
}
|
||||
if (context.hasRecipients()) {
|
||||
for (Talkable target : context) {
|
||||
if (target.getEntity().equals(bystander)) {
|
||||
@ -123,8 +123,6 @@ public class Chat implements VocalChord {
|
||||
}
|
||||
}
|
||||
|
||||
// Found a nearby LivingEntity, make it Talkable and
|
||||
// talkNear it if 'should_talk'
|
||||
if (shouldTalk) {
|
||||
new TalkableEntity(bystander).talkNear(context, text, this);
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ public class TalkableEntity implements Talkable {
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
// If not living entity, return -1
|
||||
if (!(o instanceof Entity)) {
|
||||
return -1;
|
||||
// If NPC and matches, return 0
|
||||
|
@ -88,7 +88,7 @@ public class DropsTrait extends Trait {
|
||||
ctx.getInventory().setItem(islot, drop.drop.clone());
|
||||
}
|
||||
InventoryMenuSlot slot = ctx.getSlot(i * 9 + j);
|
||||
slot.setItemStack(new ItemStack(Util.getFallbackMaterial("GLASS_PANE", "FIRE")),
|
||||
slot.setItemStack(new ItemStack(Util.getFallbackMaterial("BARRIER", "FIRE")),
|
||||
"Drop chance <e>" + chance + "%");
|
||||
slot.addClickHandler(new PercentageSlotHandler((pct) -> {
|
||||
if (chances.containsKey(islot)) {
|
||||
|
Loading…
Reference in New Issue
Block a user