Skip to content

Commit 87c8f12

Browse files
committed
player message action
1 parent f98bcfe commit 87c8f12

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

spaceNPC/src/main/java/me/tofaa/entitylib/npc/interactions/InteractionAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class InteractionAction {
99

1010
public static final String RUN_COMMAND = "RUN_COMMAND";
1111
public static final String MESSAGE = "MESSAGE";
12+
public static final String PLAYER_CHAT = "PLAYER_CHAT";
1213

1314
private InteractionType type;
1415
private String actionType;

spaceNPC/src/main/java/me/tofaa/entitylib/npc/interactions/InteractionHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ private static void executeActions(List<InteractionAction> actions, Player playe
4848
Bukkit.getScheduler().runTask(SpaceNPC.getInstance(), () -> {
4949
executeCommand(player, value, npc);
5050
});
51+
} else if (InteractionAction.PLAYER_CHAT.equals(actionType)) {
52+
Bukkit.getScheduler().runTask(SpaceNPC.getInstance(), () -> {
53+
player.chat(value.replace("%player%", player.getName()).replace("%npc%", npc.getId()));
54+
});
5155
} else if (InteractionAction.MESSAGE.equals(actionType)) {
5256
player.sendMessage(value.replace("%player%", player.getName()));
5357
}
@@ -63,12 +67,8 @@ private static void executeCommand(Player player, String command, NPC npc) {
6367
finalCommand = finalCommand.substring(1);
6468
}
6569

66-
boolean isOp = player.isOp();
6770
try {
68-
Bukkit.dispatchCommand(
69-
Bukkit.getConsoleSender(),
70-
finalCommand
71-
);
71+
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), finalCommand);
7272
} catch (Exception e) {
7373
LOGGER.warning("[SpaceNPC] Failed to execute command '" + finalCommand + "' for player " + player.getName() + ": " + e.getMessage());
7474
}

0 commit comments

Comments
 (0)