001/* 002 * PermissionsEx 003 * Copyright (C) zml and PermissionsEx contributors 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package ca.stellardrift.permissionsex.minecraft.profile; 018 019import com.google.gson.annotations.SerializedName; 020import net.kyori.adventure.identity.Identity; 021import net.kyori.examination.ExaminableProperty; 022import org.immutables.gson.Gson; 023import org.immutables.value.Value; 024 025import java.util.UUID; 026import java.util.stream.Stream; 027 028/** 029 * A profile containing user data for a Minecraft user. 030 * 031 * @since 2.0.0 032 */ 033@Gson.TypeAdapters 034@Value.Immutable(copy = false) 035public interface MinecraftProfile extends Identity { 036 037 /** 038 * Create a new builder for a profile object. 039 * @return new profile builder 040 */ 041 static Builder builder() { 042 return new Builder(); 043 } 044 045 /** 046 * Create a new profile with the provided parameters. 047 * 048 * @param uuid unique ID 049 * @param name player name 050 * @return a new profile 051 * @since 2.0.0 052 */ 053 static MinecraftProfile of(final UUID uuid, final String name) { 054 return new MinecraftProfileImpl(uuid, name); 055 } 056 057 /** 058 * The unique identifier for a user. 059 * 060 * @return user id 061 * @since 2.0.0 062 */ 063 @Override 064 @Value.Parameter 065 @SerializedName("id") 066 UUID uuid(); 067 068 /** 069 * The changeable name for a user. 070 * 071 * @return user name 072 * @since 2.0.0 073 */ 074 @Value.Parameter 075 String name(); 076 077 @Override 078 default String examinableName() { 079 return MinecraftProfile.class.getSimpleName(); 080 } 081 082 @Override 083 default Stream<? extends ExaminableProperty> examinableProperties() { 084 return Stream.of( 085 ExaminableProperty.of("uuid", this.uuid()), 086 ExaminableProperty.of("name", this.name()) 087 ); 088 } 089 090 class Builder extends MinecraftProfileImpl.Builder {} 091}