Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

WIP: General code cleanup #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<img src="assets/magnolia-runtime.png" title="magnolia runtime" alt="magnolia runtime">

**WARNING: This software is still in its early stages, it is NOT production ready! (Well technically it could be, but you know what I mean.)**

Magnolia runtime is a different-ish paper server fork for following reasons:
* Instead of patching server code directly everything will be gradually moved overt to `magnolia-core` module that does not require patches for changes
* Bukkit, Spigot and Paper APIs will be gradually deprecated and their new replacement will be implemented in `magnolia-api` module that again does not require patches for changing things
Expand Down
Binary file added assets/magnolia-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
group=com.example.paperfork
group=org.op65n.magnolia
version=1.18.2-R0.1-SNAPSHOT

mcVersion=1.18.2
paperRef=c449f6a1f712b81b50e250a2e258ef3e37fd6b9b
paperRef=9fd870db0b681b9840706aea4958376492e725b5

org.gradle.caching=true
org.gradle.parallel=true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package org.op65n.magnolia.core;

import org.op65n.magnolia.core.console.ColoredErrorStream;
import org.op65n.magnolia.core.util.SystemProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MagnoliaCore {

public static void bootstrapRuntime() {
SystemProperty.ifMissing("jdk.nio.maxCachedBufferSize", "262144"); // cap per-thread NIO cache size
private static final Logger log = LoggerFactory.getLogger(MagnoliaCore.class);

public static void bootstrapRuntime() {
ColoredErrorStream.overrideStream(); // let's enjoy the red exceptions again, or at least try to :/

SystemProperty.ifMissing("jdk.nio.maxCachedBufferSize", "262144"); // cap per-thread NIO cache size
SystemProperty.ifMissing("java.awt.headless", "true"); // force AWT to work with its head chopped off - thanks Velocity
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package org.op65n.magnolia.core.console;

import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;

/**
* This class overrides default output stream and
* appends ASCII colors to the content, we are only overriding
* error stream with red prefix and reset suffix to get red error
* messages and exceptions in the terminal output
*
* @author sebba
*/
public final class ColoredErrorStream extends OutputStream {

private static final String COLOR_RED = "\033[31m";
private static final String COLOR_RESET = "\033[0m";

private final OutputStream stream;

private ColoredErrorStream(final @NotNull OutputStream stream) {
this.stream = stream;
}

public static void overrideStream() {
final ColoredErrorStream coloredStream = new ColoredErrorStream(System.err);
final PrintStream printStream = new PrintStream(coloredStream, true);

System.setErr(printStream);
}

@Override
public void write(final int b) throws IOException {
stream.write(COLOR_RED.getBytes());
stream.write(b);
stream.write(COLOR_RESET.getBytes());
}

@Override
public void write(final byte @NotNull [] b) throws IOException {
stream.write(COLOR_RED.getBytes());
stream.write(b);
stream.write(COLOR_RESET.getBytes());
}

@Override
public void write(final byte @NotNull [] b, final int off, final int len) throws IOException {
stream.write(COLOR_RED.getBytes());
stream.write(b, off, len);
stream.write(COLOR_RESET.getBytes());
}

@Override
public void flush() throws IOException {
stream.flush();
}

@Override
public void close() throws IOException {
stream.close();
}

}
Loading