use of com.massivecraft.massivecore.command.type.Type in project MassiveCore by MassiveCraft.
the class EngineMassiveCoreCommandSet method setValue.
public <T extends Serializable> void setValue(EventMassiveCoreCommandSet<T> event) throws MassiveException {
String senderId = event.getSenderId();
String targetId = event.getTargetId();
T after = event.getValue();
PlayerValue<T> playerValue = event.getPlayerValue();
String name = event.getName();
Player player = IdUtil.getPlayer(targetId);
if (player == null)
return;
T before = playerValue.getValue(player);
Type<T> type = (Type<T>) RegistryType.getType(after.getClass());
String afterDesc = type.getVisual(after);
String targetDesc = this.getTargetDesc(targetId, senderId, name);
// NoChange
if (after == before) {
throw new MassiveException().addMsg("%s<i> is already <h>%s<i>.", targetDesc, afterDesc);
}
// Apply
playerValue.setValue(after, player);
// Inform
MixinMessage.get().msgOne(senderId, "%s<i> is now <h>%s<i>.", targetDesc, afterDesc);
// Inform target
if (!targetId.equals(senderId)) {
MixinMessage.get().msgOne(targetId, "%s<i> is now <h>%s<i>.", getTargetDesc(targetId, targetId, name), afterDesc);
}
}
use of com.massivecraft.massivecore.command.type.Type 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());
}
Aggregations