mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-10 16:01:50 -04:00
set default TextComponent color to white, fixes
This commit is contained in:
parent
b6db5558a1
commit
25e9856d1a
@ -157,7 +157,9 @@ public class TextComponent extends ChatComponent {
|
|||||||
@Override
|
@Override
|
||||||
public ObservableList<Node> getJavaFXText(ObservableList<Node> nodes) {
|
public ObservableList<Node> getJavaFXText(ObservableList<Node> nodes) {
|
||||||
Text text = new Text(this.text);
|
Text text = new Text(this.text);
|
||||||
if (color != null) {
|
if (color == null) {
|
||||||
|
text.setFill(Color.WHITE);
|
||||||
|
} else {
|
||||||
text.setFill(Color.web(color.toString()));
|
text.setFill(Color.web(color.toString()));
|
||||||
}
|
}
|
||||||
formatting.forEach((chatFormattingCode -> {
|
formatting.forEach((chatFormattingCode -> {
|
||||||
|
@ -207,7 +207,12 @@ public class MainWindow implements Initializable {
|
|||||||
ServerListCell.listView.getItems().add(server1);
|
ServerListCell.listView.getItems().add(server1);
|
||||||
} else {
|
} else {
|
||||||
server1.setName(serverName);
|
server1.setName(serverName);
|
||||||
|
server1.setAddress(serverAddress);
|
||||||
server1.setDesiredVersionId(desiredVersionId);
|
server1.setDesiredVersionId(desiredVersionId);
|
||||||
|
if (server1.getCell() != null) {
|
||||||
|
server1.getCell().setName(server1.getName());
|
||||||
|
//ToDo: version
|
||||||
|
}
|
||||||
}
|
}
|
||||||
server1.saveToConfig();
|
server1.saveToConfig();
|
||||||
Log.info(String.format("%s and saved server (serverName=%s, serverAddress=%s, version=%d)", ((server == null) ? "Added" : "Edited"), serverName.getLegacyText(), serverAddress, desiredVersionId));
|
Log.info(String.format("%s and saved server (serverName=%s, serverAddress=%s, version=%d)", ((server == null) ? "Added" : "Edited"), serverName.getLegacyText(), serverAddress, desiredVersionId));
|
||||||
|
@ -36,6 +36,7 @@ public class Server {
|
|||||||
private byte[] favicon;
|
private byte[] favicon;
|
||||||
private Connection lastPing;
|
private Connection lastPing;
|
||||||
private boolean readOnly = false;
|
private boolean readOnly = false;
|
||||||
|
private ServerListCell cell;
|
||||||
|
|
||||||
public Server(int id, BaseComponent name, String address, int desiredVersion, byte[] favicon) {
|
public Server(int id, BaseComponent name, String address, int desiredVersion, byte[] favicon) {
|
||||||
this(id, name, address, desiredVersion);
|
this(id, name, address, desiredVersion);
|
||||||
@ -192,4 +193,12 @@ public class Server {
|
|||||||
public boolean isReadOnly() {
|
public boolean isReadOnly() {
|
||||||
return readOnly;
|
return readOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ServerListCell getCell() {
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCell(ServerListCell cell) {
|
||||||
|
this.cell = cell;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import de.bixilon.minosoft.data.locale.LocaleManager;
|
|||||||
import de.bixilon.minosoft.data.locale.Strings;
|
import de.bixilon.minosoft.data.locale.Strings;
|
||||||
import de.bixilon.minosoft.data.mappings.versions.Version;
|
import de.bixilon.minosoft.data.mappings.versions.Version;
|
||||||
import de.bixilon.minosoft.data.mappings.versions.Versions;
|
import de.bixilon.minosoft.data.mappings.versions.Versions;
|
||||||
|
import de.bixilon.minosoft.data.text.BaseComponent;
|
||||||
import de.bixilon.minosoft.logging.Log;
|
import de.bixilon.minosoft.logging.Log;
|
||||||
import de.bixilon.minosoft.modding.event.EventInvokerCallback;
|
import de.bixilon.minosoft.modding.event.EventInvokerCallback;
|
||||||
import de.bixilon.minosoft.modding.event.events.ConnectionStateChangeEvent;
|
import de.bixilon.minosoft.modding.event.events.ConnectionStateChangeEvent;
|
||||||
@ -32,6 +33,7 @@ import de.bixilon.minosoft.protocol.ping.ServerListPing;
|
|||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
|
import javafx.scene.Node;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
@ -113,10 +115,11 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
|||||||
if (server.equals(this.server)) {
|
if (server.equals(this.server)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
server.setCell(this);
|
||||||
resetCell();
|
resetCell();
|
||||||
|
|
||||||
this.server = server;
|
this.server = server;
|
||||||
nameField.getChildren().setAll(server.getName().getJavaFXText());
|
setName(server.getName());
|
||||||
|
|
||||||
Image favicon = GUITools.getImage(server.getFavicon());
|
Image favicon = GUITools.getImage(server.getFavicon());
|
||||||
if (favicon == null) {
|
if (favicon == null) {
|
||||||
@ -195,6 +198,13 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
|||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setName(BaseComponent name) {
|
||||||
|
nameField.getChildren().setAll(name.getJavaFXText());
|
||||||
|
for (Node node : nameField.getChildren()) {
|
||||||
|
node.setStyle("-fx-font-size: 15pt ;");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void resetCell() {
|
private void resetCell() {
|
||||||
// clear all cells
|
// clear all cells
|
||||||
setStyle(null);
|
setStyle(null);
|
||||||
|
@ -333,13 +333,8 @@ public class PacketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handle(PacketEntityVelocity pkg) {
|
public void handle(PacketEntityVelocity pkg) {
|
||||||
Entity entity;
|
Entity entity = connection.getPlayer().getWorld().getEntity(pkg.getEntityId());
|
||||||
if (pkg.getEntityId() == connection.getPlayer().getEntity().getEntityId()) {
|
|
||||||
// that's us!
|
|
||||||
entity = connection.getPlayer().getEntity();
|
|
||||||
} else {
|
|
||||||
entity = connection.getPlayer().getWorld().getEntity(pkg.getEntityId());
|
|
||||||
}
|
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
// thanks mojang
|
// thanks mojang
|
||||||
return;
|
return;
|
||||||
@ -490,6 +485,7 @@ public class PacketHandler {
|
|||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
nbt.writeTag(String.format("Text%d", (i + 1)), new StringTag(pkg.getLines()[i].getLegacyText()));
|
nbt.writeTag(String.format("Text%d", (i + 1)), new StringTag(pkg.getLines()[i].getLegacyText()));
|
||||||
}
|
}
|
||||||
|
// ToDo: handle sign updates
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(PacketEntityAnimation pkg) {
|
public void handle(PacketEntityAnimation pkg) {
|
||||||
@ -585,7 +581,7 @@ public class PacketHandler {
|
|||||||
connection.fireEvent(new SingleSlotChangeEvent(connection, pkg));
|
connection.fireEvent(new SingleSlotChangeEvent(connection, pkg));
|
||||||
|
|
||||||
if (pkg.getWindowId() == -1) {
|
if (pkg.getWindowId() == -1) {
|
||||||
// invalid window Id
|
// thanks mojang
|
||||||
// ToDo: what is windowId -1
|
// ToDo: what is windowId -1
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -639,9 +635,8 @@ public class PacketHandler {
|
|||||||
case CREATE_UPDATE -> connection.getPlayer().getScoreboardManager().getObjective(pkg.getScoreName()).addScore(new ScoreboardScore(pkg.getItemName(), pkg.getScoreName(), pkg.getScoreValue()));
|
case CREATE_UPDATE -> connection.getPlayer().getScoreboardManager().getObjective(pkg.getScoreName()).addScore(new ScoreboardScore(pkg.getItemName(), pkg.getScoreName(), pkg.getScoreValue()));
|
||||||
case REMOVE -> {
|
case REMOVE -> {
|
||||||
ScoreboardObjective objective = connection.getPlayer().getScoreboardManager().getObjective(pkg.getScoreName());
|
ScoreboardObjective objective = connection.getPlayer().getScoreboardManager().getObjective(pkg.getScoreName());
|
||||||
if (objective == null) {
|
if (objective != null) {
|
||||||
Log.warn(String.format("Server tried to remove score witch was not created before (itemName=\"%s\", scoreName=\"%s\")!", pkg.getItemName(), pkg.getScoreName()));
|
// thanks mojang
|
||||||
} else {
|
|
||||||
objective.removeScore(pkg.getItemName());
|
objective.removeScore(pkg.getItemName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Minosoft
|
||||||
|
~ Copyright (C) 2020 Moritz Zwerger
|
||||||
|
~
|
||||||
|
~ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
~
|
||||||
|
~ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU General Public License along with this program.If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
~
|
||||||
|
~ This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
-->
|
||||||
|
|
||||||
<?import javafx.geometry.*?>
|
<?import javafx.geometry.*?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user