[Bleeding] Added Conversations API. Addresses BUKKIT-864
By: rmichela <deltahat@gmail.com>
This commit is contained in:
@@ -42,16 +42,17 @@ public class ColouredConsoleSender extends CraftConsoleCommandSender {
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
if (terminal.isANSISupported()) {
|
||||
String result = message;
|
||||
|
||||
for (ChatColor color : colors) {
|
||||
if (replacements.containsKey(color)) {
|
||||
result = result.replaceAll(color.toString(), replacements.get(color));
|
||||
} else {
|
||||
result = result.replaceAll(color.toString(), "");
|
||||
if (!conversationTracker.isConversingModaly()) {
|
||||
String result = message;
|
||||
for (ChatColor color : colors) {
|
||||
if (replacements.containsKey(color)) {
|
||||
result = result.replaceAll(color.toString(), replacements.get(color));
|
||||
} else {
|
||||
result = result.replaceAll(color.toString(), "");
|
||||
}
|
||||
}
|
||||
System.out.println(result + ANSICodes.attrib(0));
|
||||
}
|
||||
System.out.println(result + ANSICodes.attrib(0));
|
||||
} else {
|
||||
super.sendMessage(message);
|
||||
}
|
||||
|
||||
@@ -2,17 +2,25 @@ package org.bukkit.craftbukkit.command;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.craftbukkit.conversations.ConversationTracker;
|
||||
|
||||
/**
|
||||
* Represents CLI input from a console
|
||||
*/
|
||||
public class CraftConsoleCommandSender extends ServerCommandSender implements ConsoleCommandSender {
|
||||
|
||||
protected ConversationTracker conversationTracker = new ConversationTracker();
|
||||
|
||||
protected CraftConsoleCommandSender() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void sendMessage(String message) {
|
||||
sendRawMessage(message);
|
||||
}
|
||||
|
||||
public void sendRawMessage(String message) {
|
||||
System.out.println(ChatColor.stripColor(message));
|
||||
}
|
||||
|
||||
@@ -33,4 +41,20 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co
|
||||
public void setOp(boolean value) {
|
||||
throw new UnsupportedOperationException("Cannot change operator status of server console");
|
||||
}
|
||||
|
||||
public boolean beginConversation(Conversation conversation) {
|
||||
return conversationTracker.beginConversation(conversation);
|
||||
}
|
||||
|
||||
public void abandonConversation(Conversation conversation) {
|
||||
conversationTracker.abandonConversation(conversation);
|
||||
}
|
||||
|
||||
public void acceptConversationInput(String input) {
|
||||
conversationTracker.acceptConversationInput(input);
|
||||
}
|
||||
|
||||
public boolean isConversing() {
|
||||
return conversationTracker.isConversing();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user