use of com.massivecraft.massivecore.mson.Mson in project MassiveCore by MassiveCraft.
the class TypeCombined method getVisualMsonInner.
// -------------------------------------------- //
// WRITE VISUAL MSON
// -------------------------------------------- //
@SuppressWarnings("unchecked")
@Override
public Mson getVisualMsonInner(T value, CommandSender sender) {
// Create
List<Mson> parts = new MassiveList<>();
// Fill
for (Entry<Type<?>, Object> entry : this.splitEntriesUser(value)) {
Type<Object> type = (Type<Object>) entry.getKey();
Mson part = type.getVisualMson(entry.getValue(), sender);
if (!this.isVisualMsonNullIncluded() && part == null)
continue;
parts.add(part);
}
// Return
return Mson.implode(parts, this.getVisualMsonSeparator());
}
use of com.massivecraft.massivecore.mson.Mson in project MassiveCore by MassiveCraft.
the class Parameter method getTemplate.
public Mson getTemplate(CommandSender sender) {
Mson ret;
if (this.isRequiredFor(sender)) {
ret = mson("<" + this.getName() + ">");
} else {
String def = this.getDefaultDesc();
def = (def != null ? "=" + def : "");
ret = mson("[" + this.getName() + def + "]");
}
return ret;
}
use of com.massivecraft.massivecore.mson.Mson in project MassiveCore by MassiveCraft.
the class CommandEditAbstract method attemptSetPerform.
protected void attemptSetPerform(V after) {
String descProperty = this.getProperty().getDisplayName();
Mson descObject = this.getObjectVisual();
Mson descValue = this.getInheritedVisual();
// Create messages
List<Mson> messages = new MassiveList<>();
// Before
// We inform what the value was before.
messages.add(mson(mson("Before: ").color(ChatColor.AQUA), descValue));
// Apply
// We set the new property value.
this.setValue(after);
// After
// We inform what the value is after.
descValue = this.getInheritedVisual();
messages.add(mson(mson("After: ").color(ChatColor.AQUA), descValue));
// Startup
// We inform what property and object the edit is taking place on.
// The visual might change after modification, so this should be added after we have made the change.
descObject = this.getObjectVisual();
messages.add(0, mson(descProperty, " for ", descObject, " edited:").color(ChatColor.GRAY));
message(messages);
}
use of com.massivecraft.massivecore.mson.Mson in project MassiveCore by MassiveCraft.
the class CommandEditAbstract method show.
public void show(int page) {
List<Mson> show = this.getValueType().getShow(this.getValue(), sender);
Property<O, V> property = this.getProperty();
Mson descProperty = property.getDisplayNameMson();
Mson descObject = this.getObjectVisual();
Mson title;
if (property instanceof PropertyThis) {
title = descObject;
} else {
title = mson(descProperty, " for ", descObject);
}
// For things with line breaks.
if (show.size() > 1) {
message(Txt.getPage(show, page, title, this));
} else // Others
{
message(Mson.prepondfix(title.add(mson(":").color(ChatColor.GRAY)), show, null));
}
}
use of com.massivecraft.massivecore.mson.Mson in project MassiveCore by MassiveCraft.
the class CommandEditContainerAbstract method attemptSetPerform.
@SuppressWarnings("unchecked")
@Override
public void attemptSetPerform(V after) {
V before = this.getInheritedValue();
Mson descProperty = this.getProperty().getDisplayNameMson();
// Apply
// We set the new property value.
this.setValue(after);
// Create messages
List<Mson> messages = new MassiveList<>();
messages.add(mson(descProperty, mson(" for ").color(ChatColor.GRAY), this.getObjectVisual(), mson(" edited:").color(ChatColor.GRAY)));
// Note: The result of getAdditions is not actually V, but the implementation doesn't care.
Collection<Object> additions = ContainerUtil.getAdditions(before, after);
if (!additions.isEmpty()) {
messages.add(Mson.prepondfix(mson("Additions:").color(ChatColor.AQUA), this.getValueType().getVisualMson((V) additions, sender), null));
}
// Note: The result of getDeletions is not actually V, but the implementation doesn't care.
Collection<Object> deletions = ContainerUtil.getDeletions(before, after);
if (!deletions.isEmpty()) {
messages.add(Mson.prepondfix(mson("Deletions:").color(ChatColor.AQUA), this.getValueType().getVisualMson((V) deletions, sender), null));
}
message(messages);
}
Aggregations