Add standard tooltip for insertion strings.

This commit is contained in:
ulumulu1510 2016-11-10 17:50:41 +01:00
parent bd01a47a91
commit a1e56098b7

View File

@ -259,15 +259,19 @@ public class Mson implements Serializable
public Mson strikethrough(Boolean strikethrough) { return Mson.valueOf(text, color, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertion, extra, parent); } public Mson strikethrough(Boolean strikethrough) { return Mson.valueOf(text, color, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertion, extra, parent); }
public Mson obfuscated(Boolean obfuscated) { return Mson.valueOf(text, color, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertion, extra, parent); } public Mson obfuscated(Boolean obfuscated) { return Mson.valueOf(text, color, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertion, extra, parent); }
private Mson createTooltip(Boolean override, String created)
{
if (created == null) override = false;
if (override == null) override = (this.getTooltip() == null && this.getItem() == null);
return override ? this.tooltip(created) : this;
}
public Mson event(Boolean tooltip, MsonEventType type, MsonEvent event) public Mson event(Boolean tooltip, MsonEventType type, MsonEvent event)
{ {
if (type == null) type = event.getType(); if (type == null) type = event.getType();
Mson ret = type.set(this, event); Mson ret = type.set(this, event);
String created = event.createTooltip(); String created = event.createTooltip();
if (created == null) tooltip = false; return ret.createTooltip(tooltip, created);
if (tooltip == null) tooltip = (this.getTooltip() == null && this.getItem() == null);
if (tooltip) ret = ret.tooltip(created);
return ret;
} }
public Mson event(Boolean tooltip, MsonEvent event) public Mson event(Boolean tooltip, MsonEvent event)
{ {
@ -282,7 +286,13 @@ public class Mson implements Serializable
return this.event(null, null, event); return this.event(null, null, event);
} }
public Mson insertionString(String insertionString) { return Mson.valueOf(text, color, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertionString, extra, parent); } public Mson insertionString(String insertionString, Boolean tooltip)
{
String prefix = Txt.parse("<h>Shift-Click Insert: <c>");
Mson ret = Mson.valueOf(text, color, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertionString, extra, parent);
return ret.createTooltip(tooltip, prefix + insertionString);
}
public Mson insertionString (String insertionString) { return this.insertionString(insertionString, null); }
public Mson extra(List<Mson> extra) { return Mson.valueOf(text, color, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertion, extra, parent); } public Mson extra(List<Mson> extra) { return Mson.valueOf(text, color, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertion, extra, parent); }
public Mson extra(Mson[] extra) { return Mson.valueOf(text, color, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertion, extra == null ? null : ImmutableList.copyOf(extra), parent); } public Mson extra(Mson[] extra) { return Mson.valueOf(text, color, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertion, extra == null ? null : ImmutableList.copyOf(extra), parent); }
public Mson parent(Mson parent) { return Mson.valueOf(text, color, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertion, extra, parent); } public Mson parent(Mson parent) { return Mson.valueOf(text, color, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertion, extra, parent); }