mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-23 02:55:45 +01:00
added ability to send chat through an NPC
This commit is contained in:
parent
848cbce13a
commit
575c3a5b99
Binary file not shown.
@ -34,7 +34,8 @@ public class Settings {
|
||||
USE_DATABASE("use-database", false),
|
||||
SELECTION_ITEM("npc.selection.item", 280),
|
||||
SELECTION_MESSAGE("npc.selection.message", "<b>You selected <a><npc><b>!"),
|
||||
QUICK_SELECT("npc.selection.quick-select", false);
|
||||
QUICK_SELECT("npc.selection.quick-select", false),
|
||||
PRINT_CHAT_TO_CONSOLE("npc.chat.print-to-console", true);
|
||||
|
||||
private String path;
|
||||
private Object value;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.citizensnpcs.npc;
|
||||
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.DataKey;
|
||||
import net.citizensnpcs.api.event.NPCDespawnEvent;
|
||||
import net.citizensnpcs.api.event.NPCSpawnEvent;
|
||||
@ -15,6 +16,7 @@ import net.citizensnpcs.util.Messaging;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CitizensNPC extends AbstractNPC {
|
||||
private CraftNPC mcEntity;
|
||||
@ -90,6 +92,15 @@ public class CitizensNPC extends AbstractNPC {
|
||||
spawned = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chat(String message) {
|
||||
String formatted = "<" + getFullName() + "> " + message;
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
player.sendMessage(formatted);
|
||||
if (Setting.PRINT_CHAT_TO_CONSOLE.getBoolean())
|
||||
Messaging.log(formatted);
|
||||
}
|
||||
|
||||
public void save(Storage saves) {
|
||||
DataKey key = saves.getKey("npc." + getId());
|
||||
key.setString("name", getFullName());
|
||||
|
Loading…
Reference in New Issue
Block a user