added ability to send chat through an NPC

This commit is contained in:
aPunch 2012-01-25 04:32:24 -06:00
parent 3469f017f5
commit 84858b2c23
3 changed files with 13 additions and 1 deletions

Binary file not shown.

View File

@ -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;

View File

@ -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());