Use PlaceholderAPI for /npc command

This commit is contained in:
fullwall 2020-01-16 20:40:32 +09:00
parent 529855bd6d
commit 89874092ed
3 changed files with 5 additions and 3 deletions

View File

@ -67,8 +67,9 @@ public class TalkableEntity implements Talkable {
} }
private void talk(String message) { private void talk(String message) {
if (entity instanceof Player && !CitizensAPI.getNPCRegistry().isNPC(entity)) if (entity instanceof Player && !CitizensAPI.getNPCRegistry().isNPC(entity)) {
Messaging.send((Player) entity, message); Messaging.send((Player) entity, message);
}
} }
@Override @Override

View File

@ -18,6 +18,7 @@ import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName; import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.api.util.DataKey; import net.citizensnpcs.api.util.DataKey;
import net.citizensnpcs.api.util.Messaging; import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.Placeholders;
import net.citizensnpcs.util.Messages; import net.citizensnpcs.util.Messages;
@TraitName("commandtrait") @TraitName("commandtrait")
@ -113,7 +114,7 @@ public class CommandTrait extends Trait {
} }
public void run(NPC npc, Player clicker) { public void run(NPC npc, Player clicker) {
String interpolatedCommand = command.replace("<npc>", npc.getName()).replace("<p>", clicker.getName()); String interpolatedCommand = Placeholders.replace(command, clicker, npc);
if (player) { if (player) {
boolean wasOp = clicker.isOp(); boolean wasOp = clicker.isOp();
if (op) { if (op) {

View File

@ -1,6 +1,6 @@
name: Citizens name: Citizens
authors: [fullwall] authors: [fullwall]
softdepend: [Vault] softdepend: [Vault, PlaceholderAPI]
version: ${project.version} (build ${BUILD_NUMBER}) version: ${project.version} (build ${BUILD_NUMBER})
main: net.citizensnpcs.Citizens main: net.citizensnpcs.Citizens
website: http://www.citizensnpcs.co website: http://www.citizensnpcs.co