Skip to content

Commit

Permalink
Fixes related with ANSI colors
Browse files Browse the repository at this point in the history
  • Loading branch information
mesacarlos committed Jul 25, 2024
1 parent ef7ebdc commit 652a81b
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/mesacarlos/WebConsole)](https://github.com/mesacarlos/WebConsole/releases/latest)
![GitHub All Releases](https://img.shields.io/github/downloads/mesacarlos/WebConsole/total?label=total%20downloads)

WebConsole is a Spigot plugin for Minecraft 1.8-1.18+ that allows you to view your server console and manage your server from anywhere. It creates a WebSocket server in the background used by the web interface to send commands, receive your console log and manage your server.
WebConsole is a Spigot plugin for Minecraft 1.8-1.21+ that allows you to view your server console and manage your server from anywhere. It creates a WebSocket server in the background used by the web interface to send commands, receive your console log and manage your server.

Don't worry about privacy or security: all data is stored in your browser locally and your PC will connect directly to your minecraft server. No intermediary web servers, just you and your MC server.

Expand Down
18 changes: 16 additions & 2 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web-console-client",
"version": "2.5.0",
"version": "2.7.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand Down Expand Up @@ -28,6 +28,7 @@
"@ngx-translate/core": "^14.0.0",
"@ngx-translate/http-loader": "^7.0.0",
"@popperjs/core": "^2.10.2",
"ansi_up": "^6.0.2",
"bootstrap": "^5.1.3",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
Expand Down
26 changes: 6 additions & 20 deletions client/src/app/content/console/console.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { WebSocketResponse } from 'src/app/_dto/response/WebSocketResponse';
import { ServerDto } from 'src/app/_dto/ServerDto';
import { SettingsEnum, StorageService } from 'src/app/_services/storage.service';
import { WebconsoleService } from 'src/app/_services/webconsole.service';
import { AnsiUp } from "ansi_up"

@Component({
selector: 'app-console',
Expand Down Expand Up @@ -211,26 +212,7 @@ export class ConsoleComponent implements OnInit, AfterViewInit, OnDestroy {
msg = msg.replace(/</g, "&lt;");
msg = msg.replace(/(?:\r\n|\r|\n)/g, "<br>");

//Color filter for Windows (thanks to SuperPykkon)
msg = msg.replace(/\[0;30;22m/g, "<span style='color: #000000;'>"); //&0
msg = msg.replace(/\[0;34;22m/g, "<span style='color: #0000AA;'>"); //&1
msg = msg.replace(/\[0;32;22m/g, "<span style='color: #00AA00;'>"); //&2
msg = msg.replace(/\[0;36;22m/g, "<span style='color: #00AAAA;'>"); //&3
msg = msg.replace(/\[0;31;22m/g, "<span style='color: #AA0000;'>"); //&4
msg = msg.replace(/\[0;35;22m/g, "<span style='color: #AA00AA;'>"); //&5
msg = msg.replace(/\[0;33;22m/g, "<span style='color: #FFAA00;'>"); //&6
msg = msg.replace(/\[0;37;22m/g, "<span style='color: #AAAAAA;'>"); //&7
msg = msg.replace(/\[0;30;1m/g, "<span style='color: #555555;'>"); //&8
msg = msg.replace(/\[0;34;1m/g, "<span style='color: #5555FF;'>"); //&9
msg = msg.replace(/\[0;32;1m/g, "<span style='color: #55FF55;'>"); //&a
msg = msg.replace(/\[0;36;1m/g, "<span style='color: #55FFFF;'>"); //&b
msg = msg.replace(/\[0;31;1m/g, "<span style='color: #FF5555;'>"); //&c
msg = msg.replace(/\[0;35;1m/g, "<span style='color: #FF55FF;'>"); //&d
msg = msg.replace(/\[0;33;1m/g, "<span style='color: #FFFF55;'>"); //&e
msg = msg.replace(/\[0;37;1m/g, "<span style='color: #FFFFFF;'>"); //&f
msg = msg.replace(/\[m/g, "</span>"); //&f

//Color filter for UNIX (This is easier!)
//Color filter for MC codes.
msg = msg.replace(/§0/g, "<span style='color: #000000;'>"); //&0
msg = msg.replace(/§1/g, "<span style='color: #0000AA;'>"); //&1
msg = msg.replace(/§2/g, "<span style='color: #00AA00;'>"); //&2
Expand Down Expand Up @@ -280,6 +262,10 @@ export class ConsoleComponent implements OnInit, AfterViewInit, OnDestroy {

msg = msg.replace(/r/g, "</span>"); //&r

// ANSI Processing
var ansi_up = new AnsiUp();
msg = ansi_up.ansi_to_html(msg);

//Append datetime if enabled
if (this.storageService.getSetting(SettingsEnum.DateTimePrefix)) {
if (typeof time !== 'undefined' && time !== null) //if time is present and not null
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/core/layout/layout.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</li>
</ul>
<ul class="navbar-nav ms-auto">
<span class="navbar-text">v2.5 - </span>
<span class="navbar-text">v2.7 - </span>
<a class="nav-link" target="_blank" href="https://github.com/mesacarlos/WebConsole">
<fa-icon [icon]="icons.faArrowUpRightFromSquare"></fa-icon> GitHub
</a>
Expand Down
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: WebConsole
main: es.mesacarlos.webconsole.WebConsole
api-version: 1.13
version: 2.6
version: 2.7
description: WebSocket-based web console
author: Carlos Mesa
commands:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>WebConsole</groupId>
<artifactId>WebConsole</artifactId>
<version>2.6</version>
<version>2.7</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
Expand Down
3 changes: 1 addition & 2 deletions src/es/mesacarlos/webconsole/util/LogFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ public Result filter(Logger logger, Level level, Marker marker, Message msg, Thr

@Override
public Result filter(LogEvent event) {
String message = event.getMessage().getFormattedMessage().replaceAll("\u001b"," ");
wsServer.onNewConsoleLinePrinted(message);
wsServer.onNewConsoleLinePrinted(event.getMessage().getFormattedMessage());
return null;
}

Expand Down

0 comments on commit 652a81b

Please sign in to comment.