Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jline3 and other console improvements #935

Open
wants to merge 46 commits into
base: dev
from
Open

Jline3 and other console improvements #935

wants to merge 46 commits into from

Conversation

@mastercoms
Copy link
Member

@mastercoms mastercoms commented Jun 1, 2018

This moves Glowstone to jline3. It comes with a better formatted console, compatibility improvements and more.

In addition to jline3, there are also new console manager tasks in addition to the already present command task: evaluation tasks and console tasks. EvalTasks parse Java code from the console and ConsoleTasks add new ways to customize the console through binds (not implemented), settings, keymaps and widgets.

Co-authored-by: Pr0methean 4961925+Pr0methean@users.noreply.github.com

mastercoms added 30 commits May 8, 2017
Fixes bug with returnable statements not using the parsed command
Adds support for multiple classes
Adds ability to reference last returned output with the "last" variable (must be cast to type)
mastercoms added 4 commits Jun 1, 2018
@NonNls private static String CONSOLE_DATE = "HH:mm:ss";
@NonNls private static String FILE_DATE = "yyyy/MM/dd HH:mm:ss";
@NonNls private static String CONSOLE_PROMPT = ">";
@NonNls private static String CONSOLE_PROMPT = "> "; // TODO: fix prompt

This comment has been minimized.

@Pr0methean

Pr0methean Jun 3, 2018
Contributor

What's the problem here? Document in detail or link a bug.

addReplacement(ChatColor.RESET, "\u001B[39;0m"); // NON-NLS
}

private static void addReplacement(ChatColor formatting, String ansi) {

This comment has been minimized.

@Pr0methean

Pr0methean Jun 3, 2018
Contributor

Make Ansi @NonNls, and then the // NON-NLS comments probably won't be needed.

this.level = level;
}
if (record.getThrown() != null) {
// StringWriter's close() is trivial

This comment has been minimized.

@Pr0methean

Pr0methean Jun 3, 2018
Contributor

Use try-with-resources anyway, for future-proofing. It's probably equally concise.

for (ChatColor color : colors) {
if (this.color && replacements.containsKey(color)) {
string = string.replaceAll("(?i)" + color, replacements.get(color));
} else {

This comment has been minimized.

@Pr0methean

Pr0methean Jun 3, 2018
Contributor

Just use the ternary operator here.

}
candidates.addAll(completions);
completions = server.getScheduler().syncIfNeeded(() -> server.getCommandMap()
.tabComplete(sender, line.line()));

This comment has been minimized.

@Pr0methean

Pr0methean Jun 3, 2018
Contributor

Keep the lambda on one line.

if (task.call()) {
try {
Object returned = MethodInvocationUtils
.invokeStaticMethod(getCompiledClass("REPLShell"), "run",

This comment has been minimized.

@Pr0methean

Pr0methean Jun 3, 2018
Contributor

Move the methods of MethodInvocationUtils to this class, unless and until another class uses them.

+ '"')); // NON-NLS
if (command.startsWith("$")) { // NON-NLS
server.getScheduler().runTask(null,
new EvalTask(command.substring(1), command.startsWith("$$")));

This comment has been hidden.

@Pr0methean

Pr0methean Jun 3, 2018
Contributor

Add a config setting that disables this mode. Disable it by default, unless that would break mod compatibility, and maybe even then. That way, gaining control of the console doesn't allow arbitrary code execution if the legit admin doesn't use it.

@@ -0,0 +1,14 @@
package net.glowstone.i18n;

This comment has been minimized.

@Pr0methean

Pr0methean Jun 3, 2018
Contributor

Why not just add these methods to LoggableLocalizedString instead?

import java.util.logging.Level;
import javax.tools.FileObject;
import javax.tools.ForwardingJavaFileManager;
import javax.tools.JavaCompiler;

This comment has been hidden.

@Pr0methean

Pr0methean Jun 3, 2018
Contributor

Can we build this as a nested jar or something, and avoid trying to load it on JVMs that don't have the java.compiler module (JDK 9+) or are the compact profiles (JDK 8), rather than breaking compatibility with those JVMs?

}
}

public class ClassDataOutputStream extends OutputStream {

This comment has been minimized.

@Pr0methean

Pr0methean Jun 3, 2018
Contributor

What does this do differently than the underlying ByteArrayOutputStream? If this can't simply be replaced by a BAOS, document why not, and can we use a FilterOutputStream instead?

Pr0methean added 10 commits Jun 6, 2018
Restores compatibility with mastercoms' commits.
@Pr0methean
Copy link
Contributor

@Pr0methean Pr0methean commented Jun 6, 2018

@mastercoms asked me to commit the changes I could. I've done that; the REPL implementation is now on branch jline3repl.

@VaiTon
Copy link
Contributor

@VaiTon VaiTon commented Feb 10, 2019

Why is this stalled?

@mastercoms
Copy link
Member Author

@mastercoms mastercoms commented Feb 10, 2019

Unfortunately, we encountered regressions in the terminal on Windows. I haven't tested the latest version to see if it was fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.