use of io.github.wysohn.triggerreactor.tools.ScriptEditor in project TriggerReactor by wysohn.
the class ScriptEditManager method startEdit.
@Override
public void startEdit(ICommandSender sender, String title, String script, SaveHandler saveHandler) {
ConversationFactory factory = new ConversationFactory(plugin.getMain());
EditingPrompt prompt = new EditingPrompt(plugin.getMain(), sender.get(), new ScriptEditor(title, script, saveHandler));
Conversation conv = factory.thatExcludesNonPlayersWithMessage("Sorry, this is in-game only feature!").withFirstPrompt(new UsagePrompt(prompt)).addConversationAbandonedListener(this).buildConversation(sender.get());
conv.getContext().setSessionData("edit", prompt);
conv.begin();
}
use of io.github.wysohn.triggerreactor.tools.ScriptEditor in project TriggerReactor by wysohn.
the class ScriptEditManager method onChat.
@Listener
public void onChat(MessageChannelEvent.Chat e, @First MessageReceiver receiver) {
if (!editings.containsKey(receiver))
return;
e.setCancelled(true);
ScriptEditor editor = editings.get(receiver);
Text message = e.getRawMessage();
String arg1 = message.toPlainSingle();
if (arg1.equals("save")) {
try {
editor.save();
} catch (IOException | ScriptException ex) {
plugin.handleException(e, ex);
}
editings.remove(receiver);
} else if (arg1.equals("exit")) {
editings.remove(receiver);
} else if (arg1.equals("il")) {
editor.insertNewLine();
} else if (arg1.equals("dl")) {
editor.deleteLine();
} else if (arg1.length() > 0 && arg1.charAt(0) == 'u') {
String[] split = arg1.split(" ");
int lines = 1;
try {
lines = split.length > 1 ? Integer.parseInt(split[1]) : 1;
} catch (NumberFormatException ex) {
plugin.handleException(e, ex);
}
editor.up(lines);
} else if (arg1.length() > 0 && arg1.charAt(0) == 'd') {
String[] split = arg1.split(" ");
int lines = 1;
try {
lines = split.length > 1 ? Integer.parseInt(split[1]) : 1;
} catch (NumberFormatException ex) {
plugin.handleException(e, ex);
}
editor.down(lines);
} else {
editor.intput(arg1.replaceAll("\\$", " "));
}
}
use of io.github.wysohn.triggerreactor.tools.ScriptEditor in project TriggerReactor by wysohn.
the class ScriptEditManager method startEdit.
@Override
public void startEdit(ICommandSender sender, String title, String script, SaveHandler saveHandler) {
if (editings.containsKey(sender))
return;
ScriptEditor editor = new ScriptEditor(title, script, saveHandler);
editings.put(sender, editor);
}
Aggregations