mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 01:48:04 -04:00
annotate ChatComponent::valueOf with @JvmOverloads
This commit is contained in:
parent
1c0f95cc4c
commit
f30de97e31
@ -262,7 +262,7 @@ public enum EntityMetaDataFields {
|
|||||||
MINECART_FURNACE_HAS_FUEL(false),
|
MINECART_FURNACE_HAS_FUEL(false),
|
||||||
|
|
||||||
MINECART_COMMAND_BLOCK_COMMAND(""),
|
MINECART_COMMAND_BLOCK_COMMAND(""),
|
||||||
MINECART_COMMAND_BLOCK_LAST_OUTPUT(ChatComponent.Companion.valueOf(null, null, "")),
|
MINECART_COMMAND_BLOCK_LAST_OUTPUT(ChatComponent.Companion.valueOf("")),
|
||||||
|
|
||||||
PRIMED_TNT_FUSE_TIME(80),
|
PRIMED_TNT_FUSE_TIME(80),
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ interface ChatComponent {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
@JvmOverloads
|
||||||
fun valueOf(translator: Translator? = null, parent: TextComponent? = null, raw: Any?): ChatComponent {
|
fun valueOf(translator: Translator? = null, parent: TextComponent? = null, raw: Any?): ChatComponent {
|
||||||
if (raw == null) {
|
if (raw == null) {
|
||||||
return BaseComponent()
|
return BaseComponent()
|
||||||
|
@ -37,7 +37,7 @@ public class HoverEvent {
|
|||||||
}
|
}
|
||||||
json.get("value");
|
json.get("value");
|
||||||
this.value = switch (this.action) { // ToDo
|
this.value = switch (this.action) { // ToDo
|
||||||
case SHOW_TEXT -> ChatComponent.Companion.valueOf(null, null, data);
|
case SHOW_TEXT -> ChatComponent.Companion.valueOf(data);
|
||||||
case SHOW_ENTITY -> EntityHoverData.deserialize(data);
|
case SHOW_ENTITY -> EntityHoverData.deserialize(data);
|
||||||
default -> null;
|
default -> null;
|
||||||
};
|
};
|
||||||
@ -79,7 +79,7 @@ public class HoverEvent {
|
|||||||
if (json.has("type")) {
|
if (json.has("type")) {
|
||||||
type = new ResourceLocation(json.get("type").getAsString());
|
type = new ResourceLocation(json.get("type").getAsString());
|
||||||
}
|
}
|
||||||
return new EntityHoverData(Util.getUUIDFromString(json.get("id").getAsString()), type, ChatComponent.Companion.valueOf(null, null, json.get("name")));
|
return new EntityHoverData(Util.getUUIDFromString(json.get("id").getAsString()), type, ChatComponent.Companion.valueOf(json.get("name")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ public class MainWindow implements Initializable {
|
|||||||
|
|
||||||
submitButton.setOnAction(actionEvent -> {
|
submitButton.setOnAction(actionEvent -> {
|
||||||
Server server1 = server;
|
Server server1 = server;
|
||||||
ChatComponent serverName = ChatComponent.Companion.valueOf(null, null, serverNameField.getText());
|
ChatComponent serverName = ChatComponent.Companion.valueOf(serverNameField.getText());
|
||||||
String serverAddress = DNSUtil.correctHostName(serverAddressField.getText());
|
String serverAddress = DNSUtil.correctHostName(serverAddressField.getText());
|
||||||
int desiredVersionId = GUITools.VERSION_COMBO_BOX.getSelectionModel().getSelectedItem().getVersionId();
|
int desiredVersionId = GUITools.VERSION_COMBO_BOX.getSelectionModel().getSelectedItem().getVersionId();
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class Server {
|
|||||||
}
|
}
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.addressName = ChatComponent.Companion.valueOf(null, null, address);
|
this.addressName = ChatComponent.Companion.valueOf(address);
|
||||||
this.desiredVersion = desiredVersion;
|
this.desiredVersion = desiredVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ public class Server {
|
|||||||
|
|
||||||
public Server(ServerAddress address) {
|
public Server(ServerAddress address) {
|
||||||
this.id = getNextServerId();
|
this.id = getNextServerId();
|
||||||
this.name = ChatComponent.Companion.valueOf(null, null, String.format("LAN Server #%d", LANServerListener.getServerMap().size()));
|
this.name = ChatComponent.Companion.valueOf(String.format("LAN Server #%d", LANServerListener.getServerMap().size()));
|
||||||
this.address = address.toString();
|
this.address = address.toString();
|
||||||
this.desiredVersion = -1; // Automatic
|
this.desiredVersion = -1; // Automatic
|
||||||
this.readOnly = true;
|
this.readOnly = true;
|
||||||
@ -75,7 +75,7 @@ public class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Server deserialize(Map<String, Object> json) {
|
public static Server deserialize(Map<String, Object> json) {
|
||||||
Server server = new Server((int) (double) json.get("id"), ChatComponent.Companion.valueOf(null, null, json.get("name")), (String) json.get("address"), (int) (double) json.get("version"));
|
Server server = new Server((int) (double) json.get("id"), ChatComponent.Companion.valueOf(json.get("name")), (String) json.get("address"), (int) (double) json.get("version"));
|
||||||
if (json.containsKey("favicon")) {
|
if (json.containsKey("favicon")) {
|
||||||
server.setFavicon(Base64.getDecoder().decode((String) json.get("favicon")));
|
server.setFavicon(Base64.getDecoder().decode((String) json.get("favicon")));
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ public class Server {
|
|||||||
|
|
||||||
public void setAddress(String address) {
|
public void setAddress(String address) {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.addressName = ChatComponent.Companion.valueOf(null, null, address);
|
this.addressName = ChatComponent.Companion.valueOf(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ping() {
|
public void ping() {
|
||||||
|
@ -44,7 +44,7 @@ public class PacketLoginSuccess extends PlayS2CPacket {
|
|||||||
|
|
||||||
var playerEntity = connection.getPlayer().getEntity();
|
var playerEntity = connection.getPlayer().getEntity();
|
||||||
playerEntity.getTabListItem().setName(this.playerName);
|
playerEntity.getTabListItem().setName(this.playerName);
|
||||||
playerEntity.getTabListItem().setDisplayName(ChatComponent.Companion.valueOf(null, null, this.playerName));
|
playerEntity.getTabListItem().setDisplayName(ChatComponent.Companion.valueOf(this.playerName));
|
||||||
|
|
||||||
connection.getWorld().addEntity(null, this.uuid, playerEntity);
|
connection.getWorld().addEntity(null, this.uuid, playerEntity);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class ServerListPing {
|
|||||||
this.favicon = Base64.getDecoder().decode(json.get("favicon").getAsString().replace("data:image/png;base64,", "").replace("\n", ""));
|
this.favicon = Base64.getDecoder().decode(json.get("favicon").getAsString().replace("data:image/png;base64,", "").replace("\n", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.motd = ChatComponent.Companion.valueOf(localeManager, null, json.get("description"));
|
this.motd = ChatComponent.Companion.valueOf(localeManager, json.get("description"));
|
||||||
this.serverBrand = json.getAsJsonObject("version").get("name").getAsString();
|
this.serverBrand = json.getAsJsonObject("version").get("name").getAsString();
|
||||||
|
|
||||||
if (json.has("modinfo") && json.getAsJsonObject("modinfo").has("type") && json.getAsJsonObject("modinfo").get("type").getAsString().equals("FML")) {
|
if (json.has("modinfo") && json.getAsJsonObject("modinfo").has("type") && json.getAsJsonObject("modinfo").get("type").getAsString().equals("FML")) {
|
||||||
|
@ -130,7 +130,7 @@ public class PacketSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendFakeChatMessage(String message) {
|
public void sendFakeChatMessage(String message) {
|
||||||
sendFakeChatMessage(ChatComponent.Companion.valueOf(null, null, message), ChatTextPositions.CHAT_BOX);
|
sendFakeChatMessage(ChatComponent.Companion.valueOf(message), ChatTextPositions.CHAT_BOX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectSlot(@IntRange(from = 0, to = 8) int slot) {
|
public void selectSlot(@IntRange(from = 0, to = 8) int slot) {
|
||||||
|
@ -186,11 +186,7 @@ class PlayInByteBuffer : InByteBuffer {
|
|||||||
return Ingredient(readItemStackArray())
|
return Ingredient(readItemStackArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(message = "Legacy only", replaceWith = ReplaceWith("readIngredientArray(readVarInt())"))
|
@JvmOverloads
|
||||||
fun readIngredientArray(): Array<Ingredient> {
|
|
||||||
return readIngredientArray(readVarInt())
|
|
||||||
}
|
|
||||||
|
|
||||||
fun readIngredientArray(length: Int = readVarInt()): Array<Ingredient> {
|
fun readIngredientArray(length: Int = readVarInt()): Array<Ingredient> {
|
||||||
return readArray(length) { readIngredient() }
|
return readArray(length) { readIngredient() }
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public class CommandServer extends Command {
|
|||||||
if (version == null) {
|
if (version == null) {
|
||||||
version = Versions.AUTOMATIC_VERSION;
|
version = Versions.AUTOMATIC_VERSION;
|
||||||
}
|
}
|
||||||
Server server = new Server(ChatComponent.Companion.valueOf(null, null, name), address, version);
|
Server server = new Server(ChatComponent.Companion.valueOf(name), address, version);
|
||||||
|
|
||||||
server.saveToConfig();
|
server.saveToConfig();
|
||||||
print("Added server %s (address=%s, version=%d)", server.getName(), server.getAddress(), server.getDesiredVersionId());
|
print("Added server %s (address=%s, version=%d)", server.getName(), server.getAddress(), server.getDesiredVersionId());
|
||||||
|
@ -109,8 +109,8 @@ public class Log {
|
|||||||
builder.append(level.name());
|
builder.append(level.name());
|
||||||
builder.append("] ");
|
builder.append("] ");
|
||||||
builder.append(prefix);
|
builder.append(prefix);
|
||||||
var component = (BaseComponent) ChatComponent.Companion.valueOf(null, null, builder.toString());
|
var component = (BaseComponent) ChatComponent.Companion.valueOf(builder.toString());
|
||||||
var messageComponent = (BaseComponent) ChatComponent.Companion.valueOf(null, null, message);
|
var messageComponent = (BaseComponent) ChatComponent.Companion.valueOf(message);
|
||||||
if (color != null && StaticConfiguration.COLORED_LOG) {
|
if (color != null && StaticConfiguration.COLORED_LOG) {
|
||||||
messageComponent.applyDefaultColor(color);
|
messageComponent.applyDefaultColor(color);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,8 @@ enum class NBTTagTypes {
|
|||||||
LIST,
|
LIST,
|
||||||
COMPOUND,
|
COMPOUND,
|
||||||
INT_ARRAY,
|
INT_ARRAY,
|
||||||
LONG_ARRAY;
|
LONG_ARRAY,
|
||||||
|
;
|
||||||
|
|
||||||
companion object : ValuesEnum<NBTTagTypes> {
|
companion object : ValuesEnum<NBTTagTypes> {
|
||||||
override val VALUES: Array<NBTTagTypes> = values()
|
override val VALUES: Array<NBTTagTypes> = values()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user